From 2029fd56dbf091dae417a5eae4daf7ed98af0c9b Mon Sep 17 00:00:00 2001 From: Sudha Bheemanna Date: Thu, 8 Sep 2016 11:21:06 +0530 Subject: [PATCH] Bluetooth: Set filter policy for LE connection This patch sets the filter policy to a default value 0x01 during LE auto connection if the destination address is not set. And it updates the destination address once the LE connection complete event is recieved during LE auto connection. And for it checks valid destination address before cancelling LE connection when connection timeout occurs. Change-Id: I9877556c0b0ab4826f5f4934ead4d85b7837036d Signed-off-by: Sudha Bheemanna [squash patches, LE connection policy, set dest address and check dest address before cancelling connection] Signed-off-by: Seung-Woo Kim Signed-off-by: Amit Purwar --- net/bluetooth/hci_conn.c | 8 ++++++++ net/bluetooth/hci_event.c | 4 ++++ net/bluetooth/hci_request.c | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 5570a86..79476c5 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -866,7 +866,15 @@ static void hci_req_add_le_create_conn(struct hci_request *req, cp.scan_interval = cpu_to_le16(hdev->le_scan_interval); cp.scan_window = cp.scan_interval; +#ifdef TIZEN_BT + /* LE auto connect */ + if (!bacmp(&conn->dst, BDADDR_ANY)) + cp.filter_policy = 0x1; + else bacpy(&cp.peer_addr, &conn->dst); +#else + bacpy(&cp.peer_addr, &conn->dst); +#endif cp.peer_addr_type = conn->dst_type; cp.own_address_type = own_addr_type; cp.conn_interval_min = cpu_to_le16(conn->le_conn_min_interval); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6261613..78ce5f6 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4978,6 +4978,10 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, } } } else { +#ifdef TIZEN_BT + /* LE auto connect */ + bacpy(&conn->dst, bdaddr); +#endif cancel_delayed_work(&conn->le_conn_timeout); } diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index b0ff47c..010c857 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -2222,7 +2222,11 @@ void __hci_abort_conn(struct hci_request *req, struct hci_conn *conn, break; case BT_CONNECT: +#ifdef TIZEN_BT + if (conn->type == LE_LINK && bacmp(&conn->dst, BDADDR_ANY)) { +#else if (conn->type == LE_LINK) { +#endif if (test_bit(HCI_CONN_SCANNING, &conn->flags)) break; hci_req_add(req, HCI_OP_LE_CREATE_CONN_CANCEL, -- 2.7.4