Skip to content

Commit

Permalink
Add ota firmware download button
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWieland committed Dec 31, 2024
1 parent 494af2b commit 055a36d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ <h2>Choose your ratgdo control board:</h2>
</div>

<p>
<esp-web-install-button></esp-web-install-button>
<form method="get" action="v32board-esp32/v32board-esp32.ota.bin" id="download_ota_form" style="float: right">
<button type="submit" style="padding: 8px 28px; font-size: 14px; border-radius: 4px; color: #fff; background-color: #03a9f4; border: none; box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.12), 0 1px 5px 0 rgba(0,0,0,.2);">Download OTA Firmware</button>
</form>
<esp-web-install-button></esp-web-install-button>
</p>


Expand Down Expand Up @@ -310,6 +313,19 @@ <h3>Advanced Users</h3>
}
}

function setOTAFirmwarePath(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
document.querySelector("#download_ota_form").action = xhr.response.builds[0].ota.path;
}
};
xhr.send();
};

document.querySelectorAll('div.radios input').forEach((radio) =>
radio.addEventListener("change", () => {
const button = document.querySelector("esp-web-install-button");
Expand Down Expand Up @@ -337,6 +353,7 @@ <h3>Advanced Users</h3>
}

button.manifest = `${hardware}${protocol}-manifest.json`;
setOTAFirmwarePath(button.manifest);
})
);

Expand Down

0 comments on commit 055a36d

Please sign in to comment.