ESPHome
2023.5.5
|
OTAComponent provides a simple way to integrate Over-the-Air updates into your app using ArduinoOTA. More...
#include <ota_component.h>
Public Member Functions | |
OTAComponent () | |
void | set_auth_password (const std::string &password) |
void | set_port (uint16_t port) |
Manually set the port OTA should listen on. More... | |
bool | should_enter_safe_mode (uint8_t num_attempts, uint32_t enable_time) |
void | set_safe_mode_pending (const bool &pending) |
Set to true if the next startup will enter safe mode. More... | |
bool | get_safe_mode_pending () |
void | add_on_state_callback (std::function< void(OTAState, float, uint8_t)> &&callback) |
void | setup () override |
void | dump_config () override |
float | get_setup_priority () const override |
void | loop () override |
uint16_t | get_port () const |
void | clean_rtc () |
void | on_safe_shutdown () override |
![]() | |
float | get_actual_setup_priority () const |
void | set_setup_priority (float priority) |
virtual float | get_loop_priority () const |
priority of loop(). More... | |
void | call () |
virtual void | on_shutdown () |
uint32_t | get_component_state () const |
virtual void | mark_failed () |
Mark this component as failed. More... | |
bool | is_failed () |
bool | is_ready () |
virtual bool | can_proceed () |
bool | status_has_warning () |
bool | status_has_error () |
void | status_set_warning () |
void | status_set_error () |
void | status_clear_warning () |
void | status_clear_error () |
void | status_momentary_warning (const std::string &name, uint32_t length=5000) |
void | status_momentary_error (const std::string &name, uint32_t length=5000) |
bool | has_overridden_loop () const |
void | set_component_source (const char *source) |
Set where this component was loaded from for some debug messages. More... | |
const char * | get_component_source () const |
Get the integration where this component was declared as a string. More... | |
Protected Member Functions | |
void | write_rtc_ (uint32_t val) |
uint32_t | read_rtc_ () |
void | handle_ () |
bool | readall_ (uint8_t *buf, size_t len) |
bool | writeall_ (const uint8_t *buf, size_t len) |
![]() | |
virtual void | call_loop () |
virtual void | call_setup () |
virtual void | call_dump_config () |
void | set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f) |
Set an interval function with a unique name. More... | |
void | set_interval (uint32_t interval, std::function< void()> &&f) |
bool | cancel_interval (const std::string &name) |
Cancel an interval function. More... | |
void | set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f) |
Set an retry function with a unique name. More... | |
void | set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f) |
bool | cancel_retry (const std::string &name) |
Cancel a retry function. More... | |
void | set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f) |
Set a timeout function with a unique name. More... | |
void | set_timeout (uint32_t timeout, std::function< void()> &&f) |
bool | cancel_timeout (const std::string &name) |
Cancel a timeout function. More... | |
void | defer (const std::string &name, std::function< void()> &&f) |
Defer a callback to the next loop() call. More... | |
void | defer (std::function< void()> &&f) |
Defer a callback to the next loop() call. More... | |
bool | cancel_defer (const std::string &name) |
Cancel a defer callback using the specified name, name must not be empty. More... | |
Protected Attributes | |
std::string | password_ |
uint16_t | port_ |
std::unique_ptr< socket::Socket > | server_ |
std::unique_ptr< socket::Socket > | client_ |
bool | has_safe_mode_ {false} |
stores whether safe mode can be enabled. More... | |
uint32_t | safe_mode_start_time_ |
stores when safe mode was enabled. More... | |
uint32_t | safe_mode_enable_time_ {60000} |
The time safe mode should be on for. More... | |
uint32_t | safe_mode_rtc_value_ |
uint8_t | safe_mode_num_attempts_ |
ESPPreferenceObject | rtc_ |
CallbackManager< void(OTAState, float, uint8_t)> | state_callback_ {} |
![]() | |
uint32_t | component_state_ {0x0000} |
State of this component. More... | |
float | setup_priority_override_ {NAN} |
const char * | component_source_ {nullptr} |
Static Protected Attributes | |
static const uint32_t | ENTER_SAFE_MODE_MAGIC |
a magic number to indicate that safe mode should be entered on next boot More... | |
OTAComponent provides a simple way to integrate Over-the-Air updates into your app using ArduinoOTA.
Definition at line 43 of file ota_component.h.
esphome::ota::OTAComponent::OTAComponent | ( | ) |
Definition at line 44 of file ota_component.cpp.
void esphome::ota::OTAComponent::add_on_state_callback | ( | std::function< void(OTAState, float, uint8_t)> && | callback | ) |
Definition at line 515 of file ota_component.cpp.
void esphome::ota::OTAComponent::clean_rtc | ( | ) |
Definition at line 508 of file ota_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 92 of file ota_component.cpp.
uint16_t esphome::ota::OTAComponent::get_port | ( | ) | const |
Definition at line 433 of file ota_component.cpp.
bool esphome::ota::OTAComponent::get_safe_mode_pending | ( | ) |
Definition at line 452 of file ota_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 432 of file ota_component.cpp.
|
protected |
Definition at line 120 of file ota_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 107 of file ota_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 509 of file ota_component.cpp.
|
protected |
Definition at line 502 of file ota_component.cpp.
|
protected |
Definition at line 373 of file ota_component.cpp.
|
inline |
Definition at line 47 of file ota_component.h.
void esphome::ota::OTAComponent::set_port | ( | uint16_t | port | ) |
Manually set the port OTA should listen on.
Definition at line 434 of file ota_component.cpp.
void esphome::ota::OTAComponent::set_safe_mode_pending | ( | const bool & | pending | ) |
Set to true if the next startup will enter safe mode.
Definition at line 436 of file ota_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 46 of file ota_component.cpp.
bool esphome::ota::OTAComponent::should_enter_safe_mode | ( | uint8_t | num_attempts, |
uint32_t | enable_time | ||
) |
Definition at line 456 of file ota_component.cpp.
|
protected |
Definition at line 498 of file ota_component.cpp.
|
protected |
Definition at line 404 of file ota_component.cpp.
|
protected |
Definition at line 91 of file ota_component.h.
|
staticprotected |
a magic number to indicate that safe mode should be entered on next boot
Definition at line 100 of file ota_component.h.
|
protected |
stores whether safe mode can be enabled.
Definition at line 93 of file ota_component.h.
|
protected |
Definition at line 85 of file ota_component.h.
|
protected |
Definition at line 88 of file ota_component.h.
|
protected |
Definition at line 98 of file ota_component.h.
|
protected |
The time safe mode should be on for.
Definition at line 95 of file ota_component.h.
|
protected |
Definition at line 97 of file ota_component.h.
|
protected |
Definition at line 96 of file ota_component.h.
|
protected |
stores when safe mode was enabled.
Definition at line 94 of file ota_component.h.
|
protected |
Definition at line 90 of file ota_component.h.
|
protected |
Definition at line 104 of file ota_component.h.