From 34ba72a431332539b945e8405cbb429d75a119c9 Mon Sep 17 00:00:00 2001 From: yinqingzhao Date: Fri, 25 Oct 2024 19:33:55 +0800 Subject: [PATCH] feat(twt): twt add parameter to enable keep alive --- components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld | 2 +- components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld | 2 +- components/esp_wifi/include/esp_wifi_he_types.h | 1 + components/esp_wifi/lib | 2 +- examples/wifi/itwt/main/Kconfig.projbuild | 6 ++++++ examples/wifi/itwt/main/itwt_main.c | 12 ++++++++++++ 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld b/components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld index b63edf3cf5..dbe5ab1adf 100644 --- a/components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld +++ b/components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld @@ -112,7 +112,7 @@ pm_disable_sleep_delay_timer = 0x40000d50; /*pm_dream = 0x40000d54;*/ pm_mac_wakeup = 0x40000d58; pm_mac_sleep = 0x40000d5c; -pm_enable_active_timer = 0x40000d60; +/*pm_enable_active_timer = 0x40000d60;*/ pm_enable_sleep_delay_timer = 0x40000d64; pm_local_tsf_process = 0x40000d68; pm_set_beacon_filter = 0x40000d6c; diff --git a/components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld b/components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld index 6931333f9d..2bdc202eb7 100644 --- a/components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld +++ b/components/esp_rom/esp32c61/ld/esp32c61.rom.pp.ld @@ -113,7 +113,7 @@ pm_disable_sleep_delay_timer = 0x40000cbc; pm_dream = 0x40000cc0; pm_mac_wakeup = 0x40000cc4; pm_mac_sleep = 0x40000cc8; -pm_enable_active_timer = 0x40000ccc; +/*pm_enable_active_timer = 0x40000ccc;*/ pm_enable_sleep_delay_timer = 0x40000cd0; pm_local_tsf_process = 0x40000cd4; pm_set_beacon_filter = 0x40000cd8; diff --git a/components/esp_wifi/include/esp_wifi_he_types.h b/components/esp_wifi/include/esp_wifi_he_types.h index e9dc2e17a4..e2fe9c9f75 100644 --- a/components/esp_wifi/include/esp_wifi_he_types.h +++ b/components/esp_wifi/include/esp_wifi_he_types.h @@ -406,6 +406,7 @@ typedef enum { /** Argument structure for twt configuration */ typedef struct { bool post_wakeup_event; /**< post twt wakeup event */ + bool twt_enable_keep_alive; /**< twt enable send qos null to keep alive */ } wifi_twt_config_t; /** Argument structure for WIFI_EVENT_TWT_WAKEUP event */ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index a663beed1a..601124b36a 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit a663beed1a9ef3a316e8502268c14e053db108e1 +Subproject commit 601124b36a88ae0ab5b8538b0769cbf893e9d9f2 diff --git a/examples/wifi/itwt/main/Kconfig.projbuild b/examples/wifi/itwt/main/Kconfig.projbuild index 9eb0e46e7b..8d8dd52b2e 100644 --- a/examples/wifi/itwt/main/Kconfig.projbuild +++ b/examples/wifi/itwt/main/Kconfig.projbuild @@ -38,6 +38,12 @@ menu "Example Configuration" help Set static gateway address. + config EXAMPLE_TWT_ENABLE_KEEP_ALIVE_QOS_NULL + bool "enable keep alive qos null" + default n + help + Enable send QOS NULL to keep alive during TWT. + menu "iTWT Configuration" config EXAMPLE_ITWT_TRIGGER_ENABLE bool "trigger-enabled" diff --git a/examples/wifi/itwt/main/itwt_main.c b/examples/wifi/itwt/main/itwt_main.c index e2f4ecc771..c1e44d8eb2 100644 --- a/examples/wifi/itwt/main/itwt_main.c +++ b/examples/wifi/itwt/main/itwt_main.c @@ -49,6 +49,12 @@ static const char *TAG = "itwt"; #define DEFAULT_PWD CONFIG_EXAMPLE_WIFI_PASSWORD #define ITWT_SETUP_SUCCESS 1 +#if CONFIG_EXAMPLE_TWT_ENABLE_KEEP_ALIVE_QOS_NULL +bool keep_alive_enabled = true; +#else +bool keep_alive_enabled = false; +#endif + #if CONFIG_EXAMPLE_ITWT_TRIGGER_ENABLE uint8_t trigger_enabled = 1; #else @@ -264,6 +270,12 @@ static void wifi_itwt(void) ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config)); + wifi_twt_config_t wifi_twt_config = { + .post_wakeup_event = false, + .twt_enable_keep_alive = keep_alive_enabled, + }; + ESP_ERROR_CHECK(esp_wifi_sta_twt_config(&wifi_twt_config)); + esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT20); esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_11AX); esp_wifi_set_ps(WIFI_PS_MIN_MODEM);