Skip to content

Commit 8baf0fd

Browse files
committed
Add UI logic to hide ArduinoOTA checkbox and remove configuration items
1 parent ca7d7d9 commit 8baf0fd

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

wled00/cfg.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
611611
if (pwdCorrect) { //only accept these values from cfg.json if ota is unlocked (else from wsec.json)
612612
CJSON(otaLock, ota[F("lock")]);
613613
CJSON(wifiLock, ota[F("lock-wifi")]);
614+
#ifndef WLED_DISABLE_OTA
614615
CJSON(aOtaEnabled, ota[F("aota")]);
616+
#endif
615617
getStringFromJson(otaPass, pwd, 33); //normally not present due to security
616618
}
617619

@@ -1103,7 +1105,9 @@ void serializeConfig(JsonObject root) {
11031105
ota[F("lock")] = otaLock;
11041106
ota[F("lock-wifi")] = wifiLock;
11051107
ota[F("pskl")] = strlen(otaPass);
1108+
#ifndef WLED_DISABLE_OTA
11061109
ota[F("aota")] = aOtaEnabled;
1110+
#endif
11071111

11081112
#ifdef WLED_ENABLE_DMX
11091113
JsonObject dmx = root.createNestedObject("dmx");
@@ -1174,7 +1178,9 @@ bool deserializeConfigSec() {
11741178
getStringFromJson(otaPass, ota[F("pwd")], 33);
11751179
CJSON(otaLock, ota[F("lock")]);
11761180
CJSON(wifiLock, ota[F("lock-wifi")]);
1181+
#ifndef WLED_DISABLE_OTA
11771182
CJSON(aOtaEnabled, ota[F("aota")]);
1183+
#endif
11781184

11791185
releaseJSONBufferLock();
11801186
return true;
@@ -1214,7 +1220,9 @@ void serializeConfigSec() {
12141220
ota[F("pwd")] = otaPass;
12151221
ota[F("lock")] = otaLock;
12161222
ota[F("lock-wifi")] = wifiLock;
1223+
#ifndef WLED_DISABLE_OTA
12171224
ota[F("aota")] = aOtaEnabled;
1225+
#endif
12181226

12191227
File f = WLED_FS.open(FPSTR(s_wsec_json), "w");
12201228
if (f) serializeJson(root, f);

wled00/data/settings_sec.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h2>Security & Update setup</h2>
5656
<hr>
5757
<h3>Software Update</h3>
5858
<button type="button" onclick="U()">Manual OTA Update</button><br>
59-
Enable ArduinoOTA: <input type="checkbox" name="AO">
59+
<div id="aOTA">Enable ArduinoOTA: <input type="checkbox" name="AO"></div>
6060
<hr id="backup">
6161
<h3>Backup & Restore</h3>
6262
<div class="warn">&#9888; Restoring presets/configuration will OVERWRITE your current presets/configuration.<br>

wled00/set.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
593593
{
594594
otaLock = request->hasArg(F("NO"));
595595
wifiLock = request->hasArg(F("OW"));
596+
#ifndef WLED_DISABLE_OTA
596597
aOtaEnabled = request->hasArg(F("AO"));
598+
#endif
597599
//createEditHandler(correctPIN && !otaLock);
598600
}
599601
}

wled00/wled.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,11 @@ WLED_GLOBAL bool otaLock _INIT(true); // prevents OTA firmware update
584584
WLED_GLOBAL bool otaLock _INIT(false); // prevents OTA firmware updates without password. ALWAYS enable if system exposed to any public networks
585585
#endif
586586
WLED_GLOBAL bool wifiLock _INIT(false); // prevents access to WiFi settings when OTA lock is enabled
587+
#ifndef WLED_DISABLE_OTA
587588
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
589+
#else
590+
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
591+
#endif
588592
WLED_GLOBAL char settingsPIN[5] _INIT(WLED_PIN); // PIN for settings pages
589593
WLED_GLOBAL bool correctPIN _INIT(!strlen(settingsPIN));
590594
WLED_GLOBAL unsigned long lastEditTime _INIT(0);

wled00/xml.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,10 @@ void getSettingsJS(byte subPage, Print& settingsScript)
595595
snprintf_P(tmp_buf,sizeof(tmp_buf),PSTR("WLED %s (build %d)"),versionString,VERSION);
596596
printSetClassElementHTML(settingsScript,PSTR("sip"),0,tmp_buf);
597597
settingsScript.printf_P(PSTR("sd=\"%s\";"), serverDescription);
598+
#ifdef WLED_DISABLE_OTA
599+
//hide settings if not compiled
600+
settingsScript.print(F("toggle('aOTA');")); // hide ArduinoOTA checkbox
601+
#endif
598602
}
599603

600604
#ifdef WLED_ENABLE_DMX // include only if DMX is enabled

0 commit comments

Comments
 (0)