Fix IPv6 compilation for ESP8266 (#17374)

This commit is contained in:
s-hadinger 2022-12-13 09:31:43 +01:00 committed by GitHub
parent 7e27945e5a
commit f429d41a32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -517,8 +517,14 @@ void WifiDumpAddressesIPv6(void)
// Check to see if we have any routable IP address // Check to see if we have any routable IP address
bool WifiHasIP(void) { bool WifiHasIP(void) {
#ifdef USE_IPV6 #ifdef USE_IPV6
#ifdef ESP32
return !WiFi.localIP().isAny(); return !WiFi.localIP().isAny();
#else // ESP32
const ip_addr_t &ipaddr = (ip_addr_t)WiFi.localIP();
return !ip_addr_isany_val(ipaddr);
#endif // ESP32
#else #else
// IPv4 only
return (uint32_t)WiFi.localIP() != 0; return (uint32_t)WiFi.localIP() != 0;
#endif // USE_IPV6 #endif // USE_IPV6
} }
@ -526,12 +532,13 @@ bool WifiHasIP(void) {
void WifiCheckIp(void) { void WifiCheckIp(void) {
#ifdef USE_IPV6 #ifdef USE_IPV6
if (WL_CONNECTED == WiFi.status()) { if (WL_CONNECTED == WiFi.status()) {
#ifdef ESP32
if (!Wifi.ipv6_local_link_called) { if (!Wifi.ipv6_local_link_called) {
WiFi.enableIpV6(); WiFi.enableIpV6();
Wifi.ipv6_local_link_called = true; Wifi.ipv6_local_link_called = true;
// AddLog(LOG_LEVEL_DEBUG, PSTR("WIF: calling enableIpV6")); // AddLog(LOG_LEVEL_DEBUG, PSTR("WIF: calling enableIpV6"));
} }
#endif
} }
#endif // USE_IPV6 #endif // USE_IPV6