From: Jefferson Delfes <jefferson.delfes@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Jefferson Delfes <jefferson.delfes@openbossa.org>
Subject: [PATCH BlueZ 6/6] emulator: Implement LE advertising report
Date: Wed, 3 Jul 2013 16:54:56 -0400 [thread overview]
Message-ID: <1372884896-11419-7-git-send-email-jefferson.delfes@openbossa.org> (raw)
In-Reply-To: <1372884896-11419-1-git-send-email-jefferson.delfes@openbossa.org>
When a virtual device starts a LE advertising, emulator searches for
other virtual devices that are in scan mode, in order to send adv data
to these devices.
Inverse goes when LE scan is enabled. Emulator searches virtual devices
that are in advertising mode and copy adv data to them.
---
emulator/btdev.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/emulator/btdev.c b/emulator/btdev.c
index c98a20d..79d2f0e 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -811,6 +811,60 @@ static void remote_version_complete(struct btdev *btdev, uint16_t handle)
&rvc, sizeof(rvc));
}
+static void le_send_adv_report(struct btdev *btdev, const struct btdev *remote)
+{
+ struct __packed {
+ uint8_t subevent;
+ union {
+ struct bt_hci_evt_le_adv_report lar;
+ uint8_t raw[10 + 31 + 1];
+ };
+ } meta_event;
+
+ meta_event.subevent = BT_HCI_EVT_LE_ADV_REPORT;
+
+ memset(&meta_event.lar, 0, sizeof(meta_event.lar));
+ meta_event.lar.num_reports = 1;
+ memcpy(meta_event.lar.addr, remote->bdaddr, 6);
+ meta_event.lar.data_len = remote->le_adv_data_len;
+ memcpy(meta_event.lar.data, remote->le_adv_data,
+ meta_event.lar.data_len);
+ /* Not available */
+ meta_event.raw[10 + meta_event.lar.data_len] = 127;
+ send_event(btdev, BT_HCI_EVT_LE_META_EVENT, &meta_event,
+ 1 + 10 + meta_event.lar.data_len + 1);
+}
+
+static void le_set_adv_enable_complete(struct btdev *btdev)
+{
+ int i;
+
+ for (i = 0; i < MAX_BTDEV_ENTRIES; i++) {
+ if (!btdev_list[i] || btdev_list[i] == btdev)
+ continue;
+
+ if (!btdev_list[i]->le_scan_enable)
+ continue;
+
+ le_send_adv_report(btdev_list[i], btdev);
+ }
+}
+
+static void le_set_scan_enable_complete(struct btdev *btdev)
+{
+ int i;
+
+ for (i = 0; i < MAX_BTDEV_ENTRIES; i++) {
+ if (!btdev_list[i] || btdev_list[i] == btdev)
+ continue;
+
+ if (!btdev_list[i]->le_adv_enable)
+ continue;
+
+ le_send_adv_report(btdev, btdev_list[i]);
+ }
+}
+
static void default_cmd(struct btdev *btdev, uint16_t opcode,
const void *data, uint8_t len)
{
@@ -1480,6 +1534,8 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode,
status = BT_HCI_ERR_SUCCESS;
}
cmd_complete(btdev, opcode, &status, sizeof(status));
+ if (status == BT_HCI_ERR_SUCCESS && btdev->le_adv_enable)
+ le_set_adv_enable_complete(btdev);
break;
case BT_HCI_CMD_LE_SET_SCAN_PARAMETERS:
@@ -1504,6 +1560,8 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode,
status = BT_HCI_ERR_SUCCESS;
}
cmd_complete(btdev, opcode, &status, sizeof(status));
+ if (status == BT_HCI_ERR_SUCCESS && btdev->le_scan_enable)
+ le_set_scan_enable_complete(btdev);
break;
case BT_HCI_CMD_LE_READ_WHITE_LIST_SIZE:
--
1.8.3.2
next prev parent reply other threads:[~2013-07-03 20:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 20:54 [PATCH BlueZ 0/6] emulator: add LE advertising and scanning support Jefferson Delfes
2013-07-03 20:54 ` [PATCH BlueZ 1/6] emulator: Store LE advertising data length in btdev Jefferson Delfes
2013-07-03 20:54 ` [PATCH BlueZ 2/6] emulator: Implement basic LE set adv enable command Jefferson Delfes
2013-07-03 20:54 ` [PATCH BlueZ 3/6] emulator: Store LE scan state of virtual controller Jefferson Delfes
2013-07-03 20:54 ` [PATCH BlueZ 4/6] emulator: Disallow LE set scan params command when scan is enabled Jefferson Delfes
2013-07-03 20:54 ` [PATCH BlueZ 5/6] emulator: Dummy LE set advertising parameters Jefferson Delfes
2013-07-03 20:54 ` Jefferson Delfes [this message]
[not found] ` <51d54149.42a5420a.2de5.6abcSMTPIN_ADDED_BROKEN@mx.google.com>
2013-07-04 17:15 ` [PATCH BlueZ 0/6] emulator: add LE advertising and scanning support Jefferson Delfes
2013-07-05 9:00 ` Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372884896-11419-7-git-send-email-jefferson.delfes@openbossa.org \
--to=jefferson.delfes@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).