diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 653c839e56..3762369c54 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 653c839e56087f63450a948394ab1af943a3c87c +Subproject commit 3762369c54c7341d13f181b7f1911afa5c3dc887 diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index 9c050e1e1b..a1e3df010c 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -1693,7 +1693,7 @@ config SOC_WIFI_HW_TSF config SOC_WIFI_FTM_SUPPORT bool - default n + default y config SOC_WIFI_GCMP_SUPPORT bool diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 8f5c02f9b3..d289171725 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -667,7 +667,7 @@ /*------------------------------------ WI-FI CAPS ------------------------------------*/ #define SOC_WIFI_HW_TSF (1) /*!< Support hardware TSF */ -#define SOC_WIFI_FTM_SUPPORT (0) /*!< Support FTM */ // TODO: [ESP32C5] WIFI-6426 +#define SOC_WIFI_FTM_SUPPORT (1) /*!< Support FTM */ #define SOC_WIFI_GCMP_SUPPORT (1) /*!< Support GCMP(GCMP128 and GCMP256) */ #define SOC_WIFI_WAPI_SUPPORT (1) /*!< Support WAPI */ #define SOC_WIFI_CSI_SUPPORT (1) /*!< Support CSI */ diff --git a/examples/wifi/ftm/README.md b/examples/wifi/ftm/README.md index a124ac79de..7f6df2c5f1 100644 --- a/examples/wifi/ftm/README.md +++ b/examples/wifi/ftm/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 | -| ----------------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-S2 | ESP32-S3 | +| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | # FTM Example diff --git a/examples/wifi/ftm/main/ftm_main.c b/examples/wifi/ftm/main/ftm_main.c index b6eb413ab7..806de08e88 100644 --- a/examples/wifi/ftm/main/ftm_main.c +++ b/examples/wifi/ftm/main/ftm_main.c @@ -418,10 +418,12 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel, } strlcpy((char*) g_ap_config.ap.password, pass, MAX_PASSPHRASE_LEN); } +#if !CONFIG_SOC_WIFI_SUPPORT_5G if (!(channel >=1 && channel <= 14)) { ESP_LOGE(TAG_AP, "Channel cannot be %d!", channel); return false; } +#endif if (bw != 20 && bw != 40) { ESP_LOGE(TAG_AP, "Cannot set %d MHz bandwidth!", bw); return false; @@ -430,16 +432,41 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel, if (ESP_OK != wifi_add_mode(WIFI_MODE_AP)) { return false; } + wifi_bandwidths_t bws = {0}; + wifi_protocols_t proto = {0}; + if (channel <= 14) { + if (bw == 40) { + proto.ghz_2g = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N; + proto.ghz_5g = 0; + esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto); + bws.ghz_2g = WIFI_BW_HT40; + esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws); + } else { + bws.ghz_2g = WIFI_BW_HT20; + esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws); + } + } else { +#if CONFIG_SOC_WIFI_SUPPORT_5G + if (bw == 40) { + proto.ghz_2g = 0; + proto.ghz_5g = WIFI_PROTOCOL_11N | WIFI_PROTOCOL_11A; + esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto); + bws.ghz_5g=WIFI_BW_HT40; + esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws); + } else { + proto.ghz_2g = 0; + proto.ghz_5g = WIFI_PROTOCOL_11AC | WIFI_PROTOCOL_11A | WIFI_PROTOCOL_11AX; + esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto); + bws.ghz_5g = WIFI_BW_HT20; + esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws); + } +#endif + } if (strlen(pass) == 0) { g_ap_config.ap.authmode = WIFI_AUTH_OPEN; } g_ap_config.ap.channel = channel; ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &g_ap_config)); - if (bw == 40) { - esp_wifi_set_bandwidth(ESP_IF_WIFI_AP, WIFI_BW_HT40); - } else { - esp_wifi_set_bandwidth(ESP_IF_WIFI_AP, WIFI_BW_HT20); - } ESP_LOGI(TAG_AP, "Starting SoftAP with FTM Responder support, SSID - %s, Password - %s, Primary Channel - %d, Bandwidth - %dMHz", ap_args.ssid->sval[0], ap_args.password->sval[0], channel, bw);