Added getSignalQuality for ESP8266

This commit is contained in:
SRGDamia1
2017-06-06 16:53:13 -04:00
parent b771b1f313
commit a129331e42
2 changed files with 18 additions and 1 deletions

View File

@@ -203,6 +203,20 @@ public:
return autoBaud(); return autoBaud();
} }
/*
* 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();
}
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"));
@@ -224,6 +238,8 @@ public:
*/ */
bool networkConnect(const char* ssid, const char* pwd) { bool networkConnect(const char* ssid, const char* pwd) {
_ssid = ssid;
sendAT(GF("+CIPMUX=1")); sendAT(GF("+CIPMUX=1"));
if (waitResponse() != 1) { if (waitResponse() != 1) {
return false; return false;
@@ -418,6 +434,7 @@ private:
private: private:
Stream& stream; Stream& stream;
GsmClient* sockets[5]; GsmClient* sockets[5];
const char* _ssid;
}; };
typedef TinyGsm::GsmClient TinyGsmClient; typedef TinyGsm::GsmClient TinyGsmClient;

View File

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