incyclist-devices 2.2.3 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/antv2/base/adapter.d.ts +1 -2
- package/lib/antv2/base/adapter.js +7 -2
- package/lib/antv2/base/binding.d.ts +0 -1
- package/lib/antv2/base/interface.d.ts +0 -1
- package/lib/antv2/base/interface.js +3 -3
- package/lib/antv2/fe/adapter.js +2 -2
- package/lib/base/adpater.d.ts +0 -1
- package/lib/base/adpater.js +1 -1
- package/lib/ble/base/adapter.js +3 -3
- package/lib/ble/base/comms-utils.js +5 -6
- package/lib/ble/base/comms.d.ts +0 -3
- package/lib/ble/bindings/linux.d.ts +0 -1
- package/lib/ble/bindings/types.d.ts +0 -3
- package/lib/ble/ble-interface.d.ts +0 -2
- package/lib/ble/ble-interface.js +6 -6
- package/lib/ble/ble-peripheral.js +3 -3
- package/lib/ble/cp/comm.d.ts +0 -1
- package/lib/ble/elite/comms.d.ts +0 -1
- package/lib/ble/fm/adapter.js +4 -4
- package/lib/ble/fm/comms.d.ts +0 -1
- package/lib/ble/hr/comm.d.ts +0 -1
- package/lib/ble/tacx/adapter.js +2 -2
- package/lib/ble/tacx/comms.d.ts +0 -1
- package/lib/ble/types.d.ts +0 -2
- package/lib/ble/utils.js +5 -6
- package/lib/ble/wahoo/adapter.js +2 -2
- package/lib/ble/wahoo/comms.d.ts +0 -1
- package/lib/serial/base/comms.d.ts +0 -1
- package/lib/serial/base/comms.js +2 -2
- package/lib/serial/base/serial-interface.d.ts +0 -2
- package/lib/serial/base/serial-scanner.js +5 -0
- package/lib/serial/bindings/tcp.d.ts +0 -2
- package/lib/serial/bindings/tcp.js +4 -4
- package/lib/serial/daum/DaumAdapter.d.ts +0 -2
- package/lib/serial/daum/DaumAdapter.js +7 -8
- package/lib/serial/daum/classic/adapter.js +4 -2
- package/lib/serial/daum/classic/comms.js +4 -4
- package/lib/serial/daum/classic/mock.d.ts +0 -2
- package/lib/serial/daum/classic/utils.js +10 -10
- package/lib/serial/daum/premium/adapter.js +6 -4
- package/lib/serial/daum/premium/comms.d.ts +0 -1
- package/lib/serial/daum/premium/comms.js +54 -35
- package/lib/serial/daum/premium/mock.d.ts +0 -2
- package/lib/serial/daum/premium/mock.js +2 -2
- package/lib/serial/daum/premium/utils.d.ts +0 -1
- package/lib/serial/daum/premium/utils.js +15 -15
- package/lib/serial/kettler/comms.d.ts +0 -2
- package/lib/serial/kettler/ergo-racer/adapter.js +2 -2
- package/lib/serial/kettler/ergo-racer/mock.d.ts +0 -1
- package/lib/serial/kettler/types.d.ts +0 -1
- package/lib/simulator/Simulator.d.ts +0 -1
- package/lib/types/adapter.d.ts +0 -1
- package/lib/types/interface.d.ts +0 -1
- package/lib/utils/calculations.js +2 -2
- package/lib/utils/utils.js +8 -8
- package/package.json +8 -8
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { IChannel, ISensor, Profile } from 'incyclist-ant-plus';
|
|
4
2
|
import AntInterface from './interface';
|
|
5
3
|
import IncyclistDevice from '../../base/adpater';
|
|
@@ -65,6 +63,7 @@ export default class AntAdapter<TDeviceData extends BaseDeviceData> extends Incy
|
|
|
65
63
|
reportStartStatus(): boolean;
|
|
66
64
|
protected waitForInitialData(startupTimeout: any): Promise<void>;
|
|
67
65
|
protected initSensor(props: any): Promise<boolean>;
|
|
66
|
+
getLogProps(startProps?: AntDeviceProperties): AntDeviceProperties;
|
|
68
67
|
start(startProps?: AntDeviceProperties): Promise<boolean>;
|
|
69
68
|
stop(): Promise<boolean>;
|
|
70
69
|
startSensor(): Promise<boolean>;
|
|
@@ -333,8 +333,8 @@ class AntAdapter extends adpater_1.default {
|
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
initSensor(props) {
|
|
336
|
-
var _a, _b;
|
|
337
336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
337
|
+
var _a, _b;
|
|
338
338
|
this.startStatus.sensorStarted = this.sensorConnected;
|
|
339
339
|
if (this.startStatus.sensorStarted || this.startStatus.sensorStarted)
|
|
340
340
|
return;
|
|
@@ -354,15 +354,20 @@ class AntAdapter extends adpater_1.default {
|
|
|
354
354
|
}
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
|
+
getLogProps(startProps) {
|
|
358
|
+
const { user, userWeight, bikeWeight, startupTimeout, automaticReconnect } = startProps !== null && startProps !== void 0 ? startProps : {};
|
|
359
|
+
return { user, userWeight, bikeWeight, startupTimeout, automaticReconnect };
|
|
360
|
+
}
|
|
357
361
|
start(startProps) {
|
|
358
362
|
return __awaiter(this, void 0, void 0, function* () {
|
|
359
363
|
const props = this.getStartProps(startProps);
|
|
364
|
+
const logProps = this.getLogProps(startProps);
|
|
360
365
|
const preCheckResult = yield this.startPreChecks(props);
|
|
361
366
|
if (preCheckResult === 'done')
|
|
362
367
|
return this.started;
|
|
363
368
|
if (preCheckResult === 'connection-failed')
|
|
364
369
|
throw new Error(`could not start device, reason:could not connect`);
|
|
365
|
-
this.logEvent({ message: 'starting device', device: this.getName(), props, isStarted: this.started });
|
|
370
|
+
this.logEvent({ message: 'starting device', device: this.getName(), props: logProps, isStarted: this.started, isPaused: this.isPaused, isStopped: this.isStopped });
|
|
366
371
|
this.resetStartStatus();
|
|
367
372
|
this.resetData();
|
|
368
373
|
const { startupTimeout = this.getDefaultStartupTimeout() } = props;
|
|
@@ -154,8 +154,8 @@ class AntInterface extends events_1.default {
|
|
|
154
154
|
return 1000;
|
|
155
155
|
}
|
|
156
156
|
scannerWaitForConnection() {
|
|
157
|
-
var _a;
|
|
158
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
var _a;
|
|
159
159
|
let scanFinished = false;
|
|
160
160
|
let scanStopRequested = false;
|
|
161
161
|
this.activeScan.emitter.once('timeout', () => {
|
|
@@ -176,8 +176,8 @@ class AntInterface extends events_1.default {
|
|
|
176
176
|
(_a = this.activeScan) === null || _a === void 0 ? void 0 : _a.emitter.removeAllListeners();
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
scan(
|
|
180
|
-
return __awaiter(this,
|
|
179
|
+
scan() {
|
|
180
|
+
return __awaiter(this, arguments, void 0, function* (props = {}) {
|
|
181
181
|
this.logEvent({ message: 'starting scan ..' });
|
|
182
182
|
if (this.isScanning()) {
|
|
183
183
|
return yield this.scanPromise;
|
package/lib/antv2/fe/adapter.js
CHANGED
|
@@ -122,11 +122,11 @@ class AntFEAdapter extends adapter_1.default {
|
|
|
122
122
|
data.deviceTime = adapterData.time;
|
|
123
123
|
this.data = data;
|
|
124
124
|
}
|
|
125
|
-
start(
|
|
125
|
+
start() {
|
|
126
126
|
const _super = Object.create(null, {
|
|
127
127
|
start: { get: () => super.start }
|
|
128
128
|
});
|
|
129
|
-
return __awaiter(this,
|
|
129
|
+
return __awaiter(this, arguments, void 0, function* (props = {}) {
|
|
130
130
|
return yield _super.start.call(this, props);
|
|
131
131
|
});
|
|
132
132
|
}
|
package/lib/base/adpater.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import ICyclingMode, { CyclingMode, UpdateRequest } from "../modes/types";
|
|
3
2
|
import { DeviceProperties, DeviceSettings, ControllerConfig, IAdapter, OnDeviceDataCallback, IncyclistCapability, IncyclistAdapterData, User } from "../types";
|
|
4
3
|
import { EventLogger } from "gd-eventlog";
|
package/lib/base/adpater.js
CHANGED
|
@@ -90,8 +90,8 @@ class IncyclistDevice extends events_1.default {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
resume() {
|
|
93
|
-
var _a;
|
|
94
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
var _a;
|
|
95
95
|
if (this.isStarted() && !this.isStopped())
|
|
96
96
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.logEvent({ message: 'resuming device', device: this.getName() });
|
|
97
97
|
this.paused = false;
|
package/lib/ble/base/adapter.js
CHANGED
|
@@ -165,8 +165,8 @@ class BleAdapter extends adpater_1.default {
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
start(startProps) {
|
|
168
|
-
var _a;
|
|
169
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
var _a;
|
|
170
170
|
const props = this.getStartProps(startProps);
|
|
171
171
|
const preCheckResult = yield this.startPreChecks(props);
|
|
172
172
|
if (preCheckResult === 'done')
|
|
@@ -211,8 +211,8 @@ class BleAdapter extends adpater_1.default {
|
|
|
211
211
|
const _super = Object.create(null, {
|
|
212
212
|
pause: { get: () => super.pause }
|
|
213
213
|
});
|
|
214
|
-
var _a;
|
|
215
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
var _a;
|
|
216
216
|
const res = yield _super.pause.call(this);
|
|
217
217
|
(_a = this.getComms()) === null || _a === void 0 ? void 0 : _a.pause();
|
|
218
218
|
return res;
|
|
@@ -222,8 +222,8 @@ class BleAdapter extends adpater_1.default {
|
|
|
222
222
|
const _super = Object.create(null, {
|
|
223
223
|
resume: { get: () => super.resume }
|
|
224
224
|
});
|
|
225
|
-
var _a;
|
|
226
225
|
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
var _a;
|
|
227
227
|
const res = yield _super.resume.call(this);
|
|
228
228
|
(_a = this.getComms()) === null || _a === void 0 ? void 0 : _a.resume();
|
|
229
229
|
return res;
|
|
@@ -3,7 +3,11 @@ 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.getBestDeviceMatch = getBestDeviceMatch;
|
|
7
|
+
exports.getDevicesFromServices = getDevicesFromServices;
|
|
8
|
+
exports.getServicesFromDeviceTypes = getServicesFromDeviceTypes;
|
|
9
|
+
exports.getServicesFromProtocols = getServicesFromProtocols;
|
|
10
|
+
exports.getServicesFromDevice = getServicesFromDevice;
|
|
7
11
|
const adapter_factory_1 = __importDefault(require("../adapter-factory"));
|
|
8
12
|
const utils_1 = require("../utils");
|
|
9
13
|
function getBestDeviceMatch(DeviceClasses) {
|
|
@@ -13,7 +17,6 @@ function getBestDeviceMatch(DeviceClasses) {
|
|
|
13
17
|
details.sort((a, b) => b.priority - a.priority);
|
|
14
18
|
return details[0].class;
|
|
15
19
|
}
|
|
16
|
-
exports.getBestDeviceMatch = getBestDeviceMatch;
|
|
17
20
|
function getDevicesFromServices(deviceTypes, services) {
|
|
18
21
|
if (!deviceTypes || !Array.isArray(deviceTypes) || deviceTypes.length === 0) {
|
|
19
22
|
return [];
|
|
@@ -40,7 +43,6 @@ function getDevicesFromServices(deviceTypes, services) {
|
|
|
40
43
|
}
|
|
41
44
|
return [];
|
|
42
45
|
}
|
|
43
|
-
exports.getDevicesFromServices = getDevicesFromServices;
|
|
44
46
|
function getServicesFromDeviceTypes(deviceTypes) {
|
|
45
47
|
let services = [];
|
|
46
48
|
try {
|
|
@@ -62,7 +64,6 @@ function getServicesFromDeviceTypes(deviceTypes) {
|
|
|
62
64
|
}
|
|
63
65
|
return services;
|
|
64
66
|
}
|
|
65
|
-
exports.getServicesFromDeviceTypes = getServicesFromDeviceTypes;
|
|
66
67
|
function getServicesFromProtocols(protocols) {
|
|
67
68
|
const services = [];
|
|
68
69
|
const comms = adapter_factory_1.default.getInstance().getAllSupportedComms();
|
|
@@ -76,7 +77,6 @@ function getServicesFromProtocols(protocols) {
|
|
|
76
77
|
});
|
|
77
78
|
return services;
|
|
78
79
|
}
|
|
79
|
-
exports.getServicesFromProtocols = getServicesFromProtocols;
|
|
80
80
|
function getServicesFromDevice(device) {
|
|
81
81
|
if (!device)
|
|
82
82
|
return [];
|
|
@@ -88,4 +88,3 @@ function getServicesFromDevice(device) {
|
|
|
88
88
|
});
|
|
89
89
|
return services;
|
|
90
90
|
}
|
|
91
|
-
exports.getServicesFromDevice = getServicesFromDevice;
|
package/lib/ble/base/comms.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { EventLogger } from 'gd-eventlog';
|
|
4
2
|
import BleAdapterFactory from './adapter-factory';
|
|
5
3
|
import { BleInterfaceProps, BlePeripheral, BleDeviceSettings, BleProtocol, BleBinding, BleInterfaceState, BleScanProps, BleCharacteristic } from './types';
|
package/lib/ble/ble-interface.js
CHANGED
|
@@ -322,9 +322,9 @@ class BleInterface extends events_1.default {
|
|
|
322
322
|
}, 100);
|
|
323
323
|
});
|
|
324
324
|
}
|
|
325
|
-
onPeripheralFound(
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
onPeripheralFound(p_1, callback_1) {
|
|
326
|
+
return __awaiter(this, arguments, void 0, function* (p, callback, props = {}) {
|
|
327
|
+
var _a;
|
|
328
328
|
let peripheral = p;
|
|
329
329
|
if (!peripheral || !peripheral.advertisement || !peripheral.advertisement.localName) {
|
|
330
330
|
return;
|
|
@@ -492,8 +492,8 @@ class BleInterface extends events_1.default {
|
|
|
492
492
|
});
|
|
493
493
|
});
|
|
494
494
|
}
|
|
495
|
-
scan(
|
|
496
|
-
return __awaiter(this,
|
|
495
|
+
scan() {
|
|
496
|
+
return __awaiter(this, arguments, void 0, function* (props = {}) {
|
|
497
497
|
this.logEvent({ message: 'starting scan ..' });
|
|
498
498
|
this.resumeLogging();
|
|
499
499
|
const { timeout, protocol, protocols } = props;
|
|
@@ -531,7 +531,7 @@ class BleInterface extends events_1.default {
|
|
|
531
531
|
this.scanState.peripherals = new Map();
|
|
532
532
|
const detected = [];
|
|
533
533
|
const requested = protocolFilter;
|
|
534
|
-
const onTimeoutOrStopped = (
|
|
534
|
+
const onTimeoutOrStopped = (...args_1) => __awaiter(this, [...args_1], void 0, function* (wasTimeout = false) {
|
|
535
535
|
if (!this.scanState.isScanning || !this.scanState.timeout)
|
|
536
536
|
return;
|
|
537
537
|
if (this.scanState.timeout) {
|
|
@@ -82,8 +82,8 @@ class BlePeripheralConnector {
|
|
|
82
82
|
this.state.subscribed = [];
|
|
83
83
|
this.emitter.emit('disconnect');
|
|
84
84
|
}
|
|
85
|
-
initialize(
|
|
86
|
-
return __awaiter(this,
|
|
85
|
+
initialize() {
|
|
86
|
+
return __awaiter(this, arguments, void 0, function* (enforce = false) {
|
|
87
87
|
this.logEvent({ message: 'initialize', peripheral: this.peripheral.address, state: this.state, enforce });
|
|
88
88
|
if (this.state.isInitialized && !enforce)
|
|
89
89
|
return true;
|
|
@@ -126,8 +126,8 @@ class BlePeripheralConnector {
|
|
|
126
126
|
return ((_a = this.state.subscribed) === null || _a === void 0 ? void 0 : _a.find(c => c === characteristicUuid || (0, utils_1.uuid)(c) === characteristicUuid || c === (0, utils_1.uuid)(characteristicUuid))) !== undefined;
|
|
127
127
|
}
|
|
128
128
|
subscribeAll(callback) {
|
|
129
|
-
var _a;
|
|
130
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
var _a;
|
|
131
131
|
const cnt = this.characteristics.length;
|
|
132
132
|
this.state.isSubscribing = true;
|
|
133
133
|
const subscribed = [];
|
package/lib/ble/cp/comm.d.ts
CHANGED
package/lib/ble/elite/comms.d.ts
CHANGED
package/lib/ble/fm/adapter.js
CHANGED
|
@@ -107,8 +107,8 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
107
107
|
};
|
|
108
108
|
return data;
|
|
109
109
|
}
|
|
110
|
-
start(
|
|
111
|
-
return __awaiter(this,
|
|
110
|
+
start() {
|
|
111
|
+
return __awaiter(this, arguments, void 0, function* (props = {}) {
|
|
112
112
|
const wasPaused = this.paused;
|
|
113
113
|
const wasStopped = this.stopped;
|
|
114
114
|
if (wasPaused)
|
|
@@ -208,8 +208,8 @@ class BleFmAdapter extends adapter_1.default {
|
|
|
208
208
|
}
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
|
-
sendUpdate(
|
|
212
|
-
return __awaiter(this,
|
|
211
|
+
sendUpdate(request_1) {
|
|
212
|
+
return __awaiter(this, arguments, void 0, function* (request, enforced = false) {
|
|
213
213
|
if (!enforced && (this.paused || !this.device))
|
|
214
214
|
return;
|
|
215
215
|
try {
|
package/lib/ble/fm/comms.d.ts
CHANGED
package/lib/ble/hr/comm.d.ts
CHANGED
package/lib/ble/tacx/adapter.js
CHANGED
|
@@ -38,8 +38,8 @@ class BleTacxAdapter extends fm_1.BleFmAdapter {
|
|
|
38
38
|
getProfile() {
|
|
39
39
|
return 'Smart Trainer';
|
|
40
40
|
}
|
|
41
|
-
start(
|
|
42
|
-
return __awaiter(this,
|
|
41
|
+
start() {
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* (props = {}) {
|
|
43
43
|
const wasPaused = this.paused;
|
|
44
44
|
const wasStopped = this.stopped;
|
|
45
45
|
if (wasPaused)
|
package/lib/ble/tacx/comms.d.ts
CHANGED
package/lib/ble/types.d.ts
CHANGED
package/lib/ble/utils.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mapLegacyProfile = mapLegacyProfile;
|
|
4
|
+
exports.uuid = uuid;
|
|
5
|
+
exports.matches = matches;
|
|
6
|
+
exports.getPeripheralInfo = getPeripheralInfo;
|
|
7
|
+
exports.getCharachteristicsInfo = getCharachteristicsInfo;
|
|
4
8
|
function mapLegacyProfile(profile) {
|
|
5
9
|
switch (profile) {
|
|
6
10
|
case 'Smart Trainer': return { profile: 'Smart Trainer', protocol: 'fm' };
|
|
@@ -14,7 +18,6 @@ function mapLegacyProfile(profile) {
|
|
|
14
18
|
case 'Wahoo Smart Trainer': return { profile: 'Smart Trainer', protocol: 'wahoo' };
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
|
-
exports.mapLegacyProfile = mapLegacyProfile;
|
|
18
21
|
function uuid(s) {
|
|
19
22
|
if (s) {
|
|
20
23
|
if (s.includes('-')) {
|
|
@@ -25,7 +28,6 @@ function uuid(s) {
|
|
|
25
28
|
return s;
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
|
-
exports.uuid = uuid;
|
|
29
31
|
function matches(uuid1, uuid2) {
|
|
30
32
|
const ul1 = uuid1.toLowerCase();
|
|
31
33
|
const ul2 = uuid2.toLowerCase();
|
|
@@ -37,7 +39,6 @@ function matches(uuid1, uuid2) {
|
|
|
37
39
|
return true;
|
|
38
40
|
return false;
|
|
39
41
|
}
|
|
40
|
-
exports.matches = matches;
|
|
41
42
|
function getPeripheralInfo(p) {
|
|
42
43
|
const { id, name, address, advertisement, services } = p;
|
|
43
44
|
if (advertisement) {
|
|
@@ -47,11 +48,9 @@ function getPeripheralInfo(p) {
|
|
|
47
48
|
return { id, name, address, services };
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
exports.getPeripheralInfo = getPeripheralInfo;
|
|
51
51
|
function getCharachteristicsInfo(c) {
|
|
52
52
|
const { uuid, properties, name, _serviceUuid } = c;
|
|
53
53
|
const nameStr = name ? ` (${name})` : '';
|
|
54
54
|
const serviceStr = _serviceUuid ? `${_serviceUuid}:` : '';
|
|
55
55
|
return `${serviceStr}${uuid}${nameStr} ${properties}`;
|
|
56
56
|
}
|
|
57
|
-
exports.getCharachteristicsInfo = getCharachteristicsInfo;
|
package/lib/ble/wahoo/adapter.js
CHANGED
|
@@ -38,8 +38,8 @@ class BleWahooAdapter extends fm_1.BleFmAdapter {
|
|
|
38
38
|
getProfile() {
|
|
39
39
|
return 'Smart Trainer';
|
|
40
40
|
}
|
|
41
|
-
start(
|
|
42
|
-
return __awaiter(this,
|
|
41
|
+
start() {
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* (props = {}) {
|
|
43
43
|
const wasPaused = this.paused;
|
|
44
44
|
const wasStopped = this.stopped;
|
|
45
45
|
if (wasPaused)
|
package/lib/ble/wahoo/comms.d.ts
CHANGED
package/lib/serial/base/comms.js
CHANGED
|
@@ -225,8 +225,8 @@ class SerialPortComms {
|
|
|
225
225
|
getTimeoutValue() {
|
|
226
226
|
throw new Error('method not implemented');
|
|
227
227
|
}
|
|
228
|
-
onData(
|
|
229
|
-
return __awaiter(this,
|
|
228
|
+
onData(data_1) {
|
|
229
|
+
return __awaiter(this, arguments, void 0, function* (data, depth = 0) {
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
send(command) {
|
|
@@ -67,6 +67,11 @@ class SinglePathScanner {
|
|
|
67
67
|
}
|
|
68
68
|
const adapterSettings = { interface: this.serial.getName(), host, port, protocol };
|
|
69
69
|
const adapter = adapter_factory_1.default.getInstance().createInstance(adapterSettings);
|
|
70
|
+
if (!adapter) {
|
|
71
|
+
this.isScanning = false;
|
|
72
|
+
resolve(this.result);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
70
75
|
if (this.isScanning) {
|
|
71
76
|
found = yield (adapter === null || adapter === void 0 ? void 0 : adapter.check());
|
|
72
77
|
if (found) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { BindingPortInterface, OpenOptions, PortStatus, PortInfo, SetOptions, UpdateOptions, BindingInterface } from "@serialport/bindings-interface";
|
|
4
2
|
import { EventLogger } from 'gd-eventlog';
|
|
5
3
|
import net from 'net';
|
|
@@ -12,7 +12,10 @@ 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.TCPPortBinding = exports.TCPBinding = exports.
|
|
15
|
+
exports.TCPPortBinding = exports.TCPBinding = exports.CanceledError = void 0;
|
|
16
|
+
exports.scanPort = scanPort;
|
|
17
|
+
exports.scanSubNet = scanSubNet;
|
|
18
|
+
exports.getSubnets = getSubnets;
|
|
16
19
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
17
20
|
const os_1 = require("os");
|
|
18
21
|
const net_1 = __importDefault(require("net"));
|
|
@@ -49,7 +52,6 @@ function scanPort(host, port) {
|
|
|
49
52
|
}
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
|
-
exports.scanPort = scanPort;
|
|
53
55
|
function scanSubNet(sn, port, excludeHosts) {
|
|
54
56
|
const range = [];
|
|
55
57
|
for (let i = 1; i < 255; i++)
|
|
@@ -59,7 +61,6 @@ function scanSubNet(sn, port, excludeHosts) {
|
|
|
59
61
|
.then(hosts => hosts.filter(h => h !== null))
|
|
60
62
|
.catch();
|
|
61
63
|
}
|
|
62
|
-
exports.scanSubNet = scanSubNet;
|
|
63
64
|
function getSubnets() {
|
|
64
65
|
const nets = (0, os_1.networkInterfaces)();
|
|
65
66
|
const results = [];
|
|
@@ -85,7 +86,6 @@ function getSubnets() {
|
|
|
85
86
|
subnets.push('127.0.0');
|
|
86
87
|
return subnets;
|
|
87
88
|
}
|
|
88
|
-
exports.getSubnets = getSubnets;
|
|
89
89
|
exports.TCPBinding = {
|
|
90
90
|
list(port, excludeList) {
|
|
91
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { IncyclistAdapterData, ControllerConfig, IAdapter, DeviceProperties, IncyclistBikeData } from '../../types';
|
|
4
2
|
import { SerialDeviceSettings } from "../types";
|
|
5
3
|
import { DaumSerialComms } from './types';
|
|
@@ -114,20 +114,20 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
114
114
|
const _super = Object.create(null, {
|
|
115
115
|
pause: { get: () => super.pause }
|
|
116
116
|
});
|
|
117
|
-
var _a;
|
|
118
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
var _a;
|
|
119
119
|
yield this.stopUpdatePull();
|
|
120
120
|
const paused = yield _super.pause.call(this);
|
|
121
121
|
(_a = this.comms) === null || _a === void 0 ? void 0 : _a.pause();
|
|
122
122
|
return paused;
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
resume(
|
|
125
|
+
resume() {
|
|
126
126
|
const _super = Object.create(null, {
|
|
127
127
|
resume: { get: () => super.resume }
|
|
128
128
|
});
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
return __awaiter(this, arguments, void 0, function* (startUpdatePull = true) {
|
|
130
|
+
var _a;
|
|
131
131
|
const resumed = yield _super.resume.call(this);
|
|
132
132
|
(_a = this.comms) === null || _a === void 0 ? void 0 : _a.resume();
|
|
133
133
|
if (startUpdatePull)
|
|
@@ -185,8 +185,8 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
start(startProps) {
|
|
188
|
-
var _a;
|
|
189
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
var _a;
|
|
190
190
|
const props = this.getStartProps(startProps);
|
|
191
191
|
yield this.waitForPrevCheckFinished();
|
|
192
192
|
yield this.waitForPrevStartFinished();
|
|
@@ -211,7 +211,7 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
211
211
|
const deviceInfo = yield this.getDeviceInfo();
|
|
212
212
|
this.logEvent({ message: 'device info', deviceInfo });
|
|
213
213
|
}
|
|
214
|
-
catch (
|
|
214
|
+
catch (_a) { }
|
|
215
215
|
}
|
|
216
216
|
this.logEvent({ message: 'start result: success' });
|
|
217
217
|
this.started = true;
|
|
@@ -343,7 +343,6 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
343
343
|
}
|
|
344
344
|
stop() {
|
|
345
345
|
return __awaiter(this, void 0, void 0, function* () {
|
|
346
|
-
console.log('~~~ STOP', this.stopped);
|
|
347
346
|
if (this.stopped) {
|
|
348
347
|
return true;
|
|
349
348
|
}
|
|
@@ -424,8 +423,8 @@ class DaumAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
424
423
|
});
|
|
425
424
|
}
|
|
426
425
|
bikeSync() {
|
|
427
|
-
var _a, _b, _c;
|
|
428
426
|
return __awaiter(this, void 0, void 0, function* () {
|
|
427
|
+
var _a, _b, _c;
|
|
429
428
|
if (!((_a = this.iv) === null || _a === void 0 ? void 0 : _a.stopRequested))
|
|
430
429
|
yield this.sendRequests();
|
|
431
430
|
if (!((_b = this.iv) === null || _b === void 0 ? void 0 : _b.stopRequested))
|
|
@@ -163,11 +163,13 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
const checkInterrupt = () => new Promise(done => {
|
|
166
|
-
|
|
166
|
+
const onStop = () => {
|
|
167
167
|
stopped = true;
|
|
168
168
|
this.started = false;
|
|
169
169
|
done(false);
|
|
170
|
-
|
|
170
|
+
this.internalEmitter.off('stop', onStop);
|
|
171
|
+
};
|
|
172
|
+
this.internalEmitter.on('stop', onStop);
|
|
171
173
|
});
|
|
172
174
|
return (0, utils_1.runWithRetries)(() => Promise.race([start(), checkInterrupt()]), 5, 1000);
|
|
173
175
|
}
|
|
@@ -158,8 +158,8 @@ class Daum8008 extends comms_1.default {
|
|
|
158
158
|
return { bike: data[1], pedalling: data[2] > 0 };
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
setProg(
|
|
162
|
-
return __awaiter(this,
|
|
161
|
+
setProg() {
|
|
162
|
+
return __awaiter(this, arguments, void 0, function* (progNo = 0, bike) {
|
|
163
163
|
const bikeNo = bike === undefined ? this.bikeNo : bike;
|
|
164
164
|
const data = yield this.sendCommand(`setProg(${bikeNo},${progNo})`, [0x23, bikeNo, progNo], 4);
|
|
165
165
|
return { bike: data[1], progNo: data[2], pedalling: data[3] !== 0 };
|
|
@@ -173,8 +173,8 @@ class Daum8008 extends comms_1.default {
|
|
|
173
173
|
return { bike: data[1] };
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
|
-
setPerson(
|
|
177
|
-
return __awaiter(this,
|
|
176
|
+
setPerson() {
|
|
177
|
+
return __awaiter(this, arguments, void 0, function* (user = {}, bike) {
|
|
178
178
|
const bikeNo = bike === undefined ? this.bikeNo : bike;
|
|
179
179
|
const age = user.age !== undefined ? user.age : utils_2.DEFAULT_AGE;
|
|
180
180
|
const gender = (0, utils_2.getGender)(user.sex);
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DEFAULT_BIKE_WEIGHT = exports.DEFAULT_USER_WEIGHT = exports.DEFAULT_AGE = void 0;
|
|
4
|
+
exports.getCockpit = getCockpit;
|
|
5
|
+
exports.getSerialNo = getSerialNo;
|
|
6
|
+
exports.getBikeType = getBikeType;
|
|
7
|
+
exports.getGender = getGender;
|
|
8
|
+
exports.getLength = getLength;
|
|
9
|
+
exports.getWeight = getWeight;
|
|
10
|
+
exports.parseRunData = parseRunData;
|
|
11
|
+
exports.between = between;
|
|
12
|
+
exports.buildSetSlopeCommand = buildSetSlopeCommand;
|
|
4
13
|
exports.DEFAULT_AGE = 30;
|
|
5
14
|
exports.DEFAULT_USER_WEIGHT = 75;
|
|
6
15
|
exports.DEFAULT_BIKE_WEIGHT = 10;
|
|
@@ -30,12 +39,10 @@ function getCockpit(c) {
|
|
|
30
39
|
return "Unknown";
|
|
31
40
|
}
|
|
32
41
|
}
|
|
33
|
-
exports.getCockpit = getCockpit;
|
|
34
42
|
function getSerialNo(arr, start, length) {
|
|
35
43
|
const buffer = Buffer.from(arr.subarray(start, start + length));
|
|
36
44
|
return buffer.toString('hex');
|
|
37
45
|
}
|
|
38
|
-
exports.getSerialNo = getSerialNo;
|
|
39
46
|
function getBikeType(type) {
|
|
40
47
|
const DAUM_CLASSIC_BT_MOUNTAIN = 1;
|
|
41
48
|
const DAUM_CLASSIC_BT_RACE = 0;
|
|
@@ -50,7 +57,6 @@ function getBikeType(type) {
|
|
|
50
57
|
return DAUM_CLASSIC_BT_MOUNTAIN;
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
|
-
exports.getBikeType = getBikeType;
|
|
54
60
|
function getGender(sex) {
|
|
55
61
|
if (sex === undefined)
|
|
56
62
|
return 2;
|
|
@@ -63,21 +69,18 @@ function getGender(sex) {
|
|
|
63
69
|
return 2;
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
|
-
exports.getGender = getGender;
|
|
67
72
|
function getLength(length) {
|
|
68
73
|
if (length === undefined || length === null)
|
|
69
74
|
return 180;
|
|
70
75
|
const l = Math.round(length);
|
|
71
76
|
return between(l, 100, 220);
|
|
72
77
|
}
|
|
73
|
-
exports.getLength = getLength;
|
|
74
78
|
function getWeight(weight) {
|
|
75
79
|
if (weight === undefined || weight === null)
|
|
76
80
|
return 80;
|
|
77
81
|
let m = Math.round(weight);
|
|
78
82
|
return between(m, 10, 250);
|
|
79
83
|
}
|
|
80
|
-
exports.getWeight = getWeight;
|
|
81
84
|
function parseRunData(data) {
|
|
82
85
|
const bikeData = {};
|
|
83
86
|
bikeData.isPedalling = (data[4] > 0);
|
|
@@ -90,7 +93,6 @@ function parseRunData(data) {
|
|
|
90
93
|
bikeData.gear = data[16];
|
|
91
94
|
return bikeData;
|
|
92
95
|
}
|
|
93
|
-
exports.parseRunData = parseRunData;
|
|
94
96
|
function between(v, min, max) {
|
|
95
97
|
if (v < min)
|
|
96
98
|
return min;
|
|
@@ -98,11 +100,9 @@ function between(v, min, max) {
|
|
|
98
100
|
return max;
|
|
99
101
|
return v;
|
|
100
102
|
}
|
|
101
|
-
exports.between = between;
|
|
102
103
|
function buildSetSlopeCommand(bikeNo, slope) {
|
|
103
104
|
const buffer = Buffer.from([0x55, bikeNo, 0, 0, 0, 0]);
|
|
104
105
|
buffer.writeFloatLE(slope, 2);
|
|
105
106
|
const cmd = Array.from(buffer);
|
|
106
107
|
return cmd;
|
|
107
108
|
}
|
|
108
|
-
exports.buildSetSlopeCommand = buildSetSlopeCommand;
|
|
@@ -132,8 +132,8 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
132
132
|
return yield _super.restart.call(this, pause);
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
-
performStart(
|
|
136
|
-
return __awaiter(this,
|
|
135
|
+
performStart() {
|
|
136
|
+
return __awaiter(this, arguments, void 0, function* (props = {}, _isRelaunch = false, wasPaused = false) {
|
|
137
137
|
this.setBikeProps(props);
|
|
138
138
|
this.initData();
|
|
139
139
|
if (!wasPaused)
|
|
@@ -194,11 +194,13 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
const checkInterrupt = () => new Promise(done => {
|
|
197
|
-
|
|
197
|
+
const onStop = () => {
|
|
198
198
|
stopped = true;
|
|
199
199
|
this.started = false;
|
|
200
200
|
done(false);
|
|
201
|
-
|
|
201
|
+
this.internalEmitter.off('stop', onStop);
|
|
202
|
+
};
|
|
203
|
+
this.internalEmitter.on('stop', onStop);
|
|
202
204
|
});
|
|
203
205
|
const started = yield (0, utils_1.runWithRetries)(() => Promise.race([start(), checkInterrupt()]), this.getStartRetries(), this.getStartRetryTimeout());
|
|
204
206
|
if (started) {
|
|
@@ -51,8 +51,8 @@ class Daum8i extends comms_1.default {
|
|
|
51
51
|
this.recvState.waitingForStart = start;
|
|
52
52
|
this.recvState.waitingForEnd = end;
|
|
53
53
|
}
|
|
54
|
-
onData(
|
|
55
|
-
return __awaiter(this,
|
|
54
|
+
onData(data_1) {
|
|
55
|
+
return __awaiter(this, arguments, void 0, function* (data, depth = 0) {
|
|
56
56
|
let cmd = '';
|
|
57
57
|
const MAX_DEPTH = 5;
|
|
58
58
|
if (this.recvState.waitingForEnd && this.recvState.partialCmd) {
|
|
@@ -204,14 +204,14 @@ class Daum8i extends comms_1.default {
|
|
|
204
204
|
return this.sendCmdPromise;
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
sendStrCommand(
|
|
208
|
-
return __awaiter(this,
|
|
207
|
+
sendStrCommand(logString_1, command_1) {
|
|
208
|
+
return __awaiter(this, arguments, void 0, function* (logString, command, payload = '') {
|
|
209
209
|
const response = yield this.send({ logString, command, payload, isBinary: false });
|
|
210
210
|
return response.data;
|
|
211
211
|
});
|
|
212
212
|
}
|
|
213
|
-
sendBinaryCommand(
|
|
214
|
-
return __awaiter(this,
|
|
213
|
+
sendBinaryCommand(logString_1, command_1) {
|
|
214
|
+
return __awaiter(this, arguments, void 0, function* (logString, command, payload = '') {
|
|
215
215
|
const response = yield this.send({ logString, command, payload, isBinary: true });
|
|
216
216
|
return response.data;
|
|
217
217
|
});
|
|
@@ -256,8 +256,8 @@ class Daum8i extends comms_1.default {
|
|
|
256
256
|
throw new types_2.ResponseTimeout();
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
|
-
write(
|
|
260
|
-
return __awaiter(this,
|
|
259
|
+
write(buffer_1) {
|
|
260
|
+
return __awaiter(this, arguments, void 0, function* (buffer, ackExpected = true) {
|
|
261
261
|
if (this.writePromise) {
|
|
262
262
|
try {
|
|
263
263
|
yield this.writePromise;
|
|
@@ -473,32 +473,51 @@ class Daum8i extends comms_1.default {
|
|
|
473
473
|
}
|
|
474
474
|
programUploadStart(bikeType, route) {
|
|
475
475
|
return __awaiter(this, void 0, void 0, function* () {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
476
|
+
let payload, epp, eppLength, bikeTypeVal, wBits;
|
|
477
|
+
try {
|
|
478
|
+
payload = Buffer.alloc(40);
|
|
479
|
+
epp = route ? (0, utils_1.routeToEpp)(route) : undefined;
|
|
480
|
+
eppLength = epp ? epp.length : 0;
|
|
481
|
+
bikeTypeVal = (0, utils_1.getBikeType)(bikeType);
|
|
482
|
+
wBits = route.lapMode ? consts_1.DS_BITS_ENDLESS_RACE : consts_1.DS_BITS_OFF;
|
|
483
|
+
}
|
|
484
|
+
catch (err) {
|
|
485
|
+
this.logEvent({ message: 'error', fn: 'programUploadStart#prepare', epp, error: err.message, stack: err.stack });
|
|
486
|
+
throw err;
|
|
487
|
+
}
|
|
488
|
+
try {
|
|
489
|
+
payload.writeInt32LE(0, 0);
|
|
490
|
+
payload.writeInt8(bikeTypeVal, 4);
|
|
491
|
+
payload.writeInt8(0, 5);
|
|
492
|
+
payload.writeInt16LE(0, 6);
|
|
493
|
+
payload.writeInt32LE(0, 8);
|
|
494
|
+
payload.writeInt32LE(0, 12);
|
|
495
|
+
payload.writeFloatLE(0, 16);
|
|
496
|
+
payload.writeFloatLE(0, 20);
|
|
497
|
+
payload.writeInt16LE(0, 24);
|
|
498
|
+
payload.writeInt16LE(0, 26);
|
|
499
|
+
payload.writeInt16LE(0, 28);
|
|
500
|
+
payload.writeInt16LE(wBits, 30);
|
|
501
|
+
payload.writeInt32LE(7, 32);
|
|
502
|
+
payload.writeInt32LE(eppLength, 36);
|
|
503
|
+
}
|
|
504
|
+
catch (err) {
|
|
505
|
+
this.logEvent({ message: 'error', fn: 'programUploadStart#createPayload', bikeTypeVal, wBits, eppLength, error: err.message, stack: err.stack });
|
|
506
|
+
throw err;
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
const res = yield this.sendReservedDaum8iCommand('programUploadStart()', utils_1.ReservedCommands.PROGRAM_LIST_NEW_PROGRAM, payload);
|
|
510
|
+
const buffer = Buffer.from(res);
|
|
511
|
+
if (buffer.readInt16LE(0) === utils_1.ReservedCommands.PROGRAM_LIST_NEW_PROGRAM) {
|
|
512
|
+
this.logEvent({ message: 'programUploadStart() response', success: true });
|
|
513
|
+
return epp;
|
|
514
|
+
}
|
|
515
|
+
this.logEvent({ message: 'programUploadStart() response', success: false });
|
|
516
|
+
}
|
|
517
|
+
catch (err) {
|
|
518
|
+
this.logEvent({ message: 'error', fn: 'programUploadStart#send', payload: payload.toString('hex'), error: err.message, stack: err.stack });
|
|
519
|
+
throw err;
|
|
500
520
|
}
|
|
501
|
-
this.logEvent({ message: 'programUploadStart() response', success: false });
|
|
502
521
|
throw new Error('Illegal Response');
|
|
503
522
|
});
|
|
504
523
|
}
|
|
@@ -538,8 +557,8 @@ class Daum8i extends comms_1.default {
|
|
|
538
557
|
;
|
|
539
558
|
});
|
|
540
559
|
}
|
|
541
|
-
startProgram(
|
|
542
|
-
return __awaiter(this,
|
|
560
|
+
startProgram() {
|
|
561
|
+
return __awaiter(this, arguments, void 0, function* (programId = 1) {
|
|
543
562
|
const payload = Buffer.alloc(2);
|
|
544
563
|
payload.writeInt16LE(programId, 0);
|
|
545
564
|
const logStr = `startProgram(${programId})`;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
|
|
4
2
|
import { BindingInterface } from '@serialport/bindings-interface';
|
|
5
3
|
import { User } from '../../../types';
|
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Daum8iMockBinding = exports.
|
|
12
|
+
exports.Daum8iMockBinding = exports.Daum8MockSimulator = exports.Daum8iMockImpl = exports.Daum8iMock = void 0;
|
|
13
|
+
exports.parseProgramListNewData = parseProgramListNewData;
|
|
13
14
|
const binding_mock_1 = require("@serialport/binding-mock");
|
|
14
15
|
const __1 = require("../../");
|
|
15
16
|
const types_1 = require("../../../types");
|
|
@@ -135,7 +136,6 @@ function parseProgramListNewData(buffer) {
|
|
|
135
136
|
const lapMode = wBits === consts_1.DS_BITS_ENDLESS_RACE;
|
|
136
137
|
return { lapMode };
|
|
137
138
|
}
|
|
138
|
-
exports.parseProgramListNewData = parseProgramListNewData;
|
|
139
139
|
class Daum8iMockBinding extends binding_mock_1.MockPortBinding {
|
|
140
140
|
constructor(parent) {
|
|
141
141
|
super(parent.port, parent.openOptions);
|
|
@@ -3,7 +3,21 @@ 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.FileTimeSupport = exports.BikeType = exports.ReservedCommands = exports.validatePath = exports.validateHost = exports.DEBUG_LOGGER = void 0;
|
|
7
|
+
exports.responseLog = responseLog;
|
|
8
|
+
exports.bin2esc = bin2esc;
|
|
9
|
+
exports.esc2bin = esc2bin;
|
|
10
|
+
exports.checkSum = checkSum;
|
|
11
|
+
exports.buildMessage = buildMessage;
|
|
12
|
+
exports.getMessageData = getMessageData;
|
|
13
|
+
exports.hexstr = hexstr;
|
|
14
|
+
exports.ascii = ascii;
|
|
15
|
+
exports.getAsciiArrayFromStr = getAsciiArrayFromStr;
|
|
16
|
+
exports.getBikeType = getBikeType;
|
|
17
|
+
exports.routeToEpp = routeToEpp;
|
|
18
|
+
exports.parseTrainingData = parseTrainingData;
|
|
19
|
+
exports.getPersonData = getPersonData;
|
|
20
|
+
exports.parsePersonData = parsePersonData;
|
|
7
21
|
const types_1 = require("../../../types");
|
|
8
22
|
const win32filetime_1 = __importDefault(require("win32filetime"));
|
|
9
23
|
const sum = (arr) => arr.reduce((a, b) => a + b, 0);
|
|
@@ -19,7 +33,6 @@ function responseLog(str) {
|
|
|
19
33
|
}
|
|
20
34
|
return str;
|
|
21
35
|
}
|
|
22
|
-
exports.responseLog = responseLog;
|
|
23
36
|
const validateHost = (host) => {
|
|
24
37
|
const ipParts = host.split('.');
|
|
25
38
|
if (ipParts.length > 1)
|
|
@@ -70,7 +83,6 @@ function bin2esc(arr) {
|
|
|
70
83
|
});
|
|
71
84
|
return new Uint8Array(res);
|
|
72
85
|
}
|
|
73
|
-
exports.bin2esc = bin2esc;
|
|
74
86
|
function esc2bin(arr) {
|
|
75
87
|
const res = [];
|
|
76
88
|
let escaped = false;
|
|
@@ -109,7 +121,6 @@ function esc2bin(arr) {
|
|
|
109
121
|
});
|
|
110
122
|
return new Uint8Array(res);
|
|
111
123
|
}
|
|
112
|
-
exports.esc2bin = esc2bin;
|
|
113
124
|
function checkSum(cmdArr, payload) {
|
|
114
125
|
const total = sum(cmdArr) + sum(payload);
|
|
115
126
|
const checkSumVal = total % 100;
|
|
@@ -118,7 +129,6 @@ function checkSum(cmdArr, payload) {
|
|
|
118
129
|
checkSumStr = '0' + checkSumStr;
|
|
119
130
|
return checkSumStr;
|
|
120
131
|
}
|
|
121
|
-
exports.checkSum = checkSum;
|
|
122
132
|
function buildMessage(command, payload) {
|
|
123
133
|
const cmdArr = getAsciiArrayFromStr(command);
|
|
124
134
|
let data = payload || [];
|
|
@@ -136,14 +146,12 @@ function buildMessage(command, payload) {
|
|
|
136
146
|
message.push(0x17);
|
|
137
147
|
return message;
|
|
138
148
|
}
|
|
139
|
-
exports.buildMessage = buildMessage;
|
|
140
149
|
function getMessageData(command) {
|
|
141
150
|
const res = [...command];
|
|
142
151
|
res.splice(0, 4);
|
|
143
152
|
res.splice(-3, 3);
|
|
144
153
|
return res;
|
|
145
154
|
}
|
|
146
|
-
exports.getMessageData = getMessageData;
|
|
147
155
|
function hexstr(arr, start, len) {
|
|
148
156
|
const isArr = Array.isArray(arr) || arr instanceof Uint8Array;
|
|
149
157
|
if (!arr)
|
|
@@ -168,11 +176,9 @@ function hexstr(arr, start, len) {
|
|
|
168
176
|
}
|
|
169
177
|
return str;
|
|
170
178
|
}
|
|
171
|
-
exports.hexstr = hexstr;
|
|
172
179
|
function ascii(c) {
|
|
173
180
|
return c.charCodeAt(0);
|
|
174
181
|
}
|
|
175
|
-
exports.ascii = ascii;
|
|
176
182
|
function getAsciiArrayFromStr(str) {
|
|
177
183
|
if (str === undefined || str === null)
|
|
178
184
|
return undefined;
|
|
@@ -183,7 +189,6 @@ function getAsciiArrayFromStr(str) {
|
|
|
183
189
|
}
|
|
184
190
|
return result;
|
|
185
191
|
}
|
|
186
|
-
exports.getAsciiArrayFromStr = getAsciiArrayFromStr;
|
|
187
192
|
var ReservedCommands;
|
|
188
193
|
(function (ReservedCommands) {
|
|
189
194
|
ReservedCommands[ReservedCommands["RESULT_RESET"] = 0] = "RESULT_RESET";
|
|
@@ -218,7 +223,6 @@ function getBikeType(bikeTypeStr) {
|
|
|
218
223
|
return BikeType.MOUNTAIN;
|
|
219
224
|
return BikeType.RACE;
|
|
220
225
|
}
|
|
221
|
-
exports.getBikeType = getBikeType;
|
|
222
226
|
exports.FileTimeSupport = {
|
|
223
227
|
fromCurrentDate: () => win32filetime_1.default.fromUnix(Date.now()),
|
|
224
228
|
fromDate: (date) => win32filetime_1.default.fromUnix(date),
|
|
@@ -276,7 +280,6 @@ function routeToEpp(route, date) {
|
|
|
276
280
|
});
|
|
277
281
|
return new Uint8Array(buffer);
|
|
278
282
|
}
|
|
279
|
-
exports.routeToEpp = routeToEpp;
|
|
280
283
|
function parseTrainingData(payload) {
|
|
281
284
|
const gearVal = (v) => v > 0 ? v - 1 : undefined;
|
|
282
285
|
const vals = payload.split(String.fromCharCode(GS));
|
|
@@ -293,7 +296,6 @@ function parseTrainingData(payload) {
|
|
|
293
296
|
data.isPedalling = (data.pedalRpm > 0);
|
|
294
297
|
return data;
|
|
295
298
|
}
|
|
296
|
-
exports.parseTrainingData = parseTrainingData;
|
|
297
299
|
function getPersonData(user) {
|
|
298
300
|
const buffer = Buffer.alloc(136);
|
|
299
301
|
let offset = 0;
|
|
@@ -337,7 +339,6 @@ function getPersonData(user) {
|
|
|
337
339
|
offset += 4;
|
|
338
340
|
return buffer;
|
|
339
341
|
}
|
|
340
|
-
exports.getPersonData = getPersonData;
|
|
341
342
|
function parsePersonData(buffer) {
|
|
342
343
|
const valSex = buffer.readInt32LE(112);
|
|
343
344
|
const valAge = buffer.readInt32LE(116);
|
|
@@ -347,4 +348,3 @@ function parsePersonData(buffer) {
|
|
|
347
348
|
const sex = valSex === 2 ? types_1.Gender.FEMALE : types_1.Gender.MALE;
|
|
348
349
|
return { length, weight, age, sex };
|
|
349
350
|
}
|
|
350
|
-
exports.parsePersonData = parsePersonData;
|
|
@@ -517,8 +517,8 @@ class KettlerRacerAdapter extends adapter_1.SerialIncyclistDevice {
|
|
|
517
517
|
return yield this.waitForClosed();
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
|
-
waitForOpened(
|
|
521
|
-
return __awaiter(this,
|
|
520
|
+
waitForOpened() {
|
|
521
|
+
return __awaiter(this, arguments, void 0, function* (retries = false) {
|
|
522
522
|
if (!retries) {
|
|
523
523
|
return yield this.comms.open();
|
|
524
524
|
}
|
package/lib/types/adapter.d.ts
CHANGED
package/lib/types/interface.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.IllegalArgumentException = void 0;
|
|
4
|
+
exports.solveCubic = solveCubic;
|
|
4
5
|
const g = 9.80665;
|
|
5
6
|
const rho = 1.2041;
|
|
6
7
|
const cwABike = {
|
|
@@ -143,4 +144,3 @@ function solveCubic(p, q) {
|
|
|
143
144
|
results[0] = -2 * R * Math.sinh(phi / 3);
|
|
144
145
|
return results;
|
|
145
146
|
}
|
|
146
|
-
exports.solveCubic = solveCubic;
|
package/lib/utils/utils.js
CHANGED
|
@@ -9,7 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.Queue = exports.resolveNextTick = exports.sleep = void 0;
|
|
13
|
+
exports.runWithRetries = runWithRetries;
|
|
14
|
+
exports.floatVal = floatVal;
|
|
15
|
+
exports.intVal = intVal;
|
|
16
|
+
exports.hexstr = hexstr;
|
|
17
|
+
exports.isTrue = isTrue;
|
|
18
|
+
exports.runWithTimeout = runWithTimeout;
|
|
19
|
+
exports.waitWithTimeout = waitWithTimeout;
|
|
13
20
|
const sleep = (ms) => {
|
|
14
21
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
15
22
|
};
|
|
@@ -54,7 +61,6 @@ function runWithRetries(fn, maxRetries, timeBetween) {
|
|
|
54
61
|
}), 50);
|
|
55
62
|
});
|
|
56
63
|
}
|
|
57
|
-
exports.runWithRetries = runWithRetries;
|
|
58
64
|
function floatVal(d) {
|
|
59
65
|
if (d === undefined)
|
|
60
66
|
return;
|
|
@@ -63,7 +69,6 @@ function floatVal(d) {
|
|
|
63
69
|
const res = parseFloat(d);
|
|
64
70
|
return isNaN(res) ? undefined : res;
|
|
65
71
|
}
|
|
66
|
-
exports.floatVal = floatVal;
|
|
67
72
|
function intVal(d) {
|
|
68
73
|
if (d === undefined)
|
|
69
74
|
return;
|
|
@@ -72,7 +77,6 @@ function intVal(d) {
|
|
|
72
77
|
const res = parseInt(d);
|
|
73
78
|
return isNaN(res) ? undefined : res;
|
|
74
79
|
}
|
|
75
|
-
exports.intVal = intVal;
|
|
76
80
|
function hexstr(arr, start, len) {
|
|
77
81
|
let str = "";
|
|
78
82
|
const startIdx = start || 0;
|
|
@@ -91,7 +95,6 @@ function hexstr(arr, start, len) {
|
|
|
91
95
|
}
|
|
92
96
|
return str;
|
|
93
97
|
}
|
|
94
|
-
exports.hexstr = hexstr;
|
|
95
98
|
function isTrue(value) {
|
|
96
99
|
if (typeof (value) === 'string') {
|
|
97
100
|
value = value.trim().toLowerCase();
|
|
@@ -108,7 +111,6 @@ function isTrue(value) {
|
|
|
108
111
|
return false;
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
exports.isTrue = isTrue;
|
|
112
114
|
class Queue {
|
|
113
115
|
constructor(values) {
|
|
114
116
|
this.data = [];
|
|
@@ -138,13 +140,11 @@ function runWithTimeout(promise, timeout) {
|
|
|
138
140
|
return yield doWaitWithTimeout(promise, timeout, true);
|
|
139
141
|
});
|
|
140
142
|
}
|
|
141
|
-
exports.runWithTimeout = runWithTimeout;
|
|
142
143
|
function waitWithTimeout(promise, timeout, onTimeout) {
|
|
143
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
144
145
|
return yield doWaitWithTimeout(promise, timeout, false, onTimeout);
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
|
-
exports.waitWithTimeout = waitWithTimeout;
|
|
148
148
|
function doWaitWithTimeout(promise, timeout, throwError, onTimeout) {
|
|
149
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
150
150
|
let to;
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-devices",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@serialport/bindings-interface": "^1.2.2",
|
|
6
6
|
"@serialport/parser-byte-length": "^9.0.1",
|
|
7
7
|
"@serialport/parser-delimiter": "^9.0.1",
|
|
8
8
|
"@serialport/parser-readline": "^10.5.0",
|
|
9
9
|
"@serialport/stream": "^10.5.0",
|
|
10
|
-
"incyclist-ant-plus": "^0.3.
|
|
10
|
+
"incyclist-ant-plus": "^0.3.3",
|
|
11
11
|
"win32filetime": "^1.0.2"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"gd-eventlog": "^0.1.
|
|
14
|
+
"gd-eventlog": "^0.1.27"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@serialport/binding-mock": "^10.2.2",
|
|
18
18
|
"@serialport/bindings-cpp": "^10.8.0",
|
|
19
|
-
"@types/jest": "^29.5.
|
|
20
|
-
"@types/node": "^
|
|
19
|
+
"@types/jest": "^29.5.12",
|
|
20
|
+
"@types/node": "^22.5.0",
|
|
21
21
|
"eslint": "^8.47.0",
|
|
22
22
|
"eslint-config-react-app": "^7.0.1",
|
|
23
|
-
"jest": "^29.
|
|
24
|
-
"ts-jest": "^29.
|
|
25
|
-
"typescript": "^5.
|
|
23
|
+
"jest": "^29.7.0",
|
|
24
|
+
"ts-jest": "^29.2.4",
|
|
25
|
+
"typescript": "^5.5.4"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"lint": "eslint . --ext .ts",
|