mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 08:50:22 +00:00
Address review: gate the cache clean where the paths converge
The stack-down settle skipped release_services() locally, but its report routes into the wrapper's reset which calls it anyway - the warn survived. Gating the clean on an active stack inside release_services() covers every path, and the stack-down branch goes back to the plain call.
This commit is contained in:
@@ -49,10 +49,7 @@ void BluedroidGattClient::loop() {
|
||||
// frees its slot, then re-register the app on the next enable.
|
||||
auto down_st = this->state();
|
||||
if (down_st != ClientState::IDLE && down_st != ClientState::INIT) {
|
||||
// The dying stack invalidates its own cache; a cache_clean would just
|
||||
// warn against a disabled stack. Reset the stream latches directly.
|
||||
this->service_total_ = 0;
|
||||
this->services_released_ = true;
|
||||
this->release_services();
|
||||
this->set_idle_();
|
||||
this->listener_->on_connection_state(false, 0, ble_device_base::GATT_ERR_NOT_CONNECTED);
|
||||
}
|
||||
@@ -305,8 +302,11 @@ void BluedroidGattClient::release_services() {
|
||||
this->services_released_ = true;
|
||||
#ifndef CONFIG_BT_GATTC_CACHE_NVS_FLASH
|
||||
// A failed clean leaves a stale database the next connection could serve
|
||||
// as authoritative; make it visible like every other IDF call here.
|
||||
this->check_and_log_error_("esp_ble_gattc_cache_clean", esp_ble_gattc_cache_clean(this->remote_bda_));
|
||||
// as authoritative. A disabled stack invalidates its own cache; skip the
|
||||
// meaningless call instead of warning on every OTA/ble.disable teardown.
|
||||
if (esp32_ble::global_ble->is_active()) {
|
||||
this->check_and_log_error_("esp_ble_gattc_cache_clean", esp_ble_gattc_cache_clean(this->remote_bda_));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user