Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
Loading...
Searching...
No Matches
pairing_advisor.h
Go to the documentation of this file.
1
#pragma once
2
3
/// @file pairing_advisor.h
4
/// @brief Read-only advisor that turns PairingTelemetry into actionable diagnostics.
5
/// @ingroup hioc_hub
6
///
7
/// PairingAdvisor is a pure, stateless consumer of a completed PairingTelemetry attempt: it
8
/// never touches the radio or the pairing state machine, only inspects the events already
9
/// recorded. It exists to convert the most common field failures (a 1W remote's PROG gesture
10
/// overheard while no device answers, issues #27/#121; a busy channel; a foreign controller
11
/// mid-pairing; dead RF)
12
/// from a hex-dump exercise into a self-explaining WARN line.
13
14
#include "
pairing_telemetry.h
"
15
#include "
proto_frame.h
"
16
17
#include <cstdint>
18
#include <string>
19
20
namespace
esphome
{
21
namespace
home_io_control
{
22
namespace
advisor
{
23
24
/// @brief Actionable diagnosis derived from a completed pairing attempt's telemetry.
25
enum class
PairingAdviceCode
: uint8_t {
26
NONE
,
///< Nothing actionable to report.
27
ONE_WAY_PAIRING_TRAFFIC
,
///< A 1W remote's PROG gesture was overheard. Proves a gesture happened,
28
///< not the device's state: the same frames also precede successful
29
///< pairings (issue #19).
30
CHANNEL_BUSY_LBT_DELAYED
,
///< LBT retries were consumed while a source kept repeating; the
31
///< reported subject_node is a best-effort correlation (LBT's
32
///< carrier-sense doesn't parse frames, so the actual jammer may
33
///< not be among the parsed events attributed here).
34
FOREIGN_CONTROLLER_PAIRING
,
///< A discovery response was seen addressed to another controller.
35
RF_SILENT
,
///< Nothing at all was heard during the whole window.
36
};
37
38
/// @brief One piece of advice, with the node/RSSI it pertains to (if any).
39
struct
PairingAdvice
{
40
PairingAdviceCode
code
{
PairingAdviceCode::NONE
};
41
uint8_t
subject_node
[NODE_ID_SIZE]{};
///< Node the advice is about; zero if not applicable.
42
int16_t
rssi
{0};
///< RSSI associated with the observation; zero if not applicable.
43
};
44
45
/// @brief Maximum number of advice entries a single attempt can produce (one slot per non-NONE code).
46
static
constexpr
uint8_t
PAIRING_ADVICE_MAX
= 4;
47
48
/// @brief Inspect a completed pairing attempt's telemetry and produce actionable advice.
49
///
50
/// Read-only: never mutates telemetry, never touches the radio or pairing state machine.
51
/// @param telemetry Completed (or in-progress) telemetry for one pairing attempt.
52
/// @param own_node_id This controller's node ID, used to detect discovery responses addressed
53
/// to a different controller.
54
/// @param out Output buffer, must hold at least PAIRING_ADVICE_MAX entries.
55
/// @return Number of advice entries written to `out` (0 if nothing actionable was found).
56
uint8_t
analyze_pairing_telemetry
(
const
PairingTelemetry
&telemetry,
const
uint8_t own_node_id[NODE_ID_SIZE],
57
PairingAdvice
out[PAIRING_ADVICE_MAX]);
58
59
/// @return Short, stable code string for the `;advice=` result-sensor field (e.g. "1w_traffic").
60
const
char
*
pairing_advice_code_name
(
PairingAdviceCode
code);
61
62
/// @return The full actionable, human-readable WARN message for one piece of advice.
63
std::string
pairing_advice_message
(
const
PairingAdvice
&advice);
64
65
}
// namespace advisor
66
}
// namespace home_io_control
67
}
// namespace esphome
esphome::home_io_control::PairingTelemetry
Fixed-size per-attempt telemetry recorder for the pairing flow.
Definition
pairing_telemetry.h:93
esphome::home_io_control::advisor
Definition
pairing_advisor.cpp:16
esphome::home_io_control::advisor::pairing_advice_message
std::string pairing_advice_message(const PairingAdvice &advice)
Definition
pairing_advisor.cpp:154
esphome::home_io_control::advisor::PAIRING_ADVICE_MAX
static constexpr uint8_t PAIRING_ADVICE_MAX
Maximum number of advice entries a single attempt can produce (one slot per non-NONE code).
Definition
pairing_advisor.h:46
esphome::home_io_control::advisor::pairing_advice_code_name
const char * pairing_advice_code_name(PairingAdviceCode code)
Definition
pairing_advisor.cpp:138
esphome::home_io_control::advisor::PairingAdviceCode
PairingAdviceCode
Actionable diagnosis derived from a completed pairing attempt's telemetry.
Definition
pairing_advisor.h:25
esphome::home_io_control::advisor::PairingAdviceCode::RF_SILENT
@ RF_SILENT
Nothing at all was heard during the whole window.
Definition
pairing_advisor.h:35
esphome::home_io_control::advisor::PairingAdviceCode::NONE
@ NONE
Nothing actionable to report.
Definition
pairing_advisor.h:26
esphome::home_io_control::advisor::PairingAdviceCode::FOREIGN_CONTROLLER_PAIRING
@ FOREIGN_CONTROLLER_PAIRING
A discovery response was seen addressed to another controller.
Definition
pairing_advisor.h:34
esphome::home_io_control::advisor::PairingAdviceCode::ONE_WAY_PAIRING_TRAFFIC
@ ONE_WAY_PAIRING_TRAFFIC
A 1W remote's PROG gesture was overheard.
Definition
pairing_advisor.h:27
esphome::home_io_control::advisor::PairingAdviceCode::CHANNEL_BUSY_LBT_DELAYED
@ CHANNEL_BUSY_LBT_DELAYED
LBT retries were consumed while a source kept repeating; the reported subject_node is a best-effort c...
Definition
pairing_advisor.h:30
esphome::home_io_control::advisor::analyze_pairing_telemetry
uint8_t analyze_pairing_telemetry(const PairingTelemetry &telemetry, const uint8_t own_node_id[NODE_ID_SIZE], PairingAdvice out[PAIRING_ADVICE_MAX])
Inspect a completed pairing attempt's telemetry and produce actionable advice.
Definition
pairing_advisor.cpp:121
esphome::home_io_control
Definition
device_registry.cpp:13
esphome::home_io_control::BootloaderMismatch::NONE
@ NONE
target_fw is unknown, or its required bootloader matches bootloader_version.
Definition
lr1121_firmware_decisions.h:156
esphome
Definition
device_registry.cpp:12
pairing_telemetry.h
Structured per-attempt telemetry recorder for the pairing flow.
proto_frame.h
IO-Homecontrol 2W frame container: control bytes, IoFrame and (de)serialization.
esphome::home_io_control::advisor::PairingAdvice
One piece of advice, with the node/RSSI it pertains to (if any).
Definition
pairing_advisor.h:39
esphome::home_io_control::advisor::PairingAdvice::subject_node
uint8_t subject_node[NODE_ID_SIZE]
Node the advice is about; zero if not applicable.
Definition
pairing_advisor.h:41
esphome::home_io_control::advisor::PairingAdvice::code
PairingAdviceCode code
Definition
pairing_advisor.h:40
esphome::home_io_control::advisor::PairingAdvice::rssi
int16_t rssi
RSSI associated with the observation; zero if not applicable.
Definition
pairing_advisor.h:42
components
home_io_control
pairing_advisor.h
Generated by
1.18.0