incyclist-devices 2.4.6-beta.2 → 2.4.6
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/lib/antv2/base/adapter.js +3 -3
- package/lib/antv2/fe/adapter.js +1 -1
- package/lib/base/adpater.d.ts +2 -0
- package/lib/base/adpater.js +16 -5
- package/lib/ble/fm/adapter.d.ts +1 -0
- package/lib/ble/fm/adapter.js +20 -11
- package/lib/ble/fm/consts.d.ts +1 -0
- package/lib/ble/fm/consts.js +2 -1
- package/lib/ble/fm/sensor.d.ts +1 -0
- package/lib/ble/fm/sensor.js +7 -0
- package/lib/modes/antble-smarttrainer.d.ts +1 -0
- package/lib/modes/antble-smarttrainer.js +24 -13
- package/lib/modes/types.d.ts +3 -0
- package/lib/modes/types.js +1 -0
- package/lib/serial/daum/DaumAdapter.js +1 -1
- package/lib/serial/daum/classic/adapter.js +1 -2
- package/lib/serial/daum/premium/adapter.js +1 -2
- package/lib/types/adapter.d.ts +1 -0
- package/package.json +1 -1
|
@@ -208,9 +208,9 @@ class AntAdapter extends adpater_1.default {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
getID() {
|
|
211
|
-
var _a;
|
|
212
|
-
const id = this.deviceData.DeviceID
|
|
213
|
-
return id.toString();
|
|
211
|
+
var _a, _b, _c;
|
|
212
|
+
const id = (_b = (_a = this.deviceData) === null || _a === void 0 ? void 0 : _a.DeviceID) !== null && _b !== void 0 ? _b : (_c = this.sensor) === null || _c === void 0 ? void 0 : _c.getDeviceID();
|
|
213
|
+
return id === null || id === void 0 ? void 0 : id.toString();
|
|
214
214
|
}
|
|
215
215
|
getName() {
|
|
216
216
|
if (this.settings.name)
|
package/lib/antv2/fe/adapter.js
CHANGED
|
@@ -39,7 +39,7 @@ class AntFEAdapter extends adapter_1.default {
|
|
|
39
39
|
}
|
|
40
40
|
getDefaultCyclingMode() {
|
|
41
41
|
if (this.props.capabilities && this.props.capabilities.indexOf(types_1.IncyclistCapability.Control) === -1)
|
|
42
|
-
return
|
|
42
|
+
return this.createMode(power_meter_1.default);
|
|
43
43
|
return super.getDefaultCyclingMode();
|
|
44
44
|
}
|
|
45
45
|
sendUpdate(request) {
|
package/lib/base/adpater.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export default class IncyclistDevice<P extends DeviceProperties> extends EventEm
|
|
|
14
14
|
scanning: boolean;
|
|
15
15
|
protected props: P;
|
|
16
16
|
protected cyclingMode: ICyclingMode;
|
|
17
|
+
protected modes: Record<string, ICyclingMode>;
|
|
17
18
|
protected logger: EventLogger;
|
|
18
19
|
protected static controllers: ControllerConfig;
|
|
19
20
|
protected user: User;
|
|
@@ -49,6 +50,7 @@ export default class IncyclistDevice<P extends DeviceProperties> extends EventEm
|
|
|
49
50
|
setMaxUpdateFrequency(value: number): void;
|
|
50
51
|
update(): void;
|
|
51
52
|
setCyclingMode(mode: string | ICyclingMode, settings?: any, sendInitCommands?: boolean): void;
|
|
53
|
+
createMode(ModeClass: typeof CyclingMode): ICyclingMode;
|
|
52
54
|
protected createOrGetMode(mode: string | ICyclingMode): ICyclingMode;
|
|
53
55
|
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
54
56
|
getCyclingMode(): ICyclingMode;
|
package/lib/base/adpater.js
CHANGED
|
@@ -19,6 +19,7 @@ const utils_1 = require("../utils/utils");
|
|
|
19
19
|
class IncyclistDevice extends events_1.default {
|
|
20
20
|
constructor(settings, props) {
|
|
21
21
|
super();
|
|
22
|
+
this.modes = {};
|
|
22
23
|
this.onDataFn = undefined;
|
|
23
24
|
this.settings = settings;
|
|
24
25
|
this.props = props || {};
|
|
@@ -146,22 +147,32 @@ class IncyclistDevice extends events_1.default {
|
|
|
146
147
|
this.cyclingMode = selectedMode;
|
|
147
148
|
this.cyclingMode.setSettings(settings);
|
|
148
149
|
}
|
|
150
|
+
createMode(ModeClass) {
|
|
151
|
+
try {
|
|
152
|
+
const mode = new ModeClass(null);
|
|
153
|
+
return this.createOrGetMode(mode.getName());
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
this.logEvent({ message: 'error', error: err.message, stack: err.stack, mode: ModeClass === null || ModeClass === void 0 ? void 0 : ModeClass.name });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
149
159
|
createOrGetMode(mode) {
|
|
150
|
-
var _a, _b;
|
|
160
|
+
var _a, _b, _c;
|
|
151
161
|
if (typeof mode === 'string') {
|
|
152
162
|
if (mode === ((_a = this.getCyclingMode()) === null || _a === void 0 ? void 0 : _a.getName())) {
|
|
153
163
|
return this.cyclingMode;
|
|
154
164
|
}
|
|
155
165
|
const supported = this.getSupportedCyclingModes();
|
|
156
|
-
const CyclingModeClass = supported.find(M => { const m = new M(
|
|
166
|
+
const CyclingModeClass = supported.find(M => { const m = new M(null); return m.getName() === mode; });
|
|
157
167
|
if (CyclingModeClass) {
|
|
158
|
-
|
|
168
|
+
this.modes[mode] = (_b = this.modes[mode]) !== null && _b !== void 0 ? _b : new CyclingModeClass(this);
|
|
169
|
+
return this.modes[mode];
|
|
159
170
|
}
|
|
160
171
|
else {
|
|
161
172
|
return this.getDefaultCyclingMode();
|
|
162
173
|
}
|
|
163
174
|
}
|
|
164
|
-
if (mode.getName() === ((
|
|
175
|
+
if (mode.getName() === ((_c = this.cyclingMode) === null || _c === void 0 ? void 0 : _c.getName())) {
|
|
165
176
|
return this.cyclingMode;
|
|
166
177
|
}
|
|
167
178
|
return mode;
|
|
@@ -182,7 +193,7 @@ class IncyclistDevice extends events_1.default {
|
|
|
182
193
|
const config = this.getControllerInfo();
|
|
183
194
|
const C = config.default;
|
|
184
195
|
try {
|
|
185
|
-
return
|
|
196
|
+
return this.createMode(C);
|
|
186
197
|
}
|
|
187
198
|
catch (err) {
|
|
188
199
|
this.logEvent({ message: 'error', error: err.message, fn: 'getDefaultCyclingMode', stack: err.stack });
|
package/lib/ble/fm/adapter.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export default class BleFmAdapter extends BleAdapter<IndoorBikeData, BleFitnessM
|
|
|
29
29
|
protected setConstants(): void;
|
|
30
30
|
protected establishControl(): Promise<boolean>;
|
|
31
31
|
protected sendInitialRequest(): Promise<void>;
|
|
32
|
+
protected updateCyclingModeConfig(): void;
|
|
32
33
|
protected checkCapabilities(): Promise<void>;
|
|
33
34
|
protected updateCapabilitiesFromFeatures(features: IndoorBikeFeatures): void;
|
|
34
35
|
sendUpdate(request: any, enforced?: boolean): Promise<UpdateRequest | void>;
|
package/lib/ble/fm/adapter.js
CHANGED
|
@@ -21,11 +21,9 @@ const adapter_1 = __importDefault(require("../base/adapter"));
|
|
|
21
21
|
const consts_1 = require("./consts");
|
|
22
22
|
const types_1 = require("../../types");
|
|
23
23
|
const utils_1 = require("../../utils/utils");
|
|
24
|
-
const utils_2 = require("../utils");
|
|
25
24
|
const play_1 = require("../zwift/play");
|
|
26
25
|
const features_1 = require("../../features");
|
|
27
26
|
const fm_resistance_1 = __importDefault(require("../../modes/fm-resistance"));
|
|
28
|
-
const ZWIFT_PLAY_UUID = '0000000119ca465186e5fa29dcdd09d1';
|
|
29
27
|
class BleFmAdapter extends adapter_1.default {
|
|
30
28
|
constructor(settings, props) {
|
|
31
29
|
super(settings, props);
|
|
@@ -53,7 +51,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
53
51
|
var _a, _b;
|
|
54
52
|
if (!this.getFeatureToggle().has('VirtualShifting'))
|
|
55
53
|
return false;
|
|
56
|
-
return (_b = (_a = this.device) === null || _a === void 0 ? void 0 : _a.
|
|
54
|
+
return (_b = (_a = this.device) === null || _a === void 0 ? void 0 : _a.supportsVirtualShifting()) !== null && _b !== void 0 ? _b : false;
|
|
57
55
|
}
|
|
58
56
|
getSupportedCyclingModes() {
|
|
59
57
|
var _a, _b;
|
|
@@ -75,18 +73,20 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
75
73
|
getDefaultCyclingMode() {
|
|
76
74
|
var _a, _b;
|
|
77
75
|
if (((_a = this.props) === null || _a === void 0 ? void 0 : _a.capabilities) && this.props.capabilities.indexOf(types_1.IncyclistCapability.Control) === -1)
|
|
78
|
-
return
|
|
76
|
+
return this.createMode(power_meter_1.default);
|
|
79
77
|
const features = (_b = this.getSensor()) === null || _b === void 0 ? void 0 : _b.features;
|
|
80
|
-
if (!features)
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
if (!features) {
|
|
79
|
+
return this.createMode(antble_smarttrainer_1.default);
|
|
80
|
+
}
|
|
81
|
+
if (features.setSlope === undefined || features.setSlope) {
|
|
82
|
+
return this.createMode(antble_smarttrainer_1.default);
|
|
83
|
+
}
|
|
84
84
|
if (features.setPower === undefined || features.setPower)
|
|
85
|
-
return
|
|
85
|
+
return this.createMode(antble_erg_1.default);
|
|
86
86
|
if (features.setResistance) {
|
|
87
|
-
return
|
|
87
|
+
return this.createMode(fm_resistance_1.default);
|
|
88
88
|
}
|
|
89
|
-
return
|
|
89
|
+
return this.createMode(power_meter_1.default);
|
|
90
90
|
}
|
|
91
91
|
mapData(deviceData) {
|
|
92
92
|
var _a, _b, _c, _d, _e;
|
|
@@ -223,6 +223,14 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
223
223
|
yield this.sendUpdate(startRequest, true);
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
|
+
updateCyclingModeConfig() {
|
|
227
|
+
const modes = this.getSupportedCyclingModes();
|
|
228
|
+
modes.forEach(ModeClass => {
|
|
229
|
+
const mode = this.createMode(ModeClass);
|
|
230
|
+
mode.resetConfig();
|
|
231
|
+
mode.getConfig();
|
|
232
|
+
});
|
|
233
|
+
}
|
|
226
234
|
checkCapabilities() {
|
|
227
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
236
|
const before = this.capabilities.join(',');
|
|
@@ -242,6 +250,7 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
242
250
|
if (before !== after) {
|
|
243
251
|
this.logEvent({ message: 'device capabilities updated', name: this.getSettings().name, interface: this.getSettings().interface, capabilities: this.capabilities });
|
|
244
252
|
this.emit('device-info', this.getSettings(), { capabilities: this.capabilities });
|
|
253
|
+
this.updateCyclingModeConfig();
|
|
245
254
|
}
|
|
246
255
|
});
|
|
247
256
|
}
|
package/lib/ble/fm/consts.d.ts
CHANGED
package/lib/ble/fm/consts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TargetSettingFeatureFlag = exports.FitnessMachineFeatureFlag = exports.IndoorBikeDataFlag = exports.cRR = exports.cwABike = void 0;
|
|
3
|
+
exports.ZWIFT_PLAY_UUID = exports.TargetSettingFeatureFlag = exports.FitnessMachineFeatureFlag = exports.IndoorBikeDataFlag = exports.cRR = exports.cwABike = void 0;
|
|
4
4
|
exports.cwABike = {
|
|
5
5
|
race: 0.35,
|
|
6
6
|
triathlon: 0.29,
|
|
@@ -61,3 +61,4 @@ exports.TargetSettingFeatureFlag = {
|
|
|
61
61
|
SpinDownControlSupported: bit(15),
|
|
62
62
|
TargetedCadenceConfigurationSupported: bit(16)
|
|
63
63
|
};
|
|
64
|
+
exports.ZWIFT_PLAY_UUID = '0000000119ca465186e5fa29dcdd09d1';
|
package/lib/ble/fm/sensor.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export default class BleFitnessMachineDevice extends TBleSensor {
|
|
|
36
36
|
protected parseIndoorBikeData(_data: Uint8Array): IndoorBikeData;
|
|
37
37
|
protected parseFitnessMachineStatus(_data: Uint8Array): IndoorBikeData;
|
|
38
38
|
getFitnessMachineFeatures(): Promise<IndoorBikeFeatures | undefined>;
|
|
39
|
+
supportsVirtualShifting(): boolean;
|
|
39
40
|
protected buildFitnessMachineInfo(fitnessMachine: number): string[];
|
|
40
41
|
protected buildTargetSettingsInfo(targetSettings: number): string[];
|
|
41
42
|
protected writeFtmsMessage(requestedOpCode: any, data: any, props?: BleWriteProps): Promise<number>;
|
package/lib/ble/fm/sensor.js
CHANGED
|
@@ -332,6 +332,10 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
332
332
|
}
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
|
+
supportsVirtualShifting() {
|
|
336
|
+
var _a;
|
|
337
|
+
return (_a = this.getSupportedServiceUUids()) === null || _a === void 0 ? void 0 : _a.some(s => (0, utils_1.matches)(s, consts_2.ZWIFT_PLAY_UUID));
|
|
338
|
+
}
|
|
335
339
|
buildFitnessMachineInfo(fitnessMachine) {
|
|
336
340
|
const info = [];
|
|
337
341
|
const check = (flag, name) => {
|
|
@@ -387,6 +391,9 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
|
|
|
387
391
|
check(consts_2.TargetSettingFeatureFlag.WheelCircumferenceConfigurationSupported, 'wheelCircumference');
|
|
388
392
|
check(consts_2.TargetSettingFeatureFlag.SpinDownControlSupported, 'spindown');
|
|
389
393
|
check(consts_2.TargetSettingFeatureFlag.TargetedCadenceConfigurationSupported, 'cadence');
|
|
394
|
+
if (this.supportsVirtualShifting) {
|
|
395
|
+
info.push('virtualShifting');
|
|
396
|
+
}
|
|
390
397
|
}
|
|
391
398
|
catch (err) {
|
|
392
399
|
this.logEvent({ message: 'could not read TargetSettingsInfo', error: err.message, stack: err.stack, device: this.getName() });
|
|
@@ -40,6 +40,7 @@ export default class SmartTrainerCyclingMode extends PowerBasedCyclingModeBase i
|
|
|
40
40
|
constructor(adapter: IAdapter, props?: any);
|
|
41
41
|
getBikeInitRequest(): UpdateRequest;
|
|
42
42
|
checkForResetOrEmpty(request: UpdateRequest): UpdateRequest | undefined;
|
|
43
|
+
resetConfig(): void;
|
|
43
44
|
getConfig(): CyclingModeConfig;
|
|
44
45
|
protected checkSlopeNoShiftig(request: UpdateRequest, newRequest?: UpdateRequest): void;
|
|
45
46
|
protected checkSlopeWithAdapterShifting(request: UpdateRequest, newRequest?: UpdateRequest): void;
|
|
@@ -70,12 +70,24 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
70
70
|
return this.prevRequest;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
resetConfig() {
|
|
74
|
+
const config = this.getConfig();
|
|
75
|
+
const virtshiftIdx = config.properties.findIndex(p => p.key === 'virtshift');
|
|
76
|
+
if (virtshiftIdx !== -1) {
|
|
77
|
+
config.properties.splice(virtshiftIdx, 1);
|
|
78
|
+
}
|
|
79
|
+
let startGearIdx = config.properties.findIndex(p => p.key === 'startGear');
|
|
80
|
+
if (startGearIdx !== -1) {
|
|
81
|
+
config.properties.splice(startGearIdx, 1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
73
84
|
getConfig() {
|
|
85
|
+
var _a, _b;
|
|
74
86
|
const config = super.getConfig();
|
|
75
87
|
const virtShiftEnabled = this.getFeatureToogle().has('VirtualShifting');
|
|
76
88
|
let virtshift = config.properties.find(p => p.key === 'virtshift');
|
|
77
89
|
let startGear = config.properties.find(p => p.key === 'startGear');
|
|
78
|
-
if (!virtshift && !this.adapter.supportsVirtualShifting()) {
|
|
90
|
+
if (!virtshift && !((_a = this.adapter) === null || _a === void 0 ? void 0 : _a.supportsVirtualShifting())) {
|
|
79
91
|
const options = virtShiftEnabled ? [
|
|
80
92
|
'Disabled',
|
|
81
93
|
{ key: 'Incyclist', display: 'App only (beta)' },
|
|
@@ -88,7 +100,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
88
100
|
virtshift = { key: 'virtshift', name: 'Virtual Shifting', description: 'Enable virtual shifting', type: types_1.CyclingModeProperyType.SingleSelect, options, default: 'Disabled' };
|
|
89
101
|
config.properties.push(virtshift);
|
|
90
102
|
}
|
|
91
|
-
if (!virtshift && virtShiftEnabled && this.adapter.supportsVirtualShifting()) {
|
|
103
|
+
if (!virtshift && virtShiftEnabled && ((_b = this.adapter) === null || _b === void 0 ? void 0 : _b.supportsVirtualShifting())) {
|
|
92
104
|
const options = [
|
|
93
105
|
'Disabled',
|
|
94
106
|
{ key: 'Incyclist', display: 'App only (beta)' },
|
|
@@ -193,7 +205,6 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
193
205
|
return;
|
|
194
206
|
}
|
|
195
207
|
if (request.targetPower !== undefined || request.targetPowerDelta !== undefined || request.gearDelta !== undefined || request.gearRatio !== undefined) {
|
|
196
|
-
console.log('# cadence change ignored due to other power/gear request', request);
|
|
197
208
|
return;
|
|
198
209
|
}
|
|
199
210
|
if (this.data.pedalRpm !== this.prevData.pedalRpm) {
|
|
@@ -216,20 +227,23 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
216
227
|
const prev = ((_e = (_d = this.prevSimPower) !== null && _d !== void 0 ? _d : prevPower) !== null && _e !== void 0 ? _e : 0);
|
|
217
228
|
const delta = newPower - prev;
|
|
218
229
|
if (!this.prevEkin && this.data.isPedalling) {
|
|
230
|
+
this.simPower = prev + delta / 2;
|
|
219
231
|
this.simPower = Math.max(newPower, prevPower);
|
|
220
232
|
this.prevEkin = m * v * v / 2;
|
|
221
233
|
this.logger.logEvent({ message: 'set simulated power (starting)', target: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevTarget: this.prevSimPower, actualPower: prevPower, newPower });
|
|
222
234
|
}
|
|
223
235
|
else if (changed === 'gear') {
|
|
224
|
-
this.simPower = prev + delta
|
|
236
|
+
this.simPower = prev + delta;
|
|
225
237
|
this.prevEkin = m * v * v / 2;
|
|
226
238
|
this.logger.logEvent({ message: 'set simulated power (gear change)', target: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevTarget: this.prevSimPower, actualPower: prevPower, newPower });
|
|
227
239
|
}
|
|
228
240
|
else if (changed === 'slope' || changed === 'cadence') {
|
|
229
|
-
this.
|
|
241
|
+
const adjustTime = this.simSlope < 0 ? 5 : 3;
|
|
242
|
+
this.simPower = prev + delta / adjustTime;
|
|
230
243
|
this.logger.logEvent({ message: `set simulated power (${changed} change)`, target: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevTarget: this.prevSimPower, actualPower: prevPower, newPower });
|
|
231
244
|
}
|
|
232
245
|
else {
|
|
246
|
+
this.logger.logEvent({ message: `set simulated power (mothing changed)`, target: this.simPower, gear: this.gear, simSlope: this.simSlope, routeSlope: this.data.slope, prevTarget: this.prevSimPower, actualPower: prevPower, newPower });
|
|
233
247
|
}
|
|
234
248
|
}
|
|
235
249
|
else {
|
|
@@ -266,12 +280,11 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
266
280
|
this.gear = this.gearRatios.length;
|
|
267
281
|
}
|
|
268
282
|
delete request.gearDelta;
|
|
269
|
-
console.log('# gear changed');
|
|
270
283
|
this.logger.logEvent({ message: 'gear changed', gear: this.gear, oldGear });
|
|
284
|
+
this.data.gearStr = this.getGearString();
|
|
271
285
|
this.calculateSimulatedPower('gear');
|
|
272
286
|
if (this.simPower !== undefined) {
|
|
273
|
-
|
|
274
|
-
this.prevSimPower = this.simPower;
|
|
287
|
+
newRequest.targetPower = this.simPower;
|
|
275
288
|
}
|
|
276
289
|
}
|
|
277
290
|
break;
|
|
@@ -342,6 +355,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
342
355
|
}
|
|
343
356
|
}
|
|
344
357
|
getVirtualShiftMode() {
|
|
358
|
+
var _a;
|
|
345
359
|
try {
|
|
346
360
|
if (!this.getFeatureToogle().has('VirtualShifting')) {
|
|
347
361
|
return 'Disabled';
|
|
@@ -360,7 +374,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
360
374
|
return 'SlopeDelta';
|
|
361
375
|
}
|
|
362
376
|
else if (virtshiftMode === 'Enabled') {
|
|
363
|
-
return this.adapter.supportsVirtualShifting() ? 'Adapter' : 'Simulated';
|
|
377
|
+
return ((_a = this.adapter) === null || _a === void 0 ? void 0 : _a.supportsVirtualShifting()) ? 'Adapter' : 'Simulated';
|
|
364
378
|
}
|
|
365
379
|
}
|
|
366
380
|
catch (err) {
|
|
@@ -370,7 +384,6 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
370
384
|
}
|
|
371
385
|
updateData(bikeData, log) {
|
|
372
386
|
var _a;
|
|
373
|
-
console.log('# update data', bikeData);
|
|
374
387
|
const prev = this.prevData = Object.assign({}, this.data);
|
|
375
388
|
const data = super.updateData(bikeData, log);
|
|
376
389
|
const mode = this.getVirtualShiftMode();
|
|
@@ -386,7 +399,6 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
386
399
|
this.gear = (_a = Number(this.getSetting('startGear'))) !== null && _a !== void 0 ? _a : 0;
|
|
387
400
|
data.gearStr = this.getGearString();
|
|
388
401
|
}
|
|
389
|
-
console.log('# data updated', data);
|
|
390
402
|
return data;
|
|
391
403
|
}
|
|
392
404
|
getData() {
|
|
@@ -402,7 +414,6 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
402
414
|
return super.updateRequired(request);
|
|
403
415
|
}
|
|
404
416
|
sendBikeUpdate(incoming) {
|
|
405
|
-
console.log('# bike update request', incoming);
|
|
406
417
|
this.logger.logEvent({ message: "processing update request", request: incoming, prev: this.prevRequest, data: this.getData() });
|
|
407
418
|
let newRequest = {};
|
|
408
419
|
const request = Object.assign({}, incoming);
|
|
@@ -422,7 +433,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
422
433
|
catch (err) {
|
|
423
434
|
this.logger.logEvent({ message: "error", fn: 'sendBikeUpdate()', error: err.message, stack: err.stack });
|
|
424
435
|
}
|
|
425
|
-
if (newRequest.targetPower) {
|
|
436
|
+
if (newRequest.targetPower && this.simPower) {
|
|
426
437
|
this.prevSimPower = newRequest.targetPower;
|
|
427
438
|
}
|
|
428
439
|
return newRequest;
|
package/lib/modes/types.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export default interface ICyclingMode {
|
|
|
53
53
|
setModeProperty(name: string, value: any): void;
|
|
54
54
|
getModeProperty(name: string): any;
|
|
55
55
|
getData(): Partial<IncyclistBikeData>;
|
|
56
|
+
resetConfig(): void;
|
|
57
|
+
getConfig(): CyclingModeConfig;
|
|
56
58
|
}
|
|
57
59
|
export type CyclingModeConfig = {
|
|
58
60
|
isERG?: boolean;
|
|
@@ -82,6 +84,7 @@ export declare class CyclingMode implements ICyclingMode {
|
|
|
82
84
|
isERG(): boolean;
|
|
83
85
|
isSIM(): boolean;
|
|
84
86
|
isResistance(): boolean;
|
|
87
|
+
resetConfig(): void;
|
|
85
88
|
getData(): Partial<IncyclistBikeData>;
|
|
86
89
|
confirmed(request: UpdateRequest): void;
|
|
87
90
|
}
|
package/lib/modes/types.js
CHANGED
|
@@ -52,7 +52,7 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
52
52
|
}
|
|
53
53
|
getDefaultCyclingMode() {
|
|
54
54
|
if (this.props.capabilities && this.props.capabilities.indexOf(types_1.IncyclistCapability.Control) === -1)
|
|
55
|
-
return
|
|
55
|
+
return this.createMode(daum_power_1.default);
|
|
56
56
|
return super.getDefaultCyclingMode();
|
|
57
57
|
}
|
|
58
58
|
sendInitCommands() {
|
|
@@ -19,7 +19,6 @@ const daum_classic_standard_1 = __importDefault(require("../../../modes/daum-cla
|
|
|
19
19
|
const comms_1 = __importDefault(require("./comms"));
|
|
20
20
|
const serial_interface_1 = __importDefault(require("../../base/serial-interface"));
|
|
21
21
|
const daum_erg_1 = __importDefault(require("../../../modes/daum-erg"));
|
|
22
|
-
const daum_smarttrainer_1 = __importDefault(require("../../../modes/daum-smarttrainer"));
|
|
23
22
|
const daum_power_1 = __importDefault(require("../../../modes/daum-power"));
|
|
24
23
|
const consts_1 = require("./consts");
|
|
25
24
|
class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
@@ -191,7 +190,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
191
190
|
}
|
|
192
191
|
DaumClassicAdapter.NAME = consts_1.PROTOCOL_NAME;
|
|
193
192
|
DaumClassicAdapter.controllers = {
|
|
194
|
-
modes: [daum_erg_1.default,
|
|
193
|
+
modes: [daum_erg_1.default, daum_power_1.default, daum_classic_standard_1.default],
|
|
195
194
|
default: daum_classic_standard_1.default
|
|
196
195
|
};
|
|
197
196
|
exports.default = DaumClassicAdapter;
|
|
@@ -21,7 +21,6 @@ const types_1 = require("../../types");
|
|
|
21
21
|
const types_2 = require("../../../types");
|
|
22
22
|
const daum_premium_standard_1 = __importDefault(require("../../../modes/daum-premium-standard"));
|
|
23
23
|
const daum_erg_1 = __importDefault(require("../../../modes/daum-erg"));
|
|
24
|
-
const daum_smarttrainer_1 = __importDefault(require("../../../modes/daum-smarttrainer"));
|
|
25
24
|
const daum_power_1 = __importDefault(require("../../../modes/daum-power"));
|
|
26
25
|
const PROTOCOL_NAME = "Daum Premium";
|
|
27
26
|
const DAUM_PREMIUM_DEFAULT_PORT = 51955;
|
|
@@ -233,7 +232,7 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
233
232
|
}
|
|
234
233
|
DaumPremiumAdapter.NAME = PROTOCOL_NAME;
|
|
235
234
|
DaumPremiumAdapter.controllers = {
|
|
236
|
-
modes: [daum_erg_1.default,
|
|
235
|
+
modes: [daum_erg_1.default, daum_power_1.default, daum_premium_standard_1.default],
|
|
237
236
|
default: daum_erg_1.default
|
|
238
237
|
};
|
|
239
238
|
exports.default = DaumPremiumAdapter;
|
package/lib/types/adapter.d.ts
CHANGED