diff --git a/esphome/components/esp32_ble_client/ble_client_base.cpp b/esphome/components/esp32_ble_client/ble_client_base.cpp index fe6695dde7..83c1fe8900 100644 --- a/esphome/components/esp32_ble_client/ble_client_base.cpp +++ b/esphome/components/esp32_ble_client/ble_client_base.cpp @@ -201,8 +201,9 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ break; } if (this->state == espbt::ClientState::DISCONNECTING) { - // Disconnect we requested before after connecting started, - // but before the connection was established. + // Disconnect was requested before after connecting started, + // but before the connection was established. Now that we have + // this->conn_id_ set, we can disconnect it. this->_unconditional_disconnect(); this->conn_id_ = UNSET_CONN_ID; break; @@ -227,8 +228,9 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ return false; this->log_event_("ESP_GATTC_CONNECT_EVT"); if (this->state == espbt::ClientState::DISCONNECTING) { - // Disconnect we requested before after connecting started, - // but before the connection was established. + // Disconnect was requested before after connecting started, + // but before the connection was established. Now that we have + // this->conn_id_ set, we can disconnect it. this->_unconditional_disconnect(); this->conn_id_ = UNSET_CONN_ID; }