summaryrefslogtreecommitdiff
path: root/emulator/le.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2015-07-14 23:25:45 +0200
committerMarcel Holtmann <marcel@holtmann.org>2015-07-14 23:25:45 +0200
commit838abde25be799cc3493867bf97d8b624499312f (patch)
tree7ab1b5daf7f20994e2da20fc416bf5aefc839f0a /emulator/le.c
parent81596d12b173a4d53e8fcf04a775ce3c6573d5e9 (diff)
downloadbluez-838abde25be799cc3493867bf97d8b624499312f.tar.gz
emulator: Add support for scanning on different channels
Diffstat (limited to 'emulator/le.c')
-rw-r--r--emulator/le.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/emulator/le.c b/emulator/le.c
index 6ffa0d4a1..82ae573f4 100644
--- a/emulator/le.c
+++ b/emulator/le.c
@@ -71,6 +71,7 @@ struct bt_le {
int adv_timeout_id;
int scan_timeout_id;
bool scan_window_active;
+ uint8_t scan_chan_idx;
uint8_t event_mask[16];
uint16_t manufacturer;
@@ -424,11 +425,12 @@ static void send_event(struct bt_le *hci, uint8_t event,
fprintf(stderr, "Write to /dev/vhci failed (%m)\n");
}
-static void send_adv_pkt(struct bt_le *hci)
+static void send_adv_pkt(struct bt_le *hci, uint8_t channel)
{
struct bt_phy_pkt_adv pkt;
memset(&pkt, 0, sizeof(pkt));
+ pkt.chan_idx = channel;
pkt.pdu_type = hci->le_adv_type;
pkt.tx_addr_type = hci->le_adv_own_addr_type;
switch (hci->le_adv_own_addr_type) {
@@ -465,7 +467,12 @@ static void adv_timeout_callback(int id, void *user_data)
struct bt_le *hci = user_data;
unsigned int msec, min_msec, max_msec;
- send_adv_pkt(hci);
+ if (hci->le_adv_channel_map & 0x01)
+ send_adv_pkt(hci, 37);
+ if (hci->le_adv_channel_map & 0x02)
+ send_adv_pkt(hci, 38);
+ if (hci->le_adv_channel_map & 0x04)
+ send_adv_pkt(hci, 39);
min_msec = (hci->le_adv_min_interval * 625) / 1000;
max_msec = (hci->le_adv_max_interval * 625) / 1000;
@@ -515,6 +522,10 @@ static void scan_timeout_callback(int id, void *user_data)
!hci->scan_window_active) {
msec = (hci->le_scan_window * 625) / 1000;
hci->scan_window_active = true;
+
+ hci->scan_chan_idx++;
+ if (hci->scan_chan_idx > 39)
+ hci->scan_chan_idx = 37;
} else {
msec = ((hci->le_scan_interval -
hci->le_scan_window) * 625) / 1000;
@@ -543,6 +554,7 @@ static bool start_scan(struct bt_le *hci)
return false;
hci->scan_window_active = true;
+ hci->scan_chan_idx = 37;
return true;
}
@@ -1796,6 +1808,9 @@ static void phy_recv_callback(uint16_t type, const void *data,
struct bt_hci_evt_le_adv_report *evt = (void *) buf;
uint8_t tx_addr_type, tx_addr[6];
+ if (hci->scan_chan_idx != pkt->chan_idx)
+ break;
+
resolve_peer_addr(hci, pkt->tx_addr_type, pkt->tx_addr,
&tx_addr_type, tx_addr);