|
ESPHome 2026.11.0-dev
|
#include <modem_component.h>
Data Structures | |
| struct | PinRecord |
Public Member Functions | |
| ModemComponent (InternalGPIOPin *tx_pin, InternalGPIOPin *rx_pin, const char *model, DceFactory factory, const char *apn) | |
| void | setup () override |
| void | loop () override |
| void | dump_config () override |
| float | get_setup_priority () const override |
| void | set_reboot_timeout (uint32_t timeout) |
| void | set_use_address (const char *use_address) |
| void | set_rts_pin (InternalGPIOPin *rts_pin) |
| void | set_cts_pin (InternalGPIOPin *cts_pin) |
| void | set_baud_rate (int baud_rate) |
| void | set_pin_code (const char *pin_code) |
| void | set_tx_buffer_size (uint16_t tx_buffer_size) |
| void | set_rx_buffer_size (uint16_t rx_buffer_size) |
| void | set_dte_buffer_size (uint16_t dte_buffer_size) |
| void | set_init_at_commands (const char *const *cmds, uint8_t count) |
| void | set_urc_text_sensor (text_sensor::TextSensor *urc_text_sensor) |
| template<typename F > | |
| void | add_on_state_callback (F &&callback) |
| bool | is_connected () const |
| bool | is_disabled () const |
| bool | is_enabled () const |
| void | enable () |
| void | disable () |
| bool | send_at (const char *cmd, uint32_t timeout=COMMAND_TIMEOUT_MS) |
| Queue an AT command for the modem task, which sends it at its next pass and logs the result and response. | |
| bool | send_at (const std::string &cmd, uint32_t timeout=COMMAND_TIMEOUT_MS) |
| network::IPAddresses | get_ip_addresses () |
| const char * | get_use_address () const |
Public Member Functions inherited from esphome::Component | |
| float | get_actual_setup_priority () const |
| void | set_setup_priority (float priority) |
| void | call () |
| virtual void | on_shutdown () |
| virtual void | on_safe_shutdown () |
| virtual bool | teardown () |
| Called during teardown to allow component to gracefully finish operations. | |
| 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) |
| bool | status_comm_result (bool ok) |
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok. | |
| bool | status_comm_result (bool ok, const LogString *message) |
| void | status_set_error () |
| void | status_set_error (const LogString *message) |
| void | status_clear_warning () |
| void | status_clear_error () |
| ESPDEPRECATED ("Use status_momentary_warning() without a name. Removed in 2027.5.0", "2026.11.0") void status_momentary_warning(const char *name | |
| void | status_momentary_warning (uint32_t length=5000) |
Set warning status flag and clear it after length ms. | |
| void | status_momentary_warning (const LogString *message, uint32_t length=5000) |
| ESPDEPRECATED ("Use status_momentary_error() without a name. Removed in 2027.5.0", "2026.11.0") void status_momentary_error(const char *name | |
| void | status_momentary_error (uint32_t length=5000) |
Set error status flag and clear it after length ms. | |
| void | status_momentary_error (const LogString *message, uint32_t length=5000) |
| 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) |
Protected Types | |
| enum | Pending : uint32_t { PENDING_STATUS = 1 << 0 , PENDING_SAVE_BAUD = 1 << 1 , PENDING_SAVE_PIN = 1 << 2 , PENDING_CONNECT_TIMEOUT = 1 << 3 , PENDING_ON_SYNC = 1 << 4 , PENDING_ON_CONNECT = 1 << 5 , PENDING_ON_DISCONNECT = 1 << 6 } |
Protected Member Functions | |
| void | run_task_ () |
| void | wake_task_ () |
| ModemState | compute_next_state_ () |
| ModemState | handle_state_enabling_ () |
| ModemState | handle_state_synced_ () |
| ModemState | handle_state_connecting_ () |
| ModemState | handle_state_wait_ip_ () |
| ModemState | handle_state_disconnecting_ () |
| uint32_t | next_probe_delay_ () |
| Pause the task before the next pass, then go to state. | |
| ModemState | retry_ (ModemState state, uint32_t delay_ms=RETRY_DELAY_MS) |
| void | transition_to_ (ModemState next_state) |
| void | arm_connect_timeout_ () |
| void | cancel_connect_timeout_ () |
| void | fail_setup_ (const LogString *reason) |
| void | set_fault_ (ModemFault fault) |
| void | set_teardown_fault_ () |
| void | clear_config_fault_ (ModemFault fault) |
| void | hand_over_ (uint32_t pending) |
| esp_modem::command_result | at_ (const char *cmd, uint32_t timeout=COMMAND_TIMEOUT_MS) |
| Send an AT command from the task and log the result; blocks for up to the timeout. | |
| void | publish_status_ () |
| void | not_responding_ (int baud) |
| void | dump_connect_params_ () |
| SimResult | prepare_sim_ () |
| SimResult | send_pin_ () |
| void | save_pin_record_ () |
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. | |
| bool | set_error_flag_ (const LogString *message) |
| Set the error flag and log it; true when it was not set before. | |
| 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_ () |
Static Protected Member Functions | |
| static void | task_entry (void *arg) |
Protected Attributes | |
| InternalGPIOPin * | tx_pin_ |
| InternalGPIOPin * | rx_pin_ |
| InternalGPIOPin * | rts_pin_ {nullptr} |
| InternalGPIOPin * | cts_pin_ {nullptr} |
| const char * | model_ |
| DceFactory | dce_factory_ |
| const char * | apn_ |
| const char *const * | init_at_commands_ {nullptr} |
| text_sensor::TextSensor * | urc_text_sensor_ {nullptr} |
| const char * | urc_line_ {nullptr} |
| std::unique_ptr< esp_modem::DCE > | dce_ |
| std::shared_ptr< esp_modem::DTE > | dte_ |
| esp_netif_t * | ppp_netif_ {nullptr} |
| ESPPreferenceObject | pref_ |
| LazyCallbackManager< void(ModemState)> | on_state_callback_ |
| int | baud_rate_ {0} |
| int | current_baud_rate_ {0} |
| int | restored_baud_ {0} |
| StaticTask | task_ |
| uint32_t | timeout_ {0} |
| uint32_t | step_delay_ms_ {0} |
| uint32_t | state_started_ms_ {0} |
| std::atomic< uint32_t > | pending_ {0} |
| const char * | pin_code_ {nullptr} |
| ESPPreferenceObject | pin_pref_ |
| PinRecord | pin_record_ {} |
| uint32_t | at_timeout_ {COMMAND_TIMEOUT_MS} |
| uint16_t | tx_buffer_size_ {1024} |
| uint16_t | rx_buffer_size_ {1024} |
| uint16_t | dte_buffer_size_ {1024} |
| std::atomic< ModemState > | component_state_ {ModemState::MODEM_STATE_DISABLED} |
| std::atomic< ModemState > | target_state_ {ModemState::MODEM_STATE_DISABLED} |
| std::atomic< ModemFault > | fault_ {ModemFault::MODEM_FAULT_NONE} |
| std::atomic< ModemFault > | config_fault_ {ModemFault::MODEM_FAULT_NONE} |
| std::atomic< uint8_t > | got_ip_ {0} |
| std::atomic< uint8_t > | ppp_error_ {0} |
| std::atomic< uint8_t > | probe_backoff_ {0} |
| std::atomic< uint8_t > | sync_acked_ {0} |
| std::atomic< uint8_t > | at_pending_ {0} |
| std::atomic< uint8_t > | urc_pending_ {0} |
| std::atomic< PinSave > | pin_save_state_ {PinSave::PIN_SAVE_DONE} |
| PinStep | pin_step_ {PinStep::PIN_STEP_IDLE} |
| bool | pin_record_unsaved_ {false} |
| ConnectStep | connect_step_ {ConnectStep::CONNECT_STEP_START} |
| uint8_t | init_at_count_ {0} |
| uint8_t | uart_port_ {UART_NUM_MAX} |
| uint8_t | attach_polls_ {0} |
| bool | connect_timeout_armed_ {false} |
| bool | modem_synced_ {false} |
| bool | resync_ {false} |
| char | at_command_ [AT_COMMAND_SIZE] |
| LineReader< URC_LINE_SIZE > | urc_reader_ |
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_ |
Static Protected Attributes | |
| static constexpr uint32_t | COMMAND_TIMEOUT_MS = 1000 |
| static constexpr uint32_t | RETRY_DELAY_MS = 1000 |
| static constexpr size_t | URC_LINE_SIZE = 128 |
| static constexpr size_t | AT_COMMAND_SIZE = 128 |
Additional Inherited Members | |
Data Fields inherited from esphome::Component | |
| uint32_t | length = 5000) |
Definition at line 85 of file modem_component.h.
|
protected |
| Enumerator | |
|---|---|
| PENDING_STATUS | |
| PENDING_SAVE_BAUD | |
| PENDING_SAVE_PIN | |
| PENDING_CONNECT_TIMEOUT | |
| PENDING_ON_SYNC | |
| PENDING_ON_CONNECT | |
| PENDING_ON_DISCONNECT | |
Definition at line 156 of file modem_component.h.
| esphome::modem::ModemComponent::ModemComponent | ( | InternalGPIOPin * | tx_pin, |
| InternalGPIOPin * | rx_pin, | ||
| const char * | model, | ||
| DceFactory | factory, | ||
| const char * | apn ) |
Definition at line 83 of file modem_component.cpp.
|
inline |
Definition at line 112 of file modem_component.h.
|
protected |
Definition at line 114 of file modem_component.cpp.
|
protected |
Send an AT command from the task and log the result; blocks for up to the timeout.
Definition at line 908 of file modem_component.cpp.
|
protected |
Definition at line 131 of file modem_component.cpp.
|
protected |
Definition at line 181 of file modem_component.cpp.
|
protected |
Definition at line 508 of file modem_component.cpp.
| void esphome::modem::ModemComponent::disable | ( | ) |
Definition at line 100 of file modem_component.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 449 of file modem_component.cpp.
|
protected |
Definition at line 1050 of file modem_component.cpp.
| void esphome::modem::ModemComponent::enable | ( | ) |
Definition at line 89 of file modem_component.cpp.
|
protected |
Definition at line 148 of file modem_component.cpp.
| network::IPAddresses esphome::modem::ModemComponent::get_ip_addresses | ( | ) |
Definition at line 136 of file modem_component.cpp.
|
inlineoverridevirtual |
Reimplemented from esphome::Component.
Definition at line 92 of file modem_component.h.
|
inline |
Definition at line 132 of file modem_component.h.
|
protected |
Definition at line 157 of file modem_component.cpp.
|
protected |
Definition at line 708 of file modem_component.cpp.
|
protected |
Definition at line 816 of file modem_component.cpp.
|
protected |
Definition at line 550 of file modem_component.cpp.
|
protected |
Definition at line 693 of file modem_component.cpp.
|
protected |
Definition at line 795 of file modem_component.cpp.
|
inline |
Definition at line 116 of file modem_component.h.
|
inline |
Definition at line 117 of file modem_component.h.
|
inline |
Definition at line 121 of file modem_component.h.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 215 of file modem_component.cpp.
|
protected |
Pause the task before the next pass, then go to state.
Definition at line 494 of file modem_component.cpp.
|
protected |
Definition at line 877 of file modem_component.cpp.
|
protected |
Definition at line 920 of file modem_component.cpp.
|
protected |
Definition at line 188 of file modem_component.cpp.
|
protected |
Definition at line 503 of file modem_component.cpp.
|
protected |
Definition at line 477 of file modem_component.cpp.
|
protected |
Definition at line 987 of file modem_component.cpp.
| bool esphome::modem::ModemComponent::send_at | ( | const char * | cmd, |
| uint32_t | timeout = COMMAND_TIMEOUT_MS ) |
Queue an AT command for the modem task, which sends it at its next pass and logs the result and response.
Returns false when a command is still queued or the command is too long.
Definition at line 885 of file modem_component.cpp.
| bool esphome::modem::ModemComponent::send_at | ( | const std::string & | cmd, |
| uint32_t | timeout = COMMAND_TIMEOUT_MS ) |
Definition at line 883 of file modem_component.cpp.
|
protected |
Definition at line 994 of file modem_component.cpp.
|
inline |
Definition at line 98 of file modem_component.h.
|
inline |
Definition at line 97 of file modem_component.h.
|
inline |
Definition at line 104 of file modem_component.h.
|
protected |
Definition at line 163 of file modem_component.cpp.
|
inline |
Definition at line 105 of file modem_component.h.
|
inline |
Definition at line 100 of file modem_component.h.
|
inline |
Definition at line 94 of file modem_component.h.
|
inline |
Definition at line 96 of file modem_component.h.
|
inline |
Definition at line 103 of file modem_component.h.
|
protected |
Definition at line 175 of file modem_component.cpp.
|
inline |
Definition at line 102 of file modem_component.h.
|
inline |
Definition at line 110 of file modem_component.h.
|
inline |
Definition at line 95 of file modem_component.h.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 280 of file modem_component.cpp.
|
staticprotected |
Definition at line 475 of file modem_component.cpp.
|
protected |
Definition at line 840 of file modem_component.cpp.
|
protected |
Definition at line 107 of file modem_component.cpp.
|
protected |
Definition at line 193 of file modem_component.h.
|
protected |
Definition at line 266 of file modem_component.h.
|
staticconstexprprotected |
Definition at line 138 of file modem_component.h.
|
protected |
Definition at line 247 of file modem_component.h.
|
protected |
Definition at line 225 of file modem_component.h.
|
protected |
Definition at line 261 of file modem_component.h.
|
protected |
Definition at line 204 of file modem_component.h.
|
staticconstexprprotected |
Definition at line 135 of file modem_component.h.
|
protected |
Definition at line 231 of file modem_component.h.
|
protected |
Definition at line 236 of file modem_component.h.
|
protected |
Definition at line 258 of file modem_component.h.
|
protected |
Definition at line 262 of file modem_component.h.
|
protected |
Definition at line 190 of file modem_component.h.
|
protected |
Definition at line 205 of file modem_component.h.
|
protected |
Definition at line 199 of file modem_component.h.
|
protected |
Definition at line 192 of file modem_component.h.
|
protected |
Definition at line 200 of file modem_component.h.
|
protected |
Definition at line 229 of file modem_component.h.
|
protected |
Definition at line 234 of file modem_component.h.
|
protected |
Definition at line 239 of file modem_component.h.
|
protected |
Definition at line 194 of file modem_component.h.
|
protected |
Definition at line 259 of file modem_component.h.
|
protected |
Definition at line 191 of file modem_component.h.
|
protected |
Definition at line 263 of file modem_component.h.
|
protected |
Definition at line 203 of file modem_component.h.
|
protected |
Definition at line 211 of file modem_component.h.
|
protected |
Definition at line 213 of file modem_component.h.
|
protected |
Definition at line 214 of file modem_component.h.
|
protected |
Definition at line 222 of file modem_component.h.
|
protected |
Definition at line 256 of file modem_component.h.
|
protected |
Definition at line 254 of file modem_component.h.
|
protected |
Definition at line 255 of file modem_component.h.
|
protected |
Definition at line 240 of file modem_component.h.
|
protected |
Definition at line 201 of file modem_component.h.
|
protected |
Definition at line 202 of file modem_component.h.
|
protected |
Definition at line 242 of file modem_component.h.
|
protected |
Definition at line 206 of file modem_component.h.
|
protected |
Definition at line 264 of file modem_component.h.
|
staticconstexprprotected |
Definition at line 136 of file modem_component.h.
|
protected |
Definition at line 189 of file modem_component.h.
|
protected |
Definition at line 228 of file modem_component.h.
|
protected |
Definition at line 188 of file modem_component.h.
|
protected |
Definition at line 210 of file modem_component.h.
|
protected |
Definition at line 209 of file modem_component.h.
|
protected |
Definition at line 244 of file modem_component.h.
|
protected |
Definition at line 232 of file modem_component.h.
|
protected |
Definition at line 207 of file modem_component.h.
|
protected |
Definition at line 208 of file modem_component.h.
|
protected |
Definition at line 227 of file modem_component.h.
|
protected |
Definition at line 187 of file modem_component.h.
|
protected |
Definition at line 260 of file modem_component.h.
|
protected |
Definition at line 197 of file modem_component.h.
|
staticconstexprprotected |
Definition at line 137 of file modem_component.h.
|
protected |
Definition at line 251 of file modem_component.h.
|
protected |
Definition at line 270 of file modem_component.h.
|
protected |
Definition at line 196 of file modem_component.h.