bt-sensors-plugin-sk 1.2.0-beta.0.1.5 → 1.2.0-beta.0.1.6

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
@@ -284,7 +284,7 @@ class BTSensor extends EventEmitter {
284
284
  *
285
285
  */
286
286
 
287
- initSchema(){
287
+ async initSchema(){
288
288
  this._schema = {
289
289
  properties:{
290
290
  active: {title: "Active", type: "boolean", default: true },
@@ -338,13 +338,13 @@ class BTSensor extends EventEmitter {
338
338
  }
339
339
  async init(){
340
340
  this.currentProperties = await this.constructor.getDeviceProps(this.device)
341
- this.initSchema()
341
+ await this.initSchema()
342
342
 
343
343
  this.initListen()
344
344
  }
345
345
 
346
346
  initListen(){
347
- Promise.resolve(this.listen())
347
+ this.listen()
348
348
  }
349
349
  activate(config, plugin){
350
350
  if (config.paths){
@@ -369,9 +369,8 @@ class BTSensor extends EventEmitter {
369
369
  activateGATT(){
370
370
  this.initGATTConnection().then(async ()=>{
371
371
  this.emitGATT()
372
- if (this.pollFreq){
372
+ if (this.pollFreq)
373
373
  this.initGATTInterval()
374
- }
375
374
  else
376
375
  await this.initGATTNotifications()
377
376
  }).catch((e)=>{
@@ -469,8 +468,10 @@ class BTSensor extends EventEmitter {
469
468
 
470
469
 
471
470
  return connectQueue.enqueue( async ()=>{
472
- this.debug(`Connecting to ${this.getName()}`)
471
+ this.debug(`Connecting... ${this.getName()}`)
473
472
  await this.device.connect()
473
+ this.debug(`Connected to ${this.getName()}`)
474
+
474
475
  try {
475
476
 
476
477
  /* CAUTION: HACK AHEAD
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## What's New
4
4
 
5
- ## 1.2.0-beta-0.1.4
5
+ ## 1.2.0-beta-0.1.5/6
6
6
 
7
7
  Renogy and JBDBMS fixes
8
8
 
package/index.js CHANGED
@@ -276,6 +276,7 @@ module.exports = function (app) {
276
276
 
277
277
  function getSensorInfo(sensor){
278
278
 
279
+
279
280
  return { mac: sensor.getMacAddress(),
280
281
  name: sensor.getName(),
281
282
  domain: sensor.getDomain().name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-sensors-plugin-sk",
3
- "version": "1.2.0-beta.0.1.5",
3
+ "version": "1.2.0-beta.0.1.6",
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, Aranet4 environment sensors, SwitchBot temp and humidity sensors, KilovaultHLXPlus smart batteries, and Govee GVH51xx temp sensors",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -62,11 +62,15 @@ class JBDBMS extends BTSensor {
62
62
  (buffer)=>{return buffer.readUInt8(24)} )
63
63
  .default="electrical.batteries.{batteryID}.FETControl"
64
64
 
65
- await this.deviceConnect()
66
- await this.initCharacteristics()
67
- const cellsAndTemps = await this.getNumberOfCellsAndTemps()
68
- this.numberOfCells=cellsAndTemps.cells
69
- this.numberOfTemps=cellsAndTemps.temps
65
+ await this.deviceConnect()
66
+ const gattServer = await this.device.gatt()
67
+ const txRxService= await gattServer.getPrimaryService(this.constructor.TX_RX_SERVICE)
68
+ this.rxChar = await txRxService.getCharacteristic(this.constructor.NOTIFY_CHAR_UUID)
69
+ this.txChar = await txRxService.getCharacteristic(this.constructor.WRITE_CHAR_UUID)
70
+ await this.rxChar.startNotifications()
71
+ const cellsAndTemps = await this.getNumberOfCellsAndTemps()
72
+ this.numberOfCells=cellsAndTemps.cells
73
+ this.numberOfTemps=cellsAndTemps.temps
70
74
 
71
75
  for (let i=0; i<this.numberOfTemps; i++){
72
76
  this.addMetadatum(`temp${i}`, 'K', `Temperature${i+1} reading`,
@@ -88,14 +92,6 @@ class JBDBMS extends BTSensor {
88
92
  hasGATT(){
89
93
  return true
90
94
  }
91
- async initCharacteristics(){
92
- const gattServer = await this.device.gatt()
93
- const txRxService= await gattServer.getPrimaryService(this.constructor.TX_RX_SERVICE)
94
- this.rxChar = await txRxService.getCharacteristic(this.constructor.NOTIFY_CHAR_UUID)
95
- this.txChar = await txRxService.getCharacteristic(this.constructor.WRITE_CHAR_UUID)
96
- await this.rxChar.startNotifications()
97
- return this
98
- }
99
95
 
100
96
  async initGATTNotifications(){
101
97
  this.intervalID = setInterval(()=>{