提交 3fd24153 编写于 作者: A Andre Guedes 提交者: Johan Hedberg

Bluetooth: MGMT start discovery LE-Only support

This patch adds LE-Only discovery procedure support to MGMT Start
Discovery command.
Signed-off-by: NAndre Guedes <andre.guedes@openbossa.org>
Acked-by: NMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
上级 28b75a89
...@@ -1033,6 +1033,13 @@ static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -1033,6 +1033,13 @@ static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb)
BT_DBG("%s status 0x%x", hdev->name, status); BT_DBG("%s status 0x%x", hdev->name, status);
hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_PARAM, status); hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_PARAM, status);
if (status) {
hci_dev_lock(hdev);
mgmt_start_discovery_failed(hdev, status);
hci_dev_unlock(hdev);
return;
}
} }
static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, static 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,8 +1058,12 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
case LE_SCANNING_ENABLED: case LE_SCANNING_ENABLED:
hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_ENABLE, status); hci_req_complete(hdev, HCI_OP_LE_SET_SCAN_ENABLE, status);
if (status) if (status) {
hci_dev_lock(hdev);
mgmt_start_discovery_failed(hdev, status);
hci_dev_unlock(hdev);
return; return;
}
set_bit(HCI_LE_SCAN, &hdev->dev_flags); set_bit(HCI_LE_SCAN, &hdev->dev_flags);
......
...@@ -35,6 +35,15 @@ ...@@ -35,6 +35,15 @@
#define MGMT_VERSION 0 #define MGMT_VERSION 0
#define MGMT_REVISION 1 #define MGMT_REVISION 1
/*
* These LE scan and inquiry parameters were chosen according to LE General
* Discovery Procedure specification.
*/
#define LE_SCAN_TYPE 0x01
#define LE_SCAN_WIN 0x12
#define LE_SCAN_INT 0x12
#define LE_SCAN_TIMEOUT_LE_ONLY 10240 /* TGAP(gen_disc_scan_min) */
#define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ #define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */
#define SERVICE_CACHE_TIMEOUT (5 * 1000) #define SERVICE_CACHE_TIMEOUT (5 * 1000)
...@@ -1916,6 +1925,7 @@ static int start_discovery(struct sock *sk, u16 index, ...@@ -1916,6 +1925,7 @@ static int start_discovery(struct sock *sk, u16 index,
void *data, u16 len) void *data, u16 len)
{ {
struct mgmt_cp_start_discovery *cp = data; struct mgmt_cp_start_discovery *cp = data;
unsigned long discov_type = cp->type;
struct pending_cmd *cmd; struct pending_cmd *cmd;
struct hci_dev *hdev; struct hci_dev *hdev;
int err; int err;
...@@ -1951,7 +1961,15 @@ static int start_discovery(struct sock *sk, u16 index, ...@@ -1951,7 +1961,15 @@ static int start_discovery(struct sock *sk, u16 index,
goto failed; goto failed;
} }
if (test_bit(MGMT_ADDR_BREDR, &discov_type))
err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR);
else if (test_bit(MGMT_ADDR_LE_PUBLIC, &discov_type) &&
test_bit(MGMT_ADDR_LE_RANDOM, &discov_type))
err = hci_le_scan(hdev, LE_SCAN_TYPE, LE_SCAN_INT,
LE_SCAN_WIN, LE_SCAN_TIMEOUT_LE_ONLY);
else
err = -EINVAL;
if (err < 0) if (err < 0)
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册