Make sure that modemRead is properly maintaining sock_available

This commit is contained in:
Sara Damiano
2019-05-07 14:23:32 -04:00
parent e18c5dacbd
commit d5520757e4
9 changed files with 84 additions and 11 deletions

View File

@@ -62,6 +62,8 @@ public:
got_data = false;
at->sockets[mux] = this;
// ^^ TODO: attach the socket here at init? Or later at connect?
// Currently done inconsistently between modems
return true;
}
@@ -72,6 +74,10 @@ public:
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, mux);
// sock_connected = at->modemConnect(host, port, &mux);
// at->sockets[mux] = this;
// ^^ TODO: attach the socet after attempting connection or above at init?
// Currently done inconsistently between modems
return sock_connected;
}
@@ -97,7 +103,7 @@ public:
rx.clear();
at->maintain();
while (sock_available > 0) {
sock_available -= at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
rx.clear();
at->maintain();
}
@@ -696,6 +702,7 @@ protected:
return 0;
}
size_t len = stream.readStringUntil('\n').toInt();
sockets[mux]->sock_available = len;
for (size_t i=0; i<len; i++) {
while (!stream.available()) { TINY_GSM_YIELD(); }