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
|
@@ -8,26 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const ble_interface_1 = __importDefault(require("./ble-interface"));
|
|
18
|
-
const device_1 = __importDefault(require("../device"));
|
|
19
|
-
const gd_eventlog_1 = require("gd-eventlog");
|
|
20
|
-
const power_meter_1 = __importDefault(require("../modes/power-meter"));
|
|
21
|
-
const ble_st_mode_1 = __importDefault(require("./ble-st-mode"));
|
|
22
|
-
const ble_erg_mode_1 = __importDefault(require("./ble-erg-mode"));
|
|
23
|
-
const consts_1 = require("./consts");
|
|
24
|
-
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
25
|
-
const cwABike = {
|
|
26
|
-
race: 0.35,
|
|
27
|
-
triathlon: 0.29,
|
|
28
|
-
mountain: 0.57
|
|
29
|
-
};
|
|
30
|
-
const cRR = 0.0036;
|
|
12
|
+
const consts_1 = require("../consts");
|
|
13
|
+
const comms_1 = require("../base/comms");
|
|
31
14
|
const bit = (nr) => (1 << nr);
|
|
32
15
|
const IndoorBikeDataFlag = {
|
|
33
16
|
MoreData: bit(0),
|
|
@@ -82,7 +65,7 @@ const TargetSettingFeatureFlag = {
|
|
|
82
65
|
SpinDownControlSupported: bit(15),
|
|
83
66
|
TargetedCadenceConfigurationSupported: bit(16)
|
|
84
67
|
};
|
|
85
|
-
class BleFitnessMachineDevice extends
|
|
68
|
+
class BleFitnessMachineDevice extends comms_1.BleComms {
|
|
86
69
|
constructor(props) {
|
|
87
70
|
super(props);
|
|
88
71
|
this.features = undefined;
|
|
@@ -96,7 +79,7 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
|
|
|
96
79
|
this.data = {};
|
|
97
80
|
this.services = BleFitnessMachineDevice.services;
|
|
98
81
|
}
|
|
99
|
-
isMatching(characteristics) {
|
|
82
|
+
static isMatching(characteristics) {
|
|
100
83
|
if (!characteristics)
|
|
101
84
|
return false;
|
|
102
85
|
const hasStatus = characteristics.find(c => c === consts_1.FTMS_STATUS) !== undefined;
|
|
@@ -107,7 +90,7 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
|
|
|
107
90
|
subscribeWriteResponse(cuuid) {
|
|
108
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
92
|
this.logEvent({ message: 'subscribe to CP response', characteristics: cuuid });
|
|
110
|
-
const connector = this.ble.getConnector(this.peripheral);
|
|
93
|
+
const connector = this.ble.peripheralCache.getConnector(this.peripheral);
|
|
111
94
|
const isAlreadySubscribed = connector.isSubscribed(cuuid);
|
|
112
95
|
if (!isAlreadySubscribed) {
|
|
113
96
|
connector.removeAllListeners(cuuid);
|
|
@@ -127,36 +110,14 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
|
|
|
127
110
|
});
|
|
128
111
|
}
|
|
129
112
|
subscribeAll(conn) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
resolve();
|
|
139
|
-
}
|
|
140
|
-
}, 100);
|
|
141
|
-
try {
|
|
142
|
-
const connector = conn || this.ble.getConnector(this.peripheral);
|
|
143
|
-
for (let i = 0; i < characteristics.length; i++) {
|
|
144
|
-
const c = characteristics[i];
|
|
145
|
-
const isAlreadySubscribed = connector.isSubscribed(c);
|
|
146
|
-
if (!isAlreadySubscribed) {
|
|
147
|
-
connector.removeAllListeners(c);
|
|
148
|
-
connector.on(c, (uuid, data) => {
|
|
149
|
-
this.onData(uuid, data);
|
|
150
|
-
});
|
|
151
|
-
connector.subscribe(c);
|
|
152
|
-
this.subscribedCharacteristics.push(c);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
catch (err) {
|
|
157
|
-
this.logEvent({ message: 'Error', fn: 'subscribeAll()', error: err.message, stack: err.stack });
|
|
158
|
-
}
|
|
159
|
-
});
|
|
113
|
+
const characteristics = [consts_1.INDOOR_BIKE_DATA, consts_1.FTMS_STATUS, consts_1.FTMS_CP];
|
|
114
|
+
if (!this.features || (this.features && this.features.cadence))
|
|
115
|
+
characteristics.push(consts_1.CSC_MEASUREMENT);
|
|
116
|
+
if (!this.features || (this.features && this.features.power))
|
|
117
|
+
characteristics.push(consts_1.CSP_MEASUREMENT);
|
|
118
|
+
if (!this.features || (this.features && this.features.heartrate))
|
|
119
|
+
characteristics.push(consts_1.HR_MEASUREMENT);
|
|
120
|
+
return this.subscribeMultiple(characteristics, conn);
|
|
160
121
|
}
|
|
161
122
|
init() {
|
|
162
123
|
const _super = Object.create(null, {
|
|
@@ -167,39 +128,32 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
|
|
|
167
128
|
yield _super.initDevice.call(this);
|
|
168
129
|
yield this.getFitnessMachineFeatures();
|
|
169
130
|
this.logEvent({ message: 'device info', deviceInfo: this.deviceInfo, features: this.features });
|
|
131
|
+
return true;
|
|
170
132
|
}
|
|
171
133
|
catch (err) {
|
|
172
134
|
this.logEvent({ message: 'error', fn: 'BleFitnessMachineDevice.init()', error: err.message || err, stack: err.stack });
|
|
173
|
-
return
|
|
135
|
+
return false;
|
|
174
136
|
}
|
|
175
137
|
});
|
|
176
138
|
}
|
|
177
139
|
onDisconnect() {
|
|
178
|
-
|
|
179
|
-
|
|
140
|
+
const _super = Object.create(null, {
|
|
141
|
+
onDisconnect: { get: () => super.onDisconnect }
|
|
142
|
+
});
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
_super.onDisconnect.call(this);
|
|
145
|
+
this.hasControl = false;
|
|
146
|
+
});
|
|
180
147
|
}
|
|
181
148
|
getProfile() {
|
|
182
149
|
return 'Smart Trainer';
|
|
183
150
|
}
|
|
151
|
+
getProtocol() {
|
|
152
|
+
return BleFitnessMachineDevice.protocol;
|
|
153
|
+
}
|
|
184
154
|
getServiceUUids() {
|
|
185
155
|
return BleFitnessMachineDevice.services;
|
|
186
156
|
}
|
|
187
|
-
isBike() {
|
|
188
|
-
return this.features === undefined ||
|
|
189
|
-
((this.features.targetSettings & TargetSettingFeatureFlag.IndoorBikeSimulationParametersSupported) !== 0);
|
|
190
|
-
}
|
|
191
|
-
isPower() {
|
|
192
|
-
if (this.hasService('1818'))
|
|
193
|
-
return true;
|
|
194
|
-
if (this.features === undefined)
|
|
195
|
-
return false;
|
|
196
|
-
const { fitnessMachine } = this.features;
|
|
197
|
-
if (fitnessMachine & FitnessMachineFeatureFlag.PowerMeasurementSupported)
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
isHrm() {
|
|
201
|
-
return this.hasService('180d') || (this.features && (this.features.fitnessMachine & FitnessMachineFeatureFlag.HeartRateMeasurementSupported) !== 0);
|
|
202
|
-
}
|
|
203
157
|
parseHrm(_data) {
|
|
204
158
|
const data = Buffer.from(_data);
|
|
205
159
|
try {
|
|
@@ -344,8 +298,14 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
|
|
|
344
298
|
if (buffer) {
|
|
345
299
|
const fitnessMachine = buffer.readUInt32LE(0);
|
|
346
300
|
const targetSettings = buffer.readUInt32LE(4);
|
|
347
|
-
|
|
348
|
-
|
|
301
|
+
const power = (fitnessMachine & FitnessMachineFeatureFlag.PowerMeasurementSupported) !== 0;
|
|
302
|
+
const heartrate = (fitnessMachine & FitnessMachineFeatureFlag.HeartRateMeasurementSupported) !== 0;
|
|
303
|
+
const cadence = (fitnessMachine & FitnessMachineFeatureFlag.CadenceSupported) !== 0;
|
|
304
|
+
const setSlope = (targetSettings & TargetSettingFeatureFlag.IndoorBikeSimulationParametersSupported) !== 0
|
|
305
|
+
|| (targetSettings & TargetSettingFeatureFlag.InclinationTargetSettingSupported) !== 0;
|
|
306
|
+
const setPower = (targetSettings & TargetSettingFeatureFlag.PowerTargetSettingSupported) !== 0;
|
|
307
|
+
this.features = { fitnessMachine, targetSettings, power, heartrate, cadence, setPower, setSlope };
|
|
308
|
+
this.logEvent({ message: 'supported Features: ', fatures: this.features, power, heartrate, cadence });
|
|
349
309
|
}
|
|
350
310
|
}
|
|
351
311
|
catch (err) {
|
|
@@ -537,210 +497,7 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
|
|
|
537
497
|
}
|
|
538
498
|
}
|
|
539
499
|
exports.default = BleFitnessMachineDevice;
|
|
500
|
+
BleFitnessMachineDevice.protocol = 'fm';
|
|
540
501
|
BleFitnessMachineDevice.services = [consts_1.FTMS];
|
|
541
502
|
BleFitnessMachineDevice.characteristics = ['2acc', consts_1.INDOOR_BIKE_DATA, '2ad6', '2ad8', consts_1.FTMS_CP, consts_1.FTMS_STATUS];
|
|
542
503
|
BleFitnessMachineDevice.detectionPriority = 100;
|
|
543
|
-
ble_interface_1.default.register('BleFitnessMachineDevice', 'fm', BleFitnessMachineDevice, BleFitnessMachineDevice.services);
|
|
544
|
-
class FmAdapter extends device_1.default {
|
|
545
|
-
constructor(device, protocol) {
|
|
546
|
-
super(protocol);
|
|
547
|
-
this.ignore = false;
|
|
548
|
-
this.paused = false;
|
|
549
|
-
this.distanceInternal = 0;
|
|
550
|
-
this.device = device;
|
|
551
|
-
this.ble = protocol.ble;
|
|
552
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
553
|
-
this.logger = new gd_eventlog_1.EventLogger('BLE-FM');
|
|
554
|
-
if (this.device)
|
|
555
|
-
this.device.setLogger(this.logger);
|
|
556
|
-
}
|
|
557
|
-
isBike() { return this.device.isBike() || this.device.isPower(); }
|
|
558
|
-
isHrm() { return this.device.isHrm(); }
|
|
559
|
-
isPower() { return this.device.isPower(); }
|
|
560
|
-
isSame(device) {
|
|
561
|
-
if (!(device instanceof FmAdapter))
|
|
562
|
-
return false;
|
|
563
|
-
const adapter = device;
|
|
564
|
-
return (adapter.getName() === this.getName() && adapter.getProfile() === this.getProfile());
|
|
565
|
-
}
|
|
566
|
-
getProfile() {
|
|
567
|
-
const profile = this.device ? this.device.getProfile() : undefined;
|
|
568
|
-
return profile || 'Smart Trainer';
|
|
569
|
-
}
|
|
570
|
-
getName() {
|
|
571
|
-
return `${this.device.name}`;
|
|
572
|
-
}
|
|
573
|
-
getDisplayName() {
|
|
574
|
-
return this.getName();
|
|
575
|
-
}
|
|
576
|
-
getSupportedCyclingModes() {
|
|
577
|
-
return [ble_st_mode_1.default, ble_erg_mode_1.default, power_meter_1.default];
|
|
578
|
-
}
|
|
579
|
-
setCyclingMode(mode, settings) {
|
|
580
|
-
let selectedMode;
|
|
581
|
-
if (typeof mode === 'string') {
|
|
582
|
-
const supported = this.getSupportedCyclingModes();
|
|
583
|
-
const CyclingModeClass = supported.find(M => { const m = new M(this); return m.getName() === mode; });
|
|
584
|
-
if (CyclingModeClass) {
|
|
585
|
-
this.cyclingMode = new CyclingModeClass(this, settings);
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
588
|
-
selectedMode = this.getDefaultCyclingMode();
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
selectedMode = mode;
|
|
592
|
-
}
|
|
593
|
-
this.cyclingMode = selectedMode;
|
|
594
|
-
this.cyclingMode.setSettings(settings);
|
|
595
|
-
}
|
|
596
|
-
getCyclingMode() {
|
|
597
|
-
if (!this.cyclingMode)
|
|
598
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
599
|
-
return this.cyclingMode;
|
|
600
|
-
}
|
|
601
|
-
getDefaultCyclingMode() {
|
|
602
|
-
return new ble_st_mode_1.default(this);
|
|
603
|
-
}
|
|
604
|
-
getPort() {
|
|
605
|
-
return 'ble';
|
|
606
|
-
}
|
|
607
|
-
setIgnoreBike(ignore) {
|
|
608
|
-
this.ignore = ignore;
|
|
609
|
-
}
|
|
610
|
-
setIgnorePower(ignore) {
|
|
611
|
-
this.ignore = ignore;
|
|
612
|
-
}
|
|
613
|
-
onDeviceData(deviceData) {
|
|
614
|
-
if (this.prevDataTS && Date.now() - this.prevDataTS < 1000)
|
|
615
|
-
return;
|
|
616
|
-
this.prevDataTS = Date.now();
|
|
617
|
-
this.logger.logEvent({ message: 'onDeviceData', data: deviceData });
|
|
618
|
-
let incyclistData = this.mapData(deviceData);
|
|
619
|
-
incyclistData = this.getCyclingMode().updateData(incyclistData);
|
|
620
|
-
const data = this.transformData(incyclistData);
|
|
621
|
-
if (this.onDataFn && !this.ignore && !this.paused)
|
|
622
|
-
this.onDataFn(data);
|
|
623
|
-
}
|
|
624
|
-
mapData(deviceData) {
|
|
625
|
-
const data = {
|
|
626
|
-
isPedalling: false,
|
|
627
|
-
power: 0,
|
|
628
|
-
pedalRpm: undefined,
|
|
629
|
-
speed: 0,
|
|
630
|
-
heartrate: 0,
|
|
631
|
-
distanceInternal: 0,
|
|
632
|
-
slope: undefined,
|
|
633
|
-
time: undefined
|
|
634
|
-
};
|
|
635
|
-
data.power = (deviceData.instantaneousPower !== undefined ? deviceData.instantaneousPower : data.power);
|
|
636
|
-
data.pedalRpm = (deviceData.cadence !== undefined ? deviceData.cadence : data.pedalRpm);
|
|
637
|
-
data.time = (deviceData.time !== undefined ? deviceData.time : data.time);
|
|
638
|
-
data.isPedalling = data.pedalRpm > 0 || (data.pedalRpm === undefined && data.power > 0);
|
|
639
|
-
return data;
|
|
640
|
-
}
|
|
641
|
-
transformData(bikeData) {
|
|
642
|
-
if (this.ignore) {
|
|
643
|
-
return {};
|
|
644
|
-
}
|
|
645
|
-
if (bikeData === undefined)
|
|
646
|
-
return;
|
|
647
|
-
let distance = 0;
|
|
648
|
-
if (this.distanceInternal !== undefined && bikeData.distanceInternal !== undefined) {
|
|
649
|
-
distance = Math.round(bikeData.distanceInternal - this.distanceInternal);
|
|
650
|
-
}
|
|
651
|
-
if (bikeData.distanceInternal !== undefined)
|
|
652
|
-
this.distanceInternal = bikeData.distanceInternal;
|
|
653
|
-
let data = {
|
|
654
|
-
speed: bikeData.speed,
|
|
655
|
-
slope: bikeData.slope,
|
|
656
|
-
power: bikeData.power !== undefined ? Math.round(bikeData.power) : undefined,
|
|
657
|
-
cadence: bikeData.pedalRpm !== undefined ? Math.round(bikeData.pedalRpm) : undefined,
|
|
658
|
-
distance,
|
|
659
|
-
timestamp: Date.now()
|
|
660
|
-
};
|
|
661
|
-
return data;
|
|
662
|
-
}
|
|
663
|
-
start(props) {
|
|
664
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
665
|
-
this.logger.logEvent({ message: 'ftms: start requested', profile: this.getProfile(), props });
|
|
666
|
-
const { restart } = props || {};
|
|
667
|
-
if (!restart && this.ble.isScanning())
|
|
668
|
-
yield this.ble.stopScan();
|
|
669
|
-
try {
|
|
670
|
-
let bleDevice;
|
|
671
|
-
if (!this.device || !restart) {
|
|
672
|
-
bleDevice = (yield this.ble.connectDevice(this.device));
|
|
673
|
-
this.device = bleDevice;
|
|
674
|
-
}
|
|
675
|
-
else
|
|
676
|
-
bleDevice = this.device;
|
|
677
|
-
if (bleDevice) {
|
|
678
|
-
bleDevice.setLogger(this.logger);
|
|
679
|
-
const mode = this.getCyclingMode();
|
|
680
|
-
if (mode && mode.getSetting('bikeType')) {
|
|
681
|
-
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
682
|
-
this.device.setCrr(cRR);
|
|
683
|
-
switch (bikeType) {
|
|
684
|
-
case 'race':
|
|
685
|
-
this.device.setCw(cwABike.race);
|
|
686
|
-
break;
|
|
687
|
-
case 'triathlon':
|
|
688
|
-
this.device.setCw(cwABike.triathlon);
|
|
689
|
-
break;
|
|
690
|
-
case 'mountain':
|
|
691
|
-
this.device.setCw(cwABike.mountain);
|
|
692
|
-
break;
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
let hasControl = yield this.device.requestControl();
|
|
696
|
-
if (!hasControl) {
|
|
697
|
-
let retry = 1;
|
|
698
|
-
while (!hasControl && retry < 3) {
|
|
699
|
-
yield sleep(1000);
|
|
700
|
-
hasControl = yield this.device.requestControl();
|
|
701
|
-
retry++;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
if (!hasControl)
|
|
705
|
-
throw new Error('could not establish control');
|
|
706
|
-
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
707
|
-
yield this.sendUpdate(startRequest);
|
|
708
|
-
bleDevice.on('data', (data) => {
|
|
709
|
-
this.onDeviceData(data);
|
|
710
|
-
});
|
|
711
|
-
bleDevice.on('disconnected', this.emit);
|
|
712
|
-
return true;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
catch (err) {
|
|
716
|
-
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
717
|
-
throw new Error(`could not start device, reason:${err.message}`);
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
stop() {
|
|
722
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
723
|
-
this.logger.logEvent({ message: 'stop requested', profile: this.getProfile() });
|
|
724
|
-
this.distanceInternal = 0;
|
|
725
|
-
this.device.reset();
|
|
726
|
-
return this.device.disconnect();
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
sendUpdate(request) {
|
|
730
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
731
|
-
if (this.paused || !this.device)
|
|
732
|
-
return;
|
|
733
|
-
const update = this.getCyclingMode().sendBikeUpdate(request);
|
|
734
|
-
this.logger.logEvent({ message: 'send bike update requested', profile: this.getProfile(), update, request });
|
|
735
|
-
if (update.slope !== undefined) {
|
|
736
|
-
yield this.device.setSlope(update.slope);
|
|
737
|
-
}
|
|
738
|
-
if (update.targetPower !== undefined) {
|
|
739
|
-
yield this.device.setTargetPower(update.targetPower);
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
pause() { this.paused = true; return Promise.resolve(true); }
|
|
744
|
-
resume() { this.paused = false; return Promise.resolve(true); }
|
|
745
|
-
}
|
|
746
|
-
exports.FmAdapter = FmAdapter;
|
|
@@ -0,0 +1,13 @@
|
|
|
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.cwABike = exports.cRR = exports.BleFmComms = exports.BleFmAdapter = void 0;
|
|
7
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
8
|
+
exports.BleFmComms = comms_1.default;
|
|
9
|
+
const adapter_1 = __importDefault(require("./adapter"));
|
|
10
|
+
exports.BleFmAdapter = adapter_1.default;
|
|
11
|
+
const consts_1 = require("./consts");
|
|
12
|
+
Object.defineProperty(exports, "cRR", { enumerable: true, get: function () { return consts_1.cRR; } });
|
|
13
|
+
Object.defineProperty(exports, "cwABike", { enumerable: true, get: function () { return consts_1.cwABike; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type IndoorBikeData = {
|
|
2
|
+
speed?: number;
|
|
3
|
+
averageSpeed?: number;
|
|
4
|
+
cadence?: number;
|
|
5
|
+
averageCadence?: number;
|
|
6
|
+
totalDistance?: number;
|
|
7
|
+
resistanceLevel?: number;
|
|
8
|
+
instantaneousPower?: number;
|
|
9
|
+
averagePower?: number;
|
|
10
|
+
totalEnergy?: number;
|
|
11
|
+
energyPerHour?: number;
|
|
12
|
+
energyPerMinute?: number;
|
|
13
|
+
heartrate?: number;
|
|
14
|
+
metabolicEquivalent?: number;
|
|
15
|
+
time?: number;
|
|
16
|
+
remainingTime?: number;
|
|
17
|
+
raw?: string;
|
|
18
|
+
targetPower?: number;
|
|
19
|
+
targetInclination?: number;
|
|
20
|
+
status?: string;
|
|
21
|
+
};
|
|
22
|
+
export type IndoorBikeFeatures = {
|
|
23
|
+
fitnessMachine: number;
|
|
24
|
+
targetSettings: number;
|
|
25
|
+
power?: boolean;
|
|
26
|
+
heartrate?: boolean;
|
|
27
|
+
cadence?: boolean;
|
|
28
|
+
setSlope?: boolean;
|
|
29
|
+
setPower?: boolean;
|
|
30
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import BleAdapter from '../base/adapter';
|
|
2
|
+
import { DeviceProperties } from '../../types/device';
|
|
3
|
+
import { BleDeviceSettings } from '../types';
|
|
4
|
+
import { HrmData } from './types';
|
|
5
|
+
import { DeviceData } from '../../types/data';
|
|
6
|
+
export default class HrmAdapter extends BleAdapter {
|
|
7
|
+
ignore: boolean;
|
|
8
|
+
constructor(settings: BleDeviceSettings, props?: DeviceProperties);
|
|
9
|
+
isSame(device: BleAdapter): boolean;
|
|
10
|
+
getProfile(): string;
|
|
11
|
+
getName(): string;
|
|
12
|
+
getDisplayName(): string;
|
|
13
|
+
mapData(deviceData: HrmData): DeviceData;
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
7
|
+
const adapter_1 = __importDefault(require("../base/adapter"));
|
|
8
|
+
const comm_1 = __importDefault(require("./comm"));
|
|
9
|
+
const capabilities_1 = require("../../types/capabilities");
|
|
10
|
+
class HrmAdapter extends adapter_1.default {
|
|
11
|
+
constructor(settings, props) {
|
|
12
|
+
super(settings, props);
|
|
13
|
+
this.ignore = false;
|
|
14
|
+
this.logger = new gd_eventlog_1.EventLogger('Ble-HR');
|
|
15
|
+
const { id, address, name } = settings;
|
|
16
|
+
const logger = this.logger;
|
|
17
|
+
const ble = this.ble;
|
|
18
|
+
this.device = new comm_1.default({ id, address, name, ble, logger });
|
|
19
|
+
this.capabilities = [
|
|
20
|
+
capabilities_1.IncyclistCapability.HeartRate
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
isSame(device) {
|
|
24
|
+
if (!(device instanceof HrmAdapter))
|
|
25
|
+
return false;
|
|
26
|
+
return this.isEqual(device.settings);
|
|
27
|
+
}
|
|
28
|
+
getProfile() {
|
|
29
|
+
return 'Heartrate Monitor';
|
|
30
|
+
}
|
|
31
|
+
getName() {
|
|
32
|
+
return `${this.device.name}`;
|
|
33
|
+
}
|
|
34
|
+
getDisplayName() {
|
|
35
|
+
const { name } = this.device;
|
|
36
|
+
const { heartrate: hrm } = this.deviceData;
|
|
37
|
+
const hrmStr = hrm ? ` (${hrm})` : '';
|
|
38
|
+
return `${name}${hrmStr}`;
|
|
39
|
+
}
|
|
40
|
+
mapData(deviceData) {
|
|
41
|
+
const { heartrate } = deviceData;
|
|
42
|
+
return { heartrate };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = HrmAdapter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { LegacyProfile } from '../../antv2/types';
|
|
3
|
+
import { BleComms } from '../base/comms';
|
|
4
|
+
import { BleProtocol } from '../types';
|
|
5
|
+
import { HrmData } from './types';
|
|
6
|
+
export default class BleHrmDevice extends BleComms {
|
|
7
|
+
static protocol: BleProtocol;
|
|
8
|
+
static services: string[];
|
|
9
|
+
static characteristics: string[];
|
|
10
|
+
static detectionPriority: number;
|
|
11
|
+
heartrate: number;
|
|
12
|
+
rr: number;
|
|
13
|
+
constructor(props?: any);
|
|
14
|
+
getProfile(): LegacyProfile;
|
|
15
|
+
getProtocol(): BleProtocol;
|
|
16
|
+
getServiceUUids(): string[];
|
|
17
|
+
parseHrm(_data: Uint8Array): HrmData;
|
|
18
|
+
onData(characteristic: string, data: Buffer): boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const comms_1 = require("../base/comms");
|
|
4
|
+
class BleHrmDevice extends comms_1.BleComms {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.heartrate = undefined;
|
|
8
|
+
this.rr = undefined;
|
|
9
|
+
}
|
|
10
|
+
getProfile() {
|
|
11
|
+
return 'Heartrate Monitor';
|
|
12
|
+
}
|
|
13
|
+
getProtocol() {
|
|
14
|
+
return BleHrmDevice.protocol;
|
|
15
|
+
}
|
|
16
|
+
getServiceUUids() {
|
|
17
|
+
return BleHrmDevice.services;
|
|
18
|
+
}
|
|
19
|
+
parseHrm(_data) {
|
|
20
|
+
const data = Buffer.from(_data);
|
|
21
|
+
try {
|
|
22
|
+
const flags = data.readUInt8(0);
|
|
23
|
+
let offset = 2;
|
|
24
|
+
if (flags % 1 === 0) {
|
|
25
|
+
this.heartrate = data.readUInt8(1);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.heartrate = data.readUInt16LE(1);
|
|
29
|
+
offset = 3;
|
|
30
|
+
}
|
|
31
|
+
if (flags % 0xF) {
|
|
32
|
+
this.rr = (data.readUInt16LE(offset)) / 1024;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
}
|
|
37
|
+
const { heartrate, rr } = this;
|
|
38
|
+
return { heartrate, rr, raw: data.toString('hex') };
|
|
39
|
+
}
|
|
40
|
+
onData(characteristic, data) {
|
|
41
|
+
const hasData = super.onData(characteristic, data);
|
|
42
|
+
if (!hasData)
|
|
43
|
+
return;
|
|
44
|
+
if (characteristic.toLocaleLowerCase() === '2a37') {
|
|
45
|
+
const res = this.parseHrm(data);
|
|
46
|
+
this.emit('data', res);
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.default = BleHrmDevice;
|
|
53
|
+
BleHrmDevice.protocol = 'hr';
|
|
54
|
+
BleHrmDevice.services = ['180d'];
|
|
55
|
+
BleHrmDevice.characteristics = ['2a37', '2a38', '2a39', '2a3c'];
|
|
56
|
+
BleHrmDevice.detectionPriority = 1;
|
|
@@ -0,0 +1,10 @@
|
|
|
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.BleHrmComms = exports.BleHrmAdapter = void 0;
|
|
7
|
+
const adapter_1 = __importDefault(require("./adapter"));
|
|
8
|
+
exports.BleHrmAdapter = adapter_1.default;
|
|
9
|
+
const comm_1 = __importDefault(require("./comm"));
|
|
10
|
+
exports.BleHrmComms = comm_1.default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HrMock = void 0;
|
|
4
|
+
const types_1 = require("../bindings/types");
|
|
5
|
+
class HeartRateMeasuremenCharacteristic extends types_1.StaticNotifyCharacteristic {
|
|
6
|
+
constructor(uuid, description, heartrate = 0) {
|
|
7
|
+
super(uuid, description);
|
|
8
|
+
this.heartrate = heartrate;
|
|
9
|
+
this.value = Buffer.from(this.heartrate.toString());
|
|
10
|
+
}
|
|
11
|
+
notify() {
|
|
12
|
+
const buffer = Buffer.alloc(2);
|
|
13
|
+
buffer.writeUInt8(0, 0);
|
|
14
|
+
buffer.writeUInt8(this.heartrate, 1);
|
|
15
|
+
this.emit('data', buffer);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const HR = {
|
|
19
|
+
uuid: "180d",
|
|
20
|
+
characteristics: [
|
|
21
|
+
new HeartRateMeasuremenCharacteristic('2a37', 'Heart Rate Measurement', 60)
|
|
22
|
+
]
|
|
23
|
+
};
|
|
24
|
+
const DIS = {
|
|
25
|
+
uuid: '180a',
|
|
26
|
+
characteristics: [
|
|
27
|
+
new types_1.StaticReadCharacteristic('2a23', 'System Id', '0'),
|
|
28
|
+
new types_1.StaticReadCharacteristic('2a24', 'Model Number', '1'),
|
|
29
|
+
new types_1.StaticReadCharacteristic('2a25', 'Serial Number', '4711'),
|
|
30
|
+
new types_1.StaticReadCharacteristic('2a26', 'Firmware Revision', '1'),
|
|
31
|
+
new types_1.StaticReadCharacteristic('2a27', 'Hardware Revision', '1'),
|
|
32
|
+
new types_1.StaticReadCharacteristic('2a28', 'Software Revision', '1'),
|
|
33
|
+
new types_1.StaticReadCharacteristic('2a29', 'Manufacturer Name', 'Incyclist')
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
exports.HrMock = {
|
|
37
|
+
services: [HR, DIS],
|
|
38
|
+
id: "a87b6100820d48b1401bf83a8cf6f046",
|
|
39
|
+
name: "HRM-Mock",
|
|
40
|
+
address: "a87b6100820d48b1401bf83a8cf6f046",
|
|
41
|
+
setNotifyFrequency: (ms) => {
|
|
42
|
+
HR.characteristics[0].notifyFrequency = ms;
|
|
43
|
+
},
|
|
44
|
+
setHeartrate: (hr) => {
|
|
45
|
+
HR.characteristics[0].heartrate = hr;
|
|
46
|
+
}
|
|
47
|
+
};
|