bt-sensors-plugin-sk 1.1.0-beta.2.2.3 → 1.1.0-beta.2.2.4

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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/index.js +17 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Bluetooth Sensors for [Signal K](http://www.signalk.org)
2
2
 
3
+ ## BETA 2.2.4
4
+ ### What's New
5
+ Fix to 2.2.3 scan and connect issues. Added Transport option to Config page. Default is Bluetooth LE (was Auto in 2.2.3).
6
+
3
7
  ## BETA 2.2.3
4
8
  ### What's New
5
9
  Support for [JBD/Jiabaida/Xiaoxiang Battery management systems](https://jiabaida-bms.com/), IBeacon and clone devices courtesy of [Arjen R](https://github.com/ArjenR).
package/index.js CHANGED
@@ -4,6 +4,7 @@ const path = require('path')
4
4
  const packageInfo = require("./package.json")
5
5
 
6
6
  const {createBluetooth} = require('node-ble')
7
+ const { Variant } = require('dbus-next')
7
8
  const {bluetooth, destroy} = createBluetooth()
8
9
 
9
10
  const BTSensor = require('./BTSensor.js')
@@ -193,12 +194,15 @@ module.exports = function (app) {
193
194
  properties: {
194
195
  adapter: {title: "Bluetooth adapter",
195
196
  type: "string", default: "hci0"},
197
+ transport: {title: "Transport ",
198
+ type: "string", enum: ["auto","le","bredr"], default: "le", enumNames:["Auto", "LE-Bluetooth Low Energy", "BR/EDR Bluetooth basic rate/enhanced data rate"]},
196
199
 
197
200
  discoveryTimeout: {title: "Default device discovery timeout (in seconds)",
198
201
  type: "integer", default: 30,
199
202
  minimum: 10,
200
203
  maximum: 3600
201
204
  },
205
+
202
206
  discoveryInterval: {title: "Scan for new devices interval (in seconds-- 0 for no new device scanning)",
203
207
  type: "integer",
204
208
  default: 10,
@@ -348,13 +352,23 @@ module.exports = function (app) {
348
352
  })})
349
353
  }
350
354
 
351
- async function startScanner() {
355
+ async function startScanner(transport) {
352
356
 
353
357
  app.debug("Starting scan...");
354
358
  //Use adapter.helper directly to get around Adapter::startDiscovery()
355
359
  //filter options which can cause issues with Device::Connect()
356
360
  //turning off Discovery
357
- try{ await adapter.helper.callMethod('StartDiscovery') } catch (error){
361
+ //try {await adapter.startDiscovery()}
362
+ try{
363
+ if (transport) {
364
+ app.debug(`Setting Bluetooth transport option to ${transport}`)
365
+ await adapter.helper.callMethod('SetDiscoveryFilter', {
366
+ Transport: new Variant('s', transport)
367
+ })
368
+ }
369
+ await adapter.helper.callMethod('StartDiscovery')
370
+ }
371
+ catch (error){
358
372
  app.debug(error)
359
373
  }
360
374
 
@@ -511,7 +525,7 @@ module.exports = function (app) {
511
525
  plugin.uiSchema.adapter={'ui:disabled': (activeAdapters.length==1)}
512
526
 
513
527
 
514
- await startScanner()
528
+ await startScanner(options.transport)
515
529
  if (starts>0){
516
530
  app.debug(`Plugin ${packageInfo.version} restarting...`);
517
531
  if (plugin.schema.properties.peripherals.items.dependencies)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-sensors-plugin-sk",
3
- "version": "1.1.0-beta.2.2.3",
3
+ "version": "1.1.0-beta.2.2.4",
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": {