mirror of
https://github.com/esphome/esphome.git
synced 2025-09-14 09:12:19 +01:00
cleaner fix
This commit is contained in:
@@ -26,11 +26,8 @@ void BLEClientBase::set_state(espbt::ClientState st) {
|
|||||||
ESP_LOGV(TAG, "[%d] [%s] Set state %d", this->connection_index_, this->address_str_.c_str(), (int) st);
|
ESP_LOGV(TAG, "[%d] [%s] Set state %d", this->connection_index_, this->address_str_.c_str(), (int) st);
|
||||||
ESPBTClient::set_state(st);
|
ESPBTClient::set_state(st);
|
||||||
|
|
||||||
// Disable loop when idle AND address is not set (unused connection slot)
|
if (st == espbt::ClientState::READY_TO_CONNECT) {
|
||||||
if (st == espbt::ClientState::IDLE && this->address_ == 0) {
|
// Enable loop when we need to connect
|
||||||
this->disable_loop();
|
|
||||||
} else if (st == espbt::ClientState::READY_TO_CONNECT || st == espbt::ClientState::INIT) {
|
|
||||||
// Enable loop when we need to initialize or connect
|
|
||||||
this->enable_loop();
|
this->enable_loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,9 +48,8 @@ void BLEClientBase::loop() {
|
|||||||
|
|
||||||
// READY_TO_CONNECT means we have discovered the device
|
// READY_TO_CONNECT means we have discovered the device
|
||||||
// and the scanner has been stopped by the tracker.
|
// and the scanner has been stopped by the tracker.
|
||||||
if (this->state_ == espbt::ClientState::READY_TO_CONNECT) {
|
elif (this->state_ == espbt::ClientState::READY_TO_CONNECT) { this->connect(); }
|
||||||
this->connect();
|
elif (this->state_ == espbt::ClientState::IDLE) { this->disable_loop(); }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float BLEClientBase::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; }
|
float BLEClientBase::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; }
|
||||||
|
Reference in New Issue
Block a user