Corrected more XBee errors
Fixing hex return formats and catching missed wifi/cell differences
This commit is contained in:
@@ -166,7 +166,7 @@ public:
|
|||||||
while (!stream.available() && millis() - startMillis < 1000) {};
|
while (!stream.available() && millis() - startMillis < 1000) {};
|
||||||
String res = streamReadUntil('\r'); // Does not send an OK, just the result
|
String res = streamReadUntil('\r'); // Does not send an OK, just the result
|
||||||
exitCommand();
|
exitCommand();
|
||||||
if (res == "0x601") series = "WIFI";
|
if (res == "601") series = "WIFI";
|
||||||
else series = "CELL";
|
else series = "CELL";
|
||||||
guardTime = 125;
|
guardTime = 125;
|
||||||
return true;
|
return true;
|
||||||
@@ -250,16 +250,15 @@ public:
|
|||||||
|
|
||||||
int getSignalQuality() {
|
int getSignalQuality() {
|
||||||
commandMode();
|
commandMode();
|
||||||
if (series == "WIFI") sendAT(GF("DB"));
|
if (series == "WIFI") sendAT(GF("LM"));
|
||||||
else sendAT(GF("LM"));
|
else sendAT(GF("DB"));
|
||||||
// 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) {};
|
||||||
char buf[4] = { 0, }; // Does not send an OK, just the result
|
char buf[3] = { 0, }; // Does not send an OK, just the result
|
||||||
buf[0] = streamRead();
|
buf[0] = streamRead();
|
||||||
buf[1] = streamRead();
|
buf[1] = streamRead();
|
||||||
buf[2] = streamRead();
|
DBG("\n");
|
||||||
buf[3] = streamRead();
|
|
||||||
exitCommand();
|
exitCommand();
|
||||||
int intr = strtol(buf, 0, 16);
|
int intr = strtol(buf, 0, 16);
|
||||||
return intr;
|
return intr;
|
||||||
@@ -279,17 +278,17 @@ public:
|
|||||||
String res = streamReadUntil('\r'); // Does not send an OK, just the result
|
String res = streamReadUntil('\r'); // Does not send an OK, just the result
|
||||||
exitCommand();
|
exitCommand();
|
||||||
|
|
||||||
if(res == GF("0x00"))
|
if(res == GF("0"))
|
||||||
return REG_OK_HOME;
|
return REG_OK_HOME;
|
||||||
|
|
||||||
else if(res == GF("0x13") || res == GF("0x2A"))
|
else if(res == GF("13") || res == GF("2A"))
|
||||||
return REG_UNREGISTERED;
|
return REG_UNREGISTERED;
|
||||||
|
|
||||||
else if(res == GF("0xFF") || res == GF("0x22") || res == GF("0x23") ||
|
else if(res == GF("FF") || res == GF("22") || res == GF("23") ||
|
||||||
res == GF("0x40") || res == GF("0x41") || res == GF("0x42"))
|
res == GF("40") || res == GF("41") || res == GF("42"))
|
||||||
return REG_SEARCHING;
|
return REG_SEARCHING;
|
||||||
|
|
||||||
else if(res == GF("0x24"))
|
else if(res == GF("24"))
|
||||||
return REG_DENIED;
|
return REG_DENIED;
|
||||||
|
|
||||||
else return REG_UNKNOWN;
|
else return REG_UNKNOWN;
|
||||||
@@ -310,7 +309,8 @@ 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; ) {
|
||||||
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) {};
|
||||||
@@ -519,7 +519,8 @@ private:
|
|||||||
|
|
||||||
bool modemGetConnected(uint8_t mux = 1) {
|
bool modemGetConnected(uint8_t mux = 1) {
|
||||||
commandMode();
|
commandMode();
|
||||||
sendAT(GF("AI"));
|
if (series == "WIFI") sendAT(GF("AI"));
|
||||||
|
else sendAT(GF("CI"));
|
||||||
int res = waitResponse(GF("0"));
|
int res = waitResponse(GF("0"));
|
||||||
exitCommand();
|
exitCommand();
|
||||||
return 1 == res;
|
return 1 == res;
|
||||||
|
Reference in New Issue
Block a user