mirror of
https://github.com/esphome/esphome.git
synced 2025-08-04 17:37:49 +00:00
[esp32_ble_client] Connect immediately on READY_TO_CONNECT to reduce latency (#10051)
This commit is contained in:
parent
989058e6a9
commit
6be22a5ea9
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user