Skip to content

Commit 9347887

Browse files
ndrs-pstfabiobaltieri
authored andcommitted
wifi: esp32: update link_mode to reflect actual negotiated PHY mode
Updated `link_mode` assignment to reflect the actual negotiated PHY mode by using `esp_wifi_sta_get_negotiated_phymode`. Since `ap_info.phy_11b` ... `ap_info.phy_11ax` represent the access point capabilities and not the actual current link mode. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent 3590bd6 commit 9347887

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

drivers/wifi/esp32/src/esp_wifi_drv.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,9 @@ static int esp32_wifi_status(const struct device *dev, struct wifi_iface_status
611611

612612
if (esp_wifi_get_mode(&mode) == ESP_OK) {
613613
if (mode == ESP32_WIFI_MODE_STA) {
614+
wifi_phy_mode_t phy_mode;
615+
esp_err_t err;
616+
614617
esp_wifi_get_config(ESP_IF_WIFI_STA, &conf);
615618
esp_wifi_sta_get_ap_info(&ap_info);
616619

@@ -619,14 +622,18 @@ static int esp32_wifi_status(const struct device *dev, struct wifi_iface_status
619622
status->rssi = ap_info.rssi;
620623
memcpy(status->bssid, ap_info.bssid, WIFI_MAC_ADDR_LEN);
621624

622-
if (ap_info.phy_11b) {
623-
status->link_mode = WIFI_1;
624-
} else if (ap_info.phy_11g) {
625-
status->link_mode = WIFI_3;
626-
} else if (ap_info.phy_11n) {
627-
status->link_mode = WIFI_4;
628-
} else if (ap_info.phy_11ax) {
629-
status->link_mode = WIFI_6;
625+
err = esp_wifi_sta_get_negotiated_phymode(&phy_mode);
626+
if (err == ESP_OK) {
627+
if (phy_mode == WIFI_PHY_MODE_11B) {
628+
status->link_mode = WIFI_1;
629+
} else if (phy_mode == WIFI_PHY_MODE_11G) {
630+
status->link_mode = WIFI_3;
631+
} else if ((phy_mode == WIFI_PHY_MODE_HT20) ||
632+
(phy_mode == WIFI_PHY_MODE_HT40)) {
633+
status->link_mode = WIFI_4;
634+
} else if (phy_mode == WIFI_PHY_MODE_HE20) {
635+
status->link_mode = WIFI_6;
636+
}
630637
}
631638

632639
status->beacon_interval = conf.sta.listen_interval;

0 commit comments

Comments
 (0)