14static constexpr float BLE_SCAN_UNIT_MS = 0.625f;
30 ESP_LOGD(TAG,
"Scanning not started (continuous: false) - waiting for an explicit start_scan()");
34#ifdef USE_OTA_STATE_LISTENER
41#ifdef USE_OTA_STATE_LISTENER
95 ESP_LOGD(TAG,
"Scan period elapsed - restarting scan");
117 ESP_LOGV(TAG,
"Scan mode %s", active ?
"active" :
"passive");
128 "LN882H BLE Tracker:\n"
129 " Scan Duration: %" PRIu32
" s\n"
130 " Scan Interval: %.0f ms (%" PRIu16
" BLE units)\n"
131 " Scan Window: %.0f ms (%" PRIu16
" BLE units)\n"
133 " Continuous Scanning: %s",
159 false, this->scan_continuous_ ?
nullptr : TAG);
219 ESP_LOGD(TAG,
"BLE scan started (%s, window=%.0fms, interval=%.0fms)", this->
scan_active_ ?
"active" :
"passive",
234 ESP_LOGD(TAG,
"BLE scan stopped");
void enable_loop()
Enable this component's loop.
void disable_loop()
Disable this component's loop.
ln882h_ble::LN882HBLE * parent_
void dump_child_configs()
Print each listener's dump_child_config(); called from the tracker's dump_config().
void on_scan_end()
Fire listeners' on_scan_end and reset the per-scan discovered-log dedup.
void dispatch(const uint8_t *mac, int8_t rssi, uint8_t addr_type, const uint8_t *data, uint8_t data_len, bool raw_only, const char *log_unclaimed_tag)
Dispatch one (possibly merged) advertisement: the raw callback, and — unless raw_only — parsing for l...
void stash_adv(const uint8_t *mac, int8_t rssi, uint8_t addr_type, const uint8_t *data, uint8_t data_len, uint32_t now)
Hold a scannable advertisement, waiting for its scan response.
void sweep(uint32_t now)
Timeout flush (call from loop() with the stash_adv() clock): deliver held advertisements whose scan r...
void flush()
Deliver every held advertisement now (scan period/scan is ending, before on_scan_end fires): unmerged...
void submit_scan_rsp(const uint8_t *mac, int8_t rssi, uint8_t addr_type, const uint8_t *data, uint8_t data_len)
A scan response arrived: append it to the held advertisement from the same device and deliver the pai...
bool empty() const
Lets loop() skip the cross-TU sweep() call in the common case (empty: passive scan,...
void bind(AdvDispatcher *dispatcher, const bool *scan_continuous, const char *log_tag)
Wire the merger's output; call once in the tracker's setup().
void scan_stop()
Stop the controller scan (no-op when not scanning).
bool scan_continuous_before_ota_
bool request_scan_mode(bool active)
void dump_config() override
void end_scan_period_(uint32_t now)
ble_device_base::AdvDispatcher dispatcher_
uint32_t scan_period_start_
ble_device_base::ScanResponseMerger merger_
void restart_scan_duration()
Re-anchor the one-shot duration clock of a running scan to now — used when an action changes the scan...
void on_scan_report(const ln882h_ble::BLEScanReport &report) override
void on_ota_global_state(ota::OTAState state, float progress, uint8_t error, ota::OTAComponent *comp) override
bool scan_running_before_ota_
uint32_t scan_start_time_
ESPHOME_LOG_TAG(TAG, "ln882h_ble_tracker")
OTAGlobalCallback * get_global_ota_callback()
uint32_t IRAM_ATTR HOT millis()
One scan report from the controller, decoded from the SDK's rw-task event (RSSI already sign-correcte...
uint8_t mac[MAC_ADDRESS_SIZE]