incyclist-devices 1.5.38 → 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} +208 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +290 -0
- package/lib/{daum/premium/DaumClassicCyclingMode.d.ts → serial/daum/premium/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/premium/DaumClassicCyclingMode.js → serial/daum/premium/modes/daum-classic.js} +2 -2
- package/lib/serial/daum/premium/types.d.ts +12 -0
- package/lib/serial/daum/premium/types.js +2 -0
- package/lib/{daum → serial/daum}/premium/utils.d.ts +8 -11
- package/lib/{daum → serial/daum}/premium/utils.js +22 -63
- package/lib/serial/index.d.ts +9 -0
- package/lib/serial/index.js +49 -0
- package/lib/{kettler → serial/kettler}/comms.d.ts +8 -6
- package/lib/{kettler → serial/kettler}/comms.js +71 -32
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.d.ts +13 -24
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +87 -130
- package/lib/serial/kettler/ergo-racer/mock.d.ts +66 -0
- package/lib/serial/kettler/ergo-racer/mock.js +216 -0
- package/lib/{kettler/ergo-racer/ERGCyclingMode.d.ts → serial/kettler/ergo-racer/modes/erg.d.ts} +4 -4
- package/lib/{kettler/ergo-racer/ERGCyclingMode.js → serial/kettler/ergo-racer/modes/erg.js} +2 -2
- package/lib/serial/serial-interface.d.ts +58 -0
- package/lib/serial/serial-interface.js +283 -0
- package/lib/simulator/Simulator.d.ts +10 -25
- package/lib/simulator/Simulator.js +19 -83
- package/lib/types/adapter.d.ts +32 -0
- package/lib/types/adapter.js +2 -0
- package/lib/types/capabilities.d.ts +8 -0
- package/lib/types/capabilities.js +12 -0
- package/lib/types/data.d.ts +12 -0
- package/lib/types/data.js +2 -0
- package/lib/types/device.d.ts +29 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +14 -0
- package/lib/types/interface.js +2 -0
- package/lib/types/route.d.ts +2 -2
- package/lib/types/user.d.ts +1 -1
- package/lib/{utils.d.ts → utils/utils.d.ts} +1 -0
- package/lib/{utils.js → utils/utils.js} +5 -1
- package/package.json +15 -11
- package/lib/DeviceSupport.d.ts +0 -36
- package/lib/DeviceSupport.js +0 -82
- package/lib/ant/AntAdapter.d.ts +0 -50
- package/lib/ant/AntAdapter.js +0 -109
- package/lib/ant/AntScanner.d.ts +0 -60
- package/lib/ant/AntScanner.js +0 -651
- package/lib/ant/antfe/AntFEAdapter.d.ts +0 -83
- package/lib/ant/antfe/AntFEAdapter.js +0 -652
- package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/ant/antfe/ant-fe-erg-mode.d.ts +0 -6
- package/lib/ant/antfe/ant-fe-st-mode.d.ts +0 -5
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +0 -16
- package/lib/ant/anthrm/AntHrmAdapter.js +0 -130
- package/lib/ant/antpwr/pwr-adapter.d.ts +0 -49
- package/lib/ant/antpwr/pwr-adapter.js +0 -251
- package/lib/ant/utils.d.ts +0 -1
- package/lib/ant/utils.js +0 -23
- package/lib/antv2/AntAdapter.d.ts +0 -48
- package/lib/antv2/AntAdapter.js +0 -104
- package/lib/antv2/ant-device.d.ts +0 -59
- package/lib/antv2/ant-device.js +0 -161
- package/lib/antv2/fe.d.ts +0 -32
- package/lib/antv2/hr.d.ts +0 -18
- package/lib/antv2/hr.js +0 -102
- package/lib/antv2/incyclist-protocol.d.ts +0 -37
- package/lib/antv2/incyclist-protocol.js +0 -126
- package/lib/antv2/pwr.d.ts +0 -28
- package/lib/ble/elite.d.ts +0 -90
- package/lib/ble/elite.js +0 -322
- package/lib/ble/fm.d.ts +0 -125
- package/lib/ble/hrm.d.ts +0 -48
- package/lib/ble/hrm.js +0 -134
- package/lib/ble/incyclist-protocol.d.ts +0 -31
- package/lib/ble/incyclist-protocol.js +0 -153
- package/lib/ble/pwr.d.ts +0 -89
- package/lib/ble/pwr.js +0 -322
- package/lib/daum/classic/DaumClassicAdapter.d.ts +0 -28
- package/lib/daum/classic/DaumClassicProtocol.d.ts +0 -27
- package/lib/daum/classic/DaumClassicProtocol.js +0 -185
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +0 -16
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +0 -32
- package/lib/daum/premium/DaumPremiumProtocol.js +0 -207
- package/lib/daum/premium/tcpserial.d.ts +0 -33
- package/lib/daum/premium/tcpserial.js +0 -123
- package/lib/kettler/ergo-racer/protocol.d.ts +0 -41
- package/lib/kettler/ergo-racer/protocol.js +0 -203
- package/lib/protocol.d.ts +0 -74
- package/lib/protocol.js +0 -41
- package/lib/registry.d.ts +0 -8
- package/lib/registry.js +0 -33
- package/lib/serialport/bindings/tcp.d.ts +0 -20
- package/lib/serialport/bindings/tcp.js +0 -33
- package/lib/serialport/index.d.ts +0 -2
- package/lib/serialport/index.js +0 -29
- package/lib/serialport/serialport.d.ts +0 -29
- package/lib/serialport/serialport.js +0 -87
- /package/lib/antv2/{ant-binding.d.ts → binding.d.ts} +0 -0
- /package/lib/antv2/{ant-binding.js → binding.js} +0 -0
- /package/lib/{cycling-mode.js → modes/cycling-mode.js} +0 -0
- /package/lib/{daum → serial/daum}/classic/utils.js +0 -0
- /package/lib/{daum → serial/daum}/constants.d.ts +0 -0
- /package/lib/{daum → serial/daum}/constants.js +0 -0
- /package/lib/{serialport.d.ts → serial/serialport.d.ts} +0 -0
- /package/lib/{serialport.js → serial/serialport.js} +0 -0
- /package/lib/{calculations.d.ts → utils/calculations.d.ts} +0 -0
- /package/lib/{calculations.js → utils/calculations.js} +0 -0
|
@@ -0,0 +1,365 @@
|
|
|
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
|
+
exports.DaumClassicMockBinding = exports.DaumClassicSimulator = exports.DaumClassicMockImpl = exports.DaumClassicMock = void 0;
|
|
16
|
+
const binding_mock_1 = require("@serialport/binding-mock");
|
|
17
|
+
const __1 = require("../../");
|
|
18
|
+
const utils_1 = require("../../../utils/utils");
|
|
19
|
+
const calculations_1 = __importDefault(require("../../../utils/calculations"));
|
|
20
|
+
exports.DaumClassicMock = {
|
|
21
|
+
reset() {
|
|
22
|
+
DaumClassicMockImpl.getInstance().reset();
|
|
23
|
+
},
|
|
24
|
+
createPort(path, options = {}) {
|
|
25
|
+
return DaumClassicMockImpl.getInstance().createPort(path, options);
|
|
26
|
+
},
|
|
27
|
+
list() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return DaumClassicMockImpl.getInstance().list();
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
open(options) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return DaumClassicMockImpl.getInstance().open(options);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
class DaumClassicMockImpl {
|
|
39
|
+
static getInstance() {
|
|
40
|
+
if (!DaumClassicMockImpl._instance)
|
|
41
|
+
DaumClassicMockImpl._instance = new DaumClassicMockImpl();
|
|
42
|
+
return DaumClassicMockImpl._instance;
|
|
43
|
+
}
|
|
44
|
+
static reset() {
|
|
45
|
+
DaumClassicMockImpl._instance = undefined;
|
|
46
|
+
__1.SerialPortProvider._instance = undefined;
|
|
47
|
+
__1.SerialInterface._instances = [];
|
|
48
|
+
}
|
|
49
|
+
constructor() {
|
|
50
|
+
this.simulators = new Map();
|
|
51
|
+
this.ports = [];
|
|
52
|
+
}
|
|
53
|
+
setSimulator(path, simulator) {
|
|
54
|
+
this.simulators.set(path, simulator);
|
|
55
|
+
}
|
|
56
|
+
getSimulator(path) {
|
|
57
|
+
return this.simulators.get(path);
|
|
58
|
+
}
|
|
59
|
+
reset() {
|
|
60
|
+
binding_mock_1.MockBinding.reset();
|
|
61
|
+
}
|
|
62
|
+
createPort(path, options = {}) {
|
|
63
|
+
return binding_mock_1.MockBinding.createPort(path, options);
|
|
64
|
+
}
|
|
65
|
+
list() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
return binding_mock_1.MockBinding.list();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
open(options) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const port = yield binding_mock_1.MockBinding.open(options);
|
|
73
|
+
return new DaumClassicMockBinding(port);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.DaumClassicMockImpl = DaumClassicMockImpl;
|
|
78
|
+
const DEFAULT_BIKE_DATA = {
|
|
79
|
+
cockpitVersion: 3,
|
|
80
|
+
isPedalling: false,
|
|
81
|
+
bikeType: 0,
|
|
82
|
+
person: { weight: 75, length: 180, age: 30, sex: 0 }
|
|
83
|
+
};
|
|
84
|
+
class DaumClassicSimulator {
|
|
85
|
+
constructor() {
|
|
86
|
+
this.selectedBike = 0;
|
|
87
|
+
this.bikes = [];
|
|
88
|
+
this._timeoutResponse = 0;
|
|
89
|
+
this._simulateNoReponseCnt = 0;
|
|
90
|
+
this._simulateIllegalResponseCnt = 0;
|
|
91
|
+
for (let i = 0; i < 10; i++)
|
|
92
|
+
this.bikes.push(Object.assign({}, DEFAULT_BIKE_DATA));
|
|
93
|
+
this.reset();
|
|
94
|
+
}
|
|
95
|
+
reset() {
|
|
96
|
+
this.cadence = 0;
|
|
97
|
+
this.slope = 0;
|
|
98
|
+
this.gear = 1;
|
|
99
|
+
this.progNo = 0;
|
|
100
|
+
this.heartrate = 0;
|
|
101
|
+
this.distance = 0;
|
|
102
|
+
this.targetPower = 25;
|
|
103
|
+
this.currentPower = 25;
|
|
104
|
+
this.isPowerMode = false;
|
|
105
|
+
this._timeoutResponse = 0;
|
|
106
|
+
this._simulateNoReponseCnt = 0;
|
|
107
|
+
this._simulateIllegalResponseCnt = 0;
|
|
108
|
+
}
|
|
109
|
+
simulateTimeout(ms) {
|
|
110
|
+
this._timeoutResponse = ms;
|
|
111
|
+
}
|
|
112
|
+
simulateNoResponse(cnt = 1) {
|
|
113
|
+
this._simulateNoReponseCnt += cnt;
|
|
114
|
+
}
|
|
115
|
+
simulateIllegalResponse(cnt = 1) {
|
|
116
|
+
this._simulateIllegalResponseCnt += cnt;
|
|
117
|
+
}
|
|
118
|
+
isPedalling() {
|
|
119
|
+
if (this.cadence && this.cadence > 0)
|
|
120
|
+
return 1;
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.DaumClassicSimulator = DaumClassicSimulator;
|
|
125
|
+
class DaumClassicMockBinding extends binding_mock_1.MockPortBinding {
|
|
126
|
+
constructor(parent) {
|
|
127
|
+
super(parent.port, parent.openOptions);
|
|
128
|
+
this.prevCommand = null;
|
|
129
|
+
this.simulator = DaumClassicMockImpl.getInstance().getSimulator(this.getPath());
|
|
130
|
+
if (!this.simulator) {
|
|
131
|
+
this.simulator = new DaumClassicSimulator();
|
|
132
|
+
DaumClassicMockImpl.getInstance().setSimulator(this.getPath(), this.simulator);
|
|
133
|
+
}
|
|
134
|
+
this.initHandlers();
|
|
135
|
+
}
|
|
136
|
+
getPath() {
|
|
137
|
+
return this.port.info.path;
|
|
138
|
+
}
|
|
139
|
+
initHandlers() {
|
|
140
|
+
this.handlers = new Map();
|
|
141
|
+
this.handlers.set(0x10, this.onCheckCockpit.bind(this));
|
|
142
|
+
this.handlers.set(0x11, this.onGetAddress.bind(this));
|
|
143
|
+
this.handlers.set(0x73, this.onGetVersion.bind(this));
|
|
144
|
+
this.handlers.set(0x12, this.onResetDevice.bind(this));
|
|
145
|
+
this.handlers.set(0x21, this.onStartProg.bind(this));
|
|
146
|
+
this.handlers.set(0x22, this.onStopProg.bind(this));
|
|
147
|
+
this.handlers.set(0x23, this.onSetProg.bind(this));
|
|
148
|
+
this.handlers.set(0x69, this.onSetBikeType.bind(this));
|
|
149
|
+
this.handlers.set(0x24, this.onSetPerson.bind(this));
|
|
150
|
+
this.handlers.set(0x40, this.onRunData.bind(this));
|
|
151
|
+
this.handlers.set(0x53, this.onSetGear.bind(this));
|
|
152
|
+
this.handlers.set(0x51, this.onSetPower.bind(this));
|
|
153
|
+
this.handlers.set(0x55, this.onSetSlope.bind(this));
|
|
154
|
+
}
|
|
155
|
+
write(buffer) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
158
|
+
throw new TypeError('"buffer" is not a Buffer');
|
|
159
|
+
}
|
|
160
|
+
if (!this.isOpen || !this.port) {
|
|
161
|
+
throw new Error('Port is not open');
|
|
162
|
+
}
|
|
163
|
+
if (this.writeOperation) {
|
|
164
|
+
throw new Error('Overlapping writes are not supported and should be queued by the serialport object');
|
|
165
|
+
}
|
|
166
|
+
if (buffer.length == 0)
|
|
167
|
+
return;
|
|
168
|
+
this.writeOperation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
yield (0, utils_1.resolveNextTick)();
|
|
170
|
+
if (!this.isOpen || !this.port) {
|
|
171
|
+
throw new Error('Write canceled');
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const cmd = buffer.readUInt8(0);
|
|
175
|
+
const handler = this.handlers.get(cmd);
|
|
176
|
+
const payload = buffer.subarray(1);
|
|
177
|
+
if (this.simulator._simulateNoReponseCnt > 0) {
|
|
178
|
+
this.simulator._simulateNoReponseCnt--;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const to = this.simulator._timeoutResponse || 5;
|
|
182
|
+
if (handler)
|
|
183
|
+
setTimeout(() => { handler(payload); }, to);
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
}
|
|
187
|
+
this.writeOperation = null;
|
|
188
|
+
}))();
|
|
189
|
+
return this.writeOperation;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
emitData(data) {
|
|
193
|
+
if (!this.isOpen || !this.port)
|
|
194
|
+
return;
|
|
195
|
+
super.emitData(data);
|
|
196
|
+
}
|
|
197
|
+
onCheckCockpit(payload) {
|
|
198
|
+
const bikeNo = payload.readUInt8(0);
|
|
199
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
200
|
+
const response = Buffer.from([0x10, bikeNo, this.simulator.bikes[bikeNo].cockpitVersion]);
|
|
201
|
+
this.emitData(response);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
onGetAddress(_payload) {
|
|
205
|
+
const response = Buffer.from([0x11, this.simulator.selectedBike]);
|
|
206
|
+
this.emitData(response);
|
|
207
|
+
}
|
|
208
|
+
onGetVersion(payload) {
|
|
209
|
+
const bikeNo = payload.readUInt8(0);
|
|
210
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
211
|
+
const response = Buffer.from([0x73, bikeNo, this.simulator.bikes[bikeNo].cockpitVersion]);
|
|
212
|
+
this.emitData(response);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
onResetDevice(payload) {
|
|
216
|
+
const bikeNo = payload.readUInt8(0);
|
|
217
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
218
|
+
const response = Buffer.from([0x12, bikeNo]);
|
|
219
|
+
this.simulator.bikes[bikeNo] = DEFAULT_BIKE_DATA;
|
|
220
|
+
this.emitData(response);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
onStartProg(payload) {
|
|
224
|
+
const bikeNo = payload.readUInt8(0);
|
|
225
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
226
|
+
const isPedalling = this.simulator.isPedalling();
|
|
227
|
+
const response = Buffer.from([0x21, bikeNo, isPedalling ? 1 : 0]);
|
|
228
|
+
this.emitData(response);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
onStopProg(payload) {
|
|
232
|
+
const bikeNo = payload.readUInt8(0);
|
|
233
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
234
|
+
const isPedalling = this.simulator.isPedalling();
|
|
235
|
+
const response = Buffer.from([0x22, bikeNo, isPedalling]);
|
|
236
|
+
this.emitData(response);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
onSetProg(payload) {
|
|
240
|
+
const bikeNo = payload.readUInt8(0);
|
|
241
|
+
const progNo = payload.readUInt8(1);
|
|
242
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
243
|
+
const isPedalling = this.simulator.isPedalling();
|
|
244
|
+
this.simulator.progNo = progNo;
|
|
245
|
+
const response = Buffer.from([0x23, bikeNo, progNo, isPedalling]);
|
|
246
|
+
this.emitData(response);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
onSetBikeType(payload) {
|
|
250
|
+
const bikeNo = payload.readUInt8(0);
|
|
251
|
+
const bikeType = payload.readUInt8(3);
|
|
252
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
253
|
+
const { isPedalling } = this.simulator.bikes[bikeNo];
|
|
254
|
+
this.simulator.bikes[bikeNo].bikeType = bikeType;
|
|
255
|
+
const response = Buffer.from([0x69, bikeNo, bikeType]);
|
|
256
|
+
this.emitData(response);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
onSetPerson(payload) {
|
|
260
|
+
const bikeNo = payload.readUInt8(0);
|
|
261
|
+
const personNo = payload.readUInt8(1);
|
|
262
|
+
const age = payload.readUInt8(2);
|
|
263
|
+
const sex = payload.readUInt8(3);
|
|
264
|
+
const length = payload.readUint8(4);
|
|
265
|
+
const weight = payload.readUint8(5);
|
|
266
|
+
const pctFat = payload.readUint8(6);
|
|
267
|
+
const coachingLevel = payload.readUint8(7);
|
|
268
|
+
const coachingFrequency = payload.readUint8(8);
|
|
269
|
+
const powerLimit = payload.readUint8(9);
|
|
270
|
+
const hrLimit = payload.readUint8(10);
|
|
271
|
+
const timeLimit = payload.readUint8(11);
|
|
272
|
+
const distLimit = payload.readUint8(12);
|
|
273
|
+
const kcalLimit = payload.readUint8(13);
|
|
274
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
275
|
+
this.simulator.bikes[bikeNo].person = {
|
|
276
|
+
personNo, age, sex, length, weight, pctFat,
|
|
277
|
+
coachingLevel, coachingFrequency, powerLimit,
|
|
278
|
+
hrLimit, timeLimit, distLimit, kcalLimit
|
|
279
|
+
};
|
|
280
|
+
const isPedalling = this.simulator.isPedalling();
|
|
281
|
+
let response;
|
|
282
|
+
if (this.simulator._simulateIllegalResponseCnt > 0) {
|
|
283
|
+
response = Buffer.from([0x24, bikeNo, personNo, age, sex,
|
|
284
|
+
length, weight, pctFat, coachingLevel, coachingFrequency,
|
|
285
|
+
powerLimit + 10, hrLimit, timeLimit, distLimit, kcalLimit,
|
|
286
|
+
isPedalling]);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
response = Buffer.from([0x24, bikeNo, personNo, age, sex,
|
|
290
|
+
length, weight, pctFat, coachingLevel, coachingFrequency,
|
|
291
|
+
powerLimit, hrLimit, timeLimit, distLimit, kcalLimit,
|
|
292
|
+
isPedalling]);
|
|
293
|
+
}
|
|
294
|
+
this.emitData(response);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
onRunData(payload) {
|
|
298
|
+
const { cadence, gear, slope, heartrate, distance, progNo, isPowerMode, currentPower } = this.simulator;
|
|
299
|
+
const bike = this.simulator.bikes[this.simulator.selectedBike];
|
|
300
|
+
const { person, bikeType } = bike;
|
|
301
|
+
const { personNo, weight } = person;
|
|
302
|
+
const bikeNo = payload.readUInt8(0);
|
|
303
|
+
const isPedalling = this.simulator.isPedalling() + 128;
|
|
304
|
+
let speed, power;
|
|
305
|
+
speed = calculations_1.default.calculateSpeedDaum(gear, cadence, bikeType);
|
|
306
|
+
if (isPowerMode) {
|
|
307
|
+
power = currentPower;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
power = calculations_1.default.calculatePower(weight + 10, speed / 3.6, slope, { bikeType });
|
|
311
|
+
}
|
|
312
|
+
if (power < 25)
|
|
313
|
+
power = 25;
|
|
314
|
+
if (cadence === 0)
|
|
315
|
+
power = 0;
|
|
316
|
+
power = Math.round(power / 5);
|
|
317
|
+
const dist1 = distance / 1000 - Math.floor(distance / 1000 / 256);
|
|
318
|
+
const dist2 = Math.floor(distance / 1000 / 256);
|
|
319
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
320
|
+
const response = Buffer.from([0x40, bikeNo, progNo, personNo,
|
|
321
|
+
isPedalling, power, cadence, Math.floor(speed),
|
|
322
|
+
dist1, dist2, 0, 0, 0, 0, heartrate, 0, gear, 0, 0
|
|
323
|
+
]);
|
|
324
|
+
this.emitData(response);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
onSetGear(payload) {
|
|
328
|
+
const bikeNo = payload.readUInt8(0);
|
|
329
|
+
const gear = payload.readUInt8(1);
|
|
330
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
331
|
+
this.simulator.gear = gear;
|
|
332
|
+
const response = Buffer.from([0x53, bikeNo, gear]);
|
|
333
|
+
this.emitData(response);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
onSetPower(payload) {
|
|
337
|
+
const bikeNo = payload.readUInt8(0);
|
|
338
|
+
const power = payload.readUInt8(1);
|
|
339
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
340
|
+
this.simulator.targetPower = power;
|
|
341
|
+
this.simulator.isPowerMode = true;
|
|
342
|
+
setTimeout(() => { this.simulator.currentPower = power; }, 1000);
|
|
343
|
+
const response = Buffer.from([0x51, bikeNo, power]);
|
|
344
|
+
this.emitData(response);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
onSetSlope(payload) {
|
|
348
|
+
const bike = this.simulator.bikes[this.simulator.selectedBike];
|
|
349
|
+
const { person } = bike;
|
|
350
|
+
const { personNo } = person;
|
|
351
|
+
const { currentPower, cadence } = this.simulator;
|
|
352
|
+
const bikeNo = payload.readUInt8(0);
|
|
353
|
+
const slope = payload.readFloatLE(1);
|
|
354
|
+
const retVal0 = payload.readUInt8(1);
|
|
355
|
+
const isPedalling = this.simulator.isPedalling() + 128;
|
|
356
|
+
const power = cadence > 0 ? Math.floor(currentPower / 5) : 0;
|
|
357
|
+
if (bikeNo >= 0 && bikeNo < 10) {
|
|
358
|
+
this.simulator.slope = slope;
|
|
359
|
+
this.simulator.isPowerMode = false;
|
|
360
|
+
const response = Buffer.from([0x55, bikeNo, retVal0, personNo, isPedalling, power]);
|
|
361
|
+
this.emitData(response);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
exports.DaumClassicMockBinding = DaumClassicMockBinding;
|
package/lib/{daum/classic/DaumClassicCyclingMode.d.ts → serial/daum/classic/modes/daum-classic.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from "
|
|
2
|
-
import SmartTrainerCyclingMode from "
|
|
3
|
-
import DaumAdapter from "
|
|
1
|
+
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from "../../../../modes/cycling-mode";
|
|
2
|
+
import SmartTrainerCyclingMode from "../../SmartTrainerCyclingMode";
|
|
3
|
+
import DaumAdapter from "../../DaumAdapter";
|
|
4
4
|
export default class DaumClassicCyclingMode extends SmartTrainerCyclingMode implements CyclingMode {
|
|
5
5
|
constructor(adapter: DaumAdapter, props?: Settings);
|
|
6
6
|
getName(): string;
|
package/lib/{daum/classic/DaumClassicCyclingMode.js → serial/daum/classic/modes/daum-classic.js}
RENAMED
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
7
|
-
const cycling_mode_1 = require("
|
|
8
|
-
const SmartTrainerCyclingMode_1 = __importDefault(require("
|
|
7
|
+
const cycling_mode_1 = require("../../../../modes/cycling-mode");
|
|
8
|
+
const SmartTrainerCyclingMode_1 = __importDefault(require("../../SmartTrainerCyclingMode"));
|
|
9
9
|
const config = {
|
|
10
10
|
name: "Daum Classic",
|
|
11
11
|
description: "The device calculates speed and power based on slope. Incyclist will not modify any values recived from the device\nThis mode will not respect maximum power and/or workout limits",
|
|
@@ -2,7 +2,7 @@ export declare const DEFAULT_AGE = 30;
|
|
|
2
2
|
export declare const DEFAULT_USER_WEIGHT = 75;
|
|
3
3
|
export declare const DEFAULT_BIKE_WEIGHT = 10;
|
|
4
4
|
export declare function getCockpit(c: any): "Cardio" | "Fitness" | "Vita De Luxe" | "8008" | "8008 TRS" | "8080" | "Therapie" | "8008 TRS Pro" | "8008 TRS3" | "ergo_lyps Cardio Pro" | "Unknown";
|
|
5
|
-
export declare function getBikeType(type: any):
|
|
5
|
+
export declare function getBikeType(type: any): 0 | 1;
|
|
6
6
|
export declare function getGender(sex: any): 1 | 2;
|
|
7
7
|
export declare function getLength(length: any): number;
|
|
8
8
|
export declare function getWeight(weight?: any): number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DeviceProperties } from '../../../types/device';
|
|
2
|
+
import { SerialDeviceSettings } from '../../adapter';
|
|
3
|
+
import { SerialCommProps } from '../../comm';
|
|
4
|
+
import DaumAdapter from '../DaumAdapter';
|
|
5
|
+
import { Daum8iDeviceProperties } from './types';
|
|
6
|
+
export default class DaumPremiumAdapter extends DaumAdapter {
|
|
7
|
+
static NAME: string;
|
|
8
|
+
commProps: SerialCommProps;
|
|
9
|
+
_startRetryTimeout: number;
|
|
10
|
+
constructor(settings: SerialDeviceSettings, props?: DeviceProperties);
|
|
11
|
+
getName(): string;
|
|
12
|
+
getPort(): any;
|
|
13
|
+
getInterface(): string;
|
|
14
|
+
getProtocolName(): string;
|
|
15
|
+
isEqual(settings: SerialDeviceSettings): boolean;
|
|
16
|
+
getSupportedCyclingModes(): Array<any>;
|
|
17
|
+
check(): Promise<boolean>;
|
|
18
|
+
pause(): Promise<boolean>;
|
|
19
|
+
resume(): Promise<boolean>;
|
|
20
|
+
startRide(props?: Daum8iDeviceProperties): Promise<boolean>;
|
|
21
|
+
start(props?: Daum8iDeviceProperties): Promise<boolean>;
|
|
22
|
+
launch(props?: Daum8iDeviceProperties, isRelaunch?: boolean): Promise<boolean>;
|
|
23
|
+
getCurrentBikeData(): Promise<any>;
|
|
24
|
+
}
|
|
@@ -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();
|
|
@@ -37,30 +67,52 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
37
67
|
return this.bike.getPort();
|
|
38
68
|
}
|
|
39
69
|
getInterface() {
|
|
40
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
return (_a = this.bike) === null || _a === void 0 ? void 0 : _a.getInterface();
|
|
72
|
+
}
|
|
73
|
+
getProtocolName() {
|
|
74
|
+
return PROTOCOL_NAME;
|
|
75
|
+
}
|
|
76
|
+
isEqual(settings) {
|
|
77
|
+
if (this.getInterface() === device_1.INTERFACE.TCPIP) {
|
|
78
|
+
const equal = super.isEqual(settings);
|
|
79
|
+
if (!equal)
|
|
80
|
+
return false;
|
|
81
|
+
const as = this.settings;
|
|
82
|
+
return (settings.host === as.host);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return super.isEqual(settings);
|
|
86
|
+
}
|
|
41
87
|
}
|
|
42
88
|
getSupportedCyclingModes() {
|
|
43
89
|
const supported = super.getSupportedCyclingModes();
|
|
44
|
-
supported.push(
|
|
90
|
+
supported.push(daum_classic_1.default);
|
|
45
91
|
return supported;
|
|
46
92
|
}
|
|
47
93
|
check() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.logger.logEvent({ message: "check()", port: this.getPort() });
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
var info = {};
|
|
51
96
|
if (this.isStopped())
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
97
|
+
return false;
|
|
98
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
this.logger.logEvent({ message: "checking device", port: this.getPort() });
|
|
100
|
+
try {
|
|
101
|
+
const connected = yield this.connect();
|
|
102
|
+
if (!connected)
|
|
103
|
+
resolve(false);
|
|
104
|
+
info.deviceType = yield this.bike.getDeviceType();
|
|
105
|
+
info.version = yield this.bike.getProtocolVersion();
|
|
106
|
+
yield this.bike.close();
|
|
107
|
+
this.logger.logEvent({ message: "checking device success", port: this.getPort(), info });
|
|
108
|
+
resolve(true);
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
this.logger.logEvent({ message: "checking device failed", port: this.getPort(), reason: err.message || err });
|
|
112
|
+
resolve(false);
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
});
|
|
64
116
|
}
|
|
65
117
|
pause() {
|
|
66
118
|
const _super = Object.create(null, {
|
|
@@ -82,7 +134,7 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
82
134
|
return resumed;
|
|
83
135
|
});
|
|
84
136
|
}
|
|
85
|
-
startRide(props) {
|
|
137
|
+
startRide(props = {}) {
|
|
86
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
139
|
this.logger.logEvent({ message: 'relaunch of device' });
|
|
88
140
|
try {
|
|
@@ -95,7 +147,7 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
95
147
|
}
|
|
96
148
|
});
|
|
97
149
|
}
|
|
98
|
-
start(props) {
|
|
150
|
+
start(props = {}) {
|
|
99
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
152
|
this.logger.logEvent({ message: 'initial start of device' });
|
|
101
153
|
try {
|
|
@@ -108,15 +160,11 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
108
160
|
}
|
|
109
161
|
});
|
|
110
162
|
}
|
|
111
|
-
launch(props, isRelaunch = false) {
|
|
163
|
+
launch(props = {}, isRelaunch = false) {
|
|
112
164
|
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;
|
|
165
|
+
this.setBikeProps(props);
|
|
166
|
+
const user = this.user;
|
|
167
|
+
const { route, onStatusUpdate, gear } = props;
|
|
120
168
|
var info = {};
|
|
121
169
|
this.initData();
|
|
122
170
|
if (isRelaunch) {
|
|
@@ -124,9 +172,7 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
124
172
|
}
|
|
125
173
|
return (0, utils_1.runWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
126
174
|
try {
|
|
127
|
-
|
|
128
|
-
yield this.bike.saveConnect();
|
|
129
|
-
}
|
|
175
|
+
yield this.connect();
|
|
130
176
|
if (!info.deviceType) {
|
|
131
177
|
info.deviceType = yield this.bike.getDeviceType();
|
|
132
178
|
}
|
|
@@ -135,27 +181,32 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
135
181
|
}
|
|
136
182
|
if (this.getCyclingMode().getModeProperty('eppSupport')) {
|
|
137
183
|
const bikeType = this.getCyclingMode().getSetting('bikeType');
|
|
138
|
-
if (!info.upload)
|
|
139
|
-
info.upload = yield this.bike.programUpload(bikeType, route,
|
|
184
|
+
if (!info.upload) {
|
|
185
|
+
info.upload = yield this.bike.programUpload(bikeType, route, onStatusUpdate);
|
|
186
|
+
if (!info.upload)
|
|
187
|
+
throw new Error('Epp Upload failed');
|
|
188
|
+
}
|
|
140
189
|
if (!info.started) {
|
|
141
190
|
const programId = route ? route.programId : 0;
|
|
142
191
|
info.started = yield this.bike.startProgram(programId);
|
|
192
|
+
if (!info.started) {
|
|
193
|
+
throw new Error('Epp start failed');
|
|
194
|
+
}
|
|
143
195
|
}
|
|
144
196
|
}
|
|
145
197
|
if (!info.person && this.getCyclingMode().getModeProperty('setPersonSupport')) {
|
|
146
198
|
info.person = yield this.bike.setPerson(user);
|
|
147
199
|
}
|
|
148
200
|
if (!this.getCyclingMode().getModeProperty('eppSupport')) {
|
|
149
|
-
|
|
150
|
-
return gear;
|
|
201
|
+
info.gear = yield this.bike.setGear(this.cyclingData.gear || gear || DEFAULT_GEAR);
|
|
151
202
|
}
|
|
152
203
|
return;
|
|
153
204
|
}
|
|
154
205
|
catch (err) {
|
|
155
206
|
throw (new Error(`could not start device, reason:${err.message}`));
|
|
156
207
|
}
|
|
157
|
-
}), 5,
|
|
158
|
-
.then(
|
|
208
|
+
}), 5, this._startRetryTimeout)
|
|
209
|
+
.then(() => {
|
|
159
210
|
this.stopped = false;
|
|
160
211
|
this.paused = false;
|
|
161
212
|
this.startUpdatePull();
|
|
@@ -166,11 +217,13 @@ class DaumPremiumDevice extends DaumAdapter_1.default {
|
|
|
166
217
|
getCurrentBikeData() {
|
|
167
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
219
|
if (!this.bike.isConnected()) {
|
|
169
|
-
yield this.bike.
|
|
220
|
+
const connected = yield this.bike.connect();
|
|
221
|
+
if (!connected)
|
|
222
|
+
return;
|
|
170
223
|
}
|
|
171
224
|
return this.getBike().getTrainingData();
|
|
172
225
|
});
|
|
173
226
|
}
|
|
174
227
|
}
|
|
175
|
-
exports.default =
|
|
176
|
-
|
|
228
|
+
exports.default = DaumPremiumAdapter;
|
|
229
|
+
DaumPremiumAdapter.NAME = PROTOCOL_NAME;
|