From df4cdc1141fca706291ab1463e954ad191bb1d81 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Fri, 24 Jan 2020 10:20:39 +0100 Subject: [PATCH] minor fixes --- plejd/ble.bluez.js | 10 ++++++++++ plejd/mqtt.js | 1 - plejd/package-lock.json | 8 -------- plejd/package.json | 1 - 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plejd/ble.bluez.js b/plejd/ble.bluez.js index a25769b..3ddaa8f 100644 --- a/plejd/ble.bluez.js +++ b/plejd/ble.bluez.js @@ -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(); } diff --git a/plejd/mqtt.js b/plejd/mqtt.js index d9607fa..698b536 100644 --- a/plejd/mqtt.js +++ b/plejd/mqtt.js @@ -39,7 +39,6 @@ const getDiscoveryPayload = device => ({ state_topic: getStateTopic(device), command_topic: getCommandTopic(device), optimistic: false, - retain: true, brightness: `${device.dimmable}`, device: { identifiers: device.serialNumber, diff --git a/plejd/package-lock.json b/plejd/package-lock.json index 4478971..90fb2b8 100644 --- a/plejd/package-lock.json +++ b/plejd/package-lock.json @@ -199,14 +199,6 @@ "type": "^1.0.1" } }, - "dbus": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/dbus/-/dbus-1.0.5.tgz", - "integrity": "sha512-itMup/0lcjnwV4DULJtI8q37Nky713KE2b1QM4+W/0zlzAsMNJZURBtyENtnJc6BlHouqbur++PXWeEKDuGulg==", - "requires": { - "nan": "^2.13.2" - } - }, "dbus-next": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/dbus-next/-/dbus-next-0.8.1.tgz", diff --git a/plejd/package.json b/plejd/package.json index 9e21fea..7d3646f 100644 --- a/plejd/package.json +++ b/plejd/package.json @@ -3,7 +3,6 @@ "@abandonware/bluetooth-hci-socket": "0.5.3-3", "axios": "^0.19.0", "buffer-xor": "^2.0.2", - "dbus": "^1.0.5", "dbus-next": "^0.8.1", "fs": "0.0.1-security", "jspack": "0.0.4",