feat(esp_wifi): Add FTM support for ESP32C5 (ECO2)

Closes https://github.com/espressif/esp-idf/issues/15909
This commit is contained in:
akshat
2024-09-18 11:55:43 +05:30
committed by Jack
parent de17b6ff94
commit 0a17f79cc7
5 changed files with 37 additions and 10 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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

View File

@ -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);