diff --git a/components/esp_modem/include/cxx_include/esp_modem_cmux.hpp b/components/esp_modem/include/cxx_include/esp_modem_cmux.hpp index a17c3518d..01ef14dea 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_cmux.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_cmux.hpp @@ -96,6 +96,8 @@ public: */ bool recover(); + bool isInBullshitState() { if (m_isInBullshitState) { m_isInBullshitState = false; return true; } return false; } + private: enum class protocol_mismatch_reason { @@ -128,6 +130,9 @@ private: bool on_footer(CMuxFrame &frame); void recover_protocol(protocol_mismatch_reason reason); + //! When espressif again fucks up the recovering of the MUX + bool m_isInBullshitState{}; + std::function read_cb[MAX_TERMINALS_NUM]; /*!< Function pointers to read callbacks */ std::shared_ptr term; /*!< The original terminal */ cmux_state state; /*!< CMux protocol state */ 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 ddaa9cd0c..4d2d9ccb6 100644 --- a/components/esp_modem/include/cxx_include/esp_modem_dte.hpp +++ b/components/esp_modem/include/cxx_include/esp_modem_dte.hpp @@ -151,6 +151,8 @@ public: */ void set_command_callbacks(); + bool isInBullshitState(); + protected: /** * @brief Allows for locking the DTE diff --git a/components/esp_modem/src/esp_modem_cmux.cpp b/components/esp_modem/src/esp_modem_cmux.cpp index 8089d66e6..9faac0b91 100644 --- a/components/esp_modem/src/esp_modem_cmux.cpp +++ b/components/esp_modem/src/esp_modem_cmux.cpp @@ -202,6 +202,7 @@ bool CMux::on_recovery(CMuxFrame &frame) frame.ptr = recover_ptr; state = cmux_state::INIT; ESP_LOGI("CMUX", "Protocol recovered"); + m_isInBullshitState = true; if (frame.len > 1 && frame.ptr[1] == SOF_MARKER) { // empty frame frame.advance(); diff --git a/components/esp_modem/src/esp_modem_dte.cpp b/components/esp_modem/src/esp_modem_dte.cpp index 5adea5bc5..ca917b4e2 100644 --- a/components/esp_modem/src/esp_modem_dte.cpp +++ b/components/esp_modem/src/esp_modem_dte.cpp @@ -394,6 +394,13 @@ bool DTE::recover() return false; } +bool DTE::isInBullshitState() +{ + if (!cmux_term) + return false; + return cmux_term->isInBullshitState(); +} + void DTE::handle_error(terminal_error err) { if (err == terminal_error::BUFFER_OVERFLOW ||