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 +7 -6
- package/README.md +1 -1
- package/index.js +1 -0
- package/package.json +1 -1
- package/sensor_classes/JBDBMS.js +9 -13
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
|
-
|
|
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
|
|
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
package/index.js
CHANGED
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.
|
|
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": {
|
package/sensor_classes/JBDBMS.js
CHANGED
|
@@ -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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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(()=>{
|