Skip to content

Commit fbfa32c

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'feature/ftm_support_5ghz_esp32c5' into 'master'
feat(esp_wifi): Add FTM support for ESP32C5 Closes WIFI-6426, IDF-10612, and IDFGH-15244 See merge request espressif/esp-idf!33587
2 parents 016e836 + 9b1a806 commit fbfa32c

File tree

5 files changed

+37
-10
lines changed

5 files changed

+37
-10
lines changed

components/soc/esp32c5/include/soc/Kconfig.soc_caps.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ config SOC_WIFI_HW_TSF
16931693

16941694
config SOC_WIFI_FTM_SUPPORT
16951695
bool
1696-
default n
1696+
default y
16971697

16981698
config SOC_WIFI_GCMP_SUPPORT
16991699
bool

components/soc/esp32c5/include/soc/soc_caps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@
667667

668668
/*------------------------------------ WI-FI CAPS ------------------------------------*/
669669
#define SOC_WIFI_HW_TSF (1) /*!< Support hardware TSF */
670-
#define SOC_WIFI_FTM_SUPPORT (0) /*!< Support FTM */ // TODO: [ESP32C5] WIFI-6426
670+
#define SOC_WIFI_FTM_SUPPORT (1) /*!< Support FTM */
671671
#define SOC_WIFI_GCMP_SUPPORT (1) /*!< Support GCMP(GCMP128 and GCMP256) */
672672
#define SOC_WIFI_WAPI_SUPPORT (1) /*!< Support WAPI */
673673
#define SOC_WIFI_CSI_SUPPORT (1) /*!< Support CSI */

examples/wifi/ftm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 |
2-
| ----------------- | -------- | -------- | -------- | -------- | -------- |
1+
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-S2 | ESP32-S3 |
2+
| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- |
33

44
# FTM Example
55

examples/wifi/ftm/main/ftm_main.c

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,12 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel,
418418
}
419419
strlcpy((char*) g_ap_config.ap.password, pass, MAX_PASSPHRASE_LEN);
420420
}
421+
#if !CONFIG_SOC_WIFI_SUPPORT_5G
421422
if (!(channel >=1 && channel <= 14)) {
422423
ESP_LOGE(TAG_AP, "Channel cannot be %d!", channel);
423424
return false;
424425
}
426+
#endif
425427
if (bw != 20 && bw != 40) {
426428
ESP_LOGE(TAG_AP, "Cannot set %d MHz bandwidth!", bw);
427429
return false;
@@ -430,16 +432,41 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel,
430432
if (ESP_OK != wifi_add_mode(WIFI_MODE_AP)) {
431433
return false;
432434
}
435+
wifi_bandwidths_t bws = {0};
436+
wifi_protocols_t proto = {0};
437+
if (channel <= 14) {
438+
if (bw == 40) {
439+
proto.ghz_2g = WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N;
440+
proto.ghz_5g = 0;
441+
esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto);
442+
bws.ghz_2g = WIFI_BW_HT40;
443+
esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws);
444+
} else {
445+
bws.ghz_2g = WIFI_BW_HT20;
446+
esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws);
447+
}
448+
} else {
449+
#if CONFIG_SOC_WIFI_SUPPORT_5G
450+
if (bw == 40) {
451+
proto.ghz_2g = 0;
452+
proto.ghz_5g = WIFI_PROTOCOL_11N | WIFI_PROTOCOL_11A;
453+
esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto);
454+
bws.ghz_5g=WIFI_BW_HT40;
455+
esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws);
456+
} else {
457+
proto.ghz_2g = 0;
458+
proto.ghz_5g = WIFI_PROTOCOL_11AC | WIFI_PROTOCOL_11A | WIFI_PROTOCOL_11AX;
459+
esp_wifi_set_protocols(ESP_IF_WIFI_AP, &proto);
460+
bws.ghz_5g = WIFI_BW_HT20;
461+
esp_wifi_set_bandwidths(ESP_IF_WIFI_AP, &bws);
462+
}
463+
#endif
464+
}
433465
if (strlen(pass) == 0) {
434466
g_ap_config.ap.authmode = WIFI_AUTH_OPEN;
435467
}
436468
g_ap_config.ap.channel = channel;
437469
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &g_ap_config));
438-
if (bw == 40) {
439-
esp_wifi_set_bandwidth(ESP_IF_WIFI_AP, WIFI_BW_HT40);
440-
} else {
441-
esp_wifi_set_bandwidth(ESP_IF_WIFI_AP, WIFI_BW_HT20);
442-
}
443470
ESP_LOGI(TAG_AP, "Starting SoftAP with FTM Responder support, SSID - %s, Password - %s, Primary Channel - %d, Bandwidth - %dMHz",
444471
ap_args.ssid->sval[0], ap_args.password->sval[0], channel, bw);
445472

0 commit comments

Comments
 (0)