Add stop with timeout and implement where applicable

This commit is contained in:
Sara Damiano
2019-06-11 16:00:35 -04:00
parent 0502ee435f
commit 86356f5323
13 changed files with 76 additions and 156 deletions

View File

@@ -93,25 +93,15 @@ public:
TINY_GSM_CLIENT_CONNECT_OVERLOADS()
virtual void stop() {
TINY_GSM_YIELD();
// Read and dump anything remaining in the modem's internal buffer.
// The socket will appear open in response to connected() even after it
// closes until all data is read from the buffer.
// Doing it this way allows the external mcu to find and get all of the data
// that it wants from the socket even if it was closed externally.
rx.clear();
at->maintain();
while (sock_available > 0) {
at->modemRead(TinyGsmMin((uint16_t)rx.free(), sock_available), mux);
rx.clear();
at->maintain();
}
virtual void stop(uint32_t maxWaitMs) {
TINY_GSM_CLIENT_DUMP_MODEM_BUFFER()
at->sendAT(GF("+SQNSH="), mux);
sock_connected = false;
at->waitResponse();
}
virtual void stop() { stop(15000L); }
TINY_GSM_CLIENT_WRITE()
TINY_GSM_CLIENT_AVAILABLE_WITH_BUFFER_CHECK()