Skip to content

Commit

Permalink
Add wifi sleep toggle (implements Aircoookie#672 )
Browse files Browse the repository at this point in the history
  • Loading branch information
Aircoookie committed Feb 20, 2020
1 parent 9dbd1b2 commit c1a8fde
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 10 deletions.
16 changes: 8 additions & 8 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ build_flags =
lib_deps =
${common.lib_deps_external}
lib_compat_mode = strict
lib_ignore = AsynTCP
lib_ignore = AsyncTCP

[env:d1_mini]
board = d1_mini
Expand All @@ -143,7 +143,7 @@ build_flags =
lib_deps =
${common.lib_deps_external}
lib_compat_mode = strict
lib_ignore = AsynTCP
lib_ignore = AsyncTCP

[env:esp01_1m]
board = esp01_1m
Expand All @@ -159,7 +159,7 @@ build_flags =
lib_deps =
${common.lib_deps_external}
lib_compat_mode = strict
lib_ignore = AsynTCP
lib_ignore = AsyncTCP

[env:esp01]
board = esp01
Expand All @@ -174,7 +174,7 @@ build_flags =
lib_deps =
${common.lib_deps_external}
lib_compat_mode = strict
lib_ignore = AsynTCP
lib_ignore = AsyncTCP

[env:esp07]
board = esp07
Expand All @@ -188,7 +188,7 @@ build_flags =
lib_deps =
${common.lib_deps_external}
lib_compat_mode = strict
lib_ignore = AsynTCP
lib_ignore = AsyncTCP

# see: http://docs.platformio.org/en/latest/platforms/espressif32.html
[env:esp32dev]
Expand Down Expand Up @@ -220,7 +220,7 @@ build_flags =
lib_deps =
${common.lib_deps_external}
lib_compat_mode = strict
lib_ignore = AsynTCP
lib_ignore = AsyncTCP

[env:esp8285_4CH_H801]
board = esp8285
Expand All @@ -237,7 +237,7 @@ build_flags =
lib_deps =
${common.lib_deps_external}
lib_compat_mode = strict
lib_ignore = AsynTCP
lib_ignore = AsyncTCP

[env:esp8285_5CH_H801]
board = esp8285
Expand All @@ -255,5 +255,5 @@ build_flags =
lib_deps =
${common.lib_deps_external}
lib_compat_mode = strict
lib_ignore = AsynTCP
lib_ignore = AsyncTCP

7 changes: 6 additions & 1 deletion wled00/html_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ AP opens:
<option value="1">Disconnected</option>
<option value="2">Always</option>
<option value="3">Never (not recommended)</option></select><br>
AP IP: <span class="sip"> Not active </span><hr>
AP IP: <span class="sip"> Not active </span><br>
<h3>Experimental</h3>
Disable WiFi sleep: <input type="checkbox" name="WS"><br>
<i>Can help with connectivity issues.<br>
Do not enable if WiFi is working correctly, increases power consumption.</i>
<hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Connect</button>
</form>
</body>
Expand Down
5 changes: 5 additions & 0 deletions wled00/wled00.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ESPAsyncTCP.h>
extern "C" {
#include <user_interface.h>
}
#else
#include <WiFi.h>
#include "esp_wifi.h"
Expand Down Expand Up @@ -120,6 +123,8 @@ byte apBehavior = AP_BEHAVIOR_BOOT_NO_CONN; //access point opens when no conne
IPAddress staticIP(0, 0, 0, 0); //static IP of ESP
IPAddress staticGateway(0, 0, 0, 0); //gateway (router) IP
IPAddress staticSubnet(255, 255, 255, 0); //most common subnet in home networks
bool noWifiSleep = false; //disabling modem sleep modes will increase heat output and power usage, but may help with connection issues


//LED CONFIG
uint16_t ledCount = 30; //overcurrent prevented by ABL
Expand Down
10 changes: 9 additions & 1 deletion wled00/wled01_eeprom.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define EEPSIZE 2560

//eeprom Version code, enables default settings instead of 0 init on update
#define EEPVER 15
#define EEPVER 16
//0 -> old version, default
//1 -> 0.4p 1711272 and up
//2 -> 0.4p 1711302 and up
Expand All @@ -23,6 +23,7 @@
//13-> 0.9.0-dev
//14-> 0.9.0-b1
//15-> 0.9.0-b3
//16-> 0.9.1

void commit()
{
Expand Down Expand Up @@ -131,6 +132,8 @@ void saveSettingsToEEPROM()
EEPROM.write(368, abs(arlsOffset));
EEPROM.write(369, turnOnAtBoot);

EEPROM.write(370, noWifiSleep);

EEPROM.write(372, useRGBW);
EEPROM.write(374, strip.paletteFade);
EEPROM.write(375, strip.milliampsPerLed); //was apWaitTimeSecs up to 0.8.5
Expand Down Expand Up @@ -484,6 +487,11 @@ void loadSettingsFromEEPROM(bool first)
DMXMode = DMX_MODE_MULTIPLE_RGB;
}

//if (lastEEPROMversion > 15)
//{
noWifiSleep = EEPROM.read(370);
//}


receiveDirect = !EEPROM.read(2200);
notifyMacro = EEPROM.read(2201);
Expand Down
2 changes: 2 additions & 0 deletions wled00/wled02_xml.ino
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ void getSettingsJS(byte subPage, char* dest)
sappends('s',"AP",fapass);

sappend('v',"AC",apChannel);
sappend('c',"WS",noWifiSleep);


if (WiFi.localIP()[0] != 0) //is connected
{
Expand Down
2 changes: 2 additions & 0 deletions wled00/wled03_set.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (passlen == 0 || (passlen > 7 && !isAsterisksOnly(request->arg("AP").c_str(), 65))) strlcpy(apPass, request->arg("AP").c_str(), 65);
int t = request->arg("AC").toInt(); if (t > 0 && t < 14) apChannel = t;

noWifiSleep = request->hasArg("WS");

char k[3]; k[2] = 0;
for (int i = 0; i<4; i++)
{
Expand Down
5 changes: 5 additions & 0 deletions wled00/wled05_init.ino
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,14 @@ void initConnection()
#ifdef ESP8266
WiFi.hostname(serverDescription);
#endif

WiFi.begin(clientSSID, clientPass);

#ifdef ARDUINO_ARCH_ESP32
if (noWifiSleep) WiFi.setSleep(false);
WiFi.setHostname(serverDescription);
#else
if (noWifiSleep) wifi_set_sleep_type(NONE_SLEEP_T);
#endif
}

Expand Down
1 change: 1 addition & 0 deletions wled00/wled17_mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ bool initMqtt()
strcpy(mqttStatusTopic, mqttDeviceTopic);
strcat(mqttStatusTopic, "/status");
mqtt->setWill(mqttStatusTopic, 0, true, "offline");
mqtt->setKeepAlive(60);
mqtt->connect();
return true;
}
Expand Down

0 comments on commit c1a8fde

Please sign in to comment.