mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-09 10:40:04 +00:00
fix(nimble): Handle corner case scenarios for ble_adv_reattempt.retry
This commit is contained in:
+14
-11
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user