mirror of
https://github.com/esphome/esphome.git
synced 2026-07-11 09:25:34 +00:00
[esp32_ble_client] Release services in DISCONNECTING timeout and add comments
This commit is contained in:
@@ -67,6 +67,10 @@ void BLEClientBase::loop() {
|
||||
(millis() - this->disconnecting_started_) > DISCONNECTING_TIMEOUT) {
|
||||
ESP_LOGE(TAG, "[%d] [%s] Timeout waiting for CLOSE_EVT after disconnect, forcing IDLE", this->connection_index_,
|
||||
this->address_str_);
|
||||
// release_services() must be called before set_idle_() — if we entered DISCONNECTING
|
||||
// via unconditional_disconnect() (which doesn't call release_services()), and ESP-IDF
|
||||
// never delivered CLOSE_EVT/DISCONNECT_EVT, services would leak without this call.
|
||||
this->release_services();
|
||||
this->set_idle_();
|
||||
}
|
||||
}
|
||||
@@ -230,6 +234,7 @@ void BLEClientBase::log_connection_params_(const char *param_type) {
|
||||
void BLEClientBase::handle_connection_result_(esp_err_t ret) {
|
||||
if (ret) {
|
||||
this->log_gattc_warning_("esp_ble_gattc_open", ret);
|
||||
// Don't use set_idle_() here — CONNECT_EVT never fired so conn_id_ is still UNSET_CONN_ID.
|
||||
this->set_state(espbt::ClientState::IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user