[esp32_ble_client] Connect immediately on READY_TO_CONNECT to reduce latency (#10051)

This commit is contained in:
J. Nick Koston 2025-08-03 19:15:28 -10:00 committed by GitHub
parent 989058e6a9
commit 6be22a5ea9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,8 +45,10 @@ void BLEClientBase::set_state(espbt::ClientState st) {
ESPBTClient::set_state(st); ESPBTClient::set_state(st);
if (st == espbt::ClientState::READY_TO_CONNECT) { if (st == espbt::ClientState::READY_TO_CONNECT) {
// Enable loop when we need to connect // Enable loop for state processing
this->enable_loop(); this->enable_loop();
// Connect immediately instead of waiting for next loop
this->connect();
} }
} }
@ -63,11 +65,6 @@ void BLEClientBase::loop() {
} }
this->set_state(espbt::ClientState::IDLE); this->set_state(espbt::ClientState::IDLE);
} }
// READY_TO_CONNECT means we have discovered the device
// and the scanner has been stopped by the tracker.
else if (this->state_ == espbt::ClientState::READY_TO_CONNECT) {
this->connect();
}
// If its idle, we can disable the loop as set_state // If its idle, we can disable the loop as set_state
// will enable it again when we need to connect. // will enable it again when we need to connect.
else if (this->state_ == espbt::ClientState::IDLE) { else if (this->state_ == espbt::ClientState::IDLE) {