Browse Source

Set wifi sleep mode from settings

rules-rpn
Max Prokhorov 5 years ago
parent
commit
3c1cfbfdbe
2 changed files with 18 additions and 2 deletions
  1. +14
    -0
      code/espurna/utils.ino
  2. +4
    -2
      code/espurna/wifi.ino

+ 14
- 0
code/espurna/utils.ino View File

@ -368,6 +368,15 @@ void infoMemory(const char * name, unsigned int total_memory, unsigned int free_
}
const char* _info_wifi_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";
}
}
void info() {
DEBUG_MSG_P(PSTR("\n\n---8<-------\n\n"));
@ -473,6 +482,11 @@ void info() {
DEBUG_MSG_P(PSTR("[MAIN] Power saving delay value: %lu ms\n"), systemLoopDelay());
}
const WiFiSleepType_t sleep_mode = WiFi.getSleepMode();
if (sleep_mode != WIFI_NONE_SLEEP) {
DEBUG_MSG_P(PSTR("[MAIN] WiFi Sleep Mode: %s\n"), _info_wifi_sleep_mode(sleep_mode));
}
// -------------------------------------------------------------------------
#if SYSTEM_CHECK_ENABLED


+ 4
- 2
code/espurna/wifi.ino View File

@ -75,6 +75,10 @@ void _wifiConfigure() {
jw.enableScan(getSetting("wifiScan", WIFI_SCAN_NETWORKS).toInt() == 1);
unsigned char sleep_mode = getSetting("wifiSleep", WIFI_SLEEP_MODE).toInt();
sleep_mode = constrain(sleep_mode, 0, 2);
WiFi.setSleepMode(static_cast<WiFiSleepType_t>(sleep_mode));
}
void _wifiScan(uint32_t client_id = 0) {
@ -603,8 +607,6 @@ void wifiRegister(wifi_callback_f callback) {
void wifiSetup() {
WiFi.setSleepMode(WIFI_SLEEP_MODE);
_wifiInject();
_wifiConfigure();


Loading…
Cancel
Save