28#ifdef USE_BLE_SCAN_RESPONSE_MERGER
45#ifdef ESPHOME_BLE_DEVICE_BASE_LISTENER_COUNT
57 void dispatch(
const uint8_t *mac, int8_t rssi, uint8_t addr_type,
const uint8_t *data, uint8_t data_len,
58 bool raw_only,
const char *log_unclaimed_tag);
64#ifdef ESPHOME_BLE_DEVICE_BASE_LISTENER_COUNT
82 this->dispatcher_ = dispatcher;
83 this->scan_continuous_ = scan_continuous;
84 this->log_tag_ = log_tag;
92 void stash_adv(
const uint8_t *mac, int8_t rssi, uint8_t addr_type,
const uint8_t *data, uint8_t data_len,
100 void submit_scan_rsp(
const uint8_t *mac, int8_t rssi, uint8_t addr_type,
const uint8_t *data, uint8_t data_len);
110 bool empty()
const {
return this->pending_count_ == 0; }
116 void deliver_(
const uint8_t *mac, int8_t rssi, uint8_t addr_type,
const uint8_t *data, uint8_t data_len,
123 uint8_t mac[MAC_ADDRESS_SIZE];
135 static constexpr size_t MAX_PENDING_ADV = 8;
140 static constexpr uint32_t PENDING_ADV_TIMEOUT_MS = 300;
141 AdvDispatcher *dispatcher_{
nullptr};
142 const bool *scan_continuous_{
nullptr};
143 const char *log_tag_{
nullptr};
146 PendingAdv pending_adv_[MAX_PENDING_ADV];
147 uint8_t pending_count_{0};
Minimal static vector - saves memory by avoiding std::vector overhead.
The delivery half of a split-report tracker, shared so the dispatch contract (raw-callback ordering,...
void set_raw_advertisement_callback(RawAdvertisementCallback callback)
void register_listener(ESPBTDeviceListener *listener)
StaticVector< ESPBTDeviceListener *, ESPHOME_BLE_DEVICE_BASE_LISTENER_COUNT > listeners_
RawAdvertisementCallback raw_callback_
DiscoveredDeviceLog discovered_log_
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...
Per-scan-period "Found device" DEBUG logger, deduplicated by MAC address.
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().
Subscriber slot for the raw-advertisement stream (the bluetooth_proxy path).