Add ESP32 bootloader upgrade functionality with JSON API support

Co-authored-by: netmindz <442066+netmindz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-05 14:17:51 +00:00
parent 30fbf55b9a
commit 93908e758f
4 changed files with 170 additions and 1 deletions

View File

@@ -18,13 +18,25 @@
window.open(getURL("/update?revert"),"_self");
}
function GetV() {/*injected values here*/}
var isESP32 = false;
function checkESP32() {
fetch(getURL('/json/info')).then(r=>r.json()).then(d=>{
isESP32 = d.arch && d.arch.startsWith('esp32');
if (isESP32) {
gId('bootloader-section').style.display = 'block';
if (d.bootloaderSHA256) {
gId('bootloader-hash').innerText = 'Current bootloader SHA256: ' + d.bootloaderSHA256;
}
}
}).catch(e=>console.error(e));
}
</script>
<style>
@import url("style.css");
</style>
</head>
<body onload="GetV()">
<body onload="GetV(); checkESP32();">
<h2>WLED Software Update</h2>
<form method='POST' action='./update' id='upd' enctype='multipart/form-data' onsubmit="toggle('upd')">
Installed version: <span class="sip">WLED ##VERSION##</span><br>
@@ -37,6 +49,16 @@
<button id="rev" type="button" onclick="cR()">Revert update</button><br>
<button type="button" onclick="B()">Back</button>
</form>
<div id="bootloader-section" style="display:none;">
<hr class="sml">
<h2>ESP32 Bootloader Update</h2>
<div id="bootloader-hash" class="sip" style="margin-bottom:8px;"></div>
<form method='POST' action='./updatebootloader' id='bootupd' enctype='multipart/form-data' onsubmit="toggle('bootupd')">
<b>Warning:</b> Only upload verified ESP32 bootloader files!<br>
<input type='file' name='update' required><br>
<button type="submit">Update Bootloader</button>
</form>
</div>
<div id="Noupd" class="hide"><b>Updating...</b><br>Please do not close or refresh the page :)</div>
</body>
</html>