[esp32_ble_client] Don't reset conn_id_ in want_disconnect_ path

The CLOSE_EVT handler matches on conn_id_ to call set_idle_().
Resetting conn_id_ to UNSET_CONN_ID before CLOSE_EVT arrives
causes the event to be dropped, leaving the client stuck in
DISCONNECTING state permanently.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
J. Nick Koston
2026-02-23 09:48:23 -06:00
parent a0b69effe4
commit 1dba01e05b

View File

@@ -318,8 +318,8 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
// Disconnect was requested after connecting started,
// but before the connection was established. Now that we have
// this->conn_id_ set, we can disconnect it.
// Don't reset conn_id_ here — CLOSE_EVT needs it to match and call set_idle_().
this->unconditional_disconnect();
this->conn_id_ = UNSET_CONN_ID;
break;
}
// MTU negotiation already started in ESP_GATTC_CONNECT_EVT