incyclist-devices 1.5.38 → 2.0.0
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/README.MD +238 -0
- package/lib/adapters.d.ts +7 -0
- package/lib/adapters.js +49 -0
- package/lib/antv2/adapter-factory.d.ts +21 -10
- package/lib/antv2/adapter-factory.js +51 -33
- package/lib/antv2/adapter.d.ts +65 -0
- package/lib/antv2/adapter.js +310 -0
- package/lib/antv2/ant-interface.d.ts +17 -11
- package/lib/antv2/ant-interface.js +41 -31
- package/lib/antv2/{ant-binding.d.ts → binding.d.ts} +1 -1
- package/lib/antv2/{ant-binding.js → binding.js} +1 -1
- package/lib/antv2/fe/adapter.d.ts +28 -0
- package/lib/antv2/{fe.js → fe/adapter.js} +106 -90
- package/lib/antv2/fe/index.d.ts +2 -0
- package/lib/antv2/fe/index.js +7 -0
- package/lib/antv2/hr/adapter.d.ts +15 -0
- package/lib/antv2/hr/adapter.js +76 -0
- package/lib/antv2/hr/index.d.ts +2 -0
- package/lib/antv2/hr/index.js +7 -0
- package/lib/antv2/index.d.ts +7 -0
- package/lib/antv2/index.js +20 -0
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +9 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-adv-st-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +6 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-erg-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +5 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-st-mode.js +1 -1
- package/lib/antv2/pwr/adapter.d.ts +24 -0
- package/lib/antv2/pwr/adapter.js +141 -0
- package/lib/antv2/pwr/index.d.ts +2 -0
- package/lib/antv2/pwr/index.js +7 -0
- package/lib/antv2/sensor-factory.d.ts +2 -2
- package/lib/antv2/types.d.ts +22 -0
- package/lib/antv2/types.js +5 -0
- package/lib/antv2/utils.d.ts +4 -0
- package/lib/antv2/utils.js +192 -0
- package/lib/base/adpater.d.ts +68 -0
- package/lib/base/adpater.js +183 -0
- package/lib/ble/adapter-factory.d.ts +33 -0
- package/lib/ble/adapter-factory.js +105 -0
- package/lib/ble/base/adapter.d.ts +53 -0
- package/lib/ble/base/adapter.js +290 -0
- package/lib/ble/base/comms-utils.d.ts +7 -0
- package/lib/ble/base/comms-utils.js +91 -0
- package/lib/ble/{ble-device.d.ts → base/comms.d.ts} +31 -16
- package/lib/ble/{ble-device.js → base/comms.js} +193 -55
- package/lib/ble/bindings/index.d.ts +2 -0
- package/lib/ble/bindings/index.js +8 -0
- package/lib/ble/bindings/linux.d.ts +15 -0
- package/lib/ble/bindings/linux.js +39 -0
- package/lib/ble/bindings/mock.d.ts +9 -0
- package/lib/ble/bindings/mock.js +108 -0
- package/lib/ble/bindings/types.d.ts +57 -0
- package/lib/ble/bindings/types.js +96 -0
- package/lib/ble/ble-interface.d.ts +38 -59
- package/lib/ble/ble-interface.js +254 -462
- package/lib/ble/ble-peripheral.d.ts +7 -5
- package/lib/ble/ble-peripheral.js +52 -21
- package/lib/ble/consts.d.ts +3 -0
- package/lib/ble/consts.js +4 -1
- package/lib/ble/cp/adapter.d.ts +22 -0
- package/lib/ble/cp/adapter.js +111 -0
- package/lib/ble/cp/comm.d.ts +31 -0
- package/lib/ble/cp/comm.js +125 -0
- package/lib/ble/cp/index.d.ts +4 -0
- package/lib/ble/cp/index.js +10 -0
- package/lib/ble/cp/types.d.ts +13 -0
- package/lib/ble/cp/types.js +2 -0
- package/lib/ble/elite/adapter.d.ts +19 -0
- package/lib/ble/elite/adapter.js +120 -0
- package/lib/ble/elite/comms.d.ts +32 -0
- package/lib/ble/elite/comms.js +126 -0
- package/lib/ble/elite/index.d.ts +3 -0
- package/lib/ble/elite/index.js +10 -0
- package/lib/ble/fm/adapter.d.ts +22 -0
- package/lib/ble/fm/adapter.js +249 -0
- package/lib/ble/fm/comms.d.ts +50 -0
- package/lib/ble/{fm.js → fm/comms.js} +34 -277
- package/lib/ble/fm/consts.d.ts +6 -0
- package/lib/ble/fm/consts.js +9 -0
- package/lib/ble/fm/index.d.ts +5 -0
- package/lib/ble/fm/index.js +13 -0
- package/lib/ble/fm/types.d.ts +30 -0
- package/lib/ble/fm/types.js +2 -0
- package/lib/ble/hr/adapter.d.ts +14 -0
- package/lib/ble/hr/adapter.js +45 -0
- package/lib/ble/hr/comm.d.ts +19 -0
- package/lib/ble/hr/comm.js +56 -0
- package/lib/ble/hr/index.d.ts +4 -0
- package/lib/ble/hr/index.js +10 -0
- package/lib/ble/hr/mock.d.ts +7 -0
- package/lib/ble/hr/mock.js +47 -0
- package/lib/ble/hr/types.d.ts +5 -0
- package/lib/ble/hr/types.js +2 -0
- package/lib/ble/index.d.ts +9 -0
- package/lib/ble/index.js +26 -0
- package/lib/ble/peripheral-cache.d.ts +43 -0
- package/lib/ble/peripheral-cache.js +107 -0
- package/lib/ble/tacx/adapter.d.ts +10 -0
- package/lib/ble/tacx/adapter.js +99 -0
- package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +11 -43
- package/lib/ble/{tacx.js → tacx/comms.js} +23 -155
- package/lib/ble/tacx/index.d.ts +4 -0
- package/lib/ble/tacx/index.js +10 -0
- package/lib/ble/tacx/types.d.ts +25 -0
- package/lib/ble/tacx/types.js +2 -0
- package/lib/ble/types.d.ts +128 -0
- package/lib/ble/types.js +2 -0
- package/lib/ble/utils.d.ts +17 -0
- package/lib/ble/utils.js +54 -0
- package/lib/ble/wahoo/adapter.d.ts +9 -0
- package/lib/ble/wahoo/adapter.js +95 -0
- package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +11 -44
- package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +29 -129
- package/lib/ble/wahoo/index.d.ts +4 -0
- package/lib/ble/wahoo/index.js +10 -0
- package/lib/ble/wahoo/types.d.ts +19 -0
- package/lib/ble/wahoo/types.js +2 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +34 -0
- package/lib/interfaces.d.ts +7 -0
- package/lib/interfaces.js +27 -0
- package/lib/{ble → modes}/ble-erg-mode.d.ts +4 -4
- package/lib/{ble → modes}/ble-erg-mode.js +2 -2
- package/lib/{ble → modes}/ble-st-mode.d.ts +3 -3
- package/lib/{ble → modes}/ble-st-mode.js +1 -1
- package/lib/{cycling-mode.d.ts → modes/cycling-mode.d.ts} +8 -8
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +8 -4
- package/lib/modes/power-meter.d.ts +3 -3
- package/lib/modes/simulator.d.ts +2 -2
- package/lib/modes/simulator.js +1 -1
- package/lib/serial/adapter-factory.d.ts +12 -0
- package/lib/serial/adapter-factory.js +30 -0
- package/lib/serial/adapter.d.ts +21 -0
- package/lib/serial/adapter.js +61 -0
- package/lib/serial/bindings/tcp.d.ts +45 -0
- package/lib/serial/bindings/tcp.js +284 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/{daum → serial/daum}/DaumAdapter.d.ts +14 -23
- package/lib/{daum → serial/daum}/DaumAdapter.js +57 -97
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.d.ts +2 -2
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.js +1 -1
- package/lib/{daum → serial/daum}/ERGCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/ERGCyclingMode.js +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.js +4 -3
- package/lib/serial/daum/classic/adapter.d.ts +29 -0
- package/lib/{daum/classic/DaumClassicAdapter.js → serial/daum/classic/adapter.js} +77 -50
- package/lib/{daum/classic/bike.d.ts → serial/daum/classic/comms.d.ts} +14 -16
- package/lib/{daum/classic/bike.js → serial/daum/classic/comms.js} +68 -152
- package/lib/serial/daum/classic/mock.d.ts +96 -0
- package/lib/serial/daum/classic/mock.js +365 -0
- package/lib/{daum/classic/DaumClassicCyclingMode.d.ts → serial/daum/classic/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/classic/DaumClassicCyclingMode.js → serial/daum/classic/modes/daum-classic.js} +2 -2
- package/lib/{daum → serial/daum}/classic/utils.d.ts +1 -1
- package/lib/serial/daum/premium/adapter.d.ts +25 -0
- package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +107 -47
- package/lib/{daum/premium/bike.d.ts → serial/daum/premium/comms.d.ts} +26 -54
- package/lib/{daum/premium/bike.js → serial/daum/premium/comms.js} +215 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +289 -0
- package/lib/{daum/premium/DaumClassicCyclingMode.d.ts → serial/daum/premium/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/premium/DaumClassicCyclingMode.js → serial/daum/premium/modes/daum-classic.js} +2 -2
- package/lib/serial/daum/premium/types.d.ts +12 -0
- package/lib/serial/daum/premium/types.js +2 -0
- package/lib/{daum → serial/daum}/premium/utils.d.ts +8 -11
- package/lib/{daum → serial/daum}/premium/utils.js +22 -63
- package/lib/serial/index.d.ts +9 -0
- package/lib/serial/index.js +49 -0
- package/lib/{kettler → serial/kettler}/comms.d.ts +8 -6
- package/lib/{kettler → serial/kettler}/comms.js +71 -32
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.d.ts +14 -28
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +102 -169
- package/lib/serial/kettler/ergo-racer/mock.d.ts +66 -0
- package/lib/serial/kettler/ergo-racer/mock.js +216 -0
- package/lib/{kettler/ergo-racer/ERGCyclingMode.d.ts → serial/kettler/ergo-racer/modes/erg.d.ts} +4 -4
- package/lib/{kettler/ergo-racer/ERGCyclingMode.js → serial/kettler/ergo-racer/modes/erg.js} +2 -2
- package/lib/serial/serial-interface.d.ts +60 -0
- package/lib/serial/serial-interface.js +309 -0
- package/lib/simulator/Simulator.d.ts +12 -25
- package/lib/simulator/Simulator.js +26 -87
- package/lib/types/adapter.d.ts +39 -0
- package/lib/types/adapter.js +2 -0
- package/lib/types/capabilities.d.ts +8 -0
- package/lib/types/capabilities.js +12 -0
- package/lib/types/data.d.ts +12 -0
- package/lib/types/data.js +2 -0
- package/lib/types/device.d.ts +32 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +18 -0
- package/lib/types/interface.js +2 -0
- package/lib/types/route.d.ts +2 -2
- package/lib/types/user.d.ts +1 -1
- package/lib/{utils.d.ts → utils/utils.d.ts} +1 -0
- package/lib/{utils.js → utils/utils.js} +5 -1
- package/package.json +16 -14
- package/lib/DeviceSupport.d.ts +0 -36
- package/lib/DeviceSupport.js +0 -82
- package/lib/ant/AntAdapter.d.ts +0 -50
- package/lib/ant/AntAdapter.js +0 -109
- package/lib/ant/AntScanner.d.ts +0 -60
- package/lib/ant/AntScanner.js +0 -651
- package/lib/ant/antfe/AntFEAdapter.d.ts +0 -83
- package/lib/ant/antfe/AntFEAdapter.js +0 -652
- package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/ant/antfe/ant-fe-erg-mode.d.ts +0 -6
- package/lib/ant/antfe/ant-fe-st-mode.d.ts +0 -5
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +0 -16
- package/lib/ant/anthrm/AntHrmAdapter.js +0 -130
- package/lib/ant/antpwr/pwr-adapter.d.ts +0 -49
- package/lib/ant/antpwr/pwr-adapter.js +0 -251
- package/lib/ant/utils.d.ts +0 -1
- package/lib/ant/utils.js +0 -23
- package/lib/antv2/AntAdapter.d.ts +0 -48
- package/lib/antv2/AntAdapter.js +0 -104
- package/lib/antv2/ant-device.d.ts +0 -59
- package/lib/antv2/ant-device.js +0 -161
- package/lib/antv2/fe.d.ts +0 -32
- package/lib/antv2/hr.d.ts +0 -18
- package/lib/antv2/hr.js +0 -102
- package/lib/antv2/incyclist-protocol.d.ts +0 -37
- package/lib/antv2/incyclist-protocol.js +0 -126
- package/lib/antv2/pwr.d.ts +0 -28
- package/lib/antv2/pwr.js +0 -171
- package/lib/ble/ble.d.ts +0 -129
- package/lib/ble/ble.js +0 -86
- package/lib/ble/elite.d.ts +0 -90
- package/lib/ble/elite.js +0 -322
- package/lib/ble/fm.d.ts +0 -125
- package/lib/ble/hrm.d.ts +0 -48
- package/lib/ble/hrm.js +0 -134
- package/lib/ble/incyclist-protocol.d.ts +0 -31
- package/lib/ble/incyclist-protocol.js +0 -153
- package/lib/ble/pwr.d.ts +0 -89
- package/lib/ble/pwr.js +0 -322
- package/lib/daum/classic/DaumClassicAdapter.d.ts +0 -28
- package/lib/daum/classic/DaumClassicProtocol.d.ts +0 -27
- package/lib/daum/classic/DaumClassicProtocol.js +0 -185
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +0 -16
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +0 -32
- package/lib/daum/premium/DaumPremiumProtocol.js +0 -207
- package/lib/daum/premium/tcpserial.d.ts +0 -33
- package/lib/daum/premium/tcpserial.js +0 -123
- package/lib/device.d.ts +0 -94
- package/lib/device.js +0 -76
- package/lib/kettler/ergo-racer/protocol.d.ts +0 -41
- package/lib/kettler/ergo-racer/protocol.js +0 -203
- package/lib/protocol.d.ts +0 -74
- package/lib/protocol.js +0 -41
- package/lib/registry.d.ts +0 -8
- package/lib/registry.js +0 -33
- package/lib/serialport/bindings/tcp.d.ts +0 -20
- package/lib/serialport/bindings/tcp.js +0 -33
- package/lib/serialport/index.d.ts +0 -2
- package/lib/serialport/index.js +0 -29
- package/lib/serialport/serialport.d.ts +0 -29
- package/lib/serialport/serialport.js +0 -87
- /package/lib/{cycling-mode.js → modes/cycling-mode.js} +0 -0
- /package/lib/{daum → serial/daum}/classic/utils.js +0 -0
- /package/lib/{daum → serial/daum}/constants.d.ts +0 -0
- /package/lib/{daum → serial/daum}/constants.js +0 -0
- /package/lib/{serialport.d.ts → serial/serialport.d.ts} +0 -0
- /package/lib/{serialport.js → serial/serialport.js} +0 -0
- /package/lib/{calculations.d.ts → utils/calculations.d.ts} +0 -0
- /package/lib/{calculations.js → utils/calculations.js} +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const comms_utils_1 = require("./base/comms-utils");
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
class BleAdapterFactory {
|
|
6
|
+
static getInstance() {
|
|
7
|
+
if (!BleAdapterFactory._instance)
|
|
8
|
+
BleAdapterFactory._instance = new BleAdapterFactory();
|
|
9
|
+
return BleAdapterFactory._instance;
|
|
10
|
+
}
|
|
11
|
+
constructor() {
|
|
12
|
+
this.implementations = [];
|
|
13
|
+
this.instances = [];
|
|
14
|
+
}
|
|
15
|
+
getAdapterInfo(protocol) {
|
|
16
|
+
return this.implementations.find(a => a.protocol === protocol);
|
|
17
|
+
}
|
|
18
|
+
getAll() {
|
|
19
|
+
return this.implementations;
|
|
20
|
+
}
|
|
21
|
+
createInstance(settings, props) {
|
|
22
|
+
let { profile, protocol } = settings;
|
|
23
|
+
const adapterSettings = Object.assign({}, settings);
|
|
24
|
+
if (profile) {
|
|
25
|
+
const mapping = (0, utils_1.mapLegacyProfile)(profile);
|
|
26
|
+
protocol = adapterSettings.protocol = mapping.protocol;
|
|
27
|
+
delete adapterSettings.profile;
|
|
28
|
+
}
|
|
29
|
+
const existing = this.find(adapterSettings);
|
|
30
|
+
if (existing) {
|
|
31
|
+
existing.setProperties(props);
|
|
32
|
+
return existing;
|
|
33
|
+
}
|
|
34
|
+
const info = this.getAdapterInfo(protocol);
|
|
35
|
+
if (!info || !info.Adapter)
|
|
36
|
+
return;
|
|
37
|
+
const adapter = new info.Adapter(adapterSettings, props);
|
|
38
|
+
this.instances.push(adapter);
|
|
39
|
+
return adapter;
|
|
40
|
+
}
|
|
41
|
+
removeInstance(query) {
|
|
42
|
+
let idx = -1;
|
|
43
|
+
if (query.settings) {
|
|
44
|
+
idx = this.instances.findIndex(a => a.isEqual(query.settings));
|
|
45
|
+
}
|
|
46
|
+
else if (query.adapter) {
|
|
47
|
+
idx = this.instances.findIndex(a => a.isEqual(query.adapter.getSettings()));
|
|
48
|
+
}
|
|
49
|
+
if (idx !== -1)
|
|
50
|
+
this.instances.splice(idx);
|
|
51
|
+
}
|
|
52
|
+
find(settings) {
|
|
53
|
+
return this.instances.find(a => a.isEqual(settings));
|
|
54
|
+
}
|
|
55
|
+
register(protocol, Adapter, Comm) {
|
|
56
|
+
const info = Object.assign({}, { protocol, Adapter, Comm });
|
|
57
|
+
const existing = this.implementations.findIndex(a => a.protocol === protocol);
|
|
58
|
+
if (existing !== -1)
|
|
59
|
+
this.implementations[existing] = info;
|
|
60
|
+
else
|
|
61
|
+
this.implementations.push(info);
|
|
62
|
+
}
|
|
63
|
+
getAllInstances() {
|
|
64
|
+
return this.instances;
|
|
65
|
+
}
|
|
66
|
+
getAllSupportedComms() {
|
|
67
|
+
const supported = BleAdapterFactory.getInstance().getAll();
|
|
68
|
+
return supported.map(info => info.Comm);
|
|
69
|
+
}
|
|
70
|
+
getAllSupportedAdapters() {
|
|
71
|
+
const supported = BleAdapterFactory.getInstance().getAll();
|
|
72
|
+
return supported.map(info => info.Adapter);
|
|
73
|
+
}
|
|
74
|
+
getAllSupportedServices() {
|
|
75
|
+
const supported = BleAdapterFactory.getInstance().getAll();
|
|
76
|
+
const res = [];
|
|
77
|
+
if (supported && supported.length > 0) {
|
|
78
|
+
supported.forEach(info => {
|
|
79
|
+
if (info && info.Comm && info.Comm.services) {
|
|
80
|
+
info.Comm.services.forEach(s => {
|
|
81
|
+
if (!res.includes(s))
|
|
82
|
+
res.push(s);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return res;
|
|
88
|
+
}
|
|
89
|
+
getDeviceClasses(peripheral, props = {}) {
|
|
90
|
+
let DeviceClasses;
|
|
91
|
+
const { protocol, services = peripheral.advertisement.serviceUuids } = props;
|
|
92
|
+
const classes = this.getAllSupportedComms();
|
|
93
|
+
DeviceClasses = (0, comms_utils_1.getDevicesFromServices)(classes, services);
|
|
94
|
+
if (protocol && DeviceClasses && DeviceClasses.length > 0) {
|
|
95
|
+
DeviceClasses = DeviceClasses.filter((C) => {
|
|
96
|
+
const device = new C({ peripheral });
|
|
97
|
+
if (device.getProtocol() !== protocol)
|
|
98
|
+
return false;
|
|
99
|
+
return true;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return DeviceClasses;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.default = BleAdapterFactory;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import IncyclistDevice from "../../base/adpater";
|
|
2
|
+
import CyclingMode, { IncyclistBikeData } from "../../modes/cycling-mode";
|
|
3
|
+
import { Bike } from "../../types/adapter";
|
|
4
|
+
import { DeviceData } from "../../types/data";
|
|
5
|
+
import { DeviceProperties } from "../../types/device";
|
|
6
|
+
import { User } from "../../types/user";
|
|
7
|
+
import { BleComms } from "./comms";
|
|
8
|
+
import BleInterface from "../ble-interface";
|
|
9
|
+
import { BleDeviceProperties, BleDeviceSettings, BleStartProperties } from "../types";
|
|
10
|
+
export default class BleAdapter extends IncyclistDevice {
|
|
11
|
+
ble: BleInterface;
|
|
12
|
+
deviceData: any;
|
|
13
|
+
data: DeviceData;
|
|
14
|
+
dataMsgCount: number;
|
|
15
|
+
lastDataTS: number;
|
|
16
|
+
device: BleComms;
|
|
17
|
+
constructor(settings: BleDeviceSettings, props?: DeviceProperties);
|
|
18
|
+
getUniqueName(): string;
|
|
19
|
+
connect(): Promise<boolean>;
|
|
20
|
+
close(): Promise<boolean>;
|
|
21
|
+
getComms(): BleComms;
|
|
22
|
+
isEqual(settings: BleDeviceSettings): boolean;
|
|
23
|
+
isSame(adapter: BleAdapter): boolean;
|
|
24
|
+
isConnected(): boolean;
|
|
25
|
+
resetData(): void;
|
|
26
|
+
getInterface(): string;
|
|
27
|
+
getProtocolName(): string;
|
|
28
|
+
getID(): string;
|
|
29
|
+
getName(): string;
|
|
30
|
+
onDeviceData(deviceData: any): void;
|
|
31
|
+
mapData(deviceData: any): DeviceData | IncyclistBikeData;
|
|
32
|
+
transformData(data: IncyclistBikeData): DeviceData;
|
|
33
|
+
getSettings(): BleDeviceSettings;
|
|
34
|
+
setProperties(props: BleDeviceProperties): void;
|
|
35
|
+
check(): Promise<boolean>;
|
|
36
|
+
start(props?: BleStartProperties): Promise<any>;
|
|
37
|
+
stop(): Promise<boolean>;
|
|
38
|
+
pause(): Promise<boolean>;
|
|
39
|
+
resume(): Promise<boolean>;
|
|
40
|
+
}
|
|
41
|
+
export declare class BleControllableAdapter extends BleAdapter implements Bike {
|
|
42
|
+
cyclingMode: CyclingMode;
|
|
43
|
+
user?: User;
|
|
44
|
+
constructor(settings: BleDeviceSettings, props?: DeviceProperties);
|
|
45
|
+
setUser(user: User): void;
|
|
46
|
+
isControllable(): boolean;
|
|
47
|
+
setBikeProps(props: DeviceProperties): void;
|
|
48
|
+
getWeight(): number;
|
|
49
|
+
getSupportedCyclingModes(): any[];
|
|
50
|
+
getDefaultCyclingMode(): CyclingMode;
|
|
51
|
+
setCyclingMode(mode: CyclingMode | string, settings?: any): void;
|
|
52
|
+
getCyclingMode(): CyclingMode;
|
|
53
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.BleControllableAdapter = void 0;
|
|
39
|
+
const adpater_1 = __importStar(require("../../base/adpater"));
|
|
40
|
+
const ble_interface_1 = __importDefault(require("../ble-interface"));
|
|
41
|
+
const INTERFACE_NAME = 'ble';
|
|
42
|
+
class BleAdapter extends adpater_1.default {
|
|
43
|
+
constructor(settings, props) {
|
|
44
|
+
super(settings, props);
|
|
45
|
+
if (this.settings.interface !== INTERFACE_NAME)
|
|
46
|
+
throw new Error('Incorrect interface');
|
|
47
|
+
this.deviceData = {};
|
|
48
|
+
this.data = {};
|
|
49
|
+
this.dataMsgCount = 0;
|
|
50
|
+
this.updateFrequency = 1000;
|
|
51
|
+
this.ble = ble_interface_1.default.getInstance();
|
|
52
|
+
}
|
|
53
|
+
getUniqueName() {
|
|
54
|
+
const settings = this.settings;
|
|
55
|
+
if (settings.name.match(/[0-9]/g))
|
|
56
|
+
return this.settings.name;
|
|
57
|
+
else {
|
|
58
|
+
const addressHash = settings.address.substring(0, 2) + settings.address.slice(-2);
|
|
59
|
+
return `${this.getName()} ${addressHash}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
connect() {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
if (!this.device) {
|
|
65
|
+
throw new Error('No Comms');
|
|
66
|
+
}
|
|
67
|
+
if (this.isConnected())
|
|
68
|
+
return true;
|
|
69
|
+
let connected = false;
|
|
70
|
+
try {
|
|
71
|
+
connected = yield this.device.connect();
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
this.logEvent({ message: 'error', fn: 'connect()', error: err.message, stack: err.stack });
|
|
75
|
+
}
|
|
76
|
+
return connected;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
close() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (!this.device || !this.isConnected())
|
|
82
|
+
return true;
|
|
83
|
+
if (this.device) {
|
|
84
|
+
yield this.device.disconnect();
|
|
85
|
+
this.ble.removeConnectedDevice(this);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
getComms() {
|
|
91
|
+
return this.device;
|
|
92
|
+
}
|
|
93
|
+
isEqual(settings) {
|
|
94
|
+
const as = this.settings;
|
|
95
|
+
if (as.interface !== settings.interface)
|
|
96
|
+
return false;
|
|
97
|
+
if (as.profile || settings.profile) {
|
|
98
|
+
return (as.protocol === settings.protocol && as.profile === settings.profile && as.name === settings.name);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return (as.protocol === settings.protocol && ((as.name && settings.name && as.name === settings.name) ||
|
|
102
|
+
(as.address && settings.address && as.address === settings.address) ||
|
|
103
|
+
(as.id && settings.id && as.id === settings.id)));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
isSame(adapter) {
|
|
107
|
+
return this.isEqual(adapter.getSettings());
|
|
108
|
+
}
|
|
109
|
+
isConnected() {
|
|
110
|
+
return this.device && this.device.isConnected();
|
|
111
|
+
}
|
|
112
|
+
resetData() {
|
|
113
|
+
this.dataMsgCount = 0;
|
|
114
|
+
this.deviceData = {};
|
|
115
|
+
this.data = {};
|
|
116
|
+
this.lastDataTS = undefined;
|
|
117
|
+
}
|
|
118
|
+
getInterface() {
|
|
119
|
+
return INTERFACE_NAME;
|
|
120
|
+
}
|
|
121
|
+
getProtocolName() {
|
|
122
|
+
const settings = this.settings;
|
|
123
|
+
return settings.protocol;
|
|
124
|
+
}
|
|
125
|
+
getID() {
|
|
126
|
+
const settings = this.settings;
|
|
127
|
+
return settings.id;
|
|
128
|
+
}
|
|
129
|
+
getName() {
|
|
130
|
+
const settings = this.settings;
|
|
131
|
+
return settings.name || settings.id || settings.address;
|
|
132
|
+
}
|
|
133
|
+
onDeviceData(deviceData) {
|
|
134
|
+
this.dataMsgCount++;
|
|
135
|
+
this.lastDataTS = Date.now();
|
|
136
|
+
this.deviceData = Object.assign({}, deviceData);
|
|
137
|
+
if (!this.started || !this.canSendUpdate())
|
|
138
|
+
return;
|
|
139
|
+
this.logEvent({ message: 'onDeviceData', data: deviceData, isControllable: (this instanceof BleControllableAdapter) });
|
|
140
|
+
if (this instanceof BleControllableAdapter) {
|
|
141
|
+
const mappedData = this.mapData(deviceData);
|
|
142
|
+
const incyclistData = this.getCyclingMode().updateData(mappedData);
|
|
143
|
+
this.data = this.transformData(incyclistData);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
this.data = this.mapData(this.deviceData);
|
|
147
|
+
}
|
|
148
|
+
this.emitData(this.data);
|
|
149
|
+
}
|
|
150
|
+
mapData(deviceData) {
|
|
151
|
+
throw new Error('message not implemented');
|
|
152
|
+
}
|
|
153
|
+
transformData(data) {
|
|
154
|
+
throw new Error('message not implemented');
|
|
155
|
+
}
|
|
156
|
+
getSettings() {
|
|
157
|
+
return this.settings;
|
|
158
|
+
}
|
|
159
|
+
setProperties(props) {
|
|
160
|
+
this.props = props;
|
|
161
|
+
}
|
|
162
|
+
check() {
|
|
163
|
+
return this.start({ scanOnly: true });
|
|
164
|
+
}
|
|
165
|
+
start(props = {}) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
if (this.started)
|
|
168
|
+
return true;
|
|
169
|
+
const connected = yield this.connect();
|
|
170
|
+
if (!connected)
|
|
171
|
+
throw new Error(`could not start device, reason:could not connect`);
|
|
172
|
+
this.logger.logEvent({ message: 'start requested', protocol: this.getProtocolName(), props });
|
|
173
|
+
try {
|
|
174
|
+
const comms = this.device;
|
|
175
|
+
if (comms) {
|
|
176
|
+
comms.on('data', (data) => {
|
|
177
|
+
this.onDeviceData(data);
|
|
178
|
+
});
|
|
179
|
+
this.resetData();
|
|
180
|
+
this.stopped = false;
|
|
181
|
+
this.started = true;
|
|
182
|
+
this.paused = false;
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
this.logger.logEvent({ message: 'start result: error', error: err.message, protocol: this.getProtocolName() });
|
|
188
|
+
throw new Error(`could not start device, reason:${err.message}`);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
stop() {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
this.logger.logEvent({ message: 'stop requested', protocol: this.getProtocolName() });
|
|
195
|
+
this.device.reset();
|
|
196
|
+
const stopped = this.device.disconnect();
|
|
197
|
+
if (stopped) {
|
|
198
|
+
this.stopped = true;
|
|
199
|
+
this.started = false;
|
|
200
|
+
this.paused = false;
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
pause() {
|
|
207
|
+
const _super = Object.create(null, {
|
|
208
|
+
pause: { get: () => super.pause }
|
|
209
|
+
});
|
|
210
|
+
var _a;
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
const res = yield _super.pause.call(this);
|
|
213
|
+
(_a = this.getComms()) === null || _a === void 0 ? void 0 : _a.pause();
|
|
214
|
+
return res;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
resume() {
|
|
218
|
+
const _super = Object.create(null, {
|
|
219
|
+
resume: { get: () => super.resume }
|
|
220
|
+
});
|
|
221
|
+
var _a;
|
|
222
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
const res = yield _super.resume.call(this);
|
|
224
|
+
(_a = this.getComms()) === null || _a === void 0 ? void 0 : _a.resume();
|
|
225
|
+
return res;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.default = BleAdapter;
|
|
230
|
+
class BleControllableAdapter extends BleAdapter {
|
|
231
|
+
constructor(settings, props) {
|
|
232
|
+
super(settings, props);
|
|
233
|
+
this.cyclingMode = this.getDefaultCyclingMode();
|
|
234
|
+
this.user = {};
|
|
235
|
+
}
|
|
236
|
+
setUser(user) {
|
|
237
|
+
this.user = user;
|
|
238
|
+
if (!user.weight)
|
|
239
|
+
this.user.weight = adpater_1.DEFAULT_USER_WEIGHT;
|
|
240
|
+
}
|
|
241
|
+
isControllable() {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
setBikeProps(props) {
|
|
245
|
+
const { user, userWeight } = props || {};
|
|
246
|
+
if (user)
|
|
247
|
+
this.setUser(user);
|
|
248
|
+
if (userWeight)
|
|
249
|
+
this.user.weight = userWeight;
|
|
250
|
+
const keys = Object.keys(props);
|
|
251
|
+
keys.forEach(k => {
|
|
252
|
+
const p = props[k];
|
|
253
|
+
if (p === null)
|
|
254
|
+
delete this.props[k];
|
|
255
|
+
else if (p !== undefined)
|
|
256
|
+
this.props[k] = p;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
getWeight() {
|
|
260
|
+
const { user = {}, props = adpater_1.DEFAULT_PROPS } = this;
|
|
261
|
+
const userWeight = user.weight || props.userWeight || adpater_1.DEFAULT_USER_WEIGHT;
|
|
262
|
+
const bikeWeight = props.bikeWeight || adpater_1.DEFAULT_BIKE_WEIGHT;
|
|
263
|
+
return userWeight + bikeWeight;
|
|
264
|
+
}
|
|
265
|
+
getSupportedCyclingModes() { throw new Error('not implemented'); }
|
|
266
|
+
getDefaultCyclingMode() { throw new Error('not implemented'); }
|
|
267
|
+
setCyclingMode(mode, settings) {
|
|
268
|
+
let selectedMode;
|
|
269
|
+
if (typeof mode === 'string') {
|
|
270
|
+
const supported = this.getSupportedCyclingModes();
|
|
271
|
+
const CyclingModeClass = supported.find(M => { const m = new M(this); return m.getName() === mode; });
|
|
272
|
+
if (CyclingModeClass) {
|
|
273
|
+
this.cyclingMode = new CyclingModeClass(this, settings);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
selectedMode = this.getDefaultCyclingMode();
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
selectedMode = mode;
|
|
280
|
+
}
|
|
281
|
+
this.cyclingMode = selectedMode;
|
|
282
|
+
this.cyclingMode.setSettings(settings);
|
|
283
|
+
}
|
|
284
|
+
getCyclingMode() {
|
|
285
|
+
if (!this.cyclingMode)
|
|
286
|
+
this.setCyclingMode(this.getDefaultCyclingMode());
|
|
287
|
+
return this.cyclingMode;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
exports.BleControllableAdapter = BleControllableAdapter;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BleProtocol } from "../types";
|
|
2
|
+
import { BleComms } from "./comms";
|
|
3
|
+
export declare function getBestDeviceMatch(DeviceClasses: (typeof BleComms)[]): typeof BleComms;
|
|
4
|
+
export declare function getDevicesFromServices(deviceTypes: (typeof BleComms)[], services: string | string[]): (typeof BleComms)[];
|
|
5
|
+
export declare function getServicesFromDeviceTypes(deviceTypes: (typeof BleComms)[]): string[];
|
|
6
|
+
export declare function getServicesFromProtocols(protocols: BleProtocol[]): string[];
|
|
7
|
+
export declare function getServicesFromDevice(device: BleComms): string[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getServicesFromDevice = exports.getServicesFromProtocols = exports.getServicesFromDeviceTypes = exports.getDevicesFromServices = exports.getBestDeviceMatch = void 0;
|
|
7
|
+
const adapter_factory_1 = __importDefault(require("../adapter-factory"));
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
function getBestDeviceMatch(DeviceClasses) {
|
|
10
|
+
if (!DeviceClasses || DeviceClasses.length === 0)
|
|
11
|
+
return;
|
|
12
|
+
const details = DeviceClasses.map(c => ({ name: c.prototype.constructor.name, priority: c.detectionPriority || 0, class: c }));
|
|
13
|
+
details.sort((a, b) => b.priority - a.priority);
|
|
14
|
+
return details[0].class;
|
|
15
|
+
}
|
|
16
|
+
exports.getBestDeviceMatch = getBestDeviceMatch;
|
|
17
|
+
function getDevicesFromServices(deviceTypes, services) {
|
|
18
|
+
if (!deviceTypes || !Array.isArray(deviceTypes) || deviceTypes.length === 0) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
const get = (deviceTypes, fnCompare) => {
|
|
22
|
+
const types = deviceTypes.filter(DeviceType => {
|
|
23
|
+
const C = DeviceType;
|
|
24
|
+
let found = false;
|
|
25
|
+
if (C.services)
|
|
26
|
+
found = C.services.find((s) => fnCompare(s));
|
|
27
|
+
return found;
|
|
28
|
+
});
|
|
29
|
+
return types;
|
|
30
|
+
};
|
|
31
|
+
if (typeof services === 'string') {
|
|
32
|
+
return get(deviceTypes, (s) => (0, utils_1.matches)(s, services));
|
|
33
|
+
}
|
|
34
|
+
if (Array.isArray(services)) {
|
|
35
|
+
const sids = services.map(utils_1.uuid);
|
|
36
|
+
return get(deviceTypes, s => {
|
|
37
|
+
const res = sids.find((service) => (0, utils_1.matches)(s, service));
|
|
38
|
+
return res !== undefined;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
exports.getDevicesFromServices = getDevicesFromServices;
|
|
44
|
+
function getServicesFromDeviceTypes(deviceTypes) {
|
|
45
|
+
let services = [];
|
|
46
|
+
try {
|
|
47
|
+
if (!deviceTypes || !Array.isArray(deviceTypes) || deviceTypes.length === 0) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
deviceTypes.forEach(DeviceType => {
|
|
51
|
+
if (DeviceType.services) {
|
|
52
|
+
const dtServices = DeviceType.services;
|
|
53
|
+
dtServices.forEach(s => {
|
|
54
|
+
if (!services.find(s2 => s2 === s))
|
|
55
|
+
services.push(s);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
console.log(err);
|
|
62
|
+
}
|
|
63
|
+
return services;
|
|
64
|
+
}
|
|
65
|
+
exports.getServicesFromDeviceTypes = getServicesFromDeviceTypes;
|
|
66
|
+
function getServicesFromProtocols(protocols) {
|
|
67
|
+
const services = [];
|
|
68
|
+
const comms = adapter_factory_1.default.getInstance().getAllSupportedComms();
|
|
69
|
+
comms
|
|
70
|
+
.filter((C) => protocols.find(p => p === C.protocol) !== undefined)
|
|
71
|
+
.forEach((C) => {
|
|
72
|
+
C.services.forEach(s => {
|
|
73
|
+
if (!services.find(s2 => s2 === s))
|
|
74
|
+
services.push(s);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
return services;
|
|
78
|
+
}
|
|
79
|
+
exports.getServicesFromProtocols = getServicesFromProtocols;
|
|
80
|
+
function getServicesFromDevice(device) {
|
|
81
|
+
if (!device)
|
|
82
|
+
return [];
|
|
83
|
+
const services = [];
|
|
84
|
+
const dServices = device.getServiceUUids();
|
|
85
|
+
dServices.forEach(s => {
|
|
86
|
+
if (!services.find(s2 => s2 === s))
|
|
87
|
+
services.push(s);
|
|
88
|
+
});
|
|
89
|
+
return services;
|
|
90
|
+
}
|
|
91
|
+
exports.getServicesFromDevice = getServicesFromDevice;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import EventEmitter from "events";
|
|
2
5
|
import { EventLogger } from "gd-eventlog";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
declare type CommandQueueItem = {
|
|
6
|
+
import { LegacyProfile } from "../../antv2/types";
|
|
7
|
+
import BleInterface from "../ble-interface";
|
|
8
|
+
import BlePeripheralConnector from "../ble-peripheral";
|
|
9
|
+
import { BleCharacteristic, BleCommsConnectProps, BleDeviceConstructProps, BleDeviceInfo, BleDeviceSettings, BlePeripheral, BleProtocol, BleWriteProps, ConnectState, IBlePeripheralConnector } from "../types";
|
|
10
|
+
type CommandQueueItem = {
|
|
10
11
|
uuid: string;
|
|
11
12
|
data: Buffer;
|
|
12
13
|
timeout: number;
|
|
@@ -18,14 +19,17 @@ export interface MessageLog {
|
|
|
18
19
|
timestamp: any;
|
|
19
20
|
data: string;
|
|
20
21
|
}
|
|
21
|
-
export declare
|
|
22
|
+
export declare class BleComms extends EventEmitter {
|
|
23
|
+
static services: string[];
|
|
24
|
+
static protocol: BleProtocol;
|
|
22
25
|
id: string;
|
|
26
|
+
paused: boolean;
|
|
23
27
|
address: string;
|
|
24
28
|
name: string;
|
|
25
29
|
services: string[];
|
|
26
|
-
ble:
|
|
30
|
+
ble: BleInterface;
|
|
27
31
|
peripheral?: BlePeripheral;
|
|
28
|
-
characteristics:
|
|
32
|
+
characteristics: BleCharacteristic[];
|
|
29
33
|
state?: string;
|
|
30
34
|
logger?: EventLogger;
|
|
31
35
|
deviceInfo: BleDeviceInfo;
|
|
@@ -34,23 +38,34 @@ export declare abstract class BleDevice extends BleDeviceClass {
|
|
|
34
38
|
writeQueue: CommandQueueItem[];
|
|
35
39
|
workerIv: NodeJS.Timeout;
|
|
36
40
|
prevMessages: MessageLog[];
|
|
41
|
+
connectState: ConnectState;
|
|
37
42
|
constructor(props?: BleDeviceConstructProps);
|
|
43
|
+
getConnectState(): ConnectState;
|
|
44
|
+
isConnected(): boolean;
|
|
45
|
+
pause(): void;
|
|
46
|
+
resume(): void;
|
|
47
|
+
getServiceUUids(): string[];
|
|
48
|
+
getProfile(): LegacyProfile;
|
|
49
|
+
getProtocol(): BleProtocol;
|
|
50
|
+
getSettings(): BleDeviceSettings;
|
|
38
51
|
getServices(): string[];
|
|
39
52
|
logEvent(event: any): void;
|
|
40
53
|
setLogger(logger: EventLogger): void;
|
|
41
|
-
setInterface(ble:
|
|
42
|
-
isMatching(characteristics: string[]): boolean;
|
|
54
|
+
setInterface(ble: BleInterface): void;
|
|
55
|
+
static isMatching(characteristics: string[]): boolean;
|
|
56
|
+
reset(): void;
|
|
43
57
|
cleanupListeners(): void;
|
|
44
|
-
onDisconnect(): void
|
|
58
|
+
onDisconnect(): Promise<void>;
|
|
45
59
|
waitForConnectFinished(timeout: any): Promise<unknown>;
|
|
46
60
|
hasService(serviceUuid: any): boolean;
|
|
47
61
|
init(): Promise<boolean>;
|
|
48
62
|
initDevice(): Promise<boolean>;
|
|
49
|
-
connectPeripheral(peripheral: BlePeripheral): Promise<
|
|
63
|
+
connectPeripheral(peripheral: BlePeripheral): Promise<boolean>;
|
|
64
|
+
subscribeMultiple(characteristics: string[], conn?: IBlePeripheralConnector): Promise<void>;
|
|
50
65
|
subscribeAll(conn?: BlePeripheralConnector): Promise<void>;
|
|
51
|
-
|
|
66
|
+
unsubscribeAll(conn?: BlePeripheralConnector): void;
|
|
67
|
+
connect(props?: BleCommsConnectProps): Promise<boolean>;
|
|
52
68
|
disconnect(): Promise<boolean>;
|
|
53
|
-
abstract getProfile(): string;
|
|
54
69
|
checkForDuplicate(characteristic: string, data: Buffer): boolean;
|
|
55
70
|
onData(characteristic: string, _data: Buffer): boolean;
|
|
56
71
|
timeoutCheck(): void;
|