incyclist-devices 1.5.38 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +238 -0
- package/lib/adapters.d.ts +7 -0
- package/lib/adapters.js +49 -0
- package/lib/antv2/adapter-factory.d.ts +21 -10
- package/lib/antv2/adapter-factory.js +51 -33
- package/lib/antv2/adapter.d.ts +65 -0
- package/lib/antv2/adapter.js +310 -0
- package/lib/antv2/ant-interface.d.ts +17 -11
- package/lib/antv2/ant-interface.js +41 -31
- package/lib/antv2/{ant-binding.d.ts → binding.d.ts} +1 -1
- package/lib/antv2/{ant-binding.js → binding.js} +1 -1
- package/lib/antv2/fe/adapter.d.ts +28 -0
- package/lib/antv2/{fe.js → fe/adapter.js} +106 -90
- package/lib/antv2/fe/index.d.ts +2 -0
- package/lib/antv2/fe/index.js +7 -0
- package/lib/antv2/hr/adapter.d.ts +15 -0
- package/lib/antv2/hr/adapter.js +76 -0
- package/lib/antv2/hr/index.d.ts +2 -0
- package/lib/antv2/hr/index.js +7 -0
- package/lib/antv2/index.d.ts +7 -0
- package/lib/antv2/index.js +20 -0
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +9 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-adv-st-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +6 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-erg-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +5 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-st-mode.js +1 -1
- package/lib/antv2/pwr/adapter.d.ts +24 -0
- package/lib/antv2/pwr/adapter.js +141 -0
- package/lib/antv2/pwr/index.d.ts +2 -0
- package/lib/antv2/pwr/index.js +7 -0
- package/lib/antv2/sensor-factory.d.ts +2 -2
- package/lib/antv2/types.d.ts +22 -0
- package/lib/antv2/types.js +5 -0
- package/lib/antv2/utils.d.ts +4 -0
- package/lib/antv2/utils.js +192 -0
- package/lib/base/adpater.d.ts +68 -0
- package/lib/base/adpater.js +183 -0
- package/lib/ble/adapter-factory.d.ts +33 -0
- package/lib/ble/adapter-factory.js +105 -0
- package/lib/ble/base/adapter.d.ts +53 -0
- package/lib/ble/base/adapter.js +290 -0
- package/lib/ble/base/comms-utils.d.ts +7 -0
- package/lib/ble/base/comms-utils.js +91 -0
- package/lib/ble/{ble-device.d.ts → base/comms.d.ts} +31 -16
- package/lib/ble/{ble-device.js → base/comms.js} +193 -55
- package/lib/ble/bindings/index.d.ts +2 -0
- package/lib/ble/bindings/index.js +8 -0
- package/lib/ble/bindings/linux.d.ts +15 -0
- package/lib/ble/bindings/linux.js +39 -0
- package/lib/ble/bindings/mock.d.ts +9 -0
- package/lib/ble/bindings/mock.js +108 -0
- package/lib/ble/bindings/types.d.ts +57 -0
- package/lib/ble/bindings/types.js +96 -0
- package/lib/ble/ble-interface.d.ts +38 -59
- package/lib/ble/ble-interface.js +254 -462
- package/lib/ble/ble-peripheral.d.ts +7 -5
- package/lib/ble/ble-peripheral.js +52 -21
- package/lib/ble/consts.d.ts +3 -0
- package/lib/ble/consts.js +4 -1
- package/lib/ble/cp/adapter.d.ts +22 -0
- package/lib/ble/cp/adapter.js +111 -0
- package/lib/ble/cp/comm.d.ts +31 -0
- package/lib/ble/cp/comm.js +125 -0
- package/lib/ble/cp/index.d.ts +4 -0
- package/lib/ble/cp/index.js +10 -0
- package/lib/ble/cp/types.d.ts +13 -0
- package/lib/ble/cp/types.js +2 -0
- package/lib/ble/elite/adapter.d.ts +19 -0
- package/lib/ble/elite/adapter.js +120 -0
- package/lib/ble/elite/comms.d.ts +32 -0
- package/lib/ble/elite/comms.js +126 -0
- package/lib/ble/elite/index.d.ts +3 -0
- package/lib/ble/elite/index.js +10 -0
- package/lib/ble/fm/adapter.d.ts +22 -0
- package/lib/ble/fm/adapter.js +249 -0
- package/lib/ble/fm/comms.d.ts +50 -0
- package/lib/ble/{fm.js → fm/comms.js} +34 -277
- package/lib/ble/fm/consts.d.ts +6 -0
- package/lib/ble/fm/consts.js +9 -0
- package/lib/ble/fm/index.d.ts +5 -0
- package/lib/ble/fm/index.js +13 -0
- package/lib/ble/fm/types.d.ts +30 -0
- package/lib/ble/fm/types.js +2 -0
- package/lib/ble/hr/adapter.d.ts +14 -0
- package/lib/ble/hr/adapter.js +45 -0
- package/lib/ble/hr/comm.d.ts +19 -0
- package/lib/ble/hr/comm.js +56 -0
- package/lib/ble/hr/index.d.ts +4 -0
- package/lib/ble/hr/index.js +10 -0
- package/lib/ble/hr/mock.d.ts +7 -0
- package/lib/ble/hr/mock.js +47 -0
- package/lib/ble/hr/types.d.ts +5 -0
- package/lib/ble/hr/types.js +2 -0
- package/lib/ble/index.d.ts +9 -0
- package/lib/ble/index.js +26 -0
- package/lib/ble/peripheral-cache.d.ts +43 -0
- package/lib/ble/peripheral-cache.js +107 -0
- package/lib/ble/tacx/adapter.d.ts +10 -0
- package/lib/ble/tacx/adapter.js +99 -0
- package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +11 -43
- package/lib/ble/{tacx.js → tacx/comms.js} +23 -155
- package/lib/ble/tacx/index.d.ts +4 -0
- package/lib/ble/tacx/index.js +10 -0
- package/lib/ble/tacx/types.d.ts +25 -0
- package/lib/ble/tacx/types.js +2 -0
- package/lib/ble/types.d.ts +128 -0
- package/lib/ble/types.js +2 -0
- package/lib/ble/utils.d.ts +17 -0
- package/lib/ble/utils.js +54 -0
- package/lib/ble/wahoo/adapter.d.ts +9 -0
- package/lib/ble/wahoo/adapter.js +95 -0
- package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +11 -44
- package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +29 -129
- package/lib/ble/wahoo/index.d.ts +4 -0
- package/lib/ble/wahoo/index.js +10 -0
- package/lib/ble/wahoo/types.d.ts +19 -0
- package/lib/ble/wahoo/types.js +2 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +34 -0
- package/lib/interfaces.d.ts +7 -0
- package/lib/interfaces.js +27 -0
- package/lib/{ble → modes}/ble-erg-mode.d.ts +4 -4
- package/lib/{ble → modes}/ble-erg-mode.js +2 -2
- package/lib/{ble → modes}/ble-st-mode.d.ts +3 -3
- package/lib/{ble → modes}/ble-st-mode.js +1 -1
- package/lib/{cycling-mode.d.ts → modes/cycling-mode.d.ts} +8 -8
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +8 -4
- package/lib/modes/power-meter.d.ts +3 -3
- package/lib/modes/simulator.d.ts +2 -2
- package/lib/modes/simulator.js +1 -1
- package/lib/serial/adapter-factory.d.ts +12 -0
- package/lib/serial/adapter-factory.js +30 -0
- package/lib/serial/adapter.d.ts +21 -0
- package/lib/serial/adapter.js +61 -0
- package/lib/serial/bindings/tcp.d.ts +45 -0
- package/lib/serial/bindings/tcp.js +284 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/{daum → serial/daum}/DaumAdapter.d.ts +14 -23
- package/lib/{daum → serial/daum}/DaumAdapter.js +57 -97
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.d.ts +2 -2
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.js +1 -1
- package/lib/{daum → serial/daum}/ERGCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/ERGCyclingMode.js +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.js +4 -3
- package/lib/serial/daum/classic/adapter.d.ts +29 -0
- package/lib/{daum/classic/DaumClassicAdapter.js → serial/daum/classic/adapter.js} +77 -50
- package/lib/{daum/classic/bike.d.ts → serial/daum/classic/comms.d.ts} +14 -16
- package/lib/{daum/classic/bike.js → serial/daum/classic/comms.js} +68 -152
- package/lib/serial/daum/classic/mock.d.ts +96 -0
- package/lib/serial/daum/classic/mock.js +365 -0
- package/lib/{daum/classic/DaumClassicCyclingMode.d.ts → serial/daum/classic/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/classic/DaumClassicCyclingMode.js → serial/daum/classic/modes/daum-classic.js} +2 -2
- package/lib/{daum → serial/daum}/classic/utils.d.ts +1 -1
- package/lib/serial/daum/premium/adapter.d.ts +25 -0
- package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +107 -47
- package/lib/{daum/premium/bike.d.ts → serial/daum/premium/comms.d.ts} +26 -54
- package/lib/{daum/premium/bike.js → serial/daum/premium/comms.js} +215 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +289 -0
- package/lib/{daum/premium/DaumClassicCyclingMode.d.ts → serial/daum/premium/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/premium/DaumClassicCyclingMode.js → serial/daum/premium/modes/daum-classic.js} +2 -2
- package/lib/serial/daum/premium/types.d.ts +12 -0
- package/lib/serial/daum/premium/types.js +2 -0
- package/lib/{daum → serial/daum}/premium/utils.d.ts +8 -11
- package/lib/{daum → serial/daum}/premium/utils.js +22 -63
- package/lib/serial/index.d.ts +9 -0
- package/lib/serial/index.js +49 -0
- package/lib/{kettler → serial/kettler}/comms.d.ts +8 -6
- package/lib/{kettler → serial/kettler}/comms.js +71 -32
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.d.ts +14 -28
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +102 -169
- package/lib/serial/kettler/ergo-racer/mock.d.ts +66 -0
- package/lib/serial/kettler/ergo-racer/mock.js +216 -0
- package/lib/{kettler/ergo-racer/ERGCyclingMode.d.ts → serial/kettler/ergo-racer/modes/erg.d.ts} +4 -4
- package/lib/{kettler/ergo-racer/ERGCyclingMode.js → serial/kettler/ergo-racer/modes/erg.js} +2 -2
- package/lib/serial/serial-interface.d.ts +60 -0
- package/lib/serial/serial-interface.js +309 -0
- package/lib/simulator/Simulator.d.ts +12 -25
- package/lib/simulator/Simulator.js +26 -87
- package/lib/types/adapter.d.ts +39 -0
- package/lib/types/adapter.js +2 -0
- package/lib/types/capabilities.d.ts +8 -0
- package/lib/types/capabilities.js +12 -0
- package/lib/types/data.d.ts +12 -0
- package/lib/types/data.js +2 -0
- package/lib/types/device.d.ts +32 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +18 -0
- package/lib/types/interface.js +2 -0
- package/lib/types/route.d.ts +2 -2
- package/lib/types/user.d.ts +1 -1
- package/lib/{utils.d.ts → utils/utils.d.ts} +1 -0
- package/lib/{utils.js → utils/utils.js} +5 -1
- package/package.json +16 -14
- package/lib/DeviceSupport.d.ts +0 -36
- package/lib/DeviceSupport.js +0 -82
- package/lib/ant/AntAdapter.d.ts +0 -50
- package/lib/ant/AntAdapter.js +0 -109
- package/lib/ant/AntScanner.d.ts +0 -60
- package/lib/ant/AntScanner.js +0 -651
- package/lib/ant/antfe/AntFEAdapter.d.ts +0 -83
- package/lib/ant/antfe/AntFEAdapter.js +0 -652
- package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/ant/antfe/ant-fe-erg-mode.d.ts +0 -6
- package/lib/ant/antfe/ant-fe-st-mode.d.ts +0 -5
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +0 -16
- package/lib/ant/anthrm/AntHrmAdapter.js +0 -130
- package/lib/ant/antpwr/pwr-adapter.d.ts +0 -49
- package/lib/ant/antpwr/pwr-adapter.js +0 -251
- package/lib/ant/utils.d.ts +0 -1
- package/lib/ant/utils.js +0 -23
- package/lib/antv2/AntAdapter.d.ts +0 -48
- package/lib/antv2/AntAdapter.js +0 -104
- package/lib/antv2/ant-device.d.ts +0 -59
- package/lib/antv2/ant-device.js +0 -161
- package/lib/antv2/fe.d.ts +0 -32
- package/lib/antv2/hr.d.ts +0 -18
- package/lib/antv2/hr.js +0 -102
- package/lib/antv2/incyclist-protocol.d.ts +0 -37
- package/lib/antv2/incyclist-protocol.js +0 -126
- package/lib/antv2/pwr.d.ts +0 -28
- package/lib/antv2/pwr.js +0 -171
- package/lib/ble/ble.d.ts +0 -129
- package/lib/ble/ble.js +0 -86
- package/lib/ble/elite.d.ts +0 -90
- package/lib/ble/elite.js +0 -322
- package/lib/ble/fm.d.ts +0 -125
- package/lib/ble/hrm.d.ts +0 -48
- package/lib/ble/hrm.js +0 -134
- package/lib/ble/incyclist-protocol.d.ts +0 -31
- package/lib/ble/incyclist-protocol.js +0 -153
- package/lib/ble/pwr.d.ts +0 -89
- package/lib/ble/pwr.js +0 -322
- package/lib/daum/classic/DaumClassicAdapter.d.ts +0 -28
- package/lib/daum/classic/DaumClassicProtocol.d.ts +0 -27
- package/lib/daum/classic/DaumClassicProtocol.js +0 -185
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +0 -16
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +0 -32
- package/lib/daum/premium/DaumPremiumProtocol.js +0 -207
- package/lib/daum/premium/tcpserial.d.ts +0 -33
- package/lib/daum/premium/tcpserial.js +0 -123
- package/lib/device.d.ts +0 -94
- package/lib/device.js +0 -76
- package/lib/kettler/ergo-racer/protocol.d.ts +0 -41
- package/lib/kettler/ergo-racer/protocol.js +0 -203
- package/lib/protocol.d.ts +0 -74
- package/lib/protocol.js +0 -41
- package/lib/registry.d.ts +0 -8
- package/lib/registry.js +0 -33
- package/lib/serialport/bindings/tcp.d.ts +0 -20
- package/lib/serialport/bindings/tcp.js +0 -33
- package/lib/serialport/index.d.ts +0 -2
- package/lib/serialport/index.js +0 -29
- package/lib/serialport/serialport.d.ts +0 -29
- package/lib/serialport/serialport.js +0 -87
- /package/lib/{cycling-mode.js → modes/cycling-mode.js} +0 -0
- /package/lib/{daum → serial/daum}/classic/utils.js +0 -0
- /package/lib/{daum → serial/daum}/constants.d.ts +0 -0
- /package/lib/{daum → serial/daum}/constants.js +0 -0
- /package/lib/{serialport.d.ts → serial/serialport.d.ts} +0 -0
- /package/lib/{serialport.js → serial/serialport.js} +0 -0
- /package/lib/{calculations.d.ts → utils/calculations.d.ts} +0 -0
- /package/lib/{calculations.js → utils/calculations.js} +0 -0
|
@@ -1,130 +0,0 @@
|
|
|
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 AntAdapter_1 = __importDefault(require("../AntAdapter"));
|
|
17
|
-
const utils_1 = require("../utils");
|
|
18
|
-
const DEFAULT_START_TIMEOUT = 5000;
|
|
19
|
-
class AntHrmAdapter extends AntAdapter_1.default {
|
|
20
|
-
constructor(DeviceID, port, stick, protocol) {
|
|
21
|
-
super(protocol);
|
|
22
|
-
this.logger = new gd_eventlog_1.EventLogger('Ant+Hrm');
|
|
23
|
-
this.deviceID = DeviceID;
|
|
24
|
-
this.port = port;
|
|
25
|
-
this.stick = stick;
|
|
26
|
-
this.paused = false;
|
|
27
|
-
this.deviceData = {
|
|
28
|
-
DeviceID
|
|
29
|
-
};
|
|
30
|
-
this.data = {};
|
|
31
|
-
this.started = false;
|
|
32
|
-
this.starting = false;
|
|
33
|
-
}
|
|
34
|
-
isBike() { return false; }
|
|
35
|
-
isHrm() { return true; }
|
|
36
|
-
isPower() { return false; }
|
|
37
|
-
getProfile() {
|
|
38
|
-
return 'Heartrate Monitor';
|
|
39
|
-
}
|
|
40
|
-
getName() {
|
|
41
|
-
return `Ant+Hrm ${this.deviceID}`;
|
|
42
|
-
}
|
|
43
|
-
getDisplayName() {
|
|
44
|
-
const { DeviceID, manID, ComputedHeartRate } = this.deviceData;
|
|
45
|
-
const hrmStr = ComputedHeartRate ? ` (${ComputedHeartRate})` : '';
|
|
46
|
-
return `${(0, utils_1.getBrand)(manID)} Hrm ${DeviceID}${hrmStr}`;
|
|
47
|
-
}
|
|
48
|
-
onDeviceData(deviceData) {
|
|
49
|
-
if (!this.started)
|
|
50
|
-
return;
|
|
51
|
-
this.deviceData = deviceData;
|
|
52
|
-
try {
|
|
53
|
-
if (this.onDataFn && !this.ignoreHrm && !this.paused) {
|
|
54
|
-
if (this.lastUpdate === undefined || (Date.now() - this.lastUpdate) > this.updateFrequency) {
|
|
55
|
-
this.logger.logEvent({ message: 'onDeviceData', data: deviceData });
|
|
56
|
-
const data = this.updateData(this.data, deviceData);
|
|
57
|
-
this.onDataFn(data);
|
|
58
|
-
this.lastUpdate = Date.now();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
updateData(data, deviceData) {
|
|
66
|
-
data.heartrate = deviceData.ComputedHeartRate;
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
start(props) {
|
|
70
|
-
const _super = Object.create(null, {
|
|
71
|
-
start: { get: () => super.start }
|
|
72
|
-
});
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
yield _super.start.call(this, props);
|
|
75
|
-
this.logger.logEvent({ message: 'start()' });
|
|
76
|
-
const args = props || {};
|
|
77
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
if (this.ignoreHrm)
|
|
79
|
-
resolve(false);
|
|
80
|
-
if (this.starting) {
|
|
81
|
-
this.logger.logEvent({ message: 'start() not done: bike starting' });
|
|
82
|
-
return resolve(false);
|
|
83
|
-
}
|
|
84
|
-
if (this.started) {
|
|
85
|
-
this.logger.logEvent({ message: 'start() done: bike was already started' });
|
|
86
|
-
return resolve(true);
|
|
87
|
-
}
|
|
88
|
-
this.starting = true;
|
|
89
|
-
const Ant = this.getProtocol().getAnt();
|
|
90
|
-
const protocol = this.getProtocol();
|
|
91
|
-
let start = Date.now();
|
|
92
|
-
let timeout = start + (args.timeout || DEFAULT_START_TIMEOUT);
|
|
93
|
-
const iv = setInterval(() => {
|
|
94
|
-
if (Date.now() > timeout) {
|
|
95
|
-
clearInterval(iv);
|
|
96
|
-
this.starting = false;
|
|
97
|
-
reject(new Error('timeout'));
|
|
98
|
-
}
|
|
99
|
-
if (this.isStopped()) {
|
|
100
|
-
clearInterval(iv);
|
|
101
|
-
this.starting = false;
|
|
102
|
-
reject(new Error('stopped'));
|
|
103
|
-
}
|
|
104
|
-
}, 100);
|
|
105
|
-
protocol.attachSensors(this, Ant.HeartRateSensor, 'hbData')
|
|
106
|
-
.then(() => {
|
|
107
|
-
this.starting = false;
|
|
108
|
-
this.started = true;
|
|
109
|
-
clearInterval(iv);
|
|
110
|
-
resolve(true);
|
|
111
|
-
})
|
|
112
|
-
.catch(err => reject(err));
|
|
113
|
-
}));
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
stop() {
|
|
117
|
-
const _super = Object.create(null, {
|
|
118
|
-
stop: { get: () => super.stop }
|
|
119
|
-
});
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
yield _super.stop.call(this);
|
|
122
|
-
this.logger.logEvent({ message: 'stop()' });
|
|
123
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
this.starting = false;
|
|
125
|
-
return resolve(true);
|
|
126
|
-
}));
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.default = AntHrmAdapter;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import AntAdapter from '../AntAdapter';
|
|
2
|
-
import { IncyclistBikeData } from '../../cycling-mode';
|
|
3
|
-
import CyclingMode from '../../cycling-mode';
|
|
4
|
-
import { DeviceData } from '../../device';
|
|
5
|
-
export declare type AntPwrData = {
|
|
6
|
-
DeviceID: number;
|
|
7
|
-
PedalPower?: number;
|
|
8
|
-
RightPedalPower?: number;
|
|
9
|
-
LeftPedalPower?: number;
|
|
10
|
-
Cadence?: number;
|
|
11
|
-
AccumulatedPower?: number;
|
|
12
|
-
Power?: number;
|
|
13
|
-
offset?: number;
|
|
14
|
-
EventCount?: number;
|
|
15
|
-
TimeStamp?: number;
|
|
16
|
-
Slope?: number;
|
|
17
|
-
TorqueTicksStamp?: number;
|
|
18
|
-
CalculatedCadence?: number;
|
|
19
|
-
CalculatedTorque?: number;
|
|
20
|
-
CalculatedPower?: number;
|
|
21
|
-
};
|
|
22
|
-
export default class AntFEAdapter extends AntAdapter {
|
|
23
|
-
started: boolean;
|
|
24
|
-
starting: boolean;
|
|
25
|
-
connected: boolean;
|
|
26
|
-
distanceInternal?: number;
|
|
27
|
-
workerId?: any;
|
|
28
|
-
currentCmd?: any;
|
|
29
|
-
mode: CyclingMode;
|
|
30
|
-
constructor(DeviceID: any, port: any, stick: any, protocol: any);
|
|
31
|
-
isBike(): boolean;
|
|
32
|
-
isHrm(): boolean;
|
|
33
|
-
isPower(): boolean;
|
|
34
|
-
getProfile(): string;
|
|
35
|
-
getName(): string;
|
|
36
|
-
getDisplayName(): string;
|
|
37
|
-
getCyclingMode(): CyclingMode;
|
|
38
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
39
|
-
getSupportedCyclingModes(): any[];
|
|
40
|
-
onAttached(): void;
|
|
41
|
-
getLogData(data: any, excludeList: any): any;
|
|
42
|
-
onDeviceData(deviceData: AntPwrData): void;
|
|
43
|
-
onDeviceEvent(data: any): void;
|
|
44
|
-
sendUpdate(request: any): void;
|
|
45
|
-
mapData(deviceData: AntPwrData): IncyclistBikeData;
|
|
46
|
-
transformData(bikeData: IncyclistBikeData): DeviceData;
|
|
47
|
-
start(props?: any): Promise<any>;
|
|
48
|
-
stop(): Promise<boolean>;
|
|
49
|
-
}
|
|
@@ -1,251 +0,0 @@
|
|
|
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 AntAdapter_1 = __importDefault(require("../AntAdapter"));
|
|
17
|
-
const utils_1 = require("../utils");
|
|
18
|
-
const power_meter_1 = __importDefault(require("../../modes/power-meter"));
|
|
19
|
-
const floatVal = (d) => d ? parseFloat(d) : d;
|
|
20
|
-
const intVal = (d) => d ? parseInt(d) : d;
|
|
21
|
-
const hex = (v) => Math.abs(v).toString(16).toUpperCase();
|
|
22
|
-
const DEFAULT_START_TIMEOUT = 5000;
|
|
23
|
-
class AntFEAdapter extends AntAdapter_1.default {
|
|
24
|
-
constructor(DeviceID, port, stick, protocol) {
|
|
25
|
-
super(protocol);
|
|
26
|
-
this.logger = new gd_eventlog_1.EventLogger('Ant+PWR');
|
|
27
|
-
this.logger.logEvent({ message: 'Ant+PWR Adapter created', DeviceID, port });
|
|
28
|
-
this.deviceID = DeviceID;
|
|
29
|
-
this.port = port;
|
|
30
|
-
this.stick = stick;
|
|
31
|
-
this.deviceData = {
|
|
32
|
-
DeviceID
|
|
33
|
-
};
|
|
34
|
-
this.data = {};
|
|
35
|
-
this.started = false;
|
|
36
|
-
this.starting = false;
|
|
37
|
-
this.connected = false;
|
|
38
|
-
this.mode = this.getDefaultCyclingMode();
|
|
39
|
-
}
|
|
40
|
-
isBike() { return true; }
|
|
41
|
-
isHrm() { return false; }
|
|
42
|
-
isPower() { return true; }
|
|
43
|
-
getProfile() {
|
|
44
|
-
return 'Power Meter';
|
|
45
|
-
}
|
|
46
|
-
getName() {
|
|
47
|
-
return `Ant+PWR ${this.deviceID}`;
|
|
48
|
-
}
|
|
49
|
-
getDisplayName() {
|
|
50
|
-
const { DeviceID, ManId } = this.deviceData;
|
|
51
|
-
return `${(0, utils_1.getBrand)(ManId)} PWR ${DeviceID}`;
|
|
52
|
-
}
|
|
53
|
-
getCyclingMode() {
|
|
54
|
-
if (!this.mode)
|
|
55
|
-
this.mode = this.getDefaultCyclingMode();
|
|
56
|
-
return this.mode;
|
|
57
|
-
}
|
|
58
|
-
getDefaultCyclingMode() {
|
|
59
|
-
return new power_meter_1.default(this);
|
|
60
|
-
}
|
|
61
|
-
getSupportedCyclingModes() {
|
|
62
|
-
return [power_meter_1.default];
|
|
63
|
-
}
|
|
64
|
-
onAttached() {
|
|
65
|
-
this.logger.logEvent({ message: 'Device connected' });
|
|
66
|
-
this.connected = true;
|
|
67
|
-
}
|
|
68
|
-
getLogData(data, excludeList) {
|
|
69
|
-
const logData = JSON.parse(JSON.stringify(data));
|
|
70
|
-
excludeList.forEach((key) => {
|
|
71
|
-
delete logData[key];
|
|
72
|
-
});
|
|
73
|
-
return logData;
|
|
74
|
-
}
|
|
75
|
-
onDeviceData(deviceData) {
|
|
76
|
-
if (!this.started || this.isStopped())
|
|
77
|
-
return;
|
|
78
|
-
this.deviceData = deviceData;
|
|
79
|
-
try {
|
|
80
|
-
if (this.onDataFn && !(this.ignoreBike && this.ignorePower) && !this.paused) {
|
|
81
|
-
if (!this.lastUpdate || (Date.now() - this.lastUpdate) > this.updateFrequency) {
|
|
82
|
-
const logData = this.getLogData(deviceData, ['PairedDevices', 'RawData']);
|
|
83
|
-
this.logger.logEvent({ message: 'onDeviceData', data: logData });
|
|
84
|
-
let incyclistData = this.mapData(deviceData);
|
|
85
|
-
incyclistData = this.getCyclingMode().updateData(incyclistData);
|
|
86
|
-
const data = this.transformData(incyclistData);
|
|
87
|
-
this.onDataFn(data);
|
|
88
|
-
this.lastUpdate = Date.now();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
onDeviceEvent(data) {
|
|
96
|
-
try {
|
|
97
|
-
const cmdInfo = this.currentCmd;
|
|
98
|
-
if (!cmdInfo)
|
|
99
|
-
return;
|
|
100
|
-
const msg = cmdInfo.msg.readUInt8(2);
|
|
101
|
-
const Constants = this.getProtocol().getAnt().Constants;
|
|
102
|
-
const { expectedResponse } = cmdInfo;
|
|
103
|
-
if (data.message === msg) {
|
|
104
|
-
if (expectedResponse === undefined && data.code === Constants.EVENT_TRANSFER_TX_COMPLETED) {
|
|
105
|
-
this.currentCmd.response = { success: true, message: hex(data.message), code: hex(data.code) };
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (expectedResponse === undefined && data.code !== Constants.EVENT_TRANSFER_TX_COMPLETED) {
|
|
109
|
-
this.currentCmd.response = { success: false, message: hex(data.message), code: hex(data.code) };
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (data.message === 1) {
|
|
114
|
-
if (expectedResponse !== undefined && data.code === expectedResponse) {
|
|
115
|
-
this.currentCmd.response = { success: true, message: hex(data.message), code: hex(data.code) };
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (expectedResponse === undefined && (data.code === Constants.EVENT_TRANSFER_TX_COMPLETED || data.code === 3)) {
|
|
119
|
-
this.currentCmd.response = { success: true, message: hex(data.message), code: hex(data.code) };
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (data.code === Constants.EVENT_TRANSFER_TX_FAILED || data.code === Constants.EVENT_CHANNEL_COLLISION) {
|
|
123
|
-
this.currentCmd.response = { success: false, message: hex(data.message), code: hex(data.code) };
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (this.currentCmd !== undefined && data.message === Constants.MESSAGE_CHANNEL_ACKNOWLEDGED_DATA && data.code === 31) {
|
|
128
|
-
this.logger.log("could not send (TRANSFER_IN_PROGRESS)");
|
|
129
|
-
this.currentCmd.response = { success: false, message: hex(data.message), code: hex(data.code) };
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
this.logger.logEvent({ message: "Incoming Event ", event: { message: hex(data.message), code: hex(data.code) } });
|
|
133
|
-
}
|
|
134
|
-
catch (err) {
|
|
135
|
-
this.logger.logEvent({ message: 'Error', fn: 'parseEvent', event: { message: hex(data.message), code: hex(data.code) }, error: err.message || err });
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
sendUpdate(request) {
|
|
139
|
-
if (this.paused)
|
|
140
|
-
return;
|
|
141
|
-
this.getCyclingMode().sendBikeUpdate(request);
|
|
142
|
-
}
|
|
143
|
-
mapData(deviceData) {
|
|
144
|
-
const data = {
|
|
145
|
-
isPedalling: false,
|
|
146
|
-
power: 0,
|
|
147
|
-
pedalRpm: 0,
|
|
148
|
-
speed: 0,
|
|
149
|
-
heartrate: 0,
|
|
150
|
-
distanceInternal: 0,
|
|
151
|
-
slope: undefined,
|
|
152
|
-
time: undefined
|
|
153
|
-
};
|
|
154
|
-
data.slope = (deviceData.Slope !== undefined ? deviceData.Slope : data.slope);
|
|
155
|
-
data.power = (deviceData.Power !== undefined ? deviceData.Power : data.power);
|
|
156
|
-
data.pedalRpm = (deviceData.Cadence !== undefined ? deviceData.Cadence : data.pedalRpm);
|
|
157
|
-
data.time = (deviceData.TimeStamp !== undefined ? deviceData.TimeStamp : data.time);
|
|
158
|
-
data.isPedalling = data.pedalRpm > 0;
|
|
159
|
-
return data;
|
|
160
|
-
}
|
|
161
|
-
transformData(bikeData) {
|
|
162
|
-
if (bikeData === undefined)
|
|
163
|
-
return;
|
|
164
|
-
let distance = 0;
|
|
165
|
-
if (this.distanceInternal !== undefined && bikeData.distanceInternal !== undefined) {
|
|
166
|
-
distance = intVal(bikeData.distanceInternal - this.distanceInternal);
|
|
167
|
-
}
|
|
168
|
-
if (bikeData.distanceInternal !== undefined)
|
|
169
|
-
this.distanceInternal = bikeData.distanceInternal;
|
|
170
|
-
let data = {
|
|
171
|
-
speed: floatVal(bikeData.speed),
|
|
172
|
-
slope: floatVal(bikeData.slope),
|
|
173
|
-
power: intVal(bikeData.power),
|
|
174
|
-
cadence: intVal(bikeData.pedalRpm),
|
|
175
|
-
distance,
|
|
176
|
-
timestamp: Date.now()
|
|
177
|
-
};
|
|
178
|
-
if (this.ignorePower) {
|
|
179
|
-
delete data.power;
|
|
180
|
-
delete data.cadence;
|
|
181
|
-
}
|
|
182
|
-
if (this.ignoreBike) {
|
|
183
|
-
data = {};
|
|
184
|
-
}
|
|
185
|
-
return data;
|
|
186
|
-
}
|
|
187
|
-
start(props) {
|
|
188
|
-
const _super = Object.create(null, {
|
|
189
|
-
start: { get: () => super.start }
|
|
190
|
-
});
|
|
191
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
-
yield _super.start.call(this, props);
|
|
193
|
-
this.logger.logEvent({ message: 'start()', props });
|
|
194
|
-
const opts = props || {};
|
|
195
|
-
const { args = {} } = opts;
|
|
196
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
197
|
-
if (this.ignoreBike && this.ignorePower) {
|
|
198
|
-
this.logger.logEvent({ message: 'start() not done: bike disabled' });
|
|
199
|
-
return resolve(false);
|
|
200
|
-
}
|
|
201
|
-
if (this.starting) {
|
|
202
|
-
this.logger.logEvent({ message: 'start() not done: bike starting' });
|
|
203
|
-
return resolve(false);
|
|
204
|
-
}
|
|
205
|
-
if (this.started) {
|
|
206
|
-
this.logger.logEvent({ message: 'start() done: bike was already started' });
|
|
207
|
-
return resolve(true);
|
|
208
|
-
}
|
|
209
|
-
this.starting = true;
|
|
210
|
-
const Ant = this.getProtocol().getAnt();
|
|
211
|
-
const protocol = this.getProtocol();
|
|
212
|
-
let start = Date.now();
|
|
213
|
-
let timeout = start + (args.timeout || DEFAULT_START_TIMEOUT);
|
|
214
|
-
const iv = setInterval(() => {
|
|
215
|
-
if (Date.now() > timeout) {
|
|
216
|
-
clearInterval(iv);
|
|
217
|
-
this.starting = false;
|
|
218
|
-
reject(new Error('timeout'));
|
|
219
|
-
}
|
|
220
|
-
if (this.isStopped()) {
|
|
221
|
-
clearInterval(iv);
|
|
222
|
-
this.starting = false;
|
|
223
|
-
reject(new Error('stopped'));
|
|
224
|
-
}
|
|
225
|
-
}, 100);
|
|
226
|
-
protocol.attachSensors(this, Ant.BicyclePowerSensor, 'powerData')
|
|
227
|
-
.then(() => {
|
|
228
|
-
this.starting = false;
|
|
229
|
-
this.started = true;
|
|
230
|
-
clearInterval(iv);
|
|
231
|
-
resolve(true);
|
|
232
|
-
})
|
|
233
|
-
.catch(err => reject(err));
|
|
234
|
-
}));
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
stop() {
|
|
238
|
-
const _super = Object.create(null, {
|
|
239
|
-
stop: { get: () => super.stop }
|
|
240
|
-
});
|
|
241
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
-
yield _super.stop.call(this);
|
|
243
|
-
this.logger.logEvent({ message: 'stop()' });
|
|
244
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
this.starting = false;
|
|
246
|
-
return resolve(true);
|
|
247
|
-
}));
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
exports.default = AntFEAdapter;
|
package/lib/ant/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getBrand: (manId: any) => "ANT+" | "Garmin" | "Timex" | "Suunto" | "Seiko" | "Sigma" | "Polar" | "VDO" | "Wahoo" | "Elite" | "Tacx";
|
package/lib/ant/utils.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBrand = void 0;
|
|
4
|
-
const getBrand = (manId) => {
|
|
5
|
-
if (manId === undefined)
|
|
6
|
-
return "ANT+";
|
|
7
|
-
switch (manId) {
|
|
8
|
-
case 1: return "Garmin";
|
|
9
|
-
case 16: return "Timex";
|
|
10
|
-
case 23: return "Suunto";
|
|
11
|
-
case 52: return "Seiko";
|
|
12
|
-
case 53: return "Seiko";
|
|
13
|
-
case 70: return "Sigma";
|
|
14
|
-
case 123: return "Polar";
|
|
15
|
-
case 287: return "VDO";
|
|
16
|
-
case 32: return "Wahoo";
|
|
17
|
-
case 86: return "Elite";
|
|
18
|
-
case 89: return "Tacx";
|
|
19
|
-
default:
|
|
20
|
-
return "ANT+";
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
exports.getBrand = getBrand;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import IncyclistDevice from '../device';
|
|
2
|
-
import { EventLogger } from 'gd-eventlog';
|
|
3
|
-
import AntInterface from "./ant-interface";
|
|
4
|
-
import AntProtocol from "./incyclist-protocol";
|
|
5
|
-
import { ISensor } from "incyclist-ant-plus";
|
|
6
|
-
export declare const DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
7
|
-
export default class AntAdapter extends IncyclistDevice {
|
|
8
|
-
paused: boolean;
|
|
9
|
-
stopped: boolean;
|
|
10
|
-
ignoreHrm: boolean;
|
|
11
|
-
ignoreBike: boolean;
|
|
12
|
-
ignorePower: boolean;
|
|
13
|
-
deviceData: any;
|
|
14
|
-
data: any;
|
|
15
|
-
logger: EventLogger;
|
|
16
|
-
lastUpdate?: number;
|
|
17
|
-
updateFrequency: number;
|
|
18
|
-
userSettings: {
|
|
19
|
-
weight?: number;
|
|
20
|
-
};
|
|
21
|
-
bikeSettings: {
|
|
22
|
-
weight?: number;
|
|
23
|
-
};
|
|
24
|
-
protected ant: AntInterface;
|
|
25
|
-
protected sensor: ISensor;
|
|
26
|
-
constructor(sensor: ISensor, protocol: AntProtocol);
|
|
27
|
-
isSame(device: IncyclistDevice): 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
|
-
isStopped(): boolean;
|
|
37
|
-
onDeviceData(data: any): void;
|
|
38
|
-
onDeviceEvent(data: any): void;
|
|
39
|
-
onAttached(): void;
|
|
40
|
-
update(): void;
|
|
41
|
-
check(): void;
|
|
42
|
-
connect(): void;
|
|
43
|
-
close(): void;
|
|
44
|
-
pause(): Promise<boolean>;
|
|
45
|
-
resume(): Promise<boolean>;
|
|
46
|
-
start(props?: any): Promise<any>;
|
|
47
|
-
stop(): Promise<boolean>;
|
|
48
|
-
}
|
package/lib/antv2/AntAdapter.js
DELETED
|
@@ -1,104 +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
|
-
const ant_interface_1 = __importDefault(require("./ant-interface"));
|
|
10
|
-
const incyclist_protocol_1 = require("./incyclist-protocol");
|
|
11
|
-
exports.DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
12
|
-
class AntAdapter extends device_1.default {
|
|
13
|
-
constructor(sensor, protocol) {
|
|
14
|
-
super(protocol);
|
|
15
|
-
this.paused = false;
|
|
16
|
-
this.stopped = false;
|
|
17
|
-
this.ignoreHrm = false;
|
|
18
|
-
this.ignoreBike = false;
|
|
19
|
-
this.ignorePower = false;
|
|
20
|
-
this.deviceData = {};
|
|
21
|
-
this.data = {};
|
|
22
|
-
this.updateFrequency = exports.DEFAULT_UPDATE_FREQUENCY;
|
|
23
|
-
this.ant = ant_interface_1.default.getInstance();
|
|
24
|
-
this.sensor = sensor;
|
|
25
|
-
this.onData = this.onDeviceData.bind(this);
|
|
26
|
-
}
|
|
27
|
-
isSame(device) {
|
|
28
|
-
if (!(device instanceof AntAdapter))
|
|
29
|
-
return false;
|
|
30
|
-
const adapter = device;
|
|
31
|
-
return (adapter.getID() === this.getID() && adapter.getProfile() === this.getProfile());
|
|
32
|
-
}
|
|
33
|
-
setSensor(sensor) {
|
|
34
|
-
this.sensor = sensor;
|
|
35
|
-
}
|
|
36
|
-
getID() {
|
|
37
|
-
return this.sensor.getDeviceID().toString();
|
|
38
|
-
}
|
|
39
|
-
setIgnoreHrm(ignore) {
|
|
40
|
-
this.ignoreHrm = ignore;
|
|
41
|
-
}
|
|
42
|
-
setIgnoreBike(ignore) {
|
|
43
|
-
this.ignoreBike = ignore;
|
|
44
|
-
}
|
|
45
|
-
setIgnorePower(ignore) {
|
|
46
|
-
this.ignorePower = ignore;
|
|
47
|
-
}
|
|
48
|
-
getProfile() {
|
|
49
|
-
return (0, incyclist_protocol_1.mapAntProfile)(this.sensor.getProfile());
|
|
50
|
-
}
|
|
51
|
-
getPort() {
|
|
52
|
-
return 'ant';
|
|
53
|
-
}
|
|
54
|
-
getWeight() {
|
|
55
|
-
let userWeight = device_2.DEFAULT_USER_WEIGHT;
|
|
56
|
-
let bikeWeight = device_2.DEFAULT_BIKE_WEIGHT;
|
|
57
|
-
if (this.userSettings && this.userSettings.weight) {
|
|
58
|
-
userWeight = Number(this.userSettings.weight);
|
|
59
|
-
}
|
|
60
|
-
if (this.bikeSettings && this.bikeSettings.weight) {
|
|
61
|
-
bikeWeight = Number(this.bikeSettings.weight);
|
|
62
|
-
}
|
|
63
|
-
return bikeWeight + userWeight;
|
|
64
|
-
}
|
|
65
|
-
isStopped() {
|
|
66
|
-
return this.stopped;
|
|
67
|
-
}
|
|
68
|
-
onDeviceData(data) { }
|
|
69
|
-
onDeviceEvent(data) { }
|
|
70
|
-
onAttached() { }
|
|
71
|
-
update() { }
|
|
72
|
-
check() { }
|
|
73
|
-
connect() { }
|
|
74
|
-
close() { }
|
|
75
|
-
pause() {
|
|
76
|
-
return new Promise(resolve => {
|
|
77
|
-
this.paused = true;
|
|
78
|
-
resolve(true);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
resume() {
|
|
82
|
-
return new Promise(resolve => {
|
|
83
|
-
this.paused = false;
|
|
84
|
-
resolve(true);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
start(props) {
|
|
88
|
-
if (props && props.user)
|
|
89
|
-
this.userSettings = props.user;
|
|
90
|
-
if (props && props.bikeSettings)
|
|
91
|
-
this.bikeSettings = props.bikeSettings;
|
|
92
|
-
return new Promise(resolve => {
|
|
93
|
-
this.stopped = false;
|
|
94
|
-
resolve(true);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
stop() {
|
|
98
|
-
return new Promise(resolve => {
|
|
99
|
-
this.stopped = true;
|
|
100
|
-
resolve(true);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.default = AntAdapter;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Device } from '../protocol';
|
|
3
|
-
import { IChannel, ISensor } from 'incyclist-ant-plus';
|
|
4
|
-
import AntProtocol from './incyclist-protocol';
|
|
5
|
-
import AntInterface from './ant-interface';
|
|
6
|
-
import IncyclistDevice, { DeviceAdapter, OnDeviceDataCallback } from '../device';
|
|
7
|
-
export declare const DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
8
|
-
export default class AntAdapter extends IncyclistDevice implements Device {
|
|
9
|
-
sensor: ISensor;
|
|
10
|
-
protocol: AntProtocol;
|
|
11
|
-
ignoreHrm: boolean;
|
|
12
|
-
ignoreBike: boolean;
|
|
13
|
-
ignorePower: boolean;
|
|
14
|
-
lastUpdate?: number;
|
|
15
|
-
data: any;
|
|
16
|
-
deviceData: any;
|
|
17
|
-
updateFrequency: number;
|
|
18
|
-
channel: IChannel;
|
|
19
|
-
ant: AntInterface;
|
|
20
|
-
stopped: boolean;
|
|
21
|
-
paused: boolean;
|
|
22
|
-
userSettings: {
|
|
23
|
-
weight?: number;
|
|
24
|
-
};
|
|
25
|
-
bikeSettings: {
|
|
26
|
-
weight?: number;
|
|
27
|
-
};
|
|
28
|
-
detected: boolean;
|
|
29
|
-
selected: boolean;
|
|
30
|
-
settings: any;
|
|
31
|
-
onDataFn: OnDeviceDataCallback;
|
|
32
|
-
protected ivDataTimeout: NodeJS.Timer;
|
|
33
|
-
protected lastDataTS: number;
|
|
34
|
-
protected dataMsgCount: number;
|
|
35
|
-
private ivWaitForData;
|
|
36
|
-
constructor(sensor: ISensor, protocol: AntProtocol, settings?: any);
|
|
37
|
-
isBike(): boolean;
|
|
38
|
-
isPower(): boolean;
|
|
39
|
-
isHrm(): boolean;
|
|
40
|
-
getDisplayName(): string;
|
|
41
|
-
isSame(device: DeviceAdapter): boolean;
|
|
42
|
-
waitForData(timeout: number): Promise<unknown>;
|
|
43
|
-
getID(): string;
|
|
44
|
-
getName(): string;
|
|
45
|
-
getProfile(): string;
|
|
46
|
-
getPort(): string;
|
|
47
|
-
getProtocol(): AntProtocol;
|
|
48
|
-
getProtocolName(): string;
|
|
49
|
-
setIgnoreHrm(ignore: any): void;
|
|
50
|
-
setIgnoreBike(ignore: any): void;
|
|
51
|
-
setIgnorePower(ignore: any): void;
|
|
52
|
-
pause(): Promise<boolean>;
|
|
53
|
-
resume(): Promise<boolean>;
|
|
54
|
-
startDataTimeoutCheck(): void;
|
|
55
|
-
stopDataTimeoutCheck(): void;
|
|
56
|
-
start(props?: any): Promise<any>;
|
|
57
|
-
stop(): Promise<boolean>;
|
|
58
|
-
isStopped(): boolean;
|
|
59
|
-
}
|