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
|
@@ -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) {
|
|
@@ -32,17 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
32
13
|
};
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
15
|
exports.Simulator = void 0;
|
|
35
|
-
const
|
|
36
|
-
const registry_1 = __importDefault(require("../registry"));
|
|
37
|
-
const device_1 = __importDefault(require("../device"));
|
|
16
|
+
const adpater_1 = require("../base/adpater");
|
|
38
17
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
39
18
|
const simulator_1 = __importDefault(require("../modes/simulator"));
|
|
40
|
-
const
|
|
41
|
-
const DEFAULT_SETTINGS = { name: 'Simulator',
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
super(
|
|
19
|
+
const capabilities_1 = require("../types/capabilities");
|
|
20
|
+
const DEFAULT_SETTINGS = { name: 'Simulator', protocol: 'Simulator', port: '' };
|
|
21
|
+
const DEFAULT_PROPS = { isBot: false };
|
|
22
|
+
class Simulator extends adpater_1.ControllableDevice {
|
|
23
|
+
constructor(settings, props = DEFAULT_PROPS) {
|
|
24
|
+
super(settings, props);
|
|
46
25
|
this.logger = new gd_eventlog_1.EventLogger(Simulator.NAME);
|
|
47
26
|
this.speed = 0;
|
|
48
27
|
this.power = 0;
|
|
@@ -59,12 +38,16 @@ class Simulator extends device_1.default {
|
|
|
59
38
|
this.isBot = props.isBot || false;
|
|
60
39
|
this.ignoreHrm = false;
|
|
61
40
|
const name = this.getCyclingMode().getName();
|
|
62
|
-
const modeSettings = this.isBot ? props.settings
|
|
41
|
+
const modeSettings = this.isBot ? props.settings : this.getCyclingMode().getSettings();
|
|
63
42
|
this.setCyclingMode(name, modeSettings);
|
|
43
|
+
this.capabilities = [
|
|
44
|
+
capabilities_1.IncyclistCapability.Power, capabilities_1.IncyclistCapability.Speed, capabilities_1.IncyclistCapability.Cadence, capabilities_1.IncyclistCapability.Gear,
|
|
45
|
+
capabilities_1.IncyclistCapability.Control
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
isEqual(settings) {
|
|
49
|
+
return settings.interface === this.getInterface() && settings.name === this.settings.name;
|
|
64
50
|
}
|
|
65
|
-
isBike() { return true; }
|
|
66
|
-
isHrm() { return false; }
|
|
67
|
-
isPower() { return true; }
|
|
68
51
|
isSame(device) {
|
|
69
52
|
if (!(device instanceof Simulator))
|
|
70
53
|
return false;
|
|
@@ -72,18 +55,6 @@ class Simulator extends device_1.default {
|
|
|
72
55
|
}
|
|
73
56
|
getID() { return Simulator.NAME; }
|
|
74
57
|
getName() { return Simulator.NAME; }
|
|
75
|
-
getPort() { return 'local'; }
|
|
76
|
-
getWeight() {
|
|
77
|
-
let userWeight = device_2.DEFAULT_USER_WEIGHT;
|
|
78
|
-
let bikeWeight = device_2.DEFAULT_BIKE_WEIGHT;
|
|
79
|
-
if (this.userSettings && this.userSettings.weight) {
|
|
80
|
-
userWeight = Number(this.userSettings.weight);
|
|
81
|
-
}
|
|
82
|
-
if (this.bikeSettings && this.bikeSettings.weight) {
|
|
83
|
-
bikeWeight = Number(this.bikeSettings.weight);
|
|
84
|
-
}
|
|
85
|
-
return bikeWeight + userWeight;
|
|
86
|
-
}
|
|
87
58
|
setIgnoreHrm(ignore) {
|
|
88
59
|
this.ignoreHrm = ignore;
|
|
89
60
|
}
|
|
@@ -120,15 +91,13 @@ class Simulator extends device_1.default {
|
|
|
120
91
|
start(props) {
|
|
121
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
93
|
this.startProps = props;
|
|
123
|
-
if (props
|
|
124
|
-
this.
|
|
125
|
-
if (props && props.bikeSettings)
|
|
126
|
-
this.bikeSettings = props.bikeSettings;
|
|
94
|
+
if (props)
|
|
95
|
+
this.setBikeProps(props);
|
|
127
96
|
return new Promise((resolve) => {
|
|
128
97
|
if (!this.isBot)
|
|
129
98
|
this.logger.logEvent({ message: 'start', iv: this.iv });
|
|
130
99
|
if (this.started) {
|
|
131
|
-
return resolve(
|
|
100
|
+
return resolve(true);
|
|
132
101
|
}
|
|
133
102
|
this.started = true;
|
|
134
103
|
this.time = Date.now();
|
|
@@ -146,7 +115,7 @@ class Simulator extends device_1.default {
|
|
|
146
115
|
this.iv = setInterval(() => this.update(), 1000);
|
|
147
116
|
if (!this.isBot)
|
|
148
117
|
this.logger.logEvent({ message: 'started' });
|
|
149
|
-
resolve(
|
|
118
|
+
resolve(true);
|
|
150
119
|
});
|
|
151
120
|
});
|
|
152
121
|
}
|
|
@@ -253,36 +222,3 @@ class Simulator extends device_1.default {
|
|
|
253
222
|
}
|
|
254
223
|
exports.Simulator = Simulator;
|
|
255
224
|
Simulator.NAME = 'Simulator';
|
|
256
|
-
class SimulatorProtocol extends protocol_1.default {
|
|
257
|
-
constructor() {
|
|
258
|
-
super();
|
|
259
|
-
this.devices = [];
|
|
260
|
-
}
|
|
261
|
-
add(settings) {
|
|
262
|
-
let device = new Simulator(this, settings);
|
|
263
|
-
this.devices.push(device);
|
|
264
|
-
return device;
|
|
265
|
-
}
|
|
266
|
-
getName() {
|
|
267
|
-
return SimulatorProtocol.NAME;
|
|
268
|
-
}
|
|
269
|
-
getInterfaces() {
|
|
270
|
-
return [protocol_1.INTERFACE.SIMULATOR];
|
|
271
|
-
}
|
|
272
|
-
isBike() {
|
|
273
|
-
return true;
|
|
274
|
-
}
|
|
275
|
-
isHrm() {
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
isPower() {
|
|
279
|
-
return true;
|
|
280
|
-
}
|
|
281
|
-
getDevices() {
|
|
282
|
-
return this.devices;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
exports.default = SimulatorProtocol;
|
|
286
|
-
SimulatorProtocol.NAME = 'Simulator';
|
|
287
|
-
const simulator = new SimulatorProtocol();
|
|
288
|
-
registry_1.default.register(simulator);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import CyclingMode from "../modes/cycling-mode";
|
|
2
|
+
import { IncyclistCapability } from "./capabilities";
|
|
3
|
+
import { DeviceData } from "./data";
|
|
4
|
+
import { DeviceProperties, DeviceSettings } from "./device";
|
|
5
|
+
import { User } from "./user";
|
|
6
|
+
export type OnDeviceDataCallback = (data: DeviceData) => void;
|
|
7
|
+
export interface IncyclistDeviceAdapter {
|
|
8
|
+
connect(): Promise<boolean>;
|
|
9
|
+
close(): Promise<boolean>;
|
|
10
|
+
check(): Promise<boolean>;
|
|
11
|
+
isEqual(settings: DeviceSettings): any;
|
|
12
|
+
getCapabilities(): IncyclistCapability[];
|
|
13
|
+
hasCapability(capability: IncyclistCapability): any;
|
|
14
|
+
getName(): string;
|
|
15
|
+
getSettings(): DeviceSettings;
|
|
16
|
+
getDisplayName(): string;
|
|
17
|
+
update(): any;
|
|
18
|
+
start(props?: DeviceProperties): Promise<boolean>;
|
|
19
|
+
stop(): Promise<boolean>;
|
|
20
|
+
pause(): Promise<boolean>;
|
|
21
|
+
resume(): Promise<boolean>;
|
|
22
|
+
sendUpdate(request: any): any;
|
|
23
|
+
onData(callback: OnDeviceDataCallback): any;
|
|
24
|
+
}
|
|
25
|
+
export interface Bike {
|
|
26
|
+
setCyclingMode(mode: CyclingMode | string, settings?: any): void;
|
|
27
|
+
getSupportedCyclingModes(): Array<any>;
|
|
28
|
+
getCyclingMode(): CyclingMode;
|
|
29
|
+
getDefaultCyclingMode(): CyclingMode;
|
|
30
|
+
setBikeProps(props: DeviceProperties): void;
|
|
31
|
+
setUser(user: User): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IncyclistCapability = void 0;
|
|
4
|
+
var IncyclistCapability;
|
|
5
|
+
(function (IncyclistCapability) {
|
|
6
|
+
IncyclistCapability["Power"] = "power";
|
|
7
|
+
IncyclistCapability["Speed"] = "speed";
|
|
8
|
+
IncyclistCapability["Cadence"] = "cadence";
|
|
9
|
+
IncyclistCapability["HeartRate"] = "heartrate";
|
|
10
|
+
IncyclistCapability["Gear"] = "gear";
|
|
11
|
+
IncyclistCapability["Control"] = "control";
|
|
12
|
+
})(IncyclistCapability = exports.IncyclistCapability || (exports.IncyclistCapability = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type DeviceData = {
|
|
2
|
+
speed?: number;
|
|
3
|
+
slope?: number;
|
|
4
|
+
power?: number;
|
|
5
|
+
cadence?: number;
|
|
6
|
+
heartrate?: number;
|
|
7
|
+
distance?: number;
|
|
8
|
+
timestamp?: number;
|
|
9
|
+
deviceTime?: number;
|
|
10
|
+
deviceDistanceCounter?: number;
|
|
11
|
+
internalDistanceCounter?: number;
|
|
12
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EventLogger } from "gd-eventlog";
|
|
2
|
+
import { IncyclistInterface } from "./interface";
|
|
3
|
+
import { User } from "./user";
|
|
4
|
+
export declare const INTERFACE: {
|
|
5
|
+
SERIAL: string;
|
|
6
|
+
TCPIP: string;
|
|
7
|
+
ANT: string;
|
|
8
|
+
BLE: string;
|
|
9
|
+
USB: string;
|
|
10
|
+
SIMULATOR: string;
|
|
11
|
+
};
|
|
12
|
+
export type Device = {
|
|
13
|
+
getID(): string;
|
|
14
|
+
getName(): string;
|
|
15
|
+
getInterface(): string;
|
|
16
|
+
};
|
|
17
|
+
export type DeviceProperties = {
|
|
18
|
+
user?: User;
|
|
19
|
+
userWeight?: number;
|
|
20
|
+
bikeWeight?: number;
|
|
21
|
+
};
|
|
22
|
+
export type IncyclistScanProps = {
|
|
23
|
+
timeout?: number;
|
|
24
|
+
logger?: EventLogger;
|
|
25
|
+
};
|
|
26
|
+
export type DeviceSettings = {
|
|
27
|
+
interface: string | IncyclistInterface;
|
|
28
|
+
name?: string;
|
|
29
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EventLogger } from "gd-eventlog";
|
|
2
|
+
import { IncyclistScanProps, DeviceSettings } from "./device";
|
|
3
|
+
export type InterfaceProps = {
|
|
4
|
+
binding?: any;
|
|
5
|
+
logger?: EventLogger;
|
|
6
|
+
log?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type IncyclistInterface = {
|
|
9
|
+
getName(): string;
|
|
10
|
+
setBinding(binding: any): void;
|
|
11
|
+
connect(): Promise<boolean>;
|
|
12
|
+
disconnect(): Promise<Boolean>;
|
|
13
|
+
scan(props: IncyclistScanProps): Promise<DeviceSettings[]>;
|
|
14
|
+
};
|
package/lib/types/route.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Point = {
|
|
2
2
|
lat?: number;
|
|
3
3
|
lng?: number;
|
|
4
4
|
elevation?: number;
|
|
@@ -10,7 +10,7 @@ export declare enum RouteType {
|
|
|
10
10
|
FOLLOW_ROUTE = "follow route",
|
|
11
11
|
VIDEO = "video"
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type Route = {
|
|
14
14
|
programId: number;
|
|
15
15
|
points: Point[];
|
|
16
16
|
type: string;
|
package/lib/types/user.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const sleep: (ms: any) => Promise<unknown>;
|
|
2
|
+
export declare const resolveNextTick: () => Promise<void>;
|
|
2
3
|
export declare function runWithRetries(fn: any, maxRetries: any, timeBetween: any): Promise<unknown>;
|
|
3
4
|
export declare function floatVal(d?: number | string): number;
|
|
4
5
|
export declare function intVal(d?: number | string): number;
|
|
@@ -9,11 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Queue = exports.hexstr = exports.intVal = exports.floatVal = exports.runWithRetries = exports.sleep = void 0;
|
|
12
|
+
exports.Queue = exports.hexstr = exports.intVal = exports.floatVal = exports.runWithRetries = exports.resolveNextTick = exports.sleep = void 0;
|
|
13
13
|
const sleep = (ms) => {
|
|
14
14
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
15
15
|
};
|
|
16
16
|
exports.sleep = sleep;
|
|
17
|
+
const resolveNextTick = () => {
|
|
18
|
+
return new Promise(resolve => process.nextTick(() => resolve()));
|
|
19
|
+
};
|
|
20
|
+
exports.resolveNextTick = resolveNextTick;
|
|
17
21
|
function runWithRetries(fn, maxRetries, timeBetween) {
|
|
18
22
|
return new Promise((resolve, reject) => {
|
|
19
23
|
let retries = 0;
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-devices",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"dependencies": {
|
|
5
|
+
"@serialport/bindings-interface": "^1.2.2",
|
|
5
6
|
"@serialport/parser-byte-length": "^9.0.1",
|
|
6
7
|
"@serialport/parser-delimiter": "^9.0.1",
|
|
7
|
-
"@
|
|
8
|
+
"@serialport/parser-readline": "^10.5.0",
|
|
9
|
+
"@serialport/stream": "^10.5.0",
|
|
10
|
+
"@types/serialport": "^8.0.2",
|
|
8
11
|
"gd-ant-plus": "^0.0.33",
|
|
9
12
|
"incyclist-ant-plus": "^0.1.15",
|
|
10
13
|
"win32filetime": "^1.0.2"
|
|
@@ -13,14 +16,15 @@
|
|
|
13
16
|
"gd-eventlog": "^0.1.22"
|
|
14
17
|
},
|
|
15
18
|
"devDependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"eslint
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
19
|
+
"@serialport/binding-mock": "^10.2.2",
|
|
20
|
+
"@serialport/bindings-cpp": "^10.8.0",
|
|
21
|
+
"@types/jest": "^29.2.4",
|
|
22
|
+
"@types/node": "^18.11.18",
|
|
23
|
+
"eslint": "^8.30.0",
|
|
24
|
+
"eslint-config-react-app": "^7.0.1",
|
|
25
|
+
"jest": "^29.3.1",
|
|
26
|
+
"ts-jest": "^29.0.3",
|
|
27
|
+
"typescript": "^4.9.4"
|
|
24
28
|
},
|
|
25
29
|
"scripts": {
|
|
26
30
|
"lint": "eslint . --ext .ts",
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
"files": [
|
|
32
36
|
"lib/"
|
|
33
37
|
],
|
|
34
|
-
"main": "lib/
|
|
38
|
+
"main": "lib/index.js",
|
|
35
39
|
"directories": {
|
|
36
40
|
"example": "./sample",
|
|
37
41
|
"lib": "./src"
|
package/lib/DeviceSupport.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import DeviceRegistry from './registry';
|
|
2
|
-
import DeviceAdapter from './device';
|
|
3
|
-
import DeviceProtocolBase, { INTERFACE, DeviceProtocol } from './protocol';
|
|
4
|
-
import SimulatorProtocol from './simulator/Simulator';
|
|
5
|
-
import DaumPremiumProtocol from './daum/premium/DaumPremiumProtocol';
|
|
6
|
-
import DaumClassicProtocol from './daum/classic/DaumClassicProtocol';
|
|
7
|
-
import KettlerRacerProtocol from './kettler/ergo-racer/protocol';
|
|
8
|
-
import { AntScanner } from './ant/AntScanner';
|
|
9
|
-
import { CyclingModeProperyType } from './cycling-mode';
|
|
10
|
-
import AntProtocol from './antv2/incyclist-protocol';
|
|
11
|
-
import AntInterface from './antv2/ant-interface';
|
|
12
|
-
import BleProtocol from './ble/incyclist-protocol';
|
|
13
|
-
import BleInterface from './ble/ble-interface';
|
|
14
|
-
import BleHrmDevice from './ble/hrm';
|
|
15
|
-
import BleCyclingPowerDevice from './ble/pwr';
|
|
16
|
-
import BleFitnessMachineDevice from './ble/fm';
|
|
17
|
-
import WahooAdvancedFitnessMachineDevice from './ble/wahoo-kickr';
|
|
18
|
-
declare const Protocols: {
|
|
19
|
-
SimulatorProtocol: typeof SimulatorProtocol;
|
|
20
|
-
DaumClassicProtocol: typeof DaumClassicProtocol;
|
|
21
|
-
DaumPremiumProtocol: typeof DaumPremiumProtocol;
|
|
22
|
-
KettlerRacerProtocol: typeof KettlerRacerProtocol;
|
|
23
|
-
BleProtocol: typeof BleProtocol;
|
|
24
|
-
};
|
|
25
|
-
export interface FeatureList {
|
|
26
|
-
[key: string]: boolean;
|
|
27
|
-
}
|
|
28
|
-
export default class DeviceSupport {
|
|
29
|
-
static _features: FeatureList;
|
|
30
|
-
static init(props?: {
|
|
31
|
-
features?: FeatureList;
|
|
32
|
-
}): void;
|
|
33
|
-
static hasFeature(feature: string): boolean;
|
|
34
|
-
static setFeature(key: string, value: boolean): void;
|
|
35
|
-
}
|
|
36
|
-
export { DeviceProtocolBase, DeviceProtocol, DeviceRegistry, INTERFACE, DeviceAdapter as Device, Protocols, AntScanner, AntProtocol, AntInterface, CyclingModeProperyType, BleProtocol, BleInterface, BleHrmDevice, BleCyclingPowerDevice, BleFitnessMachineDevice, WahooAdvancedFitnessMachineDevice };
|
package/lib/DeviceSupport.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.WahooAdvancedFitnessMachineDevice = exports.BleFitnessMachineDevice = exports.BleCyclingPowerDevice = exports.BleHrmDevice = exports.BleInterface = exports.BleProtocol = exports.CyclingModeProperyType = exports.AntInterface = exports.AntProtocol = exports.AntScanner = exports.Protocols = exports.Device = exports.INTERFACE = exports.DeviceRegistry = exports.DeviceProtocolBase = void 0;
|
|
26
|
-
const registry_1 = __importDefault(require("./registry"));
|
|
27
|
-
exports.DeviceRegistry = registry_1.default;
|
|
28
|
-
const device_1 = __importDefault(require("./device"));
|
|
29
|
-
exports.Device = device_1.default;
|
|
30
|
-
const protocol_1 = __importStar(require("./protocol"));
|
|
31
|
-
exports.DeviceProtocolBase = protocol_1.default;
|
|
32
|
-
Object.defineProperty(exports, "INTERFACE", { enumerable: true, get: function () { return protocol_1.INTERFACE; } });
|
|
33
|
-
const Simulator_1 = __importDefault(require("./simulator/Simulator"));
|
|
34
|
-
const DaumPremiumProtocol_1 = __importDefault(require("./daum/premium/DaumPremiumProtocol"));
|
|
35
|
-
const DaumClassicProtocol_1 = __importDefault(require("./daum/classic/DaumClassicProtocol"));
|
|
36
|
-
const protocol_2 = __importDefault(require("./kettler/ergo-racer/protocol"));
|
|
37
|
-
const AntScanner_1 = require("./ant/AntScanner");
|
|
38
|
-
Object.defineProperty(exports, "AntScanner", { enumerable: true, get: function () { return AntScanner_1.AntScanner; } });
|
|
39
|
-
const cycling_mode_1 = require("./cycling-mode");
|
|
40
|
-
Object.defineProperty(exports, "CyclingModeProperyType", { enumerable: true, get: function () { return cycling_mode_1.CyclingModeProperyType; } });
|
|
41
|
-
const incyclist_protocol_1 = __importDefault(require("./antv2/incyclist-protocol"));
|
|
42
|
-
exports.AntProtocol = incyclist_protocol_1.default;
|
|
43
|
-
const ant_interface_1 = __importDefault(require("./antv2/ant-interface"));
|
|
44
|
-
exports.AntInterface = ant_interface_1.default;
|
|
45
|
-
const incyclist_protocol_2 = __importDefault(require("./ble/incyclist-protocol"));
|
|
46
|
-
exports.BleProtocol = incyclist_protocol_2.default;
|
|
47
|
-
const ble_interface_1 = __importDefault(require("./ble/ble-interface"));
|
|
48
|
-
exports.BleInterface = ble_interface_1.default;
|
|
49
|
-
const hrm_1 = __importDefault(require("./ble/hrm"));
|
|
50
|
-
exports.BleHrmDevice = hrm_1.default;
|
|
51
|
-
const pwr_1 = __importDefault(require("./ble/pwr"));
|
|
52
|
-
exports.BleCyclingPowerDevice = pwr_1.default;
|
|
53
|
-
const fm_1 = __importDefault(require("./ble/fm"));
|
|
54
|
-
exports.BleFitnessMachineDevice = fm_1.default;
|
|
55
|
-
const wahoo_kickr_1 = __importDefault(require("./ble/wahoo-kickr"));
|
|
56
|
-
exports.WahooAdvancedFitnessMachineDevice = wahoo_kickr_1.default;
|
|
57
|
-
const Protocols = {
|
|
58
|
-
SimulatorProtocol: Simulator_1.default,
|
|
59
|
-
DaumClassicProtocol: DaumClassicProtocol_1.default,
|
|
60
|
-
DaumPremiumProtocol: DaumPremiumProtocol_1.default,
|
|
61
|
-
KettlerRacerProtocol: protocol_2.default,
|
|
62
|
-
BleProtocol: incyclist_protocol_2.default
|
|
63
|
-
};
|
|
64
|
-
exports.Protocols = Protocols;
|
|
65
|
-
class DeviceSupport {
|
|
66
|
-
static init(props = {}) {
|
|
67
|
-
if (props.features) {
|
|
68
|
-
this._features = props.features;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
static hasFeature(feature) {
|
|
72
|
-
const featureVal = this._features[feature];
|
|
73
|
-
if (featureVal === undefined)
|
|
74
|
-
return false;
|
|
75
|
-
return featureVal;
|
|
76
|
-
}
|
|
77
|
-
static setFeature(key, value) {
|
|
78
|
-
this._features[key] = value;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.default = DeviceSupport;
|
|
82
|
-
DeviceSupport._features = {};
|
package/lib/ant/AntAdapter.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import DeviceAdapter from "../device";
|
|
2
|
-
import { EventLogger } from 'gd-eventlog';
|
|
3
|
-
export declare const DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
4
|
-
export default class AntAdapter extends DeviceAdapter {
|
|
5
|
-
paused: boolean;
|
|
6
|
-
stopped: boolean;
|
|
7
|
-
ignoreHrm: boolean;
|
|
8
|
-
ignoreBike: boolean;
|
|
9
|
-
ignorePower: boolean;
|
|
10
|
-
deviceID: string;
|
|
11
|
-
port: string;
|
|
12
|
-
stick: any;
|
|
13
|
-
channel: number;
|
|
14
|
-
sensor: any;
|
|
15
|
-
deviceData: any;
|
|
16
|
-
data: any;
|
|
17
|
-
logger: EventLogger;
|
|
18
|
-
lastUpdate?: number;
|
|
19
|
-
updateFrequency: number;
|
|
20
|
-
userSettings: {
|
|
21
|
-
weight?: number;
|
|
22
|
-
};
|
|
23
|
-
bikeSettings: {
|
|
24
|
-
weight?: number;
|
|
25
|
-
};
|
|
26
|
-
constructor(protocol: any);
|
|
27
|
-
isSame(device: DeviceAdapter): boolean;
|
|
28
|
-
setSensor(sensor: any): void;
|
|
29
|
-
getID(): string;
|
|
30
|
-
setIgnoreHrm(ignore: any): void;
|
|
31
|
-
setIgnoreBike(ignore: any): void;
|
|
32
|
-
setIgnorePower(ignore: any): void;
|
|
33
|
-
getProfile(): string;
|
|
34
|
-
getPort(): string;
|
|
35
|
-
getWeight(): number;
|
|
36
|
-
setChannel(channel: any): void;
|
|
37
|
-
setStick(stick: any): void;
|
|
38
|
-
isStopped(): boolean;
|
|
39
|
-
onDeviceData(data: any): void;
|
|
40
|
-
onDeviceEvent(data: any): void;
|
|
41
|
-
onAttached(): void;
|
|
42
|
-
update(): void;
|
|
43
|
-
check(): void;
|
|
44
|
-
connect(): void;
|
|
45
|
-
close(): void;
|
|
46
|
-
pause(): Promise<boolean>;
|
|
47
|
-
resume(): Promise<boolean>;
|
|
48
|
-
start(props?: any): Promise<any>;
|
|
49
|
-
stop(): Promise<boolean>;
|
|
50
|
-
}
|
package/lib/ant/AntAdapter.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
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.DEFAULT_UPDATE_FREQUENCY = void 0;
|
|
7
|
-
const device_1 = __importDefault(require("../device"));
|
|
8
|
-
const device_2 = require("../device");
|
|
9
|
-
exports.DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
10
|
-
class AntAdapter extends device_1.default {
|
|
11
|
-
constructor(protocol) {
|
|
12
|
-
super(protocol);
|
|
13
|
-
this.paused = false;
|
|
14
|
-
this.stopped = false;
|
|
15
|
-
this.ignoreHrm = false;
|
|
16
|
-
this.ignoreBike = false;
|
|
17
|
-
this.ignorePower = false;
|
|
18
|
-
this.deviceID = undefined;
|
|
19
|
-
this.port = undefined;
|
|
20
|
-
this.stick = undefined;
|
|
21
|
-
this.channel = -1;
|
|
22
|
-
this.deviceData = {};
|
|
23
|
-
this.data = {};
|
|
24
|
-
this.updateFrequency = exports.DEFAULT_UPDATE_FREQUENCY;
|
|
25
|
-
}
|
|
26
|
-
isSame(device) {
|
|
27
|
-
if (!(device instanceof AntAdapter))
|
|
28
|
-
return false;
|
|
29
|
-
const adapter = device;
|
|
30
|
-
return (adapter.getName() === this.getName() && adapter.getProfile() === this.getProfile());
|
|
31
|
-
}
|
|
32
|
-
setSensor(sensor) {
|
|
33
|
-
this.sensor = sensor;
|
|
34
|
-
}
|
|
35
|
-
getID() {
|
|
36
|
-
return this.deviceID;
|
|
37
|
-
}
|
|
38
|
-
setIgnoreHrm(ignore) {
|
|
39
|
-
this.ignoreHrm = ignore;
|
|
40
|
-
}
|
|
41
|
-
setIgnoreBike(ignore) {
|
|
42
|
-
this.ignoreBike = ignore;
|
|
43
|
-
}
|
|
44
|
-
setIgnorePower(ignore) {
|
|
45
|
-
this.ignorePower = ignore;
|
|
46
|
-
}
|
|
47
|
-
getProfile() {
|
|
48
|
-
return "unknown";
|
|
49
|
-
}
|
|
50
|
-
getPort() {
|
|
51
|
-
return this.port;
|
|
52
|
-
}
|
|
53
|
-
getWeight() {
|
|
54
|
-
let userWeight = device_2.DEFAULT_USER_WEIGHT;
|
|
55
|
-
let bikeWeight = device_2.DEFAULT_BIKE_WEIGHT;
|
|
56
|
-
if (this.userSettings && this.userSettings.weight) {
|
|
57
|
-
userWeight = Number(this.userSettings.weight);
|
|
58
|
-
}
|
|
59
|
-
if (this.bikeSettings && this.bikeSettings.weight) {
|
|
60
|
-
bikeWeight = Number(this.bikeSettings.weight);
|
|
61
|
-
}
|
|
62
|
-
return bikeWeight + userWeight;
|
|
63
|
-
}
|
|
64
|
-
setChannel(channel) {
|
|
65
|
-
this.channel = channel;
|
|
66
|
-
}
|
|
67
|
-
setStick(stick) {
|
|
68
|
-
this.stick = stick;
|
|
69
|
-
}
|
|
70
|
-
isStopped() {
|
|
71
|
-
return this.stopped;
|
|
72
|
-
}
|
|
73
|
-
onDeviceData(data) { }
|
|
74
|
-
onDeviceEvent(data) { }
|
|
75
|
-
onAttached() { }
|
|
76
|
-
update() { }
|
|
77
|
-
check() { }
|
|
78
|
-
connect() { }
|
|
79
|
-
close() { }
|
|
80
|
-
pause() {
|
|
81
|
-
return new Promise(resolve => {
|
|
82
|
-
this.paused = true;
|
|
83
|
-
resolve(true);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
resume() {
|
|
87
|
-
return new Promise(resolve => {
|
|
88
|
-
this.paused = false;
|
|
89
|
-
resolve(true);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
start(props) {
|
|
93
|
-
if (props && props.user)
|
|
94
|
-
this.userSettings = props.user;
|
|
95
|
-
if (props && props.bikeSettings)
|
|
96
|
-
this.bikeSettings = props.bikeSettings;
|
|
97
|
-
return new Promise(resolve => {
|
|
98
|
-
this.stopped = false;
|
|
99
|
-
resolve(true);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
stop() {
|
|
103
|
-
return new Promise(resolve => {
|
|
104
|
-
this.stopped = true;
|
|
105
|
-
resolve(true);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.default = AntAdapter;
|