Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
hub_decisions.h File Reference

Pure transition helpers for hub-owned exchange and pairing frame decisions. More...

#include "proto_constants.h"
#include "proto_device_model.h"
#include "proto_frame.h"
#include "proto_timing.h"
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <string>
Include dependency graph for hub_decisions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  esphome::home_io_control::decisions::OneWayDedupState
 Key fields of the last processed 1W frame, used to collapse a remote's repeat burst. More...
struct  esphome::home_io_control::decisions::TargetEvidence
 What the hub knows about the device an exchange is addressed to, as the exchange engine sees it. More...

Namespaces

namespace  esphome
namespace  esphome::home_io_control
namespace  esphome::home_io_control::decisions

Enumerations

enum class  esphome::home_io_control::decisions::ExchangeFirstResponseDisposition : uint8_t { esphome::home_io_control::decisions::IGNORE_UNRELATED , esphome::home_io_control::decisions::COMPLETE_DIRECT , esphome::home_io_control::decisions::REQUIRE_AUTH }
 Disposition for the first response in an authenticated exchange. More...
enum class  esphome::home_io_control::decisions::ExchangeFinalResponseDisposition : uint8_t { esphome::home_io_control::decisions::IGNORE_UNRELATED , esphome::home_io_control::decisions::ACCEPT }
 Disposition for the final response after authentication. More...
enum class  esphome::home_io_control::decisions::PairingDiscoveryDisposition : uint8_t { esphome::home_io_control::decisions::NO_RESPONSE , esphome::home_io_control::decisions::INVALID , esphome::home_io_control::decisions::ACCEPT }
 Disposition during pairing discovery phase. More...
enum class  esphome::home_io_control::decisions::PairingKeyChallengeDisposition : uint8_t { esphome::home_io_control::decisions::IGNORE , esphome::home_io_control::decisions::ACCEPT }
 Disposition during pairing key-challenge phase. More...
enum class  esphome::home_io_control::decisions::PairingDiscoverConfirmDisposition : uint8_t { esphome::home_io_control::decisions::IGNORE , esphome::home_io_control::decisions::ACK , esphome::home_io_control::decisions::ERROR }
 Disposition for a candidate reply to a discovery-confirm request (0x2C). More...
enum class  esphome::home_io_control::decisions::PairingKeyConfirmDisposition : uint8_t { esphome::home_io_control::decisions::IGNORE , esphome::home_io_control::decisions::CONFIRM , esphome::home_io_control::decisions::CHALLENGE , esphome::home_io_control::decisions::REFUSE }
 Disposition for a candidate reply to the key-transfer (0x32) confirm wait — the slow-turnaround path's expanded classification of PairingKeyChallengeDisposition's device challenge to also cover a direct confirm or an explicit refusal. More...
enum class  esphome::home_io_control::decisions::WakeBelief : uint8_t { esphome::home_io_control::decisions::ASLEEP , esphome::home_io_control::decisions::MAYBE_AWAKE , esphome::home_io_control::decisions::AWAKE }
 How likely a low-power receiver is to be awake right now, judged from what this hub has seen of it. More...

Functions

bool esphome::home_io_control::decisions::is_exchange_internal_command (uint8_t cmd)
 Returns true for commands that are internal to an exchange handshake and carry no useful information for a passive observer (challenge request/response).
bool esphome::home_io_control::decisions::frame_matches_nodes (const IoFrame &frame, const uint8_t expected_src[NODE_ID_SIZE], const uint8_t expected_dst[NODE_ID_SIZE])
 Check if two frames have identical src/dst node IDs.
bool esphome::home_io_control::decisions::frame_matches_exchange_endpoints (const IoFrame &request, const IoFrame &candidate)
 Check if candidate frame endpoints are the reverse of the request (dst==request.src, src==request.dst).
ExchangeFirstResponseDisposition esphome::home_io_control::decisions::classify_exchange_first_response (const IoFrame &request, const IoFrame &candidate)
 Decide how to handle the first response packet in an authenticated exchange.
ExchangeFinalResponseDisposition esphome::home_io_control::decisions::classify_exchange_final_response (const IoFrame &request, const IoFrame &candidate)
 Decide if a candidate frame is an acceptable final response after authentication.
bool esphome::home_io_control::decisions::is_repeatable_execute (const IoFrame &request)
 True for a CMD_EXECUTE that has the same effect sent twice as sent once.
bool esphome::home_io_control::decisions::retry_after_unconfirmed_accept_is_safe (const IoFrame &request, bool target_confirms_execute, uint8_t unconfirmed_tries)
 Whether an authenticated-but-unanswered request may be sent again.
PairingDiscoveryDisposition esphome::home_io_control::decisions::classify_pairing_discovery_response (const IoFrame &candidate, const uint8_t controller_id[NODE_ID_SIZE])
 Decide if a frame is a valid discovery response (0x29) during pairing.
PairingKeyChallengeDisposition esphome::home_io_control::decisions::classify_pairing_key_challenge (const IoFrame &candidate, const uint8_t device_id[NODE_ID_SIZE], const uint8_t controller_id[NODE_ID_SIZE])
 Decide if a frame is a valid key-challenge (0x3C) during pairing key exchange.
PairingDiscoverConfirmDisposition esphome::home_io_control::decisions::classify_pairing_discover_confirm_reply (const IoFrame &candidate, const uint8_t device_id[NODE_ID_SIZE], const uint8_t controller_id[NODE_ID_SIZE])
 Decide how to handle a candidate reply to a discovery-confirm request (0x2C) during pairing.
PairingKeyConfirmDisposition esphome::home_io_control::decisions::classify_pairing_key_confirm_reply (const IoFrame &request, const IoFrame &candidate)
 Decide how to handle a candidate reply to the key-transfer (0x32) confirm wait (wait_for_key_confirm_(), slow-turnaround chips only).
bool esphome::home_io_control::decisions::discover_confirm_try_rotates (uint8_t try_index)
 Whether discover-confirm try try_index (1-based) should rotate channels rather than hold the request channel.
bool esphome::home_io_control::decisions::is_duplicate_1w_frame (const OneWayDedupState &last, const OneWayDedupState &incoming, uint32_t window_ms)
 Decide whether an incoming 1W frame repeats the previous one inside the burst window.
bool esphome::home_io_control::decisions::defer_background_poll_for_1w_activity (bool next_op_is_background, uint32_t first_1w_activity_ms, uint32_t last_1w_activity_ms, uint32_t now, uint32_t quiet_ms, uint32_t max_defer_ms)
 Decide whether to hold back a queued background poll because a 1W remote is still transmitting.
uint8_t esphome::home_io_control::decisions::scheduled_poll_max_tries (uint8_t status_poll_failures, uint8_t auth_poll_failures, bool settles_a_stop=false)
 Transmit-attempt budget for a scheduler-owned status poll, by backoff-ladder position.
TargetEvidence esphome::home_io_control::decisions::target_evidence (const IoDevice &dev)
 Build the exchange engine's view of a device record.
bool esphome::home_io_control::decisions::is_stop_request (const IoFrame &request)
 True for a CMD_EXECUTE whose main byte is POS_STOP.
WakeBelief esphome::home_io_control::decisions::wake_belief (const TargetEvidence &evidence, uint32_t now, bool is_stop)
 Judge how awake a low-power receiver is.
uint16_t esphome::home_io_control::decisions::low_power_try_preamble (WakeBelief belief, uint8_t try_index, uint16_t short_preamble)
 Start-preamble length for one try of a directed exchange to a low-power receiver.
const char * esphome::home_io_control::decisions::wake_belief_name (WakeBelief belief)
 Lowercase name of a belief for log lines.
bool esphome::home_io_control::decisions::is_one_way_pairing_gesture (bool oneway, const uint8_t dst[NODE_ID_SIZE], uint8_t cmd)
 True if a frame's shape matches a 1W remote's pairing gesture (issue #27/#65): CTRL0 1W bit set, addressed to the 1W broadcast address (0x00003F), with one of the three command bytes observed in the field capture — 0x20 (WRITE_PRIVATE), 0x39 (1W remove), or 0x2E (alternate discovery, 1W-flagged).
bool esphome::home_io_control::decisions::oneway_burst_started_fresh (uint32_t last_1w_activity_ms, uint32_t now, uint32_t quiet_ms)
 Whether a 1W frame arriving at now starts a new burst rather than extending the current one — true if no frame has been seen yet, or the gap since the last one reached quiet_ms (the previous burst already released any deferred poll).
uint32_t esphome::home_io_control::decisions::remote_poll_timer_id (const uint8_t node_id[NODE_ID_SIZE])
 Numeric set_timeout() id for a device's remote-activity poll timer (hub_status.cpp's schedule_status_poll_()).

Variables

constexpr uint32_t esphome::home_io_control::decisions::REMOTE_POLL_TIMER_ID_TAG = 0x01000000
 Namespace tag for remote_poll_timer_id() below: the node address occupies the low 24 bits, and this is OR-ed in above them.

Detailed Description

Pure transition helpers for hub-owned exchange and pairing frame decisions.

This header contains inline, testable decision logic: frame classification for exchange and pairing flows, plus shared timing utilities. No state, no side effects — suitable for unit testing without radio hardware.

Definition in file hub_decisions.h.