kopia lustrzana https://github.com/Aircoookie/WLED
Merge 6a5dcb3a76
into 929a5a8d80
commit
6d44e9b18f
|
@ -13,7 +13,7 @@ function isN(n) { return !isNaN(parseFloat(n)) && isFinite(n); } // isNumber
|
||||||
// https://stackoverflow.com/questions/3885817/how-do-i-check-that-a-number-is-float-or-integer
|
// https://stackoverflow.com/questions/3885817/how-do-i-check-that-a-number-is-float-or-integer
|
||||||
function isF(n) { return n === +n && n !== (n|0); } // isFloat
|
function isF(n) { return n === +n && n !== (n|0); } // isFloat
|
||||||
function isI(n) { return n === +n && n === (n|0); } // isInteger
|
function isI(n) { return n === +n && n === (n|0); } // isInteger
|
||||||
function toggle(el) { gId(el).classList.toggle("hide"); gId('No'+el).classList.toggle("hide"); }
|
function toggle(el) { gId(el).classList.toggle("hide"); let n = gId('No'+el); if (n) n.classList.toggle("hide"); }
|
||||||
function tooltip(cont=null) {
|
function tooltip(cont=null) {
|
||||||
d.querySelectorAll((cont?cont+" ":"")+"[title]").forEach((element)=>{
|
d.querySelectorAll((cont?cont+" ":"")+"[title]").forEach((element)=>{
|
||||||
element.addEventListener("pointerover", ()=>{
|
element.addEventListener("pointerover", ()=>{
|
||||||
|
|
|
@ -329,7 +329,7 @@
|
||||||
<div>
|
<div>
|
||||||
<button class="btn ibtn" onclick="requestJson()">Refresh</button>
|
<button class="btn ibtn" onclick="requestJson()">Refresh</button>
|
||||||
<button class="btn ibtn" onclick="toggleNodes()">Instance List</button>
|
<button class="btn ibtn" onclick="toggleNodes()">Instance List</button>
|
||||||
<button class="btn ibtn" onclick="window.open(getURL('/update'),'_self');">Update WLED</button>
|
<button class="btn ibtn" onclick="window.open(getURL('/update'),'_self');" id="updBt">Update WLED</button>
|
||||||
<button class="btn ibtn" id="resetbtn" onclick="cnfReset()">Reboot WLED</button>
|
<button class="btn ibtn" id="resetbtn" onclick="cnfReset()">Reboot WLED</button>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -685,6 +685,7 @@ function parseInfo(i) {
|
||||||
gId("filter2D").classList.remove('hide');
|
gId("filter2D").classList.remove('hide');
|
||||||
gId('bs').querySelectorAll('option[data-type="2D"]').forEach((o,i)=>{o.style.display='';});
|
gId('bs').querySelectorAll('option[data-type="2D"]').forEach((o,i)=>{o.style.display='';});
|
||||||
}
|
}
|
||||||
|
gId("updBt").style.display = (i.opt & 1) ? '':'none';
|
||||||
// if (i.noaudio) {
|
// if (i.noaudio) {
|
||||||
// gId("filterVol").classList.add("hide");
|
// gId("filterVol").classList.add("hide");
|
||||||
// gId("filterFreq").classList.add("hide");
|
// gId("filterFreq").classList.add("hide");
|
||||||
|
|
|
@ -53,13 +53,13 @@
|
||||||
Factory reset: <input type="checkbox" name="RS"><br>
|
Factory reset: <input type="checkbox" name="RS"><br>
|
||||||
All settings and presets will be erased.<br><br>
|
All settings and presets will be erased.<br><br>
|
||||||
<div class="warn">⚠ Unencrypted transmission. An attacker on the same network can intercept form data!</div>
|
<div class="warn">⚠ Unencrypted transmission. An attacker on the same network can intercept form data!</div>
|
||||||
<hr>
|
<span id="OTA"><hr>
|
||||||
<h3>Software Update</h3>
|
<h3>Software Update</h3>
|
||||||
<button type="button" onclick="U()">Manual OTA Update</button><br>
|
<button type="button" onclick="U()">Manual OTA Update</button><br>
|
||||||
<div id="aOTA">Enable ArduinoOTA: <input type="checkbox" name="AO"></div>
|
<div id="aOTA">Enable ArduinoOTA: <input type="checkbox" name="AO"></div>
|
||||||
Only allow update from same network/WiFi: <input type="checkbox" name="SU"><br>
|
Only allow update from same network/WiFi: <input type="checkbox" name="SU"><br>
|
||||||
<i class="warn">⚠ If you are using multiple VLANs (i.e. IoT or guest network) either set PIN or disable this option.<br>
|
<i class="warn">⚠ If you are using multiple VLANs (i.e. IoT or guest network) either set PIN or disable this option.<br>
|
||||||
Disabling this option will make your device less secure.</i><br>
|
Disabling this option will make your device less secure.</i><br></span>
|
||||||
<hr id="backup">
|
<hr id="backup">
|
||||||
<h3>Backup & Restore</h3>
|
<h3>Backup & Restore</h3>
|
||||||
<div class="warn">⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.<br>
|
<div class="warn">⚠ Restoring presets/configuration will OVERWRITE your current presets/configuration.<br>
|
||||||
|
|
|
@ -73,17 +73,13 @@ void NetworkClass::localMAC(uint8_t* MAC)
|
||||||
|
|
||||||
bool NetworkClass::isConnected()
|
bool NetworkClass::isConnected()
|
||||||
{
|
{
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
|
return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED) || isEthernet();
|
||||||
return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED) || ETH.localIP()[0] != 0;
|
|
||||||
#else
|
|
||||||
return (WiFi.localIP()[0] != 0 && WiFi.status() == WL_CONNECTED);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetworkClass::isEthernet()
|
bool NetworkClass::isEthernet()
|
||||||
{
|
{
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
|
||||||
return (ETH.localIP()[0] != 0);
|
return (ETH.localIP()[0] != 0) && ETH.linkUp();
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#define WLED_DEFINE_GLOBAL_VARS //only in one source file, wled.cpp!
|
#define WLED_DEFINE_GLOBAL_VARS //only in one source file, wled.cpp!
|
||||||
#include "wled.h"
|
#include "wled.h"
|
||||||
#include "wled_ethernet.h"
|
#include "wled_ethernet.h"
|
||||||
#include <Arduino.h>
|
#ifdef WLED_ENABLE_AOTA
|
||||||
|
#define NO_OTA_PORT
|
||||||
|
#include <ArduinoOTA.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DISABLE_BROWNOUT_DET)
|
||||||
#include "soc/soc.h"
|
#include "soc/soc.h"
|
||||||
|
@ -105,8 +108,8 @@ void WLED::loop()
|
||||||
if (!realtimeMode || realtimeOverride || (realtimeMode && useMainSegmentOnly)) // block stuff if WARLS/Adalight is enabled
|
if (!realtimeMode || realtimeOverride || (realtimeMode && useMainSegmentOnly)) // block stuff if WARLS/Adalight is enabled
|
||||||
{
|
{
|
||||||
if (apActive) dnsServer.processNextRequest();
|
if (apActive) dnsServer.processNextRequest();
|
||||||
#ifndef WLED_DISABLE_OTA
|
#ifdef WLED_ENABLE_AOTA
|
||||||
if (WLED_CONNECTED && aOtaEnabled && !otaLock && correctPIN) ArduinoOTA.handle();
|
if (Network.isConnected() && aOtaEnabled && !otaLock && correctPIN) ArduinoOTA.handle();
|
||||||
#endif
|
#endif
|
||||||
handleNightlight();
|
handleNightlight();
|
||||||
yield();
|
yield();
|
||||||
|
@ -471,7 +474,7 @@ void WLED::setup()
|
||||||
if (mqttClientID[0] == 0) sprintf_P(mqttClientID, PSTR("WLED-%*s"), 6, escapedMac.c_str() + 6);
|
if (mqttClientID[0] == 0) sprintf_P(mqttClientID, PSTR("WLED-%*s"), 6, escapedMac.c_str() + 6);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WLED_DISABLE_OTA
|
#ifdef WLED_ENABLE_AOTA
|
||||||
if (aOtaEnabled) {
|
if (aOtaEnabled) {
|
||||||
ArduinoOTA.onStart([]() {
|
ArduinoOTA.onStart([]() {
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
@ -711,9 +714,8 @@ void WLED::initInterfaces()
|
||||||
alexaInit();
|
alexaInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WLED_DISABLE_OTA
|
#ifdef WLED_ENABLE_AOTA
|
||||||
if (aOtaEnabled)
|
if (aOtaEnabled) ArduinoOTA.begin();
|
||||||
ArduinoOTA.begin();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Set up mDNS responder:
|
// Set up mDNS responder:
|
||||||
|
@ -784,7 +786,7 @@ void WLED::handleConnection()
|
||||||
if (stac != stacO) {
|
if (stac != stacO) {
|
||||||
stacO = stac;
|
stacO = stac;
|
||||||
DEBUG_PRINTF_P(PSTR("Connected AP clients: %d\n"), (int)stac);
|
DEBUG_PRINTF_P(PSTR("Connected AP clients: %d\n"), (int)stac);
|
||||||
if (!WLED_CONNECTED && wifiConfigured) { // trying to connect, but not connected
|
if (!Network.isConnected() && wifiConfigured) { // trying to connect, but not connected
|
||||||
if (stac)
|
if (stac)
|
||||||
WiFi.disconnect(); // disable search so that AP can work
|
WiFi.disconnect(); // disable search so that AP can work
|
||||||
else
|
else
|
||||||
|
@ -859,7 +861,7 @@ void WLED::handleConnection()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If status LED pin is allocated for other uses, does nothing
|
// If status LED pin is allocated for other uses, does nothing
|
||||||
// else blink at 1Hz when WLED_CONNECTED is false (no WiFi, ?? no Ethernet ??)
|
// else blink at 1Hz when Network.isConnected() is false (no WiFi, ?? no Ethernet ??)
|
||||||
// else blink at 2Hz when MQTT is enabled but not connected
|
// else blink at 2Hz when MQTT is enabled but not connected
|
||||||
// else turn the status LED off
|
// else turn the status LED off
|
||||||
#if defined(STATUSLED)
|
#if defined(STATUSLED)
|
||||||
|
@ -873,7 +875,7 @@ void WLED::handleStatusLED()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (WLED_CONNECTED) {
|
if (Network.isConnected()) {
|
||||||
c = RGBW32(0,255,0,0);
|
c = RGBW32(0,255,0,0);
|
||||||
ledStatusType = 2;
|
ledStatusType = 2;
|
||||||
} else if (WLED_MQTT_CONNECTED) {
|
} else if (WLED_MQTT_CONNECTED) {
|
||||||
|
|
|
@ -21,6 +21,12 @@
|
||||||
|
|
||||||
// You are required to disable over-the-air updates:
|
// You are required to disable over-the-air updates:
|
||||||
//#define WLED_DISABLE_OTA // saves 14kb
|
//#define WLED_DISABLE_OTA // saves 14kb
|
||||||
|
#ifdef WLED_ENABLE_AOTA
|
||||||
|
#if defined(WLED_DISABLE_OTA)
|
||||||
|
#warning WLED_DISABLE_OTA was defined but it will be ignored due to WLED_ENABLE_AOTA.
|
||||||
|
#endif
|
||||||
|
#undef WLED_DISABLE_OTA
|
||||||
|
#endif
|
||||||
|
|
||||||
// You can choose some of these features to disable:
|
// You can choose some of these features to disable:
|
||||||
//#define WLED_DISABLE_ALEXA // saves 11kb
|
//#define WLED_DISABLE_ALEXA // saves 11kb
|
||||||
|
@ -121,10 +127,6 @@
|
||||||
#endif
|
#endif
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
#ifndef WLED_DISABLE_OTA
|
|
||||||
#define NO_OTA_PORT
|
|
||||||
#include <ArduinoOTA.h>
|
|
||||||
#endif
|
|
||||||
#include <SPIFFSEditor.h>
|
#include <SPIFFSEditor.h>
|
||||||
#include "src/dependencies/time/TimeLib.h"
|
#include "src/dependencies/time/TimeLib.h"
|
||||||
#include "src/dependencies/timezone/Timezone.h"
|
#include "src/dependencies/timezone/Timezone.h"
|
||||||
|
@ -588,7 +590,7 @@ WLED_GLOBAL bool otaLock _INIT(true); // prevents OTA firmware update
|
||||||
WLED_GLOBAL bool otaLock _INIT(false); // prevents OTA firmware updates without password. ALWAYS enable if system exposed to any public networks
|
WLED_GLOBAL bool otaLock _INIT(false); // prevents OTA firmware updates without password. ALWAYS enable if system exposed to any public networks
|
||||||
#endif
|
#endif
|
||||||
WLED_GLOBAL bool wifiLock _INIT(false); // prevents access to WiFi settings when OTA lock is enabled
|
WLED_GLOBAL bool wifiLock _INIT(false); // prevents access to WiFi settings when OTA lock is enabled
|
||||||
#ifndef WLED_DISABLE_OTA
|
#ifdef WLED_ENABLE_AOTA
|
||||||
WLED_GLOBAL bool aOtaEnabled _INIT(true); // ArduinoOTA allows easy updates directly from the IDE. Careful, it does not auto-disable when OTA lock is on
|
WLED_GLOBAL bool aOtaEnabled _INIT(true); // ArduinoOTA allows easy updates directly from the IDE. Careful, it does not auto-disable when OTA lock is on
|
||||||
#else
|
#else
|
||||||
WLED_GLOBAL bool aOtaEnabled _INIT(false); // ArduinoOTA allows easy updates directly from the IDE. Careful, it does not auto-disable when OTA lock is on
|
WLED_GLOBAL bool aOtaEnabled _INIT(false); // ArduinoOTA allows easy updates directly from the IDE. Careful, it does not auto-disable when OTA lock is on
|
||||||
|
@ -1024,11 +1026,7 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0);
|
||||||
WLED_GLOBAL unsigned loops _INIT(0);
|
WLED_GLOBAL unsigned loops _INIT(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#define WLED_CONNECTED (Network.isConnected())
|
||||||
#define WLED_CONNECTED (WiFi.status() == WL_CONNECTED || ETH.localIP()[0] != 0)
|
|
||||||
#else
|
|
||||||
#define WLED_CONNECTED (WiFi.status() == WL_CONNECTED)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WLED_AP_SSID_UNIQUE
|
#ifndef WLED_AP_SSID_UNIQUE
|
||||||
#define WLED_SET_AP_SSID() do { \
|
#define WLED_SET_AP_SSID() do { \
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#include "wled.h"
|
#include "wled.h"
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifndef WLED_DISABLE_OTA
|
||||||
#include <Updater.h>
|
#ifdef ESP8266
|
||||||
#else
|
#include <Updater.h>
|
||||||
#include <Update.h>
|
#else
|
||||||
|
#include <Update.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#include "html_ui.h"
|
#include "html_ui.h"
|
||||||
#include "html_settings.h"
|
#include "html_settings.h"
|
||||||
|
@ -387,6 +389,7 @@ void initServer()
|
||||||
createEditHandler(correctPIN);
|
createEditHandler(correctPIN);
|
||||||
|
|
||||||
static const char _update[] PROGMEM = "/update";
|
static const char _update[] PROGMEM = "/update";
|
||||||
|
#ifndef WLED_DISABLE_OTA
|
||||||
//init ota page
|
//init ota page
|
||||||
server.on(_update, HTTP_GET, [](AsyncWebServerRequest *request){
|
server.on(_update, HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
if (otaLock) {
|
if (otaLock) {
|
||||||
|
@ -446,14 +449,17 @@ void initServer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
#else
|
||||||
|
const auto notSupported = [](AsyncWebServerRequest *request){
|
||||||
|
serveMessage(request, 501, FPSTR(s_notimplemented), F("This build does not support OTA update."), 254);
|
||||||
|
};
|
||||||
|
server.on(_update, HTTP_GET, notSupported);
|
||||||
|
server.on(_update, HTTP_POST, notSupported, [](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool isFinal){});
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WLED_ENABLE_DMX
|
#ifdef WLED_ENABLE_DMX
|
||||||
server.on(F("/dmxmap"), HTTP_GET, [](AsyncWebServerRequest *request){
|
server.on(F("/dmxmap"), HTTP_GET, [](AsyncWebServerRequest *request){
|
||||||
request->send_P(200, FPSTR(CONTENT_TYPE_HTML), PAGE_dmxmap , dmxProcessor);
|
request->send_P(200, FPSTR(CONTENT_TYPE_HTML), PAGE_dmxmap, dmxProcessor);
|
||||||
});
|
|
||||||
#else
|
|
||||||
server.on(F("/dmxmap"), HTTP_GET, [](AsyncWebServerRequest *request){
|
|
||||||
serveMessage(request, 501, FPSTR(s_notimplemented), F("DMX support is not enabled in this build."), 254);
|
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -657,6 +663,7 @@ void serveSettings(AsyncWebServerRequest* request, bool post) {
|
||||||
case SUBPAGE_DMX : content = PAGE_settings_dmx; len = PAGE_settings_dmx_length; break;
|
case SUBPAGE_DMX : content = PAGE_settings_dmx; len = PAGE_settings_dmx_length; break;
|
||||||
#endif
|
#endif
|
||||||
case SUBPAGE_UM : content = PAGE_settings_um; len = PAGE_settings_um_length; break;
|
case SUBPAGE_UM : content = PAGE_settings_um; len = PAGE_settings_um_length; break;
|
||||||
|
#ifndef WLED_DISABLE_OTA
|
||||||
case SUBPAGE_UPDATE : content = PAGE_update; len = PAGE_update_length;
|
case SUBPAGE_UPDATE : content = PAGE_update; len = PAGE_update_length;
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
if (request->hasArg(F("revert")) && inLocalSubnet(request->client()->remoteIP()) && Update.canRollBack()) {
|
if (request->hasArg(F("revert")) && inLocalSubnet(request->client()->remoteIP()) && Update.canRollBack()) {
|
||||||
|
@ -670,6 +677,7 @@ void serveSettings(AsyncWebServerRequest* request, bool post) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
case SUBPAGE_2D : content = PAGE_settings_2D; len = PAGE_settings_2D_length; break;
|
case SUBPAGE_2D : content = PAGE_settings_2D; len = PAGE_settings_2D_length; break;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -596,8 +596,11 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
||||||
snprintf_P(tmp_buf,sizeof(tmp_buf),PSTR("WLED %s (build %d)"),versionString,VERSION);
|
snprintf_P(tmp_buf,sizeof(tmp_buf),PSTR("WLED %s (build %d)"),versionString,VERSION);
|
||||||
printSetClassElementHTML(settingsScript,PSTR("sip"),0,tmp_buf);
|
printSetClassElementHTML(settingsScript,PSTR("sip"),0,tmp_buf);
|
||||||
settingsScript.printf_P(PSTR("sd=\"%s\";"), serverDescription);
|
settingsScript.printf_P(PSTR("sd=\"%s\";"), serverDescription);
|
||||||
#ifdef WLED_DISABLE_OTA
|
|
||||||
//hide settings if not compiled
|
//hide settings if not compiled
|
||||||
|
#ifdef WLED_DISABLE_OTA
|
||||||
|
settingsScript.print(F("toggle('OTA');")); // hide update section
|
||||||
|
#endif
|
||||||
|
#ifndef WLED_ENABLE_AOTA
|
||||||
settingsScript.print(F("toggle('aOTA');")); // hide ArduinoOTA checkbox
|
settingsScript.print(F("toggle('aOTA');")); // hide ArduinoOTA checkbox
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue