Skip to content

Commit 6eceb28

Browse files
fix(modem): Consume buffer after handled URC
1 parent b8cdd37 commit 6eceb28

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

components/esp_modem/src/esp_modem_dte.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -369,18 +369,23 @@ void DTE::on_read(got_line_cb on_read_cb)
369369
bool DTE::command_cb::process_line(uint8_t *data, size_t consumed, size_t len)
370370
{
371371
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
372+
command_result commandResult = command_result::FAIL;
372373
if (urc_handler) {
373-
urc_handler(data, consumed + len);
374+
commandResult = urc_handler(data, consumed + len);
374375
}
375-
if (result != command_result::TIMEOUT || got_line == nullptr) {
376-
return false; // this line has been processed already (got OK or FAIL previously)
376+
if (result != command_result::TIMEOUT && got_line == nullptr) {
377+
return false; // this line has been processed already (got OK or FAIL previously)
377378
}
378379
#endif
379380
if (memchr(data + consumed, separator, len)) {
380-
result = got_line(data, consumed + len);
381+
result = got_line(data + consumed, consumed + len);
381382
if (result == command_result::OK || result == command_result::FAIL) {
382383
signal.set(GOT_LINE);
384+
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
385+
return commandResult == command_result::OK;
386+
#else
383387
return true;
388+
#endif
384389
}
385390
}
386391
return false;

0 commit comments

Comments
 (0)