linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fast Advertising Interval
@ 2019-07-08  6:06 spoorthix.k
  2019-07-12 19:03 ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: spoorthix.k @ 2019-07-08  6:06 UTC (permalink / raw)
  To: linux-bluetooth

From: Spoorthi Ravishankar Koppad <spoorthix.k@intel.com>

Changes made to add support for fast advertising interval
as per core 4.1 specification, section 9.3.11.2.

A peripheral device entering any of the following GAP modes and
sending either non-connectable advertising events or scannable
undirected advertising events should use adv_fast_interval2
(100ms - 150ms) for adv_fast_period(30s).

         - Non-Discoverable Mode
         - Non-Connectable Mode
         - Limited Discoverable Mode
         - General Discoverable Mode

Signed-off-by: Spoorthi Ravishankar Koppad <spoorthix.k@intel.com>
---
 include/net/bluetooth/hci_core.h |  2 ++
 net/bluetooth/hci_request.c      | 25 +++++++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 7dfe6ff..a69534d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1512,6 +1512,8 @@ struct hci_mgmt_chan {
 #define DISCOV_INTERLEAVED_INQUIRY_LEN	0x04
 #define DISCOV_BREDR_INQUIRY_LEN	0x08
 #define DISCOV_LE_RESTART_DELAY		msecs_to_jiffies(200)	/* msec */
+#define DISCOV_LE_FAST_ADV_INT_MIN     100     /* msec */
+#define DISCOV_LE_FAST_ADV_INT_MAX     150     /* msec */
 
 void mgmt_fill_version_info(void *ver);
 int mgmt_new_settings(struct hci_dev *hdev);
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index d4ecf71..6d8ffcc 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1199,15 +1199,24 @@ void __hci_req_enable_advertising(struct hci_request *req)
 		return;
 
 	memset(&cp, 0, sizeof(cp));
-	cp.min_interval = cpu_to_le16(hdev->le_adv_min_interval);
-	cp.max_interval = cpu_to_le16(hdev->le_adv_max_interval);
-
-	if (connectable)
+	if (connectable) {
 		cp.type = LE_ADV_IND;
-	else if (get_cur_adv_instance_scan_rsp_len(hdev))
-		cp.type = LE_ADV_SCAN_IND;
-	else
-		cp.type = LE_ADV_NONCONN_IND;
+		cp.min_interval = cpu_to_le16(hdev->le_adv_min_interval);
+		cp.max_interval = cpu_to_le16(hdev->le_adv_max_interval);
+	} else {
+		if (get_cur_adv_instance_scan_rsp_len(hdev))
+			cp.type = LE_ADV_SCAN_IND;
+		else
+			cp.type = LE_ADV_NONCONN_IND;
+
+		if (!hci_dev_test_flag(hdev, HCI_DISCOVERABLE) ||
+		    hci_dev_test_flag(hdev, HCI_LIMITED_DISCOVERABLE)) {
+			cp.min_interval =
+				cpu_to_le16(DISCOV_LE_FAST_ADV_INT_MIN);
+			cp.max_interval =
+				cpu_to_le16(DISCOV_LE_FAST_ADV_INT_MAX);
+		}
+	}
 
 	cp.own_address_type = own_addr_type;
 	cp.channel_map = hdev->le_adv_channel_map;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] Fast advertising interval
@ 2019-06-21  9:22 spoorthix.k
  2019-06-22  7:29 ` spoorthix.k
  2019-07-06 10:42 ` Marcel Holtmann
  0 siblings, 2 replies; 5+ messages in thread
From: spoorthix.k @ 2019-06-21  9:22 UTC (permalink / raw)
  To: linux-bluetooth

From: Spoorthi Ravishankar Koppad <spoorthix.k@intel.com>

Implemented as per Core Spec 5.0

Signed-off-by: Spoorthi Ravishankar Koppad <spoorthix.k@intel.com>
---
 include/net/bluetooth/hci_core.h |  2 ++
 net/bluetooth/hci_request.c      | 33 ++++++++++++++++++++++++---------
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index aed17df..9b19992 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1510,6 +1510,8 @@ struct hci_mgmt_chan {
 #define DISCOV_INTERLEAVED_INQUIRY_LEN	0x04
 #define DISCOV_BREDR_INQUIRY_LEN	0x08
 #define DISCOV_LE_RESTART_DELAY		msecs_to_jiffies(200)	/* msec */
+#define DISCOV_LE_FAST_ADV_INT_MIN     100     /* msec */
+#define DISCOV_LE_FAST_ADV_INT_MAX     150     /* msec */
 
 void mgmt_fill_version_info(void *ver);
 int mgmt_new_settings(struct hci_dev *hdev);
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index d4f5bfa..c077b06 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1177,8 +1177,10 @@ void __hci_req_enable_advertising(struct hci_request *req)
 	bool connectable;
 	u32 flags;
 
+       	BT_INFO("Entered __hci_req_enable_advertising");
 	flags = get_adv_instance_flags(hdev, hdev->cur_adv_instance);
 
+
 	/* If the "connectable" instance flag was not set, then choose between
 	 * ADV_IND and ADV_NONCONN_IND based on the global connectable setting.
 	 */
@@ -1208,15 +1210,28 @@ void __hci_req_enable_advertising(struct hci_request *req)
 		return;
 
 	memset(&cp, 0, sizeof(cp));
-	cp.min_interval = cpu_to_le16(hdev->le_adv_min_interval);
-	cp.max_interval = cpu_to_le16(hdev->le_adv_max_interval);
-
-	if (connectable)
-		cp.type = LE_ADV_IND;
-	else if (get_cur_adv_instance_scan_rsp_len(hdev))
-		cp.type = LE_ADV_SCAN_IND;
-	else
-		cp.type = LE_ADV_NONCONN_IND;
+       BT_INFO("__hci_req_enable_advertising");
+
+       if (connectable) {
+               BT_INFO("set adv min and max");
+                cp.type = LE_ADV_IND;
+               cp.min_interval = cpu_to_le16(hdev->le_adv_min_interval);
+               cp.max_interval = cpu_to_le16(hdev->le_adv_max_interval);
+       } else {
+               if (get_cur_adv_instance_scan_rsp_len(hdev))
+                       cp.type = LE_ADV_SCAN_IND;
+               else
+                       cp.type = LE_ADV_NONCONN_IND;
+
+              if (!hci_dev_test_flag(hdev, HCI_DISCOVERABLE) ||
+                       hci_dev_test_flag(hdev, HCI_LIMITED_DISCOVERABLE)) {
+                       BT_INFO("Check  HCI_DISCOVERABLE or HCI_LIMITED_DISCOVERABLE");
+                       cp.min_interval =
+                              cpu_to_le16(DISCOV_LE_FAST_ADV_INT_MIN);
+                       cp.max_interval =
+                               cpu_to_le16(DISCOV_LE_FAST_ADV_INT_MAX);
+               }
+       }
 
 	cp.own_address_type = own_addr_type;
 	cp.channel_map = hdev->le_adv_channel_map;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-12 19:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08  6:06 [PATCH] Fast Advertising Interval spoorthix.k
2019-07-12 19:03 ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2019-06-21  9:22 [PATCH] Fast advertising interval spoorthix.k
2019-06-22  7:29 ` spoorthix.k
2019-07-06 10:42 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).