Skip to contentSkip to conversation

Periodic Inquiry Handling

PATCH In review Andre Guedes 2 participants 6 messages Mar 21, 2012 – Mar 22, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Periodic Inquiry Handling

Hi all,

This patch series implements some Marcel's considerations about Periodic Inquiry handling.

The main points are:
* Track if periodic inquiry enabled or not;
* Fail start discovery if periodic inquiry is enabled;
* Ignore inquiry result events from periodic inquiry.

These considerations were given in "[PATCH v4 01/14] Bluetooth: Periodic Inquiry and mgmt discovering event" email.

BR,

Andre

Andre Guedes (4):
Bluetooth: Add Periodic Inquiry command complete handler
Bluetooth: Add HCI_PERIODIC_INQ to dev_flags
Bluetooth: Check HCI_PERIODIC_INQ in start_discovery
Bluetooth: Ignore inquiry results from periodic inquiry

 include/net/bluetooth/hci.h |    3 +++
 net/bluetooth/hci_event.c   |   30 +++++++++++++++++++++++++++++-
 net/bluetooth/mgmt.c        |    6 ++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.9.4
#1 lore raw

PATCH 1/4 Bluetooth: Add Periodic Inquiry command complete handler

This patch adds a handler function to Periodic Inquiry command complete event.

---
 include/net/bluetooth/hci.h |    2 ++
 net/bluetooth/hci_event.c   |   11 +++++++++++
 2 files changed, 13 insertions(+)
include/net/bluetooth/hci.h +2 -0
index dbbb593..d74645e 100644
@@ -324,6 +324,8 @@ struct hci_cp_inquiry {
 
 #define HCI_OP_INQUIRY_CANCEL		0x0402
 
+#define HCI_OP_PERIODIC_INQ		0x0403
+
 #define HCI_OP_EXIT_PERIODIC_INQ	0x0404
 
 #define HCI_OP_CREATE_CONN		0x0405
net/bluetooth/hci_event.c +11 -0
index 04d39f4..af0c5a2 100644
@@ -70,6 +70,13 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
 	hci_conn_check_pending(hdev);
 }
 
+static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	__u8 status = *((__u8 *) skb->data);
+
+	BT_DBG("%s status 0x%x", hdev->name, status);
+}
+
 static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
@@ -2154,6 +2161,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
 		hci_cc_inquiry_cancel(hdev, skb);
 		break;
 
+	case HCI_OP_PERIODIC_INQ:
+		hci_cc_periodic_inq(hdev, skb);
+		break;
+
 	case HCI_OP_EXIT_PERIODIC_INQ:
 		hci_cc_exit_periodic_inq(hdev, skb);
 		break;
Signature · 1 line
1.7.9.4
#2 lore raw

PATCH 2/4 Bluetooth: Add HCI_PERIODIC_INQ to dev_flags

In reply to Andre Guedes

This patch adds the HCI_PERIODIC_INQ flag to dev_flags. This flag tracks if periodic inquiry is enabled or not.

---
 include/net/bluetooth/hci.h |    1 +
 net/bluetooth/hci_event.c   |   10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
include/net/bluetooth/hci.h +1 -0
index d74645e..38ac0e6 100644
@@ -102,6 +102,7 @@ enum {
 	HCI_DISCOVERABLE,
 	HCI_LINK_SECURITY,
 	HCI_PENDING_CLASS,
+	HCI_PERIODIC_INQ,
 };
 
 /* HCI ioctl defines */
net/bluetooth/hci_event.c +9 -1
index af0c5a2..bffb0c3 100644
@@ -75,6 +75,11 @@ static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
 	__u8 status = *((__u8 *) skb->data);
 
 	BT_DBG("%s status 0x%x", hdev->name, status);
+
+	if (status)
+		return;
+
+	set_bit(HCI_PERIODIC_INQ, &hdev->dev_flags);
 }
 
 static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
@@ -86,6 +91,8 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
 	if (status)
 		return;
 
+	clear_bit(HCI_PERIODIC_INQ, &hdev->dev_flags);
+
 	hci_conn_check_pending(hdev);
 }
 
@@ -200,7 +207,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
 	hci_req_complete(hdev, HCI_OP_RESET, status);
 
 	/* Reset all non-persistent flags */
-	hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS));
+	hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS) |
+							BIT(HCI_PERIODIC_INQ));
 
 	hdev->discovery.state = DISCOVERY_STOPPED;
 }
Signature · 1 line
1.7.9.4
#3 lore raw

PATCH 3/4 Bluetooth: Check HCI_PERIODIC_INQ in start_discovery

In reply to Andre Guedes

This patch adds a HCI_PERIODIC_INQ check to start_discovery. If periodic inquiry is enabled, we fail MGMT Start Discovery command with MGMT_STATUS_BUSY code.

---
 net/bluetooth/mgmt.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/bluetooth/mgmt.c +6 -0
index d93f2bf..e399581 100644
@@ -2315,6 +2315,12 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
 		goto failed;
 	}
 
+	if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) {
+		err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
+				 MGMT_STATUS_BUSY);
+		goto failed;
+	}
+
 	if (hdev->discovery.state != DISCOVERY_STOPPED) {
 		err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
 				 MGMT_STATUS_BUSY);
Signature · 1 line
1.7.9.4
#4 lore raw

PATCH 4/4 Bluetooth: Ignore inquiry results from periodic inquiry

In reply to Andre Guedes

This patch changes inquiry result function handlers so they ignore inquiry result events if periodic inquiry is enabled.

---
 net/bluetooth/hci_event.c |    9 +++++++++
 1 file changed, 9 insertions(+)
net/bluetooth/hci_event.c +9 -0
index bffb0c3..7325300 100644
@@ -1723,6 +1723,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
 	if (!num_rsp)
 		return;
 
+	if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
+		return;
+
 	hci_dev_lock(hdev);
 
 	for (; num_rsp; num_rsp--, info++) {
@@ -2824,6 +2827,9 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
 	if (!num_rsp)
 		return;
 
+	if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
+		return;
+
 	hci_dev_lock(hdev);
 
 	if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
@@ -2995,6 +3001,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
 	if (!num_rsp)
 		return;
 
+	if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
+		return;
+
 	hci_dev_lock(hdev);
 
 	for (; num_rsp; num_rsp--, info++) {
Signature · 1 line
1.7.9.4
#5 lore raw

Re: [PATCH 4/4] Bluetooth: Ignore inquiry results from periodic inquiry

Hi Andre,

Quoted 8 lines · Andre Guedes

This patch changes inquiry result function handlers so they ignore inquiry result events if periodic inquiry is enabled.

---
 net/bluetooth/hci_event.c |    9 +++++++++
 1 file changed, 9 insertions(+)

All four patches applied. Thanks.

Gustavo