fix(nimble): Handle corner case scenarios for ble_adv_reattempt.retry

This commit is contained in:
Rahul Tank
2026-05-19 17:12:51 +05:30
parent 8423dc7d47
commit 402a1b76a3
+14 -11
View File
@@ -1438,6 +1438,9 @@ int ble_gap_slave_adv_reattempt(void)
return rc;
}
/* Mark retry context before invoking start; cleared in ble_gap_adv_start(). */
ble_adv_reattempt.retry = 1;
rc = ble_gap_adv_start(ble_adv_reattempt.own_addr_type,
(ble_adv_reattempt.direct_addr_present == 1 ? &ble_adv_reattempt.direct_addr: NULL),
ble_adv_reattempt.duration_ms, &ble_adv_reattempt.adv_params,
@@ -1445,8 +1448,6 @@ int ble_gap_slave_adv_reattempt(void)
if (rc != 0) {
return rc;
}
ble_adv_reattempt.retry = 1 ;
break;
case 1:
@@ -1457,8 +1458,12 @@ int ble_gap_slave_adv_reattempt(void)
rc = ble_gap_ext_adv_start(ble_adv_reattempt.instance, ble_adv_reattempt.duration,
ble_adv_reattempt.max_events);
if (rc != 0)
ble_adv_reattempt.retry = 0;
if (rc != 0) {
return rc;
}
#endif
break;
@@ -3854,6 +3859,9 @@ ble_gap_adv_start(uint8_t own_addr_type, const ble_addr_t *direct_addr,
STATS_INC(ble_gap_stats, adv_start);
if (!ble_hs_is_enabled()) {
#if MYNEWT_VAL(BLE_ENABLE_CONN_REATTEMPT) && NIMBLE_BLE_CONNECT
ble_adv_reattempt.retry = 0;
#endif
return BLE_HS_EDISABLED;
}
@@ -3957,15 +3965,10 @@ ble_gap_adv_start(uint8_t own_addr_type, const ble_addr_t *direct_addr,
}
rc = 0;
#if MYNEWT_VAL(BLE_ENABLE_CONN_REATTEMPT) && NIMBLE_BLE_CONNECT
if (ble_adv_reattempt.retry) {
ble_adv_reattempt.retry = 0;
}
#endif
done:
#if MYNEWT_VAL(BLE_ENABLE_CONN_REATTEMPT) && NIMBLE_BLE_CONNECT
ble_adv_reattempt.retry = 0;
#endif
ble_hs_unlock();
if (rc != 0) {