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
10
plejd/ble.js
10
plejd/ble.js
|
|
@ -315,6 +315,7 @@ class PlejdService extends EventEmitter {
|
|||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const encryptedData = this._encryptDecrypt(this.cryptoKey, this.deviceAddress, data);
|
||||
this.characteristics.data.write(encryptedData, false);
|
||||
|
||||
|
|
@ -323,6 +324,15 @@ class PlejdService extends EventEmitter {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
||||
onAuthenticated() {
|
||||
// Start ping
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue