Skip to content

Commit aa28769

Browse files
authored
Merge pull request wled#4652 from wled/disable-ota
Only disable Arduino OTA when using -D WLED_DISABLE_OTA
2 parents 25223c4 + 8baf0fd commit aa28769

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

wled00/cfg.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
627627
if (pwdCorrect) { //only accept these values from cfg.json if ota is unlocked (else from wsec.json)
628628
CJSON(otaLock, ota[F("lock")]);
629629
CJSON(wifiLock, ota[F("lock-wifi")]);
630+
#ifndef WLED_DISABLE_OTA
630631
CJSON(aOtaEnabled, ota[F("aota")]);
632+
#endif
631633
getStringFromJson(otaPass, pwd, 33); //normally not present due to security
632634
}
633635

@@ -1122,7 +1124,9 @@ void serializeConfig(JsonObject root) {
11221124
ota[F("lock")] = otaLock;
11231125
ota[F("lock-wifi")] = wifiLock;
11241126
ota[F("pskl")] = strlen(otaPass);
1127+
#ifndef WLED_DISABLE_OTA
11251128
ota[F("aota")] = aOtaEnabled;
1129+
#endif
11261130

11271131
#ifdef WLED_ENABLE_DMX
11281132
JsonObject dmx = root.createNestedObject("dmx");
@@ -1193,7 +1197,9 @@ bool deserializeConfigSec() {
11931197
getStringFromJson(otaPass, ota[F("pwd")], 33);
11941198
CJSON(otaLock, ota[F("lock")]);
11951199
CJSON(wifiLock, ota[F("lock-wifi")]);
1200+
#ifndef WLED_DISABLE_OTA
11961201
CJSON(aOtaEnabled, ota[F("aota")]);
1202+
#endif
11971203

11981204
releaseJSONBufferLock();
11991205
return true;
@@ -1233,7 +1239,9 @@ void serializeConfigSec() {
12331239
ota[F("pwd")] = otaPass;
12341240
ota[F("lock")] = otaLock;
12351241
ota[F("lock-wifi")] = wifiLock;
1242+
#ifndef WLED_DISABLE_OTA
12361243
ota[F("aota")] = aOtaEnabled;
1244+
#endif
12371245

12381246
File f = WLED_FS.open(FPSTR(s_wsec_json), "w");
12391247
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
@@ -606,7 +606,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
606606
{
607607
otaLock = request->hasArg(F("NO"));
608608
wifiLock = request->hasArg(F("OW"));
609+
#ifndef WLED_DISABLE_OTA
609610
aOtaEnabled = request->hasArg(F("AO"));
611+
#endif
610612
//createEditHandler(correctPIN && !otaLock);
611613
}
612614
}

wled00/wled.h

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

wled00/wled_server.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ void initServer()
365365
createEditHandler(correctPIN);
366366

367367
static const char _update[] PROGMEM = "/update";
368-
#ifndef WLED_DISABLE_OTA
369368
//init ota page
370369
server.on(_update, HTTP_GET, [](AsyncWebServerRequest *request){
371370
if (otaLock) {
@@ -419,12 +418,6 @@ void initServer()
419418
}
420419
}
421420
});
422-
#else
423-
server.on(_update, HTTP_GET, [](AsyncWebServerRequest *request){
424-
serveMessage(request, 501, FPSTR(s_notimplemented), F("OTA updating is disabled in this build."), 254);
425-
});
426-
#endif
427-
428421

429422
#ifdef WLED_ENABLE_DMX
430423
server.on(F("/dmxmap"), HTTP_GET, [](AsyncWebServerRequest *request){

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)