diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 09e4b84fa..f22aa1c4d 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -200,6 +200,7 @@ #define D_JSON_VOLUME "Volume" #define D_JSON_WEIGHT "Weight" #define D_JSON_WIFI "Wifi" +#define D_JSON_WIFI_MODE "Mode" #define D_JSON_WRONG "Wrong" #define D_JSON_WRONG_PARAMETERS "Wrong parameters" #define D_JSON_YESTERDAY "Yesterday" diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 7a7a00340..e8bca9f73 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -2142,8 +2142,12 @@ void CmndWifi(void) if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) { Settings.flag4.network_wifi = XdrvMailbox.payload; if (Settings.flag4.network_wifi) { WifiEnable(); } +#ifdef ESP8266 + } else if ((XdrvMailbox.payload >= 2) && (XdrvMailbox.payload <= 4)) { + WiFi.setPhyMode(WiFiPhyMode_t(XdrvMailbox.payload - 1)); // 1-B/2-BG/3-BGN +#endif } - ResponseCmndStateText(Settings.flag4.network_wifi); + Response_P(PSTR("{\"" D_JSON_WIFI "\":\"%s\",\"" D_JSON_WIFI_MODE "\":\"11%c\"}"), GetStateText(Settings.flag4.network_wifi), pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]) ); } #ifdef USE_I2C diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index d04073805..d439fe0a2 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -767,9 +767,10 @@ void MqttShowState(void) if (!TasmotaGlobal.global_state.wifi_down) { int32_t rssi = WiFi.RSSI(); - ResponseAppend_P(PSTR(",\"" D_JSON_WIFI "\":{\"" D_JSON_AP "\":%d,\"" D_JSON_SSID "\":\"%s\",\"" D_JSON_BSSID "\":\"%s\",\"" D_JSON_CHANNEL "\":%d,\"" D_JSON_RSSI "\":%d,\"" D_JSON_SIGNAL "\":%d,\"" D_JSON_LINK_COUNT "\":%d,\"" D_JSON_DOWNTIME "\":\"%s\"}"), + ResponseAppend_P(PSTR(",\"" D_JSON_WIFI "\":{\"" D_JSON_AP "\":%d,\"" D_JSON_SSID "\":\"%s\",\"" D_JSON_BSSID "\":\"%s\",\"" D_JSON_CHANNEL "\":%d,\"" D_JSON_WIFI_MODE "\":\"11%c\",\"" D_JSON_RSSI "\":%d,\"" D_JSON_SIGNAL "\":%d,\"" D_JSON_LINK_COUNT "\":%d,\"" D_JSON_DOWNTIME "\":\"%s\"}"), Settings.sta_active +1, EscapeJSONString(SettingsText(SET_STASSID1 + Settings.sta_active)).c_str(), WiFi.BSSIDstr().c_str(), WiFi.channel(), - WifiGetRssiAsQuality(rssi), rssi, WifiLinkCount(), WifiDowntime().c_str()); + pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]), WifiGetRssiAsQuality(rssi), rssi, + WifiLinkCount(), WifiDowntime().c_str()); } ResponseJsonEnd(); diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index 3f4b96ef8..577377386 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -175,8 +175,6 @@ void WiFiSetSleepMode(void) void WifiBegin(uint8_t flag, uint8_t channel) { - const static char kWifiPhyMode[] PROGMEM = " bgnl"; - #ifdef USE_EMULATION UdpDisconnect(); #endif // USE_EMULATION diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index 46d554ad7..d087bd5fb 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -105,6 +105,9 @@ const uint8_t MAX_FRIENDLYNAMES = 8; // Max number of Friendly names const uint8_t MAX_BUTTON_TEXT = 16; // Max number of GUI button labels const uint8_t MAX_GROUP_TOPICS = 4; // Max number of Group Topics const uint8_t MAX_DEV_GROUP_NAMES = 4; // Max number of Device Group names + +const static char kWifiPhyMode[] PROGMEM = " bgnl"; // Wi-Fi Modes + #ifdef ESP8266 const uint8_t MAX_ADCS = 1; // Max number of ESP8266 ADC pins const uint8_t MAX_SWITCHES_TXT = 8; // Max number of switches user text diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index b16d1b75e..a84eb5b16 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -1782,13 +1782,8 @@ void HandleWifiConfiguration(void) { TasmotaGlobal.save_data_counter = 0; // Stop auto saving data - Updating Settings Settings.save_data = 0; - if (MAX_WIFI_OPTION == Web.old_wificonfig) { - Web.old_wificonfig = Settings.sta_config; - //AddLog(LOG_LEVEL_INFO,PSTR("WFM: save wificonfig %d and set to 2 (settings=%d)"), Web.old_wificonfig, Settings.sta_config); - } else { - //AddLog(LOG_LEVEL_INFO,PSTR("WFM: wificonfig already saved %d, set to 2 (settings=%d)"), Web.old_wificonfig, Settings.sta_config); - } - TasmotaGlobal.wifi_state_flag = Settings.sta_config = WIFI_MANAGER;; + if (MAX_WIFI_OPTION == Web.old_wificonfig) { Web.old_wificonfig = Settings.sta_config; } + TasmotaGlobal.wifi_state_flag = Settings.sta_config = WIFI_MANAGER; TasmotaGlobal.sleep = 0; // Disable sleep TasmotaGlobal.restart_flag = 0; // No restart @@ -2271,7 +2266,7 @@ void HandleInformation(void) #endif if (Settings.flag4.network_wifi) { int32_t rssi = WiFi.RSSI(); - WSContentSend_P(PSTR("}1" D_AP "%d " D_SSID " (" D_RSSI ")}2%s (%d%%, %d dBm)"), Settings.sta_active +1, HtmlEscape(SettingsText(SET_STASSID1 + Settings.sta_active)).c_str(), WifiGetRssiAsQuality(rssi), rssi); + WSContentSend_P(PSTR("}1" D_AP "%d " D_SSID " (" D_RSSI ")}2%s (%d%%, %d dBm) 11%c"), Settings.sta_active +1, HtmlEscape(SettingsText(SET_STASSID1 + Settings.sta_active)).c_str(), WifiGetRssiAsQuality(rssi), rssi, pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]) ); WSContentSend_P(PSTR("}1" D_HOSTNAME "}2%s%s"), TasmotaGlobal.hostname, (Mdns.begun) ? PSTR(".local") : ""); #if LWIP_IPV6 String ipv6_addr = WifiGetIPv6(); @@ -3268,9 +3263,6 @@ bool Xdrv01(uint8_t function) // TasmotaGlobal.blinks = 255; // Signal wifi connection with blinks if (MAX_WIFI_OPTION != Web.old_wificonfig) { TasmotaGlobal.wifi_state_flag = Settings.sta_config = Web.old_wificonfig; - //AddLog(LOG_LEVEL_INFO,PSTR("WFM: Restore wificonfig %d"), Web.old_wificonfig); - } else { - //AddLog(LOG_LEVEL_INFO,PSTR("WFM: Keep wificonfig %d"), Settings.sta_config); } TasmotaGlobal.save_data_counter = Web.save_data_counter; Settings.save_data = Web.save_data_counter;