Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_some_wifi_bugs_1030_v5.1' into 'release/v5.1'
Browse files Browse the repository at this point in the history
Bugfix/fix some wifi bugs 1030 v5.1(Backport v5.1)

See merge request espressif/esp-idf!34709
  • Loading branch information
Jiang Jiang Jian committed Nov 25, 2024
2 parents 07821e8 + 2a715e4 commit 024c6de
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
9 changes: 9 additions & 0 deletions components/esp_wifi/include/esp_wifi_he.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ esp_err_t esp_wifi_enable_rx_statistics(bool rx_stats, bool rx_mu_stats);
*/
esp_err_t esp_wifi_enable_tx_statistics(esp_wifi_aci_t aci, bool tx_stats);

/**
* @brief Set WiFi TWT config
*
* @param[in] config pointer to the WiFi TWT configure structure.
*
* @return
* - ESP_OK: succeed
*/
esp_err_t esp_wifi_sta_twt_config(wifi_twt_config_t *config);

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions components/esp_wifi/include/esp_wifi_he_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,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 */
Expand Down
6 changes: 6 additions & 0 deletions examples/wifi/itwt/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions examples/wifi/itwt/main/itwt.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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
Expand Down Expand Up @@ -259,6 +265,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);
Expand Down

0 comments on commit 024c6de

Please sign in to comment.