UNPKG

node-red-contrib-victron-ble

Version:

node-red node to parse Instant Readout advertisement data from Victron BLE devices

22 lines (21 loc) 748 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getBleAdapter = void 0; const noble_adapter_1 = require("./noble-adapter"); const bluetoothctl_adapter_1 = require("./bluetoothctl-adapter"); async function getBleAdapter() { let btctlAdapter = undefined; try { btctlAdapter = new bluetoothctl_adapter_1.BluetoothctlBleAdapter(); await btctlAdapter.startScan(); return btctlAdapter; } catch (err) { // Fallback to noble-based adapter console.log("Try noble-based adapter"); const nobleAdapter = new noble_adapter_1.NobleBleAdapter(); await nobleAdapter.startScan(); return nobleAdapter; } } exports.getBleAdapter = getBleAdapter;