Closed
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: Any
- Core Version: 7a2e935
- Development Env: Any
Problem Description
Current code ignores setSleepMode(...)
completely:
Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
Lines 252 to 258 in 7a2e935
Original change from #5763:
https://github.com/esp8266/Arduino/pull/5763/files#diff-0889054126fa6ecf0deea9d56f59e988
From PR and the related issue, I understood that light sleep mode is broken with SDK 2.x.x, but default MODEM
setting is sometimes detrimental too (a lot of disconnections with some APs, when RSSI is low) and needs to be changed to NONE instead.
MCVE Sketch
#include <Arduino.h>
#include <ESP8266WiFi.h>
const char* sleep_mode(WiFiSleepType_t type) {
switch (type) {
case WIFI_NONE_SLEEP: return "NONE";
case WIFI_LIGHT_SLEEP: return "LIGHT";
case WIFI_MODEM_SLEEP: return "MODEM";
default: return "UNKNOWN";
}
}
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(SSID, PSK);
Serial.println("connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
WiFi.setSleepMode(WIFI_NONE_SLEEP);
Serial.printf("Sleep mode: %s\n", sleep_mode(WiFi.getSleepMode()));
}
void loop() {
delay(10);
}
Debug Messages
SDK 2.2.x:
Sleep mode: MODEM
SDK pre3:
Sleep mode: NONE