ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
3#ifdef USE_OPENTHREAD
4#include "openthread.h"
5
8
9namespace esphome::openthread {
10
18class OpenThreadComponentBaseAction : public Parented<OpenThreadComponent> {
19 public:
20 // Enforce ctor with parent argument (not without args)
22
23 protected:
25 virtual void apply_locked(otInstance *instance) = 0;
26
28 void lock_and_apply_();
29
31 void warn_ftd_no_op_();
32
34 static constexpr uint32_t LOCK_ACQUIRE_TIMEOUT_MS = 100;
35};
36
38template<typename... Ts>
40 TEMPLATABLE_VALUE(uint32_t, poll_period)
41
42 public:
43 /* Passthrough ctor */
45
46 protected:
47 void play(const Ts &...x) override {
48#if CONFIG_OPENTHREAD_MTD
49 this->parent_->set_poll_period(this->poll_period_.value(x...));
50
51 this->lock_and_apply_();
52#else
53 this->warn_ftd_no_op_();
54#endif
55 }
56
57 void apply_locked(otInstance *instance) override { this->parent_->apply_linkmode_(instance); }
58};
59
60} // namespace esphome::openthread
61#endif
Helper class to easily give an object a parent of type T.
Definition helpers.h:1875
Base class allowing to fetch OpenThread lock from parent component while applying action.
Definition automation.h:18
virtual void apply_locked(otInstance *instance)=0
Handler to implement in subclass for applying action parts that need lock.
void lock_and_apply_()
Fetch OT lock and then call apply_locked.
static constexpr uint32_t LOCK_ACQUIRE_TIMEOUT_MS
Timeout (ms) for acquiring OT lock.
Definition automation.h:34
void warn_ftd_no_op_()
Log a warning that this action has no effect on FTD devices.
OpenThreadComponentBaseAction(OpenThreadComponent *ot)
Definition automation.h:21
Action to set single poll period parameter.
Definition openthread.h:22
void apply_locked(otInstance *instance) override
Definition automation.h:57
static void uint32_t
uint16_t x
Definition tt21100.cpp:5