Merge pull request #6618 from altelch/development

Initial IPv6 support for SLAAC (automatic address configuration).
This commit is contained in:
Theo Arends 2019-10-11 13:41:01 +02:00 committed by GitHub
commit 8803b55e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 1 deletions

View File

@ -117,7 +117,7 @@ build_flags = ${esp82xx_defaults.build_flags}
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH ; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
; lwIP 2 - Higher Bandwitdh Low Memory no Features ; lwIP 2 - Higher Bandwitdh Low Memory no Features
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH ; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH
; lwIP 2 - Higher Bandwitdh no Features ; lwIP 2 - Higher Bandwidth no Features (Tasmota default)
-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
; VTABLES in Flash (default) ; VTABLES in Flash (default)
-DVTABLES_IN_FLASH -DVTABLES_IN_FLASH
@ -133,6 +133,44 @@ build_flags = ${esp82xx_defaults.build_flags}
; -fexceptions ; -fexceptions
; -lstdc++-exc ; -lstdc++-exc
[core_stage_ipv6]
; *** Esp8266 core for Arduino version latest beta
platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m.ld
; Code optimization see https://github.com/esp8266/Arduino/issues/5790#issuecomment-475672473
-O2
-DBEARSSL_SSL_BASIC
; nonos-sdk 22y
-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22y
; nonos-sdk 22x
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x
; nonos-sdk-pre-v3
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
; lwIP 1.4
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
; lwIP 2 - Low Memory
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
; lwIP 2 - Higher Bandwidth
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
; lwIP 2 - Higher Bandwitdh Low Memory no Features
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH
; lwIP 2 - Higher Bandwidth IPv6
-DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_HIGHER_BANDWIDTH
; VTABLES in Flash (default)
-DVTABLES_IN_FLASH
; VTABLES in Heap
; -DVTABLES_IN_DRAM
; VTABLES in IRAM
; -DVTABLES_IN_IRAM
; enable one option set -> No exception recommended
; No exception code in firmware
-fno-exceptions
-lstdc++
; Exception code in firmware /needs much space! 90k
; -fexceptions
; -lstdc++-exc
[core_pre] [core_pre]
; *** Arduino Esp8266 core pre 2.6.x for Tasmota (mqtt reconnects fixed) ; *** Arduino Esp8266 core pre 2.6.x for Tasmota (mqtt reconnects fixed)
platform = https://github.com/Jason2866/platform-espressif8266.git#Tasmota platform = https://github.com/Jason2866/platform-espressif8266.git#Tasmota
@ -180,6 +218,8 @@ build_flags = ${esp82xx_defaults.build_flags}
;build_flags = ${core_2_5_2.build_flags} ;build_flags = ${core_2_5_2.build_flags}
;platform = ${core_stage.platform} ;platform = ${core_stage.platform}
;build_flags = ${core_stage.build_flags} ;build_flags = ${core_stage.build_flags}
;platform = ${core_stage_ipv6.platform}
;build_flags = ${core_stage_ipv6.build_flags}
platform = ${core_pre.platform} platform = ${core_pre.platform}
build_flags = ${core_pre.build_flags} build_flags = ${core_pre.build_flags}

View File

@ -33,6 +33,9 @@ const uint8_t WIFI_CHECK_SEC = 20; // seconds
const uint8_t WIFI_RETRY_OFFSET_SEC = 20; // seconds const uint8_t WIFI_RETRY_OFFSET_SEC = 20; // seconds
#include <ESP8266WiFi.h> // Wifi, MQTT, Ota, WifiManager #include <ESP8266WiFi.h> // Wifi, MQTT, Ota, WifiManager
#if LWIP_IPV6
#include <AddrList.h> // IPv6 DualStack
#endif
struct WIFI { struct WIFI {
uint32_t last_event = 0; // Last wifi connection event uint32_t last_event = 0; // Last wifi connection event
@ -235,6 +238,24 @@ void WifiBegin(uint8_t flag, uint8_t channel)
} }
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s " D_IN_MODE " 11%c " D_AS " %s..."), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s " D_IN_MODE " 11%c " D_AS " %s..."),
Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], kWifiPhyMode[WiFi.getPhyMode() & 0x3], my_hostname); Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], kWifiPhyMode[WiFi.getPhyMode() & 0x3], my_hostname);
#if LWIP_IPV6
for (bool configured = false; !configured;) {
uint16_t cfgcnt=0;
for (auto addr : addrList)
{
if ((configured = !addr.isLocal() && addr.isV6()) || cfgcnt==30) break; // IPv6 is mandatory but stop after 15 seconds
delay(500); // Loop until real IPv6 address is aquired or too many tries failed
cfgcnt++;
}
}
for (auto a : addrList) {
if(!a.isLocal() && !a.isLegacy())
{
AddLog_P2(LOG_LEVEL_INFO, PSTR("WIFi: Got IPv6 global address %s"),a.toString().c_str());
}
}
#endif
} }
void WifiBeginAfterScan() void WifiBeginAfterScan()