From e94da35c60ef6bd616916bb6ca35080720a8278d Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Tue, 3 Feb 2026 17:41:40 +0530 Subject: [PATCH] fix(nimble): Add support to allow multiple ext adv --- nimble/host/src/ble_gap.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 10847a157..e823c62a7 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -4765,9 +4765,18 @@ ble_gap_ext_adv_start(uint8_t instance, int duration, int max_events) return BLE_HS_EINVAL; } - if (ble_gap_slave[instance].op != BLE_GAP_OP_NULL) { + /* + * If extended advertising is already enabled for this instance, allow + * sending HCI_LE_Set_Extended_Advertising_Enable again. Per Core Spec + * (Vol 4, Part E, 7.8.56), re-sending enable while enabled resets the + * duration timer and event counter, and applies any random address changes. + * + * If some other GAP procedure is in progress, still reject with EALREADY. + */ + if (ble_gap_slave[instance].op != BLE_GAP_OP_NULL && + ble_gap_slave[instance].op != BLE_GAP_OP_S_ADV) { ble_hs_unlock(); - return BLE_HS_EALREADY; + return BLE_HS_EALREADY; } /* HD directed duration shall not be 0 or larger than >1.28s */