Browse Source

Accounting for API differences in XBee between WiFi and Cellular

v_master
SRGDamia1 7 years ago
parent
commit
b771b1f313
1 changed files with 12 additions and 2 deletions
  1. +12
    -2
      TinyGsmClientXBee.h

+ 12
- 2
TinyGsmClientXBee.h View File

@ -160,7 +160,14 @@ public:
sendAT(GF("GT64")); // shorten the guard time to 100ms sendAT(GF("GT64")); // shorten the guard time to 100ms
waitResponse(); waitResponse();
writeChanges(); writeChanges();
sendAT(GF("IM")); // Get the Hardware series; 0x601 for S6B (Wifi)
// wait for the response
unsigned long startMillis = millis();
while (!stream.available() && millis() - startMillis < 1000) {};
String res = streamReadUntil('\r'); // Does not send an OK, just the result
exitCommand(); exitCommand();
if (res == "0x601") series = "WIFI";
else series = "CELL";
guardTime = 125; guardTime = 125;
return true; return true;
} }
@ -243,7 +250,8 @@ public:
int getSignalQuality() { int getSignalQuality() {
commandMode(); commandMode();
sendAT(GF("DB"));
if (series == "WIFI") sendAT(GF("DB"));
else sendAT(GF("LM"));
// wait for the response // wait for the response
unsigned long startMillis = millis(); unsigned long startMillis = millis();
while (!stream.available() && millis() - startMillis < 1000) {}; while (!stream.available() && millis() - startMillis < 1000) {};
@ -263,7 +271,8 @@ public:
RegStatus getRegistrationStatus() { RegStatus getRegistrationStatus() {
commandMode(); commandMode();
sendAT(GF("AI"));
if (series == "WIFI") sendAT(GF("AI"));
else sendAT(GF("CI"));
// wait for the response // wait for the response
unsigned long startMillis = millis(); unsigned long startMillis = millis();
while (!stream.available() && millis() - startMillis < 1000) {}; while (!stream.available() && millis() - startMillis < 1000) {};
@ -571,6 +580,7 @@ private:
private: private:
int guardTime; int guardTime;
String series;
Stream& stream; Stream& stream;
GsmClient* sockets[1]; GsmClient* sockets[1];
}; };


Loading…
Cancel
Save