incyclist-devices 2.0.29 → 2.0.31
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/ble/wahoo/adapter.js +0 -3
- package/lib/serial/daum/DaumAdapter.js +1 -0
- package/lib/serial/daum/classic/adapter.d.ts +2 -0
- package/lib/serial/daum/classic/adapter.js +26 -1
- package/lib/serial/daum/classic/comms.js +19 -10
- package/lib/serial/daum/premium/adapter.js +6 -3
- package/lib/serial/daum/premium/mock.d.ts +2 -2
- package/lib/serial/serial-interface.js +4 -4
- package/package.json +1 -1
package/lib/ble/wahoo/adapter.js
CHANGED
|
@@ -83,9 +83,6 @@ class BleWahooAdapter extends fm_1.BleFmAdapter {
|
|
|
83
83
|
comms.on('data', (data) => {
|
|
84
84
|
this.onDeviceData(data);
|
|
85
85
|
});
|
|
86
|
-
if (comms.features.heartrate && !this.hasCapability(capabilities_1.IncyclistCapability.HeartRate)) {
|
|
87
|
-
this.capabilities.push(capabilities_1.IncyclistCapability.HeartRate);
|
|
88
|
-
}
|
|
89
86
|
this.resetData();
|
|
90
87
|
this.stopped = false;
|
|
91
88
|
this.started = true;
|
|
@@ -11,6 +11,7 @@ export default class DaumClassicAdapter extends DaumAdapter {
|
|
|
11
11
|
id: string;
|
|
12
12
|
started: boolean;
|
|
13
13
|
startPromise: Promise<unknown>;
|
|
14
|
+
checkPromise: Promise<boolean>;
|
|
14
15
|
constructor(settings: SerialDeviceSettings, props?: DeviceProperties);
|
|
15
16
|
setID(id: any): void;
|
|
16
17
|
getID(): string;
|
|
@@ -21,6 +22,7 @@ export default class DaumClassicAdapter extends DaumAdapter {
|
|
|
21
22
|
getSupportedCyclingModes(): Array<any>;
|
|
22
23
|
getDefaultCyclingMode(): CyclingMode;
|
|
23
24
|
check(): Promise<boolean>;
|
|
25
|
+
performCheck(): Promise<boolean>;
|
|
24
26
|
pause(): Promise<boolean>;
|
|
25
27
|
resume(): Promise<boolean>;
|
|
26
28
|
startRide(props?: DaumClassicDeviceProperties): Promise<boolean>;
|
|
@@ -51,6 +51,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
51
51
|
this.iv = undefined;
|
|
52
52
|
this.distanceInternal = undefined;
|
|
53
53
|
this.startPromise = undefined;
|
|
54
|
+
this.checkPromise = undefined;
|
|
54
55
|
this.initData();
|
|
55
56
|
}
|
|
56
57
|
setID(id) {
|
|
@@ -81,9 +82,32 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
81
82
|
}
|
|
82
83
|
check() {
|
|
83
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
var info = {};
|
|
85
85
|
if (this.isStopped())
|
|
86
86
|
return false;
|
|
87
|
+
if (this.checkPromise) {
|
|
88
|
+
this.logEvent({ message: "waiting for previous check device", port: this.getPort() });
|
|
89
|
+
try {
|
|
90
|
+
yield this.checkPromise;
|
|
91
|
+
}
|
|
92
|
+
catch (_a) { }
|
|
93
|
+
this.logEvent({ message: "previous check device completed", port: this.getPort() });
|
|
94
|
+
this.checkPromise = undefined;
|
|
95
|
+
}
|
|
96
|
+
this.checkPromise = this.performCheck();
|
|
97
|
+
try {
|
|
98
|
+
const res = yield this.checkPromise;
|
|
99
|
+
this.checkPromise = undefined;
|
|
100
|
+
return res;
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
this.checkPromise = undefined;
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
performCheck() {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
var info = {};
|
|
87
111
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
88
112
|
this.logEvent({ message: "checking device", port: this.getPort() });
|
|
89
113
|
const iv = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -109,6 +133,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
|
|
|
109
133
|
resolve(true);
|
|
110
134
|
}
|
|
111
135
|
catch (err) {
|
|
136
|
+
clearTimeout(iv);
|
|
112
137
|
this.logEvent({ message: "checking device failed", port: this.getPort(), reason: err.message || err });
|
|
113
138
|
resolve(false);
|
|
114
139
|
}
|
|
@@ -94,20 +94,27 @@ class Daum8008 {
|
|
|
94
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
95
|
if (!this.serial)
|
|
96
96
|
return;
|
|
97
|
+
this.closing = true;
|
|
97
98
|
this.stopWorker();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
if (this.isConnected()) {
|
|
100
|
+
try {
|
|
101
|
+
yield this.flush();
|
|
102
|
+
}
|
|
103
|
+
catch (_a) { }
|
|
104
|
+
try {
|
|
105
|
+
yield this.serial.closePort(this.portName);
|
|
106
|
+
}
|
|
107
|
+
catch (_b) { }
|
|
101
108
|
}
|
|
102
|
-
catch (_a) { }
|
|
103
109
|
this.connected = false;
|
|
104
|
-
|
|
110
|
+
this.cmdBusy = false;
|
|
111
|
+
if (this.sp) {
|
|
105
112
|
this.sp.removeAllListeners();
|
|
106
|
-
|
|
113
|
+
this.sp = null;
|
|
114
|
+
}
|
|
107
115
|
this.error = undefined;
|
|
108
116
|
this.closing = false;
|
|
109
117
|
this.closed = true;
|
|
110
|
-
this.cmdBusy = false;
|
|
111
118
|
return;
|
|
112
119
|
});
|
|
113
120
|
}
|
|
@@ -116,8 +123,9 @@ class Daum8008 {
|
|
|
116
123
|
if (!this.cmdBusy)
|
|
117
124
|
return;
|
|
118
125
|
return new Promise(done => {
|
|
126
|
+
const tsStart = Date.now();
|
|
119
127
|
const iv = setInterval(() => {
|
|
120
|
-
if (!this.cmdBusy) {
|
|
128
|
+
if (!this.cmdBusy || (Date.now() - tsStart > TIMEOUT_SEND + 500)) {
|
|
121
129
|
clearInterval(iv);
|
|
122
130
|
done();
|
|
123
131
|
}
|
|
@@ -176,7 +184,7 @@ class Daum8008 {
|
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
186
|
}
|
|
179
|
-
if (this.connected && this.cmdBusy) {
|
|
187
|
+
if (this.connected && this.cmdBusy && !this.closing) {
|
|
180
188
|
if (this.cmdCurrent !== undefined && this.cmdCurrent.start !== undefined) {
|
|
181
189
|
const cmdInfo = this.cmdCurrent;
|
|
182
190
|
const timeout = (cmdInfo.options && cmdInfo.options.timeout) ? cmdInfo.options.timeout : this._timeoutSend;
|
|
@@ -205,7 +213,8 @@ class Daum8008 {
|
|
|
205
213
|
return;
|
|
206
214
|
}
|
|
207
215
|
const cmd = this.queue.dequeue();
|
|
208
|
-
this.
|
|
216
|
+
if (this.connected && !this.closing && !this.closed)
|
|
217
|
+
this.send(cmd);
|
|
209
218
|
}
|
|
210
219
|
sendDaum8008Command(logStr, payload, expected, callback, callbackErr, options) {
|
|
211
220
|
let cmdInfo = {
|
|
@@ -92,10 +92,13 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
|
|
|
92
92
|
}
|
|
93
93
|
isEqual(settings) {
|
|
94
94
|
if (this.getInterface() === device_1.INTERFACE.TCPIP) {
|
|
95
|
-
const equal = super.isEqual(settings);
|
|
96
|
-
if (!equal)
|
|
97
|
-
return false;
|
|
98
95
|
const as = this.settings;
|
|
96
|
+
if (settings.interface !== this.getInterface())
|
|
97
|
+
return false;
|
|
98
|
+
if (settings.protocol !== as.protocol)
|
|
99
|
+
return false;
|
|
100
|
+
if ((settings.port || DAUM_PREMIUM_DEFAULT_PORT) !== (as.port || DAUM_PREMIUM_DEFAULT_PORT))
|
|
101
|
+
return false;
|
|
99
102
|
return (settings.host === as.host);
|
|
100
103
|
}
|
|
101
104
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { MockBindingInterface, MockPortBinding, CreatePortOptions } from '@serialport/binding-mock';
|
|
3
|
-
import { BindingInterface
|
|
3
|
+
import { BindingInterface } from '@serialport/bindings-interface';
|
|
4
4
|
import { User } from '../../../types/user';
|
|
5
5
|
export type MockProps = {
|
|
6
6
|
interface: string;
|
|
@@ -25,7 +25,7 @@ export declare class Daum8iMockImpl {
|
|
|
25
25
|
getSimulator(path: any): Daum8MockSimulator;
|
|
26
26
|
reset(): void;
|
|
27
27
|
createPort(path: string, options?: CreatePortOptions): void;
|
|
28
|
-
list(): Promise<PortInfo[]>;
|
|
28
|
+
list(): Promise<import("@serialport/bindings-interface").PortInfo[]>;
|
|
29
29
|
open(options: any): Promise<Daum8iMockBinding>;
|
|
30
30
|
}
|
|
31
31
|
export declare class Daum8MockSimulator {
|
|
@@ -175,12 +175,12 @@ class SerialInterface extends events_1.default {
|
|
|
175
175
|
}
|
|
176
176
|
openPort(path) {
|
|
177
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
this.logEvent({ message: 'opening port', path });
|
|
178
|
+
this.logEvent({ message: 'opening port', port: path });
|
|
179
179
|
const existing = this.ports.findIndex(p => p.path === path);
|
|
180
180
|
if (existing !== -1) {
|
|
181
181
|
const port = this.ports[existing].port;
|
|
182
182
|
if (port.isOpen) {
|
|
183
|
-
this.logEvent({ message: 'opening port - port already exists', path });
|
|
183
|
+
this.logEvent({ message: 'opening port - port already exists', port: path });
|
|
184
184
|
return port;
|
|
185
185
|
}
|
|
186
186
|
else {
|
|
@@ -189,7 +189,7 @@ class SerialInterface extends events_1.default {
|
|
|
189
189
|
}
|
|
190
190
|
const port = serialport_1.default.getInstance().getSerialPort(this.ifaceName, { path });
|
|
191
191
|
if (!port) {
|
|
192
|
-
this.logEvent({ message: 'opening port - port does not exist', path });
|
|
192
|
+
this.logEvent({ message: 'opening port - port does not exist', port: path });
|
|
193
193
|
return null;
|
|
194
194
|
}
|
|
195
195
|
return new Promise((resolve) => {
|
|
@@ -210,7 +210,7 @@ class SerialInterface extends events_1.default {
|
|
|
210
210
|
}
|
|
211
211
|
closePort(path) {
|
|
212
212
|
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
this.logEvent({ message: 'closing port' });
|
|
213
|
+
this.logEvent({ message: 'closing port', port: path });
|
|
214
214
|
const existing = this.ports.findIndex(p => p.path === path);
|
|
215
215
|
if (existing === -1)
|
|
216
216
|
return true;
|