From e322670760e413f7fe7145e3a368f720fb7c47ad Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 19 Jul 2024 16:32:27 +0200 Subject: [PATCH] Skip unaligned responses from WiFi chip --- libraries/WiFiS3/src/Modem.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/WiFiS3/src/Modem.cpp b/libraries/WiFiS3/src/Modem.cpp index 884ae688..3dd1a87c 100644 --- a/libraries/WiFiS3/src/Modem.cpp +++ b/libraries/WiFiS3/src/Modem.cpp @@ -228,28 +228,36 @@ bool ModemClass::buf_read(const string &prompt, string &data_res) { } else { if(string::npos != data_res.rfind(RESULT_DATA)) { - found = true; data_res = data_res.substr(0, data_res.length() - (sizeof(RESULT_DATA) - 1)); if(prompt != DO_NOT_CHECK_CMD) { if(removeAtBegin(data_res, prompt)) { res = true; + found = true; + } else { + data_res.clear(); + continue; } } else { res = true; + found = true; } break; } else if(string::npos != data_res.rfind(RESULT_OK)){ - found = true; data_res = data_res.substr(0, data_res.length() - (sizeof(RESULT_OK) - 1) ); if(prompt != DO_NOT_CHECK_CMD) { if(removeAtBegin(data_res, prompt)) { res = true; + found = true; + } else { + data_res.clear(); + continue; } } else { res = true; + found = true; } break; }