12static const char *
const TAG =
"ln882h_ble_tracker";
14static constexpr float BLE_SCAN_UNIT_MS = 0.625f;
33 ESP_LOGD(TAG,
"Scanning not started (continuous: false) - waiting for an explicit start_scan()");
37#ifdef USE_OTA_STATE_LISTENER
44#ifdef USE_OTA_STATE_LISTENER
98 ESP_LOGD(TAG,
"Scan period elapsed - restarting scan");
120 ESP_LOGV(TAG,
"Scan mode %s", active ?
"active" :
"passive");
131 "LN882H BLE Tracker:\n"
132 " Scan Duration: %" PRIu32
" s\n"
133 " Scan Interval: %.0f ms (%" PRIu16
" BLE units)\n"
134 " Scan Window: %.0f ms (%" PRIu16
" BLE units)\n"
136 " Continuous Scanning: %s",
161 false, this->scan_continuous_ ?
nullptr : TAG);
221 ESP_LOGD(TAG,
"BLE scan started (%s, window=%.0fms, interval=%.0fms)", this->
scan_active_ ?
"active" :
"passive",
236 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 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 register_scan_listener(BLEScanListener *listener)
Register a consumer for scan reports (delivered on the main task via loop()).
void scan_start(uint16_t interval, uint16_t window, bool active)
Start the controller scan.
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_
void add_global_state_listener(OTAGlobalStateListener *listener)
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]