Merge pull request #34 from icanos/dev
added error handling for writing to Plejd
This commit is contained in:
commit
f38c7ebce9
3 changed files with 17 additions and 7 deletions
20
plejd/ble.js
20
plejd/ble.js
|
|
@ -315,12 +315,22 @@ class PlejdService extends EventEmitter {
|
|||
return false;
|
||||
}
|
||||
|
||||
const encryptedData = this._encryptDecrypt(this.cryptoKey, this.deviceAddress, data);
|
||||
this.characteristics.data.write(encryptedData, false);
|
||||
try {
|
||||
const encryptedData = this._encryptDecrypt(this.cryptoKey, this.deviceAddress, data);
|
||||
this.characteristics.data.write(encryptedData, false);
|
||||
|
||||
let writeData;
|
||||
while ((writeData = this.writeQueue.shift()) !== undefined) {
|
||||
this.characteristics.data.write(this._encryptDecrypt(this.cryptoKey, this.deviceAddress, writeData), false);
|
||||
let writeData;
|
||||
while ((writeData = this.writeQueue.shift()) !== undefined) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Plejd",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"slug": "plejd",
|
||||
"description": "Adds support for the Swedish home automation devices from Plejd.",
|
||||
"url": "https://github.com/icanos/hassio-plejd/",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const mqtt = require('./mqtt');
|
|||
const fs = require('fs');
|
||||
const PlejdService = require('./ble');
|
||||
|
||||
const version = "0.2.3";
|
||||
const version = "0.2.4";
|
||||
|
||||
async function main() {
|
||||
console.log('starting Plejd add-on v. ' + version);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue