diff options
author | Andre Guedes <andre.guedes@openbossa.org> | 2012-02-03 15:47:59 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-13 10:01:34 -0500 |
commit | 7ba8b4be38e7c83b2b13333a82a0ecde921a7390 (patch) | |
tree | 1ad9bb8b0eafed266538a2e238649149439ccc29 /net/bluetooth/hci_event.c | |
parent | 6fbe195dc41c4fae1fa7aca1a38c888de1d24e2d (diff) |
Bluetooth: Add hci_do_le_scan()
This patch adds to hci_core the hci_do_le_scan function which
should be used to scan LE devices.
In order to enable LE scan, hci_do_le_scan() sends commands (Set
LE Scan Parameters and Set LE Scan Enable) to the controller and
waits for its results. If commands were executed successfully a
delayed work is scheduled to disable the ongoing scanning after
some amount of time. This function blocks.
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>
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r-- | net/bluetooth/hci_event.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8971c18205c0..97152d9d7116 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1031,6 +1031,8 @@ static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb) | |||
1031 | __u8 status = *((__u8 *) skb->data); | 1031 | __u8 status = *((__u8 *) skb->data); |
1032 | 1032 | ||
1033 | BT_DBG("%s status 0x%x", hdev->name, status); | 1033 | BT_DBG("%s status 0x%x", hdev->name, status); |
1034 | |||
1035 | hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_PARAM, status); | ||
1034 | } | 1036 | } |
1035 | 1037 | ||
1036 | static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, | 1038 | static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, |
@@ -1041,15 +1043,17 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, | |||
1041 | 1043 | ||
1042 | BT_DBG("%s status 0x%x", hdev->name, status); | 1044 | BT_DBG("%s status 0x%x", hdev->name, status); |
1043 | 1045 | ||
1044 | if (status) | ||
1045 | return; | ||
1046 | |||
1047 | cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); | 1046 | cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_SCAN_ENABLE); |
1048 | if (!cp) | 1047 | if (!cp) |
1049 | return; | 1048 | return; |
1050 | 1049 | ||
1051 | switch (cp->enable) { | 1050 | switch (cp->enable) { |
1052 | case LE_SCANNING_ENABLED: | 1051 | case LE_SCANNING_ENABLED: |
1052 | hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_ENABLE, status); | ||
1053 | |||
1054 | if (status) | ||
1055 | return; | ||
1056 | |||
1053 | set_bit(HCI_LE_SCAN, &hdev->dev_flags); | 1057 | set_bit(HCI_LE_SCAN, &hdev->dev_flags); |
1054 | 1058 | ||
1055 | cancel_delayed_work_sync(&hdev->adv_work); | 1059 | cancel_delayed_work_sync(&hdev->adv_work); |
@@ -1061,6 +1065,9 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, | |||
1061 | break; | 1065 | break; |
1062 | 1066 | ||
1063 | case LE_SCANNING_DISABLED: | 1067 | case LE_SCANNING_DISABLED: |
1068 | if (status) | ||
1069 | return; | ||
1070 | |||
1064 | clear_bit(HCI_LE_SCAN, &hdev->dev_flags); | 1071 | clear_bit(HCI_LE_SCAN, &hdev->dev_flags); |
1065 | 1072 | ||
1066 | hci_dev_lock(hdev); | 1073 | hci_dev_lock(hdev); |