bt-sensors-plugin-sk 1.1.0-beta.2.2.0 → 1.1.0-beta.2.2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/BTSensor.js CHANGED
@@ -374,16 +374,21 @@ class BTSensor extends EventEmitter {
374
374
  * NOTE: The function mucks about with node-ble internal functions to help make sure the
375
375
  * DBUS connection stays alive, doesn't tax resources and doesn't spit out spurious errors.
376
376
  */
377
- initPropertiesChanged(){
377
+ initPropertiesChanged(){
378
378
 
379
379
  this.propertiesChanged.bind(this)
380
380
  this.device.helper._prepare()
381
381
  this.device.helper.on("PropertiesChanged",
382
382
  ((props)=> {
383
- this.propertiesChanged(props)
383
+ try{
384
+ this.propertiesChanged(props)
385
+ }
386
+ catch(error){
387
+ this.debug(`Error occured on ${this.getNameAndAddress()}: ${error?.message??error}`)
388
+ this.debug(error)
389
+ }
384
390
  }))
385
391
  }
386
-
387
392
  //END instance initialization functions
388
393
 
389
394
  //Metadata functions
@@ -569,8 +574,12 @@ class BTSensor extends EventEmitter {
569
574
 
570
575
 
571
576
  listen(){
572
- this.initPropertiesChanged()
573
- this.propertiesChanged(this.currentProperties)
577
+ try{
578
+ this.initPropertiesChanged()
579
+ this.propertiesChanged(this.currentProperties)
580
+ } catch(e){
581
+ this.debug(e)
582
+ }
574
583
  if (this.usingGATT()){
575
584
  this.initGATTConnection().then(async ()=>{
576
585
  this.emitGATT()
package/index.js CHANGED
@@ -102,6 +102,8 @@ module.exports = function (app) {
102
102
  const sensor = new c(device,config?.params, config?.gattParams)
103
103
  sensor.debug=app.debug
104
104
  await sensor.init()
105
+ app.debug(`instantiated ${await BTSensor.getDeviceProp(device,"Address")}`)
106
+
105
107
  return sensor
106
108
  }
107
109
  }} catch(error){
@@ -358,13 +360,16 @@ module.exports = function (app) {
358
360
  createSensor(adapter, deviceConfig).then((sensor)=>{
359
361
  deviceConfig.sensor=sensor
360
362
  if (deviceConfig.active) {
361
- createPaths(deviceConfig)
362
- initPaths(deviceConfig)
363
+ if (deviceConfig.paths){
364
+ createPaths(deviceConfig)
365
+ initPaths(deviceConfig)
366
+ }
363
367
  const result = Promise.resolve(deviceConfig.sensor.listen())
364
368
  result.then(() => {
365
369
  app.debug(`Listening for changes from ${deviceConfig.sensor.getDisplayName()}`);
366
370
  app.setPluginStatus(`Initial scan complete. Listening to ${++found} sensors.`);
367
371
  })
372
+
368
373
  }
369
374
 
370
375
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-sensors-plugin-sk",
3
- "version": "1.1.0-beta.2.2.0",
3
+ "version": "1.1.0-beta.2.2.0.1",
4
4
  "description": "Bluetooth Sensors for Signalk -- support for Victron devices, RuuviTag, Xiaomi, ATC and Inkbird, Ultrasonic wind meters, Mopeka tank readers, Renogy Battery and Solar Controllers (new), Aranet4 environment sensors, and Govee GVH51xx temp sensors",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -64,7 +64,7 @@ function sleep(x) {
64
64
 
65
65
  decrypt(data){
66
66
  if (!this.encryptionKey)
67
- throw Error("Unable to decrypt: no encryption key set")
67
+ throw new Error("Unable to decrypt: no encryption key set")
68
68
 
69
69
  const encMethod = 'aes-128-ctr';
70
70
  const iv = data.readUInt16LE(5);
@@ -166,6 +166,9 @@ class XiaomiMiBeacon extends BTSensor{
166
166
  if (this.usingGATT()) return
167
167
  const data = this.getServiceData(this.constructor.SERVICE_MIBEACON)
168
168
  var dec
169
+ if (!this.encryptionKey){
170
+ throw new Error(`${this.getNameAndAddress()} requires an encryption key.`)
171
+ }
169
172
  if (this.encryptionVersion >= 4) {
170
173
  dec = this.decryptV4and5(data)
171
174
  } else {