Browse Source

Fixed ESP8266 GetSignalQuality

v_master
SRGDamia1 7 years ago
parent
commit
787fb33054
3 changed files with 38 additions and 16 deletions
  1. +1
    -1
      TinyGsmClientA6.h
  2. +36
    -14
      TinyGsmClientESP8266.h
  3. +1
    -1
      TinyGsmClientM590.h

+ 1
- 1
TinyGsmClientA6.h View File

@ -225,7 +225,7 @@ public:
}
/*
* SIM card & Networ Operator functions
* SIM card & Network Operator functions
*/
bool simUnlock(const char *pin) {


+ 36
- 14
TinyGsmClientESP8266.h View File

@ -207,23 +207,25 @@ public:
* SIM card & Network Operator functions
*/
int getSignalQuality() {
sendAT(GF("+CWLAP=\""), _ssid, GF("\""));
String res1 = stream.readStringUntil(':');
DBG(GSM_NL, res1, ':');
String res2 = stream.readStringUntil(',');
DBG(res2);
waitResponse();
return res2.toInt();
}
int getSignalQuality() {
sendAT(GF("+CWLAP=\""), _ssid, GF("\""));
DBG(GSM_NL, "<<< ");
streamSkipUntil(':');
streamSkipUntil(',');
streamSkipUntil(',');
streamSkipUntil(',');
String res2 = streamReadUntil(',');
streamSkipUntil(')');
waitResponse();
return res2.toInt();
}
bool waitForNetwork(unsigned long timeout = 60000L) {
for (unsigned long start = millis(); millis() - start < timeout; ) {
sendAT(GF("+CIPSTATUS"));
String res1 = stream.readStringUntil(':');
DBG(GSM_NL, res1, ':');
String res2 = stream.readStringUntil(*GSM_NL);
DBG(res2);
DBG(GSM_NL, "<<< ");
String res1 = streamReadUntil(':');
String res2 = streamReadUntil(*GSM_NL);
waitResponse();
if (res2 == GF("2") || res2 == GF("3") || res2 == GF("4")) {
return true;
@ -280,7 +282,7 @@ public:
streamWrite("AT", cmd..., GSM_NL);
stream.flush();
TINY_GSM_YIELD();
DBG(GSM_NL, ">>> AT:", cmd...);
DBG(GSM_NL, ">>> AT", cmd...);
}
// TODO: Optimize this!
@ -431,6 +433,26 @@ private:
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:
Stream& stream;
GsmClient* sockets[5];


+ 1
- 1
TinyGsmClientM590.h View File

@ -234,7 +234,7 @@ public:
}
/*
* SIM card & Networ Operator functions
* SIM card & Network Operator functions
*/
bool simUnlock(const char *pin) {


Loading…
Cancel
Save