incyclist-devices 2.1.29 → 2.1.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.
@@ -415,7 +415,7 @@ class AntAdapter extends adpater_1.default {
415
415
  yield (0, utils_1.sleep)(20);
416
416
  }
417
417
  try {
418
- stopped = yield this.ant.stopSensor(this.sensor);
418
+ stopped = yield (0, utils_1.runWithTimeout)(this.ant.stopSensor(this.sensor), 5000);
419
419
  }
420
420
  catch (err) {
421
421
  this.logEvent({ message: 'stop sensor failed', reason: err.message });
@@ -116,12 +116,14 @@ class AntInterface extends events_1.default {
116
116
  else
117
117
  promises.push(c.channel.stopAllSensors());
118
118
  });
119
- yield Promise.allSettled(promises);
119
+ yield (0, utils_1.waitWithTimeout)(Promise.allSettled(promises), 2000, () => {
120
+ this.logEvent({ message: 'ANT+ disconnect timeout' });
121
+ });
120
122
  yield (0, utils_1.sleep)(200);
121
123
  }
122
124
  if (this.device) {
123
125
  try {
124
- closed = yield this.device.close();
126
+ closed = yield (0, utils_1.runWithTimeout)(this.device.close(), 1000);
125
127
  }
126
128
  catch (_a) {
127
129
  closed = false;
@@ -133,6 +135,7 @@ class AntInterface extends events_1.default {
133
135
  }
134
136
  catch (err) {
135
137
  this.logEvent({ message: 'Error', fn: '', error: err.message, stack: err.stack });
138
+ closed = false;
136
139
  }
137
140
  this.logEvent({ message: 'ANT+ disconnected' });
138
141
  this.connectPromise = null;
@@ -16,6 +16,7 @@ export default class AntFEAdapter extends AntAdapter<FitnessEquipmentSensorState
16
16
  protected startProps: AntDeviceProperties;
17
17
  protected promiseReconnect: Promise<boolean>;
18
18
  protected promiseSendUpdate: Promise<boolean>;
19
+ protected promiseStop: Promise<boolean>;
19
20
  constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
20
21
  getDisplayName(): string;
21
22
  isReconnecting(): boolean;
@@ -40,6 +40,8 @@ class AntFEAdapter extends adapter_1.default {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
41
  if ((this.paused || this.isReconnecting()) && !forced)
42
42
  return;
43
+ if (this.promiseStop)
44
+ return;
43
45
  if (this.promiseSendUpdate) {
44
46
  this.logEvent({ message: 'send bike update skipped', device: this.getName(), request, reason: 'busy' });
45
47
  return;
@@ -221,9 +223,18 @@ class AntFEAdapter extends adapter_1.default {
221
223
  fe.setSendTimeout(5000);
222
224
  }
223
225
  stop() {
224
- const stopped = super.stop();
225
- this.sensorConnected = false;
226
- return stopped;
226
+ const _super = Object.create(null, {
227
+ stop: { get: () => super.stop }
228
+ });
229
+ return __awaiter(this, void 0, void 0, function* () {
230
+ if (this.promiseStop)
231
+ return yield this.promiseStop;
232
+ this.promiseStop = _super.stop.call(this);
233
+ this.sensorConnected = false;
234
+ const stopped = yield this.promiseStop;
235
+ delete this.promiseStop;
236
+ return stopped;
237
+ });
227
238
  }
228
239
  reconnect() {
229
240
  return __awaiter(this, void 0, void 0, function* () {
@@ -12,7 +12,7 @@ class InterfaceFactory {
12
12
  switch (ifaceName) {
13
13
  case device_1.INTERFACE.SERIAL:
14
14
  case device_1.INTERFACE.TCPIP:
15
- const serialProps = props;
15
+ const serialProps = (props || {});
16
16
  serialProps.ifaceName = ifaceName;
17
17
  return serial_1.SerialInterface.getInstance(serialProps);
18
18
  case device_1.INTERFACE.ANT:
@@ -20,6 +20,7 @@ export default class DaumPremiumAdapter extends DaumAdapter<SerialDeviceSettings
20
20
  performCheck(): Promise<boolean>;
21
21
  getStartRetries(): number;
22
22
  getStartRetryTimeout(): number;
23
+ restart(pause?: number): Promise<boolean>;
23
24
  performStart(props?: DaumPremiumDeviceProperties, _isRelaunch?: boolean, wasPaused?: boolean): Promise<boolean>;
24
25
  requiresProgramUpload(): boolean;
25
26
  getCurrentBikeData(): Promise<IncyclistBikeData>;
@@ -122,6 +122,16 @@ class DaumPremiumAdapter extends DaumAdapter_1.default {
122
122
  getStartRetryTimeout() {
123
123
  return START_RETRY_TIMEOUT;
124
124
  }
125
+ restart(pause) {
126
+ const _super = Object.create(null, {
127
+ restart: { get: () => super.restart }
128
+ });
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ if (this.requiresProgramUpload())
131
+ return false;
132
+ return yield _super.restart.call(this, pause);
133
+ });
134
+ }
125
135
  performStart(props = {}, _isRelaunch = false, wasPaused = false) {
126
136
  return __awaiter(this, void 0, void 0, function* () {
127
137
  this.setBikeProps(props);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.1.29",
3
+ "version": "2.1.31",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",