ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
esphome::openthread::OpenThreadComponent Class Referencefinal

#include <openthread.h>

Inheritance diagram for esphome::openthread::OpenThreadComponent:
esphome::Component

Public Member Functions

 OpenThreadComponent ()
 
 ~OpenThreadComponent ()
 
void dump_config () override
 
void setup () override
 
bool teardown () override
 
float get_setup_priority () const override
 
bool is_connected () const
 
bool is_lock_initialized () const
 Returns true once esp_openthread_init() has completed and the OT lock is usable.
 
network::IPAddresses get_ip_addresses ()
 
std::optional< otIp6Address > get_omr_address ()
 
void ot_main ()
 
void on_factory_reset (std::function< void()> callback)
 
void defer_factory_reset_external_callback ()
 
const char * get_use_address () const
 Returns nullptr when no explicit use_address is configured and the address is derived at runtime from the device name (see network::get_use_address_to()).
 
void set_use_address (const char *use_address)
 
void set_poll_period (uint32_t poll_period)
 
uint32_t get_poll_period () const
 
void set_output_power (int8_t output_power)
 
void set_connected (bool connected)
 
- Public Member Functions inherited from esphome::Component
virtual void loop ()
 This method will be called repeatedly.
 
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
virtual void on_powerdown ()
 Called after teardown is complete to power down hardware.
 
uint8_t get_component_state () const
 
void reset_to_construction_state ()
 Reset this component back to the construction state to allow setup to run again.
 
bool is_in_loop_state () const
 Check if this component has completed setup and is in the loop state.
 
bool is_idle () const
 Check if this component is idle.
 
void mark_failed ()
 Mark this component as failed.
 
void mark_failed (const LogString *message)
 
void disable_loop ()
 Disable this component's loop.
 
void enable_loop ()
 Enable this component's loop.
 
void enable_loop_soon_any_context ()
 Thread and ISR-safe version of enable_loop() that can be called from any context.
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning ()
 
void status_set_warning (const char *message)
 
void status_set_warning (const LogString *message)
 
void status_set_error ()
 
void status_set_error (const LogString *message)
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const char *name, uint32_t length=5000)
 Set warning status flag and automatically clear it after a timeout.
 
void status_momentary_error (const char *name, uint32_t length=5000)
 Set error status flag and automatically clear it after a timeout.
 
bool has_overridden_loop () const
 
const LogString * get_component_log_str () const ESPHOME_ALWAYS_INLINE
 Get the integration where this component was declared as a LogString for logging.
 
bool should_warn_of_blocking (uint32_t blocking_time, uint32_t &threshold_ms_out)
 

Static Public Member Functions

static void on_state_changed (otChangedFlags flags, void *context)
 

Protected Member Functions

void apply_linkmode_ (otInstance *instance)
 Apply Link Mode settings (incl poll period).
 
std::optional< otIp6Address > get_omr_address_ (InstanceLock &lock)
 
otInstance * get_openthread_instance_ ()
 
int openthread_stop_ ()
 
- Protected Member Functions inherited from esphome::Component
friend void::setup ()
 
friend void::original_setup ()
 
void set_component_source_ (uint8_t index)
 Set where this component was loaded from for some debug messages.
 
virtual void call_setup ()
 
void call_dump_config_ ()
 
void enable_loop_slow_path_ ()
 
void set_component_state_ (uint8_t state)
 Helper to set component state (clears state bits and sets new state)
 
bool set_status_flag_ (uint8_t flag)
 Helper to set a status LED flag on both this component and the app.
 
void set_interval (const char *name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a const char* name.
 
void set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a numeric ID (zero heap allocation).
 
void set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f)
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const char *name)
 Cancel an interval function.
 
bool cancel_interval (uint32_t id)
 
bool cancel_interval (InternalSchedulerID id)
 
void set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a const char* name.
 
void set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a numeric ID (zero heap allocation).
 
void set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f)
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const char *name)
 Cancel a timeout function.
 
bool cancel_timeout (uint32_t id)
 
bool cancel_timeout (InternalSchedulerID id)
 
void defer (const char *name, std::function< void()> &&f)
 Defer a callback to the next loop() call with a const char* name.
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call.
 
void defer (uint32_t id, std::function< void()> &&f)
 Defer a callback with a numeric ID (zero heap allocation)
 
bool cancel_defer (const char *name)
 Cancel a defer callback using the specified name, name must not be empty.
 
bool cancel_defer (uint32_t id)
 
void status_clear_warning_slow_path_ ()
 
void status_clear_error_slow_path_ ()
 

Protected Attributes

std::function< void()> factory_reset_external_callback_
 
uint32_t poll_period_ {0}
 
std::optional< int8_t > output_power_ {}
 
std::atomic< bool > lock_initialized_ {false}
 
bool teardown_started_ {false}
 
bool teardown_complete_ {false}
 
bool connected_ {false}
 
- Protected Attributes inherited from esphome::Component
uint8_t component_source_index_ {0}
 Index into component source PROGMEM lookup table (0 = not set)
 
uint8_t warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_CS}
 Warn threshold in centiseconds (max 2550ms)
 
uint8_t component_state_ {0x00}
 State of this component - each bit has a purpose: Bits 0-2: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED, 0x04=LOOP_DONE) Bit 3: STATUS_LED_WARNING Bit 4: STATUS_LED_ERROR Bit 5: Has overridden loop() (set at registration time) Bits 6-7: Unused - reserved for future expansion.
 
volatile bool pending_enable_loop_ {false}
 ISR-safe flag for enable_loop_soon_any_context.
 
ComponentRuntimeStats runtime_stats_
 

Detailed Description

Definition at line 24 of file openthread.h.

Constructor & Destructor Documentation

◆ OpenThreadComponent()

esphome::openthread::OpenThreadComponent::OpenThreadComponent ( )

Definition at line 25 of file openthread.cpp.

◆ ~OpenThreadComponent()

esphome::openthread::OpenThreadComponent::~OpenThreadComponent ( )

Member Function Documentation

◆ apply_linkmode_()

void esphome::openthread::OpenThreadComponent::apply_linkmode_ ( otInstance * instance)
protected

Apply Link Mode settings (incl poll period).

Callers running outside the OpenThread task must hold InstanceLock. ot_main() runs on the OpenThread task itself and must not acquire the lock.

Definition at line 269 of file openthread.cpp.

◆ defer_factory_reset_external_callback()

void esphome::openthread::OpenThreadComponent::defer_factory_reset_external_callback ( )

Definition at line 86 of file openthread.cpp.

◆ dump_config()

void esphome::openthread::OpenThreadComponent::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 27 of file openthread.cpp.

◆ get_ip_addresses()

network::IPAddresses esphome::openthread::OpenThreadComponent::get_ip_addresses ( )

Definition at line 177 of file openthread_esp.cpp.

◆ get_omr_address()

std::optional< otIp6Address > esphome::openthread::OpenThreadComponent::get_omr_address ( )

Definition at line 59 of file openthread.cpp.

◆ get_omr_address_()

std::optional< otIp6Address > esphome::openthread::OpenThreadComponent::get_omr_address_ ( InstanceLock & lock)
protected

Definition at line 64 of file openthread.cpp.

◆ get_openthread_instance_()

otInstance * esphome::openthread::OpenThreadComponent::get_openthread_instance_ ( )
protected

Definition at line 192 of file openthread_esp.cpp.

◆ get_poll_period()

uint32_t esphome::openthread::OpenThreadComponent::get_poll_period ( ) const
inline

Definition at line 48 of file openthread.h.

◆ get_setup_priority()

float esphome::openthread::OpenThreadComponent::get_setup_priority ( ) const
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 31 of file openthread.h.

◆ get_use_address()

const char * esphome::openthread::OpenThreadComponent::get_use_address ( ) const
inline

Returns nullptr when no explicit use_address is configured and the address is derived at runtime from the device name (see network::get_use_address_to()).

Definition at line 44 of file openthread.h.

◆ is_connected()

bool esphome::openthread::OpenThreadComponent::is_connected ( ) const
inline

Definition at line 33 of file openthread.h.

◆ is_lock_initialized()

bool esphome::openthread::OpenThreadComponent::is_lock_initialized ( ) const
inline

Returns true once esp_openthread_init() has completed and the OT lock is usable.

Definition at line 35 of file openthread.h.

◆ on_factory_reset()

void esphome::openthread::OpenThreadComponent::on_factory_reset ( std::function< void()> callback)

Definition at line 254 of file openthread.cpp.

◆ on_state_changed()

void esphome::openthread::OpenThreadComponent::on_state_changed ( otChangedFlags flags,
void * context )
static

Definition at line 47 of file openthread.cpp.

◆ openthread_stop_()

int esphome::openthread::OpenThreadComponent::openthread_stop_ ( )
protected

Definition at line 175 of file openthread_esp.cpp.

◆ ot_main()

void esphome::openthread::OpenThreadComponent::ot_main ( )

Definition at line 59 of file openthread_esp.cpp.

◆ set_connected()

void esphome::openthread::OpenThreadComponent::set_connected ( bool connected)
inline

Definition at line 51 of file openthread.h.

◆ set_output_power()

void esphome::openthread::OpenThreadComponent::set_output_power ( int8_t output_power)
inline

Definition at line 50 of file openthread.h.

◆ set_poll_period()

void esphome::openthread::OpenThreadComponent::set_poll_period ( uint32_t poll_period)
inline

Definition at line 47 of file openthread.h.

◆ set_use_address()

void esphome::openthread::OpenThreadComponent::set_use_address ( const char * use_address)
inline

Definition at line 45 of file openthread.h.

◆ setup()

void esphome::openthread::OpenThreadComponent::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 30 of file openthread_esp.cpp.

◆ teardown()

bool esphome::openthread::OpenThreadComponent::teardown ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 231 of file openthread.cpp.

Field Documentation

◆ connected_

bool esphome::openthread::OpenThreadComponent::connected_ {false}
protected

Definition at line 76 of file openthread.h.

◆ factory_reset_external_callback_

std::function<void()> esphome::openthread::OpenThreadComponent::factory_reset_external_callback_
protected

Definition at line 68 of file openthread.h.

◆ lock_initialized_

std::atomic<bool> esphome::openthread::OpenThreadComponent::lock_initialized_ {false}
protected

Definition at line 73 of file openthread.h.

◆ output_power_

std::optional<int8_t> esphome::openthread::OpenThreadComponent::output_power_ {}
protected

Definition at line 72 of file openthread.h.

◆ poll_period_

uint32_t esphome::openthread::OpenThreadComponent::poll_period_ {0}
protected

Definition at line 70 of file openthread.h.

◆ teardown_complete_

bool esphome::openthread::OpenThreadComponent::teardown_complete_ {false}
protected

Definition at line 75 of file openthread.h.

◆ teardown_started_

bool esphome::openthread::OpenThreadComponent::teardown_started_ {false}
protected

Definition at line 74 of file openthread.h.


The documentation for this class was generated from the following files: