From 352f3ad61db5a1ae6cb340f89692c64082e07275 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 29 Jan 2013 11:09:26 -0600 Subject: [PATCH] core: Add a variable to track passive scanning This patch adds a state variable to track passive scanning and ensures that LE connections are only created through this discovery procedure and not the normal (StartDiscovery based) discovery procedure. --- src/adapter.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index aa66eb213..93cb269ed 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -163,6 +163,7 @@ struct btd_adapter { GSList *connections; /* Connected devices */ GSList *devices; /* Devices structure pointers */ GSList *connect_list; /* Devices to connect when found */ + bool passive_scanning; /* Passive (LE) scanning enabled */ sdp_list_t *services; /* Services associated to adapter */ bool toggle_discoverable; /* discoverable needs to be changed */ @@ -1113,6 +1114,7 @@ static void passive_scanning_complete(uint8_t status, uint16_t length, if (status == MGMT_STATUS_SUCCESS) { adapter->discovery_type = rp->type; adapter->discovery_enable = 0x01; + adapter->passive_scanning = true; } } @@ -1395,6 +1397,9 @@ static void discovering_callback(uint16_t index, uint16_t length, adapter->discovery_type = ev->type; adapter->discovery_enable = ev->discovering; + if (!adapter->discovery_enable) + adapter->passive_scanning = false; + /* * Check for existing discoveries triggered by client applications * and ignore all others. @@ -4070,6 +4075,10 @@ static void update_found_devices(struct btd_adapter *adapter, dev); done: + /* Don't trigger LE connections through normal discovery */ + if (!adapter->passive_scanning) + return; + if (device_is_le(dev) && !device_is_connected(dev) && g_slist_find(adapter->connect_list, dev)) { err = device_connect_le(dev); -- 2.47.3