(1.0.12) downloading firmware file

This commit is contained in:
2025-11-26 22:02:52 +00:00
parent c65ec8dcd2
commit fdcf232f8e
4 changed files with 40 additions and 1 deletions

18
dist/index.cjs.js vendored
View File

@@ -10,6 +10,7 @@ class Updater {
bleDeviceId;
_updaterServiceUUID = "71a4438e-fd52-4b15-b3d2-ec0e3e56193b";
_updaterVersionCharactersiticUUID = "1978a3df-c009-4837-b295-57ef429dde8c";
file;
constructor(archiveURL = "/", feedType = "atom", bleObject) {
this.archiveURL = archiveURL;
this.feedType = feedType;
@@ -148,6 +149,23 @@ class Updater {
async getBoardVersion() {
return await this.readVersionNumber();
}
/*
FILE FLASHING
*/
async getFirmware(version) {
try {
const res = await fetch(`${this.archiveURL}/download/${version.title}/firmware.bin`);
let buf = await res.arrayBuffer();
this.file = new Int8Array(buf);
return true;
}
catch {
return false;
}
}
getFileSize() {
return this.file.byteLength;
}
}
module.exports = Updater;