From 77c5109f9ef703f5344533a7506d3f3d05f98c14 Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Thu, 28 Sep 2017 02:11:52 +0300 Subject: [PATCH] Fix isGprsConnected, gprsDisconnect --- TinyGsmClientA6.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/TinyGsmClientA6.h b/TinyGsmClientA6.h index 1cf2163..8baf6b4 100644 --- a/TinyGsmClientA6.h +++ b/TinyGsmClientA6.h @@ -398,14 +398,15 @@ public: bool gprsDisconnect() { sendAT(GF("+CIPSHUT")); - if (waitResponse(60000L) != 1) - return false; + waitResponse(5000L); - sendAT(GF("+CGATT=0")); - if (waitResponse(60000L) != 1) - return false; + for (int i = 0; i<3; i++) { + sendAT(GF("+CGATT=0")); + if (waitResponse(5000L) == 1) + return true; + } - return true; + return false; } bool isGprsConnected() { @@ -415,14 +416,7 @@ public: } int res = stream.readStringUntil('\n').toInt(); waitResponse(); - if (res != 1) - return false; - - sendAT(GF("+CIFSR")); // TODO: check this - if (waitResponse() != 1) - return false; - - return true; + return (res == 1); } String getLocalIP() {