提交 2519a1fc 编写于 作者: A Andre Guedes 提交者: Gustavo F. Padovan

Bluetooth: Create hci_do_inquiry()

This patch adds a function to hci_core to carry out inquiry.

All inquiry code from start_discovery() were replaced by a
hci_do_inquiry() call.
Signed-off-by: NAndre Guedes <andre.guedes@openbossa.org>
Signed-off-by: NGustavo F. Padovan <padovan@profusion.mobi>
上级 66af7aaf
...@@ -970,4 +970,6 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], ...@@ -970,4 +970,6 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]);
void hci_le_ltk_neg_reply(struct hci_conn *conn); void hci_le_ltk_neg_reply(struct hci_conn *conn);
int hci_do_inquiry(struct hci_dev *hdev, u8 length);
#endif /* __HCI_CORE_H */ #endif /* __HCI_CORE_H */
...@@ -2560,3 +2560,21 @@ static void hci_cmd_task(unsigned long arg) ...@@ -2560,3 +2560,21 @@ static void hci_cmd_task(unsigned long arg)
} }
} }
} }
int hci_do_inquiry(struct hci_dev *hdev, u8 length)
{
/* General inquiry access code (GIAC) */
u8 lap[3] = { 0x33, 0x8b, 0x9e };
struct hci_cp_inquiry cp;
BT_DBG("%s", hdev->name);
if (test_bit(HCI_INQUIRY, &hdev->flags))
return -EINPROGRESS;
memset(&cp, 0, sizeof(cp));
memcpy(&cp.lap, lap, sizeof(cp.lap));
cp.length = length;
return hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp);
}
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#define MGMT_VERSION 0 #define MGMT_VERSION 0
#define MGMT_REVISION 1 #define MGMT_REVISION 1
#define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */
struct pending_cmd { struct pending_cmd {
struct list_head list; struct list_head list;
__u16 opcode; __u16 opcode;
...@@ -1598,8 +1600,6 @@ static int remove_remote_oob_data(struct sock *sk, u16 index, ...@@ -1598,8 +1600,6 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,
static int start_discovery(struct sock *sk, u16 index) static int start_discovery(struct sock *sk, u16 index)
{ {
u8 lap[3] = { 0x33, 0x8b, 0x9e };
struct hci_cp_inquiry cp;
struct pending_cmd *cmd; struct pending_cmd *cmd;
struct hci_dev *hdev; struct hci_dev *hdev;
int err; int err;
...@@ -1618,12 +1618,7 @@ static int start_discovery(struct sock *sk, u16 index) ...@@ -1618,12 +1618,7 @@ static int start_discovery(struct sock *sk, u16 index)
goto failed; goto failed;
} }
memset(&cp, 0, sizeof(cp)); err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR);
memcpy(&cp.lap, lap, 3);
cp.length = 0x08;
cp.num_rsp = 0x00;
err = hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp);
if (err < 0) if (err < 0)
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册