From a073bf32e43368cfa539df33fd32e19f52181c67 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 14 Sep 2025 12:13:03 +0000
Subject: [PATCH 1/2] Implement OTA release compatibility checking system
Implement a comprehensive solution for validating a firmware before an
OTA updated is committed. WLED metadata such as version and release
is moved to a data structure located at near the start of the firmware
binary, where it can be identified and validated.
Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
---
tools/cdata.js | 6 -
wled00/data/update.htm | 27 +++-
wled00/dmx_input.cpp | 4 +-
wled00/e131.cpp | 2 +-
wled00/ota_update.cpp | 257 +++++++++++++++++++++++++++++++++++++++
wled00/ota_update.h | 52 ++++++++
wled00/wled.cpp | 5 +-
wled00/wled.h | 15 +--
wled00/wled_metadata.cpp | 144 ++++++++++++++++++++++
wled00/wled_metadata.h | 71 +++++++++++
wled00/wled_server.cpp | 90 ++++++--------
wled00/xml.cpp | 10 --
12 files changed, 593 insertions(+), 90 deletions(-)
create mode 100644 wled00/ota_update.cpp
create mode 100644 wled00/ota_update.h
create mode 100644 wled00/wled_metadata.cpp
create mode 100644 wled00/wled_metadata.h
diff --git a/tools/cdata.js b/tools/cdata.js
index c05b28e522..d2950ac162 100644
--- a/tools/cdata.js
+++ b/tools/cdata.js
@@ -388,12 +388,6 @@ const char PAGE_dmxmap[] PROGMEM = R"=====()=====";
name: "PAGE_update",
method: "gzip",
filter: "html-minify",
- mangle: (str) =>
- str
- .replace(
- /function GetV().*\<\/script\>/gms,
- ""
- )
},
{
file: "welcome.htm",
diff --git a/wled00/data/update.htm b/wled00/data/update.htm
index 783a609ece..d8b8876ef2 100644
--- a/wled00/data/update.htm
+++ b/wled00/data/update.htm
@@ -17,7 +17,26 @@
}
window.open(getURL("/update?revert"),"_self");
}
- function GetV() {/*injected values here*/}
+ function GetV() {
+ // Fetch device info via JSON API instead of compiling it in
+ fetch('/json/info')
+ .then(response => response.json())
+ .then(data => {
+ document.querySelector('.installed-version').textContent = `${data.brand} ${data.ver} (${data.vid})`;
+ document.querySelector('.release-name').textContent = data.release;
+ // TODO - assemble update URL
+ // TODO - can this be done at build time?
+ if (data.arch == "esp8266") {
+ toggle('rev');
+ }
+ })
+ .catch(error => {
+ console.log('Could not fetch device info:', error);
+ // Fallback to compiled-in value if API call fails
+ document.querySelector('.installed-version').textContent = 'Unknown';
+ document.querySelector('.release-name').textContent = 'Unknown';
+ });
+ }