diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index d8eb6b97fd..61988a83c3 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -338,10 +338,10 @@ menu "Wi-Fi" help WiFi module can be compiled without SoftAP to save code size. - config ESP_WIFI_AUTO_BEACON_ENABLE + config ESP_WIFI_ENHANCED_LIGHT_SLEEP bool "WiFi modem automatically receives the beacon" default n - depends on ESP_PHY_MAC_BB_PD + depends on ESP_PHY_MAC_BB_PD && SOC_PM_SUPPORT_BEACON_WAKEUP help The wifi modem automatically receives the beacon frame during light sleep. @@ -372,7 +372,7 @@ menu "Wi-Fi" int "Delta early time for RF PHY on" range 0 100 default 2 - depends on ESP_WIFI_SLP_BEACON_LOST_OPT + depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW help Delta early time for rf phy on, When the beacon is lost, the next rf phy on will be earlier the time specified by the configuration item, Unit: 32 microsecond. @@ -381,7 +381,7 @@ menu "Wi-Fi" int "Delta timeout time for RF PHY off" range 0 8 default 2 - depends on ESP_WIFI_SLP_BEACON_LOST_OPT + depends on ESP_WIFI_SLP_BEACON_LOST_OPT && SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW help Delta timeout time for rf phy off, When the beacon is lost, the next rf phy off will be delayed for the time specified by the configuration item. Unit: 1024 microsecond. diff --git a/components/esp_wifi/include/esp_private/wifi.h b/components/esp_wifi/include/esp_private/wifi.h index 28f1b846ea..90edc7e3b3 100644 --- a/components/esp_wifi/include/esp_private/wifi.h +++ b/components/esp_wifi/include/esp_private/wifi.h @@ -624,11 +624,9 @@ void esp_wifi_set_keep_alive_time(uint32_t keep_alive_time); /** * @brief Configure wifi beacon montior default parameters * - * @param enable: enable or disable beacon monitor - * @param timeout: timeout time for close rf phy when beacon loss occurs, Unit: 1024 microsecond - * @param threshold: maximum number of consecutive lost beacons allowed + * @param config: the configuration parameters for wifi beacon monitor */ -void esp_wifi_beacon_monitor_configure(bool enable, int timeout, int threshold, int delta_intr_early, int delta_timeout); +void esp_wifi_beacon_monitor_configure(wifi_beacon_monitor_config_t *config); /** * @brief Require WiFi to enable or disable Advanced DTIM sleep function diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index d2732c9a73..8784730fe7 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -891,6 +891,23 @@ typedef struct { uint8_t peer_macaddr[6]; /**< Enrollee mac address */ } wifi_event_ap_wps_rg_success_t; +/** WiFi beacon monitor parameter configuration */ +typedef struct { + bool enable; /**< Enable or disable beacon monitor */ + uint8_t loss_timeout; /**< Beacon lost timeout */ + uint8_t loss_threshold; /**< Maximum number of consecutive lost beacons allowed */ + uint8_t delta_intr_early; /**< Delta early time for RF PHY on */ + uint8_t delta_loss_timeout; /**< Delta timeout time for RF PHY off */ +#if MAC_SUPPORT_PMU_MODEM_STATE + uint8_t beacon_abort: 1, /**< Enable or disable beacon abort */ + broadcast_wakeup: 1, /**< Enable or disable TIM element multicast wakeup */ + reserved: 6; /**< Reserved */ + uint8_t tsf_time_sync_deviation; /**< Deviation range to sync with AP TSF timestamp */ + uint16_t modem_state_consecutive; /**< PMU MODEM state consecutive count limit */ + uint16_t rf_ctrl_wait_cycle; /**< RF on wait time (unit: Modem APB clock cycle) */ +#endif +} wifi_beacon_monitor_config_t; + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index d43d71643d..3118f7384c 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -56,6 +56,28 @@ uint64_t g_wifi_feature_caps = #endif 0; +#if SOC_PM_SUPPORT_PMU_MODEM_STATE +# define WIFI_BEACON_MONITOR_CONFIG_DEFAULT(ena) { \ + .enable = (ena), \ + .loss_timeout = CONFIG_ESP_WIFI_SLP_BEACON_LOST_TIMEOUT, \ + .loss_threshold = CONFIG_ESP_WIFI_SLP_BEACON_LOST_THRESHOLD, \ + .delta_intr_early = 0, \ + .delta_loss_timeout = 0, \ + .beacon_abort = 1, \ + .broadcast_wakeup = 1, \ + .tsf_time_sync_deviation = 5, \ + .modem_state_consecutive = 10, \ + .rf_ctrl_wait_cycle = 20 \ +} +#else +# define WIFI_BEACON_MONITOR_CONFIG_DEFAULT(ena) { \ + .enable = (ena), \ + .loss_timeout = CONFIG_ESP_WIFI_SLP_BEACON_LOST_TIMEOUT, \ + .loss_threshold = CONFIG_ESP_WIFI_SLP_BEACON_LOST_THRESHOLD, \ + .delta_intr_early = CONFIG_ESP_WIFI_SLP_PHY_ON_DELTA_EARLY_TIME, \ + .delta_loss_timeout = CONFIG_ESP_WIFI_SLP_PHY_OFF_DELTA_TIMEOUT_TIME \ +} +#endif static const char* TAG = "wifi_init"; @@ -113,7 +135,8 @@ esp_err_t esp_wifi_deinit(void) } #if CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT - esp_wifi_beacon_monitor_configure(false, 0, 0, 0, 0); + wifi_beacon_monitor_config_t monitor_config = WIFI_BEACON_MONITOR_CONFIG_DEFAULT(false); + esp_wifi_beacon_monitor_configure(&monitor_config); #endif #if CONFIG_ESP_WIFI_SLP_IRAM_OPT @@ -124,7 +147,7 @@ esp_err_t esp_wifi_deinit(void) esp_pm_unregister_skip_light_sleep_callback(esp_wifi_internal_is_tsf_active); esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_wifi_internal_update_light_sleep_wake_ahead_time); esp_sleep_disable_wifi_wakeup(); -# if CONFIG_ESP_WIFI_AUTO_BEACON_ENABLE +# if CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP esp_sleep_disable_wifi_beacon_wakeup(); # endif #endif /* SOC_WIFI_HW_TSF */ @@ -240,7 +263,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config) return ret; } esp_sleep_enable_wifi_wakeup(); -# if CONFIG_ESP_WIFI_AUTO_BEACON_ENABLE +# if CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP esp_sleep_enable_wifi_beacon_wakeup(); # endif #if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE @@ -276,9 +299,8 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config) } } #if CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT - esp_wifi_beacon_monitor_configure(true, CONFIG_ESP_WIFI_SLP_BEACON_LOST_TIMEOUT, - CONFIG_ESP_WIFI_SLP_BEACON_LOST_THRESHOLD, CONFIG_ESP_WIFI_SLP_PHY_ON_DELTA_EARLY_TIME, - CONFIG_ESP_WIFI_SLP_PHY_OFF_DELTA_TIMEOUT_TIME); + wifi_beacon_monitor_config_t monitor_config = WIFI_BEACON_MONITOR_CONFIG_DEFAULT(true); + esp_wifi_beacon_monitor_configure(&monitor_config); #endif adc2_cal_include(); //This enables the ADC2 calibration constructor at start up. diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index c98258058c..ee2cd1e40b 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -457,6 +457,9 @@ #define SOC_PM_SUPPORT_MAC_BB_PD (1) #define SOC_PM_SUPPORT_PMU_MODEM_STATE (1) +/* macro redefine for pass esp_wifi headers md5sum check */ +#define MAC_SUPPORT_PMU_MODEM_STATE SOC_PM_SUPPORT_PMU_MODEM_STATE + #define SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY (1) /*!