aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2014-03-10 17:26:24 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-03-11 15:59:04 -0400
commit4340a124dea6a6a66c7889261574a48e57e8782a (patch)
tree3fea5fd906992484fd1b49d17feb816996b70d92 /net/bluetooth
parent27539bc441c833c958de1d0c04212cb78b2a08b0 (diff)
Bluetooth: Enable duplicates filter in background scan
To avoid flooding the host with useless advertising reports during background scan, we enable the duplicates filter from controller. However, enabling duplicates filter requires a small change in background scan routine in order to fix the following scenario: 1) Background scan is running. 2) A device disconnects and starts advertising. 3) Before host gets the disconnect event, the advertising is reported to host. Since there is no pending LE connection at that time, nothing happens. 4) Host gets the disconnection event and adds a pending connection. 5) No advertising is reported (since controller is filtering) and the connection is never established. So, to address this scenario, we should always restart background scan to unsure we don't miss any advertising report (due to duplicates filter). Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_core.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8bbfdea9cbec..a27d0b86ba1e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -5270,7 +5270,7 @@ void hci_req_add_le_passive_scan(struct hci_request *req)
5270 5270
5271 memset(&enable_cp, 0, sizeof(enable_cp)); 5271 memset(&enable_cp, 0, sizeof(enable_cp));
5272 enable_cp.enable = LE_SCAN_ENABLE; 5272 enable_cp.enable = LE_SCAN_ENABLE;
5273 enable_cp.filter_dup = LE_SCAN_FILTER_DUP_DISABLE; 5273 enable_cp.filter_dup = LE_SCAN_FILTER_DUP_ENABLE;
5274 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(enable_cp), 5274 hci_req_add(req, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(enable_cp),
5275 &enable_cp); 5275 &enable_cp);
5276} 5276}
@@ -5313,10 +5313,6 @@ void hci_update_background_scan(struct hci_dev *hdev)
5313 * keep the background scan running. 5313 * keep the background scan running.
5314 */ 5314 */
5315 5315
5316 /* If controller is already scanning we are done. */
5317 if (test_bit(HCI_LE_SCAN, &hdev->dev_flags))
5318 return;
5319
5320 /* If controller is connecting, we should not start scanning 5316 /* If controller is connecting, we should not start scanning
5321 * since some controllers are not able to scan and connect at 5317 * since some controllers are not able to scan and connect at
5322 * the same time. 5318 * the same time.
@@ -5325,6 +5321,12 @@ void hci_update_background_scan(struct hci_dev *hdev)
5325 if (conn) 5321 if (conn)
5326 return; 5322 return;
5327 5323
5324 /* If controller is currently scanning, we stop it to ensure we
5325 * don't miss any advertising (due to duplicates filter).
5326 */
5327 if (test_bit(HCI_LE_SCAN, &hdev->dev_flags))
5328 hci_req_add_le_scan_disable(&req);
5329
5328 hci_req_add_le_passive_scan(&req); 5330 hci_req_add_le_passive_scan(&req);
5329 5331
5330 BT_DBG("%s starting background scanning", hdev->name); 5332 BT_DBG("%s starting background scanning", hdev->name);