diff --git a/wled00/html_other.h b/wled00/html_other.h index b929db4d3..5de0598f0 100644 --- a/wled00/html_other.h +++ b/wled00/html_other.h @@ -20,7 +20,7 @@ const char PAGE_msg[] PROGMEM = R"=====( const char PAGE_update[] PROGMEM = R"=====( WLED Update %CSS%.bt{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%%} -

WLED Software Update

Installed version: 0.8.5
Download the latest binary:

)====="; +

WLED Software Update

Installed version: 0.8.6
Download the latest binary:

)====="; //new user welcome page diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 13dd0b489..43a913c41 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -28,7 +28,7 @@ const char PAGE_settings_wifi[] PROGMEM = R"=====( %CSS%%SCSS%
-
+

WiFi setup

Connect to existing network

Network name (SSID, empty to not connect):

@@ -50,15 +50,20 @@ Static subnet mask:

mDNS address (leave empty for no mDNS):
http:// .local
-Try connecting before opening AP for: s
Client IP: Not connected

Configure Access Point

AP SSID (leave empty for no AP):

Hide AP name:
AP password (leave empty for open):

Access Point WiFi channel:
+AP opens: +
AP IP: Not active
- +
)====="; @@ -390,9 +395,6 @@ The password should be changed when OTA is enabled.
Disable OTA when not in use, otherwise an attacker can reflash device software!
Settings on this page are only changable if OTA lock is disabled!
Deny access to WiFi settings if locked:

-Disable recovery AP:
-In case of an error there will be no wireless recovery possible!
-Completely disables all Access Point functions.

Factory reset:
All EEPROM content (settings) will be erased.

HTTP traffic is unencrypted. An attacker in the same network can intercept form data! @@ -400,7 +402,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
Enable ArduinoOTA:

About

-WLED version 0.8.5

+WLED version 0.8.6

Contributors, dependencies and special thanks
A huge thank you to everyone who helped me create WLED!

(c) 2016-2019 Christian Schwinne
diff --git a/wled00/wled00.ino b/wled00/wled00.ino index fda198663..a08801f5c 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -3,7 +3,7 @@ */ /* * @title WLED project sketch - * @version 0.8.5-dev + * @version 0.8.6 * @author Christian Schwinne */ @@ -30,7 +30,7 @@ //#define WLED_ENABLE_FS_EDITOR //enable /edit page for editing SPIFFS content. Will also be disabled with OTA lock //to toggle usb serial debug (un)comment the following line -#define WLED_DEBUG +//#define WLED_DEBUG //library inclusions @@ -99,8 +99,8 @@ //version code in format yymmddb (b = daily build) -#define VERSION 1910201 -char versionString[] = "0.8.5"; +#define VERSION 1910251 +char versionString[] = "0.8.6"; //AP and OTA default passwords (for maximum change them!) @@ -123,9 +123,9 @@ char cmDNS[33] = "x"; //mDNS address (placeholder, will char apSSID[33] = ""; //AP off by default (unless setup) byte apChannel = 1; //2.4GHz WiFi AP channel (1-13) byte apHide = 0; //hidden AP SSID -byte apWaitTimeSecs = 32; //time to wait for connection before opening AP -bool apAlwaysOn = false; -bool recoveryAPDisabled = false; //never open AP (not recommended) +//byte apWaitTimeSecs = 32; //time to wait for connection before opening AP +byte apBehavior = 0; //0: Open AP when no connection after boot 1: Open when no connection 2: Always open 3: Only when button pressed for 6 sec +//bool recoveryAPDisabled = false; //never open AP (not recommended) 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 @@ -335,8 +335,6 @@ unsigned long hueLastRequestSent = 0; bool hueAuthRequired = false; bool hueReceived = false; bool hueStoreAllowed = false, hueNewKey = false; -//unsigned long huePollIntervalMsTemp = huePollIntervalMs; -//bool hueAttempt = false; //overlays byte overlayCurrent = overlayDefault; diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 8b57a060e..8456a6c6f 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -134,8 +134,8 @@ void saveSettingsToEEPROM() EEPROM.write(372, useRGBW); EEPROM.write(373, effectPaletteDefault); EEPROM.write(374, strip.paletteFade); - EEPROM.write(375, apWaitTimeSecs); - EEPROM.write(376, recoveryAPDisabled); + //EEPROM.write(375, apWaitTimeSecs); + EEPROM.write(376, apBehavior); EEPROM.write(377, EEPVER); //eeprom was updated to latest @@ -365,8 +365,8 @@ void loadSettingsFromEEPROM(bool first) //374 - strip.paletteFade if (lastEEPROMversion > 0) { - apWaitTimeSecs = EEPROM.read(375); - recoveryAPDisabled = EEPROM.read(376); + //apWaitTimeSecs = EEPROM.read(375); + apBehavior = EEPROM.read(376); } //377 = lastEEPROMversion if (lastEEPROMversion > 1) { diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index cff0ddd46..9b0c58b2f 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -187,7 +187,7 @@ void getSettingsJS(byte subPage, char* dest) } sappends('s',"CM",cmDNS); - sappend('v',"AT",apWaitTimeSecs); + sappend('i',"AB",apBehavior); sappends('s',"AS",apSSID); sappend('c',"AH",apHide); @@ -390,7 +390,6 @@ void getSettingsJS(byte subPage, char* dest) sappend('c',"NO",otaLock); sappend('c',"OW",wifiLock); sappend('c',"AO",aOtaEnabled); - sappend('c',"NA",recoveryAPDisabled); sappends('m',"(\"msg\")[0]","WLED "); olen -= 2; //delete "; oappend(versionString); diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index d0d9ff572..c09f80063 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -28,12 +28,12 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) strcpy(cmDNS, request->arg("CM").c_str()); - int t = request->arg("AT").toInt(); if (t > 9 && t <= 255) apWaitTimeSecs = t; + apBehavior = request->arg("AB").toInt(); strcpy(apSSID, request->arg("AS").c_str()); apHide = request->hasArg("AH"); int passlen = request->arg("AP").length(); if (passlen == 0 || (passlen > 7 && request->arg("AP").charAt(0) != '*')) strcpy(apPass, request->arg("AP").c_str()); - 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; char k[3]; k[2] = 0; for (int i = 0; i<4; i++) @@ -304,7 +304,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) { otaLock = request->hasArg("NO"); wifiLock = request->hasArg("OW"); - recoveryAPDisabled = request->hasArg("NA"); aOtaEnabled = request->hasArg("AO"); } } diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 38acf32c7..53ec2cd47 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -122,15 +122,14 @@ void beginStrip() void initAP(bool resetAP=false){ - if (recoveryAPDisabled) return; - bool set = apSSID[0]; - if (!set || resetAP) strcpy(apSSID, "WLED-AP"); + if (apBehavior == 3 && !resetAP) return; + + if (!apSSID[0] || resetAP) strcpy(apSSID, "WLED-AP"); if (resetAP) strcpy(apPass,"wled1234"); DEBUG_PRINT("Opening access point "); DEBUG_PRINTLN(apSSID); WiFi.softAPConfig(IPAddress(4, 3, 2, 1), IPAddress(4, 3, 2, 1), IPAddress(255,255,255,0)); WiFi.softAP(apSSID, apPass, apChannel, apHide); - if (!set) apSSID[0] = 0; if (!apActive) //start captive portal if AP active { @@ -168,7 +167,7 @@ void initConnection() if (!apActive) initAP(); //instantly go to ap mode return; } else if (!apActive) { - if (apAlwaysOn) + if (apBehavior == 2) { initAP(); } else @@ -194,7 +193,6 @@ void initConnection() void initInterfaces() { DEBUG_PRINTLN("Init STA interfaces"); - server.begin(); if (hueIP[0] == 0) { @@ -207,7 +205,7 @@ void initInterfaces() { if (alexaEnabled) alexaInit(); #ifndef WLED_DISABLE_OTA - if (aOtaEnabled) ArduinoOTA.begin(); + if (aOtaEnabled) ArduinoOTA.begin(false); #endif strip.service(); @@ -216,16 +214,21 @@ void initInterfaces() { { if (MDNS.begin(cmDNS)) { + DEBUG_PRINTLN("mDNS started"); MDNS.addService("http", "tcp", 80); MDNS.addService("wled", "tcp", 80); - DEBUG_PRINTLN("mDNS started"); + if (aOtaEnabled) MDNS.enableArduino(8266); } else { DEBUG_PRINTLN("mDNS failed!"); } - DEBUG_PRINTLN("mDNS started"); } - strip.service(); + server.begin(); + if (udpPort > 0 && udpPort != ntpLocalPort) + { + udpConnected = notifierUdp.begin(udpPort); + if (udpConnected && udpRgbPort != udpPort) udpRgbConnected = rgbUdp.begin(udpRgbPort); + } if (ntpEnabled && WLED_CONNECTED) ntpConnected = ntpUdp.begin(ntpLocalPort); @@ -239,9 +242,14 @@ void initInterfaces() { byte stacO = 0; void handleConnection() { + //TODO: reconnect if heap <8000 byte stac = 0; #ifdef ESP8266 stac = wifi_softap_get_station_num(); + #else + wifi_sta_list_t stationList; + esp_wifi_ap_get_sta_list(&stationList); + stac = stationList.num; #endif if (stac != stacO) { @@ -267,7 +275,7 @@ void handleConnection() { initConnection(); } if (millis() - lastReconnectAttempt > 300000 && WLED_WIFI_CONFIGURED) initConnection(); - if (!apActive && millis() - lastReconnectAttempt > apWaitTimeSecs*1000) initAP(); + if (!apActive && millis() - lastReconnectAttempt > 12000) initAP(); } else if (!interfacesInited) { //newly connected DEBUG_PRINTLN(""); DEBUG_PRINT("Connected! IP address: "); @@ -276,12 +284,12 @@ void handleConnection() { userConnected(); //shut down AP - if (!apAlwaysOn && apActive) + if (apBehavior != 2 && apActive) { dnsServer.stop(); - DEBUG_PRINTLN("Access point disabled."); WiFi.softAPdisconnect(true); apActive = false; + DEBUG_PRINTLN("Access point disabled."); } } } diff --git a/wled00/wled17_mqtt.ino b/wled00/wled17_mqtt.ino index 114a88779..9f4ecd42b 100644 --- a/wled00/wled17_mqtt.ino +++ b/wled00/wled17_mqtt.ino @@ -44,7 +44,7 @@ void onMqttConnect(bool sessionPresent) } doSendHADiscovery = true; - //doPublishMqtt = true; + doPublishMqtt = true; DEBUG_PRINTLN("MQTT ready"); } @@ -98,6 +98,8 @@ void publishMqtt() const char HA_static_JSON[] PROGMEM = R"=====(,"bri_val_tpl":"{{value}}","rgb_cmd_tpl":"{{'#%02x%02x%02x' | format(red, green, blue)}}","rgb_val_tpl":"{{value[1:3]|int(base=16)}},{{value[3:5]|int(base=16)}},{{value[5:7]|int(base=16)}}","qos":0,"opt":true,"pl_on":"ON","pl_off":"OFF","fx_val_tpl":"{{value}}","fx_list":[)====="; +char buffer[2400]; //TODO: this is a TERRIBLE waste of precious memory, local var leads to exception though. Maybe dynamic allocation, but it is unclear when to free + void sendHADiscoveryMQTT() { @@ -138,7 +140,7 @@ Send out HA MQTT Discovery message on MQTT connect (~2.4kB): doSendHADiscovery = false; if (mqtt == nullptr || !mqtt->connected()) return; - char bufc[36], bufcol[38], bufg[36], bufapi[38], buffer[2500]; + char bufc[36], bufcol[38], bufg[36], bufapi[38]; strcpy(bufc, mqttDeviceTopic); strcpy(bufcol, mqttDeviceTopic); @@ -211,7 +213,6 @@ Send out HA MQTT Discovery message on MQTT connect (~2.4kB): strcat(pubt, mqttClientID); strcat(pubt, "/config"); DEBUG_PRINTLN(mqtt->publish(pubt, 0, true, buffer)); - yield(); #endif }