diff --git a/dist/index.cjs.js b/dist/index.cjs.js index b336561..d6eb221 100644 --- a/dist/index.cjs.js +++ b/dist/index.cjs.js @@ -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; diff --git a/dist/index.d.ts b/dist/index.d.ts index 8c158b6..15e10c8 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -11,6 +11,7 @@ export default class Updater { protected bleDeviceId: string; private readonly _updaterServiceUUID; private readonly _updaterVersionCharactersiticUUID; + file: Int8Array; constructor(archiveURL?: string, feedType?: string, bleObject?: BLECentralPlugin.BLECentralPluginStatic); private getRawArchive; private atomGetVersionDetails; @@ -24,4 +25,6 @@ export default class Updater { private getLatestVersion; checkForUpdate(): Promise; getBoardVersion(): Promise; + getFirmware(version: versionNotes): Promise; + getFileSize(): number; } diff --git a/dist/index.es.js b/dist/index.es.js index d041b45..f18e044 100644 --- a/dist/index.es.js +++ b/dist/index.es.js @@ -8,6 +8,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; @@ -146,6 +147,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; + } } export { Updater as default }; diff --git a/package.json b/package.json index 63eb42b..e039686 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "updaterweblibrary", - "version": "1.0.11", + "version": "1.0.12", "description": "OTA Updater App frontend library", "repository": { "type": "git",