|
ESPHome 2026.8.0b4
|
#include <scan_response_merger.h>
Public Member Functions | |
| 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 | 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 | 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 pair as one frame. | |
| void | sweep (uint32_t now) |
| Timeout flush (call from loop() with the stash_adv() clock): deliver held advertisements whose scan response never arrived (device didn't answer / frame lost) — unmerged, past PENDING_ADV_TIMEOUT_MS. | |
| void | flush () |
| Deliver every held advertisement now (scan period/scan is ending, before on_scan_end fires): unmerged delivery, same as the timeout path. | |
| bool | empty () const |
| Lets loop() skip the cross-TU sweep() call in the common case (empty: passive scan, or every pair already matched). | |
Definition at line 74 of file scan_response_merger.h.
|
inline |
Wire the merger's output; call once in the tracker's setup().
Every delivered frame goes to dispatcher->dispatch(); scan_continuous is read at each delivery (runtime continuous flips are honored) to decide the unclaimed-device log tag, so both pointers must outlive the merger — tracker members always do.
Definition at line 81 of file scan_response_merger.h.
|
inline |
Lets loop() skip the cross-TU sweep() call in the common case (empty: passive scan, or every pair already matched).
Definition at line 110 of file scan_response_merger.h.
| void esphome::ble_device_base::ScanResponseMerger::flush | ( | ) |
Deliver every held advertisement now (scan period/scan is ending, before on_scan_end fires): unmerged delivery, same as the timeout path.
Definition at line 98 of file scan_response_merger.cpp.
| void esphome::ble_device_base::ScanResponseMerger::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.
The tracker calls this only when it wants the merge (scannable advertisement while an active scan runs) and delivers everything else directly. A same-device re-advertisement delivers the held frame (its scan response is not coming) and reuses the slot; a full table degrades gracefully to unmerged delivery.
Definition at line 20 of file scan_response_merger.cpp.
| void esphome::ble_device_base::ScanResponseMerger::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 pair as one frame.
The merged frame reports the ADVERTISEMENT's RSSI — every unmerged path reports the advertisement's measurement, so a device's RSSI must not jump between two measurements depending on merge timing. Unmatched responses are delivered raw_only.
Definition at line 60 of file scan_response_merger.cpp.
| void esphome::ble_device_base::ScanResponseMerger::sweep | ( | uint32_t | now | ) |
Timeout flush (call from loop() with the stash_adv() clock): deliver held advertisements whose scan response never arrived (device didn't answer / frame lost) — unmerged, past PENDING_ADV_TIMEOUT_MS.
Definition at line 86 of file scan_response_merger.cpp.