diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld index e8d044953e..78c35f3715 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld @@ -1545,7 +1545,7 @@ pm_set_beacon_filter = 0x4000166c; pm_is_in_wifi_slice_threshold = 0x40001670; pm_is_waked = 0x40001674; pm_keep_alive = 0x40001678; -pm_on_beacon_rx = 0x4000167c; +/* pm_on_beacon_rx = 0x4000167c; */ pm_on_data_rx = 0x40001680; pm_on_tbtt = 0x40001684; pm_parse_beacon = 0x40001688; @@ -1554,7 +1554,7 @@ pm_process_tim = 0x4000168c; pm_rx_data_process = 0x40001694; /*pm_sleep = 0x40001698;*/ pm_sleep_for = 0x4000169c; -pm_tbtt_process = 0x400016a0; +/* pm_tbtt_process = 0x400016a0; */ ppAMPDU2Normal = 0x400016a4; ppAssembleAMPDU = 0x400016a8; ppCalFrameTimes = 0x400016ac; diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 54c4d29084..7955d202b2 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -322,6 +322,47 @@ menu "Wi-Fi" 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. + config ESP_WIFI_SLP_BEACON_LOST_OPT + bool "Wifi sleep optimize when beacon lost" + help + Enable wifi sleep optimization when beacon loss occurs and immediately enter + sleep mode when the WiFi module detects beacon loss. + + config ESP_WIFI_SLP_BEACON_LOST_TIMEOUT + int "Beacon loss timeout" + range 5 100 + default 10 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + help + Timeout time for close rf phy when beacon loss occurs, Unit: 1024 microsecond. + + config ESP_WIFI_SLP_BEACON_LOST_THRESHOLD + int "Maximum number of consecutive lost beacons allowed" + range 0 8 + default 3 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + help + Maximum number of consecutive lost beacons allowed, WiFi keeps Rx state when + the number of consecutive beacons lost is greater than the given threshold. + + config ESP_WIFI_SLP_PHY_ON_DELTA_EARLY_TIME + int "Delta early time for RF PHY on" + range 0 100 + default 2 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + 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. + + config ESP_WIFI_SLP_PHY_OFF_DELTA_TIMEOUT_TIME + int "Delta timeout time for RF PHY off" + range 0 8 + default 2 + depends on ESP_WIFI_SLP_BEACON_LOST_OPT + 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. + endmenu # Wi-Fi menu "PHY" diff --git a/components/esp_wifi/include/esp_private/wifi.h b/components/esp_wifi/include/esp_private/wifi.h index 3a15ffd7f2..7b2a7ef485 100644 --- a/components/esp_wifi/include/esp_private/wifi.h +++ b/components/esp_wifi/include/esp_private/wifi.h @@ -599,6 +599,15 @@ void esp_wifi_set_sleep_delay_time(uint32_t return_to_sleep_delay); */ 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 + */ +void esp_wifi_beacon_monitor_configure(bool enable, int timeout, int threshold, int delta_intr_early, int delta_timeout); + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index 337458fb7d..ea0f2563ee 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -347,7 +347,7 @@ esp_err_t esp_wifi_restore(void); * * @attention 1. This API only impact WIFI_MODE_STA or WIFI_MODE_APSTA mode * @attention 2. If the ESP32 is connected to an AP, call esp_wifi_disconnect to disconnect. - * @attention 3. The scanning triggered by esp_wifi_start_scan() will not be effective until connection between ESP32 and the AP is established. + * @attention 3. The scanning triggered by esp_wifi_scan_start() will not be effective until connection between ESP32 and the AP is established. * If ESP32 is scanning and connecting at the same time, ESP32 will abort scanning and return a warning message and error * number ESP_ERR_WIFI_STATE. * If you want to do reconnection after ESP32 received disconnect event, remember to add the maximum retry time, otherwise the called diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index c4cc374509..da6032fee5 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit c4cc374509d4f5b14ec3b7b84ec22ef659072b36 +Subproject commit da6032fee54e77c39da04a2e975bc974c86a58f6 diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index f8a16d5094..c7ffcc55b5 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -123,6 +123,10 @@ esp_err_t esp_wifi_deinit(void) #if CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER tcpip_adapter_clear_default_wifi_handlers(); #endif +#if CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT + esp_wifi_beacon_monitor_configure(false, 0, 0, 0, 0); +#endif + #if CONFIG_ESP_WIFI_SLP_IRAM_OPT esp_pm_unregister_light_sleep_default_params_config_callback(); #endif @@ -280,6 +284,11 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config) return result; } } +#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); +#endif adc2_cal_include(); //This enables the ADC2 calibration constructor at start up. esp_wifi_config_info();