trying a different way to confirm mtu size
This commit is contained in:
11
src/index.ts
11
src/index.ts
@@ -241,8 +241,8 @@ export default 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: number) => {
|
||||||
// start notify
|
this._packetSize = mtu;
|
||||||
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);
|
||||||
@@ -289,7 +289,8 @@ export default class Updater {
|
|||||||
progressCallback(`Error on remote`);
|
progressCallback(`Error on remote`);
|
||||||
reject("Error: command does not exist");
|
reject("Error: command does not exist");
|
||||||
}
|
}
|
||||||
}, (error) => { reject("Error: Failed to start notify");
|
}, (error) => {
|
||||||
|
reject("Error: Failed to start notify");
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -298,6 +299,10 @@ export default 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
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user