Home IO Control
ESPHome add-on for IO-Homecontrol devices
Toggle main menu visibility
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
14
namespace
esphome
{
15
namespace
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().
22
bool
IOHomeControlComponent::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.
32
if
(this->
pairing_result_callback_
)
33
this->
pairing_result_callback_
();
34
return
ok;
35
}
36
37
}
// namespace home_io_control
38
}
// namespace esphome
esphome::home_io_control::IOHomeControlComponent::last_pairing_end_ms_
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
esphome::home_io_control::IOHomeControlComponent::initialized_
bool initialized_
Definition
hub_core.h:1250
esphome::home_io_control::IOHomeControlComponent::discover_and_pair
virtual bool discover_and_pair()
Discover and pair a device that is in pairing mode.
Definition
hub_pairing.cpp:22
esphome::home_io_control::IOHomeControlComponent::pairing_engine_
PairingEngine pairing_engine_
Owns the three-phase device pairing flow.
Definition
hub_core.h:1279
esphome::home_io_control::IOHomeControlComponent::pairing_result_callback_
std::function< void()> pairing_result_callback_
Invoked once after every pairing attempt completes; see set_pairing_result_callback().
Definition
hub_core.h:1261
esphome::home_io_control::IOHomeControlComponent::busy_
bool busy_
Definition
hub_core.h:1251
esphome::home_io_control::PairingEngine::discover_and_pair
bool discover_and_pair()
Discover and pair a device currently in pairing mode (three-phase orchestrator).
Definition
pairing_engine.cpp:683
hub_internal.h
Helpers shared only by the hub's own implementation files (hub_*.cpp).
hub_pairing.h
Internal pairing-state model for hub‑owned discovery and key‑exchange flows.
esphome::home_io_control
Definition
device_registry.cpp:15
esphome
Definition
device_registry.cpp:14
components
home_io_control
hub_pairing.cpp
Generated by
1.18.0