From 88fe00e98e8bcc00bad698288ae12afb2db8fe9f Mon Sep 17 00:00:00 2001 From: SRGDamia1 Date: Thu, 13 Apr 2017 14:10:11 -0400 Subject: [PATCH] Added hack to close sockets --- TinyGsmClientXBee.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TinyGsmClientXBee.h b/TinyGsmClientXBee.h index 1231ce9..9cd7276 100644 --- a/TinyGsmClientXBee.h +++ b/TinyGsmClientXBee.h @@ -87,7 +87,21 @@ public: return sock_connected; } - virtual void stop() { // Not supported + // This is a hack to shut the socket by setting the timeout to zero and + // then sending an empty line to the server. + virtual void stop() { + TINY_GSM_YIELD(); + at->commandMode(); + at->sendAT(GF("TM0")); // Set socket timeout to 0; + at->writeChanges(); + at->exitCommand(); + at->modemSend("", 1, mux); + at->waitResponse(); + delay(200); + at->commandMode(); + at->sendAT(GF("TM64")); // Set socket timeout back to 10seconds; + at->writeChanges(); + at->exitCommand(); sock_connected = false; }