mirror of
https://github.com/esphome/esphome.git
synced 2026-09-21 20:18:43 +00:00
[esp32_ble_tracker] Make start_scan action idempotent (#12864)
This commit is contained in:
@@ -98,7 +98,13 @@ template<typename... Ts> class ESP32BLEStartScanAction : public Action<Ts...> {
|
||||
TEMPLATABLE_VALUE(bool, continuous)
|
||||
void play(const Ts &...x) override {
|
||||
this->parent_->set_scan_continuous(this->continuous_.value(x...));
|
||||
this->parent_->start_scan();
|
||||
// Only call start_scan() if scanner is IDLE
|
||||
// For other states (STARTING, RUNNING, STOPPING, FAILED), the normal state
|
||||
// machine flow will eventually transition back to IDLE, at which point
|
||||
// loop() will see scan_continuous_ and restart scanning if it is true.
|
||||
if (this->parent_->get_scanner_state() == ScannerState::IDLE) {
|
||||
this->parent_->start_scan();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user