(1.0.31) bump

This commit is contained in:
2025-12-01 20:30:50 +00:00
parent b471d0e20f
commit 2017847b9e
3 changed files with 105 additions and 111 deletions

19
dist/index.cjs.js vendored
View File

@@ -178,9 +178,6 @@ class Updater {
// this._fileProgress += this._packetSize; // this._fileProgress += this._packetSize;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.bleObject.writeWithoutResponse(this.bleDeviceId, this._updaterServiceUUID, this._updateFileCharacteristicUUID, packet.buffer, () => { this.bleObject.writeWithoutResponse(this.bleDeviceId, this._updaterServiceUUID, this._updateFileCharacteristicUUID, packet.buffer, () => {
console.log("Wrote");
console.log(packet.length);
this._fileProgress += packet.length;
resolve(true); resolve(true);
}, (error) => { }, (error) => {
this._fileProgress -= this._packetSize; this._fileProgress -= this._packetSize;
@@ -204,10 +201,11 @@ 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.bleObject.requestMtu(this.bleDeviceId, this._packetSize, (mtu) => { this._packetSize = await this.bleObject.withPromises.requestMtu(this.bleDeviceId, this._packetSize);
this._packetSize = mtu; // start notify
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);
if (dataView[0] == 1) { if (dataView[0] == 1) {
// send file // send file
this.sendNextPacket(); this.sendNextPacket();
@@ -216,7 +214,7 @@ class Updater {
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 - this._packetSize)) {
console.log("true"); console.log("true");
// send agree // send agree
this.sendEndCmd(true); this.sendEndCmd(true);
@@ -246,9 +244,10 @@ class Updater {
progressCallback(`Board is on`); progressCallback(`Board is on`);
} }
else { else {
// no command // should be the file progress
progressCallback(`Error on remote`); let fileProgressView = new Uint32Array(rawData);
reject("Error: command does not exist"); this._fileProgress += fileProgressView[0];
this.sendNextPacket();
} }
}, (error) => { }, (error) => {
reject("Error: Failed to start notify"); reject("Error: Failed to start notify");
@@ -259,8 +258,6 @@ class Updater {
view[0] = this._fileSize; view[0] = this._fileSize;
this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer); this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
}); });
// start notify
});
} }
} }

19
dist/index.es.js vendored
View File

@@ -176,9 +176,6 @@ class Updater {
// this._fileProgress += this._packetSize; // this._fileProgress += this._packetSize;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.bleObject.writeWithoutResponse(this.bleDeviceId, this._updaterServiceUUID, this._updateFileCharacteristicUUID, packet.buffer, () => { this.bleObject.writeWithoutResponse(this.bleDeviceId, this._updaterServiceUUID, this._updateFileCharacteristicUUID, packet.buffer, () => {
console.log("Wrote");
console.log(packet.length);
this._fileProgress += packet.length;
resolve(true); resolve(true);
}, (error) => { }, (error) => {
this._fileProgress -= this._packetSize; this._fileProgress -= this._packetSize;
@@ -202,10 +199,11 @@ 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.bleObject.requestMtu(this.bleDeviceId, this._packetSize, (mtu) => { this._packetSize = await this.bleObject.withPromises.requestMtu(this.bleDeviceId, this._packetSize);
this._packetSize = mtu; // start notify
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);
if (dataView[0] == 1) { if (dataView[0] == 1) {
// send file // send file
this.sendNextPacket(); this.sendNextPacket();
@@ -214,7 +212,7 @@ class Updater {
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 - this._packetSize)) {
console.log("true"); console.log("true");
// send agree // send agree
this.sendEndCmd(true); this.sendEndCmd(true);
@@ -244,9 +242,10 @@ class Updater {
progressCallback(`Board is on`); progressCallback(`Board is on`);
} }
else { else {
// no command // should be the file progress
progressCallback(`Error on remote`); let fileProgressView = new Uint32Array(rawData);
reject("Error: command does not exist"); this._fileProgress += fileProgressView[0];
this.sendNextPacket();
} }
}, (error) => { }, (error) => {
reject("Error: Failed to start notify"); reject("Error: Failed to start notify");
@@ -257,8 +256,6 @@ class Updater {
view[0] = this._fileSize; view[0] = this._fileSize;
this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer); this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
}); });
// start notify
});
} }
} }

View File

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