(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;

3
dist/index.d.ts vendored
View File

@@ -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<boolean>;
getBoardVersion(): Promise<string>;
getFirmware(version: versionNotes): Promise<boolean>;
getFileSize(): number;
}

18
dist/index.es.js vendored
View File

@@ -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 };