1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-26 23:22:21 +01:00

Merge branch 'no_more_stopped_state' into integration

This commit is contained in:
J. Nick Koston
2025-08-03 16:31:01 -10:00
2 changed files with 15 additions and 16 deletions

View File

@@ -430,14 +430,7 @@ void ESP32BLETracker::gap_scan_event_handler(const BLEScanResult &scan_result) {
}
}
// Scan completed naturally, perform cleanup and transition to IDLE
ESP_LOGD(TAG, "Scan completed, set scanner state to IDLE.");
this->already_discovered_.clear();
this->cancel_timeout("scan");
for (auto *listener : this->listeners_)
listener->on_scan_end();
this->set_scanner_state_(ScannerState::IDLE);
this->cleanup_scan_state_(false);
}
}
@@ -494,14 +487,7 @@ void ESP32BLETracker::gap_scan_stop_complete_(const esp_ble_gap_cb_param_t::ble_
}
// Perform cleanup and transition to IDLE
ESP_LOGD(TAG, "Scan stop complete, set scanner state to IDLE.");
this->already_discovered_.clear();
this->cancel_timeout("scan");
for (auto *listener : this->listeners_)
listener->on_scan_end();
this->set_scanner_state_(ScannerState::IDLE);
this->cleanup_scan_state_(true);
}
void ESP32BLETracker::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
@@ -875,6 +861,17 @@ bool ESPBTDevice::resolve_irk(const uint8_t *irk) const {
}
#endif // USE_ESP32_BLE_DEVICE
void ESP32BLETracker::cleanup_scan_state_(bool is_stop_complete) {
ESP_LOGD(TAG, "Scan %scomplete, set scanner state to IDLE.", is_stop_complete ? "stop " : "");
this->already_discovered_.clear();
this->cancel_timeout("scan");
for (auto *listener : this->listeners_)
listener->on_scan_end();
this->set_scanner_state_(ScannerState::IDLE);
}
} // namespace esphome::esp32_ble_tracker
#endif // USE_ESP32

View File

@@ -270,6 +270,8 @@ class ESP32BLETracker : public Component,
void gap_scan_stop_complete_(const esp_ble_gap_cb_param_t::ble_scan_stop_cmpl_evt_param &param);
/// Called to set the scanner state. Will also call callbacks to let listeners know when state is changed.
void set_scanner_state_(ScannerState state);
/// Common cleanup logic when transitioning scanner to IDLE state
void cleanup_scan_state_(bool is_stop_complete);
uint8_t app_id_{0};