diff mbox series

[BlueZ,v1,2/2] advertising: Detect when EA needs to be used

Message ID 20240515161250.1714375-2-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,v1,1/2] shared/ad: Add bt_ad_length | expand

Commit Message

Luiz Augusto von Dentz May 15, 2024, 4:12 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This attempts to detect when an advertising instance needs to set the
secondary PHY in order to force EA PDUs to be used because its data is
too big for legacy PDUs.
---
 src/advertising.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/src/advertising.c b/src/advertising.c
index b9d923d5d2c0..5d373e0884b1 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -884,6 +884,13 @@  static int get_adv_flags(struct btd_adv_client *client)
 
 	flags |= client->flags;
 
+	/* Detect if the length is bigger that legacy and secondary is not set
+	 * then force it to be set to ensure the kernel uses EA.
+	 */
+	if (bt_ad_length(client->data) > BT_AD_MAX_DATA_LEN &&
+			!(flags & MGMT_ADV_FLAG_SEC_MASK))
+		flags |= MGMT_ADV_FLAG_SEC_1M;
+
 	return flags;
 }