diff --git a/src/index.ts b/src/index.ts index 32cdd69..f93b3ec 100644 --- a/src/index.ts +++ b/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 { return await this.readVersionNumber(); } + + /* + FILE FLASHING + */ + + public async getFirmware(version: versionNotes): Promise { + 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 { + + // } }