From 512d912b771764cea708352a566f1ddd29a1e6bf Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 5 Jul 2021 14:50:33 +0200 Subject: [PATCH] Change setting hostname to fixing ArduinoESP32 core 2.0.0 --- CHANGELOG.md | 1 + RELEASENOTES.md | 2 ++ tasmota/settings.h | 2 +- tasmota/support_wifi.ino | 11 +++++------ tasmota/xdrv_01_webserver.ino | 2 -- tools/decode-status.py | 3 ++- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39bbbe8dc..40b11fc2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. - ESP32 Ethernet Phy Type information to IDF v3+ - Allow buttons to work in AP normal mode (#12518) - Enable Ping and rule features for any device compiled with more than 1M flash size (#12539) +- Setting hostname to fixing ArduinoESP32 core 2.0.0 ### Fixed - ESP32-C3 settings layout for configuration backup and restore diff --git a/RELEASENOTES.md b/RELEASENOTES.md index fbe5857fb..5e8c77495 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -97,6 +97,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo ## Changelog v9.5.0.2 ### Added +- Command ``SetOption127 1`` to force Wifi in no-sleep mode even if ``Sleep 0`` is not enabled - Initial support for Tasmota Mesh (TasMesh) providing node/broker communication using ESP-NOW [#11939](https://github.com/arendst/Tasmota/issues/11939) - Berry ESP32 partition manager [#12465](https://github.com/arendst/Tasmota/issues/12465) - Support for AM2320 Temperature and Humidity Sensor by Lars Wessels [#12485](https://github.com/arendst/Tasmota/issues/12485) @@ -108,6 +109,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - ESP32 Ethernet Phy Type information to IDF v3+ - Speed up initial GUI console refresh - Enable UFILESYS, GUI_TRASH_FILE and GUI_EDIT_FILE for any device compiled with more than 1M flash size +- Setting hostname to fixing ArduinoESP32 core 2.0.0 - Simplified configuration for ir-full and removal of tasmota-ircustom [#12428](https://github.com/arendst/Tasmota/issues/12428) - Refactor platformio [#12442](https://github.com/arendst/Tasmota/issues/12442) - Allow buttons to work in AP normal mode [#12518](https://github.com/arendst/Tasmota/issues/12518) diff --git a/tasmota/settings.h b/tasmota/settings.h index 73d4b4da9..8635eacf4 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -156,7 +156,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t wiegand_keypad_to_tag : 1; // bit 10 (v9.3.1.1) - SetOption124 - (Wiegand) send key pad stroke as single char (0) or one tag (ending char #) (1) uint32_t zigbee_hide_bridge_topic : 1; // bit 11 (v9.3.1.1) - SetOption125 - (Zigbee) Hide bridge topic from zigbee topic (use with SetOption89) (1) uint32_t ds18x20_mean : 1; // bit 12 (v9.3.1.2) - SetOption126 - (DS18x20) Enable arithmetic mean over teleperiod for JSON temperature (1) - uint32_t wifi_no_sleep : 1; // bit 13 (v9.5.0.2) - SetOption127 - (Wifi) keep wifi in no-sleep mode, prevents some occasional unresponsiveness + uint32_t wifi_no_sleep : 1; // bit 13 (v9.5.0.2) - SetOption127 - (Wifi) Keep wifi in no-sleep mode, prevents some occasional unresponsiveness uint32_t spare14 : 1; // bit 14 uint32_t spare15 : 1; // bit 15 uint32_t spare16 : 1; // bit 16 diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index 1ce780d0a..8c4fc945b 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -112,11 +112,12 @@ void WifiConfig(uint8_t type) } } -void WifiSetMode(WiFiMode_t wifi_mode) -{ +void WifiSetMode(WiFiMode_t wifi_mode) { if (WiFi.getMode() == wifi_mode) { return; } if (wifi_mode != WIFI_OFF) { + WiFi.hostname(TasmotaGlobal.hostname); // Set hostname before WiFi.mode as needed for ESP32 core 2.0.0 + // See: https://github.com/esp8266/Arduino/issues/6172#issuecomment-500457407 WiFi.forceSleepWake(); // Make sure WiFi is really active. delay(100); @@ -161,7 +162,7 @@ void WiFiSetSleepMode(void) */ bool wifi_no_sleep = Settings->flag5.wifi_no_sleep; #ifdef CONFIG_IDF_TARGET_ESP32C3 - wifi_no_sleep = true; // temporary patch for IDF4.4, wifi sleeping may cause wifi drops + wifi_no_sleep = true; // Temporary patch for IDF4.4, wifi sleeping may cause wifi drops #endif if (0 == TasmotaGlobal.sleep || wifi_no_sleep) { if (!TasmotaGlobal.wifi_stay_asleep) { @@ -186,8 +187,7 @@ void WifiBegin(uint8_t flag, uint8_t channel) WiFi.persistent(false); // Solve possible wifi init errors (re-add at 6.2.1.16 #4044, #4083) WiFi.disconnect(true); // Delete SDK wifi config delay(200); -// WiFi.mode(WIFI_STA); // Disable AP mode - WifiSetMode(WIFI_STA); + WifiSetMode(WIFI_STA); // Disable AP mode WiFiSetSleepMode(); // if (WiFi.getPhyMode() != WIFI_PHY_MODE_11N) { WiFi.setPhyMode(WIFI_PHY_MODE_11N); } // B/G/N // if (WiFi.getPhyMode() != WIFI_PHY_MODE_11G) { WiFi.setPhyMode(WIFI_PHY_MODE_11G); } // B/G @@ -207,7 +207,6 @@ void WifiBegin(uint8_t flag, uint8_t channel) if (Settings->ipv4_address[0]) { WiFi.config(Settings->ipv4_address[0], Settings->ipv4_address[1], Settings->ipv4_address[2], Settings->ipv4_address[3]); // Set static IP } - WiFi.hostname(TasmotaGlobal.hostname); char stemp[40] = { 0 }; if (channel) { diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index aae9679d0..15f35de60 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -594,11 +594,9 @@ void WifiManagerBegin(bool reset_only) // setup AP if (!Web.initial_config) { AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER " " D_ACTIVE_FOR_3_MINUTES)); } if (!TasmotaGlobal.global_state.wifi_down) { -// WiFi.mode(WIFI_AP_STA); WifiSetMode(WIFI_AP_STA); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT_AND_STATION)); } else { -// WiFi.mode(WIFI_AP); WifiSetMode(WIFI_AP); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT)); } diff --git a/tools/decode-status.py b/tools/decode-status.py index 1d047692a..b4a7ba16d 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -181,7 +181,8 @@ a_setoption = [[ "(Wiegand) send key pad stroke as single char (0) or one tag (ending char #) (1)", "(Zigbee) Hide bridge topic from zigbee topic (use with SetOption89) (1)", "(DS18x20) Enable arithmetic mean over teleperiod for JSON temperature (1)", - "","","", + "(Wifi) Keep wifi in no-sleep mode, prevents some occasional unresponsiveness", + "","", "","","","", "","","","", "","","","",