Some debug messages
This commit is contained in:
21
src/index.ts
21
src/index.ts
@@ -238,15 +238,11 @@ export default class Updater {
|
||||
|
||||
// write file length
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const buffer = new ArrayBuffer(4)
|
||||
let view = new Int32Array(buffer);
|
||||
view[0] = this._fileSize;
|
||||
await this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
|
||||
|
||||
// start notify
|
||||
this.bleObject.startNotification(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID,
|
||||
async (rawData: ArrayBuffer): Promise<void> => {
|
||||
let dataView = new Int8Array(rawData);
|
||||
let dataView = new Uint8Array(rawData);
|
||||
console.log(dataView);
|
||||
if (dataView[0] == 1) {
|
||||
// send file
|
||||
await this.sendNextPacket();
|
||||
@@ -277,14 +273,23 @@ export default class Updater {
|
||||
// error cmd
|
||||
progressCallback(`Error on remote`);
|
||||
reject("Error on remote");
|
||||
} else {
|
||||
} else if (dataView[0] == 0) {
|
||||
// ignore no command
|
||||
progressCallback(`Board is on`);
|
||||
}
|
||||
else {
|
||||
// no command
|
||||
progressCallback(`Error on remote`);
|
||||
reject("Error: command does not exist");
|
||||
}
|
||||
}, (error) => { reject("Error: Failed to start notify");
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
);
|
||||
const buffer = new ArrayBuffer(4)
|
||||
let view = new Int32Array(buffer);
|
||||
view[0] = this._fileSize;
|
||||
await this.bleObject.withPromises.write(this.bleDeviceId, this._updaterServiceUUID, this._updaterCommandCharacterisitcUUID, buffer);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user