From ea242fbf860284c13cf17f46c9731b148da4a6ac Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 15 May 2024 12:06:55 -0400 Subject: [PATCH] advertising: Detect when EA needs to be used 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 --git a/src/advertising.c b/src/advertising.c index b9d923d5d..5d373e088 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; } -- 2.47.3