mirror of
https://github.com/wled/WLED.git
synced 2025-07-12 05:16:31 +00:00
Merge pull request #4652 from wled/disable-ota
Only disable Arduino OTA when using -D WLED_DISABLE_OTA
This commit is contained in:
commit
aa28769e71
@ -627,7 +627,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
if (pwdCorrect) { //only accept these values from cfg.json if ota is unlocked (else from wsec.json)
|
if (pwdCorrect) { //only accept these values from cfg.json if ota is unlocked (else from wsec.json)
|
||||||
CJSON(otaLock, ota[F("lock")]);
|
CJSON(otaLock, ota[F("lock")]);
|
||||||
CJSON(wifiLock, ota[F("lock-wifi")]);
|
CJSON(wifiLock, ota[F("lock-wifi")]);
|
||||||
|
#ifndef WLED_DISABLE_OTA
|
||||||
CJSON(aOtaEnabled, ota[F("aota")]);
|
CJSON(aOtaEnabled, ota[F("aota")]);
|
||||||
|
#endif
|
||||||
getStringFromJson(otaPass, pwd, 33); //normally not present due to security
|
getStringFromJson(otaPass, pwd, 33); //normally not present due to security
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,7 +1124,9 @@ void serializeConfig(JsonObject root) {
|
|||||||
ota[F("lock")] = otaLock;
|
ota[F("lock")] = otaLock;
|
||||||
ota[F("lock-wifi")] = wifiLock;
|
ota[F("lock-wifi")] = wifiLock;
|
||||||
ota[F("pskl")] = strlen(otaPass);
|
ota[F("pskl")] = strlen(otaPass);
|
||||||
|
#ifndef WLED_DISABLE_OTA
|
||||||
ota[F("aota")] = aOtaEnabled;
|
ota[F("aota")] = aOtaEnabled;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WLED_ENABLE_DMX
|
#ifdef WLED_ENABLE_DMX
|
||||||
JsonObject dmx = root.createNestedObject("dmx");
|
JsonObject dmx = root.createNestedObject("dmx");
|
||||||
@ -1193,7 +1197,9 @@ bool deserializeConfigSec() {
|
|||||||
getStringFromJson(otaPass, ota[F("pwd")], 33);
|
getStringFromJson(otaPass, ota[F("pwd")], 33);
|
||||||
CJSON(otaLock, ota[F("lock")]);
|
CJSON(otaLock, ota[F("lock")]);
|
||||||
CJSON(wifiLock, ota[F("lock-wifi")]);
|
CJSON(wifiLock, ota[F("lock-wifi")]);
|
||||||
|
#ifndef WLED_DISABLE_OTA
|
||||||
CJSON(aOtaEnabled, ota[F("aota")]);
|
CJSON(aOtaEnabled, ota[F("aota")]);
|
||||||
|
#endif
|
||||||
|
|
||||||
releaseJSONBufferLock();
|
releaseJSONBufferLock();
|
||||||
return true;
|
return true;
|
||||||
@ -1233,7 +1239,9 @@ void serializeConfigSec() {
|
|||||||
ota[F("pwd")] = otaPass;
|
ota[F("pwd")] = otaPass;
|
||||||
ota[F("lock")] = otaLock;
|
ota[F("lock")] = otaLock;
|
||||||
ota[F("lock-wifi")] = wifiLock;
|
ota[F("lock-wifi")] = wifiLock;
|
||||||
|
#ifndef WLED_DISABLE_OTA
|
||||||
ota[F("aota")] = aOtaEnabled;
|
ota[F("aota")] = aOtaEnabled;
|
||||||
|
#endif
|
||||||
|
|
||||||
File f = WLED_FS.open(FPSTR(s_wsec_json), "w");
|
File f = WLED_FS.open(FPSTR(s_wsec_json), "w");
|
||||||
if (f) serializeJson(root, f);
|
if (f) serializeJson(root, f);
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
<hr>
|
<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>
|
||||||
Enable ArduinoOTA: <input type="checkbox" name="AO">
|
<div id="aOTA">Enable ArduinoOTA: <input type="checkbox" name="AO"></div>
|
||||||
<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>
|
||||||
|
@ -606,7 +606,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
{
|
{
|
||||||
otaLock = request->hasArg(F("NO"));
|
otaLock = request->hasArg(F("NO"));
|
||||||
wifiLock = request->hasArg(F("OW"));
|
wifiLock = request->hasArg(F("OW"));
|
||||||
|
#ifndef WLED_DISABLE_OTA
|
||||||
aOtaEnabled = request->hasArg(F("AO"));
|
aOtaEnabled = request->hasArg(F("AO"));
|
||||||
|
#endif
|
||||||
//createEditHandler(correctPIN && !otaLock);
|
//createEditHandler(correctPIN && !otaLock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -585,7 +585,11 @@ 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
|
||||||
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
|
||||||
|
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
|
||||||
|
#endif
|
||||||
WLED_GLOBAL char settingsPIN[5] _INIT(WLED_PIN); // PIN for settings pages
|
WLED_GLOBAL char settingsPIN[5] _INIT(WLED_PIN); // PIN for settings pages
|
||||||
WLED_GLOBAL bool correctPIN _INIT(!strlen(settingsPIN));
|
WLED_GLOBAL bool correctPIN _INIT(!strlen(settingsPIN));
|
||||||
WLED_GLOBAL unsigned long lastEditTime _INIT(0);
|
WLED_GLOBAL unsigned long lastEditTime _INIT(0);
|
||||||
|
@ -365,7 +365,6 @@ 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) {
|
||||||
@ -419,12 +418,6 @@ void initServer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#else
|
|
||||||
server.on(_update, HTTP_GET, [](AsyncWebServerRequest *request){
|
|
||||||
serveMessage(request, 501, FPSTR(s_notimplemented), F("OTA updating is disabled in this build."), 254);
|
|
||||||
});
|
|
||||||
#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){
|
||||||
|
@ -595,6 +595,10 @@ 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
|
||||||
|
settingsScript.print(F("toggle('aOTA');")); // hide ArduinoOTA checkbox
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WLED_ENABLE_DMX // include only if DMX is enabled
|
#ifdef WLED_ENABLE_DMX // include only if DMX is enabled
|
||||||
|
Loading…
x
Reference in New Issue
Block a user