incyclist-devices 1.5.37 → 2.0.0-beta.1
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 +0 -0
- package/lib/adapters.d.ts +6 -0
- package/lib/adapters.js +30 -0
- package/lib/antv2/adapter-factory.d.ts +20 -10
- package/lib/antv2/adapter-factory.js +49 -33
- package/lib/antv2/adapter.d.ts +64 -0
- package/lib/antv2/adapter.js +299 -0
- package/lib/antv2/ant-interface.d.ts +11 -9
- package/lib/antv2/ant-interface.js +15 -11
- package/lib/antv2/fe/adapter.d.ts +25 -0
- package/lib/antv2/{fe.js → fe/adapter.js} +48 -72
- package/lib/antv2/fe/index.d.ts +2 -0
- package/lib/antv2/fe/index.js +7 -0
- package/lib/antv2/hr/adapter.d.ts +14 -0
- package/lib/antv2/hr/adapter.js +73 -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 +22 -0
- package/lib/antv2/{pwr.js → pwr/adapter.js} +38 -76
- package/lib/antv2/pwr/index.d.ts +2 -0
- package/lib/antv2/pwr/index.js +7 -0
- package/lib/antv2/types.d.ts +19 -0
- package/lib/antv2/types.js +2 -0
- package/lib/antv2/utils.d.ts +1 -0
- package/lib/antv2/utils.js +181 -0
- package/lib/base/adpater.d.ts +56 -0
- package/lib/base/adpater.js +144 -0
- package/lib/ble/adapter-factory.d.ts +31 -0
- package/lib/ble/adapter-factory.js +96 -0
- package/lib/ble/adapter.d.ts +41 -0
- package/lib/ble/adapter.js +188 -0
- package/lib/ble/{ble-device.d.ts → ble-comms.d.ts} +9 -4
- package/lib/ble/{ble-device.js → ble-comms.js} +23 -11
- package/lib/ble/ble-interface.d.ts +15 -24
- package/lib/ble/ble-interface.js +32 -137
- package/lib/ble/ble-peripheral.d.ts +3 -3
- package/lib/ble/ble-peripheral.js +14 -14
- package/lib/ble/ble.d.ts +9 -81
- package/lib/ble/ble.js +1 -39
- package/lib/ble/consts.d.ts +2 -0
- package/lib/ble/consts.js +3 -1
- package/lib/ble/cp/adapter.d.ts +23 -0
- package/lib/ble/cp/adapter.js +124 -0
- package/lib/ble/cp/comm.d.ts +28 -0
- package/lib/ble/cp/comm.js +140 -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 +20 -0
- package/lib/ble/elite/adapter.js +127 -0
- package/lib/ble/elite/comms.d.ts +28 -0
- package/lib/ble/elite/comms.js +139 -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 +21 -0
- package/lib/ble/fm/adapter.js +190 -0
- package/lib/ble/fm/comms.d.ts +50 -0
- package/lib/ble/{fm.js → fm/comms.js} +3 -224
- 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 +25 -0
- package/lib/ble/fm/types.js +2 -0
- package/lib/ble/hr/adapter.d.ts +17 -0
- package/lib/ble/hr/adapter.js +62 -0
- package/lib/ble/hr/comm.d.ts +15 -0
- package/lib/ble/hr/comm.js +52 -0
- package/lib/ble/hr/index.d.ts +4 -0
- package/lib/ble/hr/index.js +10 -0
- package/lib/ble/hr/types.d.ts +5 -0
- package/lib/ble/hr/types.js +2 -0
- package/lib/ble/index.d.ts +8 -0
- package/lib/ble/index.js +26 -0
- package/lib/ble/tacx/adapter.d.ts +10 -0
- package/lib/ble/tacx/adapter.js +93 -0
- package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +6 -38
- package/lib/ble/{tacx.js → tacx/comms.js} +13 -112
- 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 +101 -0
- package/lib/ble/types.js +19 -0
- package/lib/ble/utils.d.ts +7 -0
- package/lib/ble/utils.js +95 -0
- package/lib/ble/wahoo/adapter.d.ts +9 -0
- package/lib/ble/wahoo/adapter.js +93 -0
- package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +5 -39
- package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +14 -112
- 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/device.d.ts +0 -94
- package/lib/device.js +0 -76
- package/lib/index.d.ts +12 -0
- package/lib/index.js +38 -0
- package/lib/interfaces.d.ts +6 -0
- package/lib/interfaces.js +23 -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 +4 -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 +16 -0
- package/lib/serial/adapter.js +42 -0
- package/lib/serial/bindings/tcp.d.ts +44 -0
- package/lib/serial/bindings/tcp.js +270 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/{daum → serial/daum}/DaumAdapter.d.ts +13 -22
- package/lib/{daum → serial/daum}/DaumAdapter.js +44 -90
- 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 +24 -0
- package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +99 -46
- 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} +214 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +290 -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 +13 -24
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +87 -130
- 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 +58 -0
- package/lib/serial/serial-interface.js +283 -0
- package/lib/simulator/Simulator.d.ts +10 -25
- package/lib/simulator/Simulator.js +19 -83
- package/lib/types/adapter.d.ts +32 -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 +29 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +14 -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 +15 -11
- 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/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/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/antv2/{ant-binding.d.ts → binding.d.ts} +0 -0
- /package/lib/antv2/{ant-binding.js → binding.js} +0 -0
- /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,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ble_comms_1 = require("../ble-comms");
|
|
4
|
+
class BleHrmDevice extends ble_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
|
+
getServiceUUids() {
|
|
14
|
+
return BleHrmDevice.services;
|
|
15
|
+
}
|
|
16
|
+
parseHrm(_data) {
|
|
17
|
+
const data = Buffer.from(_data);
|
|
18
|
+
try {
|
|
19
|
+
const flags = data.readUInt8(0);
|
|
20
|
+
let offset = 2;
|
|
21
|
+
if (flags % 1 === 0) {
|
|
22
|
+
this.heartrate = data.readUInt8(1);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.heartrate = data.readUInt16LE(1);
|
|
26
|
+
offset = 3;
|
|
27
|
+
}
|
|
28
|
+
if (flags % 0xF) {
|
|
29
|
+
this.rr = (data.readUInt16LE(offset)) / 1024;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
}
|
|
34
|
+
const { heartrate, rr } = this;
|
|
35
|
+
return { heartrate, rr, raw: data.toString('hex') };
|
|
36
|
+
}
|
|
37
|
+
onData(characteristic, data) {
|
|
38
|
+
const hasData = super.onData(characteristic, data);
|
|
39
|
+
if (!hasData)
|
|
40
|
+
return;
|
|
41
|
+
if (characteristic.toLocaleLowerCase() === '2a37') {
|
|
42
|
+
const res = this.parseHrm(data);
|
|
43
|
+
this.emit('data', res);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.default = BleHrmDevice;
|
|
50
|
+
BleHrmDevice.services = ['180d'];
|
|
51
|
+
BleHrmDevice.characteristics = ['2a37', '2a38', '2a39', '2a3c'];
|
|
52
|
+
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,8 @@
|
|
|
1
|
+
import BleInterface from './ble-interface';
|
|
2
|
+
import BleAdapterFactory from './adapter-factory';
|
|
3
|
+
import { BleHrmAdapter } from './hr';
|
|
4
|
+
import { BlePwrAdapter } from './cp';
|
|
5
|
+
import { BleFmAdapter } from './fm';
|
|
6
|
+
import { BleWahooAdapter } from './wahoo';
|
|
7
|
+
import { BleTacxAdapter } from './tacx';
|
|
8
|
+
export { BleAdapterFactory, BleInterface, BleHrmAdapter, BlePwrAdapter, BleFmAdapter, BleWahooAdapter, BleTacxAdapter };
|
package/lib/ble/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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.BleTacxAdapter = exports.BleWahooAdapter = exports.BleFmAdapter = exports.BlePwrAdapter = exports.BleHrmAdapter = exports.BleInterface = exports.BleAdapterFactory = void 0;
|
|
7
|
+
const ble_interface_1 = __importDefault(require("./ble-interface"));
|
|
8
|
+
exports.BleInterface = ble_interface_1.default;
|
|
9
|
+
const adapter_factory_1 = __importDefault(require("./adapter-factory"));
|
|
10
|
+
exports.BleAdapterFactory = adapter_factory_1.default;
|
|
11
|
+
const hr_1 = require("./hr");
|
|
12
|
+
Object.defineProperty(exports, "BleHrmAdapter", { enumerable: true, get: function () { return hr_1.BleHrmAdapter; } });
|
|
13
|
+
const cp_1 = require("./cp");
|
|
14
|
+
Object.defineProperty(exports, "BlePwrAdapter", { enumerable: true, get: function () { return cp_1.BlePwrAdapter; } });
|
|
15
|
+
const fm_1 = require("./fm");
|
|
16
|
+
Object.defineProperty(exports, "BleFmAdapter", { enumerable: true, get: function () { return fm_1.BleFmAdapter; } });
|
|
17
|
+
const wahoo_1 = require("./wahoo");
|
|
18
|
+
Object.defineProperty(exports, "BleWahooAdapter", { enumerable: true, get: function () { return wahoo_1.BleWahooAdapter; } });
|
|
19
|
+
const tacx_1 = require("./tacx");
|
|
20
|
+
Object.defineProperty(exports, "BleTacxAdapter", { enumerable: true, get: function () { return tacx_1.BleTacxAdapter; } });
|
|
21
|
+
const af = adapter_factory_1.default.getInstance();
|
|
22
|
+
af.register('hr', 'Heartrate Monitor', hr_1.BleHrmAdapter, hr_1.BleHrmComms);
|
|
23
|
+
af.register('cp', 'Power Meter', cp_1.BlePwrAdapter, cp_1.BlePwrComms);
|
|
24
|
+
af.register('fm', 'Smart Trainer', fm_1.BleFmAdapter, fm_1.BleFmComms);
|
|
25
|
+
af.register('wahoo', 'Smart Trainer', wahoo_1.BleWahooAdapter, wahoo_1.BleWahooComms);
|
|
26
|
+
af.register('tacx', 'Smart Trainer', tacx_1.BleTacxAdapter, tacx_1.BleTacxComms);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BleFmAdapter } from '../fm';
|
|
2
|
+
import BleAdapter from '../adapter';
|
|
3
|
+
import { DeviceProperties } from '../../types/device';
|
|
4
|
+
import { BleDeviceSettings, BleStartProperties } from '../types';
|
|
5
|
+
export default class BleTacxFEAdapter extends BleFmAdapter {
|
|
6
|
+
constructor(settings: BleDeviceSettings, props?: DeviceProperties);
|
|
7
|
+
isSame(device: BleAdapter): boolean;
|
|
8
|
+
getProfile(): string;
|
|
9
|
+
start(props?: BleStartProperties): Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
16
|
+
const fm_1 = require("../fm");
|
|
17
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
18
|
+
const adpater_1 = require("../../base/adpater");
|
|
19
|
+
const capabilities_1 = require("../../types/capabilities");
|
|
20
|
+
class BleTacxFEAdapter extends fm_1.BleFmAdapter {
|
|
21
|
+
constructor(settings, props) {
|
|
22
|
+
super(settings, props);
|
|
23
|
+
this.logger = new gd_eventlog_1.EventLogger('BLE-FEC-Tacx');
|
|
24
|
+
const { id, address, name } = settings;
|
|
25
|
+
const logger = this.logger;
|
|
26
|
+
const ble = this.ble;
|
|
27
|
+
this.device = new comms_1.default({ id, address, name, ble, logger });
|
|
28
|
+
this.capabilities = [
|
|
29
|
+
capabilities_1.IncyclistCapability.Power, capabilities_1.IncyclistCapability.Speed, capabilities_1.IncyclistCapability.Cadence,
|
|
30
|
+
capabilities_1.IncyclistCapability.Control
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
isSame(device) {
|
|
34
|
+
if (!(device instanceof BleTacxFEAdapter))
|
|
35
|
+
return false;
|
|
36
|
+
return this.isEqual(device.settings);
|
|
37
|
+
}
|
|
38
|
+
getProfile() {
|
|
39
|
+
return 'Smart Trainer';
|
|
40
|
+
}
|
|
41
|
+
start(props = {}) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
this.logger.logEvent({ message: 'start requested', protocol: this.getProtocolName(), props });
|
|
44
|
+
if (this.ble.isScanning())
|
|
45
|
+
yield this.ble.stopScan();
|
|
46
|
+
try {
|
|
47
|
+
const bleDevice = yield this.ble.connectDevice(this.device);
|
|
48
|
+
bleDevice.setLogger(this.logger);
|
|
49
|
+
if (bleDevice) {
|
|
50
|
+
this.device = bleDevice;
|
|
51
|
+
const mode = this.getCyclingMode();
|
|
52
|
+
if (mode && mode.getSetting('bikeType')) {
|
|
53
|
+
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
54
|
+
bleDevice.setCrr(fm_1.cRR);
|
|
55
|
+
switch (bikeType) {
|
|
56
|
+
case 'race':
|
|
57
|
+
bleDevice.setCw(fm_1.cwABike.race);
|
|
58
|
+
break;
|
|
59
|
+
case 'triathlon':
|
|
60
|
+
bleDevice.setCw(fm_1.cwABike.triathlon);
|
|
61
|
+
break;
|
|
62
|
+
case 'mountain':
|
|
63
|
+
bleDevice.setCw(fm_1.cwABike.mountain);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const { user, wheelDiameter, gearRatio, bikeWeight = adpater_1.DEFAULT_BIKE_WEIGHT } = props || {};
|
|
68
|
+
const userWeight = (user && user.weight ? user.weight : adpater_1.DEFAULT_USER_WEIGHT);
|
|
69
|
+
bleDevice.sendTrackResistance(0.0);
|
|
70
|
+
bleDevice.sendUserConfiguration(userWeight, bikeWeight, wheelDiameter, gearRatio);
|
|
71
|
+
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
72
|
+
yield this.sendUpdate(startRequest);
|
|
73
|
+
bleDevice.on('data', (data) => {
|
|
74
|
+
this.onDeviceData(data);
|
|
75
|
+
});
|
|
76
|
+
this.resetData();
|
|
77
|
+
this.stopped = false;
|
|
78
|
+
this.started = true;
|
|
79
|
+
this.paused = false;
|
|
80
|
+
if (bleDevice.isHrm() && !this.hasCapability(capabilities_1.IncyclistCapability.HeartRate)) {
|
|
81
|
+
this.capabilities.push(capabilities_1.IncyclistCapability.HeartRate);
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
88
|
+
throw new Error(`could not start device, reason:${err.message}`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.default = BleTacxFEAdapter;
|
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
interface BleFeBikeData extends IndoorBikeData {
|
|
8
|
-
EquipmentType?: 'Treadmill' | 'Elliptical' | 'StationaryBike' | 'Rower' | 'Climber' | 'NordicSkier' | 'Trainer' | 'General';
|
|
9
|
-
RealSpeed?: number;
|
|
10
|
-
VirtualSpeed?: number;
|
|
11
|
-
HeartRateSource?: 'HandContact' | 'EM' | 'ANT+';
|
|
12
|
-
State?: 'OFF' | 'READY' | 'IN_USE' | 'FINISHED';
|
|
13
|
-
EventCount?: number;
|
|
14
|
-
AccumulatedPower?: number;
|
|
15
|
-
TrainerStatus?: number;
|
|
16
|
-
TargetStatus?: 'OnTarget' | 'LowSpeed' | 'HighSpeed';
|
|
17
|
-
HwVersion?: number;
|
|
18
|
-
ManId?: number;
|
|
19
|
-
ModelNum?: number;
|
|
20
|
-
SwVersion?: number;
|
|
21
|
-
SerialNumber?: number;
|
|
22
|
-
}
|
|
23
|
-
declare type CrankData = {
|
|
24
|
-
revolutions?: number;
|
|
25
|
-
time?: number;
|
|
26
|
-
cntUpdateMissing?: number;
|
|
27
|
-
};
|
|
2
|
+
import { CrankData } from "../cp";
|
|
3
|
+
import { IndoorBikeData } from "../fm";
|
|
4
|
+
import BleFitnessMachineDevice from "../fm/comms";
|
|
5
|
+
import { IBlePeripheralConnector } from "../types";
|
|
6
|
+
import { BleFeBikeData } from "./types";
|
|
28
7
|
export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineDevice {
|
|
29
8
|
static services: string[];
|
|
30
9
|
static characteristics: string[];
|
|
@@ -42,7 +21,7 @@ export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineD
|
|
|
42
21
|
constructor(props?: any);
|
|
43
22
|
isMatching(characteristics: string[]): boolean;
|
|
44
23
|
setCharacteristicUUIDs(uuids: string[]): void;
|
|
45
|
-
subscribeAll(conn?:
|
|
24
|
+
subscribeAll(conn?: IBlePeripheralConnector): Promise<void>;
|
|
46
25
|
init(): Promise<boolean>;
|
|
47
26
|
getProfile(): string;
|
|
48
27
|
getServiceUUids(): string[];
|
|
@@ -79,14 +58,3 @@ export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineD
|
|
|
79
58
|
setSlope(slope: any): Promise<boolean>;
|
|
80
59
|
reset(): void;
|
|
81
60
|
}
|
|
82
|
-
export declare class TacxBleFEAdapter extends FmAdapter {
|
|
83
|
-
static PROFILE: string;
|
|
84
|
-
device: TacxAdvancedFitnessMachineDevice;
|
|
85
|
-
constructor(device: BleDeviceClass, protocol: BleProtocol);
|
|
86
|
-
isSame(device: DeviceAdapter): boolean;
|
|
87
|
-
getProfile(): string;
|
|
88
|
-
start(props?: any): Promise<any>;
|
|
89
|
-
pause(): Promise<boolean>;
|
|
90
|
-
resume(): Promise<boolean>;
|
|
91
|
-
}
|
|
92
|
-
export {};
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,23 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
13
|
};
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const device_1 = require("../device");
|
|
38
|
-
const gd_eventlog_1 = require("gd-eventlog");
|
|
39
|
-
const fm_1 = __importStar(require("./fm"));
|
|
40
|
-
const consts_1 = require("./consts");
|
|
41
|
-
const SYNC_BYTE = 0xA4;
|
|
42
|
-
const DEFAULT_CHANNEL = 5;
|
|
43
|
-
const ACKNOWLEDGED_DATA = 0x4F;
|
|
44
|
-
const PROFILE_ID = 'Tacx SmartTrainer';
|
|
45
|
-
const cwABike = {
|
|
46
|
-
race: 0.35,
|
|
47
|
-
triathlon: 0.29,
|
|
48
|
-
mountain: 0.57
|
|
49
|
-
};
|
|
50
|
-
const cRR = 0.0036;
|
|
15
|
+
const consts_1 = require("../consts");
|
|
16
|
+
const comms_1 = __importDefault(require("../fm/comms"));
|
|
17
|
+
const utils_1 = require("../utils");
|
|
51
18
|
var ANTMessages;
|
|
52
19
|
(function (ANTMessages) {
|
|
53
20
|
ANTMessages[ANTMessages["calibrationCommand"] = 1] = "calibrationCommand";
|
|
@@ -66,7 +33,11 @@ var ANTMessages;
|
|
|
66
33
|
ANTMessages[ANTMessages["manufactererData"] = 80] = "manufactererData";
|
|
67
34
|
ANTMessages[ANTMessages["productInformation"] = 81] = "productInformation";
|
|
68
35
|
})(ANTMessages || (ANTMessages = {}));
|
|
69
|
-
|
|
36
|
+
const PROFILE_ID = 'Tacx SmartTrainer';
|
|
37
|
+
const SYNC_BYTE = 0xA4;
|
|
38
|
+
const DEFAULT_CHANNEL = 5;
|
|
39
|
+
const ACKNOWLEDGED_DATA = 0x4F;
|
|
40
|
+
class TacxAdvancedFitnessMachineDevice extends comms_1.default {
|
|
70
41
|
constructor(props) {
|
|
71
42
|
super(props);
|
|
72
43
|
this.prevCrankData = undefined;
|
|
@@ -82,15 +53,15 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
82
53
|
isMatching(characteristics) {
|
|
83
54
|
if (!characteristics)
|
|
84
55
|
return false;
|
|
85
|
-
const hasTacxCP = characteristics.find(c => (0,
|
|
86
|
-
characteristics.find(c => (0,
|
|
56
|
+
const hasTacxCP = characteristics.find(c => (0, utils_1.matches)(c, consts_1.TACX_FE_C_RX)) !== undefined &&
|
|
57
|
+
characteristics.find(c => (0, utils_1.matches)(c, consts_1.TACX_FE_C_TX)) !== undefined;
|
|
87
58
|
return hasTacxCP;
|
|
88
59
|
}
|
|
89
60
|
setCharacteristicUUIDs(uuids) {
|
|
90
61
|
uuids.forEach(c => {
|
|
91
|
-
if ((0,
|
|
62
|
+
if ((0, utils_1.matches)(c, consts_1.TACX_FE_C_RX))
|
|
92
63
|
this.tacxRx = c;
|
|
93
|
-
if ((0,
|
|
64
|
+
if ((0, utils_1.matches)(c, consts_1.TACX_FE_C_TX))
|
|
94
65
|
this.tacxTx = c;
|
|
95
66
|
});
|
|
96
67
|
}
|
|
@@ -484,7 +455,7 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
484
455
|
try {
|
|
485
456
|
const uuid = characteristic.toLocaleLowerCase();
|
|
486
457
|
let res = undefined;
|
|
487
|
-
if (uuid && (0,
|
|
458
|
+
if (uuid && (0, utils_1.matches)(uuid, this.tacxRx)) {
|
|
488
459
|
res = this.parseFECMessage(data);
|
|
489
460
|
}
|
|
490
461
|
else {
|
|
@@ -693,73 +664,3 @@ TacxAdvancedFitnessMachineDevice.services = [consts_1.TACX_FE_C_BLE];
|
|
|
693
664
|
TacxAdvancedFitnessMachineDevice.characteristics = ['2acc', '2ad2', '2ad6', '2ad8', '2ad9', '2ada', consts_1.TACX_FE_C_RX, consts_1.TACX_FE_C_TX];
|
|
694
665
|
TacxAdvancedFitnessMachineDevice.PROFILE = PROFILE_ID;
|
|
695
666
|
TacxAdvancedFitnessMachineDevice.detectionPriority = 10;
|
|
696
|
-
ble_interface_1.default.register('TacxBleFEDevice', 'tacx-ble-fec', TacxAdvancedFitnessMachineDevice, TacxAdvancedFitnessMachineDevice.services);
|
|
697
|
-
class TacxBleFEAdapter extends fm_1.FmAdapter {
|
|
698
|
-
constructor(device, protocol) {
|
|
699
|
-
super(device, protocol);
|
|
700
|
-
this.device = device;
|
|
701
|
-
this.ble = protocol.ble;
|
|
702
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
703
|
-
this.logger = new gd_eventlog_1.EventLogger('BLE-FEC-Tacx');
|
|
704
|
-
if (this.device)
|
|
705
|
-
this.device.setLogger(this.logger);
|
|
706
|
-
}
|
|
707
|
-
isSame(device) {
|
|
708
|
-
if (!(device instanceof TacxBleFEAdapter))
|
|
709
|
-
return false;
|
|
710
|
-
const adapter = device;
|
|
711
|
-
return (adapter.getName() === this.getName() && adapter.getProfile() === this.getProfile());
|
|
712
|
-
}
|
|
713
|
-
getProfile() {
|
|
714
|
-
return TacxBleFEAdapter.PROFILE;
|
|
715
|
-
}
|
|
716
|
-
start(props) {
|
|
717
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
718
|
-
this.logger.logEvent({ message: 'tacx: start requested', profile: this.getProfile(), props });
|
|
719
|
-
if (this.ble.isScanning())
|
|
720
|
-
yield this.ble.stopScan();
|
|
721
|
-
try {
|
|
722
|
-
const bleDevice = yield this.ble.connectDevice(this.device);
|
|
723
|
-
bleDevice.setLogger(this.logger);
|
|
724
|
-
if (bleDevice) {
|
|
725
|
-
this.device = bleDevice;
|
|
726
|
-
const mode = this.getCyclingMode();
|
|
727
|
-
if (mode && mode.getSetting('bikeType')) {
|
|
728
|
-
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
729
|
-
this.device.setCrr(cRR);
|
|
730
|
-
switch (bikeType) {
|
|
731
|
-
case 'race':
|
|
732
|
-
this.device.setCw(cwABike.race);
|
|
733
|
-
break;
|
|
734
|
-
case 'triathlon':
|
|
735
|
-
this.device.setCw(cwABike.triathlon);
|
|
736
|
-
break;
|
|
737
|
-
case 'mountain':
|
|
738
|
-
this.device.setCw(cwABike.mountain);
|
|
739
|
-
break;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
const { user, wheelDiameter, gearRatio } = props || {};
|
|
743
|
-
const userWeight = (user && user.weight ? user.weight : device_1.DEFAULT_USER_WEIGHT);
|
|
744
|
-
const bikeWeight = device_1.DEFAULT_BIKE_WEIGHT;
|
|
745
|
-
this.device.sendTrackResistance(0.0);
|
|
746
|
-
this.device.sendUserConfiguration(userWeight, bikeWeight, wheelDiameter, gearRatio);
|
|
747
|
-
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
748
|
-
yield this.sendUpdate(startRequest);
|
|
749
|
-
bleDevice.on('data', (data) => {
|
|
750
|
-
this.onDeviceData(data);
|
|
751
|
-
});
|
|
752
|
-
return true;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
catch (err) {
|
|
756
|
-
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
757
|
-
throw new Error(`could not start device, reason:${err.message}`);
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
pause() { this.paused = true; return Promise.resolve(true); }
|
|
762
|
-
resume() { this.paused = false; return Promise.resolve(true); }
|
|
763
|
-
}
|
|
764
|
-
exports.TacxBleFEAdapter = TacxBleFEAdapter;
|
|
765
|
-
TacxBleFEAdapter.PROFILE = PROFILE_ID;
|
|
@@ -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.BleTacxComms = exports.BleTacxAdapter = void 0;
|
|
7
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
8
|
+
exports.BleTacxComms = comms_1.default;
|
|
9
|
+
const adapter_1 = __importDefault(require("./adapter"));
|
|
10
|
+
exports.BleTacxAdapter = adapter_1.default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IndoorBikeData } from "../fm";
|
|
2
|
+
export interface BleFeBikeData extends IndoorBikeData {
|
|
3
|
+
EquipmentType?: 'Treadmill' | 'Elliptical' | 'StationaryBike' | 'Rower' | 'Climber' | 'NordicSkier' | 'Trainer' | 'General';
|
|
4
|
+
RealSpeed?: number;
|
|
5
|
+
VirtualSpeed?: number;
|
|
6
|
+
HeartRateSource?: 'HandContact' | 'EM' | 'ANT+';
|
|
7
|
+
State?: 'OFF' | 'READY' | 'IN_USE' | 'FINISHED';
|
|
8
|
+
EventCount?: number;
|
|
9
|
+
AccumulatedPower?: number;
|
|
10
|
+
TrainerStatus?: number;
|
|
11
|
+
TargetStatus?: 'OnTarget' | 'LowSpeed' | 'HighSpeed';
|
|
12
|
+
HwVersion?: number;
|
|
13
|
+
ManId?: number;
|
|
14
|
+
ModelNum?: number;
|
|
15
|
+
SwVersion?: number;
|
|
16
|
+
SerialNumber?: number;
|
|
17
|
+
}
|
|
18
|
+
export type MessageInfo = {
|
|
19
|
+
message: string;
|
|
20
|
+
ts: number;
|
|
21
|
+
uuid: string;
|
|
22
|
+
};
|
|
23
|
+
export type MessageLog = {
|
|
24
|
+
[uuid: string]: MessageInfo;
|
|
25
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from "stream";
|
|
4
|
+
import { DeviceProperties, DeviceSettings } from "../types/device";
|
|
5
|
+
export interface BleDeviceSettings extends DeviceSettings {
|
|
6
|
+
id?: string;
|
|
7
|
+
profile: string;
|
|
8
|
+
protocol: string;
|
|
9
|
+
address?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface BleDeviceProperties extends DeviceProperties {
|
|
12
|
+
wheelDiameter?: number;
|
|
13
|
+
gearRatio?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface BleStartProperties extends BleDeviceProperties {
|
|
16
|
+
restart?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface BlePeripheral extends EventEmitter, BlePeripheralIdentifier {
|
|
19
|
+
services: string[];
|
|
20
|
+
advertisement: any;
|
|
21
|
+
state: string;
|
|
22
|
+
connectAsync(): Promise<void>;
|
|
23
|
+
disconnect(cb: (err?: Error) => void): Promise<void>;
|
|
24
|
+
discoverSomeServicesAndCharacteristicsAsync(serviceUUIDs: string[], characteristicUUIDs: string[]): Promise<any>;
|
|
25
|
+
}
|
|
26
|
+
export interface IBlePeripheralConnector {
|
|
27
|
+
connect(): Promise<void>;
|
|
28
|
+
reconnect(): Promise<void>;
|
|
29
|
+
initialize(enforce: boolean): Promise<void>;
|
|
30
|
+
isSubscribed(characteristicUuid: string): boolean;
|
|
31
|
+
subscribeAll(callback: (characteristicUuid: string, data: any) => void): Promise<string[]>;
|
|
32
|
+
subscribe(characteristicUuid: string, timeout?: number): Promise<boolean>;
|
|
33
|
+
onDisconnect(): void;
|
|
34
|
+
onData(characteristicUuid: string, data: any): void;
|
|
35
|
+
on(characteristicUuid: string, callback: (characteristicUuid: string, data: any) => void): void;
|
|
36
|
+
off(characteristicUuid: string, callback: (characteristicUuid: string, data: any) => void): void;
|
|
37
|
+
removeAllListeners(characteristicUuid: string): void;
|
|
38
|
+
getState(): string;
|
|
39
|
+
getCharachteristics(): BleCharacteristic[];
|
|
40
|
+
getServices(): string[];
|
|
41
|
+
getPeripheral(): BlePeripheral;
|
|
42
|
+
}
|
|
43
|
+
export interface BleCharacteristic extends EventEmitter {
|
|
44
|
+
uuid: string;
|
|
45
|
+
properties: string[];
|
|
46
|
+
subscribe(callback: (err: Error) => void): void;
|
|
47
|
+
read(callback: (err: Error, data: Buffer) => void): void;
|
|
48
|
+
write(data: Buffer, withoutResponse: boolean, callback?: (err: Error) => void): void;
|
|
49
|
+
}
|
|
50
|
+
export type BleDeviceProps = {
|
|
51
|
+
id?: string;
|
|
52
|
+
address?: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
services?: string[];
|
|
55
|
+
peripheral?: BlePeripheral;
|
|
56
|
+
};
|
|
57
|
+
export type ConnectProps = {
|
|
58
|
+
timeout?: number;
|
|
59
|
+
reconnect?: boolean;
|
|
60
|
+
};
|
|
61
|
+
export interface BleWriteProps {
|
|
62
|
+
withoutResponse?: boolean;
|
|
63
|
+
timeout?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface BlePeripheralIdentifier {
|
|
66
|
+
id?: string;
|
|
67
|
+
address?: string;
|
|
68
|
+
name?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface BlePeripheralDescription extends BlePeripheralIdentifier {
|
|
71
|
+
profile: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ConnectState {
|
|
74
|
+
isConnecting: boolean;
|
|
75
|
+
isConnected: boolean;
|
|
76
|
+
isDisconnecting: boolean;
|
|
77
|
+
}
|
|
78
|
+
export type BleDeviceInfo = {
|
|
79
|
+
manufacturer?: string;
|
|
80
|
+
hwRevision?: string;
|
|
81
|
+
swRevision?: string;
|
|
82
|
+
fwRevision?: string;
|
|
83
|
+
model?: string;
|
|
84
|
+
serialNo?: string;
|
|
85
|
+
};
|
|
86
|
+
export declare abstract class BleDeviceCommsClass extends EventEmitter {
|
|
87
|
+
static services: string[];
|
|
88
|
+
id?: string;
|
|
89
|
+
address?: string;
|
|
90
|
+
name?: string;
|
|
91
|
+
connectState: ConnectState;
|
|
92
|
+
getConnectState(): ConnectState;
|
|
93
|
+
isConnected(): boolean;
|
|
94
|
+
abstract getProfile(): string;
|
|
95
|
+
abstract getServiceUUids(): string[];
|
|
96
|
+
abstract connect(props?: ConnectProps): Promise<boolean>;
|
|
97
|
+
abstract disconnect(): Promise<boolean>;
|
|
98
|
+
abstract getDeviceInfo(): Promise<BleDeviceInfo>;
|
|
99
|
+
abstract getServices(): string[];
|
|
100
|
+
setCharacteristicUUIDs(uuids: string[]): void;
|
|
101
|
+
}
|
package/lib/ble/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BleDeviceCommsClass = void 0;
|
|
4
|
+
const stream_1 = require("stream");
|
|
5
|
+
class BleDeviceCommsClass extends stream_1.EventEmitter {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.connectState = { isConnecting: false, isConnected: false, isDisconnecting: false };
|
|
9
|
+
}
|
|
10
|
+
getConnectState() {
|
|
11
|
+
return this.connectState;
|
|
12
|
+
}
|
|
13
|
+
isConnected() {
|
|
14
|
+
return this.connectState.isConnected;
|
|
15
|
+
}
|
|
16
|
+
setCharacteristicUUIDs(uuids) { }
|
|
17
|
+
}
|
|
18
|
+
exports.BleDeviceCommsClass = BleDeviceCommsClass;
|
|
19
|
+
BleDeviceCommsClass.services = [];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BleComms } from "./ble-comms";
|
|
2
|
+
export declare function uuid(s: string): string;
|
|
3
|
+
export declare function matches(uuid1: string, uuid2: string): boolean;
|
|
4
|
+
export declare function getBestDeviceMatch(DeviceClasses: (typeof BleComms)[]): typeof BleComms;
|
|
5
|
+
export declare function getDevicesFromServices(deviceTypes: (typeof BleComms)[], services: string | string[]): (typeof BleComms)[];
|
|
6
|
+
export declare function getServicesFromDeviceTypes(deviceTypes: (typeof BleComms)[]): string[];
|
|
7
|
+
export declare function getServicesFromDevice(device: BleComms): string[];
|