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
|
@@ -13,19 +13,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
16
|
-
const
|
|
16
|
+
const device_1 = require("../../../types/device");
|
|
17
|
+
const __1 = require("../..");
|
|
18
|
+
const serial_interface_1 = require("../../serial-interface");
|
|
19
|
+
const utils_1 = require("../../../utils/utils");
|
|
17
20
|
const DaumAdapter_1 = __importDefault(require("../DaumAdapter"));
|
|
18
|
-
const
|
|
21
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
22
|
+
const daum_classic_1 = __importDefault(require("./modes/daum-classic"));
|
|
19
23
|
const PROTOCOL_NAME = "Daum Premium";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const DAUM_PREMIUM_DEFAULT_PORT = 51955;
|
|
25
|
+
const START_RETRY_TIMEOUT = 1500;
|
|
26
|
+
const DEFAULT_GEAR = 10;
|
|
27
|
+
const getBikeProps = (props) => {
|
|
28
|
+
const { host, port = DAUM_PREMIUM_DEFAULT_PORT, interface: ifaceName } = props;
|
|
29
|
+
let serial;
|
|
30
|
+
if (ifaceName && typeof ifaceName === 'string') {
|
|
31
|
+
serial = __1.SerialInterface.getInstance({ ifaceName });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
serial = props.interface;
|
|
35
|
+
}
|
|
36
|
+
if (!serial || !serial.binding)
|
|
37
|
+
throw new Error(`unknonwn interface: ${ifaceName}`);
|
|
38
|
+
if (serial.getName() === serial_interface_1.SerialInterfaceType.TCPIP) {
|
|
39
|
+
const path = `${host}:${port}`;
|
|
40
|
+
return { serial, path };
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const path = `${port}`;
|
|
44
|
+
return { serial, path };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
48
|
+
constructor(settings, props) {
|
|
49
|
+
const logger = new gd_eventlog_1.EventLogger('DaumPremium');
|
|
50
|
+
const commProps = Object.assign(Object.assign({}, getBikeProps(settings)), { logger });
|
|
51
|
+
const bike = new comms_1.default(commProps);
|
|
52
|
+
super(settings, props);
|
|
53
|
+
this._startRetryTimeout = START_RETRY_TIMEOUT;
|
|
23
54
|
this.bike = bike;
|
|
24
|
-
this.logger =
|
|
55
|
+
this.logger = logger;
|
|
25
56
|
this.ignoreHrm = false;
|
|
26
57
|
this.ignorePower = false;
|
|
27
58
|
this.ignoreBike = false;
|
|
28
|
-
this.paused = undefined;
|
|
29
59
|
this.iv = undefined;
|
|
30
60
|
this.distanceInternal = undefined;
|
|
31
61
|
this.initData();
|
|
@@ -33,34 +63,62 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
33
63
|
getName() {
|
|
34
64
|
return 'Daum8i';
|
|
35
65
|
}
|
|
66
|
+
getUniqueName() {
|
|
67
|
+
if (this.getInterface() === 'tcpip') {
|
|
68
|
+
const port = this.getPort();
|
|
69
|
+
const [host] = port.split(':');
|
|
70
|
+
return `${this.getName()} (${host})`;
|
|
71
|
+
}
|
|
72
|
+
return super.getUniqueName();
|
|
73
|
+
}
|
|
36
74
|
getPort() {
|
|
37
75
|
return this.bike.getPort();
|
|
38
76
|
}
|
|
39
77
|
getInterface() {
|
|
40
|
-
|
|
78
|
+
var _a;
|
|
79
|
+
return (_a = this.bike) === null || _a === void 0 ? void 0 : _a.getInterface();
|
|
80
|
+
}
|
|
81
|
+
getProtocolName() {
|
|
82
|
+
return PROTOCOL_NAME;
|
|
83
|
+
}
|
|
84
|
+
isEqual(settings) {
|
|
85
|
+
if (this.getInterface() === device_1.INTERFACE.TCPIP) {
|
|
86
|
+
const equal = super.isEqual(settings);
|
|
87
|
+
if (!equal)
|
|
88
|
+
return false;
|
|
89
|
+
const as = this.settings;
|
|
90
|
+
return (settings.host === as.host);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return super.isEqual(settings);
|
|
94
|
+
}
|
|
41
95
|
}
|
|
42
96
|
getSupportedCyclingModes() {
|
|
43
97
|
const supported = super.getSupportedCyclingModes();
|
|
44
|
-
supported.push(
|
|
98
|
+
supported.push(daum_classic_1.default);
|
|
45
99
|
return supported;
|
|
46
100
|
}
|
|
47
101
|
check() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
var info = {};
|
|
104
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
this.logger.logEvent({ message: "checking device", port: this.getPort() });
|
|
106
|
+
try {
|
|
107
|
+
const connected = yield this.connect();
|
|
108
|
+
if (!connected)
|
|
109
|
+
resolve(false);
|
|
110
|
+
info.deviceType = yield this.bike.getDeviceType();
|
|
111
|
+
info.version = yield this.bike.getProtocolVersion();
|
|
112
|
+
yield this.bike.close();
|
|
113
|
+
this.logger.logEvent({ message: "checking device success", port: this.getPort(), info });
|
|
114
|
+
resolve(true);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
this.logger.logEvent({ message: "checking device failed", port: this.getPort(), reason: err.message || err });
|
|
118
|
+
resolve(false);
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
});
|
|
64
122
|
}
|
|
65
123
|
pause() {
|
|
66
124
|
const _super = Object.create(null, {
|
|
@@ -82,7 +140,7 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
82
140
|
return resumed;
|
|
83
141
|
});
|
|
84
142
|
}
|
|
85
|
-
startRide(props) {
|
|
143
|
+
startRide(props = {}) {
|
|
86
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
145
|
this.logger.logEvent({ message: 'relaunch of device' });
|
|
88
146
|
try {
|
|
@@ -95,7 +153,7 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
95
153
|
}
|
|
96
154
|
});
|
|
97
155
|
}
|
|
98
|
-
start(props) {
|
|
156
|
+
start(props = {}) {
|
|
99
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
158
|
this.logger.logEvent({ message: 'initial start of device' });
|
|
101
159
|
try {
|
|
@@ -108,15 +166,11 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
108
166
|
}
|
|
109
167
|
});
|
|
110
168
|
}
|
|
111
|
-
launch(props, isRelaunch = false) {
|
|
169
|
+
launch(props = {}, isRelaunch = false) {
|
|
112
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (opts.bikeSettings && opts.bikeSettings.weight)
|
|
117
|
-
this.bikeSettings.weight = opts.bikeSettings.weight;
|
|
118
|
-
const user = opts.user || this.userSettings;
|
|
119
|
-
const route = opts.route;
|
|
171
|
+
this.setBikeProps(props);
|
|
172
|
+
const user = this.user;
|
|
173
|
+
const { route, onStatusUpdate, gear } = props;
|
|
120
174
|
var info = {};
|
|
121
175
|
this.initData();
|
|
122
176
|
if (isRelaunch) {
|
|
@@ -124,38 +178,42 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
124
178
|
}
|
|
125
179
|
return (0, utils_1.runWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
126
180
|
try {
|
|
127
|
-
|
|
128
|
-
yield this.bike.saveConnect();
|
|
129
|
-
}
|
|
181
|
+
yield this.connect();
|
|
130
182
|
if (!info.deviceType) {
|
|
131
183
|
info.deviceType = yield this.bike.getDeviceType();
|
|
132
184
|
}
|
|
133
185
|
if (!info.version) {
|
|
134
186
|
info.version = yield this.bike.getProtocolVersion();
|
|
135
187
|
}
|
|
188
|
+
console.log('~~~~ starting Daum8i', this.getCyclingMode().getName(), this.getCyclingMode().getModeProperty('eppSupport'));
|
|
136
189
|
if (this.getCyclingMode().getModeProperty('eppSupport')) {
|
|
137
190
|
const bikeType = this.getCyclingMode().getSetting('bikeType');
|
|
138
|
-
if (!info.upload)
|
|
139
|
-
info.upload = yield this.bike.programUpload(bikeType, route,
|
|
191
|
+
if (!info.upload) {
|
|
192
|
+
info.upload = yield this.bike.programUpload(bikeType, route, onStatusUpdate);
|
|
193
|
+
if (!info.upload)
|
|
194
|
+
throw new Error('Epp Upload failed');
|
|
195
|
+
}
|
|
140
196
|
if (!info.started) {
|
|
141
197
|
const programId = route ? route.programId : 0;
|
|
142
198
|
info.started = yield this.bike.startProgram(programId);
|
|
199
|
+
if (!info.started) {
|
|
200
|
+
throw new Error('Epp start failed');
|
|
201
|
+
}
|
|
143
202
|
}
|
|
144
203
|
}
|
|
145
204
|
if (!info.person && this.getCyclingMode().getModeProperty('setPersonSupport')) {
|
|
146
205
|
info.person = yield this.bike.setPerson(user);
|
|
147
206
|
}
|
|
148
207
|
if (!this.getCyclingMode().getModeProperty('eppSupport')) {
|
|
149
|
-
|
|
150
|
-
return gear;
|
|
208
|
+
info.gear = yield this.bike.setGear(this.cyclingData.gear || gear || DEFAULT_GEAR);
|
|
151
209
|
}
|
|
152
210
|
return;
|
|
153
211
|
}
|
|
154
212
|
catch (err) {
|
|
155
213
|
throw (new Error(`could not start device, reason:${err.message}`));
|
|
156
214
|
}
|
|
157
|
-
}), 5,
|
|
158
|
-
.then(
|
|
215
|
+
}), 5, this._startRetryTimeout)
|
|
216
|
+
.then(() => {
|
|
159
217
|
this.stopped = false;
|
|
160
218
|
this.paused = false;
|
|
161
219
|
this.startUpdatePull();
|
|
@@ -166,11 +224,13 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
166
224
|
getCurrentBikeData() {
|
|
167
225
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
226
|
if (!this.bike.isConnected()) {
|
|
169
|
-
yield this.bike.
|
|
227
|
+
const connected = yield this.bike.connect();
|
|
228
|
+
if (!connected)
|
|
229
|
+
return;
|
|
170
230
|
}
|
|
171
231
|
return this.getBike().getTrainingData();
|
|
172
232
|
});
|
|
173
233
|
}
|
|
174
234
|
}
|
|
175
|
-
exports.default =
|
|
176
|
-
|
|
235
|
+
exports.default = DaumPremiumAdapter;
|
|
236
|
+
DaumPremiumAdapter.NAME = PROTOCOL_NAME;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ReservedCommands } from './utils';
|
|
3
|
-
import {
|
|
3
|
+
import { SerialInterface, SerialPortProvider } from '../..';
|
|
4
|
+
import { Queue } from '../../../utils/utils';
|
|
4
5
|
import { EventLogger } from 'gd-eventlog';
|
|
5
|
-
import { User } from "
|
|
6
|
-
import { Route } from "
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { User } from "../../../types/user";
|
|
7
|
+
import { Route } from "../../../types/route";
|
|
8
|
+
import { SerialCommProps } from "../../comm";
|
|
9
|
+
import { SerialPortStream } from "@serialport/stream";
|
|
10
|
+
import { OnDeviceStartCallback } from "./types";
|
|
11
|
+
export default class Daum8i {
|
|
10
12
|
logger: EventLogger;
|
|
11
|
-
serial:
|
|
12
|
-
|
|
13
|
+
serial: SerialInterface;
|
|
14
|
+
path: string;
|
|
13
15
|
tcpipConnection: {
|
|
14
16
|
host: string;
|
|
15
17
|
port: string;
|
|
16
18
|
};
|
|
17
19
|
port: string;
|
|
18
20
|
settings: any;
|
|
19
|
-
|
|
20
|
-
sp: any;
|
|
21
|
+
sp: SerialPortStream;
|
|
21
22
|
props: any;
|
|
22
23
|
connected: boolean;
|
|
23
24
|
blocked: boolean;
|
|
@@ -29,26 +30,18 @@ declare class Daum8i {
|
|
|
29
30
|
cmdCurrent: any;
|
|
30
31
|
cmdStart: number;
|
|
31
32
|
isLoggingPaused: boolean;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
static setNetImpl(netClass: any): void;
|
|
37
|
-
static getSupportedInterfaces(): string[];
|
|
33
|
+
spp: SerialPortProvider;
|
|
34
|
+
serialportProps: any;
|
|
35
|
+
constructor(props: SerialCommProps);
|
|
36
|
+
getInterface(): string;
|
|
38
37
|
getPort(): string;
|
|
39
38
|
isConnected(): boolean;
|
|
40
39
|
pauseLogging(): void;
|
|
41
|
-
|
|
40
|
+
resumeLogging(): void;
|
|
42
41
|
logEvent(e: any): void;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
unblock(): void;
|
|
47
|
-
connect(): Promise<void>;
|
|
48
|
-
reconnect(): Promise<void>;
|
|
49
|
-
saveConnect(): Promise<unknown>;
|
|
50
|
-
onPortOpen(): void;
|
|
51
|
-
onPortClose(): void;
|
|
42
|
+
connect(): Promise<boolean>;
|
|
43
|
+
close(): Promise<boolean>;
|
|
44
|
+
flush(): Promise<void>;
|
|
52
45
|
getLogState(): {
|
|
53
46
|
sending: any;
|
|
54
47
|
busy: any;
|
|
@@ -60,24 +53,21 @@ declare class Daum8i {
|
|
|
60
53
|
waitingForAck: any;
|
|
61
54
|
retry: any;
|
|
62
55
|
};
|
|
56
|
+
onPortClose(): Promise<void>;
|
|
63
57
|
onPortError(error: any): Promise<void>;
|
|
64
|
-
errorHandler(): void;
|
|
65
|
-
saveClose(force?: any): Promise<void>;
|
|
66
58
|
forceClose(updateState?: boolean): Promise<void>;
|
|
67
|
-
closePort(timeout: any): Promise<boolean>;
|
|
68
|
-
close(): Promise<void>;
|
|
69
59
|
sendTimeout(message: any): void;
|
|
70
60
|
checkForResponse(): boolean;
|
|
71
61
|
getTimeoutValue(cmd?: any): number;
|
|
72
62
|
onData(data: any, depth?: number): any;
|
|
73
|
-
sendDaum8iCommand(command:
|
|
63
|
+
sendDaum8iCommand(command: string, payload?: string | any[]): Promise<string>;
|
|
74
64
|
writeDone(): void;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
write(buffer: Buffer): Promise<void>;
|
|
66
|
+
sendACK(): Promise<void>;
|
|
67
|
+
sendNAK(): Promise<void>;
|
|
68
|
+
sendReservedDaum8iCommand(command: ReservedCommands, data?: Buffer): Promise<any[]>;
|
|
79
69
|
getProtocolVersion(): Promise<string>;
|
|
80
|
-
getDashboardVersion(): Promise<
|
|
70
|
+
getDashboardVersion(): Promise<string>;
|
|
81
71
|
getDeviceType(): Promise<any>;
|
|
82
72
|
getActualBikeType(): Promise<any>;
|
|
83
73
|
setActualBikeType(actualBikeType: any): Promise<any>;
|
|
@@ -98,7 +88,6 @@ declare class Daum8i {
|
|
|
98
88
|
}>;
|
|
99
89
|
setLoadControl(enabled: any): Promise<boolean>;
|
|
100
90
|
getLoadControl(): Promise<boolean>;
|
|
101
|
-
setSlope(slope: any): void;
|
|
102
91
|
setPower(power: any): Promise<number>;
|
|
103
92
|
getPower(power: any): Promise<number>;
|
|
104
93
|
setPerson(person: User): Promise<boolean>;
|
|
@@ -111,20 +100,3 @@ declare class Daum8i {
|
|
|
111
100
|
setGear(gear: any): Promise<number>;
|
|
112
101
|
getGear(): Promise<number>;
|
|
113
102
|
}
|
|
114
|
-
export declare class Daum8iTcp extends Daum8i {
|
|
115
|
-
static getClassName(): string;
|
|
116
|
-
getType(): string;
|
|
117
|
-
static setSerialPort(spClass: any): void;
|
|
118
|
-
getInterface(): string;
|
|
119
|
-
static setNetImpl(netClass: any): void;
|
|
120
|
-
static getSupportedInterfaces(): string[];
|
|
121
|
-
}
|
|
122
|
-
export declare class Daum8iSerial extends Daum8i {
|
|
123
|
-
static getClassName(): string;
|
|
124
|
-
getType(): string;
|
|
125
|
-
getInterface(): string;
|
|
126
|
-
static setSerialPort(spClass: any): void;
|
|
127
|
-
static setNetImpl(netClass: any): void;
|
|
128
|
-
static getSupportedInterfaces(): string[];
|
|
129
|
-
}
|
|
130
|
-
export {};
|