Skip to content

Commit b143894

Browse files
authored
Merge pull request #821 from lolrobbe2/fix-urc-line-handler-modem
fix(modem): Consume buffer after handled URC
2 parents d1c912c + 6eceb28 commit b143894

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
*/
@@ -368,18 +368,23 @@ void DTE::on_read(got_line_cb on_read_cb)
368368
bool DTE::command_cb::process_line(uint8_t *data, size_t consumed, size_t len)
369369
{
370370
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
371+
command_result commandResult = command_result::FAIL;
371372
if (urc_handler) {
372-
urc_handler(data, consumed + len);
373+
commandResult = urc_handler(data, consumed + len);
373374
}
374-
if (result != command_result::TIMEOUT || got_line == nullptr) {
375-
return false; // this line has been processed already (got OK or FAIL previously)
375+
if (result != command_result::TIMEOUT && got_line == nullptr) {
376+
return false; // this line has been processed already (got OK or FAIL previously)
376377
}
377378
#endif
378379
if (memchr(data + consumed, separator, len)) {
379-
result = got_line(data, consumed + len);
380+
result = got_line(data + consumed, consumed + len);
380381
if (result == command_result::OK || result == command_result::FAIL) {
381382
signal.set(GOT_LINE);
383+
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
384+
return commandResult == command_result::OK;
385+
#else
382386
return true;
387+
#endif
383388
}
384389
}
385390
return false;

0 commit comments

Comments
 (0)