incyclist-devices 1.5.38 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +238 -0
- package/lib/adapters.d.ts +7 -0
- package/lib/adapters.js +49 -0
- package/lib/antv2/adapter-factory.d.ts +21 -10
- package/lib/antv2/adapter-factory.js +51 -33
- package/lib/antv2/adapter.d.ts +65 -0
- package/lib/antv2/adapter.js +310 -0
- package/lib/antv2/ant-interface.d.ts +17 -11
- package/lib/antv2/ant-interface.js +41 -31
- package/lib/antv2/{ant-binding.d.ts → binding.d.ts} +1 -1
- package/lib/antv2/{ant-binding.js → binding.js} +1 -1
- package/lib/antv2/fe/adapter.d.ts +28 -0
- package/lib/antv2/{fe.js → fe/adapter.js} +106 -90
- package/lib/antv2/fe/index.d.ts +2 -0
- package/lib/antv2/fe/index.js +7 -0
- package/lib/antv2/hr/adapter.d.ts +15 -0
- package/lib/antv2/hr/adapter.js +76 -0
- package/lib/antv2/hr/index.d.ts +2 -0
- package/lib/antv2/hr/index.js +7 -0
- package/lib/antv2/index.d.ts +7 -0
- package/lib/antv2/index.js +20 -0
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +9 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-adv-st-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +6 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-erg-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +5 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-st-mode.js +1 -1
- package/lib/antv2/pwr/adapter.d.ts +24 -0
- package/lib/antv2/pwr/adapter.js +141 -0
- package/lib/antv2/pwr/index.d.ts +2 -0
- package/lib/antv2/pwr/index.js +7 -0
- package/lib/antv2/sensor-factory.d.ts +2 -2
- package/lib/antv2/types.d.ts +22 -0
- package/lib/antv2/types.js +5 -0
- package/lib/antv2/utils.d.ts +4 -0
- package/lib/antv2/utils.js +192 -0
- package/lib/base/adpater.d.ts +68 -0
- package/lib/base/adpater.js +183 -0
- package/lib/ble/adapter-factory.d.ts +33 -0
- package/lib/ble/adapter-factory.js +105 -0
- package/lib/ble/base/adapter.d.ts +53 -0
- package/lib/ble/base/adapter.js +290 -0
- package/lib/ble/base/comms-utils.d.ts +7 -0
- package/lib/ble/base/comms-utils.js +91 -0
- package/lib/ble/{ble-device.d.ts → base/comms.d.ts} +31 -16
- package/lib/ble/{ble-device.js → base/comms.js} +193 -55
- package/lib/ble/bindings/index.d.ts +2 -0
- package/lib/ble/bindings/index.js +8 -0
- package/lib/ble/bindings/linux.d.ts +15 -0
- package/lib/ble/bindings/linux.js +39 -0
- package/lib/ble/bindings/mock.d.ts +9 -0
- package/lib/ble/bindings/mock.js +108 -0
- package/lib/ble/bindings/types.d.ts +57 -0
- package/lib/ble/bindings/types.js +96 -0
- package/lib/ble/ble-interface.d.ts +38 -59
- package/lib/ble/ble-interface.js +254 -462
- package/lib/ble/ble-peripheral.d.ts +7 -5
- package/lib/ble/ble-peripheral.js +52 -21
- package/lib/ble/consts.d.ts +3 -0
- package/lib/ble/consts.js +4 -1
- package/lib/ble/cp/adapter.d.ts +22 -0
- package/lib/ble/cp/adapter.js +111 -0
- package/lib/ble/cp/comm.d.ts +31 -0
- package/lib/ble/cp/comm.js +125 -0
- package/lib/ble/cp/index.d.ts +4 -0
- package/lib/ble/cp/index.js +10 -0
- package/lib/ble/cp/types.d.ts +13 -0
- package/lib/ble/cp/types.js +2 -0
- package/lib/ble/elite/adapter.d.ts +19 -0
- package/lib/ble/elite/adapter.js +120 -0
- package/lib/ble/elite/comms.d.ts +32 -0
- package/lib/ble/elite/comms.js +126 -0
- package/lib/ble/elite/index.d.ts +3 -0
- package/lib/ble/elite/index.js +10 -0
- package/lib/ble/fm/adapter.d.ts +22 -0
- package/lib/ble/fm/adapter.js +249 -0
- package/lib/ble/fm/comms.d.ts +50 -0
- package/lib/ble/{fm.js → fm/comms.js} +34 -277
- package/lib/ble/fm/consts.d.ts +6 -0
- package/lib/ble/fm/consts.js +9 -0
- package/lib/ble/fm/index.d.ts +5 -0
- package/lib/ble/fm/index.js +13 -0
- package/lib/ble/fm/types.d.ts +30 -0
- package/lib/ble/fm/types.js +2 -0
- package/lib/ble/hr/adapter.d.ts +14 -0
- package/lib/ble/hr/adapter.js +45 -0
- package/lib/ble/hr/comm.d.ts +19 -0
- package/lib/ble/hr/comm.js +56 -0
- package/lib/ble/hr/index.d.ts +4 -0
- package/lib/ble/hr/index.js +10 -0
- package/lib/ble/hr/mock.d.ts +7 -0
- package/lib/ble/hr/mock.js +47 -0
- package/lib/ble/hr/types.d.ts +5 -0
- package/lib/ble/hr/types.js +2 -0
- package/lib/ble/index.d.ts +9 -0
- package/lib/ble/index.js +26 -0
- package/lib/ble/peripheral-cache.d.ts +43 -0
- package/lib/ble/peripheral-cache.js +107 -0
- package/lib/ble/tacx/adapter.d.ts +10 -0
- package/lib/ble/tacx/adapter.js +99 -0
- package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +11 -43
- package/lib/ble/{tacx.js → tacx/comms.js} +23 -155
- package/lib/ble/tacx/index.d.ts +4 -0
- package/lib/ble/tacx/index.js +10 -0
- package/lib/ble/tacx/types.d.ts +25 -0
- package/lib/ble/tacx/types.js +2 -0
- package/lib/ble/types.d.ts +128 -0
- package/lib/ble/types.js +2 -0
- package/lib/ble/utils.d.ts +17 -0
- package/lib/ble/utils.js +54 -0
- package/lib/ble/wahoo/adapter.d.ts +9 -0
- package/lib/ble/wahoo/adapter.js +95 -0
- package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +11 -44
- package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +29 -129
- package/lib/ble/wahoo/index.d.ts +4 -0
- package/lib/ble/wahoo/index.js +10 -0
- package/lib/ble/wahoo/types.d.ts +19 -0
- package/lib/ble/wahoo/types.js +2 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +34 -0
- package/lib/interfaces.d.ts +7 -0
- package/lib/interfaces.js +27 -0
- package/lib/{ble → modes}/ble-erg-mode.d.ts +4 -4
- package/lib/{ble → modes}/ble-erg-mode.js +2 -2
- package/lib/{ble → modes}/ble-st-mode.d.ts +3 -3
- package/lib/{ble → modes}/ble-st-mode.js +1 -1
- package/lib/{cycling-mode.d.ts → modes/cycling-mode.d.ts} +8 -8
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +8 -4
- package/lib/modes/power-meter.d.ts +3 -3
- package/lib/modes/simulator.d.ts +2 -2
- package/lib/modes/simulator.js +1 -1
- package/lib/serial/adapter-factory.d.ts +12 -0
- package/lib/serial/adapter-factory.js +30 -0
- package/lib/serial/adapter.d.ts +21 -0
- package/lib/serial/adapter.js +61 -0
- package/lib/serial/bindings/tcp.d.ts +45 -0
- package/lib/serial/bindings/tcp.js +284 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/{daum → serial/daum}/DaumAdapter.d.ts +14 -23
- package/lib/{daum → serial/daum}/DaumAdapter.js +57 -97
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.d.ts +2 -2
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.js +1 -1
- package/lib/{daum → serial/daum}/ERGCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/ERGCyclingMode.js +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.js +4 -3
- package/lib/serial/daum/classic/adapter.d.ts +29 -0
- package/lib/{daum/classic/DaumClassicAdapter.js → serial/daum/classic/adapter.js} +77 -50
- package/lib/{daum/classic/bike.d.ts → serial/daum/classic/comms.d.ts} +14 -16
- package/lib/{daum/classic/bike.js → serial/daum/classic/comms.js} +68 -152
- package/lib/serial/daum/classic/mock.d.ts +96 -0
- package/lib/serial/daum/classic/mock.js +365 -0
- package/lib/{daum/classic/DaumClassicCyclingMode.d.ts → serial/daum/classic/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/classic/DaumClassicCyclingMode.js → serial/daum/classic/modes/daum-classic.js} +2 -2
- package/lib/{daum → serial/daum}/classic/utils.d.ts +1 -1
- package/lib/serial/daum/premium/adapter.d.ts +25 -0
- package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +107 -47
- package/lib/{daum/premium/bike.d.ts → serial/daum/premium/comms.d.ts} +26 -54
- package/lib/{daum/premium/bike.js → serial/daum/premium/comms.js} +215 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +289 -0
- package/lib/{daum/premium/DaumClassicCyclingMode.d.ts → serial/daum/premium/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/premium/DaumClassicCyclingMode.js → serial/daum/premium/modes/daum-classic.js} +2 -2
- package/lib/serial/daum/premium/types.d.ts +12 -0
- package/lib/serial/daum/premium/types.js +2 -0
- package/lib/{daum → serial/daum}/premium/utils.d.ts +8 -11
- package/lib/{daum → serial/daum}/premium/utils.js +22 -63
- package/lib/serial/index.d.ts +9 -0
- package/lib/serial/index.js +49 -0
- package/lib/{kettler → serial/kettler}/comms.d.ts +8 -6
- package/lib/{kettler → serial/kettler}/comms.js +71 -32
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.d.ts +14 -28
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +102 -169
- package/lib/serial/kettler/ergo-racer/mock.d.ts +66 -0
- package/lib/serial/kettler/ergo-racer/mock.js +216 -0
- package/lib/{kettler/ergo-racer/ERGCyclingMode.d.ts → serial/kettler/ergo-racer/modes/erg.d.ts} +4 -4
- package/lib/{kettler/ergo-racer/ERGCyclingMode.js → serial/kettler/ergo-racer/modes/erg.js} +2 -2
- package/lib/serial/serial-interface.d.ts +60 -0
- package/lib/serial/serial-interface.js +309 -0
- package/lib/simulator/Simulator.d.ts +12 -25
- package/lib/simulator/Simulator.js +26 -87
- package/lib/types/adapter.d.ts +39 -0
- package/lib/types/adapter.js +2 -0
- package/lib/types/capabilities.d.ts +8 -0
- package/lib/types/capabilities.js +12 -0
- package/lib/types/data.d.ts +12 -0
- package/lib/types/data.js +2 -0
- package/lib/types/device.d.ts +32 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +18 -0
- package/lib/types/interface.js +2 -0
- package/lib/types/route.d.ts +2 -2
- package/lib/types/user.d.ts +1 -1
- package/lib/{utils.d.ts → utils/utils.d.ts} +1 -0
- package/lib/{utils.js → utils/utils.js} +5 -1
- package/package.json +16 -14
- package/lib/DeviceSupport.d.ts +0 -36
- package/lib/DeviceSupport.js +0 -82
- package/lib/ant/AntAdapter.d.ts +0 -50
- package/lib/ant/AntAdapter.js +0 -109
- package/lib/ant/AntScanner.d.ts +0 -60
- package/lib/ant/AntScanner.js +0 -651
- package/lib/ant/antfe/AntFEAdapter.d.ts +0 -83
- package/lib/ant/antfe/AntFEAdapter.js +0 -652
- package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/ant/antfe/ant-fe-erg-mode.d.ts +0 -6
- package/lib/ant/antfe/ant-fe-st-mode.d.ts +0 -5
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +0 -16
- package/lib/ant/anthrm/AntHrmAdapter.js +0 -130
- package/lib/ant/antpwr/pwr-adapter.d.ts +0 -49
- package/lib/ant/antpwr/pwr-adapter.js +0 -251
- package/lib/ant/utils.d.ts +0 -1
- package/lib/ant/utils.js +0 -23
- package/lib/antv2/AntAdapter.d.ts +0 -48
- package/lib/antv2/AntAdapter.js +0 -104
- package/lib/antv2/ant-device.d.ts +0 -59
- package/lib/antv2/ant-device.js +0 -161
- package/lib/antv2/fe.d.ts +0 -32
- package/lib/antv2/hr.d.ts +0 -18
- package/lib/antv2/hr.js +0 -102
- package/lib/antv2/incyclist-protocol.d.ts +0 -37
- package/lib/antv2/incyclist-protocol.js +0 -126
- package/lib/antv2/pwr.d.ts +0 -28
- package/lib/antv2/pwr.js +0 -171
- package/lib/ble/ble.d.ts +0 -129
- package/lib/ble/ble.js +0 -86
- package/lib/ble/elite.d.ts +0 -90
- package/lib/ble/elite.js +0 -322
- package/lib/ble/fm.d.ts +0 -125
- package/lib/ble/hrm.d.ts +0 -48
- package/lib/ble/hrm.js +0 -134
- package/lib/ble/incyclist-protocol.d.ts +0 -31
- package/lib/ble/incyclist-protocol.js +0 -153
- package/lib/ble/pwr.d.ts +0 -89
- package/lib/ble/pwr.js +0 -322
- package/lib/daum/classic/DaumClassicAdapter.d.ts +0 -28
- package/lib/daum/classic/DaumClassicProtocol.d.ts +0 -27
- package/lib/daum/classic/DaumClassicProtocol.js +0 -185
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +0 -16
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +0 -32
- package/lib/daum/premium/DaumPremiumProtocol.js +0 -207
- package/lib/daum/premium/tcpserial.d.ts +0 -33
- package/lib/daum/premium/tcpserial.js +0 -123
- package/lib/device.d.ts +0 -94
- package/lib/device.js +0 -76
- package/lib/kettler/ergo-racer/protocol.d.ts +0 -41
- package/lib/kettler/ergo-racer/protocol.js +0 -203
- package/lib/protocol.d.ts +0 -74
- package/lib/protocol.js +0 -41
- package/lib/registry.d.ts +0 -8
- package/lib/registry.js +0 -33
- package/lib/serialport/bindings/tcp.d.ts +0 -20
- package/lib/serialport/bindings/tcp.js +0 -33
- package/lib/serialport/index.d.ts +0 -2
- package/lib/serialport/index.js +0 -29
- package/lib/serialport/serialport.d.ts +0 -29
- package/lib/serialport/serialport.js +0 -87
- /package/lib/{cycling-mode.js → modes/cycling-mode.js} +0 -0
- /package/lib/{daum → serial/daum}/classic/utils.js +0 -0
- /package/lib/{daum → serial/daum}/constants.d.ts +0 -0
- /package/lib/{daum → serial/daum}/constants.js +0 -0
- /package/lib/{serialport.d.ts → serial/serialport.d.ts} +0 -0
- /package/lib/{serialport.js → serial/serialport.js} +0 -0
- /package/lib/{calculations.d.ts → utils/calculations.d.ts} +0 -0
- /package/lib/{calculations.js → utils/calculations.js} +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
|
|
3
|
+
import { BindingInterface, PortInfo } from '@serialport/bindings-interface';
|
|
4
|
+
import { User } from '../../../types/user';
|
|
5
|
+
export type MockProps = {
|
|
6
|
+
interface: string;
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
export interface Daum8iMockBindingInterface extends BindingInterface<Daum8iMockBinding> {
|
|
10
|
+
reset(): void;
|
|
11
|
+
createPort(path: string, opt?: CreatePortOptions): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const Daum8iMock: MockBindingInterface;
|
|
14
|
+
export declare class Daum8iMockImpl {
|
|
15
|
+
static _instance: Daum8iMockImpl;
|
|
16
|
+
static getInstance(): Daum8iMockImpl;
|
|
17
|
+
static reset(): void;
|
|
18
|
+
simulators: Map<string, Daum8MockSimulator>;
|
|
19
|
+
ports: {
|
|
20
|
+
path: string;
|
|
21
|
+
binding: Daum8iMockBinding;
|
|
22
|
+
}[];
|
|
23
|
+
constructor();
|
|
24
|
+
setSimulator(path: string, simulator: Daum8MockSimulator): void;
|
|
25
|
+
getSimulator(path: any): Daum8MockSimulator;
|
|
26
|
+
reset(): void;
|
|
27
|
+
createPort(path: string, options?: CreatePortOptions): void;
|
|
28
|
+
list(): Promise<PortInfo[]>;
|
|
29
|
+
open(options: any): Promise<Daum8iMockBinding>;
|
|
30
|
+
}
|
|
31
|
+
export declare class Daum8MockSimulator {
|
|
32
|
+
protoVersion: string;
|
|
33
|
+
dashboardVersion: string;
|
|
34
|
+
deviceType: number;
|
|
35
|
+
actualType: number;
|
|
36
|
+
gear: number;
|
|
37
|
+
power: number;
|
|
38
|
+
currentPower: number;
|
|
39
|
+
loadControl: number;
|
|
40
|
+
person: User;
|
|
41
|
+
_isSimulateACKTimeout: boolean;
|
|
42
|
+
_isSimulateCheckSumError: boolean;
|
|
43
|
+
_timeoutResponse: number;
|
|
44
|
+
timeoutNAKRetry: number;
|
|
45
|
+
simulateACKTimeout(): void;
|
|
46
|
+
simulateTimeout(ms: number): void;
|
|
47
|
+
simulateChecksumError(): void;
|
|
48
|
+
onNAK(): void;
|
|
49
|
+
onACK(): void;
|
|
50
|
+
}
|
|
51
|
+
export declare class Daum8iMockBinding extends MockPortBinding {
|
|
52
|
+
waitingForCommand: boolean;
|
|
53
|
+
waitingForAck: boolean;
|
|
54
|
+
prevCommand: Buffer;
|
|
55
|
+
simulator: Daum8MockSimulator;
|
|
56
|
+
handlers: Map<string, (payload: Buffer) => void>;
|
|
57
|
+
constructor(parent: MockPortBinding);
|
|
58
|
+
getPath(): string;
|
|
59
|
+
initHandlers(): void;
|
|
60
|
+
write(buffer: Buffer): Promise<void>;
|
|
61
|
+
processData(buffer: Buffer): Promise<void>;
|
|
62
|
+
createResponse(cmd: string, payload: Buffer): Buffer;
|
|
63
|
+
emitData(data: string | Buffer): void;
|
|
64
|
+
onGetProtcolVersion(_payload: Buffer): void;
|
|
65
|
+
onGetDashboardVersion(_payload: Buffer): void;
|
|
66
|
+
onGetDeviceType(_payload: Buffer): void;
|
|
67
|
+
onActualDeviceType(payload: Buffer): void;
|
|
68
|
+
onLoadControl(payload: Buffer): void;
|
|
69
|
+
onGear(payload: Buffer): void;
|
|
70
|
+
onPower(payload: Buffer): void;
|
|
71
|
+
onReservedCommand(payload: Buffer): void;
|
|
72
|
+
onPersonSet(payload: Buffer): void;
|
|
73
|
+
onPersonGet(): void;
|
|
74
|
+
onGetTrainingData(_payload: Buffer): void;
|
|
75
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Daum8iMockBinding = exports.Daum8MockSimulator = exports.Daum8iMockImpl = exports.Daum8iMock = void 0;
|
|
13
|
+
const binding_mock_1 = require("@serialport/binding-mock");
|
|
14
|
+
const __1 = require("../../");
|
|
15
|
+
const user_1 = require("../../../types/user");
|
|
16
|
+
const utils_1 = require("../../../utils/utils");
|
|
17
|
+
const utils_2 = require("./utils");
|
|
18
|
+
exports.Daum8iMock = {
|
|
19
|
+
reset() {
|
|
20
|
+
Daum8iMockImpl.getInstance().reset();
|
|
21
|
+
},
|
|
22
|
+
createPort(path, options = {}) {
|
|
23
|
+
return Daum8iMockImpl.getInstance().createPort(path, options);
|
|
24
|
+
},
|
|
25
|
+
list() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return Daum8iMockImpl.getInstance().list();
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
open(options) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
return Daum8iMockImpl.getInstance().open(options);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
class Daum8iMockImpl {
|
|
37
|
+
static getInstance() {
|
|
38
|
+
if (!Daum8iMockImpl._instance)
|
|
39
|
+
Daum8iMockImpl._instance = new Daum8iMockImpl();
|
|
40
|
+
return Daum8iMockImpl._instance;
|
|
41
|
+
}
|
|
42
|
+
static reset() {
|
|
43
|
+
Daum8iMockImpl._instance = undefined;
|
|
44
|
+
__1.SerialPortProvider._instance = undefined;
|
|
45
|
+
__1.SerialInterface._instances = [];
|
|
46
|
+
}
|
|
47
|
+
constructor() {
|
|
48
|
+
this.simulators = new Map();
|
|
49
|
+
this.ports = [];
|
|
50
|
+
}
|
|
51
|
+
setSimulator(path, simulator) {
|
|
52
|
+
this.simulators.set(path, simulator);
|
|
53
|
+
}
|
|
54
|
+
getSimulator(path) {
|
|
55
|
+
return this.simulators.get(path);
|
|
56
|
+
}
|
|
57
|
+
reset() {
|
|
58
|
+
binding_mock_1.MockBinding.reset();
|
|
59
|
+
}
|
|
60
|
+
createPort(path, options = {}) {
|
|
61
|
+
return binding_mock_1.MockBinding.createPort(path, options);
|
|
62
|
+
}
|
|
63
|
+
list() {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
return binding_mock_1.MockBinding.list();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
open(options) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const port = yield binding_mock_1.MockBinding.open(options);
|
|
71
|
+
return new Daum8iMockBinding(port);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.Daum8iMockImpl = Daum8iMockImpl;
|
|
76
|
+
class Daum8MockSimulator {
|
|
77
|
+
constructor() {
|
|
78
|
+
this.protoVersion = '201';
|
|
79
|
+
this.dashboardVersion = 'Version 1.380';
|
|
80
|
+
this.deviceType = 0;
|
|
81
|
+
this.actualType = 0;
|
|
82
|
+
this.gear = 10;
|
|
83
|
+
this.power = 0;
|
|
84
|
+
this.currentPower = 0;
|
|
85
|
+
this.loadControl = 1;
|
|
86
|
+
this.person = { weight: 75, length: 180, age: 30, sex: user_1.Gender.MALE };
|
|
87
|
+
this._isSimulateACKTimeout = false;
|
|
88
|
+
this._isSimulateCheckSumError = false;
|
|
89
|
+
this._timeoutResponse = 0;
|
|
90
|
+
this.timeoutNAKRetry = 1000;
|
|
91
|
+
}
|
|
92
|
+
simulateACKTimeout() {
|
|
93
|
+
this._isSimulateACKTimeout = true;
|
|
94
|
+
}
|
|
95
|
+
simulateTimeout(ms) {
|
|
96
|
+
this._timeoutResponse = ms;
|
|
97
|
+
}
|
|
98
|
+
simulateChecksumError() {
|
|
99
|
+
this._isSimulateCheckSumError = true;
|
|
100
|
+
}
|
|
101
|
+
onNAK() { }
|
|
102
|
+
onACK() { }
|
|
103
|
+
}
|
|
104
|
+
exports.Daum8MockSimulator = Daum8MockSimulator;
|
|
105
|
+
class Daum8iMockBinding extends binding_mock_1.MockPortBinding {
|
|
106
|
+
constructor(parent) {
|
|
107
|
+
super(parent.port, parent.openOptions);
|
|
108
|
+
this.waitingForAck = false;
|
|
109
|
+
this.waitingForCommand = true;
|
|
110
|
+
this.prevCommand = null;
|
|
111
|
+
this.simulator = Daum8iMockImpl.getInstance().getSimulator(this.getPath());
|
|
112
|
+
if (!this.simulator) {
|
|
113
|
+
this.simulator = new Daum8MockSimulator();
|
|
114
|
+
Daum8iMockImpl.getInstance().setSimulator(this.getPath(), this.simulator);
|
|
115
|
+
}
|
|
116
|
+
this.initHandlers();
|
|
117
|
+
}
|
|
118
|
+
getPath() {
|
|
119
|
+
return this.port.info.path;
|
|
120
|
+
}
|
|
121
|
+
initHandlers() {
|
|
122
|
+
this.handlers = new Map();
|
|
123
|
+
this.handlers.set('V00', this.onGetProtcolVersion.bind(this));
|
|
124
|
+
this.handlers.set('V70', this.onGetDashboardVersion.bind(this));
|
|
125
|
+
this.handlers.set('Y00', this.onGetDeviceType.bind(this));
|
|
126
|
+
this.handlers.set('M72', this.onActualDeviceType.bind(this));
|
|
127
|
+
this.handlers.set('M71', this.onGear.bind(this));
|
|
128
|
+
this.handlers.set('S20', this.onLoadControl.bind(this));
|
|
129
|
+
this.handlers.set('S23', this.onPower.bind(this));
|
|
130
|
+
this.handlers.set('M70', this.onReservedCommand.bind(this));
|
|
131
|
+
this.handlers.set('X70', this.onGetTrainingData.bind(this));
|
|
132
|
+
}
|
|
133
|
+
write(buffer) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
136
|
+
throw new TypeError('"buffer" is not a Buffer');
|
|
137
|
+
}
|
|
138
|
+
if (!this.isOpen || !this.port) {
|
|
139
|
+
throw new Error('Port is not open');
|
|
140
|
+
}
|
|
141
|
+
if (this.writeOperation) {
|
|
142
|
+
throw new Error('Overlapping writes are not supported and should be queued by the serialport object');
|
|
143
|
+
}
|
|
144
|
+
this.writeOperation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
yield (0, utils_1.resolveNextTick)();
|
|
146
|
+
if (!this.isOpen || !this.port) {
|
|
147
|
+
throw new Error('Write canceled');
|
|
148
|
+
}
|
|
149
|
+
if (this.simulator._isSimulateACKTimeout) {
|
|
150
|
+
this.simulator._isSimulateACKTimeout = false;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
setTimeout(() => { this.processData(buffer); }, 5);
|
|
154
|
+
}
|
|
155
|
+
this.writeOperation = null;
|
|
156
|
+
}))();
|
|
157
|
+
return this.writeOperation;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
processData(buffer) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
if (this.waitingForCommand) {
|
|
163
|
+
try {
|
|
164
|
+
const str = buffer.toString('hex');
|
|
165
|
+
if (str.startsWith('01') && str.endsWith('17')) {
|
|
166
|
+
const cmd = buffer.subarray(1, 4).toString();
|
|
167
|
+
const payload = buffer.subarray(4, buffer.length - 3);
|
|
168
|
+
const checksumVal = buffer.subarray(buffer.length - 3, buffer.length - 1).toString();
|
|
169
|
+
const check = (0, utils_2.checkSum)(buffer.subarray(1, 4), payload);
|
|
170
|
+
const handler = this.handlers.get(cmd);
|
|
171
|
+
if (checksumVal === check && handler) {
|
|
172
|
+
this.emitData(Buffer.from([0x06]));
|
|
173
|
+
this.waitingForCommand = true;
|
|
174
|
+
const to = this.simulator._timeoutResponse;
|
|
175
|
+
if (to) {
|
|
176
|
+
yield (0, utils_1.sleep)(to);
|
|
177
|
+
this.simulator._timeoutResponse = 0;
|
|
178
|
+
}
|
|
179
|
+
handler(payload);
|
|
180
|
+
this.waitingForCommand = false;
|
|
181
|
+
this.waitingForAck = true;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.emitData(Buffer.from([0x15]));
|
|
185
|
+
this.waitingForAck = false;
|
|
186
|
+
this.waitingForCommand = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
this.emitData(Buffer.from([0x15]));
|
|
191
|
+
this.waitingForAck = false;
|
|
192
|
+
this.waitingForCommand = true;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (this.waitingForAck) {
|
|
199
|
+
const c = buffer.readUInt8(0);
|
|
200
|
+
if (c === 0x06) {
|
|
201
|
+
this.simulator.onACK();
|
|
202
|
+
this.waitingForAck = false;
|
|
203
|
+
this.waitingForCommand = true;
|
|
204
|
+
this.prevCommand = null;
|
|
205
|
+
}
|
|
206
|
+
else if (c === 0x15) {
|
|
207
|
+
this.simulator.onNAK();
|
|
208
|
+
if (this.prevCommand) {
|
|
209
|
+
const to = this.simulator.timeoutNAKRetry || 1000;
|
|
210
|
+
setTimeout(() => {
|
|
211
|
+
this.emitData(this.prevCommand);
|
|
212
|
+
this.waitingForCommand = false;
|
|
213
|
+
this.waitingForAck = true;
|
|
214
|
+
}, to);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
createResponse(cmd, payload) {
|
|
221
|
+
const buffer = Buffer.from((0, utils_2.buildMessage)(cmd, payload));
|
|
222
|
+
this.prevCommand = Buffer.from(buffer);
|
|
223
|
+
if (this.simulator._isSimulateCheckSumError) {
|
|
224
|
+
this.simulator._isSimulateCheckSumError = false;
|
|
225
|
+
buffer[buffer.length - 2] = buffer[buffer.length - 2] - 1;
|
|
226
|
+
}
|
|
227
|
+
return buffer;
|
|
228
|
+
}
|
|
229
|
+
emitData(data) {
|
|
230
|
+
if (!this.isOpen || !this.port)
|
|
231
|
+
return;
|
|
232
|
+
super.emitData(data);
|
|
233
|
+
}
|
|
234
|
+
onGetProtcolVersion(_payload) {
|
|
235
|
+
this.emitData(this.createResponse('V00', Buffer.from(this.simulator.protoVersion)));
|
|
236
|
+
}
|
|
237
|
+
onGetDashboardVersion(_payload) {
|
|
238
|
+
this.emitData(this.createResponse('V70', Buffer.from(this.simulator.dashboardVersion)));
|
|
239
|
+
}
|
|
240
|
+
onGetDeviceType(_payload) {
|
|
241
|
+
this.emitData(this.createResponse('Y00', Buffer.from(this.simulator.deviceType.toString())));
|
|
242
|
+
}
|
|
243
|
+
onActualDeviceType(payload) {
|
|
244
|
+
if (payload.length > 0) {
|
|
245
|
+
this.simulator.actualType = Number(payload.toString());
|
|
246
|
+
}
|
|
247
|
+
this.emitData(this.createResponse('M72', Buffer.from(this.simulator.actualType.toString())));
|
|
248
|
+
}
|
|
249
|
+
onLoadControl(payload) {
|
|
250
|
+
if (payload.length > 0) {
|
|
251
|
+
const loadControl = Number(payload.toString());
|
|
252
|
+
this.simulator.loadControl = loadControl;
|
|
253
|
+
}
|
|
254
|
+
this.emitData(this.createResponse('S20', Buffer.from(this.simulator.loadControl.toString())));
|
|
255
|
+
}
|
|
256
|
+
onGear(payload) {
|
|
257
|
+
if (payload.length > 0) {
|
|
258
|
+
const gear = Number(payload.toString());
|
|
259
|
+
this.simulator.gear = gear;
|
|
260
|
+
}
|
|
261
|
+
this.emitData(this.createResponse('M71', Buffer.from(this.simulator.gear.toString())));
|
|
262
|
+
}
|
|
263
|
+
onPower(payload) {
|
|
264
|
+
if (payload.length > 0) {
|
|
265
|
+
const power = Number(payload.toString());
|
|
266
|
+
this.simulator.power = power;
|
|
267
|
+
setTimeout(() => { this.simulator.currentPower = power; }, 1000);
|
|
268
|
+
}
|
|
269
|
+
this.emitData(this.createResponse('S23', Buffer.from(this.simulator.power.toString())));
|
|
270
|
+
}
|
|
271
|
+
onReservedCommand(payload) {
|
|
272
|
+
const cmd = payload.readInt16LE(0);
|
|
273
|
+
const length = payload.readUint16LE(2);
|
|
274
|
+
const data = (0, utils_2.esc2bin)(payload.subarray(4, 4 + length - 1));
|
|
275
|
+
switch (cmd) {
|
|
276
|
+
case utils_2.ReservedCommands.PERSON_SET: this.onPersonSet(Buffer.from(data));
|
|
277
|
+
case utils_2.ReservedCommands.PERSON_GET: this.onPersonGet();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
onPersonSet(payload) {
|
|
281
|
+
this.simulator.person = (0, utils_2.parsePersonData)(payload);
|
|
282
|
+
this.emitData(this.createResponse('M70', Buffer.from('07000000', 'hex')));
|
|
283
|
+
}
|
|
284
|
+
onPersonGet() {
|
|
285
|
+
}
|
|
286
|
+
onGetTrainingData(_payload) {
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
exports.Daum8iMockBinding = Daum8iMockBinding;
|
package/lib/{daum/premium/DaumClassicCyclingMode.d.ts → serial/daum/premium/modes/daum-classic.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from "
|
|
2
|
-
import DaumAdapter from "
|
|
3
|
-
import DaumPowerMeterCyclingMode from "
|
|
1
|
+
import CyclingMode, { CyclingModeProperty, IncyclistBikeData, Settings, UpdateRequest } from "../../../../modes/cycling-mode";
|
|
2
|
+
import DaumAdapter from "../../DaumAdapter";
|
|
3
|
+
import DaumPowerMeterCyclingMode from "../../DaumPowerMeterCyclingMode";
|
|
4
4
|
export default class DaumClassicCyclingMode extends DaumPowerMeterCyclingMode implements CyclingMode {
|
|
5
5
|
constructor(adapter: DaumAdapter, props?: Settings);
|
|
6
6
|
getName(): string;
|
package/lib/{daum/premium/DaumClassicCyclingMode.js → serial/daum/premium/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 DaumPowerMeterCyclingMode_1 = __importDefault(require("
|
|
7
|
+
const cycling_mode_1 = require("../../../../modes/cycling-mode");
|
|
8
|
+
const DaumPowerMeterCyclingMode_1 = __importDefault(require("../../DaumPowerMeterCyclingMode"));
|
|
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",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DeviceProperties } from "../../../types/device";
|
|
2
|
+
import { Route } from "../../../types/route";
|
|
3
|
+
export type OnDeviceStartCallback = (completed: number, total: number) => void;
|
|
4
|
+
export type DaumPremiumAdapterProps = {
|
|
5
|
+
path: string;
|
|
6
|
+
ifaceName: string;
|
|
7
|
+
};
|
|
8
|
+
export interface Daum8iDeviceProperties extends DeviceProperties {
|
|
9
|
+
route?: Route;
|
|
10
|
+
gear?: number;
|
|
11
|
+
onStatusUpdate?: OnDeviceStartCallback;
|
|
12
|
+
}
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Route } from "
|
|
3
|
-
import { User } from "
|
|
2
|
+
import { Route } from "../../../types/route";
|
|
3
|
+
import { User } from "../../../types/user";
|
|
4
4
|
export declare function bin2esc(arr: any): any[];
|
|
5
5
|
export declare function esc2bin(arr: any): any[];
|
|
6
6
|
export declare function checkSum(cmdArr: any, payload: any): string;
|
|
7
7
|
export declare function buildMessage(command: any, payload?: any): any[];
|
|
8
8
|
export declare function getMessageData(command: any): any[];
|
|
9
9
|
export declare function hexstr(arr: any, start?: any, len?: any): string;
|
|
10
|
-
export declare function getHex(i: any): string;
|
|
11
|
-
export declare function append(cmd: any, arr: any): void;
|
|
12
10
|
export declare function ascii(c: any): any;
|
|
13
|
-
export declare function charArrayToString(arr: any): string;
|
|
14
|
-
export declare function asciiArrayToString(arr: any): string;
|
|
15
11
|
export declare function getAsciiArrayFromStr(str: any): any[];
|
|
16
|
-
export declare function Float32ToHex(float32: any): any;
|
|
17
|
-
export declare function Float32ToIntArray(float32: any): any[];
|
|
18
|
-
export declare function Int16ToIntArray(int16: any): any[];
|
|
19
|
-
export declare function Int32ToIntArray(int32: any): any[];
|
|
20
12
|
export declare enum ReservedCommands {
|
|
21
13
|
RESULT_RESET = 0,
|
|
22
14
|
RESULT_GET = 1,
|
|
@@ -43,8 +35,12 @@ export declare enum BikeType {
|
|
|
43
35
|
MOUNTAIN = 2
|
|
44
36
|
}
|
|
45
37
|
export declare function getBikeType(bikeTypeStr?: string): BikeType;
|
|
38
|
+
export declare const FileTimeSupport: {
|
|
39
|
+
fromCurrentDate: () => any;
|
|
40
|
+
fromDate: (date: Date) => any;
|
|
41
|
+
};
|
|
46
42
|
export declare function routeToEpp(route: Route, date?: Date): Uint8Array;
|
|
47
|
-
export declare function parseTrainingData(payload:
|
|
43
|
+
export declare function parseTrainingData(payload: string): {
|
|
48
44
|
time: number;
|
|
49
45
|
heartrate: number;
|
|
50
46
|
speed: number;
|
|
@@ -60,3 +56,4 @@ export declare function parseTrainingData(payload: any): {
|
|
|
60
56
|
speedStatus: string;
|
|
61
57
|
};
|
|
62
58
|
export declare function getPersonData(user: User): Buffer;
|
|
59
|
+
export declare function parsePersonData(buffer: Buffer): User;
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
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 = void 0;
|
|
7
|
+
const user_1 = require("../../../types/user");
|
|
7
8
|
const win32filetime_1 = __importDefault(require("win32filetime"));
|
|
8
9
|
const sum = (arr) => arr.reduce((a, b) => a + b, 0);
|
|
9
10
|
function bin2esc(arr) {
|
|
@@ -145,32 +146,12 @@ function hexstr(arr, start, len) {
|
|
|
145
146
|
return str;
|
|
146
147
|
}
|
|
147
148
|
exports.hexstr = hexstr;
|
|
148
|
-
function getHex(i) { return ('00' + i.toString(16)).slice(-2); }
|
|
149
|
-
exports.getHex = getHex;
|
|
150
|
-
function append(cmd, arr) { cmd.push(...arr); }
|
|
151
|
-
exports.append = append;
|
|
152
149
|
function ascii(c) {
|
|
153
150
|
if (c === undefined || c === null)
|
|
154
151
|
return;
|
|
155
152
|
return c.charCodeAt(0);
|
|
156
153
|
}
|
|
157
154
|
exports.ascii = ascii;
|
|
158
|
-
function charArrayToString(arr) {
|
|
159
|
-
if (arr === undefined || arr == null)
|
|
160
|
-
return undefined;
|
|
161
|
-
let str = '';
|
|
162
|
-
arr.forEach(c => str += c);
|
|
163
|
-
return str;
|
|
164
|
-
}
|
|
165
|
-
exports.charArrayToString = charArrayToString;
|
|
166
|
-
function asciiArrayToString(arr) {
|
|
167
|
-
if (arr === undefined || arr == null)
|
|
168
|
-
return undefined;
|
|
169
|
-
let str = '';
|
|
170
|
-
arr.forEach(c => str += String.fromCharCode(c));
|
|
171
|
-
return str;
|
|
172
|
-
}
|
|
173
|
-
exports.asciiArrayToString = asciiArrayToString;
|
|
174
155
|
function getAsciiArrayFromStr(str) {
|
|
175
156
|
if (str === undefined || str === null)
|
|
176
157
|
return undefined;
|
|
@@ -182,42 +163,6 @@ function getAsciiArrayFromStr(str) {
|
|
|
182
163
|
return result;
|
|
183
164
|
}
|
|
184
165
|
exports.getAsciiArrayFromStr = getAsciiArrayFromStr;
|
|
185
|
-
function Float32ToHex(float32) {
|
|
186
|
-
var view = new DataView(new ArrayBuffer(4));
|
|
187
|
-
view.setFloat32(0, float32);
|
|
188
|
-
return Array.apply(null, { length: 4 }).map((_, i) => getHex(view.getUint8(i))).join('');
|
|
189
|
-
}
|
|
190
|
-
exports.Float32ToHex = Float32ToHex;
|
|
191
|
-
function Float32ToIntArray(float32) {
|
|
192
|
-
var view = new DataView(new ArrayBuffer(4));
|
|
193
|
-
view.setFloat32(0, float32);
|
|
194
|
-
var arr = [];
|
|
195
|
-
for (let i = 0; i < 4; i++) {
|
|
196
|
-
arr.push(view.getUint8(i));
|
|
197
|
-
}
|
|
198
|
-
return arr;
|
|
199
|
-
}
|
|
200
|
-
exports.Float32ToIntArray = Float32ToIntArray;
|
|
201
|
-
function Int16ToIntArray(int16) {
|
|
202
|
-
var view = new DataView(new ArrayBuffer(2));
|
|
203
|
-
view.setInt16(0, int16);
|
|
204
|
-
var arr = [];
|
|
205
|
-
for (let i = 0; i < 2; i++) {
|
|
206
|
-
arr.push(view.getUint8(i));
|
|
207
|
-
}
|
|
208
|
-
return arr;
|
|
209
|
-
}
|
|
210
|
-
exports.Int16ToIntArray = Int16ToIntArray;
|
|
211
|
-
function Int32ToIntArray(int32) {
|
|
212
|
-
var view = new DataView(new ArrayBuffer(4));
|
|
213
|
-
view.setInt32(0, int32);
|
|
214
|
-
var arr = [];
|
|
215
|
-
for (let i = 0; i < 4; i++) {
|
|
216
|
-
arr.push(view.getUint8(i));
|
|
217
|
-
}
|
|
218
|
-
return arr;
|
|
219
|
-
}
|
|
220
|
-
exports.Int32ToIntArray = Int32ToIntArray;
|
|
221
166
|
var ReservedCommands;
|
|
222
167
|
(function (ReservedCommands) {
|
|
223
168
|
ReservedCommands[ReservedCommands["RESULT_RESET"] = 0] = "RESULT_RESET";
|
|
@@ -253,14 +198,18 @@ function getBikeType(bikeTypeStr) {
|
|
|
253
198
|
return BikeType.RACE;
|
|
254
199
|
}
|
|
255
200
|
exports.getBikeType = getBikeType;
|
|
201
|
+
exports.FileTimeSupport = {
|
|
202
|
+
fromCurrentDate: () => win32filetime_1.default.fromUnix(Date.now()),
|
|
203
|
+
fromDate: (date) => win32filetime_1.default.fromUnix(date),
|
|
204
|
+
};
|
|
256
205
|
function routeToEpp(route, date) {
|
|
257
206
|
const buffer = Buffer.alloc(376 + route.points.length * 12);
|
|
258
|
-
const fileTime =
|
|
207
|
+
const fileTime = date ? exports.FileTimeSupport.fromDate(date) : exports.FileTimeSupport.fromCurrentDate();
|
|
259
208
|
let offset = 0;
|
|
260
209
|
const name = route.name || '';
|
|
261
210
|
const description = route.description || '';
|
|
262
211
|
const minElevation = route.minElevation ? route.minElevation : 0;
|
|
263
|
-
const maxElevation = route.maxElevation ? route.
|
|
212
|
+
const maxElevation = route.maxElevation ? route.maxElevation : route.points.length > 0 ? Math.max(...route.points.map(p => p.elevation)) : minElevation;
|
|
264
213
|
const sampleRate = route.points.length !== 0 ? Math.round(route.totalDistance / route.points.length) : 0;
|
|
265
214
|
buffer.writeUInt32LE(fileTime.low, offset);
|
|
266
215
|
offset += 4;
|
|
@@ -359,13 +308,13 @@ function getPersonData(user) {
|
|
|
359
308
|
buffer.writeUInt8(0, offset);
|
|
360
309
|
offset += 1;
|
|
361
310
|
}
|
|
362
|
-
buffer.writeInt32LE(1, offset);
|
|
311
|
+
buffer.writeInt32LE(user && user.sex === user_1.Gender.FEMALE ? 2 : 1, offset);
|
|
363
312
|
offset += 4;
|
|
364
|
-
buffer.writeInt32LE(1, offset);
|
|
313
|
+
buffer.writeInt32LE(user && user.age !== undefined ? user.age : 1, offset);
|
|
365
314
|
offset += 4;
|
|
366
|
-
buffer.writeInt32LE(175, offset);
|
|
315
|
+
buffer.writeInt32LE(user && user.length !== undefined ? user.length : 175, offset);
|
|
367
316
|
offset += 4;
|
|
368
|
-
buffer.writeFloatLE(70, offset);
|
|
317
|
+
buffer.writeFloatLE(user && user.weight !== undefined ? user.weight : 70, offset);
|
|
369
318
|
offset += 4;
|
|
370
319
|
buffer.writeFloatLE(0, offset);
|
|
371
320
|
offset += 4;
|
|
@@ -374,3 +323,13 @@ function getPersonData(user) {
|
|
|
374
323
|
return buffer;
|
|
375
324
|
}
|
|
376
325
|
exports.getPersonData = getPersonData;
|
|
326
|
+
function parsePersonData(buffer) {
|
|
327
|
+
const valSex = buffer.readInt32LE(112);
|
|
328
|
+
const valAge = buffer.readInt32LE(116);
|
|
329
|
+
const length = buffer.readInt32LE(120);
|
|
330
|
+
const weight = buffer.readFloatLE(124);
|
|
331
|
+
const age = valAge > 1 ? valAge : undefined;
|
|
332
|
+
const sex = valSex === 2 ? user_1.Gender.FEMALE : user_1.Gender.MALE;
|
|
333
|
+
return { length, weight, age, sex };
|
|
334
|
+
}
|
|
335
|
+
exports.parsePersonData = parsePersonData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import SerialPortProvider, { useSerialPortProvider } from './serialport';
|
|
2
|
+
import SerialInterface, { SerialInterfaceProps } from './serial-interface';
|
|
3
|
+
import SerialAdapterFactory from './adapter-factory';
|
|
4
|
+
import { SerialIncyclistDevice, SerialDeviceSettings } from './adapter';
|
|
5
|
+
import DaumClassicAdapter from './daum/classic/adapter';
|
|
6
|
+
import DaumPremiumAdapter from './daum/premium/adapter';
|
|
7
|
+
import KettlerRacerAdapter from './kettler/ergo-racer/adapter';
|
|
8
|
+
export { TCPBinding } from './bindings/tcp';
|
|
9
|
+
export { SerialPortProvider, useSerialPortProvider, SerialInterface, SerialInterfaceProps, SerialDeviceSettings, SerialAdapterFactory, DaumClassicAdapter, DaumPremiumAdapter, KettlerRacerAdapter, SerialIncyclistDevice };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.SerialIncyclistDevice = exports.KettlerRacerAdapter = exports.DaumPremiumAdapter = exports.DaumClassicAdapter = exports.SerialAdapterFactory = exports.SerialInterface = exports.useSerialPortProvider = exports.SerialPortProvider = exports.TCPBinding = void 0;
|
|
30
|
+
const serialport_1 = __importStar(require("./serialport"));
|
|
31
|
+
exports.SerialPortProvider = serialport_1.default;
|
|
32
|
+
Object.defineProperty(exports, "useSerialPortProvider", { enumerable: true, get: function () { return serialport_1.useSerialPortProvider; } });
|
|
33
|
+
const serial_interface_1 = __importDefault(require("./serial-interface"));
|
|
34
|
+
exports.SerialInterface = serial_interface_1.default;
|
|
35
|
+
const adapter_factory_1 = __importDefault(require("./adapter-factory"));
|
|
36
|
+
exports.SerialAdapterFactory = adapter_factory_1.default;
|
|
37
|
+
const adapter_1 = require("./adapter");
|
|
38
|
+
Object.defineProperty(exports, "SerialIncyclistDevice", { enumerable: true, get: function () { return adapter_1.SerialIncyclistDevice; } });
|
|
39
|
+
const adapter_2 = __importDefault(require("./daum/classic/adapter"));
|
|
40
|
+
exports.DaumClassicAdapter = adapter_2.default;
|
|
41
|
+
const adapter_3 = __importDefault(require("./daum/premium/adapter"));
|
|
42
|
+
exports.DaumPremiumAdapter = adapter_3.default;
|
|
43
|
+
const adapter_4 = __importDefault(require("./kettler/ergo-racer/adapter"));
|
|
44
|
+
exports.KettlerRacerAdapter = adapter_4.default;
|
|
45
|
+
var tcp_1 = require("./bindings/tcp");
|
|
46
|
+
Object.defineProperty(exports, "TCPBinding", { enumerable: true, get: function () { return tcp_1.TCPBinding; } });
|
|
47
|
+
adapter_factory_1.default.getInstance().registerAdapter('Daum Classic', adapter_2.default);
|
|
48
|
+
adapter_factory_1.default.getInstance().registerAdapter('Daum Premium', adapter_3.default);
|
|
49
|
+
adapter_factory_1.default.getInstance().registerAdapter('Kettler Racer', adapter_4.default);
|