bt-sensors-plugin-sk 1.2.6-beta-4 → 1.2.6-beta-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 +120 -85
- package/README.md +9 -1
- package/index.js +43 -19
- package/package.json +2 -2
- package/public/847.js +1 -1
- package/sensor_classes/BankManager.js +23 -35
- package/sensor_classes/Beacon/Eddystone.js +1 -1
- package/sensor_classes/Beacon/iBeacon.js +1 -1
- package/sensor_classes/EcoWorthyBW02.js +13 -20
- package/sensor_classes/EctiveBMS.js +8 -11
- package/sensor_classes/GobiusCTankMeter.js +13 -26
- package/sensor_classes/JBDBMS.js +7 -10
- package/sensor_classes/JikongBMS.js +51 -32
- package/sensor_classes/Junctek.js +13 -24
- package/sensor_classes/KilovaultHLXPlus.js +16 -25
- package/sensor_classes/MercurySmartcraft.js +26 -36
- package/sensor_classes/MopekaTankSensor.js +1 -1
- package/sensor_classes/RemoranWave3.js +23 -31
- package/sensor_classes/Renogy/RenogySensor.js +6 -13
- package/sensor_classes/ShenzhenLiOnBMS.js +11 -23
- package/sensor_classes/UltrasonicWindMeter.js +26 -43
- package/sensor_classes/XiaomiMiBeacon.js +10 -27
- package/src/components/PluginConfigurationPanel.js +1 -2
|
@@ -36,9 +36,7 @@ class BankManager extends BTSensor{
|
|
|
36
36
|
getManufacturer(){
|
|
37
37
|
return "Bank Manager"
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
39
|
+
|
|
42
40
|
usingGATT(){
|
|
43
41
|
return true
|
|
44
42
|
}
|
|
@@ -49,48 +47,38 @@ class BankManager extends BTSensor{
|
|
|
49
47
|
this.emit("current", parseFloat(data[3]))
|
|
50
48
|
this.emit("soc", parseFloat(data[4])/100)
|
|
51
49
|
this.emit("connectionStatus", parseInt(data[5]))
|
|
52
|
-
|
|
53
50
|
}
|
|
51
|
+
|
|
54
52
|
emitGATT(){
|
|
55
53
|
|
|
56
54
|
}
|
|
57
55
|
ImageFile = "BankManager.webp"
|
|
58
56
|
|
|
59
|
-
initGATTConnection(){
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.characteristic = await this.service.getCharacteristic("0000ffe1-0000-1000-8000-00805f9b34fb")
|
|
65
|
-
}
|
|
66
|
-
resolve(this)
|
|
67
|
-
}) .catch((e)=>{ reject(e.message) }) })
|
|
57
|
+
async initGATTConnection(isReconnecting){
|
|
58
|
+
await super.initGATTConnection(isReconnecting)
|
|
59
|
+
const gattServer= await this.getGATTServer()
|
|
60
|
+
const service = await gattServer.getPrimaryService("0000ffe0-0000-1000-8000-00805f9b34fb")
|
|
61
|
+
this.characteristic = await service.getCharacteristic("0000ffe1-0000-1000-8000-00805f9b34fb")
|
|
68
62
|
}
|
|
69
63
|
|
|
70
|
-
initGATTNotifications() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}))
|
|
83
|
-
|
|
64
|
+
async initGATTNotifications() {
|
|
65
|
+
await this.characteristic.startNotifications()
|
|
66
|
+
let data = null
|
|
67
|
+
this.characteristic.on('valuechanged', buffer => {
|
|
68
|
+
if (buffer.length>0 && buffer[0]==0x23) {
|
|
69
|
+
data = Buffer.from(buffer)
|
|
70
|
+
} else if (data && buffer.indexOf(0x0d0a)!==-1) {
|
|
71
|
+
data=Buffer.concat([data,buffer.subarray(0,buffer.indexOf(0x0d0a)-1)], data.length+buffer.indexOf(0x0d0a)-1)
|
|
72
|
+
this.emitDataFrom(data)
|
|
73
|
+
data=null
|
|
74
|
+
}
|
|
75
|
+
})
|
|
84
76
|
}
|
|
85
77
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
if (await this.device.isConnected()){
|
|
92
|
-
await this.device.disconnect()
|
|
93
|
-
}
|
|
78
|
+
|
|
79
|
+
async deactivateGATT(){
|
|
80
|
+
await this.stopGATTNotifications(this.characteristic)
|
|
81
|
+
await this.deactivateGATT()
|
|
94
82
|
}
|
|
95
83
|
}
|
|
96
84
|
module.exports=BankManager
|
|
@@ -95,8 +95,8 @@ class EcoWorthyBW02 extends BTSensor {
|
|
|
95
95
|
this.addDefaultPath('SOC','electrical.batteries.capacity.stateOfCharge')
|
|
96
96
|
.read=(buffer)=>{return buffer.readUInt16BE(16)/100}
|
|
97
97
|
|
|
98
|
-
await this.
|
|
99
|
-
await this.
|
|
98
|
+
await this.initGATTConnection()
|
|
99
|
+
await this.initGATTNotifications()
|
|
100
100
|
await waitForVariable(this,"numberOfTemps")
|
|
101
101
|
await waitForVariable(this,"numberOfCells")
|
|
102
102
|
|
|
@@ -118,8 +118,11 @@ class EcoWorthyBW02 extends BTSensor {
|
|
|
118
118
|
hasGATT(){
|
|
119
119
|
return true
|
|
120
120
|
}
|
|
121
|
+
usingGATT(){
|
|
122
|
+
return true
|
|
123
|
+
}
|
|
121
124
|
|
|
122
|
-
async
|
|
125
|
+
async initGATTNotifications(){
|
|
123
126
|
await this.rxChar.startNotifications()
|
|
124
127
|
|
|
125
128
|
this.rxChar.on("valuechanged", (buffer)=>{
|
|
@@ -146,27 +149,17 @@ class EcoWorthyBW02 extends BTSensor {
|
|
|
146
149
|
}
|
|
147
150
|
})
|
|
148
151
|
}
|
|
149
|
-
async
|
|
150
|
-
await
|
|
151
|
-
const gattServer = await this.
|
|
152
|
+
async initGATTConnection(isReconnecting) {
|
|
153
|
+
await super.initGATTConnection(isReconnecting)
|
|
154
|
+
const gattServer = await this.getGATTServer()
|
|
152
155
|
const txRxService= await gattServer.getPrimaryService(this.constructor.TX_RX_SERVICE)
|
|
153
156
|
this.rxChar = await txRxService.getCharacteristic(this.constructor.NOTIFY_CHAR_UUID)
|
|
154
157
|
return this
|
|
155
158
|
}
|
|
156
159
|
|
|
157
|
-
async
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async stopListening(){
|
|
164
|
-
super.stopListening()
|
|
165
|
-
if (this.rxChar)
|
|
166
|
-
this.rxChar.stopNotifications()
|
|
167
|
-
if (this.device)
|
|
168
|
-
await this.device.disconnect()
|
|
169
|
-
}
|
|
170
|
-
|
|
160
|
+
async deactivateGATT(){
|
|
161
|
+
await this.stopGATTNotifications(this.rxChar)
|
|
162
|
+
await super.deactivateGATT()
|
|
163
|
+
}
|
|
171
164
|
}
|
|
172
165
|
module.exports = EcoWorthyBW02;
|
|
@@ -35,7 +35,6 @@ const testData=[
|
|
|
35
35
|
]
|
|
36
36
|
class EctiveDataManager extends EventEmitter{
|
|
37
37
|
static expectedLength = 120
|
|
38
|
-
static ImageFile = "TopbandBattery.webp"
|
|
39
38
|
buffer = Buffer.from([])
|
|
40
39
|
|
|
41
40
|
delimitedAt(data){
|
|
@@ -91,6 +90,7 @@ class EctiveData{
|
|
|
91
90
|
}
|
|
92
91
|
class EctiveBMS extends BTSensor {
|
|
93
92
|
static Domain = BTSensor.SensorDomains.electrical
|
|
93
|
+
static ImageFile = "TopbandBattery.webp"
|
|
94
94
|
|
|
95
95
|
static RX_SERVICE = "0000ffe0-0000-1000-8000-00805f9b34fb"
|
|
96
96
|
static NOTIFY_CHAR_UUID = "0000ffe4-0000-1000-8000-00805f9b34fb"
|
|
@@ -246,23 +246,20 @@ emitGATT(){
|
|
|
246
246
|
} )
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
async initGATTConnection() {
|
|
249
|
+
async initGATTConnection(isReconnecting) {
|
|
250
250
|
|
|
251
|
-
await
|
|
252
|
-
const gattServer = await this.
|
|
251
|
+
await super.initGATTConnection(isReconnecting)
|
|
252
|
+
const gattServer = await this.getGATTServer()
|
|
253
253
|
const rxService= await gattServer.getPrimaryService(this.constructor.RX_SERVICE)
|
|
254
254
|
this.rxChar = await rxService.getCharacteristic(this.constructor.NOTIFY_CHAR_UUID)
|
|
255
255
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
super.
|
|
261
|
-
if (this.rxChar)
|
|
262
|
-
this.rxChar.stopNotifications()
|
|
263
|
-
if (this.device)
|
|
264
|
-
await this.device.disconnect()
|
|
258
|
+
async deactivateGATT(){
|
|
259
|
+
await this.stopGATTNotifications(this.rxChar)
|
|
260
|
+
await super.deactivateGATT()
|
|
265
261
|
}
|
|
262
|
+
|
|
266
263
|
|
|
267
264
|
}
|
|
268
265
|
|
|
@@ -334,36 +334,23 @@ class GobiusCTankMeter extends BTSensor{
|
|
|
334
334
|
this.getJSONSchema().properties.params.required=["type" ]
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
initGATTConnection(){
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
this.characteristic = await this.service.getCharacteristic("0000ffe9-0000-1000-8000-00805f9b34fb")
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
resolve(this)
|
|
347
|
-
}).catch((e)=>{ reject(e.message) }) })
|
|
348
|
-
|
|
337
|
+
async initGATTConnection(isReconnecting){
|
|
338
|
+
await super.initGATTConnection(isReconnecting)
|
|
339
|
+
const gattServer = await this.getGATTServer()
|
|
340
|
+
const service = await gattServer.getPrimaryService("0000ffe0-0000-1000-8000-00805f9b34fb")
|
|
341
|
+
this.characteristic = await service.getCharacteristic("0000ffe9-0000-1000-8000-00805f9b34fb")
|
|
349
342
|
}
|
|
350
|
-
initGATTNotifications() {
|
|
351
|
-
|
|
352
|
-
|
|
343
|
+
async initGATTNotifications() {
|
|
344
|
+
await this.characteristic.startNotifications()
|
|
345
|
+
this.characteristic.on('valuechanged', buffer => {
|
|
353
346
|
this.emitValuesFrom(buffer)
|
|
354
|
-
|
|
355
|
-
}))
|
|
347
|
+
})
|
|
356
348
|
}
|
|
357
349
|
|
|
358
|
-
async
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
await this.characteristic.stopNotifications()
|
|
362
|
-
this.characteristic=null
|
|
363
|
-
}
|
|
364
|
-
if (await this.device.isConnected()){
|
|
365
|
-
await this.device.disconnect()
|
|
366
|
-
}
|
|
350
|
+
async deactivateGATT(){
|
|
351
|
+
await this.stopNotifications(this.characteristic)
|
|
352
|
+
await super.deactivateGATT()
|
|
367
353
|
}
|
|
354
|
+
|
|
368
355
|
}
|
|
369
356
|
module.exports=GobiusCTankMeter
|
package/sensor_classes/JBDBMS.js
CHANGED
|
@@ -107,7 +107,7 @@ class JBDBMS extends BTSensor {
|
|
|
107
107
|
usingGATT(){
|
|
108
108
|
return true
|
|
109
109
|
}
|
|
110
|
-
initGATTNotifications(){
|
|
110
|
+
async initGATTNotifications(){
|
|
111
111
|
this.intervalID = setInterval( async ()=>{
|
|
112
112
|
await this.emitGATT()
|
|
113
113
|
}, 1000*(this?.pollFreq??60) )
|
|
@@ -198,18 +198,15 @@ async getAndEmitCellVoltages(){
|
|
|
198
198
|
}})
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
initGATTInterval(){
|
|
201
|
+
async initGATTInterval(){
|
|
202
202
|
|
|
203
|
-
this.emitGATT()
|
|
204
|
-
this.initGATTNotifications()
|
|
203
|
+
await this.emitGATT()
|
|
204
|
+
await this.initGATTNotifications()
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
async
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
this.rxChar.stopNotifications()
|
|
211
|
-
if (this.device)
|
|
212
|
-
await this.device.disconnect()
|
|
207
|
+
async deactivateGATT(){
|
|
208
|
+
await this.stopGATTNotifications(this.rxChar)
|
|
209
|
+
await super.deactivateGATT()
|
|
213
210
|
}
|
|
214
211
|
|
|
215
212
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { ThemeProvider } = require("react-bootstrap");
|
|
1
2
|
const BTSensor = require("../BTSensor");
|
|
2
3
|
let FakeDevice,FakeGATTService,FakeGATTCharacteristic;
|
|
3
4
|
|
|
@@ -108,6 +109,7 @@ class JikongBMS extends BTSensor {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
|
|
111
113
|
async initSchema() {
|
|
112
114
|
super.initSchema();
|
|
113
115
|
this.addDefaultParam("batteryID");
|
|
@@ -129,6 +131,7 @@ class JikongBMS extends BTSensor {
|
|
|
129
131
|
|
|
130
132
|
if (this.numberOfCells == undefined) {
|
|
131
133
|
try {
|
|
134
|
+
this.debug("Getting number of cells...")
|
|
132
135
|
await this.initGATTConnection();
|
|
133
136
|
this.numberOfCells = await this.getNumberOfCells()
|
|
134
137
|
}
|
|
@@ -313,9 +316,9 @@ class JikongBMS extends BTSensor {
|
|
|
313
316
|
}
|
|
314
317
|
).default = "electrical.batteries.{batteryID}.discharging";
|
|
315
318
|
|
|
316
|
-
this.addMetadatum("temp1", "K", "Temperature
|
|
319
|
+
this.addMetadatum("temp1", "K", "Temperature in K", (buffer) => {
|
|
317
320
|
return 273.15 + buffer.readInt16LE(130 + this.offset * 2) / 10;
|
|
318
|
-
}).default = "electrical.batteries.{batteryID}.
|
|
321
|
+
}).default = "electrical.batteries.{batteryID}.temperature";
|
|
319
322
|
|
|
320
323
|
this.addMetadatum("temp2", "K", "Temperature 2 in K", (buffer) => {
|
|
321
324
|
return 273.15 + buffer.readInt16LE(132 + this.offset * 2) / 10;
|
|
@@ -435,47 +438,63 @@ class JikongBMS extends BTSensor {
|
|
|
435
438
|
}
|
|
436
439
|
|
|
437
440
|
async deactivateGATT() {
|
|
438
|
-
this.
|
|
439
|
-
|
|
440
|
-
try {
|
|
441
|
-
await this.rxChar.stopNotifications();
|
|
442
|
-
} catch (e) {
|
|
443
|
-
this.debug(
|
|
444
|
-
`(${this.getName()}) Error stopping notifications for rxChar`
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
441
|
+
await this.stopGATTNotifications(this.rxChar)
|
|
442
|
+
|
|
448
443
|
await super.deactivateGATT();
|
|
449
444
|
}
|
|
450
445
|
|
|
451
446
|
async initGATTConnection(isReconnecting = false) {
|
|
452
447
|
this.debug(`${this.getName()}::initGATTConnection`);
|
|
453
448
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
449
|
+
if (this.rxChar)
|
|
450
|
+
try {
|
|
451
|
+
this.rxChar.removeAllListeners()
|
|
452
|
+
await this.rxChar.stopNotifications()
|
|
453
|
+
}
|
|
454
|
+
catch(e){
|
|
455
|
+
this.debug(`error while stopping notifications`)
|
|
456
|
+
this.debug(e)
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
try {
|
|
460
|
+
await super.initGATTConnection(isReconnecting);
|
|
461
|
+
const gattServer = await this.getGATTServer();
|
|
462
|
+
|
|
463
|
+
this.rxService = await gattServer.getPrimaryService(
|
|
464
|
+
this.constructor.RX_SERVICE
|
|
465
|
+
);
|
|
466
|
+
this.rxChar = await this.rxService.getCharacteristic(
|
|
467
|
+
this.constructor.RX_CHAR_UUID
|
|
468
|
+
);
|
|
469
|
+
await this.rxChar.startNotifications();
|
|
470
|
+
|
|
471
|
+
} catch (e) {
|
|
472
|
+
this.setError(e.message)
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
try {
|
|
476
|
+
await this.getBuffer(0x97)
|
|
477
|
+
} catch(e){
|
|
478
|
+
this.debug(`Error encountered calling getBuffer(0x97)`)
|
|
479
|
+
}
|
|
465
480
|
//this.debug(`(${this.getName()}) Connections: ${this.connections++}`)
|
|
466
481
|
}
|
|
467
482
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
this.intervalID = setInterval(async () => {
|
|
473
|
-
if (!(await this.device.isConnected()))
|
|
483
|
+
async initGATTInterval(){
|
|
484
|
+
this.intervalID = setInterval(async () => {
|
|
485
|
+
this.setError(false)
|
|
486
|
+
if (!(await this.device.isConnected())) {
|
|
474
487
|
await this.initGATTConnection(true);
|
|
488
|
+
}
|
|
475
489
|
await this.getAndEmitBatteryInfo();
|
|
476
|
-
}, this
|
|
477
|
-
|
|
478
|
-
|
|
490
|
+
}, this?.pollFreq??40 * 1000);
|
|
491
|
+
|
|
492
|
+
try {
|
|
493
|
+
await this.getAndEmitBatteryInfo();
|
|
494
|
+
} catch(e) {
|
|
495
|
+
this.setError(e.message)
|
|
496
|
+
}
|
|
497
|
+
}
|
|
479
498
|
}
|
|
480
499
|
|
|
481
500
|
module.exports = JikongBMS;
|
|
@@ -151,35 +151,24 @@ class JunctekBMS extends BTSensor{
|
|
|
151
151
|
this.emitFrom(buffer)
|
|
152
152
|
})*/
|
|
153
153
|
}
|
|
154
|
-
initGATTConnection(){
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this.battCharacteristic = await this.battService.getCharacteristic("0000fff1-0000-1000-8000-00805f9b34fb")
|
|
154
|
+
async initGATTConnection(isReconnecting){
|
|
155
|
+
super.initGATTConnection(isReconnecting)
|
|
156
|
+
const gattServer = await this.getGATTServer()
|
|
157
|
+
const battService = await gattServer.getPrimaryService("0000fff0-0000-1000-8000-00805f9b34fb")
|
|
158
|
+
this.battCharacteristic = await battService.getCharacteristic("0000fff1-0000-1000-8000-00805f9b34fb")
|
|
160
159
|
|
|
161
|
-
}
|
|
162
|
-
resolve(this)
|
|
163
|
-
}) .catch((e)=>{ reject(e.message) }) })
|
|
164
160
|
}
|
|
165
161
|
|
|
166
|
-
initGATTNotifications() {
|
|
167
|
-
|
|
168
|
-
|
|
162
|
+
async initGATTNotifications() {
|
|
163
|
+
this.battCharacteristic.startNotifications()
|
|
164
|
+
this.battCharacteristic.on('valuechanged', buffer => {
|
|
169
165
|
this.emitFrom(buffer)
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
})
|
|
167
|
+
|
|
172
168
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
super.
|
|
176
|
-
if (this.battCharacteristic && await this.battCharacteristic.isNotifying()) {
|
|
177
|
-
await this.battCharacteristic.stopNotifications()
|
|
178
|
-
this.battCharacteristic=null
|
|
179
|
-
}
|
|
180
|
-
if (await this.device.isConnected()){
|
|
181
|
-
await this.device.disconnect()
|
|
182
|
-
}
|
|
169
|
+
async deactivateGATT(){
|
|
170
|
+
await this.stopGATTNotifications(this.battCharacteristic)
|
|
171
|
+
await super.deactivateGATT()
|
|
183
172
|
}
|
|
184
173
|
}
|
|
185
174
|
module.exports=JunctekBMS
|
|
@@ -194,34 +194,25 @@ class KilovaultHLXPlus extends BTSensor{
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
initGATTConnection(){
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
resolve(this)
|
|
205
|
-
}) .catch((e)=>{ reject(e.message) }) })
|
|
197
|
+
async initGATTConnection(isReconnecting){
|
|
198
|
+
await super.initGATTConnection(isReconnecting)
|
|
199
|
+
const gattServer= this.getGATTServer()
|
|
200
|
+
|
|
201
|
+
this.battService = await gattServer.getPrimaryService("0000ffe0-0000-1000-8000-00805f9b34fb")
|
|
202
|
+
this.battCharacteristic = await battService.getCharacteristic("0000ffe4-0000-1000-8000-00805f9b34fb")
|
|
206
203
|
}
|
|
207
204
|
|
|
208
|
-
initGATTNotifications() {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
205
|
+
async initGATTNotifications() {
|
|
206
|
+
await this.battCharacteristic.startNotifications()
|
|
207
|
+
this.battCharacteristic.on('valuechanged', buffer => {
|
|
208
|
+
this.reassemble(buffer)
|
|
209
|
+
})
|
|
210
|
+
|
|
214
211
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
super.
|
|
218
|
-
if (this.battCharacteristic && await this.battCharacteristic.isNotifying()) {
|
|
219
|
-
await this.battCharacteristic.stopNotifications()
|
|
220
|
-
this.battCharacteristic=null
|
|
221
|
-
}
|
|
222
|
-
if (await this.device.isConnected()){
|
|
223
|
-
await this.device.disconnect()
|
|
224
|
-
}
|
|
212
|
+
async deactivateGATT(){
|
|
213
|
+
await this.stopGATTNotifications(this.battCharacteristic)
|
|
214
|
+
await super.deactivateGATT()
|
|
225
215
|
}
|
|
216
|
+
|
|
226
217
|
}
|
|
227
218
|
module.exports=KilovaultHLXPlus
|
|
@@ -28,10 +28,8 @@ class MercurySmartcraft extends BTSensor{
|
|
|
28
28
|
}
|
|
29
29
|
static ImageFile = "MercurySmartcraft.jpg"
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
31
|
hasGATT(){
|
|
34
|
-
return
|
|
32
|
+
return true
|
|
35
33
|
}
|
|
36
34
|
usingGATT(){
|
|
37
35
|
return true
|
|
@@ -80,48 +78,40 @@ class MercurySmartcraft extends BTSensor{
|
|
|
80
78
|
).default='tanks.petrol.currentLevel'
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
initGATTConnection(){
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
resolve(this)
|
|
101
|
-
}) .catch((e)=>{ reject(e.message) }) })
|
|
81
|
+
async initGATTConnection(isReconnecting){
|
|
82
|
+
await super.initGATTConnection(isReconnecting)
|
|
83
|
+
|
|
84
|
+
const gattServer = await this.getGATTServer()
|
|
85
|
+
this.sdpService = await gattServer.getPrimaryService("00000000-0000-1000-8000-ec55f9f5b963")
|
|
86
|
+
this.sdpCharacteristic = await this.sdpService.getCharacteristic("00000001-0000-1000-8000-ec55f9f5b963")
|
|
87
|
+
this.dataService = await gattServer.getPrimaryService("00000100-0000-1000-8000-ec55f9f5b963")
|
|
88
|
+
this.dataCharacteristics = {
|
|
89
|
+
rpm: await this.dataService.getCharacteristic("00000102-0000-1000-8000-ec55f9f5b963"),
|
|
90
|
+
coolant: await this.dataService.getCharacteristic("00000103-0000-1000-8000-ec55f9f5b963"),
|
|
91
|
+
alternatorVoltage: await this.dataService.getCharacteristic("00000104-0000-1000-8000-ec55f9f5b963"),
|
|
92
|
+
runtime: await this.dataService.getCharacteristic("00000106-0000-1000-8000-ec55f9f5b963"),
|
|
93
|
+
rate: await this.dataService.getCharacteristic("00000107-0000-1000-8000-ec55f9f5b963"),
|
|
94
|
+
level: await this.dataService.getCharacteristic("00000108-0000-1000-8000-ec55f9f5b963"),
|
|
95
|
+
pressure: await this.dataService.getCharacteristic("0000010a-0000-1000-8000-ec55f9f5b963")
|
|
96
|
+
}
|
|
97
|
+
|
|
102
98
|
}
|
|
103
99
|
async initGATTNotifications() {
|
|
104
100
|
await this.sdpCharacteristic.writeValue(Buffer.from([0x0D,0x01]))
|
|
105
101
|
for (const c in this.dataCharacteristics){
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}))
|
|
102
|
+
await this.dataCharacteristics[c].startNotifications()
|
|
103
|
+
this.dataCharacteristics[c].on('valuechanged', buffer => {
|
|
104
|
+
this.emitData(c,buffer)
|
|
105
|
+
})
|
|
111
106
|
}
|
|
112
107
|
}
|
|
113
|
-
|
|
114
|
-
async stopListening(){
|
|
115
|
-
super.stopListening()
|
|
108
|
+
async deactivateGATT(){
|
|
116
109
|
for (const c in this.dataCharacteristics){
|
|
117
|
-
|
|
118
|
-
await this.dataCharacteristics[c].stopNotifications()
|
|
119
|
-
}
|
|
110
|
+
await this.stopGATTNotifications(c)
|
|
120
111
|
}
|
|
112
|
+
await super.deactivateGATT()
|
|
121
113
|
|
|
122
|
-
if (await this.device.isConnected()){
|
|
123
|
-
await this.device.disconnect()
|
|
124
|
-
}
|
|
125
114
|
}
|
|
115
|
+
|
|
126
116
|
}
|
|
127
117
|
module.exports=MercurySmartcraft
|