From 14a652376fa7c6c33ce348087962299616148c86 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 27 Oct 2021 11:28:47 +0200 Subject: [PATCH] Examples/PPPoS: Fix handling empty lines with CRLF only Tokenizing data by '\n' will effectively replace all LF characters by '\0' so checking for phantom lines has to be adjusted: * minimal empty line is CR only (strlen = 1) * checking for lines containing CR only --- .../pppos_client/components/modem/src/esp_modem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/protocols/pppos_client/components/modem/src/esp_modem.c b/examples/protocols/pppos_client/components/modem/src/esp_modem.c index 4217f136a5..2cb38c17fe 100644 --- a/examples/protocols/pppos_client/components/modem/src/esp_modem.c +++ b/examples/protocols/pppos_client/components/modem/src/esp_modem.c @@ -60,15 +60,15 @@ typedef struct { } esp_modem_dte_t; /** - * @brief Returns true if the supplied string contains only CR or LF + * @brief Returns true if the supplied string contains only characters * * @param str string to check * @param len length of string */ -static inline bool is_only_cr_lf(const char *str, uint32_t len) +static inline bool is_only_cr(const char *str, uint32_t len) { for (int i=0; i 2 && !is_only_cr_lf(p, plen)) { + if (plen > 1 && !is_only_cr(p, plen)) { ESP_LOGD(MODEM_TAG, "Handling line: >>%s\n<<", p); if (dce->handle_line == NULL) { /* Received an asynchronous line, but no handler waiting this this */