From 3fa9aa927a9e09156216b68ab83b162a84d29ebb Mon Sep 17 00:00:00 2001 From: Will Miles Date: Tue, 12 Nov 2024 23:30:02 -0500 Subject: [PATCH 1/2] Publish settings and OTA state in info --- wled00/json.cpp | 2 ++ wled00/set.cpp | 1 + wled00/wled.cpp | 1 + wled00/wled_server.cpp | 4 ++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index 288059653f..c92af14f1e 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -818,8 +818,10 @@ void serializeInfo(JsonObject root) #endif #ifndef WLED_DISABLE_OTA os += 0x01; + root[F("ota")] = !otaLock; #endif root[F("opt")] = os; + root[F("settings")] = correctPIN; root[F("brand")] = F(WLED_BRAND); root[F("product")] = F(WLED_PRODUCT_NAME); diff --git a/wled00/set.cpp b/wled00/set.cpp index 712e5f254a..0612d03e78 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -587,6 +587,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) wifiLock = request->hasArg(F("OW")); aOtaEnabled = request->hasArg(F("AO")); //createEditHandler(correctPIN && !otaLock); + interfaceUpdateCallMode = CALL_MODE_WS_SEND; } } diff --git a/wled00/wled.cpp b/wled00/wled.cpp index d6a39a399f..2629f756b4 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -155,6 +155,7 @@ void WLED::loop() if (strlen(settingsPIN)>0 && correctPIN && millis() - lastEditTime > PIN_TIMEOUT) { correctPIN = false; createEditHandler(false); + interfaceUpdateCallMode = CALL_MODE_WS_SEND; // schedule WS update } // reconnect WiFi to clear stale allocations if heap gets too low diff --git a/wled00/wled_server.cpp b/wled00/wled_server.cpp index e8cbb41ae5..67878db342 100644 --- a/wled00/wled_server.cpp +++ b/wled00/wled_server.cpp @@ -323,9 +323,9 @@ void initServer() releaseJSONBufferLock(); if (verboseResponse) { + interfaceUpdateCallMode = CALL_MODE_WS_SEND; // schedule WS update if (!isConfig) { - lastInterfaceUpdate = millis(); // prevent WS update until cooldown - interfaceUpdateCallMode = CALL_MODE_WS_SEND; // schedule WS update + lastInterfaceUpdate = millis(); // prevent WS update until cooldown serveJson(request); return; //if JSON contains "v" } else { doSerializeConfig = true; //serializeConfig(); //Save new settings to FS From 702fb0ee6f8f5ba0e89e73ab0dcc101e4bf41a97 Mon Sep 17 00:00:00 2001 From: Will Miles Date: Wed, 13 Nov 2024 22:19:00 -0500 Subject: [PATCH 2/2] Update lock state property names Use "settingsLocked" and "otaLocked" to clearly convey the meaning and sense. --- wled00/json.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index c92af14f1e..7646f945af 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -802,6 +802,8 @@ void serializeInfo(JsonObject root) os += 0x40; #endif + root[F("settingsLocked")] = !correctPIN; + //os += 0x20; // indicated now removed Blynk support, may be reused to indicate another build-time option #ifdef USERMOD_CRONIXIE @@ -818,11 +820,10 @@ void serializeInfo(JsonObject root) #endif #ifndef WLED_DISABLE_OTA os += 0x01; - root[F("ota")] = !otaLock; + root[F("otaLocked")] = otaLock; #endif root[F("opt")] = os; - root[F("settings")] = correctPIN; - + root[F("brand")] = F(WLED_BRAND); root[F("product")] = F(WLED_PRODUCT_NAME); root["mac"] = escapedMac;