pppos-client: support for SIM7600 modem

Reuses most of the code from BG96. At this moment, this is not a
perfect support for other modules as the generic handlers for most
common modem functionality is not easily reusable. Refactoring to a
fully independent modem component will solve this.

Closes https://github.com/espressif/esp-idf/issues/5250
This commit is contained in:
David Cermak
2020-06-24 12:02:13 +02:00
committed by bot
parent 6edf0fed2b
commit c226270138
9 changed files with 188 additions and 24 deletions

View File

@@ -62,6 +62,21 @@ typedef struct {
int pattern_queue_size; /*!< UART pattern queue size */
} esp_modem_dte_t;
/**
* @brief Returns true if the supplied string contains only CR or LF
*
* @param str string to check
* @param len length of string
*/
static inline bool is_only_cr_lf(const char *str, uint32_t len)
{
for (int i=0; i<len; ++i) {
if (str[i] != '\r' && str[i] != '\n') {
return false;
}
}
return true;
}
esp_err_t esp_modem_set_rx_cb(modem_dte_t *dte, esp_modem_on_receive receive_cb, void *receive_cb_ctx)
{
@@ -85,8 +100,9 @@ static esp_err_t esp_dte_handle_line(esp_modem_dte_t *esp_dte)
modem_dce_t *dce = esp_dte->parent.dce;
MODEM_CHECK(dce, "DTE has not yet bind with DCE", err);
const char *line = (const char *)(esp_dte->buffer);
size_t len = strlen(line);
/* Skip pure "\r\n" lines */
if (strlen(line) > 2) {
if (len > 2 && !is_only_cr_lf(line, len)) {
MODEM_CHECK(dce->handle_line, "no handler for line", err_handle);
MODEM_CHECK(dce->handle_line(dce, line) == ESP_OK, "handle line failed", err_handle);
}