diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 6fd5846eff..466389df67 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -386,6 +386,12 @@ menu "Wi-Fi" default y depends on (IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3) + config ESP_WIFI_STA_DISCONNECTED_PM_ENABLE + bool "Power Management for station at disconnected" + help + Select this option to enable power_management for station when disconnected. + Chip will do modem-sleep when rf module is not in use any more. + endmenu # Wi-Fi menu "PHY" diff --git a/components/esp_wifi/include/esp_now.h b/components/esp_wifi/include/esp_now.h index 2f20c5d392..de41a87936 100644 --- a/components/esp_wifi/include/esp_now.h +++ b/components/esp_wifi/include/esp_now.h @@ -302,6 +302,23 @@ esp_err_t esp_now_get_peer_num(esp_now_peer_num_t *num); */ esp_err_t esp_now_set_pmk(const uint8_t *pmk); +/** + * @brief Set esp_now wake window for sta_disconnected power management + * + * @param window how much microsecond would the chip keep waked each interval, vary from 0 to 65535 + * + * @attention 1. Only when ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work + * @attention 2. This configuration only work for station mode and disconnected status + * @attention 3. If more than one module has configured its wake_window, chip would choose the largest one to stay waked + * @attention 4. If the gap between interval and window is smaller than 5ms, the chip would keep waked all the time + * @attention 5. If never configured wake_window, the chip would keep waked at disconnected once it uses esp_now + * + * @return + * - ESP_OK : succeed + * - ESP_ERR_ESPNOW_NOT_INIT : ESPNOW is not initialized + */ +esp_err_t esp_now_set_wake_window(uint16_t window); + /** * @} */ diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 87303ddc48..86dcf637e4 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -115,6 +115,7 @@ typedef struct { int beacon_max_len; /**< WiFi softAP maximum length of the beacon */ int mgmt_sbuf_num; /**< WiFi management short buffer number, the minimum value is 6, the maximum value is 32 */ uint64_t feature_caps; /**< Enables additional WiFi features and capabilities */ + bool sta_disconnected_pm; /**< WiFi Power Management for station at disconnected status */ int magic; /**< WiFi init magic number, it should be the last field */ } wifi_init_config_t; @@ -201,6 +202,12 @@ extern uint64_t g_wifi_feature_caps; #define WIFI_MGMT_SBUF_NUM 32 #endif +#if CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE +#define WIFI_STA_DISCONNECTED_PM_ENABLED true +#else +#define WIFI_STA_DISCONNECTED_PM_ENABLED false +#endif + #define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0) #define CONFIG_FEATURE_CACHE_TX_BUF_BIT (1<<1) #define CONFIG_FEATURE_FTM_INITIATOR_BIT (1<<2) @@ -227,6 +234,7 @@ extern uint64_t g_wifi_feature_caps; .beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN, \ .mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, \ .feature_caps = g_wifi_feature_caps, \ + .sta_disconnected_pm = WIFI_STA_DISCONNECTED_PM_ENABLED, \ .magic = WIFI_INIT_CONFIG_MAGIC\ }; @@ -1198,6 +1206,18 @@ esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable); */ esp_err_t esp_wifi_config_espnow_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +/** + * @brief Set interval for station to wake up periodically at disconnected. + * + * @attention 1. Only when ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work + * @attention 2. This configuration only work for station mode and disconnected status + * @attention 3. This configuration would influence nothing until some module configure wake_window + * @attention 4. A sensible interval which is not too small is recommended (e.g. 100ms) + * + * @param interval how much micriosecond would the chip wake up, from 1 to 65535. + */ +esp_err_t esp_wifi_set_connectionless_wake_interval(uint16_t interval); + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 536393a4a9..8f951ea341 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 536393a4a91afc1f03714c677aac6befbfef4dfd +Subproject commit 8f951ea341721767731e18a260847f6306fc68b7