Check for XBee wifi dns
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -729,13 +729,21 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isNetworkConnectedImpl() {
|
bool isNetworkConnectedImpl() {
|
||||||
|
// first check for association indicator
|
||||||
RegStatus s = getRegistrationStatus();
|
RegStatus s = getRegistrationStatus();
|
||||||
if (s == REG_OK) {
|
if (s == REG_OK) {
|
||||||
IPAddress ip = localIP();
|
if (beeType == XBEE_S6B_WIFI) {
|
||||||
if (ip != IPAddress(0, 0, 0, 0)) {
|
// For wifi bees, if the association indicator is ok, check that a both
|
||||||
return true;
|
// 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 {
|
} else {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -770,6 +778,29 @@ class TinyGsmXBee : public TinyGsmModem<TinyGsmXBee>,
|
|||||||
return IPaddr;
|
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
|
* WiFi functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user