1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-22 19:53:46 +01:00

Fix BLE connection loop caused by timeout and pending disconnect race (#8597)

This commit is contained in:
J. Nick Koston
2025-04-21 23:17:09 -10:00
committed by GitHub
parent 82c6a40371
commit fbf00f0af4
2 changed files with 8 additions and 0 deletions

View File

@@ -265,6 +265,12 @@ void BluetoothProxy::bluetooth_device_request(const api::BluetoothDeviceRequest
connection->get_connection_index(), connection->address_str().c_str());
return;
} else if (connection->state() == espbt::ClientState::CONNECTING) {
if (connection->disconnect_pending()) {
ESP_LOGW(TAG, "[%d] [%s] Connection request while pending disconnect, cancelling pending disconnect",
connection->get_connection_index(), connection->address_str().c_str());
connection->cancel_pending_disconnect();
return;
}
ESP_LOGW(TAG, "[%d] [%s] Connection request ignored, already connecting", connection->get_connection_index(),
connection->address_str().c_str());
return;