浏览代码

Bluetooth: LE scan should send Discovering events

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>
Andre Guedes 13 年之前
父节点
当前提交
c599008f8f
共有 3 个文件被更改,包括 8 次插入0 次删除
  1. 1 0
      include/net/bluetooth/hci_core.h
  2. 2 0
      net/bluetooth/hci_core.c
  3. 5 0
      net/bluetooth/hci_event.c

+ 1 - 0
include/net/bluetooth/hci_core.h

@@ -61,6 +61,7 @@ struct discovery_state {
 		DISCOVERY_STOPPED,
 		DISCOVERY_STOPPED,
 		DISCOVERY_STARTING,
 		DISCOVERY_STARTING,
 		DISCOVERY_INQUIRY,
 		DISCOVERY_INQUIRY,
+		DISCOVERY_LE_SCAN,
 		DISCOVERY_RESOLVING,
 		DISCOVERY_RESOLVING,
 		DISCOVERY_STOPPING,
 		DISCOVERY_STOPPING,
 	} state;
 	} state;

+ 2 - 0
net/bluetooth/hci_core.c

@@ -361,6 +361,7 @@ bool hci_discovery_active(struct hci_dev *hdev)
 	struct discovery_state *discov = &hdev->discovery;
 	struct discovery_state *discov = &hdev->discovery;
 
 
 	if (discov->state == DISCOVERY_INQUIRY ||
 	if (discov->state == DISCOVERY_INQUIRY ||
+					discov->state == DISCOVERY_LE_SCAN ||
 					discov->state == DISCOVERY_RESOLVING)
 					discov->state == DISCOVERY_RESOLVING)
 		return true;
 		return true;
 
 
@@ -381,6 +382,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
 	case DISCOVERY_STARTING:
 	case DISCOVERY_STARTING:
 		break;
 		break;
 	case DISCOVERY_INQUIRY:
 	case DISCOVERY_INQUIRY:
+	case DISCOVERY_LE_SCAN:
 		mgmt_discovering(hdev, 1);
 		mgmt_discovering(hdev, 1);
 		break;
 		break;
 	case DISCOVERY_RESOLVING:
 	case DISCOVERY_RESOLVING:

+ 5 - 0
net/bluetooth/hci_event.c

@@ -1056,12 +1056,17 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
 
 
 		hci_dev_lock(hdev);
 		hci_dev_lock(hdev);
 		hci_adv_entries_clear(hdev);
 		hci_adv_entries_clear(hdev);
+		hci_discovery_set_state(hdev, DISCOVERY_LE_SCAN);
 		hci_dev_unlock(hdev);
 		hci_dev_unlock(hdev);
 		break;
 		break;
 
 
 	case LE_SCANNING_DISABLED:
 	case LE_SCANNING_DISABLED:
 		clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
 		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);
 		schedule_delayed_work(&hdev->adv_work, ADV_CLEAR_TIMEOUT);
 		break;
 		break;