16#include <cxx_include/esp_modem_api.hpp>
17#include <esp_modem_config.h>
66#ifdef USE_MODEM_PIN_CODE
82using DceFactory = std::unique_ptr<esp_modem::DCE> (*)(
const esp_modem::dce_config *, std::shared_ptr<esp_modem::DTE>,
89 void setup()
override;
95 void set_use_address(
const char *use_address) { this->use_address_ = use_address; }
99#ifdef USE_MODEM_PIN_CODE
124#ifdef USE_MODEM_SEND_AT
159#ifdef USE_MODEM_PIN_CODE
182#ifdef USE_MODEM_PIN_CODE
199 std::unique_ptr<esp_modem::DCE>
dce_;
200 std::shared_ptr<esp_modem::DTE>
dte_;
212#ifdef USE_MODEM_PIN_CODE
221#ifdef USE_MODEM_PIN_CODE
224#ifdef USE_MODEM_SEND_AT
245#ifdef USE_MODEM_SEND_AT
253#ifdef USE_MODEM_PIN_CODE
265#ifdef USE_MODEM_SEND_AT
275 const char *use_address_{
""};
Collects bytes into NUL terminated lines of up to N - 1 characters; IGNORE_CHAR bytes are skipped and...
Helper for FreeRTOS static task management.
void set_cts_pin(InternalGPIOPin *cts_pin)
InternalGPIOPin * rts_pin_
std::shared_ptr< esp_modem::DTE > dte_
std::atomic< ModemState > component_state_
std::atomic< uint8_t > ppp_error_
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 respo...
char at_command_[AT_COMMAND_SIZE]
network::IPAddresses get_ip_addresses()
InternalGPIOPin * rx_pin_
void set_dte_buffer_size(uint16_t dte_buffer_size)
bool is_connected() const
void hand_over_(uint32_t pending)
std::atomic< ModemFault > fault_
uint16_t dte_buffer_size_
void set_use_address(const char *use_address)
std::atomic< ModemFault > config_fault_
@ PENDING_CONNECT_TIMEOUT
void set_rts_pin(InternalGPIOPin *rts_pin)
void set_baud_rate(int baud_rate)
ModemState handle_state_connecting_()
ModemComponent(InternalGPIOPin *tx_pin, InternalGPIOPin *rx_pin, const char *model, DceFactory factory, const char *apn)
void cancel_connect_timeout_()
InternalGPIOPin * cts_pin_
InternalGPIOPin * tx_pin_
ConnectStep connect_step_
LineReader< URC_LINE_SIZE > urc_reader_
const char *const * init_at_commands_
uint32_t next_probe_delay_()
Pause the task before the next pass, then go to state.
ModemState handle_state_wait_ip_()
ESPPreferenceObject pin_pref_
static constexpr size_t AT_COMMAND_SIZE
void dump_connect_params_()
std::atomic< uint8_t > at_pending_
float get_setup_priority() const override
std::unique_ptr< esp_modem::DCE > dce_
void set_rx_buffer_size(uint16_t rx_buffer_size)
void add_on_state_callback(F &&callback)
void set_init_at_commands(const char *const *cmds, uint8_t count)
std::atomic< ModemState > target_state_
static constexpr uint32_t RETRY_DELAY_MS
std::atomic< uint8_t > urc_pending_
LazyCallbackManager< void(ModemState)> on_state_callback_
bool connect_timeout_armed_
void transition_to_(ModemState next_state)
void set_teardown_fault_()
void clear_config_fault_(ModemFault fault)
static void task_entry(void *arg)
void not_responding_(int baud)
ModemState compute_next_state_()
void set_tx_buffer_size(uint16_t tx_buffer_size)
void arm_connect_timeout_()
std::atomic< uint8_t > got_ip_
void set_fault_(ModemFault fault)
ModemState handle_state_disconnecting_()
void set_reboot_timeout(uint32_t timeout)
void dump_config() override
void set_urc_text_sensor(text_sensor::TextSensor *urc_text_sensor)
uint32_t state_started_ms_
std::atomic< uint8_t > sync_acked_
const char * get_use_address() const
ModemState handle_state_enabling_()
std::atomic< PinSave > pin_save_state_
void fail_setup_(const LogString *reason)
std::atomic< uint32_t > pending_
void set_pin_code(const char *pin_code)
ModemState handle_state_synced_()
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.
ESPPreferenceObject pref_
ModemState retry_(ModemState state, uint32_t delay_ms=RETRY_DELAY_MS)
text_sensor::TextSensor * urc_text_sensor_
std::atomic< uint8_t > probe_backoff_
static constexpr size_t URC_LINE_SIZE
static constexpr uint32_t COMMAND_TIMEOUT_MS
@ MODEM_FAULT_PIN_NOT_SENT
@ MODEM_FAULT_NOT_ATTACHED
@ MODEM_FAULT_NO_RESPONSE
@ MODEM_FAULT_SIM_NOT_READY
@ MODEM_STATE_DISCONNECTING
ModemComponent * global_modem_component
@ CONNECT_STEP_ATTACH_REQUESTED
std::unique_ptr< esp_modem::DCE >(*)(const esp_modem::dce_config *, std::shared_ptr< esp_modem::DTE >, esp_netif_t *) DceFactory
std::array< IPAddress, 5 > IPAddresses
struct esp_netif_obj esp_netif_t