incyclist-devices 2.1.0 → 2.1.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/lib/adapters.d.ts +1 -1
- package/lib/antv2/adapter-factory.d.ts +4 -15
- package/lib/antv2/adapter.d.ts +15 -15
- package/lib/antv2/adapter.js +67 -21
- package/lib/antv2/ant-interface.d.ts +3 -11
- package/lib/antv2/ant-interface.js +1 -1
- package/lib/antv2/base/adapter.d.ts +62 -0
- package/lib/antv2/base/adapter.js +360 -0
- package/lib/antv2/base/ant-interface.d.ts +35 -0
- package/lib/antv2/base/ant-interface.js +285 -0
- package/lib/antv2/base/binding.d.ts +13 -0
- package/lib/antv2/base/binding.js +27 -0
- package/lib/antv2/cad/adapter.d.ts +10 -0
- package/lib/antv2/cad/adapter.js +25 -0
- package/lib/antv2/cad/index.d.ts +2 -0
- package/lib/antv2/cad/index.js +7 -0
- package/lib/antv2/consts.d.ts +2 -0
- package/lib/antv2/consts.js +5 -0
- package/lib/antv2/factories/adapter-factory.d.ts +14 -0
- package/lib/antv2/factories/adapter-factory.js +65 -0
- package/lib/antv2/factories/sensor-factory.d.ts +5 -0
- package/lib/antv2/factories/sensor-factory.js +22 -0
- package/lib/antv2/fe/adapter.d.ts +24 -29
- package/lib/antv2/fe/adapter.js +208 -225
- package/lib/antv2/hr/adapter.d.ts +6 -15
- package/lib/antv2/hr/adapter.js +7 -55
- package/lib/antv2/hr copy/adapter.d.ts +11 -0
- package/lib/antv2/hr copy/adapter.js +30 -0
- package/lib/antv2/hr copy/index.d.ts +2 -0
- package/lib/antv2/hr copy/index.js +7 -0
- package/lib/antv2/index.d.ts +5 -4
- package/lib/antv2/index.js +4 -2
- package/lib/antv2/pwr/adapter.d.ts +9 -33
- package/lib/antv2/pwr/adapter.js +19 -140
- package/lib/antv2/types.d.ts +23 -4
- package/lib/base/adpater.d.ts +39 -60
- package/lib/base/adpater.js +139 -161
- package/lib/base/consts.d.ts +4 -0
- package/lib/base/consts.js +9 -0
- package/lib/ble/adapter-factory.d.ts +10 -11
- package/lib/ble/base/adapter.d.ts +7 -14
- package/lib/ble/base/adapter.js +2 -36
- package/lib/ble/ble-interface.d.ts +5 -7
- package/lib/ble/cp/adapter.d.ts +6 -8
- package/lib/ble/cp/adapter.js +8 -27
- package/lib/ble/elite/adapter.d.ts +7 -8
- package/lib/ble/elite/adapter.js +5 -25
- package/lib/ble/fm/adapter.d.ts +6 -7
- package/lib/ble/fm/adapter.js +13 -34
- package/lib/ble/hr/adapter.d.ts +5 -8
- package/lib/ble/hr/adapter.js +2 -2
- package/lib/ble/peripheral-cache.d.ts +2 -3
- package/lib/ble/tacx/adapter.d.ts +2 -3
- package/lib/ble/tacx/adapter.js +8 -8
- package/lib/ble/types.d.ts +1 -2
- package/lib/ble/wahoo/adapter.d.ts +2 -2
- package/lib/ble/wahoo/adapter.js +6 -6
- package/lib/ble/wahoo/comms.js +16 -16
- package/lib/factories/adapters.d.ts +7 -0
- package/lib/factories/adapters.js +49 -0
- package/lib/factories/index.d.ts +3 -0
- package/lib/factories/index.js +10 -0
- package/lib/factories/interfaces.d.ts +7 -0
- package/lib/factories/interfaces.js +27 -0
- package/lib/index.d.ts +5 -6
- package/lib/index.js +4 -9
- package/lib/interfaces.d.ts +1 -1
- package/lib/modes/ant-fe-adv-st-mode.d.ts +1 -1
- package/lib/modes/antble-erg.d.ts +1 -1
- package/lib/modes/antble-smarttrainer.d.ts +2 -2
- package/lib/modes/base.d.ts +5 -5
- package/lib/modes/daum-classic-standard.d.ts +3 -2
- package/lib/modes/daum-erg.d.ts +3 -3
- package/lib/modes/daum-premium-standard.d.ts +3 -2
- package/lib/modes/daum-smarttrainer.d.ts +3 -2
- package/lib/modes/kettler-erg.d.ts +3 -3
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +2 -2
- package/lib/modes/power-meter.d.ts +3 -2
- package/lib/modes/simulator.d.ts +2 -1
- package/lib/modes/types.d.ts +2 -13
- package/lib/serial/SinglePathScanner.d.ts +17 -0
- package/lib/serial/SinglePathScanner.js +87 -0
- package/lib/serial/adapter-factory.d.ts +6 -6
- package/lib/serial/adapter.d.ts +6 -11
- package/lib/serial/base/adapter.d.ts +17 -0
- package/lib/serial/base/adapter.js +67 -0
- package/lib/serial/base/comms.d.ts +62 -0
- package/lib/serial/base/comms.js +280 -0
- package/lib/serial/base/serial-interface.d.ts +36 -0
- package/lib/serial/base/serial-interface.js +288 -0
- package/lib/serial/base/serial-scanner.d.ts +16 -0
- package/lib/serial/base/serial-scanner.js +87 -0
- package/lib/serial/base/serialport.d.ts +17 -0
- package/lib/serial/base/serialport.js +87 -0
- package/lib/serial/comms.d.ts +2 -2
- package/lib/serial/daum/DaumAdapter.d.ts +12 -24
- package/lib/serial/daum/DaumAdapter.js +40 -59
- package/lib/serial/daum/classic/PROTOCOL_NAME.d.ts +2 -0
- package/lib/serial/daum/classic/PROTOCOL_NAME.js +5 -0
- package/lib/serial/daum/classic/adapter.d.ts +8 -20
- package/lib/serial/daum/classic/adapter.js +28 -58
- package/lib/serial/daum/classic/comms.d.ts +4 -6
- package/lib/serial/daum/classic/comms.js +2 -2
- package/lib/serial/daum/classic/consts.d.ts +2 -0
- package/lib/serial/daum/classic/consts.js +5 -0
- package/lib/serial/daum/classic/mock.js +4 -3
- package/lib/serial/daum/classic/types.d.ts +8 -10
- package/lib/serial/daum/classic/utils.d.ts +1 -2
- package/lib/serial/daum/consts.d.ts +0 -19
- package/lib/serial/daum/consts.js +0 -22
- package/lib/serial/daum/premium/adapter.d.ts +8 -11
- package/lib/serial/daum/premium/adapter.js +27 -53
- package/lib/serial/daum/premium/comms.d.ts +4 -7
- package/lib/serial/daum/premium/comms.js +23 -22
- package/lib/serial/daum/premium/mock.d.ts +1 -1
- package/lib/serial/daum/premium/mock.js +2 -2
- package/lib/serial/daum/premium/types.d.ts +32 -17
- package/lib/serial/daum/premium/types.js +8 -8
- package/lib/serial/daum/premium/utils.d.ts +2 -3
- package/lib/serial/daum/premium/utils.js +3 -3
- package/lib/serial/daum/types.d.ts +4 -1
- package/lib/serial/daum/types.js +9 -1
- package/lib/serial/factories/adapter-factory.d.ts +14 -0
- package/lib/serial/factories/adapter-factory.js +30 -0
- package/lib/serial/index.d.ts +8 -5
- package/lib/serial/index.js +15 -15
- package/lib/serial/kettler/comms.d.ts +1 -1
- package/lib/serial/kettler/ergo-racer/adapter.d.ts +11 -18
- package/lib/serial/kettler/ergo-racer/adapter.js +9 -21
- package/lib/serial/kettler/types.d.ts +8 -0
- package/lib/serial/kettler/types.js +2 -0
- package/lib/serial/serial-interface.d.ts +2 -32
- package/lib/serial/serial-interface.js +3 -76
- package/lib/serial/serial-scanner.d.ts +16 -0
- package/lib/serial/serial-scanner.js +87 -0
- package/lib/serial/serialport.d.ts +1 -13
- package/lib/serial/types.d.ts +45 -0
- package/lib/serial/types.js +9 -0
- package/lib/simulator/Simulator.d.ts +10 -13
- package/lib/simulator/Simulator.js +11 -23
- package/lib/types/Command.d.ts +8 -0
- package/lib/types/Command.js +2 -0
- package/lib/types/adapter.d.ts +22 -33
- package/lib/types/adapter.js +0 -68
- package/lib/types/command.d.ts +0 -8
- package/lib/types/command.js +0 -2
- package/lib/types/data.d.ts +12 -1
- package/lib/types/device.d.ts +8 -23
- package/lib/types/device.js +9 -8
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.js +22 -0
- package/lib/types/route.d.ts +0 -19
- package/lib/types/route.js +0 -2
- package/lib/types/types.d.ts +8 -0
- package/lib/types/types.js +2 -0
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/utils.js +22 -4
- package/package.json +1 -1
|
@@ -12,12 +12,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const consts_1 = require("../consts");
|
|
16
15
|
const utils_1 = require("./utils");
|
|
17
16
|
const types_1 = require("./types");
|
|
17
|
+
const types_2 = require("../types");
|
|
18
|
+
const types_3 = require("./types");
|
|
18
19
|
const utils_2 = require("../../../utils/utils");
|
|
19
|
-
const comms_1 = __importDefault(require("../../comms"));
|
|
20
|
-
const
|
|
20
|
+
const comms_1 = __importDefault(require("../../base/comms"));
|
|
21
|
+
const consts_1 = require("./consts");
|
|
21
22
|
class Daum8i extends comms_1.default {
|
|
22
23
|
validatePath(path) {
|
|
23
24
|
return (0, utils_1.validatePath)(path);
|
|
@@ -26,10 +27,10 @@ class Daum8i extends comms_1.default {
|
|
|
26
27
|
return 'DaumPremium';
|
|
27
28
|
}
|
|
28
29
|
getAckTimeoutValue() {
|
|
29
|
-
return
|
|
30
|
+
return consts_1.DEFAULT_ACK_TIMEOUT;
|
|
30
31
|
}
|
|
31
32
|
getTimeoutValue() {
|
|
32
|
-
return
|
|
33
|
+
return consts_1.DEFAULT_TIMEOUT;
|
|
33
34
|
}
|
|
34
35
|
onConnected() {
|
|
35
36
|
this.sp.on('data', this.onData.bind(this));
|
|
@@ -103,7 +104,7 @@ class Daum8i extends comms_1.default {
|
|
|
103
104
|
this.recvState.data.enqueue({ type: 'Response', cmd: cmd.substring(0, 3), data: payload });
|
|
104
105
|
}
|
|
105
106
|
else {
|
|
106
|
-
const error = new
|
|
107
|
+
const error = new types_3.CheckSumError();
|
|
107
108
|
this.recvState.data.enqueue({ type: 'Error', error, data: cmd });
|
|
108
109
|
this.recvState.waitingForACK = false;
|
|
109
110
|
this.recvState.waitingForStart = true;
|
|
@@ -176,7 +177,7 @@ class Daum8i extends comms_1.default {
|
|
|
176
177
|
}
|
|
177
178
|
if (response.type === 'Error') {
|
|
178
179
|
this.logEvent(Object.assign(Object.assign({ message: `sendCommand:received:ERROR` }, logPayload), { error: response.error.message }));
|
|
179
|
-
if (response.error instanceof
|
|
180
|
+
if (response.error instanceof types_3.CheckSumError && retry < 5) {
|
|
180
181
|
checksumFailure = true;
|
|
181
182
|
yield this.sendNAK(logPayload);
|
|
182
183
|
retry++;
|
|
@@ -230,7 +231,7 @@ class Daum8i extends comms_1.default {
|
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
|
-
throw new
|
|
234
|
+
throw new types_3.ACKTimeout();
|
|
234
235
|
});
|
|
235
236
|
}
|
|
236
237
|
waitForResponse() {
|
|
@@ -248,7 +249,7 @@ class Daum8i extends comms_1.default {
|
|
|
248
249
|
return response;
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
|
-
throw new
|
|
252
|
+
throw new types_2.ResponseTimeout();
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
255
|
write(buffer, ackExpected = true) {
|
|
@@ -320,11 +321,11 @@ class Daum8i extends comms_1.default {
|
|
|
320
321
|
const str = yield this.sendStrCommand('getActualBikeType', 'M72');
|
|
321
322
|
let deviceType;
|
|
322
323
|
if (str === '0')
|
|
323
|
-
deviceType =
|
|
324
|
+
deviceType = types_1.ACTUAL_BIKE_TYPE.ALLROUND;
|
|
324
325
|
else if (str === '1')
|
|
325
|
-
deviceType =
|
|
326
|
+
deviceType = types_1.ACTUAL_BIKE_TYPE.RACE;
|
|
326
327
|
else if (str === '2')
|
|
327
|
-
deviceType =
|
|
328
|
+
deviceType = types_1.ACTUAL_BIKE_TYPE.MOUNTAIN;
|
|
328
329
|
else {
|
|
329
330
|
throw (new Error(`unknown actual device type ${typeof str === 'string' ? (0, utils_1.ascii)(str.charAt(0)) : str}`));
|
|
330
331
|
}
|
|
@@ -336,16 +337,16 @@ class Daum8i extends comms_1.default {
|
|
|
336
337
|
return __awaiter(this, void 0, void 0, function* () {
|
|
337
338
|
let bikeType;
|
|
338
339
|
switch (actualBikeType) {
|
|
339
|
-
case
|
|
340
|
+
case types_1.ACTUAL_BIKE_TYPE.ALLROUND:
|
|
340
341
|
bikeType = '0';
|
|
341
342
|
break;
|
|
342
|
-
case
|
|
343
|
+
case types_1.ACTUAL_BIKE_TYPE.RACE:
|
|
343
344
|
bikeType = '1';
|
|
344
345
|
break;
|
|
345
|
-
case
|
|
346
|
+
case types_1.ACTUAL_BIKE_TYPE.TRIATHLON:
|
|
346
347
|
bikeType = '1';
|
|
347
348
|
break;
|
|
348
|
-
case
|
|
349
|
+
case types_1.ACTUAL_BIKE_TYPE.MOUNTAIN:
|
|
349
350
|
bikeType = '2';
|
|
350
351
|
break;
|
|
351
352
|
default:
|
|
@@ -354,11 +355,11 @@ class Daum8i extends comms_1.default {
|
|
|
354
355
|
const str = yield this.sendStrCommand('setActualBikeType', `M72${bikeType}`);
|
|
355
356
|
let deviceType;
|
|
356
357
|
if (str === '0')
|
|
357
|
-
deviceType =
|
|
358
|
+
deviceType = types_1.ACTUAL_BIKE_TYPE.ALLROUND;
|
|
358
359
|
else if (str === '1')
|
|
359
|
-
deviceType =
|
|
360
|
+
deviceType = types_1.ACTUAL_BIKE_TYPE.RACE;
|
|
360
361
|
else if (str === '2')
|
|
361
|
-
deviceType =
|
|
362
|
+
deviceType = types_1.ACTUAL_BIKE_TYPE.MOUNTAIN;
|
|
362
363
|
else
|
|
363
364
|
throw (new Error('unknown actual device type'));
|
|
364
365
|
this.actualBikeType = deviceType;
|
|
@@ -462,7 +463,7 @@ class Daum8i extends comms_1.default {
|
|
|
462
463
|
const epp = route ? (0, utils_1.routeToEpp)(route) : undefined;
|
|
463
464
|
const eppLength = epp ? epp.length : 0;
|
|
464
465
|
const bikeTypeVal = (0, utils_1.getBikeType)(bikeType);
|
|
465
|
-
const wBits = route.lapMode ?
|
|
466
|
+
const wBits = route.lapMode ? consts_1.DS_BITS_ENDLESS_RACE : consts_1.DS_BITS_OFF;
|
|
466
467
|
payload.writeInt32LE(0, 0);
|
|
467
468
|
payload.writeInt8(bikeTypeVal, 4);
|
|
468
469
|
payload.writeInt8(0, 5);
|
|
@@ -492,7 +493,7 @@ class Daum8i extends comms_1.default {
|
|
|
492
493
|
const remaining = epp.length - offset;
|
|
493
494
|
if (remaining <= 0)
|
|
494
495
|
return Promise.resolve(true);
|
|
495
|
-
const size = remaining >
|
|
496
|
+
const size = remaining > consts_1.MAX_DATA_BLOCK_SIZE ? consts_1.MAX_DATA_BLOCK_SIZE : remaining;
|
|
496
497
|
const payload = Buffer.alloc(size + 8);
|
|
497
498
|
payload.writeInt32LE(size, 0);
|
|
498
499
|
payload.writeInt32LE(offset, 4);
|
|
@@ -553,7 +554,7 @@ class Daum8i extends comms_1.default {
|
|
|
553
554
|
done = true;
|
|
554
555
|
while (success && !done) {
|
|
555
556
|
success = yield this.programUploadSendBlock(epp, offset);
|
|
556
|
-
offset +=
|
|
557
|
+
offset += consts_1.MAX_DATA_BLOCK_SIZE;
|
|
557
558
|
done = offset >= epp.length;
|
|
558
559
|
if (onStatusUpdate)
|
|
559
560
|
onStatusUpdate(done ? epp.length : offset, epp.length);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
|
|
4
4
|
import { BindingInterface } from '@serialport/bindings-interface';
|
|
5
|
-
import { User } from '../../../types
|
|
5
|
+
import { User } from '../../../types';
|
|
6
6
|
export type MockProps = {
|
|
7
7
|
interface: string;
|
|
8
8
|
path: string;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Daum8iMockBinding = exports.parseProgramListNewData = exports.Daum8MockSimulator = exports.Daum8iMockImpl = exports.Daum8iMock = void 0;
|
|
13
13
|
const binding_mock_1 = require("@serialport/binding-mock");
|
|
14
14
|
const __1 = require("../../");
|
|
15
|
-
const
|
|
15
|
+
const types_1 = require("../../../types");
|
|
16
16
|
const utils_1 = require("../../../utils/utils");
|
|
17
17
|
const utils_2 = require("./utils");
|
|
18
18
|
const consts_1 = require("./consts");
|
|
@@ -99,7 +99,7 @@ class Daum8MockSimulator {
|
|
|
99
99
|
this.power = 0;
|
|
100
100
|
this.currentPower = 0;
|
|
101
101
|
this.loadControl = 1;
|
|
102
|
-
this.person = { weight: 75, length: 180, age: 30, sex:
|
|
102
|
+
this.person = { weight: 75, length: 180, age: 30, sex: types_1.Gender.MALE };
|
|
103
103
|
this.data = DEFAULT_TRAINING_DATA;
|
|
104
104
|
this.openHandles = [];
|
|
105
105
|
this._isSimulateACKTimeout = false;
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Route } from "../../../types/route";
|
|
1
|
+
import { DeviceProperties } from "../../../types";
|
|
3
2
|
import { Queue } from "../../../utils/utils";
|
|
4
|
-
import { Request, Response } from "../../comms";
|
|
3
|
+
import { Request, Response } from "../../base/comms";
|
|
4
|
+
export type Point = {
|
|
5
|
+
lat?: number;
|
|
6
|
+
lng?: number;
|
|
7
|
+
elevation?: number;
|
|
8
|
+
distance: number;
|
|
9
|
+
slope?: number;
|
|
10
|
+
};
|
|
11
|
+
export type Route = {
|
|
12
|
+
programId: number;
|
|
13
|
+
points: Point[];
|
|
14
|
+
type: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
lapMode: boolean;
|
|
18
|
+
totalDistance: number;
|
|
19
|
+
minElevation?: number;
|
|
20
|
+
maxElevation?: number;
|
|
21
|
+
sampleRate?: number;
|
|
22
|
+
};
|
|
23
|
+
export interface DaumPremiumDeviceProperties extends DeviceProperties {
|
|
24
|
+
route?: Route;
|
|
25
|
+
gear?: number;
|
|
26
|
+
onStatusUpdate?: OnDeviceStartCallback;
|
|
27
|
+
}
|
|
5
28
|
export declare class CheckSumError extends Error {
|
|
6
29
|
constructor();
|
|
7
30
|
}
|
|
@@ -11,21 +34,7 @@ export declare class ACKTimeout extends Error {
|
|
|
11
34
|
export declare class BusyTimeout extends Error {
|
|
12
35
|
constructor();
|
|
13
36
|
}
|
|
14
|
-
export declare class ResponseTimeout extends Error {
|
|
15
|
-
constructor();
|
|
16
|
-
}
|
|
17
|
-
export interface DaumPremiumBikeData extends DaumBikeData {
|
|
18
|
-
}
|
|
19
37
|
export type OnDeviceStartCallback = (completed: number, total: number) => void;
|
|
20
|
-
export type DaumPremiumAdapterProps = {
|
|
21
|
-
path: string;
|
|
22
|
-
ifaceName: string;
|
|
23
|
-
};
|
|
24
|
-
export interface Daum8iDeviceProperties extends DeviceProperties {
|
|
25
|
-
route?: Route;
|
|
26
|
-
gear?: number;
|
|
27
|
-
onStatusUpdate?: OnDeviceStartCallback;
|
|
28
|
-
}
|
|
29
38
|
export interface DaumPremiumRequest extends Request {
|
|
30
39
|
command: string;
|
|
31
40
|
payload?: string | Uint8Array;
|
|
@@ -44,3 +53,9 @@ export type DaumPremiumCommsState = {
|
|
|
44
53
|
partialCmd?: any;
|
|
45
54
|
data: Queue<ResponseObject>;
|
|
46
55
|
};
|
|
56
|
+
export declare enum ACTUAL_BIKE_TYPE {
|
|
57
|
+
ALLROUND = "allround",
|
|
58
|
+
RACE = "race",
|
|
59
|
+
MOUNTAIN = "mountain",
|
|
60
|
+
TRIATHLON = "triathlon"
|
|
61
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ACTUAL_BIKE_TYPE = exports.BusyTimeout = exports.ACKTimeout = exports.CheckSumError = void 0;
|
|
4
4
|
class CheckSumError extends Error {
|
|
5
5
|
constructor() {
|
|
6
6
|
super();
|
|
@@ -22,10 +22,10 @@ class BusyTimeout extends Error {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
exports.BusyTimeout = BusyTimeout;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
exports.
|
|
25
|
+
var ACTUAL_BIKE_TYPE;
|
|
26
|
+
(function (ACTUAL_BIKE_TYPE) {
|
|
27
|
+
ACTUAL_BIKE_TYPE["ALLROUND"] = "allround";
|
|
28
|
+
ACTUAL_BIKE_TYPE["RACE"] = "race";
|
|
29
|
+
ACTUAL_BIKE_TYPE["MOUNTAIN"] = "mountain";
|
|
30
|
+
ACTUAL_BIKE_TYPE["TRIATHLON"] = "triathlon";
|
|
31
|
+
})(ACTUAL_BIKE_TYPE || (exports.ACTUAL_BIKE_TYPE = ACTUAL_BIKE_TYPE = {}));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { IncyclistBikeData } from "
|
|
3
|
-
import { Route } from "
|
|
4
|
-
import { User } from "../../../types/user";
|
|
2
|
+
import { User, IncyclistBikeData } from "../../../types";
|
|
3
|
+
import { Route } from "./types";
|
|
5
4
|
export declare const DEBUG_LOGGER: {
|
|
6
5
|
log: (e: any, ...args: any[]) => void;
|
|
7
6
|
logEvent: (event: any) => void;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parsePersonData = exports.getPersonData = exports.parseTrainingData = exports.routeToEpp = exports.FileTimeSupport = exports.getBikeType = exports.BikeType = exports.ReservedCommands = exports.getAsciiArrayFromStr = exports.ascii = exports.hexstr = exports.getMessageData = exports.buildMessage = exports.checkSum = exports.esc2bin = exports.bin2esc = exports.validatePath = exports.validateHost = exports.responseLog = exports.DEBUG_LOGGER = void 0;
|
|
7
|
-
const
|
|
7
|
+
const types_1 = require("../../../types");
|
|
8
8
|
const win32filetime_1 = __importDefault(require("win32filetime"));
|
|
9
9
|
const sum = (arr) => arr.reduce((a, b) => a + b, 0);
|
|
10
10
|
exports.DEBUG_LOGGER = {
|
|
@@ -323,7 +323,7 @@ function getPersonData(user) {
|
|
|
323
323
|
buffer.writeUInt8(0, offset);
|
|
324
324
|
offset += 1;
|
|
325
325
|
}
|
|
326
|
-
buffer.writeInt32LE(user && user.sex ===
|
|
326
|
+
buffer.writeInt32LE(user && user.sex === types_1.Gender.FEMALE ? 2 : 1, offset);
|
|
327
327
|
offset += 4;
|
|
328
328
|
buffer.writeInt32LE(user && user.age !== undefined ? user.age : 1, offset);
|
|
329
329
|
offset += 4;
|
|
@@ -344,7 +344,7 @@ function parsePersonData(buffer) {
|
|
|
344
344
|
const length = buffer.readInt32LE(120);
|
|
345
345
|
const weight = buffer.readFloatLE(124);
|
|
346
346
|
const age = valAge > 1 ? valAge : undefined;
|
|
347
|
-
const sex = valSex === 2 ?
|
|
347
|
+
const sex = valSex === 2 ? types_1.Gender.FEMALE : types_1.Gender.MALE;
|
|
348
348
|
return { length, weight, age, sex };
|
|
349
349
|
}
|
|
350
350
|
exports.parsePersonData = parsePersonData;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare abstract class DaumSerialComms {
|
|
2
2
|
serial: any;
|
|
3
3
|
abstract getPort(): string;
|
|
4
4
|
abstract pauseLogging(): void;
|
|
@@ -9,3 +9,6 @@ export default abstract class DaumSerialComms {
|
|
|
9
9
|
abstract setTargetSlope(slope: number): Promise<void>;
|
|
10
10
|
abstract setTargetPower(power: number): Promise<void>;
|
|
11
11
|
}
|
|
12
|
+
export declare class ResponseTimeout extends Error {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
package/lib/serial/daum/types.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseTimeout = exports.DaumSerialComms = void 0;
|
|
3
4
|
class DaumSerialComms {
|
|
4
5
|
}
|
|
5
|
-
exports.
|
|
6
|
+
exports.DaumSerialComms = DaumSerialComms;
|
|
7
|
+
class ResponseTimeout extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.message = 'RESP timeout';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ResponseTimeout = ResponseTimeout;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DeviceProperties } from '../../types';
|
|
2
|
+
import { SerialIncyclistDevice } from '../base/adapter';
|
|
3
|
+
import { SerialDeviceSettings } from "../types";
|
|
4
|
+
export default class SerialAdapterFactory {
|
|
5
|
+
static _instance: SerialAdapterFactory;
|
|
6
|
+
adapters: Array<{
|
|
7
|
+
protocol: string;
|
|
8
|
+
AdapterClass: typeof SerialIncyclistDevice<DeviceProperties>;
|
|
9
|
+
}>;
|
|
10
|
+
static getInstance(): SerialAdapterFactory;
|
|
11
|
+
constructor();
|
|
12
|
+
registerAdapter(protocol: string, AdapterClass: typeof SerialIncyclistDevice<DeviceProperties>): void;
|
|
13
|
+
createInstance(props: SerialDeviceSettings, settings?: any): SerialIncyclistDevice<DeviceProperties>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class SerialAdapterFactory {
|
|
4
|
+
static getInstance() {
|
|
5
|
+
if (!SerialAdapterFactory._instance)
|
|
6
|
+
SerialAdapterFactory._instance = new SerialAdapterFactory();
|
|
7
|
+
return SerialAdapterFactory._instance;
|
|
8
|
+
}
|
|
9
|
+
constructor() {
|
|
10
|
+
this.adapters = [];
|
|
11
|
+
}
|
|
12
|
+
registerAdapter(protocol, AdapterClass) {
|
|
13
|
+
const existing = this.adapters.findIndex(a => a.protocol === protocol);
|
|
14
|
+
if (existing !== -1)
|
|
15
|
+
this.adapters[existing].AdapterClass = AdapterClass;
|
|
16
|
+
else
|
|
17
|
+
this.adapters.push({ protocol, AdapterClass });
|
|
18
|
+
}
|
|
19
|
+
createInstance(props, settings) {
|
|
20
|
+
const { protocol } = props;
|
|
21
|
+
if (!protocol)
|
|
22
|
+
return null;
|
|
23
|
+
const adapter = this.adapters.find(a => a.protocol === protocol);
|
|
24
|
+
if (!adapter)
|
|
25
|
+
return null;
|
|
26
|
+
const { AdapterClass } = adapter;
|
|
27
|
+
return new AdapterClass(props, settings);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = SerialAdapterFactory;
|
package/lib/serial/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import SerialPortProvider, { useSerialPortProvider } from './serialport';
|
|
2
|
-
import SerialInterface
|
|
3
|
-
import SerialAdapterFactory from './adapter-factory';
|
|
4
|
-
import { SerialIncyclistDevice, SerialDeviceSettings } from './adapter';
|
|
1
|
+
import SerialPortProvider, { useSerialPortProvider } from './base/serialport';
|
|
2
|
+
import SerialInterface from './base/serial-interface';
|
|
3
|
+
import SerialAdapterFactory from './factories/adapter-factory';
|
|
5
4
|
import DaumClassicAdapter from './daum/classic/adapter';
|
|
6
5
|
import DaumPremiumAdapter from './daum/premium/adapter';
|
|
7
6
|
import KettlerRacerAdapter from './kettler/ergo-racer/adapter';
|
|
7
|
+
export { SerialIncyclistDevice } from './base/adapter';
|
|
8
|
+
export { SerialInterfaceProps, SerialDeviceSettings, SerialScannerProps } from "./types";
|
|
8
9
|
export { TCPBinding } from './bindings/tcp';
|
|
9
|
-
export {
|
|
10
|
+
export { DaumPremiumDeviceProperties, Route, Point } from './daum/premium/types';
|
|
11
|
+
export { DaumClassicProperties } from './daum/classic/types';
|
|
12
|
+
export { SerialAdapterFactory, DaumClassicAdapter, DaumPremiumAdapter, KettlerRacerAdapter, SerialPortProvider, useSerialPortProvider, SerialInterface };
|
package/lib/serial/index.js
CHANGED
|
@@ -26,24 +26,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
const serialport_1 = __importStar(require("./serialport"));
|
|
29
|
+
exports.SerialInterface = exports.useSerialPortProvider = exports.SerialPortProvider = exports.KettlerRacerAdapter = exports.DaumPremiumAdapter = exports.DaumClassicAdapter = exports.SerialAdapterFactory = exports.TCPBinding = exports.SerialIncyclistDevice = void 0;
|
|
30
|
+
const serialport_1 = __importStar(require("./base/serialport"));
|
|
31
31
|
exports.SerialPortProvider = serialport_1.default;
|
|
32
32
|
Object.defineProperty(exports, "useSerialPortProvider", { enumerable: true, get: function () { return serialport_1.useSerialPortProvider; } });
|
|
33
|
-
const serial_interface_1 = __importDefault(require("./serial-interface"));
|
|
33
|
+
const serial_interface_1 = __importDefault(require("./base/serial-interface"));
|
|
34
34
|
exports.SerialInterface = serial_interface_1.default;
|
|
35
|
-
const adapter_factory_1 = __importDefault(require("./adapter-factory"));
|
|
35
|
+
const adapter_factory_1 = __importDefault(require("./factories/adapter-factory"));
|
|
36
36
|
exports.SerialAdapterFactory = adapter_factory_1.default;
|
|
37
|
-
const adapter_1 = require("./adapter");
|
|
38
|
-
|
|
39
|
-
const adapter_2 = __importDefault(require("./daum/
|
|
40
|
-
exports.
|
|
41
|
-
const adapter_3 = __importDefault(require("./
|
|
42
|
-
exports.
|
|
43
|
-
|
|
44
|
-
exports
|
|
37
|
+
const adapter_1 = __importDefault(require("./daum/classic/adapter"));
|
|
38
|
+
exports.DaumClassicAdapter = adapter_1.default;
|
|
39
|
+
const adapter_2 = __importDefault(require("./daum/premium/adapter"));
|
|
40
|
+
exports.DaumPremiumAdapter = adapter_2.default;
|
|
41
|
+
const adapter_3 = __importDefault(require("./kettler/ergo-racer/adapter"));
|
|
42
|
+
exports.KettlerRacerAdapter = adapter_3.default;
|
|
43
|
+
var adapter_4 = require("./base/adapter");
|
|
44
|
+
Object.defineProperty(exports, "SerialIncyclistDevice", { enumerable: true, get: function () { return adapter_4.SerialIncyclistDevice; } });
|
|
45
45
|
var tcp_1 = require("./bindings/tcp");
|
|
46
46
|
Object.defineProperty(exports, "TCPBinding", { enumerable: true, get: function () { return tcp_1.TCPBinding; } });
|
|
47
|
-
adapter_factory_1.default.getInstance().registerAdapter('Daum Classic',
|
|
48
|
-
adapter_factory_1.default.getInstance().registerAdapter('Daum Premium',
|
|
49
|
-
adapter_factory_1.default.getInstance().registerAdapter('Kettler Racer',
|
|
47
|
+
adapter_factory_1.default.getInstance().registerAdapter('Daum Classic', adapter_1.default);
|
|
48
|
+
adapter_factory_1.default.getInstance().registerAdapter('Daum Premium', adapter_2.default);
|
|
49
|
+
adapter_factory_1.default.getInstance().registerAdapter('Kettler Racer', adapter_3.default);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { EventLogger } from "gd-eventlog";
|
|
4
|
-
import { Command } from "
|
|
4
|
+
import { Command } from "./types";
|
|
5
5
|
import EventEmitter from "events";
|
|
6
6
|
import { SerialInterface } from "..";
|
|
7
7
|
export type SerialCommsProps = {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { DeviceProperties } from "../../../types/device";
|
|
2
1
|
import { EventLogger } from "gd-eventlog";
|
|
3
2
|
import SerialComms from "../comms";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import SerialInterface from "../../serial-interface";
|
|
9
|
-
import {
|
|
10
|
-
import { IncyclistDeviceAdapter } from "../../../types/adapter";
|
|
3
|
+
import { IncyclistBikeData } from "../../../types";
|
|
4
|
+
import { SerialDeviceSettings } from "../../types";
|
|
5
|
+
import { Command } from "../types";
|
|
6
|
+
import { SerialIncyclistDevice } from "../../base/adapter";
|
|
7
|
+
import SerialInterface from "../../base/serial-interface";
|
|
8
|
+
import { ControllerConfig, IAdapter, IncyclistAdapterData, DeviceProperties } from "../../../types";
|
|
11
9
|
export interface KettlerRacerCommand extends Command {
|
|
12
10
|
}
|
|
13
11
|
export interface KettlerExtendedBikeData {
|
|
@@ -23,28 +21,23 @@ export interface KettlerBikeData {
|
|
|
23
21
|
time: number;
|
|
24
22
|
power: number;
|
|
25
23
|
}
|
|
26
|
-
export
|
|
27
|
-
getSupportedCyclingModes(): Array<typeof CyclingMode>;
|
|
28
|
-
getDefaultCyclingMode(): ICyclingMode;
|
|
29
|
-
sendInitCommands(): Promise<boolean>;
|
|
30
|
-
}
|
|
31
|
-
export default class KettlerRacerAdapter extends SerialIncyclistDevice<KettlerControl<DeviceProperties>, DeviceProperties> {
|
|
24
|
+
export default class KettlerRacerAdapter extends SerialIncyclistDevice<DeviceProperties> {
|
|
32
25
|
private id;
|
|
33
26
|
private iv;
|
|
34
27
|
private requests;
|
|
35
|
-
private data;
|
|
36
28
|
private internalData;
|
|
37
29
|
private kettlerData;
|
|
38
30
|
private updateBusy;
|
|
39
31
|
private requestBusy;
|
|
40
32
|
private comms;
|
|
41
33
|
private prevDistance;
|
|
34
|
+
protected static ontrollers: ControllerConfig;
|
|
42
35
|
constructor(settings: SerialDeviceSettings, props?: DeviceProperties);
|
|
43
36
|
isBike(): boolean;
|
|
44
37
|
isPower(): boolean;
|
|
45
38
|
isHrm(): boolean;
|
|
46
39
|
getProtocolName(): string;
|
|
47
|
-
isSame(device:
|
|
40
|
+
isSame(device: IAdapter): boolean;
|
|
48
41
|
setID(id: any): void;
|
|
49
42
|
getID(): string;
|
|
50
43
|
getName(): string;
|
|
@@ -73,10 +66,10 @@ export default class KettlerRacerAdapter extends SerialIncyclistDevice<KettlerCo
|
|
|
73
66
|
check(): Promise<boolean>;
|
|
74
67
|
start(props?: any): Promise<boolean>;
|
|
75
68
|
startUpdatePull(): void;
|
|
76
|
-
|
|
69
|
+
canEmitData(): boolean;
|
|
77
70
|
stop(): Promise<boolean>;
|
|
78
71
|
mapData(bikeData: KettlerBikeData): IncyclistBikeData;
|
|
79
|
-
transformData(internalData: IncyclistBikeData, bikeData: KettlerBikeData):
|
|
72
|
+
transformData(internalData: IncyclistBikeData, bikeData: KettlerBikeData): IncyclistAdapterData;
|
|
80
73
|
update(): Promise<void>;
|
|
81
74
|
sendRequest(request: any): Promise<any>;
|
|
82
75
|
sendRequests(): Promise<void>;
|
|
@@ -12,30 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.KettlerControl = void 0;
|
|
16
15
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
17
16
|
const comms_1 = __importDefault(require("../comms"));
|
|
18
17
|
const utils_1 = require("../../../utils/utils");
|
|
19
18
|
const power_meter_1 = __importDefault(require("../../../modes/power-meter"));
|
|
20
19
|
const kettler_erg_1 = __importDefault(require("../../../modes/kettler-erg"));
|
|
21
|
-
const adapter_1 = require("../../adapter");
|
|
22
|
-
const
|
|
23
|
-
const adpater_1 = require("../../../base/adpater");
|
|
20
|
+
const adapter_1 = require("../../base/adapter");
|
|
21
|
+
const types_1 = require("../../../types");
|
|
24
22
|
const PROTOCOL_NAME = 'Kettler Racer';
|
|
25
|
-
class KettlerControl extends adpater_1.ControllableDevice {
|
|
26
|
-
getSupportedCyclingModes() {
|
|
27
|
-
return [power_meter_1.default, kettler_erg_1.default];
|
|
28
|
-
}
|
|
29
|
-
getDefaultCyclingMode() {
|
|
30
|
-
return new kettler_erg_1.default(this.adapter);
|
|
31
|
-
}
|
|
32
|
-
sendInitCommands() {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
return true;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.KettlerControl = KettlerControl;
|
|
39
23
|
class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
40
24
|
constructor(settings, props) {
|
|
41
25
|
super(settings, props);
|
|
@@ -45,8 +29,8 @@ class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
45
29
|
this.iv = null;
|
|
46
30
|
this.comms = new comms_1.default({ interface: settings.interface, port: settings.port, logger: this.logger });
|
|
47
31
|
this.capabilities = [
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
types_1.IncyclistCapability.Power, types_1.IncyclistCapability.Speed, types_1.IncyclistCapability.Cadence, types_1.IncyclistCapability.Gear, types_1.IncyclistCapability.HeartRate,
|
|
33
|
+
types_1.IncyclistCapability.Control
|
|
50
34
|
];
|
|
51
35
|
}
|
|
52
36
|
isBike() { return true; }
|
|
@@ -349,7 +333,7 @@ class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
349
333
|
update: ivUpdate
|
|
350
334
|
};
|
|
351
335
|
}
|
|
352
|
-
|
|
336
|
+
canEmitData() {
|
|
353
337
|
return !this.isPaused();
|
|
354
338
|
}
|
|
355
339
|
stop() {
|
|
@@ -583,4 +567,8 @@ class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
583
567
|
});
|
|
584
568
|
}
|
|
585
569
|
}
|
|
570
|
+
KettlerRacerAdapter.ontrollers = {
|
|
571
|
+
modes: [power_meter_1.default, kettler_erg_1.default],
|
|
572
|
+
default: kettler_erg_1.default
|
|
573
|
+
};
|
|
586
574
|
exports.default = KettlerRacerAdapter;
|
|
@@ -3,39 +3,9 @@
|
|
|
3
3
|
import EventEmitter from "events";
|
|
4
4
|
import { BindingInterface } from "@serialport/bindings-interface";
|
|
5
5
|
import { SerialPortStream } from '@serialport/stream';
|
|
6
|
-
import { SerialDeviceSettings } from
|
|
6
|
+
import { SerialDeviceSettings, SerialScannerProps, PortMapping, SerialInterfaceProps } from "./types";
|
|
7
|
+
import { IncyclistInterface } from "../types";
|
|
7
8
|
import { EventLogger } from "gd-eventlog";
|
|
8
|
-
import { IncyclistScanProps } from "../types/device";
|
|
9
|
-
import { IncyclistInterface, InterfaceProps } from "../types/interface";
|
|
10
|
-
export declare const SerialInterfaceType: {
|
|
11
|
-
SERIAL: string;
|
|
12
|
-
TCPIP: string;
|
|
13
|
-
};
|
|
14
|
-
export interface SerialInterfaceProps extends InterfaceProps {
|
|
15
|
-
ifaceName: string;
|
|
16
|
-
binding?: BindingInterface;
|
|
17
|
-
}
|
|
18
|
-
export type PortMapping = {
|
|
19
|
-
path: string;
|
|
20
|
-
port: SerialPortStream;
|
|
21
|
-
};
|
|
22
|
-
export interface SerialScannerProps extends IncyclistScanProps {
|
|
23
|
-
port?: string;
|
|
24
|
-
protocol: string;
|
|
25
|
-
}
|
|
26
|
-
export declare class SinglePathScanner {
|
|
27
|
-
path: string;
|
|
28
|
-
serial: SerialInterface;
|
|
29
|
-
result: SerialDeviceSettings;
|
|
30
|
-
isScanning: boolean;
|
|
31
|
-
props: SerialScannerProps;
|
|
32
|
-
logger: EventLogger;
|
|
33
|
-
isFound: boolean;
|
|
34
|
-
constructor(path: string, serial: SerialInterface, props: SerialScannerProps);
|
|
35
|
-
logEvent(event: any): void;
|
|
36
|
-
onStopRequest(resolve: any): Promise<void>;
|
|
37
|
-
scan(): Promise<SerialDeviceSettings | undefined>;
|
|
38
|
-
}
|
|
39
9
|
export default class SerialInterface extends EventEmitter implements IncyclistInterface {
|
|
40
10
|
ifaceName: string;
|
|
41
11
|
binding: BindingInterface;
|