incyclist-devices 1.5.26 → 1.5.28
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/ant-interface.js +9 -0
- package/lib/antv2/fe.js +23 -17
- package/package.json +1 -1
|
@@ -237,6 +237,15 @@ class AntInterface extends events_1.default {
|
|
|
237
237
|
const channel = sensor.getChannel();
|
|
238
238
|
if (channel) {
|
|
239
239
|
try {
|
|
240
|
+
if (!channel.flush) {
|
|
241
|
+
this.logEvent({ message: 'old version of ant-channel detected' });
|
|
242
|
+
channel.flush = () => {
|
|
243
|
+
const c = channel;
|
|
244
|
+
c.messageQueue.forEach(msg => { msg.resolve(false); });
|
|
245
|
+
c.messageQueue = [];
|
|
246
|
+
c.isWriting = false;
|
|
247
|
+
};
|
|
248
|
+
}
|
|
240
249
|
channel.flush();
|
|
241
250
|
channel.removeAllListeners('data');
|
|
242
251
|
return yield channel.stopSensor(sensor);
|
package/lib/antv2/fe.js
CHANGED
|
@@ -198,7 +198,7 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
198
198
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
199
|
_super.start.call(this, props);
|
|
200
200
|
this.startProps = props;
|
|
201
|
-
this.logger.logEvent({ message: 'starting device', props });
|
|
201
|
+
this.logger.logEvent({ message: 'starting device', props, isStarted: this.started, isReconnecting: this.isReconnecting });
|
|
202
202
|
const opts = props || {};
|
|
203
203
|
const { args = {}, user = {} } = opts;
|
|
204
204
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -248,25 +248,30 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
248
248
|
yield (0, utils_2.sleep)(2000);
|
|
249
249
|
continue;
|
|
250
250
|
}
|
|
251
|
-
|
|
252
|
-
const fe = this.sensor;
|
|
253
|
-
const mode = this.getCyclingMode();
|
|
254
|
-
const bikeType = mode ? mode.getSetting('bikeType').toLowerCase() : 'race';
|
|
255
|
-
const defaultBikeWeight = bikeType === 'mountain' ? DEFAULT_BIKE_WEIGHT_MOUNTAIN : DEFAULT_BIKE_WEIGHT;
|
|
256
|
-
const userWeight = args.userWeight || user.weight || DEFAULT_USER_WEIGHT;
|
|
257
|
-
const bikeWeight = args.bikeWeight || defaultBikeWeight;
|
|
258
|
-
status.userSent = status.userSent || (yield fe.sendUserConfiguration(userWeight, bikeWeight, args.wheelDiameter, args.gearRatio));
|
|
259
|
-
status.slopeSent = status.slopeSent || (yield fe.sendTrackResistance(0.0));
|
|
260
|
-
}
|
|
261
|
-
catch (err) {
|
|
262
|
-
this.logger.logEvent({ message: 'sending FE message error', error: err.message });
|
|
251
|
+
if (!this.isReconnecting) {
|
|
263
252
|
try {
|
|
264
|
-
|
|
253
|
+
const fe = this.sensor;
|
|
254
|
+
const mode = this.getCyclingMode();
|
|
255
|
+
const bikeType = mode ? mode.getSetting('bikeType').toLowerCase() : 'race';
|
|
256
|
+
const defaultBikeWeight = bikeType === 'mountain' ? DEFAULT_BIKE_WEIGHT_MOUNTAIN : DEFAULT_BIKE_WEIGHT;
|
|
257
|
+
const userWeight = args.userWeight || user.weight || DEFAULT_USER_WEIGHT;
|
|
258
|
+
const bikeWeight = args.bikeWeight || defaultBikeWeight;
|
|
259
|
+
status.userSent = status.userSent || (yield fe.sendUserConfiguration(userWeight, bikeWeight, args.wheelDiameter, args.gearRatio));
|
|
260
|
+
status.slopeSent = status.slopeSent || (yield fe.sendTrackResistance(0.0));
|
|
265
261
|
}
|
|
266
|
-
catch (
|
|
267
|
-
|
|
262
|
+
catch (err) {
|
|
263
|
+
this.logger.logEvent({ message: 'sending FE message error', error: err.message });
|
|
264
|
+
try {
|
|
265
|
+
yield this.ant.stopSensor(this.sensor);
|
|
266
|
+
}
|
|
267
|
+
catch (_b) { }
|
|
268
|
+
this.started = false;
|
|
269
|
+
}
|
|
270
|
+
success = status.userSent && status.slopeSent;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
success = true;
|
|
268
274
|
}
|
|
269
|
-
success = status.userSent && status.slopeSent;
|
|
270
275
|
}
|
|
271
276
|
while (success && this.dataMsgCount === 0) {
|
|
272
277
|
yield (0, utils_2.sleep)(500);
|
|
@@ -298,6 +303,7 @@ class AntFEAdapter extends ant_device_1.default {
|
|
|
298
303
|
return __awaiter(this, void 0, void 0, function* () {
|
|
299
304
|
this.logger.logEvent({ message: 'stopping device' });
|
|
300
305
|
let stopped = yield this.ant.stopSensor(this.sensor);
|
|
306
|
+
this.started = false;
|
|
301
307
|
yield _super.stop.call(this);
|
|
302
308
|
this.logger.logEvent({ message: 'stopping device done', success: stopped });
|
|
303
309
|
return stopped;
|