|
Home IO Control
ESPHome add-on for IO-Homecontrol devices
|
Fixed-size per-attempt telemetry recorder for the pairing flow. More...
#include <pairing_telemetry.h>
Public Member Functions | |
| void | begin () |
| Reset all state and start a new attempt. Call once at discover_and_pair() entry. | |
| void | record_tx (uint8_t cmd) |
| Record that we transmitted a frame. | |
| void | record_rx (const IoFrame &frame, int16_t rssi) |
| Record that we received and accepted a frame. | |
| void | record_rx_reject (const IoFrame &frame, int16_t rssi) |
| Record that we received a frame that parsed but was rejected by a classifier. | |
| void | record_lbt_defer (int16_t rssi) |
| Record a listen-before-talk defer (channel busy). | |
| void | record_hop () |
| Record a frequency hop while waiting. | |
| void | set_phase (pairing::PairingState phase) |
| Record a pairing state-machine phase transition. | |
| void | set_outcome (PairingOutcome outcome) |
| Record the final outcome of the attempt. | |
| void | set_paired_device (const uint8_t node_id[NODE_ID_SIZE], DeviceType type) |
| Record the successfully paired device, if any. | |
| void | increment_discovery_attempt () |
| Increment the discovery attempt counter (one call per discovery command retry). | |
| void | set_advice_codes (const std::string &codes) |
| Record the advisor's short advice codes for the ;advice= result-sensor field. | |
| void | record_recent_one_way_sighting (const RecentOneWayPairingSighting &sighting) |
| Seed telemetry with a 1W pairing-gesture frame observed shortly before this attempt began. | |
| const PairingTelemetryEvent * | events () const |
| uint8_t | event_count () const |
| uint16_t | heard_count () const |
| uint32_t | hop_count () const |
| bool | truncated () const |
| pairing::PairingState | phase () const |
| PairingOutcome | outcome () const |
| uint8_t | discovery_attempts () const |
| uint8_t | lbt_retries () const |
| bool | has_paired_device () const |
| const uint8_t * | paired_node_id () const |
| DeviceType | paired_device_type () const |
| uint32_t | duration_ms () const |
| void | log_summary () const |
| Emit a multi-line human-readable summary via ESP_LOGI. Call once, at the end of the attempt. | |
| std::string | result_sensor_string () const |
| Render the frozen v1; machine-readable result string. | |
Fixed-size per-attempt telemetry recorder for the pairing flow.
Owned by the hub, reset at the start of every discover_and_pair() call. Not thread-safe — pairing is a single blocking call on the main loop, matching the rest of this component.
Definition at line 92 of file pairing_telemetry.h.
| void esphome::home_io_control::PairingTelemetry::begin | ( | ) |
Reset all state and start a new attempt. Call once at discover_and_pair() entry.
Definition at line 73 of file pairing_telemetry.cpp.
|
inlinenodiscard |
Definition at line 179 of file pairing_telemetry.h.
|
nodiscard |
Definition at line 172 of file pairing_telemetry.cpp.
|
inlinenodiscard |
Definition at line 162 of file pairing_telemetry.h.
|
inlinenodiscard |
Definition at line 160 of file pairing_telemetry.h.
|
inlinenodiscard |
Definition at line 183 of file pairing_telemetry.h.
|
inlinenodiscard |
Definition at line 164 of file pairing_telemetry.h.
|
inlinenodiscard |
Definition at line 167 of file pairing_telemetry.h.
| void esphome::home_io_control::PairingTelemetry::increment_discovery_attempt | ( | ) |
Increment the discovery attempt counter (one call per discovery command retry).
Definition at line 167 of file pairing_telemetry.cpp.
|
inlinenodiscard |
Definition at line 181 of file pairing_telemetry.h.
| void esphome::home_io_control::PairingTelemetry::log_summary | ( | ) | const |
Emit a multi-line human-readable summary via ESP_LOGI. Call once, at the end of the attempt.
Definition at line 174 of file pairing_telemetry.cpp.
|
inlinenodiscard |
Definition at line 177 of file pairing_telemetry.h.
|
inlinenodiscard |
Definition at line 187 of file pairing_telemetry.h.
|
inlinenodiscard |
Definition at line 185 of file pairing_telemetry.h.
|
inlinenodiscard |
Definition at line 175 of file pairing_telemetry.h.
| void esphome::home_io_control::PairingTelemetry::record_hop | ( | ) |
Record a frequency hop while waiting.
The exchange engine does not expose which channel index a hop landed on, so this only marks that a hop happened, not where to.
Counted via hop_count() only, deliberately not stored in the fixed event array: at the current 5-7 ms hop slice, a multi-second discovery window produces far more hops than PAIRING_TELEMETRY_MAX_EVENTS, which used to exhaust the buffer with hop events alone within about a second of essentially every real attempt (issue #27). This did not produce a false rf_silent — heard_count() is incremented in record_() before the capacity check, so it still counts an RX/RX_REJECT that arrives after the array is full. What it did do: once the array was full, PairingAdvisor's 1w_traffic/channel_busy/foreign_controller passes — which all scan events(), not heard_count() — could only ever see whatever RX/RX_REJECT evidence had landed in roughly the first ~200 ms of the attempt, and truncated() was true on nearly every real pairing attempt. A hop carries no per-event information worth itemizing (no channel index, no RSSI) anyway; the total count is enough.
Definition at line 140 of file pairing_telemetry.cpp.
| void esphome::home_io_control::PairingTelemetry::record_lbt_defer | ( | int16_t | rssi | ) |
Record a listen-before-talk defer (channel busy).
| rssi | RSSI in dBm that triggered the defer. |
Definition at line 134 of file pairing_telemetry.cpp.
| void esphome::home_io_control::PairingTelemetry::record_recent_one_way_sighting | ( | const RecentOneWayPairingSighting & | sighting | ) |
Seed telemetry with a 1W pairing-gesture frame observed shortly before this attempt began.
Recorded as an RX event with its real RSSI, marked seeded (PairingTelemetryEvent::aux = 1) so log_summary() can label it honestly instead of implying a live in-window capture, and so PairingAdvisor's channel_busy pass — which is specifically about live contention during this attempt — can exclude it while ONE_WAY_PAIRING_TRAFFIC still picks it up like any other RX. It counts toward heard_count(). Timestamped at the start of the attempt (millis_offset ≈ 0), since its real arrival time — before begin() — isn't preserved; the seeded marker is what tells a reader not to read that as "heard 0 ms into this attempt". The caller ( PairingEngine::discover_and_pair()) is responsible for deciding whether sighting is recent enough to seed with — this method always records what it's given.
| sighting | The overheard frame to seed telemetry with. |
Definition at line 145 of file pairing_telemetry.cpp.
| void esphome::home_io_control::PairingTelemetry::record_rx | ( | const IoFrame & | frame, |
| int16_t | rssi ) |
Record that we received and accepted a frame.
| frame | Parsed frame (cmd, src, dst, and the 1W protocol bit are recorded — dst and the 1W bit feed PairingAdvisor's ONE_WAY_PAIRING_TRAFFIC and FOREIGN_CONTROLLER_PAIRING detection, see pairing_advisor.h). |
| rssi | RSSI in dBm. |
Definition at line 124 of file pairing_telemetry.cpp.
| void esphome::home_io_control::PairingTelemetry::record_rx_reject | ( | const IoFrame & | frame, |
| int16_t | rssi ) |
Record that we received a frame that parsed but was rejected by a classifier.
| frame | Parsed frame (cmd, src, dst, and the 1W protocol bit are recorded — dst and the 1W bit feed PairingAdvisor's ONE_WAY_PAIRING_TRAFFIC and FOREIGN_CONTROLLER_PAIRING detection, see pairing_advisor.h). |
| rssi | RSSI in dBm. |
Definition at line 129 of file pairing_telemetry.cpp.
| void esphome::home_io_control::PairingTelemetry::record_tx | ( | uint8_t | cmd | ) |
Record that we transmitted a frame.
| cmd | Frame command byte. |
Definition at line 120 of file pairing_telemetry.cpp.
|
nodiscard |
Render the frozen v1; machine-readable result string.
Format (never change without bumping the version tag — the Phase 2 rig's read-back contract parses this exactly; the space after each ; is intentional — Home Assistant's UI only line-wraps this sensor's long value at whitespace, so a fields-only-separated-by-; string renders as one unbroken, unreadable line): v1; outcome=<...>; phase=<...>; node=<XXXXXX|->; type=<...|->; attempts=<n>; lbt=<n>; dur_ms=<n>; heard=<n>; advice=<comma-separated codes|none>
Definition at line 208 of file pairing_telemetry.cpp.
|
inline |
Record the advisor's short advice codes for the ;advice= result-sensor field.
| codes | Comma-separated short codes (e.g. "1w_traffic,channel_busy"), or empty if none. |
Definition at line 144 of file pairing_telemetry.h.
| void esphome::home_io_control::PairingTelemetry::set_outcome | ( | PairingOutcome | outcome | ) |
Record the final outcome of the attempt.
| outcome | Final disposition. |
Definition at line 155 of file pairing_telemetry.cpp.
| void esphome::home_io_control::PairingTelemetry::set_paired_device | ( | const uint8_t | node_id[NODE_ID_SIZE], |
| DeviceType | type ) |
Record the successfully paired device, if any.
| node_id | Paired device's node ID. |
| type | Paired device's type. |
Definition at line 161 of file pairing_telemetry.cpp.
| void esphome::home_io_control::PairingTelemetry::set_phase | ( | pairing::PairingState | phase | ) |
Record a pairing state-machine phase transition.
| phase | New phase. |
Definition at line 150 of file pairing_telemetry.cpp.
|
inlinenodiscard |
Definition at line 173 of file pairing_telemetry.h.