incyclist-devices 1.2.0 → 1.4.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/LICENSE +21 -0
- package/lib/CyclingMode.d.ts +72 -0
- package/lib/CyclingMode.js +66 -0
- package/lib/Device.d.ts +48 -10
- package/lib/Device.js +9 -8
- package/lib/DeviceProtocol.d.ts +40 -12
- package/lib/DeviceProtocol.js +16 -16
- package/lib/DeviceRegistry.d.ts +4 -4
- package/lib/DeviceRegistry.js +10 -10
- package/lib/DeviceSupport.d.ts +4 -3
- package/lib/DeviceSupport.js +32 -8
- package/lib/ant/AntAdapter.d.ts +9 -2
- package/lib/ant/AntAdapter.js +26 -2
- package/lib/ant/AntScanner.d.ts +16 -6
- package/lib/ant/AntScanner.js +379 -138
- package/lib/ant/antfe/AntFEAdapter.d.ts +4 -2
- package/lib/ant/antfe/AntFEAdapter.js +209 -72
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +4 -1
- package/lib/ant/anthrm/AntHrmAdapter.js +73 -19
- package/lib/ant/utils.js +2 -1
- package/lib/calculations.d.ts +12 -13
- package/lib/calculations.js +88 -125
- package/lib/daum/DaumAdapter.d.ts +29 -6
- package/lib/daum/DaumAdapter.js +219 -96
- package/lib/daum/ERGCyclingMode.d.ts +28 -0
- package/lib/daum/ERGCyclingMode.js +207 -0
- package/lib/daum/PowerMeterCyclingMode.d.ts +18 -0
- package/lib/daum/PowerMeterCyclingMode.js +79 -0
- package/lib/daum/SmartTrainerCyclingMode.d.ts +41 -0
- package/lib/daum/SmartTrainerCyclingMode.js +344 -0
- package/lib/daum/classic/DaumClassicAdapter.d.ts +3 -1
- package/lib/daum/classic/DaumClassicAdapter.js +46 -32
- package/lib/daum/classic/DaumClassicCyclingMode.d.ts +13 -0
- package/lib/daum/classic/DaumClassicCyclingMode.js +98 -0
- package/lib/daum/classic/DaumClassicProtocol.d.ts +5 -3
- package/lib/daum/classic/DaumClassicProtocol.js +39 -6
- package/lib/daum/classic/ERGCyclingMode.d.ts +23 -0
- package/lib/daum/classic/ERGCyclingMode.js +171 -0
- package/lib/daum/classic/bike.d.ts +41 -37
- package/lib/daum/classic/bike.js +86 -53
- package/lib/daum/classic/utils.d.ts +3 -3
- package/lib/daum/classic/utils.js +16 -10
- package/lib/daum/indoorbike.d.ts +2 -1
- package/lib/daum/indoorbike.js +23 -21
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +2 -2
- package/lib/daum/premium/DaumPremiumAdapter.js +30 -20
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +11 -2
- package/lib/daum/premium/DaumPremiumProtocol.js +49 -8
- package/lib/daum/premium/bike.d.ts +63 -52
- package/lib/daum/premium/bike.js +258 -207
- package/lib/daum/premium/tcpserial.d.ts +18 -14
- package/lib/daum/premium/tcpserial.js +50 -20
- package/lib/daum/premium/utils.d.ts +2 -2
- package/lib/simulator/Simulator.d.ts +13 -7
- package/lib/simulator/Simulator.js +62 -21
- package/lib/utils.d.ts +3 -1
- package/lib/utils.js +39 -18
- package/package.json +12 -11
- package/lib/ant/AntScanner.unit.tests.d.ts +0 -1
- package/lib/ant/AntScanner.unit.tests.js +0 -25
- package/lib/ant/antfe/AntFEProcessor.d.ts +0 -40
- package/lib/ant/antfe/AntFEProcessor.js +0 -238
- package/lib/ant/antfe/AntHrmProtocol.d.ts +0 -9
- package/lib/ant/antfe/AntHrmProtocol.js +0 -30
- package/lib/ant/antfe/bike.d.ts +0 -47
- package/lib/ant/antfe/bike.js +0 -602
- package/lib/ant/anthrm/anthrm.d.ts +0 -33
- package/lib/ant/anthrm/anthrm.js +0 -523
- package/lib/simulator/Simulator.unit.tests.d.ts +0 -1
- package/lib/simulator/Simulator.unit.tests.js +0 -79
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,11 +27,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
28
|
});
|
|
10
29
|
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
11
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const DeviceProtocol_1 = require("../../DeviceProtocol");
|
|
13
|
-
const DeviceRegistry_1 = require("../../DeviceRegistry");
|
|
34
|
+
const DeviceProtocol_1 = __importStar(require("../../DeviceProtocol"));
|
|
35
|
+
const DeviceRegistry_1 = __importDefault(require("../../DeviceRegistry"));
|
|
14
36
|
const bike_1 = require("../premium/bike");
|
|
15
|
-
const DaumPremiumAdapter_1 = require("./DaumPremiumAdapter");
|
|
37
|
+
const DaumPremiumAdapter_1 = __importDefault(require("./DaumPremiumAdapter"));
|
|
16
38
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
17
39
|
const PROTOCOL_NAME = "Daum Premium";
|
|
18
40
|
const DefaultState = {
|
|
@@ -27,6 +49,19 @@ class DaumPremiumProtocol extends DeviceProtocol_1.default {
|
|
|
27
49
|
this.logger = new gd_eventlog_1.EventLogger('DaumPremium');
|
|
28
50
|
this.devices = [];
|
|
29
51
|
}
|
|
52
|
+
add(settings) {
|
|
53
|
+
if (settings.interface && settings.interface === DeviceProtocol_1.INTERFACE.TCPIP) {
|
|
54
|
+
bike_1.Daum8iTcp.setNetImpl(DeviceProtocol_1.default.getNetImpl());
|
|
55
|
+
const { host } = settings;
|
|
56
|
+
const portName = `${host}:51955`;
|
|
57
|
+
return this.addDevice(bike_1.Daum8iTcp, { host, port: 51955, interface: DeviceProtocol_1.INTERFACE.TCPIP }, portName);
|
|
58
|
+
}
|
|
59
|
+
if (settings.interface && settings.interface === DeviceProtocol_1.INTERFACE.SERIAL) {
|
|
60
|
+
bike_1.Daum8iSerial.setSerialPort(DeviceProtocol_1.default.getSerialPort());
|
|
61
|
+
const { port } = settings;
|
|
62
|
+
return this.addDevice(bike_1.Daum8iSerial, { port, interface: DeviceProtocol_1.INTERFACE.SERIAL }, port);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
30
65
|
getName() {
|
|
31
66
|
return PROTOCOL_NAME;
|
|
32
67
|
}
|
|
@@ -45,6 +80,7 @@ class DaumPremiumProtocol extends DeviceProtocol_1.default {
|
|
|
45
80
|
scan(props) {
|
|
46
81
|
const opts = props || {};
|
|
47
82
|
this.logger.logEvent({ message: 'start scan', opts });
|
|
83
|
+
this.state.scanning = true;
|
|
48
84
|
if (opts.interface === DeviceProtocol_1.INTERFACE.TCPIP) {
|
|
49
85
|
this.scanTcpip(opts);
|
|
50
86
|
}
|
|
@@ -60,7 +96,8 @@ class DaumPremiumProtocol extends DeviceProtocol_1.default {
|
|
|
60
96
|
this.devices.push(device);
|
|
61
97
|
}
|
|
62
98
|
else {
|
|
63
|
-
const
|
|
99
|
+
const devices = this.devices;
|
|
100
|
+
const idx = devices.findIndex(d => d.getBike().getPort() === portName);
|
|
64
101
|
if (idx === -1) {
|
|
65
102
|
const bike = new DeviceClass(opts);
|
|
66
103
|
device = new DaumPremiumAdapter_1.default(this, bike);
|
|
@@ -91,6 +128,9 @@ class DaumPremiumProtocol extends DeviceProtocol_1.default {
|
|
|
91
128
|
this.state.activeScans.push({ iv, device });
|
|
92
129
|
}
|
|
93
130
|
}
|
|
131
|
+
isScanning() {
|
|
132
|
+
return this.state.scanning;
|
|
133
|
+
}
|
|
94
134
|
stopScan() {
|
|
95
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
136
|
this.logger.logEvent({ message: 'stop scan', activeScans: this.state.activeScans });
|
|
@@ -103,8 +143,9 @@ class DaumPremiumProtocol extends DeviceProtocol_1.default {
|
|
|
103
143
|
});
|
|
104
144
|
this.state.activeScans = [];
|
|
105
145
|
}
|
|
106
|
-
|
|
107
|
-
|
|
146
|
+
const devices = this.devices;
|
|
147
|
+
for (let i = 0; i < devices.length; i++) {
|
|
148
|
+
const d = devices[i];
|
|
108
149
|
if (!d.isSelected() && !d.isDetected()) {
|
|
109
150
|
try {
|
|
110
151
|
yield d.getBike().saveClose(true);
|
|
@@ -114,8 +155,8 @@ class DaumPremiumProtocol extends DeviceProtocol_1.default {
|
|
|
114
155
|
}
|
|
115
156
|
}
|
|
116
157
|
}
|
|
117
|
-
for (let i = 0; i <
|
|
118
|
-
const d =
|
|
158
|
+
for (let i = 0; i < devices.length; i++) {
|
|
159
|
+
const d = devices[i];
|
|
119
160
|
if (!d.isSelected() && !d.isDetected()) {
|
|
120
161
|
try {
|
|
121
162
|
yield d.getBike().unblock();
|
|
@@ -1,77 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
export class Daum8iSerial extends Daum8i {
|
|
5
|
-
constructor(props: any);
|
|
6
|
-
}
|
|
1
|
+
import { Queue } from '../../utils';
|
|
2
|
+
import { EventLogger } from 'gd-eventlog';
|
|
7
3
|
declare class Daum8i {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
static setNetImpl(netClass: any): void;
|
|
11
|
-
static getSupportedInterfaces(): string[];
|
|
12
|
-
constructor(props: any);
|
|
13
|
-
LOG: EventLogger;
|
|
14
|
-
portName: any;
|
|
15
|
-
tcpip: boolean;
|
|
4
|
+
portName: string;
|
|
5
|
+
logger: EventLogger;
|
|
16
6
|
serial: boolean;
|
|
7
|
+
tcpip: boolean;
|
|
17
8
|
tcpipConnection: {
|
|
18
|
-
host:
|
|
19
|
-
port:
|
|
9
|
+
host: string;
|
|
10
|
+
port: string;
|
|
20
11
|
};
|
|
21
|
-
port:
|
|
12
|
+
port: string;
|
|
22
13
|
settings: any;
|
|
23
14
|
sendRetryDelay: number;
|
|
24
15
|
sp: any;
|
|
16
|
+
props: any;
|
|
25
17
|
connected: boolean;
|
|
26
18
|
blocked: boolean;
|
|
27
|
-
state:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
bikeWeight: number;
|
|
37
|
-
maxPower: number;
|
|
38
|
-
};
|
|
39
|
-
processor: IndoorBikeProcessor;
|
|
19
|
+
state: any;
|
|
20
|
+
bikeData: any;
|
|
21
|
+
processor: any;
|
|
22
|
+
error: Error;
|
|
23
|
+
queue: Queue<any>;
|
|
24
|
+
cmdCurrent: any;
|
|
25
|
+
cmdStart: number;
|
|
26
|
+
constructor(props: any);
|
|
27
|
+
static getClassName(): string;
|
|
40
28
|
getType(): string;
|
|
41
|
-
|
|
29
|
+
static setSerialPort(spClass: any): void;
|
|
30
|
+
static setNetImpl(netClass: any): void;
|
|
31
|
+
static getSupportedInterfaces(): string[];
|
|
32
|
+
getPort(): string;
|
|
42
33
|
isConnected(): boolean;
|
|
43
34
|
setUser(user: any, callback: any): void;
|
|
44
35
|
getUserWeight(): any;
|
|
45
36
|
getBikeWeight(): number;
|
|
46
37
|
unblock(): void;
|
|
47
|
-
connect(
|
|
48
|
-
firstOpen: boolean;
|
|
38
|
+
connect(): void;
|
|
49
39
|
reconnect(): Promise<void>;
|
|
50
|
-
saveConnect(): Promise<
|
|
40
|
+
saveConnect(): Promise<unknown>;
|
|
51
41
|
onPortOpen(): void;
|
|
52
|
-
error: any;
|
|
53
42
|
onPortClose(): void;
|
|
54
|
-
|
|
43
|
+
getLogState(): {
|
|
44
|
+
sending: any;
|
|
45
|
+
busy: any;
|
|
46
|
+
writeBusy: any;
|
|
47
|
+
opening: any;
|
|
48
|
+
connecting: any;
|
|
49
|
+
waitingForStart: any;
|
|
50
|
+
waitingForEnd: any;
|
|
51
|
+
waitingForAck: any;
|
|
52
|
+
retry: any;
|
|
53
|
+
};
|
|
54
|
+
onPortError(error: any): void;
|
|
55
55
|
errorHandler(): void;
|
|
56
|
-
saveClose(force
|
|
56
|
+
saveClose(force?: any): Promise<unknown>;
|
|
57
|
+
forceClose(updateState?: boolean): void;
|
|
57
58
|
close(): void;
|
|
58
|
-
bikeCmdWorker: any;
|
|
59
|
-
queue: any;
|
|
60
59
|
sendTimeout(message: any): void;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
onData(data: any): void;
|
|
66
|
-
sendDaum8iCommand(command: any, queryType: any, payload: any, cb: any): Promise<any>;
|
|
60
|
+
checkForResponse(): boolean;
|
|
61
|
+
getTimeoutValue(cmd?: any): number;
|
|
62
|
+
onData(data: any): any;
|
|
63
|
+
sendDaum8iCommand(command: any, queryType: any, payload: any): Promise<unknown>;
|
|
67
64
|
sendACK(): void;
|
|
68
65
|
sendNAK(): void;
|
|
69
|
-
sendReservedDaum8iCommand(command: any, cmdType: any, data: any
|
|
66
|
+
sendReservedDaum8iCommand(command: any, cmdType: any, data: any): Promise<any[]>;
|
|
70
67
|
getProtocolVersion(): Promise<string>;
|
|
71
|
-
getDashboardVersion(): Promise<
|
|
72
|
-
getDeviceType(): Promise<
|
|
73
|
-
getActualBikeType(): Promise<
|
|
74
|
-
setActualBikeType(actualBikeType: any): Promise<
|
|
68
|
+
getDashboardVersion(): Promise<unknown>;
|
|
69
|
+
getDeviceType(): Promise<any>;
|
|
70
|
+
getActualBikeType(): Promise<any>;
|
|
71
|
+
setActualBikeType(actualBikeType: any): Promise<any>;
|
|
75
72
|
getTrainingData(): Promise<{
|
|
76
73
|
time: number;
|
|
77
74
|
heartrate: number;
|
|
@@ -96,6 +93,20 @@ declare class Daum8i {
|
|
|
96
93
|
setGear(gear: any): Promise<number>;
|
|
97
94
|
getGear(): Promise<number>;
|
|
98
95
|
}
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
export declare class Daum8iTcp extends Daum8i {
|
|
97
|
+
static getClassName(): string;
|
|
98
|
+
getType(): string;
|
|
99
|
+
static setSerialPort(spClass: any): void;
|
|
100
|
+
getInterface(): string;
|
|
101
|
+
static setNetImpl(netClass: any): void;
|
|
102
|
+
static getSupportedInterfaces(): string[];
|
|
103
|
+
}
|
|
104
|
+
export declare class Daum8iSerial extends Daum8i {
|
|
105
|
+
static getClassName(): string;
|
|
106
|
+
getType(): string;
|
|
107
|
+
getInterface(): string;
|
|
108
|
+
static setSerialPort(spClass: any): void;
|
|
109
|
+
static setNetImpl(netClass: any): void;
|
|
110
|
+
static getSupportedInterfaces(): string[];
|
|
111
|
+
}
|
|
101
112
|
export {};
|