Fixed ESP8266 GetSignalQuality
This commit is contained in:
@@ -225,7 +225,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SIM card & Networ Operator functions
|
* SIM card & Network Operator functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool simUnlock(const char *pin) {
|
bool simUnlock(const char *pin) {
|
||||||
|
@@ -209,10 +209,13 @@ public:
|
|||||||
|
|
||||||
int getSignalQuality() {
|
int getSignalQuality() {
|
||||||
sendAT(GF("+CWLAP=\""), _ssid, GF("\""));
|
sendAT(GF("+CWLAP=\""), _ssid, GF("\""));
|
||||||
String res1 = stream.readStringUntil(':');
|
DBG(GSM_NL, "<<< ");
|
||||||
DBG(GSM_NL, res1, ':');
|
streamSkipUntil(':');
|
||||||
String res2 = stream.readStringUntil(',');
|
streamSkipUntil(',');
|
||||||
DBG(res2);
|
streamSkipUntil(',');
|
||||||
|
streamSkipUntil(',');
|
||||||
|
String res2 = streamReadUntil(',');
|
||||||
|
streamSkipUntil(')');
|
||||||
waitResponse();
|
waitResponse();
|
||||||
return res2.toInt();
|
return res2.toInt();
|
||||||
}
|
}
|
||||||
@@ -220,10 +223,9 @@ public:
|
|||||||
bool waitForNetwork(unsigned long timeout = 60000L) {
|
bool waitForNetwork(unsigned long timeout = 60000L) {
|
||||||
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
for (unsigned long start = millis(); millis() - start < timeout; ) {
|
||||||
sendAT(GF("+CIPSTATUS"));
|
sendAT(GF("+CIPSTATUS"));
|
||||||
String res1 = stream.readStringUntil(':');
|
DBG(GSM_NL, "<<< ");
|
||||||
DBG(GSM_NL, res1, ':');
|
String res1 = streamReadUntil(':');
|
||||||
String res2 = stream.readStringUntil(*GSM_NL);
|
String res2 = streamReadUntil(*GSM_NL);
|
||||||
DBG(res2);
|
|
||||||
waitResponse();
|
waitResponse();
|
||||||
if (res2 == GF("2") || res2 == GF("3") || res2 == GF("4")) {
|
if (res2 == GF("2") || res2 == GF("3") || res2 == GF("4")) {
|
||||||
return true;
|
return true;
|
||||||
@@ -280,7 +282,7 @@ public:
|
|||||||
streamWrite("AT", cmd..., GSM_NL);
|
streamWrite("AT", cmd..., GSM_NL);
|
||||||
stream.flush();
|
stream.flush();
|
||||||
TINY_GSM_YIELD();
|
TINY_GSM_YIELD();
|
||||||
DBG(GSM_NL, ">>> AT:", cmd...);
|
DBG(GSM_NL, ">>> AT", cmd...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Optimize this!
|
// TODO: Optimize this!
|
||||||
@@ -431,6 +433,26 @@ private:
|
|||||||
|
|
||||||
int streamRead() { return stream.read(); }
|
int streamRead() { return stream.read(); }
|
||||||
|
|
||||||
|
String streamReadUntil(char c) {
|
||||||
|
String return_string = stream.readStringUntil(c);
|
||||||
|
return_string.trim();
|
||||||
|
if (String(c) == GSM_NL || String(c) == "\n"){
|
||||||
|
DBG(return_string, c, " ");
|
||||||
|
} else DBG(return_string, c);
|
||||||
|
return return_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool streamSkipUntil(char c) {
|
||||||
|
String skipped = stream.readStringUntil(c);
|
||||||
|
skipped.trim();
|
||||||
|
if (skipped.length()) {
|
||||||
|
if (String(c) == GSM_NL || String(c) == "\n"){
|
||||||
|
DBG(skipped, c, " ");
|
||||||
|
} else DBG(skipped, c);
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Stream& stream;
|
Stream& stream;
|
||||||
GsmClient* sockets[5];
|
GsmClient* sockets[5];
|
||||||
|
@@ -234,7 +234,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SIM card & Networ Operator functions
|
* SIM card & Network Operator functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool simUnlock(const char *pin) {
|
bool simUnlock(const char *pin) {
|
||||||
|
Reference in New Issue
Block a user