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

@@ -71,6 +71,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;
}
@@ -81,6 +83,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;
}
@@ -106,7 +112,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();
}
@@ -228,6 +234,9 @@ public:
TINY_GSM_YIELD();
rx.clear();
sock_connected = at->modemConnect(host, port, mux, true);
// sock_connected = at->modemConnect(host, port, &mux, true);
// at->sockets[mux] = this;
// TODO: When is the socket attached?
return sock_connected;
}
};
@@ -421,6 +430,7 @@ public:
RegStatus getRegistrationStatus() {
sendAT(GF("+CGREG?"));
// TODO: Shouldn't this be CEREG for the EPS status of this 4G module?
if (waitResponse(GF(GSM_NL "+CGREG:")) != 1) {
return REG_UNKNOWN;
}