diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4a776556f..01567f9f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
- ESP32 LVGL library from v9.0.0 to v9.1.0 (#21008)
- berry.exe (pre-compiled for Windows) updated to latest Berry patches (#21024)
- Some `display.ini` to utouch (#21029)
+- ESP32 WiFi phy modes 11n and 11ax represented as HT20, HT40 and HE20 (#19350)
### Fixed
- BTHome, prep BLE5 (#20989)
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 8a3e8988e..31a434a19 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -151,6 +151,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
- NeoPool webUI pH alarms (4 & 5) completed (#20743)[#20743](https://github.com/arendst/Tasmota/issues/20743)
- Prevent shutter MQTT broadcast with activated ShutterLock [#20827](https://github.com/arendst/Tasmota/issues/20827)
- Some `display.ini` to utouch [#21029](https://github.com/arendst/Tasmota/issues/21029)
+- ESP32 WiFi phy modes 11n and 11ax represented as HT20, HT40 and HE20 [#19350](https://github.com/arendst/Tasmota/issues/19350)
- berry.exe (pre-compiled for Windows) updated to latest Berry patches [#21024](https://github.com/arendst/Tasmota/issues/21024)
- Berry class `int64` made immutable [#20727](https://github.com/arendst/Tasmota/issues/20727)
- Matter reduce memory usage when reading with wildcards [#20809](https://github.com/arendst/Tasmota/issues/20809)
diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp b/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp
index c5cdedc3f..40b85d692 100644
--- a/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp
+++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/ESP32Wifi.cpp
@@ -124,13 +124,24 @@ void WiFiClass32::setSleepMode(int iSleepMode) {
}
int WiFiClass32::getPhyMode() {
- int phy_mode = 0; // " BGNL"
- uint8_t protocol_bitmap;
- if (esp_wifi_get_protocol(WIFI_IF_STA, &protocol_bitmap) == ESP_OK) {
- if (protocol_bitmap & 1) { phy_mode = TAS_WIFI_PHY_MODE_11B; } // 1 = 11b (WIFI_PHY_MODE_11B)
- if (protocol_bitmap & 2) { phy_mode = TAS_WIFI_PHY_MODE_11G; } // 2 = 11bg (WIFI_PHY_MODE_11G)
- if (protocol_bitmap & 4) { phy_mode = TAS_WIFI_PHY_MODE_11N; } // 3 = 11bgn (WIFI_PHY_MODE_11N)
- if (protocol_bitmap & 8) { phy_mode = 4; } // Low rate (WIFI_PHY_MODE_LR)
+ /*
+ typedef enum
+ {
+ WIFI_PHY_MODE_LR, // PHY mode for Low Rate
+ WIFI_PHY_MODE_11B, // PHY mode for 11b
+ WIFI_PHY_MODE_11G, // PHY mode for 11g
+ WIFI_PHY_MODE_HT20, // PHY mode for Bandwidth HT20 (11n)
+ WIFI_PHY_MODE_HT40, // PHY mode for Bandwidth HT40 (11n)
+ WIFI_PHY_MODE_HE20, // PHY mode for Bandwidth HE20 (11ax)
+ } wifi_phy_mode_t;
+ */
+ int phy_mode = 0; // "low rate|11b|11g|HT20|HT40|HE20"
+ wifi_phy_mode_t WiFiMode;
+ if (esp_wifi_sta_get_negotiated_phymode(&WiFiMode) == ESP_OK) {
+ phy_mode = (int)WiFiMode;
+ if (phy_mode > 5) {
+ phy_mode = 5;
+ }
}
return phy_mode;
}
diff --git a/tasmota/include/tasmota.h b/tasmota/include/tasmota.h
index bb23f5c1e..7fe10bf49 100644
--- a/tasmota/include/tasmota.h
+++ b/tasmota/include/tasmota.h
@@ -126,8 +126,6 @@ const uint8_t MAX_BUTTON_TEXT = 32; // 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/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino
index 4f8e1f960..3a79e9e6c 100644
--- a/tasmota/tasmota_support/support_command.ino
+++ b/tasmota/tasmota_support/support_command.ino
@@ -2686,7 +2686,8 @@ void CmndWifi(void)
#endif
WiFi.setPhyMode(WiFiPhyMode_t(XdrvMailbox.payload - 1)); // 1-B/2-BG/3-BGN
}
- 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]) );
+ Response_P(PSTR("{\"" D_JSON_WIFI "\":\"%s\",\"" D_JSON_WIFI_MODE "\":\"%s\"}"),
+ GetStateText(Settings->flag4.network_wifi), WifiGetPhyMode().c_str());
}
void CmndDnsTimeout(void) {
diff --git a/tasmota/tasmota_support/support_esp32.ino b/tasmota/tasmota_support/support_esp32.ino
index 017830a5d..7130f5215 100644
--- a/tasmota/tasmota_support/support_esp32.ino
+++ b/tasmota/tasmota_support/support_esp32.ino
@@ -11,6 +11,9 @@
* ESP32, ESP32-S2, ESP32-S3, ESP32-C2, ESP32-C3, ESP32-C6 and ESP32-H2 Support
\*********************************************************************************************/
+// 11b 11g 11n 11n 11ax
+const static char kWifiPhyMode[] PROGMEM = "low rate|11b|11g|HT20|HT40|HE20"; // Wi-Fi Modes
+
#include "soc/soc.h"
#include "soc/spi_reg.h"
// ESP32_ARCH contains the name of the architecture (used by autoconf)
@@ -976,6 +979,11 @@ String ESP_getEfuseMac(void) {
return String(ESP.getEfuseMac());
}
+String WifiGetPhyMode(void) {
+ char stemp[10];
+ return String(GetTextIndexed(stemp, sizeof(stemp), WiFi.getPhyMode(), kWifiPhyMode));
+}
+
/*********************************************************************************************\
* High entropy hardware random generator
* Thanks to DigitalAlchemist
diff --git a/tasmota/tasmota_support/support_esp8266.ino b/tasmota/tasmota_support/support_esp8266.ino
index c9ba29078..2f043aa64 100644
--- a/tasmota/tasmota_support/support_esp8266.ino
+++ b/tasmota/tasmota_support/support_esp8266.ino
@@ -11,6 +11,8 @@
* ESP8266 and ESP8285 Support
\*********************************************************************************************/
+const static char kWifiPhyMode[] PROGMEM = "low rate|11b|11g|11n"; // Wi-Fi Modes
+
extern "C" {
extern struct rst_info resetInfo;
}
@@ -258,6 +260,11 @@ String ESP_getEfuseMac(void) {
return String(macStr);
}
+String WifiGetPhyMode(void) {
+ char stemp[10];
+ return String(GetTextIndexed(stemp, sizeof(stemp), WiFi.getPhyMode() & 0x3, kWifiPhyMode));
+}
+
/*********************************************************************************************\
* High entropy hardware random generator
* Thanks to DigitalAlchemist
diff --git a/tasmota/tasmota_support/support_tasmota.ino b/tasmota/tasmota_support/support_tasmota.ino
index 032bf6f30..47d407268 100644
--- a/tasmota/tasmota_support/support_tasmota.ino
+++ b/tasmota/tasmota_support/support_tasmota.ino
@@ -877,9 +877,9 @@ 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_WIFI_MODE "\":\"11%c\",\"" 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 "\":\"%s\",\"" 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(),
- pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]), WifiGetRssiAsQuality(rssi), rssi,
+ WifiGetPhyMode().c_str(), WifiGetRssiAsQuality(rssi), rssi,
WifiLinkCount(), WifiDowntime().c_str());
}
diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino
index a1e7f02d0..fdd9db556 100644
--- a/tasmota/tasmota_support/support_wifi.ino
+++ b/tasmota/tasmota_support/support_wifi.ino
@@ -259,8 +259,8 @@ void WifiBegin(uint8_t flag, uint8_t channel) {
WiFi.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 " 11%c " D_AS " %s..."),
- Settings->sta_active +1, SettingsText(SET_STASSID1 + Settings->sta_active), stemp, pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]), TasmotaGlobal.hostname);
+ AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s%s " D_IN_MODE " %s " D_AS " %s..."),
+ Settings->sta_active +1, SettingsText(SET_STASSID1 + Settings->sta_active), stemp, WifiGetPhyMode().c_str(), TasmotaGlobal.hostname);
if (Settings->flag5.wait_for_wifi_result) { // SetOption142 - (Wifi) Wait 1 second for wifi connection solving some FRITZ!Box modem issues (1)
WiFi.waitForConnectResult(1000); // https://github.com/arendst/Tasmota/issues/14985
diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
index 27aed9159..cbc8c3426 100644
--- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
+++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
@@ -2439,11 +2439,11 @@ void HandleInformation(void) {
}
if (Settings->flag4.network_wifi) {
int32_t rssi = WiFi.RSSI();
- WSContentSend_P(PSTR("}1" D_AP "%d " D_INFORMATION "}2" D_SSID " %s
" D_RSSI " %d%%, %d dBm
" D_MODE " 11%c
" D_CHANNEL " %d
" D_BSSID " %s"),
+ WSContentSend_P(PSTR("}1" D_AP "%d " D_INFORMATION "}2" D_SSID " %s
" D_RSSI " %d%%, %d dBm
" D_MODE " %s
" D_CHANNEL " %d
" D_BSSID " %s"),
Settings->sta_active +1,
SettingsTextEscaped(SET_STASSID1 + Settings->sta_active).c_str(),
WifiGetRssiAsQuality(rssi), rssi,
- pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]),
+ WifiGetPhyMode().c_str(),
WiFi.channel(),
WiFi.BSSIDstr().c_str());
WSContentSeparatorIFat();