From c4431eb6fe24cf47d8df6a39cfaf25be5b389e8d Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Sat, 20 Apr 2024 22:15:54 +0200 Subject: [PATCH] Fixed IPv6 support in safeboot (#21233) --- CHANGELOG.md | 5 ++- tasmota/tasmota.ino | 2 - tasmota/tasmota_support/support_command.ino | 2 +- tasmota/tasmota_support/support_wifi.ino | 39 ++----------------- .../xdrv_01_9_webserver.ino | 2 +- .../tasmota_xdrv_driver/xdrv_57_9_tasmesh.ino | 2 +- 6 files changed, 9 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9473518a..273e83a5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ All notable changes to this project will be documented in this file. ### Changed ### Fixed +- HASPmota `align` attribute and expand PNG cache +- LVGL restore `lv_palette` functions +- IPv6 support in safeboot ### Removed @@ -58,8 +61,6 @@ All notable changes to this project will be documented in this file. - NeoPool hydrolysis unit for Hidrolife, Bionet and Generic device (#21098) - M5Core2 LoRa868 module receive exception - Fade out on CCT bulb with `SO92 1` (#21159) -- HASPmota `align` attribute and expand PNG cache -- LVGL restore `lv_palette` functions ### Removed - Unused `#define MQTT_DATA_STRING` support diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index b5270f0d2..b3a70d13e 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -135,8 +135,6 @@ struct WIFI { bool wifi_test_AP_TIMEOUT = false; bool wifi_Test_Restart = false; bool wifi_Test_Save_SSID2 = false; - // IPv6 support, not guarded with #if LWIP_IPV6 to avoid bloating code with ifdefs - bool ipv6_local_link_called = false; // did we already enable IPv6 Local-Link address, needs to be redone at each reconnect } Wifi; typedef struct { diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index a73f9c2f4..aaa40a3da 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -208,7 +208,7 @@ void CmndWifiTest(void) AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP " %s " D_AS " %s ..."), ssid_test, TasmotaGlobal.hostname); - WiFi.begin(ssid_test,pswd_test); + WiFiHelper::begin(ssid_test,pswd_test); } } else { ResponseCmndChar(D_JSON_BUSY); diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index 76fb4b28f..e623a9f07 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -250,12 +250,12 @@ void WifiBegin(uint8_t flag, uint8_t channel) { char stemp[40] = { 0 }; if (channel) { - WiFi.begin(SettingsText(SET_STASSID1 + Settings->sta_active), SettingsText(SET_STAPWD1 + Settings->sta_active), channel, Wifi.bssid); + WiFiHelper::begin(SettingsText(SET_STASSID1 + Settings->sta_active), SettingsText(SET_STAPWD1 + Settings->sta_active), channel, Wifi.bssid); // Add connected BSSID and channel for multi-AP installations char hex_char[18]; snprintf_P(stemp, sizeof(stemp), PSTR(" Channel %d BSSId %s"), channel, ToHex_P((unsigned char*)Wifi.bssid, 6, hex_char, sizeof(hex_char), ':')); } else { - WiFi.begin(SettingsText(SET_STASSID1 + Settings->sta_active), SettingsText(SET_STAPWD1 + Settings->sta_active)); + WiFiHelper::begin(SettingsText(SET_STASSID1 + Settings->sta_active), SettingsText(SET_STAPWD1 + Settings->sta_active)); } delay(500); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s%s " D_IN_MODE " %s " D_AS " %s..."), @@ -818,18 +818,6 @@ void WifiCheckIp(void) { AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI D_CHECKING_CONNECTION)); Wifi.counter = WIFI_CHECK_SEC; -#ifdef USE_IPV6 - if (WL_CONNECTED == WiFi.status()) { -#ifdef ESP32 - if (!Wifi.ipv6_local_link_called) { - WiFi.enableIPv6(true); // TODO - Wifi.ipv6_local_link_called = true; - // AddLog(LOG_LEVEL_DEBUG, PSTR("WIF: calling enableIPV6")); - } -#endif - } -#endif // USE_IPV6 - if ((WL_CONNECTED == WiFi.status()) && WifiHasIP()) { WifiSetState(1); Wifi.counter = WIFI_CHECK_SEC; @@ -1091,7 +1079,7 @@ void WifiConnect(void) { if (!Settings->flag4.network_wifi) { return; } -#if defined(ESP32) && !defined(FIRMWARE_MINIMAL) +#ifdef ESP32 static bool wifi_event_registered = false; if (!wifi_event_registered) { WiFi.onEvent(WifiEvents); // register event listener only once @@ -1494,27 +1482,6 @@ void WifiEvents(arduino_event_t *event) { } break; - case ARDUINO_EVENT_WIFI_STA_CONNECTED: - // workaround for the race condition in LWIP, see https://github.com/espressif/arduino-esp32/pull/9016#discussion_r1451774885 - { - uint32_t i = 5; // try 5 times only - while (esp_netif_create_ip6_linklocal(get_esp_interface_netif(ESP_IF_WIFI_STA)) != ESP_OK) { - delay(1); - if (i-- == 0) { - break; - } - } - } - - // WiFi.enableIPv6(); - // AddLog(LOG_LEVEL_DEBUG, PSTR("WIF: Received ARDUINO_EVENT_WIFI_STA_CONNECTED")); - Wifi.ipv6_local_link_called = false; // not sure if this is needed, make sure link-local is restored at each reconnect - break; - case ARDUINO_EVENT_WIFI_STA_DISCONNECTED: - case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE: - Wifi.ipv6_local_link_called = false; - break; - default: break; } diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index c4c2064c0..44ad0508d 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -1941,7 +1941,7 @@ void HandleWifiConfiguration(void) { AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP " %s " D_AS " %s ..."), SettingsText(SET_STASSID1), TasmotaGlobal.hostname); - WiFi.begin(SettingsText(SET_STASSID1), SettingsText(SET_STAPWD1)); + WiFiHelper::begin(SettingsText(SET_STASSID1), SettingsText(SET_STAPWD1)); WebRestart(2); } else { diff --git a/tasmota/tasmota_xdrv_driver/xdrv_57_9_tasmesh.ino b/tasmota/tasmota_xdrv_driver/xdrv_57_9_tasmesh.ino index a580f8826..262355e13 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_57_9_tasmesh.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_57_9_tasmesh.ino @@ -377,7 +377,7 @@ void MESHstartNode(int32_t _channel, uint8_t _role){ //we need a running broker #ifdef ESP8266 // for now only ESP8266, might be added for the ESP32 later MESH.channel = _channel; WiFi.mode(WIFI_STA); - WiFi.begin("", "", MESH.channel, nullptr, false); //fake connection attempt to set channel + WiFiHelper::begin("", "", MESH.channel, nullptr, false); //fake connection attempt to set channel wifi_promiscuous_enable(1); wifi_set_channel(MESH.channel); wifi_promiscuous_enable(0);