minor fixes

This commit is contained in:
Marcus Westin 2020-01-24 10:20:39 +01:00
parent ff1952cd88
commit df4cdc1141
4 changed files with 10 additions and 10 deletions

View file

@ -323,6 +323,10 @@ class PlejdService extends EventEmitter {
}
async write(data, retry = true) {
if (!this.plejdService || !this.characteristics.data) {
return;
}
try {
console.log('plejd-ble: sending ' + data.length + ' byte(s) of data to Plejd');
const encryptedData = this._encryptDecrypt(this.cryptoKey, this.plejdService.addr, data);
@ -480,6 +484,12 @@ class PlejdService extends EventEmitter {
return;
}
if (!this.characteristics.auth) {
console.log('plejd-ble: error: unable to connect to the Plejd mesh.');
this.emit('connectFailed');
return;
}
await this.authenticate();
}