only add to progress the number of bytes written
This commit is contained in:
@@ -209,10 +209,13 @@ 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;
|
// 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) => {
|
||||||
@@ -246,7 +249,6 @@ export default class Updater {
|
|||||||
this.bleObject.startNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID,
|
this.bleObject.startNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID,
|
||||||
(rawData: ArrayBuffer): void => {
|
(rawData: ArrayBuffer): void => {
|
||||||
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();
|
||||||
|
|||||||
Reference in New Issue
Block a user