get the firmware
This commit is contained in:
25
src/index.ts
25
src/index.ts
@@ -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> {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user