Add wifi sleep toggle (implements #672 )
This commit is contained in:
parent
9dbd1b2a1b
commit
c1a8fde9a0
@ -129,7 +129,7 @@ build_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_ignore = AsynTCP
|
lib_ignore = AsyncTCP
|
||||||
|
|
||||||
[env:d1_mini]
|
[env:d1_mini]
|
||||||
board = d1_mini
|
board = d1_mini
|
||||||
@ -143,7 +143,7 @@ build_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_ignore = AsynTCP
|
lib_ignore = AsyncTCP
|
||||||
|
|
||||||
[env:esp01_1m]
|
[env:esp01_1m]
|
||||||
board = esp01_1m
|
board = esp01_1m
|
||||||
@ -159,7 +159,7 @@ build_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_ignore = AsynTCP
|
lib_ignore = AsyncTCP
|
||||||
|
|
||||||
[env:esp01]
|
[env:esp01]
|
||||||
board = esp01
|
board = esp01
|
||||||
@ -174,7 +174,7 @@ build_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_ignore = AsynTCP
|
lib_ignore = AsyncTCP
|
||||||
|
|
||||||
[env:esp07]
|
[env:esp07]
|
||||||
board = esp07
|
board = esp07
|
||||||
@ -188,7 +188,7 @@ build_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_ignore = AsynTCP
|
lib_ignore = AsyncTCP
|
||||||
|
|
||||||
# see: http://docs.platformio.org/en/latest/platforms/espressif32.html
|
# see: http://docs.platformio.org/en/latest/platforms/espressif32.html
|
||||||
[env:esp32dev]
|
[env:esp32dev]
|
||||||
@ -220,7 +220,7 @@ build_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_ignore = AsynTCP
|
lib_ignore = AsyncTCP
|
||||||
|
|
||||||
[env:esp8285_4CH_H801]
|
[env:esp8285_4CH_H801]
|
||||||
board = esp8285
|
board = esp8285
|
||||||
@ -237,7 +237,7 @@ build_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_ignore = AsynTCP
|
lib_ignore = AsyncTCP
|
||||||
|
|
||||||
[env:esp8285_5CH_H801]
|
[env:esp8285_5CH_H801]
|
||||||
board = esp8285
|
board = esp8285
|
||||||
@ -255,5 +255,5 @@ build_flags =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
lib_ignore = AsynTCP
|
lib_ignore = AsyncTCP
|
||||||
|
|
||||||
|
@ -62,7 +62,12 @@ AP opens:
|
|||||||
<option value="1">Disconnected</option>
|
<option value="1">Disconnected</option>
|
||||||
<option value="2">Always</option>
|
<option value="2">Always</option>
|
||||||
<option value="3">Never (not recommended)</option></select><br>
|
<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>
|
<button type="button" onclick="B()">Back</button><button type="submit">Save & Connect</button>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
@ -38,6 +38,9 @@
|
|||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#include <ESPAsyncTCP.h>
|
#include <ESPAsyncTCP.h>
|
||||||
|
extern "C" {
|
||||||
|
#include <user_interface.h>
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
@ -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 staticIP(0, 0, 0, 0); //static IP of ESP
|
||||||
IPAddress staticGateway(0, 0, 0, 0); //gateway (router) IP
|
IPAddress staticGateway(0, 0, 0, 0); //gateway (router) IP
|
||||||
IPAddress staticSubnet(255, 255, 255, 0); //most common subnet in home networks
|
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
|
//LED CONFIG
|
||||||
uint16_t ledCount = 30; //overcurrent prevented by ABL
|
uint16_t ledCount = 30; //overcurrent prevented by ABL
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define EEPSIZE 2560
|
#define EEPSIZE 2560
|
||||||
|
|
||||||
//eeprom Version code, enables default settings instead of 0 init on update
|
//eeprom Version code, enables default settings instead of 0 init on update
|
||||||
#define EEPVER 15
|
#define EEPVER 16
|
||||||
//0 -> old version, default
|
//0 -> old version, default
|
||||||
//1 -> 0.4p 1711272 and up
|
//1 -> 0.4p 1711272 and up
|
||||||
//2 -> 0.4p 1711302 and up
|
//2 -> 0.4p 1711302 and up
|
||||||
@ -23,6 +23,7 @@
|
|||||||
//13-> 0.9.0-dev
|
//13-> 0.9.0-dev
|
||||||
//14-> 0.9.0-b1
|
//14-> 0.9.0-b1
|
||||||
//15-> 0.9.0-b3
|
//15-> 0.9.0-b3
|
||||||
|
//16-> 0.9.1
|
||||||
|
|
||||||
void commit()
|
void commit()
|
||||||
{
|
{
|
||||||
@ -131,6 +132,8 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(368, abs(arlsOffset));
|
EEPROM.write(368, abs(arlsOffset));
|
||||||
EEPROM.write(369, turnOnAtBoot);
|
EEPROM.write(369, turnOnAtBoot);
|
||||||
|
|
||||||
|
EEPROM.write(370, noWifiSleep);
|
||||||
|
|
||||||
EEPROM.write(372, useRGBW);
|
EEPROM.write(372, useRGBW);
|
||||||
EEPROM.write(374, strip.paletteFade);
|
EEPROM.write(374, strip.paletteFade);
|
||||||
EEPROM.write(375, strip.milliampsPerLed); //was apWaitTimeSecs up to 0.8.5
|
EEPROM.write(375, strip.milliampsPerLed); //was apWaitTimeSecs up to 0.8.5
|
||||||
@ -484,6 +487,11 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
DMXMode = DMX_MODE_MULTIPLE_RGB;
|
DMXMode = DMX_MODE_MULTIPLE_RGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (lastEEPROMversion > 15)
|
||||||
|
//{
|
||||||
|
noWifiSleep = EEPROM.read(370);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
receiveDirect = !EEPROM.read(2200);
|
receiveDirect = !EEPROM.read(2200);
|
||||||
notifyMacro = EEPROM.read(2201);
|
notifyMacro = EEPROM.read(2201);
|
||||||
|
@ -194,6 +194,8 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
sappends('s',"AP",fapass);
|
sappends('s',"AP",fapass);
|
||||||
|
|
||||||
sappend('v',"AC",apChannel);
|
sappend('v',"AC",apChannel);
|
||||||
|
sappend('c',"WS",noWifiSleep);
|
||||||
|
|
||||||
|
|
||||||
if (WiFi.localIP()[0] != 0) //is connected
|
if (WiFi.localIP()[0] != 0) //is connected
|
||||||
{
|
{
|
||||||
|
@ -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);
|
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;
|
int t = request->arg("AC").toInt(); if (t > 0 && t < 14) apChannel = t;
|
||||||
|
|
||||||
|
noWifiSleep = request->hasArg("WS");
|
||||||
|
|
||||||
char k[3]; k[2] = 0;
|
char k[3]; k[2] = 0;
|
||||||
for (int i = 0; i<4; i++)
|
for (int i = 0; i<4; i++)
|
||||||
{
|
{
|
||||||
|
@ -190,9 +190,14 @@ void initConnection()
|
|||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
WiFi.hostname(serverDescription);
|
WiFi.hostname(serverDescription);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WiFi.begin(clientSSID, clientPass);
|
WiFi.begin(clientSSID, clientPass);
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
if (noWifiSleep) WiFi.setSleep(false);
|
||||||
WiFi.setHostname(serverDescription);
|
WiFi.setHostname(serverDescription);
|
||||||
|
#else
|
||||||
|
if (noWifiSleep) wifi_set_sleep_type(NONE_SLEEP_T);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ bool initMqtt()
|
|||||||
strcpy(mqttStatusTopic, mqttDeviceTopic);
|
strcpy(mqttStatusTopic, mqttDeviceTopic);
|
||||||
strcat(mqttStatusTopic, "/status");
|
strcat(mqttStatusTopic, "/status");
|
||||||
mqtt->setWill(mqttStatusTopic, 0, true, "offline");
|
mqtt->setWill(mqttStatusTopic, 0, true, "offline");
|
||||||
|
mqtt->setKeepAlive(60);
|
||||||
mqtt->connect();
|
mqtt->connect();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user