aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2012-02-03 15:48:01 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 10:01:34 -0500
commit3fd2415363629b779549705f341e0645e32c1ad5 (patch)
tree4203df133dbbe7c65b7d4c1b0f63780c19afc276
parent28b75a89480df99a17c8facd5c33985847d06bb6 (diff)
Bluetooth: MGMT start discovery LE-Only support
This patch adds LE-Only discovery procedure support to MGMT Start Discovery command. 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>
-rw-r--r--net/bluetooth/hci_event.c13
-rw-r--r--net/bluetooth/mgmt.c20
2 files changed, 31 insertions, 2 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 97152d9d7116..ad5f37b13f77 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1033,6 +1033,13 @@ static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb)
1033 BT_DBG("%s status 0x%x", hdev->name, status); 1033 BT_DBG("%s status 0x%x", hdev->name, status);
1034 1034
1035 hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_PARAM, status); 1035 hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_PARAM, status);
1036
1037 if (status) {
1038 hci_dev_lock(hdev);
1039 mgmt_start_discovery_failed(hdev, status);
1040 hci_dev_unlock(hdev);
1041 return;
1042 }
1036} 1043}
1037 1044
1038static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, 1045static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
@@ -1051,8 +1058,12 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
1051 case LE_SCANNING_ENABLED: 1058 case LE_SCANNING_ENABLED:
1052 hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_ENABLE, status); 1059 hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_ENABLE, status);
1053 1060
1054 if (status) 1061 if (status) {
1062 hci_dev_lock(hdev);
1063 mgmt_start_discovery_failed(hdev, status);
1064 hci_dev_unlock(hdev);
1055 return; 1065 return;
1066 }
1056 1067
1057 set_bit(HCI_LE_SCAN, &hdev->dev_flags); 1068 set_bit(HCI_LE_SCAN, &hdev->dev_flags);
1058 1069
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 9e5dead1dbef..8c9de58779c7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -35,6 +35,15 @@
35#define MGMT_VERSION 0 35#define MGMT_VERSION 0
36#define MGMT_REVISION 1 36#define MGMT_REVISION 1
37 37
38/*
39 * These LE scan and inquiry parameters were chosen according to LE General
40 * Discovery Procedure specification.
41 */
42#define LE_SCAN_TYPE 0x01
43#define LE_SCAN_WIN 0x12
44#define LE_SCAN_INT 0x12
45#define LE_SCAN_TIMEOUT_LE_ONLY 10240 /* TGAP(gen_disc_scan_min) */
46
38#define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ 47#define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */
39 48
40#define SERVICE_CACHE_TIMEOUT (5 * 1000) 49#define SERVICE_CACHE_TIMEOUT (5 * 1000)
@@ -1916,6 +1925,7 @@ static int start_discovery(struct sock *sk, u16 index,
1916 void *data, u16 len) 1925 void *data, u16 len)
1917{ 1926{
1918 struct mgmt_cp_start_discovery *cp = data; 1927 struct mgmt_cp_start_discovery *cp = data;
1928 unsigned long discov_type = cp->type;
1919 struct pending_cmd *cmd; 1929 struct pending_cmd *cmd;
1920 struct hci_dev *hdev; 1930 struct hci_dev *hdev;
1921 int err; 1931 int err;
@@ -1951,7 +1961,15 @@ static int start_discovery(struct sock *sk, u16 index,
1951 goto failed; 1961 goto failed;
1952 } 1962 }
1953 1963
1954 err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); 1964 if (test_bit(MGMT_ADDR_BREDR, &discov_type))
1965 err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR);
1966 else if (test_bit(MGMT_ADDR_LE_PUBLIC, &discov_type) &&
1967 test_bit(MGMT_ADDR_LE_RANDOM, &discov_type))
1968 err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT,
1969 LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY);
1970 else
1971 err = -EINVAL;
1972
1955 if (err < 0) 1973 if (err < 0)
1956 mgmt_pending_remove(cmd); 1974 mgmt_pending_remove(cmd);
1957 else 1975 else