From c75b7de2d3cb284545bd4d0e091c2ff1331e33f3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Feb 2026 09:32:13 -0600 Subject: [PATCH] [esp32_ble_client] Let failed OPEN_EVT in DISCONNECTING state fall through to existing handler Instead of a separate early-return for DISCONNECTING state, let the failed OPEN_EVT fall through to the existing failed-status handler which already transitions to IDLE. --- .../components/esp32_ble_client/ble_client_base.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/esphome/components/esp32_ble_client/ble_client_base.cpp b/esphome/components/esp32_ble_client/ble_client_base.cpp index 3b35420d7b..026d55e1c6 100644 --- a/esphome/components/esp32_ble_client/ble_client_base.cpp +++ b/esphome/components/esp32_ble_client/ble_client_base.cpp @@ -299,16 +299,6 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ ESP_LOGD(TAG, "[%d] [%s] ESP_GATTC_OPEN_EVT in IDLE state (status=%d), ignoring", this->connection_index_, this->address_str_, param->open.status); break; - } else if (this->state() == espbt::ClientState::DISCONNECTING) { - // When a connection fails to establish, the ESP-IDF stack sends DISCONNECT_EVT - // (which we now transition to DISCONNECTING) followed by OPEN_EVT with a failure status. - // No CLOSE_EVT will follow since no GATT connection was established, so this - // failed OPEN_EVT is the terminal event — transition to IDLE here. - ESP_LOGD(TAG, "[%d] [%s] ESP_GATTC_OPEN_EVT in DISCONNECTING state (status=%d), completing disconnection", - this->connection_index_, this->address_str_, param->open.status); - this->set_state(espbt::ClientState::IDLE); - this->conn_id_ = UNSET_CONN_ID; - break; } if (this->state() != espbt::ClientState::CONNECTING) {