Bluetooth: Enable passive scanning whenever we're connectable
authorJohan Hedberg <johan.hedberg@intel.com>
Mon, 7 Jul 2014 11:40:22 +0000 (14:40 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 7 Jul 2014 11:53:03 +0000 (13:53 +0200)
Enabling passive scanning always when we're connectable aligns us with
the BR/EDR page scanning. This is also consistent with the fact that the
code dealing with passive scanning results will actively try to connect
any direct advertising event when we're connectable.

This patch implements the feature by adding the connectable condition to
hci_update_background_scan() checks for starting scanning and by calling
hci_update_background_scan() whenever the connectable state changes.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/hci_core.c
net/bluetooth/mgmt.c

index 4f8ba49ac49d134132a448de4a10927346d116de..6790dc8cff991ec9905113d0b7df0b5b1f004175 100644 (file)
@@ -5409,7 +5409,8 @@ void hci_update_background_scan(struct hci_dev *hdev)
 
        hci_req_init(&req, hdev);
 
-       if (list_empty(&hdev->pend_le_conns) &&
+       if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags) &&
+           list_empty(&hdev->pend_le_conns) &&
            list_empty(&hdev->pend_le_reports)) {
                /* If there is no pending LE connections or devices
                 * to be scanned for, we should stop the background
index 40244fc0e3268b0e2ecf9669dfefa155005ae163..ef675acbcfcea76b4b208fd337f1e4178c895728 100644 (file)
@@ -1750,8 +1750,10 @@ static void set_connectable_complete(struct hci_dev *hdev, u8 status)
 
        send_settings_rsp(cmd->sk, MGMT_OP_SET_CONNECTABLE, hdev);
 
-       if (changed)
+       if (changed) {
                new_settings(hdev, cmd->sk);
+               hci_update_background_scan(hdev);
+       }
 
 remove_cmd:
        mgmt_pending_remove(cmd);