From b93d0e9b8ceea024bd24f73d8c21f6fe325ff9fd Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Fri, 30 Aug 2024 11:34:14 +0300 Subject: [PATCH] fix(ppp): Fix PPP not working after reboot if no RST Modem will try to switch to CMUX and then back to COMMAND in order to allow communication with the modem. --- libraries/PPP/src/PPP.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/PPP/src/PPP.cpp b/libraries/PPP/src/PPP.cpp index b687153ea7c..ba1ca2e4869 100644 --- a/libraries/PPP/src/PPP.cpp +++ b/libraries/PPP/src/PPP.cpp @@ -324,8 +324,17 @@ bool PPPClass::begin(ppp_modem_model_t model, uint8_t uart_num, int baud_rate) { } else { // try to communicate with the modem if (esp_modem_sync(_dce) != ESP_OK) { - log_v("Modem does not respond to AT, maybe in DATA mode? ...exiting network mode"); + log_v("Modem does not respond to AT! Switching to COMMAND mode."); esp_modem_set_mode(_dce, ESP_MODEM_MODE_COMMAND); + if (esp_modem_sync(_dce) != ESP_OK) { + log_v("Modem does not respond to AT! Switching to CMUX mode."); + if (esp_modem_set_mode(_dce, ESP_MODEM_MODE_CMUX) != ESP_OK) { + log_v("Modem failed to switch to CMUX mode!"); + } else { + log_v("Switching back to COMMAND mode"); + esp_modem_set_mode(_dce, ESP_MODEM_MODE_COMMAND); + } + } if (esp_modem_sync(_dce) != ESP_OK) { log_e("Modem failed to respond to AT!"); goto err;