Merge pull request #6634 from altelch/development

Allow IPv6 only setup. Still dualstack but works without configured …
This commit is contained in:
Theo Arends 2019-10-13 19:40:55 +02:00 committed by GitHub
commit a8582a4d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 5 deletions

View File

@ -244,17 +244,13 @@ void WifiBegin(uint8_t flag, uint8_t channel)
uint16_t cfgcnt = 0; uint16_t cfgcnt = 0;
for (auto addr : addrList) { for (auto addr : addrList) {
if ((configured = !addr.isLocal() && addr.isV6()) || cfgcnt==30) { if ((configured = !addr.isLocal() && addr.isV6()) || cfgcnt==30) {
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Got IPv6 global address %s"), addr.toString().c_str());
break; // IPv6 is mandatory but stop after 15 seconds break; // IPv6 is mandatory but stop after 15 seconds
} }
delay(500); // Loop until real IPv6 address is aquired or too many tries failed delay(500); // Loop until real IPv6 address is aquired or too many tries failed
cfgcnt++; cfgcnt++;
} }
} }
for (auto a : addrList) {
if (!a.isLocal() && !a.isLegacy()) {
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Got IPv6 global address %s"), a.toString().c_str());
}
}
#endif #endif
} }
@ -380,9 +376,26 @@ void WifiSetState(uint8_t state)
global_state.wifi_down = state ^1; global_state.wifi_down = state ^1;
} }
#ifdef LWIP_IPV6
bool WifiCheckIPv6(void)
{
bool ipv6_global=false;
for (auto a : addrList) {
if(!a.isLocal() && a.isV6()) ipv6_global=true;
}
return ipv6_global;
}
#endif
void WifiCheckIp(void) void WifiCheckIp(void)
{ {
#ifdef LWIP_IPV6
if(WifiCheckIPv6()) {
Wifi.status = WL_CONNECTED;
#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)) {
#endif
WifiSetState(1); WifiSetState(1);
Wifi.counter = WIFI_CHECK_SEC; Wifi.counter = WIFI_CHECK_SEC;
Wifi.retry = Wifi.retry_init; Wifi.retry = Wifi.retry_init;
@ -520,7 +533,11 @@ void WifiCheck(uint8_t param)
Wifi.counter = WIFI_CHECK_SEC; Wifi.counter = WIFI_CHECK_SEC;
WifiCheckIp(); WifiCheckIp();
} }
#ifdef LWIP_IPV6
if (WifiCheckIPv6()) {
#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
WifiSetState(1); WifiSetState(1);
if (Settings.flag3.use_wifi_rescan) { if (Settings.flag3.use_wifi_rescan) {