summaryrefslogtreecommitdiff
path: root/emulator/bthost.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2015-05-14 12:50:28 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2015-05-17 10:39:00 +0300
commitf41312b893d017f4ea2e85b9bb0a06f60ecd7516 (patch)
treefb1b05e5fd0e3e56a32679e6626fb01aafe9ffce /emulator/bthost.c
parentcf8c7401a0caa237824c2adcdfb428b304a9984e (diff)
downloadbluez-f41312b893d017f4ea2e85b9bb0a06f60ecd7516.tar.gz
emulator/bthost: Add support for setting custom ADV data
This allows to set any ADV data and not just flags.
Diffstat (limited to 'emulator/bthost.c')
-rw-r--r--emulator/bthost.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 2b48ad8f6..29bbe5d1a 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -2279,30 +2279,29 @@ void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
send_command(bthost, BT_HCI_CMD_WRITE_SCAN_ENABLE, &scan, 1);
}
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable, uint8_t flags)
+void bthost_set_adv_data(struct bthost *bthost, const uint8_t *data,
+ uint8_t len)
{
- struct bt_hci_cmd_le_set_adv_parameters cp;
-
- memset(&cp, 0, sizeof(cp));
- send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
- &cp, sizeof(cp));
+ struct bt_hci_cmd_le_set_adv_data adv_cp;
- if (flags) {
- struct bt_hci_cmd_le_set_adv_data adv_cp;
+ memset(adv_cp.data, 0, 31);
- memset(adv_cp.data, 0, 31);
-
- adv_cp.data[0] = 0x02; /* Field length */
- adv_cp.data[1] = 0x01; /* Flags */
- adv_cp.data[2] = flags;
+ if (len) {
+ adv_cp.len = len;
+ memcpy(adv_cp.data, data, len);
+ }
- adv_cp.data[3] = 0x00; /* Field terminator */
+ send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
+ sizeof(adv_cp));
+}
- adv_cp.len = 1 + adv_cp.data[0];
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
+{
+ struct bt_hci_cmd_le_set_adv_parameters cp;
- send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
- sizeof(adv_cp));
- }
+ memset(&cp, 0, sizeof(cp));
+ send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
+ &cp, sizeof(cp));
send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1);
}