Close 5360 sockets cleanly

This commit is contained in:
Sara Damiano
2019-07-19 12:41:19 -04:00
parent 10b91ee932
commit 9f359eac91
5 changed files with 13 additions and 8 deletions

View File

@@ -400,6 +400,13 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
}
bool gprsDisconnect() {
// Close any open sockets
for (int mux = 0; mux < TINY_GSM_MUX_COUNT; mux++) {
GsmClient *sock = sockets[mux];
if (sock) {
sock->stop();
}
}
// Stop the socket service
// Note: all sockets should be closed first
@@ -422,13 +429,11 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
bool isGprsConnected() {
sendAT(GF("+NETOPEN?"));
if (waitResponse(GF(GSM_NL "+NETOPEN:")) != 1) {
// May return +NETOPEN: 1, 0. We just confirm that the first number is 1
if (waitResponse(GF(GSM_NL "+NETOPEN: 1")) != 1) {
return false;
}
int res = stream.readStringUntil('\n').toInt();
waitResponse();
if (res != 1)
return false;
sendAT(GF("+IPADDR")); // Inquire Socket PDP address
// sendAT(GF("+CGPADDR=1")); // Show PDP address

View File

@@ -10,7 +10,7 @@
#define TinyGsmCommon_h
// The current library version number
#define TINYGSM_VERSION "0.9.4"
#define TINYGSM_VERSION "0.9.5"
#if defined(SPARK) || defined(PARTICLE)
#include "Particle.h"