modemRead MUST end with sock_available correct

This commit is contained in:
Sara Damiano
2019-05-24 23:24:32 -04:00
parent 9ce1a2d998
commit 3d78292261
8 changed files with 16 additions and 27 deletions

View File

@@ -100,7 +100,7 @@ TINY_GSM_CLIENT_CONNECT_OVERLOADS()
// that it wants from the socket even if it was closed externally.
rx.clear();
at->maintain();
while (sock_available > 0) {
while (sock_connected && sock_available > 0) {
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
rx.clear();
at->maintain();
@@ -601,6 +601,7 @@ protected:
streamSkipUntil('\"');
waitResponse();
DBG("### READ:", len, "from", mux);
sockets[mux]->sock_available = modemGetAvailable();
return len;
}
@@ -616,8 +617,10 @@ protected:
result = stream.readStringUntil('\n').toInt();
// if (result) DBG("### DATA AVAILABLE:", result, "on", mux);
waitResponse();
} else if (res == 3) {
streamSkipUntil('\n'); // Skip the error text
}
if (!result && res != 2 && res != 3) { // Don't check modemGetConnected after an error
if (!result) {
sockets[mux]->sock_connected = modemGetConnected(mux);
}
return result;