Bluetooth: LE scan should send Discovering events
authorAndre Guedes <andre.guedes@openbossa.org>
Fri, 3 Feb 2012 20:47:57 +0000 (17:47 -0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 13 Feb 2012 15:01:34 +0000 (17:01 +0200)
Send MGMT Discovering events once LE scan starts/stops so the
userspace can track when local adapters are discovering LE devices.

This way, we also keep the same behavior of inquiry which sends MGMT
Discovering events once inquiry starts/stops even if it is triggered
by an external tool (e.g. hcitool).

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c

index 9751da78341d31bac2f570849efdaf301c106e98..bf2ef56678875aa74a68f9413a4615dfa79492ef 100644 (file)
@@ -61,6 +61,7 @@ struct discovery_state {
                DISCOVERY_STOPPED,
                DISCOVERY_STARTING,
                DISCOVERY_INQUIRY,
+               DISCOVERY_LE_SCAN,
                DISCOVERY_RESOLVING,
                DISCOVERY_STOPPING,
        } state;
index 8bffd3eb344d3271d4b2527de07824ca6b61a61d..1705d9372725f5d9b7af2aeb40b65124b0ea3b7e 100644 (file)
@@ -361,6 +361,7 @@ bool hci_discovery_active(struct hci_dev *hdev)
        struct discovery_state *discov = &hdev->discovery;
 
        if (discov->state == DISCOVERY_INQUIRY ||
+                                       discov->state == DISCOVERY_LE_SCAN ||
                                        discov->state == DISCOVERY_RESOLVING)
                return true;
 
@@ -381,6 +382,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
        case DISCOVERY_STARTING:
                break;
        case DISCOVERY_INQUIRY:
+       case DISCOVERY_LE_SCAN:
                mgmt_discovering(hdev, 1);
                break;
        case DISCOVERY_RESOLVING:
index 23dbb31f0423e8ee7f7e667a9c13ebfa5c4a5fe5..8971c18205c06f443984edbf812dccea9f4905da 100644 (file)
@@ -1056,12 +1056,17 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
 
                hci_dev_lock(hdev);
                hci_adv_entries_clear(hdev);
+               hci_discovery_set_state(hdev, DISCOVERY_LE_SCAN);
                hci_dev_unlock(hdev);
                break;
 
        case LE_SCANNING_DISABLED:
                clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
 
+               hci_dev_lock(hdev);
+               hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
+               hci_dev_unlock(hdev);
+
                schedule_delayed_work(&hdev->adv_work, ADV_CLEAR_TIMEOUT);
                break;