mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-06-06 05:14:45 +00:00
fix(nimble): Clear resource before starting advertising
This commit is contained in:
@@ -3036,6 +3036,13 @@ ble_gap_adv_start(uint8_t own_addr_type, const ble_addr_t *direct_addr,
|
||||
return BLE_HS_EDISABLED;
|
||||
}
|
||||
|
||||
ble_hs_lock();
|
||||
|
||||
rc = ble_gap_adv_validate(own_addr_type, direct_addr, adv_params);
|
||||
if (rc != 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_ENABLE_CONN_REATTEMPT)
|
||||
ble_adv_reattempt.type = 0;
|
||||
ble_adv_reattempt.own_addr_type = own_addr_type;
|
||||
@@ -3053,13 +3060,6 @@ ble_gap_adv_start(uint8_t own_addr_type, const ble_addr_t *direct_addr,
|
||||
ble_adv_reattempt.cb_arg = cb_arg;
|
||||
#endif
|
||||
|
||||
ble_hs_lock();
|
||||
|
||||
rc = ble_gap_adv_validate(own_addr_type, direct_addr, adv_params);
|
||||
if (rc != 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (duration_ms != BLE_HS_FOREVER) {
|
||||
rc = ble_npl_time_ms_to_ticks(duration_ms, &duration_ticks);
|
||||
if (rc != 0) {
|
||||
|
||||
@@ -238,6 +238,19 @@ ble_hs_hci_evt_disconn_complete(uint8_t event_code, const void *data,
|
||||
BLE_HS_LOG(INFO, "Reattempt advertising; reason: 0x%x, status = %x",
|
||||
ev->reason, ev->status);
|
||||
|
||||
ble_l2cap_sig_conn_broken(ev->conn_handle, BLE_ERR_CONN_ESTABLISHMENT);
|
||||
ble_sm_connection_broken(ev->conn_handle);
|
||||
ble_gatts_connection_broken(ev->conn_handle);
|
||||
ble_gattc_connection_broken(ev->conn_handle);
|
||||
ble_hs_flow_connection_broken(ev->conn_handle);;
|
||||
#if MYNEWT_VAL(BLE_GATT_CACHING)
|
||||
ble_gattc_cache_conn_broken(ev->conn_handle);
|
||||
#endif
|
||||
rc = ble_hs_atomic_conn_delete(ev->conn_handle);
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = ble_gap_slave_adv_reattempt();
|
||||
if (rc != 0) {
|
||||
BLE_HS_LOG(INFO, "Adv reattempt failed; rc= %d ", rc);
|
||||
|
||||
Reference in New Issue
Block a user