incyclist-devices 1.5.21 → 1.5.22
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/fe.js +4 -2
- package/lib/daum/premium/bike.d.ts +1 -1
- package/lib/daum/premium/bike.js +82 -65
- package/package.json +3 -2
package/lib/antv2/fe.js
CHANGED
|
@@ -217,7 +217,7 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
217
217
|
}), timeout);
|
|
218
218
|
this.setFEDefaultTimeout();
|
|
219
219
|
let success = false;
|
|
220
|
-
let status;
|
|
220
|
+
let status = { userSent: false, slopeSent: false };
|
|
221
221
|
let retry = 0;
|
|
222
222
|
while (!success && retry < MAX_RETRIES) {
|
|
223
223
|
retry++;
|
|
@@ -239,7 +239,8 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
239
239
|
status.userSent = status.userSent || (yield fe.sendUserConfiguration(userWeight, bikeWeight, args.wheelDiameter, args.gearRatio));
|
|
240
240
|
status.slopeSent = status.slopeSent || (yield fe.sendTrackResistance(0.0));
|
|
241
241
|
}
|
|
242
|
-
catch (
|
|
242
|
+
catch (err) {
|
|
243
|
+
this.logger.logEvent({ message: 'sending FE message error', error: err.message });
|
|
243
244
|
try {
|
|
244
245
|
yield yield this.ant.stopSensor(this.sensor);
|
|
245
246
|
}
|
|
@@ -254,6 +255,7 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
254
255
|
if (success) {
|
|
255
256
|
this.logger.logEvent({ message: 'start success' });
|
|
256
257
|
stopTimeoutCheck();
|
|
258
|
+
resolve(true);
|
|
257
259
|
}
|
|
258
260
|
else {
|
|
259
261
|
this.logger.logEvent({ message: 'start failed' });
|
package/lib/daum/premium/bike.js
CHANGED
|
@@ -118,87 +118,98 @@ class Daum8i {
|
|
|
118
118
|
this.blocked = false;
|
|
119
119
|
}
|
|
120
120
|
connect() {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
this.state.busy = true;
|
|
126
|
-
this.state.commandsInQueue = {};
|
|
127
|
-
try {
|
|
128
|
-
if (this.sp !== undefined) {
|
|
129
|
-
try {
|
|
130
|
-
this.sp.removeAllListeners();
|
|
131
|
-
this.sp.close();
|
|
132
|
-
}
|
|
133
|
-
catch (err) {
|
|
134
|
-
}
|
|
135
|
-
this.sp = undefined;
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
this.logEvent({ message: "connect()", sp: (this.sp !== undefined), connected: this.connected, blocked: this.blocked, port: this.portName, settings: this.settings });
|
|
123
|
+
if (this.connected || this.blocked) {
|
|
124
|
+
return;
|
|
136
125
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
126
|
+
this.state.busy = true;
|
|
127
|
+
this.state.commandsInQueue = {};
|
|
128
|
+
try {
|
|
129
|
+
if (this.sp !== undefined) {
|
|
130
|
+
try {
|
|
131
|
+
this.sp.removeAllListeners();
|
|
132
|
+
yield this.sp.close();
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
}
|
|
136
|
+
this.sp = undefined;
|
|
143
137
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
if (this.sp === undefined) {
|
|
139
|
+
if (this.tcpip) {
|
|
140
|
+
const { host, port } = this.tcpipConnection;
|
|
141
|
+
const { logger } = this.props;
|
|
142
|
+
this.logEvent({ message: "creating TCPSocketPort", host, port });
|
|
143
|
+
this.sp = new tcpserial_1.default({ host, port, net, timeout: OPEN_TIMEOUT, logger });
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const settings = this.settings.port || {};
|
|
147
|
+
settings.autoOpen = false;
|
|
148
|
+
this.logEvent({ message: "creating SerialPort", port: this.port, settings });
|
|
149
|
+
this.sp = new __SerialPort(this.port, settings);
|
|
150
|
+
}
|
|
151
|
+
this.sp.on('open', this.onPortOpen.bind(this));
|
|
152
|
+
this.sp.on('close', this.onPortClose.bind(this));
|
|
153
|
+
this.sp.on('error', (error) => { this.onPortError(error); });
|
|
154
|
+
this.sp.on('data', (data) => { this.onData(data); });
|
|
149
155
|
}
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
this.
|
|
153
|
-
this.
|
|
156
|
+
const start = Date.now();
|
|
157
|
+
this.state.connecting = true;
|
|
158
|
+
this.state.opening = { start, timeout: start + this.getTimeoutValue() };
|
|
159
|
+
this.logEvent({ message: "opening port ..." });
|
|
160
|
+
yield this.sp.open();
|
|
154
161
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
catch (err) {
|
|
162
|
-
this.logEvent({ message: "scan:error:", error: err.message, stack: err.stack });
|
|
163
|
-
this.state.busy = false;
|
|
164
|
-
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
this.logEvent({ message: "connect:error:", error: err.message, stack: err.stack });
|
|
164
|
+
this.state.busy = false;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
165
167
|
}
|
|
166
168
|
reconnect() {
|
|
167
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
try {
|
|
171
|
+
yield this.saveClose();
|
|
172
|
+
yield this.saveConnect();
|
|
173
|
+
}
|
|
174
|
+
catch (_a) { }
|
|
170
175
|
});
|
|
171
176
|
}
|
|
172
177
|
saveConnect() {
|
|
173
|
-
return new Promise((resolve, reject) => {
|
|
178
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
174
179
|
if (this.isConnected()) {
|
|
175
180
|
this.state.connecting = false;
|
|
176
181
|
return resolve(true);
|
|
177
182
|
}
|
|
178
|
-
|
|
183
|
+
try {
|
|
184
|
+
yield this.connect();
|
|
185
|
+
}
|
|
186
|
+
catch (_a) { }
|
|
179
187
|
const tTimeout = Date.now() + TIMEOUT_START;
|
|
180
188
|
const iv = setInterval(() => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
reject(this.state.error);
|
|
185
|
-
this.state = { opened: false, closed: true, busy: false };
|
|
186
|
-
}
|
|
187
|
-
else if (this.isConnected()) {
|
|
188
|
-
this.state.connecting = false;
|
|
189
|
-
resolve(true);
|
|
190
|
-
clearInterval(iv);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
if (Date.now() > tTimeout) {
|
|
194
|
-
this.state.connecting = false;
|
|
189
|
+
try {
|
|
190
|
+
if (this.state.error !== undefined) {
|
|
191
|
+
clearInterval(iv);
|
|
195
192
|
this.forceClose();
|
|
193
|
+
reject(this.state.error);
|
|
194
|
+
this.state = { opened: false, closed: true, busy: false };
|
|
195
|
+
}
|
|
196
|
+
else if (this.isConnected()) {
|
|
197
|
+
this.state.connecting = false;
|
|
198
|
+
resolve(true);
|
|
196
199
|
clearInterval(iv);
|
|
197
|
-
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
if (Date.now() > tTimeout) {
|
|
203
|
+
this.state.connecting = false;
|
|
204
|
+
this.forceClose();
|
|
205
|
+
clearInterval(iv);
|
|
206
|
+
reject(new Error('timeout'));
|
|
207
|
+
}
|
|
198
208
|
}
|
|
199
209
|
}
|
|
210
|
+
catch (_a) { }
|
|
200
211
|
}, 100);
|
|
201
|
-
});
|
|
212
|
+
}));
|
|
202
213
|
}
|
|
203
214
|
onPortOpen() {
|
|
204
215
|
this.error = undefined;
|
|
@@ -239,11 +250,14 @@ class Daum8i {
|
|
|
239
250
|
this.error = error;
|
|
240
251
|
if (this.blocked) {
|
|
241
252
|
if (!this.state.closed) {
|
|
242
|
-
|
|
243
|
-
this.sp
|
|
244
|
-
|
|
245
|
-
|
|
253
|
+
try {
|
|
254
|
+
if (this.sp) {
|
|
255
|
+
this.sp.removeAllListeners();
|
|
256
|
+
this.sp.close();
|
|
257
|
+
this.sp = undefined;
|
|
258
|
+
}
|
|
246
259
|
}
|
|
260
|
+
catch (_a) { }
|
|
247
261
|
this.state = { opened: false, closed: true, busy: false };
|
|
248
262
|
}
|
|
249
263
|
return;
|
|
@@ -300,7 +314,10 @@ class Daum8i {
|
|
|
300
314
|
sp.flush();
|
|
301
315
|
}
|
|
302
316
|
catch (_a) { }
|
|
303
|
-
|
|
317
|
+
try {
|
|
318
|
+
sp.close();
|
|
319
|
+
}
|
|
320
|
+
catch (_b) { }
|
|
304
321
|
this.connected = false;
|
|
305
322
|
if (updateState)
|
|
306
323
|
this.state = { opened: false, closed: true, busy: false };
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-devices",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.22",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@serialport/parser-byte-length": "^9.0.1",
|
|
6
6
|
"@serialport/parser-delimiter": "^9.0.1",
|
|
7
7
|
"@types/serialport": "^8.0.1",
|
|
8
8
|
"gd-ant-plus": "^0.0.33",
|
|
9
|
-
"incyclist-ant-plus": "
|
|
9
|
+
"incyclist-ant-plus": "file:../ant-plus",
|
|
10
|
+
"incyclist-devices": "^1.5.21",
|
|
10
11
|
"win32filetime": "^1.0.2"
|
|
11
12
|
},
|
|
12
13
|
"peerDependencies": {
|