get the firmware

This commit is contained in:
2025-11-26 22:01:04 +00:00
parent 6f77c15088
commit 3e7c9f358e

View File

@@ -18,6 +18,8 @@ export default class Updater {
private readonly _updaterServiceUUID: string = "71a4438e-fd52-4b15-b3d2-ec0e3e56193b";
private readonly _updaterVersionCharactersiticUUID: string = "1978a3df-c009-4837-b295-57ef429dde8c";
private file: Int8Array;
constructor(archiveURL: string = "/", feedType: string = "atom", bleObject?: BLECentralPlugin.BLECentralPluginStatic) {
this.archiveURL = archiveURL;
this.feedType = feedType;
@@ -176,5 +178,28 @@ export default class Updater {
public async getBoardVersion(): Promise<string> {
return await this.readVersionNumber();
}
/*
FILE FLASHING
*/
public async getFirmware(version: versionNotes): Promise<boolean> {
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;
}
}
public getFileSize(): number {
return this.file.byteLength;
}
// public async flashFirmware(): Promise<boolean> {
// }
}