Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
hub_pairing.cpp
Go to the documentation of this file.
1/// @file hub_pairing.cpp
2/// @brief Thin hub wrapper delegating all pairing logic to PairingEngine.
3/// @ingroup hioc_hub
4///
5/// All pairing implementation lives in pairing_engine.cpp. This file provides
6/// only the IOHomeControlComponent::discover_and_pair() implementation which
7/// manages the hub's busy_ flag and delegates to pairing_engine_.
8
9#include "hub_pairing.h"
10#include "hub_internal.h"
11
12#include <algorithm>
13
14namespace esphome {
15namespace home_io_control {
16
17/// Discover and pair a device in pairing mode.
18///
19/// The hub wrapper manages the busy_ flag so loop() stops hopping and polling
20/// while the blocking pairing exchange is in progress. All protocol logic is
21/// in PairingEngine::discover_and_pair().
23 if (!this->initialized_)
24 return false;
25 this->busy_ = true;
26 bool const ok = this->pairing_engine_.discover_and_pair();
27 this->busy_ = false;
28 // Never 0, so "no attempt yet" stays distinguishable (see queue_discover_and_pair()).
29 this->last_pairing_end_ms_ = std::max<uint32_t>(millis(), 1);
30 // Only fire once an attempt actually ran (telemetry was populated) — not on the early-return
31 // guard above, which would otherwise republish stale telemetry from a previous attempt.
34 return ok;
35}
36
37} // namespace home_io_control
38} // namespace esphome
uint32_t last_pairing_end_ms_
millis() when the last pairing attempt ended; 0 before the first one (see queue_discover_and_pair()).
Definition hub_core.h:1253
virtual bool discover_and_pair()
Discover and pair a device that is in pairing mode.
PairingEngine pairing_engine_
Owns the three-phase device pairing flow.
Definition hub_core.h:1279
std::function< void()> pairing_result_callback_
Invoked once after every pairing attempt completes; see set_pairing_result_callback().
Definition hub_core.h:1261
bool discover_and_pair()
Discover and pair a device currently in pairing mode (three-phase orchestrator).
Helpers shared only by the hub's own implementation files (hub_*.cpp).
Internal pairing-state model for hub‑owned discovery and key‑exchange flows.