Skip to content

Commit 1604cef

Browse files
10086loutianhaoesp-lis
authored andcommitted
chanage(example/power_save): add wifi band (2.4 GHz and 5 GHz) menuconfig option for esp32c5
1 parent d63beec commit 1604cef

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

examples/wifi/power_save/main/Kconfig.projbuild

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ menu "Example Configuration"
3737
For Station, If the station does not receive a beacon frame from the connected SoftAP during the
3838
inactive time, disconnect from SoftAP. Default 6s.
3939

40+
choice EXAMPLE_WIFI_BAND_MODE
41+
prompt "wifi band"
42+
default EXAMPLE_WIFI_BAND_MODE_2G
43+
depends on SOC_WIFI_HE_SUPPORT_5G
44+
help
45+
WiFi band for the example to use.
46+
47+
config EXAMPLE_WIFI_BAND_MODE_2G
48+
bool "2G"
49+
config EXAMPLE_WIFI_BAND_MODE_5G
50+
bool "5G"
51+
config EXAMPLE_WIFI_BAND_MODE_AUTO
52+
bool "Auto"
53+
endchoice
54+
4055
choice EXAMPLE_POWER_SAVE_MODE
4156
prompt "power save mode"
4257
default EXAMPLE_POWER_SAVE_MIN_MODEM

examples/wifi/power_save/main/power_save.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@
3636
#define DEFAULT_PS_MODE WIFI_PS_NONE
3737
#endif /*CONFIG_POWER_SAVE_MODEM*/
3838

39+
#if SOC_WIFI_HE_SUPPORT_5G
40+
#if CONFIG_EXAMPLE_WIFI_BAND_MODE_2G
41+
#define DEFAULT_WIFI_BAND_MODE WIFI_BAND_MODE_2G_ONLY
42+
#elif CONFIG_EXAMPLE_WIFI_BAND_MODE_5G
43+
#define DEFAULT_WIFI_BAND_MODE WIFI_BAND_MODE_5G_ONLY
44+
#else
45+
#define DEFAULT_WIFI_BAND_MODE WIFI_BAND_MODE_AUTO
46+
#endif
47+
#endif
3948

4049
static const char *TAG = "power_save";
4150

@@ -80,6 +89,9 @@ static void wifi_power_save(void)
8089
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
8190
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
8291
ESP_ERROR_CHECK(esp_wifi_start());
92+
#if SOC_WIFI_HE_SUPPORT_5G
93+
ESP_ERROR_CHECK(esp_wifi_set_band_mode(DEFAULT_WIFI_BAND_MODE));
94+
#endif
8395
ESP_ERROR_CHECK(esp_wifi_set_inactive_time(WIFI_IF_STA, DEFAULT_BEACON_TIMEOUT));
8496

8597
ESP_LOGI(TAG, "esp_wifi_set_ps().");

0 commit comments

Comments
 (0)