Skip to content

Commit bf99f28

Browse files
committed
fix(modem): Fixed inconsistent state on data after OK
If we received response in two chunks and the first one completes the command (result=OK or FAIL), and the second chunk pre-empts command processing, then we performed processing again rewritting the result back to TIMEOUT. This would invalidate the command, but also causes an exception: ESP_MODEM_THROW_IF_ERROR(ESP_ERR_INVALID_STATE) Fixed by checking if the processing already finished in process_line(). Closes #426
1 parent 909e8d9 commit bf99f28

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

components/esp_modem/src/esp_modem_dte.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ void DTE::on_read(got_line_cb on_read_cb)
347347

348348
bool DTE::command_cb::process_line(uint8_t *data, size_t consumed, size_t len)
349349
{
350+
if (result != command_result::TIMEOUT) {
351+
return false; // this line has been processed already (got OK or FAIL previously)
352+
}
350353
if (memchr(data + consumed, separator, len)) {
351354
result = got_line(data, consumed + len);
352355
if (result == command_result::OK || result == command_result::FAIL) {

0 commit comments

Comments
 (0)