Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set sleep mode to WIFI_NONE_SLEEP with SDK 2.2.1/2.2.x #5916

Closed
6 tasks done
mcspr opened this issue Mar 26, 2019 · 1 comment · Fixed by #5919
Closed
6 tasks done

Cannot set sleep mode to WIFI_NONE_SLEEP with SDK 2.2.1/2.2.x #5916

mcspr opened this issue Mar 26, 2019 · 1 comment · Fixed by #5919
Assignees

Comments

@mcspr
Copy link
Collaborator

mcspr commented Mar 26, 2019

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:

#ifndef NONOSDK3V0
bool ESP8266WiFiGenericClass::setSleepMode(WiFiSleepType_t type, uint8_t listenInterval) {
(void)type;
(void)listenInterval;
return false;
}
#else // defined(NONOSDK3V0)

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
@d-a-v
Copy link
Collaborator

d-a-v commented Mar 26, 2019

Ah thanks and shame on me.
I wanted to disable listenInterval that is specific to sdk-pre3 and I just disabled eveything...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants