From 58041b1d9917800412747fd0c4976a3b170c9da6 Mon Sep 17 00:00:00 2001 From: Marcus Westin Date: Mon, 20 Jan 2020 14:08:43 +0000 Subject: [PATCH] moved listening to plejd events --- plejd/ble.bluez.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plejd/ble.bluez.js b/plejd/ble.bluez.js index 1133090..36b4e6a 100644 --- a/plejd/ble.bluez.js +++ b/plejd/ble.bluez.js @@ -160,8 +160,12 @@ class PlejdService extends EventEmitter { setTimeout(async () => { await this.onDeviceConnected(connectedDevice); - await this.adapter.StopDiscovery(); + + // After we've authenticated, we need to hook up the event listener + // for changes to lastData. + this.characteristics.lastDataProperties.on('PropertiesChanged', this.onLastDataUpdated.bind(this)); + this.characteristics.lastData.StartNotify(); }, 2000); } @@ -482,11 +486,6 @@ class PlejdService extends EventEmitter { onDeviceCharacteristicsComplete() { logger('onDeviceCharacteristicsComplete()'); this.authenticate(); - - // After we've authenticated, we need to hook up the event listener - // for changes to lastData. - this.characteristics.lastDataProperties.on('PropertiesChanged', this.onLastDataUpdated.bind(this)); - this.characteristics.lastData.StartNotify(); } async onLastDataUpdated(iface, properties, invalidated) {