From ce175df376222b42a658769e90ca4752ccb90403 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 16 Sep 2022 16:17:01 +0200 Subject: [PATCH] fix(esp_modem): CMUX to ignore MSC frames Otherwise it gets confused with DISC frame and causes trouble when entering CMUX mode (if device sends MSC requests) Closes https://github.com/espressif/esp-protocols/issues/140 --- components/esp_modem/src/esp_modem_cmux.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/esp_modem/src/esp_modem_cmux.cpp b/components/esp_modem/src/esp_modem_cmux.cpp index 0243a4991..743371a99 100644 --- a/components/esp_modem/src/esp_modem_cmux.cpp +++ b/components/esp_modem/src/esp_modem_cmux.cpp @@ -143,6 +143,10 @@ void CMux::data_available(uint8_t *data, size_t len) #endif } } else if ((type&FT_UIH) == FT_UIH && dlci == 0) { // notify the internal DISC command + if (len > 0 && (data[0] & 0xE1) == 0xE1) { + // Not a DISC, ignore (MSC frame) + return; + } Scoped l(lock); sabm_ack = dlci; } @@ -385,6 +389,9 @@ bool CMux::init() return false; } } + if (i > 1) { // wait for each virtual terminal to settle MSC (no need for control term, DLCI=0) + usleep(100'000); + } } return true; }