added catch for write error unknown peripheral
This commit is contained in:
parent
74ee9e0c21
commit
dfdc7b4927
1 changed files with 15 additions and 5 deletions
20
plejd/ble.js
20
plejd/ble.js
|
|
@ -315,12 +315,22 @@ class PlejdService extends EventEmitter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptedData = this._encryptDecrypt(this.cryptoKey, this.deviceAddress, data);
|
try {
|
||||||
this.characteristics.data.write(encryptedData, false);
|
const encryptedData = this._encryptDecrypt(this.cryptoKey, this.deviceAddress, data);
|
||||||
|
this.characteristics.data.write(encryptedData, false);
|
||||||
|
|
||||||
let writeData;
|
let writeData;
|
||||||
while ((writeData = this.writeQueue.shift()) !== undefined) {
|
while ((writeData = this.writeQueue.shift()) !== undefined) {
|
||||||
this.characteristics.data.write(this._encryptDecrypt(this.cryptoKey, this.deviceAddress, writeData), false);
|
this.characteristics.data.write(this._encryptDecrypt(this.cryptoKey, this.deviceAddress, writeData), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log('error: writing to plejd: ' + error);
|
||||||
|
console.log('will reconnect and try again.');
|
||||||
|
this.writeQueue.push(data);
|
||||||
|
|
||||||
|
this.disconnect();
|
||||||
|
this.connect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue