12static const char *
const TAG =
"rp2_ble_tracker";
18static constexpr uint32_t SCAN_START_RETRY_MS = 1000;
21static constexpr float BLE_SCAN_UNIT_MS = 0.625f;
30#ifdef USE_OTA_STATE_LISTENER
41#ifdef USE_OTA_STATE_LISTENER
118 " Scan Duration: %" PRIu32
" s\n"
119 " Scan Interval: %.0f ms (%" PRIu32
" BLE units)\n"
120 " Scan Window: %.0f ms (%" PRIu32
" BLE units)\n"
122 " Continuous Scanning: %s",
125 this->
scan_active_ ? LOG_STR_LITERAL(
"ACTIVE") : LOG_STR_LITERAL(
"PASSIVE"),
132static constexpr uint8_t ADV_EVENT_TYPE_ADV_IND = 0;
133static constexpr uint8_t ADV_EVENT_TYPE_ADV_SCAN_IND = 2;
134static constexpr uint8_t ADV_EVENT_TYPE_SCAN_RSP = 4;
154 false, this->scan_continuous_ ?
nullptr : TAG);
169 ESP_LOGV(TAG,
"Scan mode %s", active ?
"active" :
"passive");
214 ESP_LOGD(TAG,
"Scan started (%s, window=%.0fms, interval=%.0fms)",
215 this->
scan_active_ ? LOG_STR_LITERAL(
"active") : LOG_STR_LITERAL(
"passive"),
231 ESP_LOGD(TAG,
"Scan stopped");
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
bool is_in_loop_state() const
Check if this component has completed setup and is in the loop state.
void enable_loop()
Enable this component's loop.
void disable_loop()
Disable this component's loop.
rp2040_ble::RP2040BLE * 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 add_global_state_listener(OTAGlobalStateListener *listener)
void scan_stop()
Stop the controller scan (no-op when not scanning).
bool scan_start(uint16_t interval, uint16_t window, bool active)
Start a controller scan; active sends scan requests and receives scan responses as separate reports.
void register_scan_listener(BLEScanListener *listener)
Register a consumer for scan reports (delivered on the main loop via loop()).
ble_device_base::AdvDispatcher dispatcher_
uint32_t scan_period_start_
bool controller_scan_start_()
uint32_t last_scan_start_attempt_
bool scan_continuous_before_ota_
bool request_scan_mode(bool active)
void on_scan_report(const rp2040_ble::BLEScanReport &report) override
ble_device_base::ScanResponseMerger merger_
void dump_config() override
bool scan_pending_before_ota_
void on_ota_global_state(ota::OTAState state, float progress, uint8_t error, ota::OTAComponent *comp) override
OTAGlobalCallback * get_global_ota_callback()
Application App
Global storage of Application pointer - only one Application can exist.
One advertisement report from the controller.
uint8_t mac[MAC_ADDRESS_SIZE]