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.
@@ -36,9 +36,7 @@ class BankManager extends BTSensor{
36
36
  getManufacturer(){
37
37
  return "Bank Manager"
38
38
  }
39
- hasGATT(){
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
- return new Promise((resolve,reject )=>{ this.deviceConnect().then(async ()=>{
61
- if (!this.gattServer) {
62
- this.gattServer = await this.device.gatt()
63
- this.service = await this.gattServer.getPrimaryService("0000ffe0-0000-1000-8000-00805f9b34fb")
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
- Promise.resolve(this.characteristic.startNotifications().then(()=>{
72
- let data = null
73
- this.characteristic.on('valuechanged', buffer => {
74
- if (buffer.length>0 && buffer[0]==0x23) {
75
- data = Buffer.from(buffer)
76
- } else if (data && buffer.indexOf(0x0d0a)!==-1) {
77
- data=Buffer.concat([data,buffer.subarray(0,buffer.indexOf(0x0d0a)-1)], data.length+buffer.indexOf(0x0d0a)-1)
78
- this.emitDataFrom(data)
79
- data=null
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
- async stopListening(){
87
- super.stopListening()
88
- if (this.characteristic && await this.characteristic.isNotifying()) {
89
- await this.characteristic.stopNotifications()
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
@@ -1,7 +1,7 @@
1
1
  const AbstractBeaconMixin = require("./AbstractBeaconMixin")
2
2
 
3
3
  function getTxPower(){
4
- return (this.app.getSelfPath(this._txPowerPath)?.value??0)-41
4
+ return (this._app.getSelfPath(this._txPowerPath)?.value??0)-41
5
5
  }
6
6
 
7
7
 
@@ -1,6 +1,6 @@
1
1
  const AbstractBeaconMixin = require('./AbstractBeaconMixin')
2
2
  function getTxPower(){
3
- return (this.app.getSelfPath(this._txPowerPath)?.value??0)
3
+ return (this._app.getSelfPath(this._txPowerPath)?.value??0)
4
4
  }
5
5
 
6
6
  class iBeacon extends AbstractBeaconMixin {
@@ -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._initGATTConnection()
99
- await this._initGATTNotifications()
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 _initGATTNotifications(){
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 _initGATTConnection() {
150
- await this.deviceConnect()
151
- const gattServer = await this.device.gatt()
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 init(){
158
-
159
- return await super.init()
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 this.deviceConnect()
252
- const gattServer = await this.device.gatt()
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
- async stopListening(){
260
- super.stopListening()
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
- return new Promise((resolve,reject )=>{ this.deviceConnect().then(async ()=>{
339
- if (!this.gattServer) {
340
- this.gattServer = await this.device.gatt()
341
- this.service = await this.gattServer.getPrimaryService("0000ffe0-0000-1000-8000-00805f9b34fb")
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
- Promise.resolve(this.characteristic.startNotifications().then(()=>{
352
- this.characteristic.on('valuechanged', buffer => {
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 stopListening(){
359
- super.stopListening()
360
- if (this.characteristic && await this.characteristic.isNotifying()) {
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
@@ -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 stopListening(){
208
- super.stopListening()
209
- if (this.rxChar)
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 1 in K", (buffer) => {
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}.temperature1";
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.debug(`${this.getName()}::deactivateGATT`);
439
- if (this.rxChar) {
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
- await super.initGATTConnection(isReconnecting);
455
-
456
- this.rxService = await this.getGATTServer().getPrimaryService(
457
- this.constructor.RX_SERVICE
458
- );
459
- this.rxChar = await this.rxService.getCharacteristic(
460
- this.constructor.RX_CHAR_UUID
461
- );
462
-
463
- await this.rxChar.startNotifications();
464
- await this.getBuffer(0x97);
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
- activate(config, plugin) {
469
- super.activate(config, plugin);
470
- this.initGATTConnection().then(async () => {
471
- await this.getAndEmitBatteryInfo();
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.pollFreq * 1000);
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
- return new Promise((resolve,reject )=>{ this.deviceConnect().then(async ()=>{
156
- if (!this.gattServer) {
157
- this.gattServer = await this.device.gatt()
158
- this.battService = await this.gattServer.getPrimaryService("0000fff0-0000-1000-8000-00805f9b34fb")
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
- Promise.resolve(this.battCharacteristic.startNotifications().then(()=>{
168
- this.battCharacteristic.on('valuechanged', buffer => {
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
- async stopListening(){
175
- super.stopListening()
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
- return new Promise((resolve,reject )=>{ this.deviceConnect().then(async ()=>{
199
- if (!this.gattServer) {
200
- this.gattServer = await this.device.gatt()
201
- this.battService = await this.gattServer.getPrimaryService("0000ffe0-0000-1000-8000-00805f9b34fb")
202
- this.battCharacteristic = await this.battService.getCharacteristic("0000ffe4-0000-1000-8000-00805f9b34fb")
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
- Promise.resolve(this.battCharacteristic.startNotifications().then(()=>{
210
- this.battCharacteristic.on('valuechanged', buffer => {
211
- this.reassemble(buffer)
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
- async stopListening(){
217
- super.stopListening()
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 false
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
- return new Promise((resolve,reject )=>{ this.deviceConnect().then(async ()=>{
85
- if (!this.gattServer) {
86
- this.gattServer = await this.device.gatt()
87
- this.sdpService = await this.gattServer.getPrimaryService("00000000-0000-1000-8000-ec55f9f5b963")
88
- this.sdpCharacteristic = await this.sdpService.getCharacteristic("00000001-0000-1000-8000-ec55f9f5b963")
89
- this.dataService = await this.gattServer.getPrimaryService("00000100-0000-1000-8000-ec55f9f5b963")
90
- this.dataCharacteristics = {
91
- rpm: await this.dataService.getCharacteristic("00000102-0000-1000-8000-ec55f9f5b963"),
92
- coolant: await this.dataService.getCharacteristic("00000103-0000-1000-8000-ec55f9f5b963"),
93
- alternatorVoltage: await this.dataService.getCharacteristic("00000104-0000-1000-8000-ec55f9f5b963"),
94
- runtime: await this.dataService.getCharacteristic("00000106-0000-1000-8000-ec55f9f5b963"),
95
- rate: await this.dataService.getCharacteristic("00000107-0000-1000-8000-ec55f9f5b963"),
96
- level: await this.dataService.getCharacteristic("00000108-0000-1000-8000-ec55f9f5b963"),
97
- pressure: await this.dataService.getCharacteristic("0000010a-0000-1000-8000-ec55f9f5b963")
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
- Promise.resolve(this.dataCharacteristics[c].startNotifications().then(()=>{
107
- this.dataCharacteristics[c].on('valuechanged', buffer => {
108
- this.emitData(c,buffer)
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
- if (this.dataCharacteristics[c] && await this.dataCharacteristics[c].isNotifying()) {
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
@@ -90,7 +90,7 @@ class MopekaTankSensor extends BTSensor{
90
90
  this.addParameter("tankHeight",
91
91
  {
92
92
  title:"height of tank (in mm)",
93
- type:"integer",
93
+ type:"number",
94
94
  unit:"mm",
95
95
  isRequired: true
96
96
  }