ESPHome  2022.6.2
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
esphome::ota::OTAComponent Class Reference

OTAComponent provides a simple way to integrate Over-the-Air updates into your app using ArduinoOTA. More...

#include <ota_component.h>

Inheritance diagram for esphome::ota::OTAComponent:
esphome::Component

Public Member Functions

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
 
- Public Member Functions inherited from esphome::Component
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 ()
 
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)
 
- Protected Member Functions inherited from esphome::Component
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()> &&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()> &&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::Socketserver_
 
std::unique_ptr< socket::Socketclient_
 
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_ {}
 
- Protected Attributes inherited from esphome::Component
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...
 

Detailed Description

OTAComponent provides a simple way to integrate Over-the-Air updates into your app using ArduinoOTA.

Definition at line 41 of file ota_component.h.

Member Function Documentation

◆ add_on_state_callback()

void esphome::ota::OTAComponent::add_on_state_callback ( std::function< void(OTAState, float, uint8_t)> &&  callback)

Definition at line 506 of file ota_component.cpp.

◆ clean_rtc()

void esphome::ota::OTAComponent::clean_rtc ( )

Definition at line 499 of file ota_component.cpp.

◆ dump_config()

void esphome::ota::OTAComponent::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 84 of file ota_component.cpp.

◆ get_port()

uint16_t esphome::ota::OTAComponent::get_port ( ) const

Definition at line 425 of file ota_component.cpp.

◆ get_safe_mode_pending()

bool esphome::ota::OTAComponent::get_safe_mode_pending ( )

Definition at line 444 of file ota_component.cpp.

◆ get_setup_priority()

float esphome::ota::OTAComponent::get_setup_priority ( ) const
overridevirtual

Reimplemented from esphome::Component.

Definition at line 424 of file ota_component.cpp.

◆ handle_()

void esphome::ota::OTAComponent::handle_ ( )
protected

Definition at line 112 of file ota_component.cpp.

◆ loop()

void esphome::ota::OTAComponent::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 99 of file ota_component.cpp.

◆ on_safe_shutdown()

void esphome::ota::OTAComponent::on_safe_shutdown ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 500 of file ota_component.cpp.

◆ read_rtc_()

uint32_t esphome::ota::OTAComponent::read_rtc_ ( )
protected

Definition at line 493 of file ota_component.cpp.

◆ readall_()

bool esphome::ota::OTAComponent::readall_ ( uint8_t *  buf,
size_t  len 
)
protected

Definition at line 365 of file ota_component.cpp.

◆ set_auth_password()

void esphome::ota::OTAComponent::set_auth_password ( const std::string &  password)
inline

Definition at line 44 of file ota_component.h.

◆ set_port()

void esphome::ota::OTAComponent::set_port ( uint16_t  port)

Manually set the port OTA should listen on.

Definition at line 426 of file ota_component.cpp.

◆ set_safe_mode_pending()

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 428 of file ota_component.cpp.

◆ setup()

void esphome::ota::OTAComponent::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 38 of file ota_component.cpp.

◆ should_enter_safe_mode()

bool esphome::ota::OTAComponent::should_enter_safe_mode ( uint8_t  num_attempts,
uint32_t  enable_time 
)

Definition at line 448 of file ota_component.cpp.

◆ write_rtc_()

void esphome::ota::OTAComponent::write_rtc_ ( uint32_t  val)
protected

Definition at line 489 of file ota_component.cpp.

◆ writeall_()

bool esphome::ota::OTAComponent::writeall_ ( const uint8_t *  buf,
size_t  len 
)
protected

Definition at line 396 of file ota_component.cpp.

Field Documentation

◆ client_

std::unique_ptr<socket::Socket> esphome::ota::OTAComponent::client_
protected

Definition at line 88 of file ota_component.h.

◆ ENTER_SAFE_MODE_MAGIC

const uint32_t esphome::ota::OTAComponent::ENTER_SAFE_MODE_MAGIC
staticprotected
Initial value:
=
0x5afe5afe

a magic number to indicate that safe mode should be entered on next boot

Definition at line 97 of file ota_component.h.

◆ has_safe_mode_

bool esphome::ota::OTAComponent::has_safe_mode_ {false}
protected

stores whether safe mode can be enabled.

Definition at line 90 of file ota_component.h.

◆ password_

std::string esphome::ota::OTAComponent::password_
protected

Definition at line 82 of file ota_component.h.

◆ port_

uint16_t esphome::ota::OTAComponent::port_
protected

Definition at line 85 of file ota_component.h.

◆ rtc_

ESPPreferenceObject esphome::ota::OTAComponent::rtc_
protected

Definition at line 95 of file ota_component.h.

◆ safe_mode_enable_time_

uint32_t esphome::ota::OTAComponent::safe_mode_enable_time_ {60000}
protected

The time safe mode should be on for.

Definition at line 92 of file ota_component.h.

◆ safe_mode_num_attempts_

uint8_t esphome::ota::OTAComponent::safe_mode_num_attempts_
protected

Definition at line 94 of file ota_component.h.

◆ safe_mode_rtc_value_

uint32_t esphome::ota::OTAComponent::safe_mode_rtc_value_
protected

Definition at line 93 of file ota_component.h.

◆ safe_mode_start_time_

uint32_t esphome::ota::OTAComponent::safe_mode_start_time_
protected

stores when safe mode was enabled.

Definition at line 91 of file ota_component.h.

◆ server_

std::unique_ptr<socket::Socket> esphome::ota::OTAComponent::server_
protected

Definition at line 87 of file ota_component.h.

◆ state_callback_

CallbackManager<void(OTAState, float, uint8_t)> esphome::ota::OTAComponent::state_callback_ {}
protected

Definition at line 101 of file ota_component.h.


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