1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

bugfix: restore WiFi::setSleepMode functionality with sdk-2.2.x (#5919)

This commit is contained in:
david gauchard 2019-03-26 14:07:49 +01:00 committed by GitHub
parent 7a2e935f53
commit 2e75e88c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -249,13 +249,6 @@ int32_t ESP8266WiFiGenericClass::channel(void) {
* @param type sleep_type_t * @param type sleep_type_t
* @return bool * @return bool
*/ */
#ifndef NONOSDK3V0
bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenInterval) {
(void)type;
(void)listenInterval;
return false;
}
#else // defined(NONOSDK3V0)
bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenInterval) { bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenInterval) {
/** /**
@ -279,14 +272,18 @@ bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenI
wifi_set_listen_interval(): wifi_set_listen_interval():
Set listen interval of maximum sleep level for modem sleep and light sleep Set listen interval of maximum sleep level for modem sleep and light sleep
It only works when sleep level is set as MAX_SLEEP_T It only works when sleep level is set as MAX_SLEEP_T
It should be called following the order:
wifi_set_sleep_level(MAX_SLEEP_T)
wifi_set_listen_interval
wifi_set_sleep_type
forum: https://github.com/espressif/ESP8266_NONOS_SDK/issues/165#issuecomment-416121920 forum: https://github.com/espressif/ESP8266_NONOS_SDK/issues/165#issuecomment-416121920
default value seems to be 3 (as recommended by https://routerguide.net/dtim-interval-period-best-setting/) default value seems to be 3 (as recommended by https://routerguide.net/dtim-interval-period-best-setting/)
call order:
wifi_set_sleep_level(MAX_SLEEP_T) (SDK3)
wifi_set_listen_interval (SDK3)
wifi_set_sleep_type (all SDKs)
*/ */
#ifdef NONOSDK3V0
#ifdef DEBUG_ESP_WIFI #ifdef DEBUG_ESP_WIFI
if (listenInterval && type == WIFI_NONE_SLEEP) if (listenInterval && type == WIFI_NONE_SLEEP)
DEBUG_WIFI_GENERIC("listenInterval not usable with WIFI_NONE_SLEEP\n"); DEBUG_WIFI_GENERIC("listenInterval not usable with WIFI_NONE_SLEEP\n");
@ -316,13 +313,16 @@ bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenI
} }
} }
} }
#else // !defined(NONOSDK3V0)
(void)listenInterval;
#endif // !defined(NONOSDK3V0)
bool ret = wifi_set_sleep_type((sleep_type_t) type); bool ret = wifi_set_sleep_type((sleep_type_t) type);
if (!ret) { if (!ret) {
DEBUG_WIFI_GENERIC("wifi_set_sleep_type(%d): error\n", (int)type); DEBUG_WIFI_GENERIC("wifi_set_sleep_type(%d): error\n", (int)type);
} }
return ret; return ret;
} }
#endif // defined(NONOSDK3V0)
/** /**
* get Sleep mode * get Sleep mode