(1.0.29) bump

This commit is contained in:
2025-12-01 18:33:57 +00:00
parent faf4e377d7
commit 27403e0aed
3 changed files with 107 additions and 103 deletions

104
dist/index.cjs.js vendored
View File

@@ -201,61 +201,63 @@ class Updater {
// write file length // write file length
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
// set mtu // set mtu
this._packetSize = await this.bleObject.withPromises.requestMtu(this.bleDeviceId, this._packetSize); this.bleObject.requestMtu(this.bleDeviceId, this._packetSize, (mtu) => {
// start notify this._packetSize = mtu;
this.bleObject.startNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, (rawData) => { this.bleObject.startNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, (rawData) => {
let dataView = new Uint8Array(rawData); let dataView = new Uint8Array(rawData);
console.log(dataView); console.log(dataView);
if (dataView[0] == 1) { if (dataView[0] == 1) {
// send file // send file
this.sendNextPacket(); this.sendNextPacket();
progressCallback(`MTU: ${this._packetSize}; Sending (${Math.floor((this._fileProgress * 100) / this._fileSize)}%), ${this._fileProgress} / ${this._fileSize}`); progressCallback(`MTU: ${this._packetSize}; Sending (${Math.floor((this._fileProgress * 100) / this._fileSize)}%), ${this._fileProgress} / ${this._fileSize}`);
} }
else if (dataView[0] == 2) { else if (dataView[0] == 2) {
// done logic // done logic
console.log(`progress >= filesize: ${this._fileProgress} vs ${this._fileSize}`); console.log(`progress >= filesize: ${this._fileProgress} vs ${this._fileSize}`);
if (this._fileProgress >= this._fileSize) { if (this._fileProgress >= this._fileSize) {
console.log("true"); console.log("true");
// send agree // send agree
this.sendEndCmd(true); this.sendEndCmd(true);
progressCallback(`Complete!`); progressCallback(`Complete!`);
this.bleObject.stopNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, () => { this.bleObject.stopNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, () => {
// success // success
resolve(true); resolve(true);
}, (error) => { }, (error) => {
reject("Error: Failed to stop notify"); reject("Error: Failed to stop notify");
}); });
}
else {
console.log("False");
// send disagree
this.sendEndCmd(false);
progressCallback(`Error, starting over: ${this._fileProgress} / ${this._fileSize}`);
this._fileProgress = 0;
}
}
else if (dataView[0] == 15) {
// error cmd
progressCallback(`Error on remote: ${this._fileProgress} / ${this._fileSize}`);
reject("Error on remote");
}
else if (dataView[0] == 0) {
// ignore no command
progressCallback(`Board is on`);
} }
else { else {
console.log("False"); // no command
// send disagree progressCallback(`Error on remote`);
this.sendEndCmd(false); reject("Error: command does not exist");
progressCallback(`Error, starting over: ${this._fileProgress} / ${this._fileSize}`);
this._fileProgress = 0;
} }
} }, (error) => {
else if (dataView[0] == 15) { reject("Error: Failed to start notify");
// error cmd console.error(error);
progressCallback(`Error on remote: ${this._fileProgress} / ${this._fileSize}`); });
reject("Error on remote"); const buffer = new ArrayBuffer(4);
} let view = new Int32Array(buffer);
else if (dataView[0] == 0) { view[0] = this._fileSize;
// ignore no command this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
progressCallback(`Board is on`);
}
else {
// no command
progressCallback(`Error on remote`);
reject("Error: command does not exist");
}
}, (error) => {
reject("Error: Failed to start notify");
console.error(error);
}); });
const buffer = new ArrayBuffer(4); // start notify
let view = new Int32Array(buffer);
view[0] = this._fileSize;
this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
}); });
} }
} }

104
dist/index.es.js vendored
View File

@@ -199,61 +199,63 @@ class Updater {
// write file length // write file length
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
// set mtu // set mtu
this._packetSize = await this.bleObject.withPromises.requestMtu(this.bleDeviceId, this._packetSize); this.bleObject.requestMtu(this.bleDeviceId, this._packetSize, (mtu) => {
// start notify this._packetSize = mtu;
this.bleObject.startNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, (rawData) => { this.bleObject.startNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, (rawData) => {
let dataView = new Uint8Array(rawData); let dataView = new Uint8Array(rawData);
console.log(dataView); console.log(dataView);
if (dataView[0] == 1) { if (dataView[0] == 1) {
// send file // send file
this.sendNextPacket(); this.sendNextPacket();
progressCallback(`MTU: ${this._packetSize}; Sending (${Math.floor((this._fileProgress * 100) / this._fileSize)}%), ${this._fileProgress} / ${this._fileSize}`); progressCallback(`MTU: ${this._packetSize}; Sending (${Math.floor((this._fileProgress * 100) / this._fileSize)}%), ${this._fileProgress} / ${this._fileSize}`);
} }
else if (dataView[0] == 2) { else if (dataView[0] == 2) {
// done logic // done logic
console.log(`progress >= filesize: ${this._fileProgress} vs ${this._fileSize}`); console.log(`progress >= filesize: ${this._fileProgress} vs ${this._fileSize}`);
if (this._fileProgress >= this._fileSize) { if (this._fileProgress >= this._fileSize) {
console.log("true"); console.log("true");
// send agree // send agree
this.sendEndCmd(true); this.sendEndCmd(true);
progressCallback(`Complete!`); progressCallback(`Complete!`);
this.bleObject.stopNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, () => { this.bleObject.stopNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, () => {
// success // success
resolve(true); resolve(true);
}, (error) => { }, (error) => {
reject("Error: Failed to stop notify"); reject("Error: Failed to stop notify");
}); });
}
else {
console.log("False");
// send disagree
this.sendEndCmd(false);
progressCallback(`Error, starting over: ${this._fileProgress} / ${this._fileSize}`);
this._fileProgress = 0;
}
}
else if (dataView[0] == 15) {
// error cmd
progressCallback(`Error on remote: ${this._fileProgress} / ${this._fileSize}`);
reject("Error on remote");
}
else if (dataView[0] == 0) {
// ignore no command
progressCallback(`Board is on`);
} }
else { else {
console.log("False"); // no command
// send disagree progressCallback(`Error on remote`);
this.sendEndCmd(false); reject("Error: command does not exist");
progressCallback(`Error, starting over: ${this._fileProgress} / ${this._fileSize}`);
this._fileProgress = 0;
} }
} }, (error) => {
else if (dataView[0] == 15) { reject("Error: Failed to start notify");
// error cmd console.error(error);
progressCallback(`Error on remote: ${this._fileProgress} / ${this._fileSize}`); });
reject("Error on remote"); const buffer = new ArrayBuffer(4);
} let view = new Int32Array(buffer);
else if (dataView[0] == 0) { view[0] = this._fileSize;
// ignore no command this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
progressCallback(`Board is on`);
}
else {
// no command
progressCallback(`Error on remote`);
reject("Error: command does not exist");
}
}, (error) => {
reject("Error: Failed to start notify");
console.error(error);
}); });
const buffer = new ArrayBuffer(4); // start notify
let view = new Int32Array(buffer);
view[0] = this._fileSize;
this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
}); });
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "updaterweblibrary", "name": "updaterweblibrary",
"version": "1.0.28", "version": "1.0.29",
"description": "OTA Updater App frontend library", "description": "OTA Updater App frontend library",
"repository": { "repository": {
"type": "git", "type": "git",