Merge pull request #6731 from altelch/development

Fix v4 address check if running v6 code in v4 only environment.
This commit is contained in:
Theo Arends 2019-10-24 18:02:00 +02:00 committed by GitHub
commit d7968da12c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -323,12 +323,22 @@ bool WifiCheckIPv6(void)
} }
return ipv6_global; return ipv6_global;
} }
bool WifiCheckIPAddrStatus(void) // Return false for 169.254.x.x or fe80::/64
{
bool ip_global=false;
for (auto a : addrList) {
if(!a.isLocal()) ip_global=true;
}
return ip_global;
}
#endif // LWIP_IPV6=1 #endif // LWIP_IPV6=1
void WifiCheckIp(void) void WifiCheckIp(void)
{ {
#if LWIP_IPV6 #if LWIP_IPV6
if(WifiCheckIPv6()) { if(WifiCheckIPAddrStatus()) {
Wifi.status = WL_CONNECTED; Wifi.status = WL_CONNECTED;
#else #else
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) { if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0)) {
@ -456,7 +466,7 @@ void WifiCheck(uint8_t param)
WifiCheckIp(); WifiCheckIp();
} }
#if LWIP_IPV6 #if LWIP_IPV6
if (WifiCheckIPv6()) { if (WifiCheckIPAddrStatus()) {
#else #else
if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0) && !Wifi.config_type) { if ((WL_CONNECTED == WiFi.status()) && (static_cast<uint32_t>(WiFi.localIP()) != 0) && !Wifi.config_type) {
#endif // LWIP_IPV6=1 #endif // LWIP_IPV6=1