From ced4d5e0a15e0d4a259dd2a627ed92ea7ef8354b Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Tue, 1 Sep 2020 17:20:16 +0800 Subject: [PATCH] feat(esp8266): support 64bit sleep time for esp_deep_sleep --- components/esp8266/include/esp_sleep.h | 2 +- components/esp8266/include/esp_wifi.h | 33 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/components/esp8266/include/esp_sleep.h b/components/esp8266/include/esp_sleep.h index b9d54a56..fbc2206d 100644 --- a/components/esp8266/include/esp_sleep.h +++ b/components/esp8266/include/esp_sleep.h @@ -65,7 +65,7 @@ typedef enum { * * @return null */ -void esp_deep_sleep(uint32_t time_in_us); +void esp_deep_sleep(uint64_t time_in_us); /** * @brief Set implementation-specific power management configuration diff --git a/components/esp8266/include/esp_wifi.h b/components/esp8266/include/esp_wifi.h index 0aaaf49c..9344a1c7 100644 --- a/components/esp8266/include/esp_wifi.h +++ b/components/esp8266/include/esp_wifi.h @@ -1019,6 +1019,39 @@ esp_err_t esp_wifi_set_rssi_threshold(int32_t rssi); */ int64_t esp_wifi_get_tsf_time(wifi_interface_t interface); +/** + * @brief Set the inactive time of the ESP32 STA or AP + * + * @attention 1. For Station, If the station does not receive a beacon frame from the connected SoftAP during the inactive time, + * disconnect from SoftAP. Default 6s. + * @attention 2. For SoftAP, If the softAP doesn't receive any data from the connected STA during inactive time, + * the softAP will force deauth the STA. Default is 300s. + * @attention 3. The inactive time configuration is not stored into flash + * + * @param ifx interface to be configured. + * @param sec Inactive time. Unit seconds. + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init + * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start + * - ESP_ERR_WIFI_ARG: invalid argument, For Station, if sec is less than 3. For SoftAP, if sec is less than 10. + */ +esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec); + +/** + * @brief Get inactive time of specified interface + * + * @param ifx Interface to be configured. + * @param sec Inactive time. Unit seconds. + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init + * - ESP_ERR_WIFI_ARG: invalid argument + */ +esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec); + #ifdef __cplusplus } #endif