bt-sensors-plugin-sk 1.2.6-beta-5 → 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 +4 -0
- package/index.js +34 -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 +35 -41
- 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
|
@@ -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
|
}
|
|
@@ -109,7 +109,7 @@ class JikongBMS extends BTSensor {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
async initSchema() {
|
|
114
114
|
super.initSchema();
|
|
115
115
|
this.addDefaultParam("batteryID");
|
|
@@ -131,6 +131,7 @@ class JikongBMS extends BTSensor {
|
|
|
131
131
|
|
|
132
132
|
if (this.numberOfCells == undefined) {
|
|
133
133
|
try {
|
|
134
|
+
this.debug("Getting number of cells...")
|
|
134
135
|
await this.initGATTConnection();
|
|
135
136
|
this.numberOfCells = await this.getNumberOfCells()
|
|
136
137
|
}
|
|
@@ -315,9 +316,9 @@ class JikongBMS extends BTSensor {
|
|
|
315
316
|
}
|
|
316
317
|
).default = "electrical.batteries.{batteryID}.discharging";
|
|
317
318
|
|
|
318
|
-
this.addMetadatum("temp1", "K", "Temperature
|
|
319
|
+
this.addMetadatum("temp1", "K", "Temperature in K", (buffer) => {
|
|
319
320
|
return 273.15 + buffer.readInt16LE(130 + this.offset * 2) / 10;
|
|
320
|
-
}).default = "electrical.batteries.{batteryID}.
|
|
321
|
+
}).default = "electrical.batteries.{batteryID}.temperature";
|
|
321
322
|
|
|
322
323
|
this.addMetadatum("temp2", "K", "Temperature 2 in K", (buffer) => {
|
|
323
324
|
return 273.15 + buffer.readInt16LE(132 + this.offset * 2) / 10;
|
|
@@ -437,70 +438,63 @@ class JikongBMS extends BTSensor {
|
|
|
437
438
|
}
|
|
438
439
|
|
|
439
440
|
async deactivateGATT() {
|
|
440
|
-
this.
|
|
441
|
-
|
|
442
|
-
try {
|
|
443
|
-
await this.rxChar.stopNotifications();
|
|
444
|
-
} catch (e) {
|
|
445
|
-
this.debug(
|
|
446
|
-
`(${this.getName()}) Error stopping notifications for rxChar`
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
441
|
+
await this.stopGATTNotifications(this.rxChar)
|
|
442
|
+
|
|
450
443
|
await super.deactivateGATT();
|
|
451
444
|
}
|
|
452
445
|
|
|
453
446
|
async initGATTConnection(isReconnecting = false) {
|
|
454
447
|
this.debug(`${this.getName()}::initGATTConnection`);
|
|
455
448
|
|
|
456
|
-
await super.initGATTConnection(isReconnecting);
|
|
457
|
-
const gattServer = await this.getGATTServer();
|
|
458
|
-
|
|
459
|
-
this.rxService = await gattServer.getPrimaryService(
|
|
460
|
-
this.constructor.RX_SERVICE
|
|
461
|
-
);
|
|
462
|
-
|
|
463
449
|
if (this.rxChar)
|
|
464
450
|
try {
|
|
451
|
+
this.rxChar.removeAllListeners()
|
|
465
452
|
await this.rxChar.stopNotifications()
|
|
466
453
|
}
|
|
467
454
|
catch(e){
|
|
468
|
-
this.rxChar.removeAllListeners()
|
|
469
|
-
|
|
470
455
|
this.debug(`error while stopping notifications`)
|
|
471
456
|
this.debug(e)
|
|
472
457
|
}
|
|
458
|
+
|
|
459
|
+
try {
|
|
460
|
+
await super.initGATTConnection(isReconnecting);
|
|
461
|
+
const gattServer = await this.getGATTServer();
|
|
473
462
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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();
|
|
477
470
|
|
|
478
|
-
await this.rxChar.startNotifications();
|
|
479
|
-
try {
|
|
480
|
-
await this.getBuffer(0x97)
|
|
481
471
|
} catch (e) {
|
|
482
472
|
this.setError(e.message)
|
|
483
473
|
}
|
|
484
|
-
|
|
474
|
+
|
|
475
|
+
try {
|
|
476
|
+
await this.getBuffer(0x97)
|
|
477
|
+
} catch(e){
|
|
478
|
+
this.debug(`Error encountered calling getBuffer(0x97)`)
|
|
479
|
+
}
|
|
485
480
|
//this.debug(`(${this.getName()}) Connections: ${this.connections++}`)
|
|
486
481
|
}
|
|
487
482
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
try {
|
|
492
|
-
await this.getAndEmitBatteryInfo();
|
|
493
|
-
} catch(e) {
|
|
494
|
-
this.setError(e.message)
|
|
495
|
-
}
|
|
496
|
-
this.intervalID = setInterval(async () => {
|
|
483
|
+
async initGATTInterval(){
|
|
484
|
+
this.intervalID = setInterval(async () => {
|
|
485
|
+
this.setError(false)
|
|
497
486
|
if (!(await this.device.isConnected())) {
|
|
498
487
|
await this.initGATTConnection(true);
|
|
499
488
|
}
|
|
500
489
|
await this.getAndEmitBatteryInfo();
|
|
501
|
-
}, this
|
|
502
|
-
|
|
503
|
-
|
|
490
|
+
}, this?.pollFreq??40 * 1000);
|
|
491
|
+
|
|
492
|
+
try {
|
|
493
|
+
await this.getAndEmitBatteryInfo();
|
|
494
|
+
} catch(e) {
|
|
495
|
+
this.setError(e.message)
|
|
496
|
+
}
|
|
497
|
+
}
|
|
504
498
|
}
|
|
505
499
|
|
|
506
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
|
|
@@ -177,49 +177,41 @@ const BTSensor = require("../BTSensor");
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
|
|
180
|
-
initGATTConnection(){
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this.eventCharacteristic = await this.service.getCharacteristic(this.eventUUID)
|
|
188
|
-
resolve(this)
|
|
189
|
-
}}) .catch((e)=>{ this.debug(e); reject(e.message) }) })
|
|
180
|
+
async initGATTConnection(isReconnecting){
|
|
181
|
+
await super.initGATTConnection(isReconnecting)
|
|
182
|
+
const gattServer = await this.getGATTServer()
|
|
183
|
+
const service = await gattServer.getPrimaryService(this.serviceUUID)
|
|
184
|
+
this.info1Characteristic = await service.getCharacteristic(this.info1CharUUID)
|
|
185
|
+
this.info2Characteristic = await service.getCharacteristic(this.info2CharUUID)
|
|
186
|
+
this.eventCharacteristic = await service.getCharacteristic(this.eventUUID)
|
|
190
187
|
}
|
|
191
188
|
|
|
192
|
-
initGATTNotifications() {
|
|
193
|
-
|
|
189
|
+
async initGATTNotifications() {
|
|
190
|
+
await this.info1Characteristic.startNotifications()
|
|
194
191
|
this.info1Characteristic.on('valuechanged', buffer => {
|
|
195
192
|
this.emitInfo1Data(buffer)
|
|
196
193
|
})
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
194
|
+
|
|
195
|
+
await this.info2Characteristic.startNotifications()
|
|
196
|
+
this.info2Characteristic.on('valuechanged', buffer => {
|
|
200
197
|
this.emitInfo2Data(buffer)
|
|
201
198
|
})
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
|
|
200
|
+
await this.eventCharacteristic.startNotifications()
|
|
204
201
|
this.eventCharacteristic.on('valuechanged', buffer => {
|
|
205
202
|
this.emitEventData(buffer)
|
|
206
203
|
})
|
|
207
|
-
|
|
204
|
+
|
|
208
205
|
}
|
|
209
206
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
super.
|
|
217
|
-
|
|
218
|
-
await this.stopNotifications(this?.info2Characteristic)
|
|
219
|
-
await this.stopNotifications(this?.eventCharacteristic)
|
|
220
|
-
if (await this.device.isConnected()){
|
|
221
|
-
await this.device.disconnect()
|
|
222
|
-
}
|
|
207
|
+
|
|
208
|
+
async deactivateGATT(){
|
|
209
|
+
|
|
210
|
+
await this.stopGATTNotifications(this?.info1Characteristic)
|
|
211
|
+
await this.stopGATTNotifications(this?.info2Characteristic)
|
|
212
|
+
await this.stopGATTNotifications(this?.eventCharacteristic)
|
|
213
|
+
await super.deactivateGATT()
|
|
214
|
+
|
|
223
215
|
}
|
|
224
216
|
}
|
|
225
217
|
module.exports=RemoranWave3
|
|
@@ -92,8 +92,8 @@ class RenogySensor extends BTSensor{
|
|
|
92
92
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
async initGATTConnection() {
|
|
96
|
-
await
|
|
95
|
+
async initGATTConnection(isReconnecting) {
|
|
96
|
+
await super.initGATTConnection(isReconnecting)
|
|
97
97
|
const rw = await this.constructor.getReadWriteCharacteristics(this.device)
|
|
98
98
|
|
|
99
99
|
this.readChar = rw.read
|
|
@@ -108,18 +108,11 @@ class RenogySensor extends BTSensor{
|
|
|
108
108
|
hasGATT(){
|
|
109
109
|
return true
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
super.
|
|
114
|
-
|
|
115
|
-
if (this.readChar)
|
|
116
|
-
await this.readChar.stopNotifications()
|
|
117
|
-
|
|
118
|
-
if (await this.device.isConnected()){
|
|
119
|
-
await this.device.disconnect()
|
|
120
|
-
this.debug(`Disconnected from ${ this.getName()}`)
|
|
121
|
-
}
|
|
111
|
+
async deactivateGATT(){
|
|
112
|
+
await this.stopGATTNotifications(this.readChar)
|
|
113
|
+
await super.deactivateGATT()
|
|
122
114
|
}
|
|
123
115
|
|
|
116
|
+
|
|
124
117
|
}
|
|
125
118
|
module.exports=RenogySensor
|