File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -367,24 +367,21 @@ void DTE::on_read(got_line_cb on_read_cb)
367
367
368
368
bool DTE::command_cb::process_line (uint8_t *data, size_t consumed, size_t len)
369
369
{
370
+ // returning true indicates that the processing finished and lower layers can destroy the accumulated buffer
370
371
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
371
- command_result commandResult = command_result::FAIL ;
372
+ bool consume_buffer = false ;
372
373
if (urc_handler) {
373
- commandResult = urc_handler (data, consumed + len);
374
+ consume_buffer = urc_handler (data, consumed + len) != command_result::TIMEOUT ;
374
375
}
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 consume_buffer; // this line has been processed already (got OK or FAIL previously)
377
378
}
378
379
#endif
379
380
if (memchr (data + consumed, separator, len)) {
380
- result = got_line (data + consumed , consumed + len);
381
+ result = got_line (data, consumed + len);
381
382
if (result == command_result::OK || result == command_result::FAIL) {
382
383
signal.set (GOT_LINE);
383
- #ifdef CONFIG_ESP_MODEM_URC_HANDLER
384
- return commandResult == command_result::OK;
385
- #else
386
384
return true ;
387
- #endif
388
385
}
389
386
}
390
387
return false ;
You can’t perform that action at this time.
0 commit comments