From 52d2ec2261eef4786bd1f44bb4de5474a2237130 Mon Sep 17 00:00:00 2001 From: Thiker Date: Mon, 24 Jun 2024 10:04:30 -0400 Subject: [PATCH] Allow to add Delay to CMUX DISC --- components/esp_modem/Kconfig | 7 +++++++ components/esp_modem/src/esp_modem_cmux.cpp | 1 + 2 files changed, 8 insertions(+) diff --git a/components/esp_modem/Kconfig b/components/esp_modem/Kconfig index 6896428d07..7f20319dc1 100644 --- a/components/esp_modem/Kconfig +++ b/components/esp_modem/Kconfig @@ -36,6 +36,13 @@ menu "esp-modem" The typical reason for failing SABM request without a delay is that some devices (SIM800) send MSC requests just after opening a new DLCI. + config ESP_MODEM_CMUX_DELAY_AFTER_DLCI_DISCONNECT + int "Delay in ms to wait after closing virtual terminal" + default 0 + help + Some devices might need a pause before sending disconnect command that closes + virtual terminal. This delay applies only to close DLCI in CMUX mode. + config ESP_MODEM_CMUX_USE_SHORT_PAYLOADS_ONLY bool "CMUX to support only short payloads (<128 bytes)" default n diff --git a/components/esp_modem/src/esp_modem_cmux.cpp b/components/esp_modem/src/esp_modem_cmux.cpp index c47e13b9db..dc8ef88b23 100644 --- a/components/esp_modem/src/esp_modem_cmux.cpp +++ b/components/esp_modem/src/esp_modem_cmux.cpp @@ -81,6 +81,7 @@ uint8_t CMux::fcs_crc(const uint8_t frame[6]) void CMux::send_disconnect(size_t i) { + usleep(CONFIG_ESP_MODEM_CMUX_DELAY_AFTER_DLCI_DISCONNECT * 1'000); if (i == 0) { // control terminal uint8_t frame[] = { SOF_MARKER, 0x3, 0xEF, 0x5, 0xC3, 0x1, 0xF2, SOF_MARKER