(1.0.31) bump
This commit is contained in:
107
dist/index.cjs.js
vendored
107
dist/index.cjs.js
vendored
@@ -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,62 +201,62 @@ 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);
|
||||||
if (dataView[0] == 1) {
|
console.log(dataView);
|
||||||
// send file
|
if (dataView[0] == 1) {
|
||||||
this.sendNextPacket();
|
// send file
|
||||||
progressCallback(`MTU: ${this._packetSize}; Sending (${Math.floor((this._fileProgress * 100) / this._fileSize)}%), ${this._fileProgress} / ${this._fileSize}`);
|
this.sendNextPacket();
|
||||||
}
|
progressCallback(`MTU: ${this._packetSize}; Sending (${Math.floor((this._fileProgress * 100) / this._fileSize)}%), ${this._fileProgress} / ${this._fileSize}`);
|
||||||
else if (dataView[0] == 2) {
|
}
|
||||||
// done logic
|
else if (dataView[0] == 2) {
|
||||||
console.log(`progress >= filesize: ${this._fileProgress} vs ${this._fileSize}`);
|
// done logic
|
||||||
if (this._fileProgress >= this._fileSize) {
|
console.log(`progress >= filesize: ${this._fileProgress} vs ${this._fileSize}`);
|
||||||
console.log("true");
|
if (this._fileProgress >= (this._fileSize - this._packetSize)) {
|
||||||
// send agree
|
console.log("true");
|
||||||
this.sendEndCmd(true);
|
// send agree
|
||||||
progressCallback(`Complete!`);
|
this.sendEndCmd(true);
|
||||||
this.bleObject.stopNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, () => {
|
progressCallback(`Complete!`);
|
||||||
// success
|
this.bleObject.stopNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, () => {
|
||||||
resolve(true);
|
// success
|
||||||
}, (error) => {
|
resolve(true);
|
||||||
reject("Error: Failed to stop notify");
|
}, (error) => {
|
||||||
});
|
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 {
|
||||||
// no command
|
console.log("False");
|
||||||
progressCallback(`Error on remote`);
|
// send disagree
|
||||||
reject("Error: command does not exist");
|
this.sendEndCmd(false);
|
||||||
|
progressCallback(`Error, starting over: ${this._fileProgress} / ${this._fileSize}`);
|
||||||
|
this._fileProgress = 0;
|
||||||
}
|
}
|
||||||
}, (error) => {
|
}
|
||||||
reject("Error: Failed to start notify");
|
else if (dataView[0] == 15) {
|
||||||
console.error(error);
|
// error cmd
|
||||||
});
|
progressCallback(`Error on remote: ${this._fileProgress} / ${this._fileSize}`);
|
||||||
const buffer = new ArrayBuffer(4);
|
reject("Error on remote");
|
||||||
let view = new Int32Array(buffer);
|
}
|
||||||
view[0] = this._fileSize;
|
else if (dataView[0] == 0) {
|
||||||
this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
|
// ignore no command
|
||||||
|
progressCallback(`Board is on`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// should be the file progress
|
||||||
|
let fileProgressView = new Uint32Array(rawData);
|
||||||
|
this._fileProgress += fileProgressView[0];
|
||||||
|
this.sendNextPacket();
|
||||||
|
}
|
||||||
|
}, (error) => {
|
||||||
|
reject("Error: Failed to start notify");
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
// start notify
|
const buffer = new ArrayBuffer(4);
|
||||||
|
let view = new Int32Array(buffer);
|
||||||
|
view[0] = this._fileSize;
|
||||||
|
this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
107
dist/index.es.js
vendored
107
dist/index.es.js
vendored
@@ -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,62 +199,62 @@ 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);
|
||||||
if (dataView[0] == 1) {
|
console.log(dataView);
|
||||||
// send file
|
if (dataView[0] == 1) {
|
||||||
this.sendNextPacket();
|
// send file
|
||||||
progressCallback(`MTU: ${this._packetSize}; Sending (${Math.floor((this._fileProgress * 100) / this._fileSize)}%), ${this._fileProgress} / ${this._fileSize}`);
|
this.sendNextPacket();
|
||||||
}
|
progressCallback(`MTU: ${this._packetSize}; Sending (${Math.floor((this._fileProgress * 100) / this._fileSize)}%), ${this._fileProgress} / ${this._fileSize}`);
|
||||||
else if (dataView[0] == 2) {
|
}
|
||||||
// done logic
|
else if (dataView[0] == 2) {
|
||||||
console.log(`progress >= filesize: ${this._fileProgress} vs ${this._fileSize}`);
|
// done logic
|
||||||
if (this._fileProgress >= this._fileSize) {
|
console.log(`progress >= filesize: ${this._fileProgress} vs ${this._fileSize}`);
|
||||||
console.log("true");
|
if (this._fileProgress >= (this._fileSize - this._packetSize)) {
|
||||||
// send agree
|
console.log("true");
|
||||||
this.sendEndCmd(true);
|
// send agree
|
||||||
progressCallback(`Complete!`);
|
this.sendEndCmd(true);
|
||||||
this.bleObject.stopNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, () => {
|
progressCallback(`Complete!`);
|
||||||
// success
|
this.bleObject.stopNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, () => {
|
||||||
resolve(true);
|
// success
|
||||||
}, (error) => {
|
resolve(true);
|
||||||
reject("Error: Failed to stop notify");
|
}, (error) => {
|
||||||
});
|
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 {
|
||||||
// no command
|
console.log("False");
|
||||||
progressCallback(`Error on remote`);
|
// send disagree
|
||||||
reject("Error: command does not exist");
|
this.sendEndCmd(false);
|
||||||
|
progressCallback(`Error, starting over: ${this._fileProgress} / ${this._fileSize}`);
|
||||||
|
this._fileProgress = 0;
|
||||||
}
|
}
|
||||||
}, (error) => {
|
}
|
||||||
reject("Error: Failed to start notify");
|
else if (dataView[0] == 15) {
|
||||||
console.error(error);
|
// error cmd
|
||||||
});
|
progressCallback(`Error on remote: ${this._fileProgress} / ${this._fileSize}`);
|
||||||
const buffer = new ArrayBuffer(4);
|
reject("Error on remote");
|
||||||
let view = new Int32Array(buffer);
|
}
|
||||||
view[0] = this._fileSize;
|
else if (dataView[0] == 0) {
|
||||||
this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
|
// ignore no command
|
||||||
|
progressCallback(`Board is on`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// should be the file progress
|
||||||
|
let fileProgressView = new Uint32Array(rawData);
|
||||||
|
this._fileProgress += fileProgressView[0];
|
||||||
|
this.sendNextPacket();
|
||||||
|
}
|
||||||
|
}, (error) => {
|
||||||
|
reject("Error: Failed to start notify");
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
// start notify
|
const buffer = new ArrayBuffer(4);
|
||||||
|
let view = new Int32Array(buffer);
|
||||||
|
view[0] = this._fileSize;
|
||||||
|
this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user