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)
367367
368368bool DTE::command_cb::process_line (uint8_t *data, size_t consumed, size_t len)
369369{
370+ // returning true indicates that the processing finished and lower layers can destroy the accumulated buffer
370371#ifdef CONFIG_ESP_MODEM_URC_HANDLER
371- command_result commandResult = command_result::FAIL ;
372+ bool consume_buffer = false ;
372373 if (urc_handler) {
373- commandResult = urc_handler (data, consumed + len);
374+ consume_buffer = urc_handler (data, consumed + len) != command_result::TIMEOUT ;
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 consume_buffer; // 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 , consumed + len);
381+ result = got_line (data, consumed + len);
381382 if (result == command_result::OK || result == command_result::FAIL) {
382383 signal.set (GOT_LINE);
383- #ifdef CONFIG_ESP_MODEM_URC_HANDLER
384- return commandResult == command_result::OK;
385- #else
386384 return true ;
387- #endif
388385 }
389386 }
390387 return false ;
You can’t perform that action at this time.
0 commit comments