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 53c8fd0b49..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,26 +60,26 @@ 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; ievent_loop_hdl, ESP_MODEM_EVENT, ESP_MODEM_EVENT_UNKNOWN, - (void *)line, strlen(line) + 1, pdMS_TO_TICKS(100)); + (void *)line, line_len + 1, pdMS_TO_TICKS(100)); } esp_err_t esp_modem_set_rx_cb(modem_dte_t *dte, esp_modem_on_receive receive_cb, void *receive_cb_ctx) @@ -112,24 +112,25 @@ static esp_err_t esp_dte_handle_line(esp_modem_dte_t *esp_dte, char * line, size char *str_ptr = NULL; char *p = strtok_r(line, "\n", &str_ptr); while (p) { - if (len > 2 && !is_only_cr_lf(p, strlen(p))) { + int plen = strlen(p); + 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 */ ESP_LOGD(MODEM_TAG, "No handler for line: %s", p); - report_unknown_line(esp_dte, line); + report_unknown_line(esp_dte, p, plen); return ESP_OK; /* Not an error, just propagate the line to user handler */ } if (dce->handle_line(dce, p) != ESP_OK) { ESP_LOGE(MODEM_TAG, "handle line failed"); - report_unknown_line(esp_dte, line); + report_unknown_line(esp_dte, p, plen); } } p = strtok_r(NULL, "\n", &str_ptr); } return ESP_OK; post_event_unknown: - report_unknown_line(esp_dte, line); + report_unknown_line(esp_dte, line, strlen(line)); err: return err; }