incyclist-devices 2.2.4 → 2.2.7
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.d.ts +1 -0
- package/lib/antv2/base/adapter.js +6 -1
- package/lib/modes/antble-smarttrainer.d.ts +1 -0
- package/lib/modes/antble-smarttrainer.js +1 -0
- package/lib/modes/types.d.ts +4 -0
- package/lib/modes/types.js +9 -0
- package/lib/serial/base/serial-scanner.js +5 -0
- package/lib/serial/daum/classic/adapter.js +4 -2
- package/lib/serial/daum/premium/adapter.js +4 -2
- package/lib/serial/daum/premium/comms.js +44 -25
- package/package.json +1 -1
|
@@ -63,6 +63,7 @@ export default class AntAdapter<TDeviceData extends BaseDeviceData> extends Incy
|
|
|
63
63
|
reportStartStatus(): boolean;
|
|
64
64
|
protected waitForInitialData(startupTimeout: any): Promise<void>;
|
|
65
65
|
protected initSensor(props: any): Promise<boolean>;
|
|
66
|
+
getLogProps(startProps?: AntDeviceProperties): AntDeviceProperties;
|
|
66
67
|
start(startProps?: AntDeviceProperties): Promise<boolean>;
|
|
67
68
|
stop(): Promise<boolean>;
|
|
68
69
|
startSensor(): Promise<boolean>;
|
|
@@ -354,15 +354,20 @@ class AntAdapter extends adpater_1.default {
|
|
|
354
354
|
}
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
|
+
getLogProps(startProps) {
|
|
358
|
+
const { user, userWeight, bikeWeight, startupTimeout, automaticReconnect } = startProps !== null && startProps !== void 0 ? startProps : {};
|
|
359
|
+
return { user, userWeight, bikeWeight, startupTimeout, automaticReconnect };
|
|
360
|
+
}
|
|
357
361
|
start(startProps) {
|
|
358
362
|
return __awaiter(this, void 0, void 0, function* () {
|
|
359
363
|
const props = this.getStartProps(startProps);
|
|
364
|
+
const logProps = this.getLogProps(startProps);
|
|
360
365
|
const preCheckResult = yield this.startPreChecks(props);
|
|
361
366
|
if (preCheckResult === 'done')
|
|
362
367
|
return this.started;
|
|
363
368
|
if (preCheckResult === 'connection-failed')
|
|
364
369
|
throw new Error(`could not start device, reason:could not connect`);
|
|
365
|
-
this.logEvent({ message: 'starting device', device: this.getName(), props, isStarted: this.started });
|
|
370
|
+
this.logEvent({ message: 'starting device', device: this.getName(), props: logProps, isStarted: this.started, isPaused: this.isPaused, isStopped: this.isStopped });
|
|
366
371
|
this.resetStartStatus();
|
|
367
372
|
this.resetData();
|
|
368
373
|
const { startupTimeout = this.getDefaultStartupTimeout() } = props;
|
|
@@ -64,6 +64,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
|
|
|
64
64
|
}
|
|
65
65
|
SmartTrainerCyclingMode.config = {
|
|
66
66
|
name: "Smart Trainer",
|
|
67
|
+
isSIM: true,
|
|
67
68
|
description: "Calculates speed based on power and slope. Slope is set to the device",
|
|
68
69
|
properties: [
|
|
69
70
|
{ key: 'bikeType', name: 'Bike Type', description: '', type: types_1.CyclingModeProperyType.SingleSelect, options: ['Race', 'Mountain', 'Triathlon'], default: 'Race' },
|
package/lib/modes/types.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export default interface ICyclingMode {
|
|
|
49
49
|
}
|
|
50
50
|
export type CyclingModeConfig = {
|
|
51
51
|
isERG?: boolean;
|
|
52
|
+
isSIM?: boolean;
|
|
52
53
|
name: string;
|
|
53
54
|
description: string;
|
|
54
55
|
properties: CyclingModeProperty[];
|
|
@@ -69,4 +70,7 @@ export declare class CyclingMode implements ICyclingMode {
|
|
|
69
70
|
getSettings(): Settings;
|
|
70
71
|
setModeProperty(_name: string, _value: any): void;
|
|
71
72
|
getModeProperty(_name: string): void;
|
|
73
|
+
getConfig(): CyclingModeConfig;
|
|
74
|
+
isERG(): boolean;
|
|
75
|
+
isSIM(): boolean;
|
|
72
76
|
}
|
package/lib/modes/types.js
CHANGED
|
@@ -52,5 +52,14 @@ class CyclingMode {
|
|
|
52
52
|
getModeProperty(_name) {
|
|
53
53
|
throw new Error("Method not implemented.");
|
|
54
54
|
}
|
|
55
|
+
getConfig() {
|
|
56
|
+
throw new Error("Method not implemented.");
|
|
57
|
+
}
|
|
58
|
+
isERG() {
|
|
59
|
+
return this.getConfig().isERG;
|
|
60
|
+
}
|
|
61
|
+
isSIM() {
|
|
62
|
+
return this.getConfig().isSIM;
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
exports.CyclingMode = CyclingMode;
|
|
@@ -67,6 +67,11 @@ class SinglePathScanner {
|
|
|
67
67
|
}
|
|
68
68
|
const adapterSettings = { interface: this.serial.getName(), host, port, protocol };
|
|
69
69
|
const adapter = adapter_factory_1.default.getInstance().createInstance(adapterSettings);
|
|
70
|
+
if (!adapter) {
|
|
71
|
+
this.isScanning = false;
|
|
72
|
+
resolve(this.result);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
70
75
|
if (this.isScanning) {
|
|
71
76
|
found = yield (adapter === null || adapter === void 0 ? void 0 : adapter.check());
|
|
72
77
|
if (found) {
|
|
@@ -163,11 +163,13 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
const checkInterrupt = () => new Promise(done => {
|
|
166
|
-
|
|
166
|
+
const onStop = () => {
|
|
167
167
|
stopped = true;
|
|
168
168
|
this.started = false;
|
|
169
169
|
done(false);
|
|
170
|
-
|
|
170
|
+
this.internalEmitter.off('stop', onStop);
|
|
171
|
+
};
|
|
172
|
+
this.internalEmitter.on('stop', onStop);
|
|
171
173
|
});
|
|
172
174
|
return (0, utils_1.runWithRetries)(() => Promise.race([start(), checkInterrupt()]), 5, 1000);
|
|
173
175
|
}
|
|
@@ -194,11 +194,13 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
const checkInterrupt = () => new Promise(done => {
|
|
197
|
-
|
|
197
|
+
const onStop = () => {
|
|
198
198
|
stopped = true;
|
|
199
199
|
this.started = false;
|
|
200
200
|
done(false);
|
|
201
|
-
|
|
201
|
+
this.internalEmitter.off('stop', onStop);
|
|
202
|
+
};
|
|
203
|
+
this.internalEmitter.on('stop', onStop);
|
|
202
204
|
});
|
|
203
205
|
const started = yield (0, utils_1.runWithRetries)(() => Promise.race([start(), checkInterrupt()]), this.getStartRetries(), this.getStartRetryTimeout());
|
|
204
206
|
if (started) {
|
|
@@ -473,32 +473,51 @@ class Daum8i extends comms_1.default {
|
|
|
473
473
|
}
|
|
474
474
|
programUploadStart(bikeType, route) {
|
|
475
475
|
return __awaiter(this, void 0, void 0, function* () {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
476
|
+
let payload, epp, eppLength, bikeTypeVal, wBits;
|
|
477
|
+
try {
|
|
478
|
+
payload = Buffer.alloc(40);
|
|
479
|
+
epp = route ? (0, utils_1.routeToEpp)(route) : undefined;
|
|
480
|
+
eppLength = epp ? epp.length : 0;
|
|
481
|
+
bikeTypeVal = (0, utils_1.getBikeType)(bikeType);
|
|
482
|
+
wBits = route.lapMode ? consts_1.DS_BITS_ENDLESS_RACE : consts_1.DS_BITS_OFF;
|
|
483
|
+
}
|
|
484
|
+
catch (err) {
|
|
485
|
+
this.logEvent({ message: 'error', fn: 'programUploadStart#prepare', epp, error: err.message, stack: err.stack });
|
|
486
|
+
throw err;
|
|
487
|
+
}
|
|
488
|
+
try {
|
|
489
|
+
payload.writeInt32LE(0, 0);
|
|
490
|
+
payload.writeInt8(bikeTypeVal, 4);
|
|
491
|
+
payload.writeInt8(0, 5);
|
|
492
|
+
payload.writeInt16LE(0, 6);
|
|
493
|
+
payload.writeInt32LE(0, 8);
|
|
494
|
+
payload.writeInt32LE(0, 12);
|
|
495
|
+
payload.writeFloatLE(0, 16);
|
|
496
|
+
payload.writeFloatLE(0, 20);
|
|
497
|
+
payload.writeInt16LE(0, 24);
|
|
498
|
+
payload.writeInt16LE(0, 26);
|
|
499
|
+
payload.writeInt16LE(0, 28);
|
|
500
|
+
payload.writeInt16LE(wBits, 30);
|
|
501
|
+
payload.writeInt32LE(7, 32);
|
|
502
|
+
payload.writeInt32LE(eppLength, 36);
|
|
503
|
+
}
|
|
504
|
+
catch (err) {
|
|
505
|
+
this.logEvent({ message: 'error', fn: 'programUploadStart#createPayload', bikeTypeVal, wBits, eppLength, error: err.message, stack: err.stack });
|
|
506
|
+
throw err;
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
const res = yield this.sendReservedDaum8iCommand('programUploadStart()', utils_1.ReservedCommands.PROGRAM_LIST_NEW_PROGRAM, payload);
|
|
510
|
+
const buffer = Buffer.from(res);
|
|
511
|
+
if (buffer.readInt16LE(0) === utils_1.ReservedCommands.PROGRAM_LIST_NEW_PROGRAM) {
|
|
512
|
+
this.logEvent({ message: 'programUploadStart() response', success: true });
|
|
513
|
+
return epp;
|
|
514
|
+
}
|
|
515
|
+
this.logEvent({ message: 'programUploadStart() response', success: false });
|
|
516
|
+
}
|
|
517
|
+
catch (err) {
|
|
518
|
+
this.logEvent({ message: 'error', fn: 'programUploadStart#send', payload: payload.toString('hex'), error: err.message, stack: err.stack });
|
|
519
|
+
throw err;
|
|
500
520
|
}
|
|
501
|
-
this.logEvent({ message: 'programUploadStart() response', success: false });
|
|
502
521
|
throw new Error('Illegal Response');
|
|
503
522
|
});
|
|
504
523
|
}
|