Fix isGprsConnected, gprsDisconnect

This commit is contained in:
Volodymyr Shymanskyy
2017-09-28 02:11:52 +03:00
parent f7983673da
commit 77c5109f9e

View File

@@ -398,16 +398,17 @@ public:
bool gprsDisconnect() { bool gprsDisconnect() {
sendAT(GF("+CIPSHUT")); sendAT(GF("+CIPSHUT"));
if (waitResponse(60000L) != 1) waitResponse(5000L);
return false;
for (int i = 0; i<3; i++) {
sendAT(GF("+CGATT=0")); sendAT(GF("+CGATT=0"));
if (waitResponse(60000L) != 1) if (waitResponse(5000L) == 1)
return false;
return true; return true;
} }
return false;
}
bool isGprsConnected() { bool isGprsConnected() {
sendAT(GF("+CGATT?")); sendAT(GF("+CGATT?"));
if (waitResponse(GF(GSM_NL "+CGATT:")) != 1) { if (waitResponse(GF(GSM_NL "+CGATT:")) != 1) {
@@ -415,14 +416,7 @@ public:
} }
int res = stream.readStringUntil('\n').toInt(); int res = stream.readStringUntil('\n').toInt();
waitResponse(); waitResponse();
if (res != 1) return (res == 1);
return false;
sendAT(GF("+CIFSR")); // TODO: check this
if (waitResponse() != 1)
return false;
return true;
} }
String getLocalIP() { String getLocalIP() {