do file progress counter preemtively
This commit is contained in:
@@ -209,13 +209,14 @@ export default class Updater {
|
|||||||
|
|
||||||
private async sendNextPacket(): Promise<boolean> {
|
private async sendNextPacket(): Promise<boolean> {
|
||||||
let packet = this.file.slice(this._fileProgress, this._fileProgress+this._packetSize);
|
let packet = this.file.slice(this._fileProgress, this._fileProgress+this._packetSize);
|
||||||
|
this._fileProgress += this._packetSize;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.bleObject.write(this.bleDeviceId, this._updaterServiceUUID, this._updateFileCharacteristicUUID, packet.buffer,
|
this.bleObject.write(this.bleDeviceId, this._updaterServiceUUID, this._updateFileCharacteristicUUID, packet.buffer,
|
||||||
() => {
|
() => {
|
||||||
this._fileProgress += this._packetSize;
|
|
||||||
resolve(true);
|
resolve(true);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
this._fileProgress -= this._packetSize;
|
||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user