diff --git a/components/esp_modem/idf_component.yml b/components/esp_modem/idf_component.yml index b7846693d..0af36a254 100644 --- a/components/esp_modem/idf_component.yml +++ b/components/esp_modem/idf_component.yml @@ -1,4 +1,4 @@ -version: "0.1.27" +version: "0.1.28" description: esp modem url: https://github.com/espressif/esp-protocols/tree/master/components/esp_modem dependencies: diff --git a/components/esp_modem/include/cxx_include/esp_modem_dte.hpp b/components/esp_modem/include/cxx_include/esp_modem_dte.hpp index 3d592ea02..d6be01856 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_dte.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_dte.hpp @@ -39,9 +39,12 @@ public: * @brief Creates a DTE instance from the terminal * @param config DTE config structure * @param t unique-ptr to Terminal + * @param s unique-ptr to secondary Terminal */ explicit DTE(const esp_modem_dte_config *config, std::unique_ptr t); explicit DTE(std::unique_ptr t); + explicit DTE(const esp_modem_dte_config *config, std::unique_ptr t, std::unique_ptr s); + explicit DTE(std::unique_ptr t, std::unique_ptr s); ~DTE() = default; diff --git a/components/esp_modem/include/cxx_include/esp_modem_types.hpp b/components/esp_modem/include/cxx_include/esp_modem_types.hpp index 8cb88ba58..80abbcfd9 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_types.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_types.hpp @@ -27,8 +27,9 @@ namespace esp_modem { */ enum class modem_mode { UNDEF, - COMMAND_MODE, /*!< Command mode -- the modem is supposed to send AT commands in this mode */ + COMMAND_MODE, /*!< Command mode -- the modem is supposed to send AT commands in this mode */ DATA_MODE, /*!< Data mode -- the modem communicates with network interface on PPP protocol */ + DUAL_MODE, /*!< Dual mode -- the modem has two real terminals. Data and commands work at the same time */ CMUX_MODE, /*!< CMUX (Multiplex mode) -- Simplified CMUX mode, which creates two virtual terminals, * assigning one solely to command interface and the other to the data mode */ CMUX_MANUAL_MODE, /*!< Enter CMUX mode manually -- just creates two virtual terminals */ diff --git a/components/esp_modem/src/esp_modem_dce.cpp b/components/esp_modem/src/esp_modem_dce.cpp index afd41ffa6..d1ea90ebd 100644 --- a/components/esp_modem/src/esp_modem_dce.cpp +++ b/components/esp_modem/src/esp_modem_dce.cpp @@ -88,6 +88,7 @@ bool DCE_Mode::set_unsafe(DTE *dte, ModuleIf *device, Netif &netif, modem_mode m { switch (m) { case modem_mode::UNDEF: + case modem_mode::DUAL_MODE: // Only DTE can be in Dual mode break; case modem_mode::COMMAND_MODE: if (mode == modem_mode::COMMAND_MODE || mode >= modem_mode::CMUX_MANUAL_MODE) { diff --git a/components/esp_modem/src/esp_modem_dte.cpp b/components/esp_modem/src/esp_modem_dte.cpp index f8eec5579..f5ad1339b 100644 --- a/components/esp_modem/src/esp_modem_dte.cpp +++ b/components/esp_modem/src/esp_modem_dte.cpp @@ -24,6 +24,16 @@ DTE::DTE(std::unique_ptr terminal): cmux_term(nullptr), primary_term(std::move(terminal)), secondary_term(primary_term), mode(modem_mode::UNDEF) {} +DTE::DTE(const esp_modem_dte_config *config, std::unique_ptr t, std::unique_ptr s): + buffer(config->dte_buffer_size), + cmux_term(nullptr), primary_term(std::move(t)), secondary_term(std::move(s)), + mode(modem_mode::DUAL_MODE) {} + +DTE::DTE(std::unique_ptr t, std::unique_ptr s): + buffer(dte_default_buffer_size), + cmux_term(nullptr), primary_term(std::move(t)), secondary_term(std::move(s)), + mode(modem_mode::DUAL_MODE) {} + command_result DTE::command(const std::string &command, got_line_cb got_line, uint32_t time_ms, const char separator) { Scoped l(internal_lock); @@ -104,9 +114,9 @@ bool DTE::set_mode(modem_mode m) return false; } } - // transitions (COMMAND|CMUX|UNDEF) -> DATA + // transitions (COMMAND|DUAL|CMUX|UNDEF) -> DATA if (m == modem_mode::DATA_MODE) { - if (mode == modem_mode::CMUX_MODE || mode == modem_mode::CMUX_MANUAL_MODE) { + if (mode == modem_mode::CMUX_MODE || mode == modem_mode::CMUX_MANUAL_MODE || mode == modem_mode::DUAL_MODE) { // mode stays the same, but need to swap terminals (as command has been switched) secondary_term.swap(primary_term); } else { @@ -114,7 +124,7 @@ bool DTE::set_mode(modem_mode m) } return true; } - // transitions (DATA|CMUX|UNDEF) -> COMMAND + // transitions (DATA|DUAL|CMUX|UNDEF) -> COMMAND if (m == modem_mode::COMMAND_MODE) { if (mode == modem_mode::CMUX_MODE) { if (exit_cmux()) { @@ -123,7 +133,7 @@ bool DTE::set_mode(modem_mode m) } mode = modem_mode::UNDEF; return false; - } if (mode == modem_mode::CMUX_MANUAL_MODE) { + } if (mode == modem_mode::CMUX_MANUAL_MODE || mode == modem_mode::DUAL_MODE) { return true; } else { mode = m;