Skip to content

Commit

Permalink
Check for XBee wifi dns
Browse files Browse the repository at this point in the history
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
  • Loading branch information
SRGDamia1 committed Jun 27, 2023
1 parent 5b83997 commit b65f1c1
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/TinyGsmClientXBee.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,21 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
}

bool isNetworkConnectedImpl() {
// first check for association indicator
RegStatus s = getRegistrationStatus();
if (s == REG_OK) {
IPAddress ip = localIP();
if (ip != IPAddress(0, 0, 0, 0)) {
return true;
if (beeType == XBEE_S6B_WIFI) {
// For wifi bees, if the association indicator is ok, check that a both
// a local IP and DNS have been allocated
IPAddress ip = localIP();
IPAddress dns = getDNSAddress();
if (ip != IPAddress(0, 0, 0, 0) && dns != IPAddress(0, 0, 0, 0)) {
return true;
} else {
return false;
}
} else {
return false;
return true;
}
} else {
return false;
Expand Down Expand Up @@ -770,6 +778,29 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
return IPaddr;
}

String getDNS() {
XBEE_COMMAND_START_DECORATOR(5, "")
switch (beeType) {
case XBEE_S6B_WIFI: {
sendAT(GF("NS"));
}
default: {
sendAT(GF("N1"));
}
}
String DNSaddr;
DNSaddr.reserve(16);
// wait for the response - this response can be very slow
DNSaddr = readResponseString(30000);
XBEE_COMMAND_END_DECORATOR
DNSaddr.trim();
return DNSaddr;
}

IPAddress getDNSAddress() {
return TinyGsmIpFromString(getDNS());
}

/*
* WiFi functions
*/
Expand Down

0 comments on commit b65f1c1

Please sign in to comment.