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
|
@@ -12,64 +12,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
16
|
-
const utils_1 = require("../
|
|
15
|
+
const adapter_1 = require("../adapter");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
17
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
18
|
-
const ant_fe_st_mode_1 = __importDefault(require("../
|
|
19
|
-
const ant_fe_erg_mode_1 = __importDefault(require("../
|
|
20
|
-
const ant_fe_adv_st_mode_1 = __importDefault(require("../
|
|
21
|
-
const utils_2 = require("
|
|
22
|
-
const
|
|
23
|
-
const
|
|
18
|
+
const ant_fe_st_mode_1 = __importDefault(require("../modes/ant-fe-st-mode"));
|
|
19
|
+
const ant_fe_erg_mode_1 = __importDefault(require("../modes/ant-fe-erg-mode"));
|
|
20
|
+
const ant_fe_adv_st_mode_1 = __importDefault(require("../modes/ant-fe-adv-st-mode"));
|
|
21
|
+
const utils_2 = require("../../utils/utils");
|
|
22
|
+
const sensor_factory_1 = __importDefault(require("../sensor-factory"));
|
|
23
|
+
const capabilities_1 = require("../../types/capabilities");
|
|
24
|
+
const adpater_1 = require("../../base/adpater");
|
|
24
25
|
const DEFAULT_BIKE_WEIGHT_MOUNTAIN = 14.5;
|
|
25
26
|
const MAX_RETRIES = 3;
|
|
26
|
-
class AntFEAdapter extends
|
|
27
|
-
constructor(
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
class AntFEAdapter extends adapter_1.ControllableAntAdapter {
|
|
28
|
+
constructor(settings, props) {
|
|
29
|
+
if (settings.protocol && settings.profile !== AntFEAdapter.INCYCLIST_PROFILE_NAME)
|
|
30
|
+
throw new Error('Incorrect Profile');
|
|
31
|
+
if (!settings.protocol && settings.profile !== AntFEAdapter.ANT_PROFILE_NAME)
|
|
32
|
+
throw new Error('Incorrect Profile');
|
|
33
|
+
super(settings, props);
|
|
30
34
|
this.deviceData = {
|
|
31
|
-
DeviceID: sensor.getDeviceID()
|
|
35
|
+
DeviceID: this.sensor.getDeviceID()
|
|
32
36
|
};
|
|
33
37
|
this.dataMsgCount = 0;
|
|
34
38
|
this.logger = new gd_eventlog_1.EventLogger('Ant+FE');
|
|
35
39
|
this.isReconnecting = false;
|
|
40
|
+
this.capabilities = [
|
|
41
|
+
capabilities_1.IncyclistCapability.Power, capabilities_1.IncyclistCapability.Speed, capabilities_1.IncyclistCapability.Cadence,
|
|
42
|
+
capabilities_1.IncyclistCapability.Control
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
createSensor(settings) {
|
|
46
|
+
return sensor_factory_1.default.create(AntFEAdapter.ANT_PROFILE_NAME, Number(settings.deviceID));
|
|
36
47
|
}
|
|
37
|
-
isBike() { return true; }
|
|
38
|
-
isHrm() { return false; }
|
|
39
|
-
isPower() { return true; }
|
|
40
48
|
getName() {
|
|
49
|
+
if (this.settings.name)
|
|
50
|
+
return this.settings.name;
|
|
41
51
|
const deviceID = this.sensor.getDeviceID();
|
|
42
52
|
return `Ant+FE ${deviceID}`;
|
|
43
53
|
}
|
|
44
54
|
getDisplayName() {
|
|
45
|
-
const { DeviceID, ManId } = this.deviceData;
|
|
46
|
-
|
|
55
|
+
const { DeviceID, ManId, InstantaneousPower } = this.deviceData;
|
|
56
|
+
const pwrStr = InstantaneousPower ? ` (${InstantaneousPower})` : '';
|
|
57
|
+
const brand = (0, utils_1.getBrand)(ManId);
|
|
58
|
+
if (brand)
|
|
59
|
+
return `${brand} FE ${DeviceID}${pwrStr}`;
|
|
60
|
+
else
|
|
61
|
+
return `${this.getName()}${pwrStr}`;
|
|
47
62
|
}
|
|
48
63
|
getSupportedCyclingModes() {
|
|
49
64
|
return [ant_fe_st_mode_1.default, ant_fe_erg_mode_1.default, ant_fe_adv_st_mode_1.default];
|
|
50
65
|
}
|
|
51
|
-
setCyclingMode(mode, settings) {
|
|
52
|
-
let selectedMode;
|
|
53
|
-
if (typeof mode === 'string') {
|
|
54
|
-
const supported = this.getSupportedCyclingModes();
|
|
55
|
-
const CyclingModeClass = supported.find(M => { const m = new M(this); return m.getName() === mode; });
|
|
56
|
-
if (CyclingModeClass) {
|
|
57
|
-
this.cyclingMode = new CyclingModeClass(this, settings);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
selectedMode = this.getDefaultCyclingMode();
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
selectedMode = mode;
|
|
64
|
-
}
|
|
65
|
-
this.cyclingMode = selectedMode;
|
|
66
|
-
this.cyclingMode.setSettings(settings);
|
|
67
|
-
}
|
|
68
|
-
getCyclingMode() {
|
|
69
|
-
if (!this.cyclingMode)
|
|
70
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
71
|
-
return this.cyclingMode;
|
|
72
|
-
}
|
|
73
66
|
getDefaultCyclingMode() {
|
|
74
67
|
return new ant_fe_st_mode_1.default(this);
|
|
75
68
|
}
|
|
@@ -112,16 +105,16 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
112
105
|
onDeviceData(deviceData) {
|
|
113
106
|
this.dataMsgCount++;
|
|
114
107
|
this.lastDataTS = Date.now();
|
|
108
|
+
super.onDeviceData(deviceData);
|
|
115
109
|
if (!this.started || this.isStopped())
|
|
116
110
|
return;
|
|
117
|
-
this.
|
|
118
|
-
if (this.dataMsgCount === 1) {
|
|
111
|
+
if (!this.ivDataTimeout && this.dataMsgCount > 0) {
|
|
119
112
|
this.startDataTimeoutCheck();
|
|
120
113
|
}
|
|
121
114
|
try {
|
|
122
115
|
const logData = this.getLogData(deviceData, ['PairedDevices', 'RawData']);
|
|
123
116
|
this.logger.logEvent({ message: 'onDeviceData', data: logData });
|
|
124
|
-
if (this.onDataFn && !
|
|
117
|
+
if (this.onDataFn && !this.paused) {
|
|
125
118
|
if (!this.lastUpdate || (Date.now() - this.lastUpdate) > this.updateFrequency) {
|
|
126
119
|
let incyclistData = this.mapData(deviceData);
|
|
127
120
|
incyclistData = this.getCyclingMode().updateData(incyclistData);
|
|
@@ -172,25 +165,17 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
172
165
|
distance,
|
|
173
166
|
timestamp: Date.now()
|
|
174
167
|
};
|
|
175
|
-
if (this.ignorePower) {
|
|
176
|
-
delete data.power;
|
|
177
|
-
delete data.cadence;
|
|
178
|
-
}
|
|
179
|
-
if (this.ignoreBike) {
|
|
180
|
-
data = { heartrate: data.heartrate };
|
|
181
|
-
}
|
|
182
|
-
if (this.ignoreHrm || !this.isHrm())
|
|
183
|
-
delete data.heartrate;
|
|
184
168
|
return data;
|
|
185
169
|
}
|
|
186
170
|
start(props) {
|
|
187
|
-
const _super = Object.create(null, {
|
|
188
|
-
start: { get: () => super.start }
|
|
189
|
-
});
|
|
190
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
|
|
172
|
+
if (this.started)
|
|
173
|
+
return true;
|
|
174
|
+
const connected = yield this.connect();
|
|
175
|
+
if (!connected)
|
|
176
|
+
throw new Error(`could not start device, reason:could not connect`);
|
|
192
177
|
this.startProps = props;
|
|
193
|
-
this.
|
|
178
|
+
this.logEvent({ message: 'starting device -', props, isStarted: this.started, isReconnecting: this.isReconnecting });
|
|
194
179
|
const opts = props || {};
|
|
195
180
|
const { args = {}, user = {} } = opts;
|
|
196
181
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -216,8 +201,10 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
216
201
|
while (!success && retry < MAX_RETRIES) {
|
|
217
202
|
retry++;
|
|
218
203
|
if (!this.started) {
|
|
204
|
+
this.logger.logEvent({ message: 'start sensor', props });
|
|
219
205
|
this.started = yield this.ant.startSensor(this.sensor, this.onDeviceData.bind(this));
|
|
220
206
|
if (this.started) {
|
|
207
|
+
this.logger.logEvent({ message: 'sensor started', props });
|
|
221
208
|
startSuccess++;
|
|
222
209
|
}
|
|
223
210
|
if (this.started && startSuccess === 1) {
|
|
@@ -245,8 +232,8 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
245
232
|
const fe = this.sensor;
|
|
246
233
|
const mode = this.getCyclingMode();
|
|
247
234
|
const bikeType = mode ? mode.getSetting('bikeType').toLowerCase() : 'race';
|
|
248
|
-
const defaultBikeWeight = bikeType === 'mountain' ? DEFAULT_BIKE_WEIGHT_MOUNTAIN : DEFAULT_BIKE_WEIGHT;
|
|
249
|
-
const userWeight = args.userWeight || user.weight || DEFAULT_USER_WEIGHT;
|
|
235
|
+
const defaultBikeWeight = bikeType === 'mountain' ? DEFAULT_BIKE_WEIGHT_MOUNTAIN : adpater_1.DEFAULT_BIKE_WEIGHT;
|
|
236
|
+
const userWeight = args.userWeight || user.weight || adpater_1.DEFAULT_USER_WEIGHT;
|
|
250
237
|
const bikeWeight = args.bikeWeight || defaultBikeWeight;
|
|
251
238
|
status.userSent = status.userSent || (yield fe.sendUserConfiguration(userWeight, bikeWeight, args.wheelDiameter, args.gearRatio));
|
|
252
239
|
status.slopeSent = status.slopeSent || (yield fe.sendTrackResistance(0.0));
|
|
@@ -288,19 +275,6 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
288
275
|
const fe = this.sensor;
|
|
289
276
|
fe.setSendTimeout(5000);
|
|
290
277
|
}
|
|
291
|
-
stop() {
|
|
292
|
-
const _super = Object.create(null, {
|
|
293
|
-
stop: { get: () => super.stop }
|
|
294
|
-
});
|
|
295
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
296
|
-
this.logger.logEvent({ message: 'stopping device' });
|
|
297
|
-
let stopped = yield this.ant.stopSensor(this.sensor);
|
|
298
|
-
this.started = false;
|
|
299
|
-
yield _super.stop.call(this);
|
|
300
|
-
this.logger.logEvent({ message: 'stopping device done', success: stopped });
|
|
301
|
-
return stopped;
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
278
|
reconnect() {
|
|
305
279
|
return __awaiter(this, void 0, void 0, function* () {
|
|
306
280
|
this.logger.logEvent({ message: 'reconnect to device' });
|
|
@@ -322,3 +296,5 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
322
296
|
}
|
|
323
297
|
}
|
|
324
298
|
exports.default = AntFEAdapter;
|
|
299
|
+
AntFEAdapter.INCYCLIST_PROFILE_NAME = 'Smart Trainer';
|
|
300
|
+
AntFEAdapter.ANT_PROFILE_NAME = 'FE';
|
|
@@ -0,0 +1,7 @@
|
|
|
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 adapter_1 = __importDefault(require("./adapter"));
|
|
7
|
+
exports.default = adapter_1.default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HeartRateSensorState, ISensor } from "incyclist-ant-plus";
|
|
2
|
+
import AntAdapter from "../adapter";
|
|
3
|
+
import { AntDeviceProperties, AntDeviceSettings } from "../types";
|
|
4
|
+
export default class AntHrAdapter extends AntAdapter {
|
|
5
|
+
static INCYCLIST_PROFILE_NAME: string;
|
|
6
|
+
static ANT_PROFILE_NAME: string;
|
|
7
|
+
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
8
|
+
createSensor(settings: AntDeviceSettings): ISensor;
|
|
9
|
+
getName(): string;
|
|
10
|
+
getDisplayName(): string;
|
|
11
|
+
onDeviceData(deviceData: HeartRateSensorState): void;
|
|
12
|
+
updateData(data: any, deviceData: any): any;
|
|
13
|
+
hasData(): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 adapter_1 = __importDefault(require("../adapter"));
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
9
|
+
const sensor_factory_1 = __importDefault(require("../sensor-factory"));
|
|
10
|
+
const capabilities_1 = require("../../types/capabilities");
|
|
11
|
+
class AntHrAdapter extends adapter_1.default {
|
|
12
|
+
constructor(settings, props) {
|
|
13
|
+
if (settings.protocol && settings.profile !== AntHrAdapter.INCYCLIST_PROFILE_NAME)
|
|
14
|
+
throw new Error('Incorrect Profile');
|
|
15
|
+
if (!settings.protocol && settings.profile !== AntHrAdapter.ANT_PROFILE_NAME)
|
|
16
|
+
throw new Error('Incorrect Profile');
|
|
17
|
+
super(settings, props);
|
|
18
|
+
this.deviceData = {
|
|
19
|
+
DeviceID: this.sensor.getDeviceID()
|
|
20
|
+
};
|
|
21
|
+
this.logger = new gd_eventlog_1.EventLogger('Ant+Hrm');
|
|
22
|
+
this.capabilities = [capabilities_1.IncyclistCapability.HeartRate];
|
|
23
|
+
}
|
|
24
|
+
createSensor(settings) {
|
|
25
|
+
return sensor_factory_1.default.create(AntHrAdapter.ANT_PROFILE_NAME, Number(settings.deviceID));
|
|
26
|
+
}
|
|
27
|
+
getName() {
|
|
28
|
+
if (this.settings.name)
|
|
29
|
+
return this.settings.name;
|
|
30
|
+
const deviceID = this.sensor.getDeviceID();
|
|
31
|
+
return `Ant+HR ${deviceID}`;
|
|
32
|
+
}
|
|
33
|
+
getDisplayName() {
|
|
34
|
+
const { DeviceID, ManId, ComputedHeartRate } = this.deviceData;
|
|
35
|
+
const hrmStr = ComputedHeartRate ? ` (${ComputedHeartRate})` : '';
|
|
36
|
+
const brand = (0, utils_1.getBrand)(ManId);
|
|
37
|
+
if (brand)
|
|
38
|
+
return `${brand} Hrm ${DeviceID}${hrmStr}`;
|
|
39
|
+
else
|
|
40
|
+
return `${this.getName()}${hrmStr}`;
|
|
41
|
+
}
|
|
42
|
+
onDeviceData(deviceData) {
|
|
43
|
+
this.dataMsgCount++;
|
|
44
|
+
this.lastDataTS = Date.now();
|
|
45
|
+
super.onDeviceData(deviceData);
|
|
46
|
+
if (!this.started)
|
|
47
|
+
return;
|
|
48
|
+
if (!this.ivDataTimeout)
|
|
49
|
+
this.startDataTimeoutCheck();
|
|
50
|
+
try {
|
|
51
|
+
if (this.onDataFn && !this.paused) {
|
|
52
|
+
if (this.lastUpdate === undefined || (Date.now() - this.lastUpdate) > this.updateFrequency) {
|
|
53
|
+
this.logEvent({ message: 'onDeviceData', data: deviceData });
|
|
54
|
+
const data = this.updateData(this.data, deviceData);
|
|
55
|
+
this.onDataFn(data);
|
|
56
|
+
this.lastUpdate = Date.now();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
updateData(data, deviceData) {
|
|
64
|
+
data.heartrate = deviceData.ComputedHeartRate;
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
hasData() {
|
|
68
|
+
return this.deviceData.ComputedHeartRate !== undefined && this.deviceData.ComputedHeartRate !== null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.default = AntHrAdapter;
|
|
72
|
+
AntHrAdapter.INCYCLIST_PROFILE_NAME = 'Heartrate Monitor';
|
|
73
|
+
AntHrAdapter.ANT_PROFILE_NAME = 'HR';
|
|
@@ -0,0 +1,7 @@
|
|
|
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 adapter_1 = __importDefault(require("./adapter"));
|
|
7
|
+
exports.default = adapter_1.default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import AntPwrAdapter from "./pwr";
|
|
2
|
+
import AntFEAdapter from "./fe";
|
|
3
|
+
import AntHrAdapter from "./hr";
|
|
4
|
+
import AntAdapterFactory from "./adapter-factory";
|
|
5
|
+
import AntInterface from "./ant-interface";
|
|
6
|
+
import { AntDeviceSettings, AntScanProps } from "./types";
|
|
7
|
+
export { AntAdapterFactory, AntFEAdapter, AntHrAdapter, AntPwrAdapter, AntDeviceSettings, AntScanProps, AntInterface };
|
|
@@ -0,0 +1,20 @@
|
|
|
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.AntInterface = exports.AntPwrAdapter = exports.AntHrAdapter = exports.AntFEAdapter = exports.AntAdapterFactory = void 0;
|
|
7
|
+
const pwr_1 = __importDefault(require("./pwr"));
|
|
8
|
+
exports.AntPwrAdapter = pwr_1.default;
|
|
9
|
+
const fe_1 = __importDefault(require("./fe"));
|
|
10
|
+
exports.AntFEAdapter = fe_1.default;
|
|
11
|
+
const hr_1 = __importDefault(require("./hr"));
|
|
12
|
+
exports.AntHrAdapter = hr_1.default;
|
|
13
|
+
const adapter_factory_1 = __importDefault(require("./adapter-factory"));
|
|
14
|
+
exports.AntAdapterFactory = adapter_factory_1.default;
|
|
15
|
+
const ant_interface_1 = __importDefault(require("./ant-interface"));
|
|
16
|
+
exports.AntInterface = ant_interface_1.default;
|
|
17
|
+
const af = adapter_factory_1.default.getInstance();
|
|
18
|
+
af.register('PWR', 'Power Meter', pwr_1.default);
|
|
19
|
+
af.register('HR', 'Heartrate Monitor', hr_1.default);
|
|
20
|
+
af.register('FE', 'Smart Trainer', fe_1.default);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import FtmsCyclingMode from "../../modes/ble-st-mode";
|
|
2
|
+
import { UpdateRequest } from "../../modes/cycling-mode";
|
|
3
|
+
import { IncyclistDeviceAdapter } from "../../types/adapter";
|
|
4
|
+
export default class AntAdvSimCyclingMode extends FtmsCyclingMode {
|
|
5
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: any);
|
|
6
|
+
getName(): string;
|
|
7
|
+
getDescription(): string;
|
|
8
|
+
sendBikeUpdate(request: UpdateRequest): UpdateRequest;
|
|
9
|
+
}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ble_st_mode_1 = __importDefault(require("../../
|
|
6
|
+
const ble_st_mode_1 = __importDefault(require("../../modes/ble-st-mode"));
|
|
7
7
|
const MAX_DEVIATION = 10;
|
|
8
8
|
class AntAdvSimCyclingMode extends ble_st_mode_1.default {
|
|
9
9
|
constructor(adapter, props) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import BleERGCyclingMode from "../../modes/ble-erg-mode";
|
|
2
|
+
import { IncyclistDeviceAdapter } from "../../types/adapter";
|
|
3
|
+
export default class AntFeERGCyclingMode extends BleERGCyclingMode {
|
|
4
|
+
static isERG: boolean;
|
|
5
|
+
constructor(adapter: IncyclistDeviceAdapter, props?: any);
|
|
6
|
+
}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ble_erg_mode_1 = __importDefault(require("../../
|
|
6
|
+
const ble_erg_mode_1 = __importDefault(require("../../modes/ble-erg-mode"));
|
|
7
7
|
class AntFeERGCyclingMode extends ble_erg_mode_1.default {
|
|
8
8
|
constructor(adapter, props) {
|
|
9
9
|
super(adapter, props);
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ble_st_mode_1 = __importDefault(require("../../
|
|
6
|
+
const ble_st_mode_1 = __importDefault(require("../../modes/ble-st-mode"));
|
|
7
7
|
class AntStCyclingMode extends ble_st_mode_1.default {
|
|
8
8
|
constructor(adapter, props) {
|
|
9
9
|
super(adapter, props);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ISensor } from "incyclist-ant-plus";
|
|
2
|
+
import { ControllableAntAdapter } from "../adapter";
|
|
3
|
+
import CyclingMode, { IncyclistBikeData } from '../../modes/cycling-mode';
|
|
4
|
+
import { AntDeviceProperties, AntDeviceSettings } from "../types";
|
|
5
|
+
import { DeviceData } from "../../types/data";
|
|
6
|
+
export default class AntPwrAdapter extends ControllableAntAdapter {
|
|
7
|
+
static INCYCLIST_PROFILE_NAME: string;
|
|
8
|
+
static ANT_PROFILE_NAME: string;
|
|
9
|
+
protected distanceInternal?: number;
|
|
10
|
+
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
11
|
+
createSensor(settings: AntDeviceSettings): ISensor;
|
|
12
|
+
getName(): string;
|
|
13
|
+
getDisplayName(): string;
|
|
14
|
+
getDefaultCyclingMode(): CyclingMode;
|
|
15
|
+
getSupportedCyclingModes(): any[];
|
|
16
|
+
getLogData(data: any, excludeList: any): any;
|
|
17
|
+
onDeviceData(deviceData: any): void;
|
|
18
|
+
sendUpdate(request: any): void;
|
|
19
|
+
mapData(deviceData: any): IncyclistBikeData;
|
|
20
|
+
transformData(bikeData: IncyclistBikeData): DeviceData;
|
|
21
|
+
hasData(): boolean;
|
|
22
|
+
}
|
|
@@ -1,45 +1,46 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
16
|
-
const utils_1 = require("../
|
|
6
|
+
const adapter_1 = require("../adapter");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
17
8
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
18
|
-
const power_meter_1 = __importDefault(require("
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
const power_meter_1 = __importDefault(require("../../modes/power-meter"));
|
|
10
|
+
const sensor_factory_1 = __importDefault(require("../sensor-factory"));
|
|
11
|
+
const capabilities_1 = require("../../types/capabilities");
|
|
12
|
+
class AntPwrAdapter extends adapter_1.ControllableAntAdapter {
|
|
13
|
+
constructor(settings, props) {
|
|
14
|
+
if (settings.protocol && settings.profile !== AntPwrAdapter.INCYCLIST_PROFILE_NAME)
|
|
15
|
+
throw new Error('Incorrect Profile');
|
|
16
|
+
if (!settings.protocol && settings.profile !== AntPwrAdapter.ANT_PROFILE_NAME)
|
|
17
|
+
throw new Error('Incorrect Profile');
|
|
18
|
+
super(settings, props);
|
|
23
19
|
this.deviceData = {
|
|
24
|
-
DeviceID: sensor.getDeviceID()
|
|
20
|
+
DeviceID: this.sensor.getDeviceID()
|
|
25
21
|
};
|
|
26
22
|
this.logger = new gd_eventlog_1.EventLogger('Ant+PWR');
|
|
23
|
+
this.capabilities = [
|
|
24
|
+
capabilities_1.IncyclistCapability.Power, capabilities_1.IncyclistCapability.Cadence, capabilities_1.IncyclistCapability.Speed
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
createSensor(settings) {
|
|
28
|
+
return sensor_factory_1.default.create(AntPwrAdapter.ANT_PROFILE_NAME, Number(settings.deviceID));
|
|
27
29
|
}
|
|
28
|
-
isBike() { return true; }
|
|
29
|
-
isHrm() { return false; }
|
|
30
|
-
isPower() { return true; }
|
|
31
30
|
getName() {
|
|
31
|
+
if (this.settings.name)
|
|
32
|
+
return this.settings.name;
|
|
32
33
|
const deviceID = this.sensor.getDeviceID();
|
|
33
34
|
return `Ant+PWR ${deviceID}`;
|
|
34
35
|
}
|
|
35
36
|
getDisplayName() {
|
|
36
|
-
const { DeviceID, ManId } = this.deviceData;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const { DeviceID, ManId, Power } = this.deviceData;
|
|
38
|
+
const pwrStr = Power ? ` (${Power})` : '';
|
|
39
|
+
const brand = (0, utils_1.getBrand)(ManId);
|
|
40
|
+
if (brand)
|
|
41
|
+
return `${brand} PWR ${DeviceID}${pwrStr}`;
|
|
42
|
+
else
|
|
43
|
+
return `${this.getName()}${pwrStr}`;
|
|
43
44
|
}
|
|
44
45
|
getDefaultCyclingMode() {
|
|
45
46
|
return new power_meter_1.default(this);
|
|
@@ -57,13 +58,13 @@ class AntPwrAdapter extends ant_device_1.default {
|
|
|
57
58
|
onDeviceData(deviceData) {
|
|
58
59
|
this.dataMsgCount++;
|
|
59
60
|
this.lastDataTS = Date.now();
|
|
61
|
+
super.onDeviceData(deviceData);
|
|
60
62
|
if (!this.started)
|
|
61
63
|
return;
|
|
62
|
-
this.deviceData = deviceData;
|
|
63
64
|
if (!this.ivDataTimeout)
|
|
64
65
|
this.startDataTimeoutCheck();
|
|
65
66
|
try {
|
|
66
|
-
if (this.onDataFn && !
|
|
67
|
+
if (this.onDataFn && !this.paused) {
|
|
67
68
|
if (!this.lastUpdate || (Date.now() - this.lastUpdate) > this.updateFrequency) {
|
|
68
69
|
const logData = this.getLogData(deviceData, ['PairedDevices', 'RawData']);
|
|
69
70
|
this.logger.logEvent({ message: 'onDeviceData', data: logData });
|
|
@@ -79,7 +80,7 @@ class AntPwrAdapter extends ant_device_1.default {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
sendUpdate(request) {
|
|
82
|
-
if (this.
|
|
83
|
+
if (this.isPaused())
|
|
83
84
|
return;
|
|
84
85
|
this.getCyclingMode().sendBikeUpdate(request);
|
|
85
86
|
}
|
|
@@ -118,54 +119,15 @@ class AntPwrAdapter extends ant_device_1.default {
|
|
|
118
119
|
distance,
|
|
119
120
|
timestamp: Date.now()
|
|
120
121
|
};
|
|
121
|
-
if (this.ignorePower) {
|
|
122
|
-
delete data.power;
|
|
123
|
-
delete data.cadence;
|
|
124
|
-
}
|
|
125
|
-
if (this.ignoreBike) {
|
|
126
|
-
data = {};
|
|
127
|
-
}
|
|
128
122
|
return data;
|
|
129
123
|
}
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (this.started)
|
|
136
|
-
return true;
|
|
137
|
-
_super.start.call(this, props);
|
|
138
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
const { timeout = 20000 } = props || {};
|
|
140
|
-
let to;
|
|
141
|
-
if (timeout) {
|
|
142
|
-
to = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
yield this.stop();
|
|
144
|
-
reject(new Error(`could not start device, reason:timeout`));
|
|
145
|
-
}), timeout);
|
|
146
|
-
}
|
|
147
|
-
this.started = yield this.ant.startSensor(this.sensor, this.onDeviceData.bind(this));
|
|
148
|
-
try {
|
|
149
|
-
yield this.waitForData(timeout - 100);
|
|
150
|
-
if (to)
|
|
151
|
-
clearTimeout(to);
|
|
152
|
-
resolve(this.started);
|
|
153
|
-
}
|
|
154
|
-
catch (err) {
|
|
155
|
-
}
|
|
156
|
-
}));
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
stop() {
|
|
160
|
-
const _super = Object.create(null, {
|
|
161
|
-
stop: { get: () => super.stop }
|
|
162
|
-
});
|
|
163
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
-
const stopped = yield this.ant.stopSensor(this.sensor);
|
|
165
|
-
_super.stop.call(this);
|
|
166
|
-
this.started = false;
|
|
167
|
-
return stopped;
|
|
168
|
-
});
|
|
124
|
+
hasData() {
|
|
125
|
+
const { Power, Cadence, TimeStamp } = this.deviceData;
|
|
126
|
+
return Power !== undefined && Power !== null ||
|
|
127
|
+
Cadence !== undefined || Cadence !== null ||
|
|
128
|
+
TimeStamp !== undefined || TimeStamp !== null;
|
|
169
129
|
}
|
|
170
130
|
}
|
|
171
131
|
exports.default = AntPwrAdapter;
|
|
132
|
+
AntPwrAdapter.INCYCLIST_PROFILE_NAME = 'Power Meter';
|
|
133
|
+
AntPwrAdapter.ANT_PROFILE_NAME = 'PWR';
|
|
@@ -0,0 +1,7 @@
|
|
|
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 adapter_1 = __importDefault(require("./adapter"));
|
|
7
|
+
exports.default = adapter_1.default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import IncyclistDevice from '../base/adpater';
|
|
2
|
+
import { DeviceProperties, DeviceSettings, IncyclistScanProps } from '../types/device';
|
|
3
|
+
export interface AntDeviceSettings extends DeviceSettings {
|
|
4
|
+
deviceID?: string;
|
|
5
|
+
profile: string;
|
|
6
|
+
protocol?: string;
|
|
7
|
+
}
|
|
8
|
+
export type DeviceFoundCallback = (device: IncyclistDevice, protocol: string) => void;
|
|
9
|
+
export type ScanFinishedCallback = (id: number) => void;
|
|
10
|
+
export interface AntScanProps extends IncyclistScanProps {
|
|
11
|
+
profiles?: string[];
|
|
12
|
+
id?: number;
|
|
13
|
+
onDeviceFound?: DeviceFoundCallback;
|
|
14
|
+
onScanFinished?: ScanFinishedCallback;
|
|
15
|
+
}
|
|
16
|
+
export interface AntDeviceProperties extends DeviceProperties {
|
|
17
|
+
startupTimeout?: number;
|
|
18
|
+
automaticReconnect?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getBrand: (manId: number) => string;
|