|
antenna-switcher-client 0.5.0
Async C++17 client for the antenna-switcher device over the ESPHome native API
|
Async, event-driven controller for the antenna-switcher device. More...
#include <client.hpp>
Public Types | |
| using | StateCallback = std::function< void(Channel, const ChannelState &)> |
| Called with the channel and its new state after each state update. | |
Public Member Functions | |
| AntennaSwitcher (Options opts) | |
| ~AntennaSwitcher () | |
| AntennaSwitcher (const AntennaSwitcher &)=delete | |
| AntennaSwitcher & | operator= (const AntennaSwitcher &)=delete |
| void | connect () const |
| Connect, enumerate entities, and resolve the per-channel handles. | |
| void | disconnect () const |
| Gracefully disconnect and stop the worker thread. | |
| bool | isConnected () const |
| void | setInput (Channel channel, int input) const |
Select input input (1..10) on channel (sends set:N). | |
| void | startAuto (Channel channel, int interval, TimeUnit unit, const std::vector< int > &inputs={}) const |
Start auto-cycling channel with the given interval. | |
| void | runPlan (Channel channel, const std::vector< PlanStep > &steps, bool repeat=false) const |
Run an ordered plan on channel, optionally repeating. | |
| void | stop (Channel channel) const |
Stop any auto/plan activity on channel (sends stop). | |
| void | setAngleOffset (Channel channel, int degrees) const |
| Set the compass angle offset for input 1 (degrees, written to the number entity). | |
| ChannelState | state (Channel channel) const |
Thread-safe snapshot of channel's latest state. | |
| void | onStateChanged (StateCallback cb) const |
| Register a state-change listener (invoked on the loop thread). | |
Async, event-driven controller for the antenna-switcher device.
Owns a background worker thread that drives the ESPHome event loop. Commands are marshalled onto that loop, so the public methods are safe to call from any thread. State-change callbacks run on the loop thread.
| using antenna_switcher::AntennaSwitcher::StateCallback = std::function<void(Channel, const ChannelState&)> |
Called with the channel and its new state after each state update.
|
explicit |
| antenna_switcher::AntennaSwitcher::~AntennaSwitcher | ( | ) |
|
delete |
| void antenna_switcher::AntennaSwitcher::connect | ( | ) | const |
Connect, enumerate entities, and resolve the per-channel handles.
Blocks until ready; throws (esphome::api::ApiError, std::runtime_error) on failure.
| void antenna_switcher::AntennaSwitcher::disconnect | ( | ) | const |
Gracefully disconnect and stop the worker thread.
| bool antenna_switcher::AntennaSwitcher::isConnected | ( | ) | const |
| void antenna_switcher::AntennaSwitcher::onStateChanged | ( | StateCallback | cb | ) | const |
Register a state-change listener (invoked on the loop thread).
|
delete |
| void antenna_switcher::AntennaSwitcher::runPlan | ( | Channel | channel, |
| const std::vector< PlanStep > & | steps, | ||
| bool | repeat = false |
||
| ) | const |
Run an ordered plan on channel, optionally repeating.
| void antenna_switcher::AntennaSwitcher::setAngleOffset | ( | Channel | channel, |
| int | degrees | ||
| ) | const |
Set the compass angle offset for input 1 (degrees, written to the number entity).
| void antenna_switcher::AntennaSwitcher::setInput | ( | Channel | channel, |
| int | input | ||
| ) | const |
Select input input (1..10) on channel (sends set:N).
| void antenna_switcher::AntennaSwitcher::startAuto | ( | Channel | channel, |
| int | interval, | ||
| TimeUnit | unit, | ||
| const std::vector< int > & | inputs = {} |
||
| ) | const |
Start auto-cycling channel with the given interval.
When inputs has 1..9 entries they form the cycle order; empty or all-ten cycles every input.
| ChannelState antenna_switcher::AntennaSwitcher::state | ( | Channel | channel | ) | const |
Thread-safe snapshot of channel's latest state.
| void antenna_switcher::AntennaSwitcher::stop | ( | Channel | channel | ) | const |
Stop any auto/plan activity on channel (sends stop).