Skip to content

Commit 2e75e88

Browse files
authored
bugfix: restore WiFi::setSleepMode functionality with sdk-2.2.x (esp8266#5919)
1 parent 7a2e935 commit 2e75e88

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,6 @@ int32_t ESP8266WiFiGenericClass::channel(void) {
249249
* @param type sleep_type_t
250250
* @return bool
251251
*/
252-
#ifndef NONOSDK3V0
253-
bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenInterval) {
254-
(void)type;
255-
(void)listenInterval;
256-
return false;
257-
}
258-
#else // defined(NONOSDK3V0)
259252
bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenInterval) {
260253

261254
/**
@@ -279,20 +272,24 @@ bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenI
279272
wifi_set_listen_interval():
280273
Set listen interval of maximum sleep level for modem sleep and light sleep
281274
It only works when sleep level is set as MAX_SLEEP_T
282-
It should be called following the order:
283-
wifi_set_sleep_level(MAX_SLEEP_T)
284-
wifi_set_listen_interval
285-
wifi_set_sleep_type
286275
forum: https://github.com/espressif/ESP8266_NONOS_SDK/issues/165#issuecomment-416121920
287276
default value seems to be 3 (as recommended by https://routerguide.net/dtim-interval-period-best-setting/)
277+
278+
call order:
279+
wifi_set_sleep_level(MAX_SLEEP_T) (SDK3)
280+
wifi_set_listen_interval (SDK3)
281+
wifi_set_sleep_type (all SDKs)
282+
288283
*/
289284

285+
#ifdef NONOSDK3V0
286+
290287
#ifdef DEBUG_ESP_WIFI
291288
if (listenInterval && type == WIFI_NONE_SLEEP)
292289
DEBUG_WIFI_GENERIC("listenInterval not usable with WIFI_NONE_SLEEP\n");
293290
#endif
294291

295-
if (type == WIFI_LIGHT_SLEEP || type == WIFI_MODEM_SLEEP) {
292+
if (type == WIFI_LIGHT_SLEEP || type == WIFI_MODEM_SLEEP) {
296293
if (listenInterval) {
297294
if (!wifi_set_sleep_level(MAX_SLEEP_T)) {
298295
DEBUG_WIFI_GENERIC("wifi_set_sleep_level(MAX_SLEEP_T): error\n");
@@ -316,13 +313,16 @@ bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenI
316313
}
317314
}
318315
}
316+
#else // !defined(NONOSDK3V0)
317+
(void)listenInterval;
318+
#endif // !defined(NONOSDK3V0)
319+
319320
bool ret = wifi_set_sleep_type((sleep_type_t) type);
320321
if (!ret) {
321322
DEBUG_WIFI_GENERIC("wifi_set_sleep_type(%d): error\n", (int)type);
322323
}
323324
return ret;
324325
}
325-
#endif // defined(NONOSDK3V0)
326326

327327
/**
328328
* get Sleep mode

0 commit comments

Comments
 (0)