feat(esp_modem): Make some CMUX params compile-time configurable

* bool flag to defragment CMUX payload (useful for devices that send longer messages)
* int flag to force a delay between creating virtual terminals (useful for chatty devices that send some requests)
This commit is contained in:
David Cermak
2022-09-30 12:01:50 +02:00
parent ce175df376
commit 25ac2d98c6
3 changed files with 48 additions and 3 deletions

View File

@ -17,15 +17,18 @@
#include <cxx_include/esp_modem_cmux.hpp>
#include "cxx_include/esp_modem_dte.hpp"
#include "esp_log.h"
#include "sdkconfig.h"
using namespace esp_modem;
#ifdef CONFIG_ESP_MODEM_CMUX_DEFRAGMENT_PAYLOAD
/**
* @brief Define this to defragment partially received data of CMUX payload
* This is useful if upper layers expect the entire payload available
* for parsing.
*/
#define DEFRAGMENT_CMUX_PAYLOAD
#endif
#define EA 0x01 /* Extension bit */
#define CR 0x02 /* Command / Response */
@ -290,7 +293,7 @@ bool CMux::on_cmux_data(uint8_t *data, size_t actual_len)
actual_len = term->read(data, data_to_read);
#else
data = buffer.get();
actual_len = term->read(data, buffer_size);
actual_len = term->read(data, buffer.size);
#endif
}
ESP_LOG_BUFFER_HEXDUMP("CMUX Received", data, actual_len, ESP_LOG_VERBOSE);
@ -390,7 +393,7 @@ bool CMux::init()
}
}
if (i > 1) { // wait for each virtual terminal to settle MSC (no need for control term, DLCI=0)
usleep(100'000);
usleep(CONFIG_ESP_MODEM_CMUX_DELAY_AFTER_DLCI_SETUP * 1'000);
}
}
return true;