incyclist-devices 2.0.23 → 2.0.25

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.
@@ -193,8 +193,9 @@ class AntAdapter extends adpater_1.default {
193
193
  }
194
194
  start(props = {}) {
195
195
  return __awaiter(this, void 0, void 0, function* () {
196
- if (this.started)
196
+ if (this.started && !this.stopped)
197
197
  return true;
198
+ this.stopped = false;
198
199
  const connected = yield this.connect();
199
200
  if (!connected)
200
201
  throw new Error(`could not start device, reason:could not connect`);
@@ -266,12 +266,12 @@ class AntInterface extends events_1.default {
266
266
  return stopped;
267
267
  }
268
268
  catch (err) {
269
- this.logEvent({ message: 'could not stop sensor', error: err.message || err, stack: err.stack });
269
+ this.logEvent({ message: 'could not stop sensor', error: err.message || err, deviceID: sensor.getDeviceID(), stack: err.stack });
270
270
  return false;
271
271
  }
272
272
  }
273
273
  else {
274
- this.logEvent({ message: 'could not stop sensor', error: 'no channel attached' });
274
+ this.logEvent({ message: 'could not stop sensor', deviceID: sensor.getDeviceID(), error: 'no channel attached' });
275
275
  return false;
276
276
  }
277
277
  });
@@ -115,14 +115,14 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
115
115
  this.dataMsgCount++;
116
116
  this.lastDataTS = Date.now();
117
117
  super.onDeviceData(deviceData);
118
- if (!this.started || this.isStopped() || this.paused)
118
+ if (!this.started || this.isStopped())
119
119
  return;
120
120
  if (!this.ivDataTimeout && this.dataMsgCount > 0) {
121
121
  this.startDataTimeoutCheck();
122
122
  }
123
123
  try {
124
124
  const logData = this.getLogData(deviceData, ['PairedDevices', 'RawData']);
125
- this.logger.logEvent({ message: 'onDeviceData', data: logData });
125
+ this.logger.logEvent({ message: 'onDeviceData', data: logData, paused: this.paused });
126
126
  if (!this.canSendUpdate())
127
127
  return;
128
128
  let incyclistData = this.mapToCycleModeData(deviceData);
@@ -181,10 +181,13 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
181
181
  start(props) {
182
182
  return __awaiter(this, void 0, void 0, function* () {
183
183
  const wasPaused = this.paused;
184
+ const wasStopped = this.stopped;
184
185
  this.startProps = props || {};
185
186
  if (wasPaused)
186
187
  this.resume();
187
- if (this.started && !wasPaused) {
188
+ if (wasStopped)
189
+ this.stopped = false;
190
+ if (this.started && !wasPaused && !wasStopped) {
188
191
  return true;
189
192
  }
190
193
  const connected = yield this.connect();
@@ -281,13 +284,14 @@ class AntFEAdapter extends adapter_1.ControllableAntAdapter {
281
284
  }
282
285
  }
283
286
  if (success) {
284
- this.logEvent({ message: 'start success' });
287
+ this.logEvent({ message: 'ANT FE start success' });
285
288
  this.started = true;
289
+ this.paused = false;
286
290
  stopTimeoutCheck();
287
291
  resolve(true);
288
292
  }
289
293
  else {
290
- this.logEvent({ message: 'start failed' });
294
+ this.logEvent({ message: 'ANT FE start failed' });
291
295
  stopTimeoutCheck();
292
296
  if (!hasData) {
293
297
  reject(new Error('could not start device, reason: no data received'));
@@ -149,9 +149,12 @@ class AntPwrAdapter extends adapter_1.ControllableAntAdapter {
149
149
  });
150
150
  return __awaiter(this, void 0, void 0, function* () {
151
151
  const wasPaused = this.paused;
152
+ const wasStopped = this.stopped;
152
153
  if (wasPaused)
153
154
  this.resume();
154
- if (this.started && !wasPaused) {
155
+ if (wasStopped)
156
+ this.stopped = false;
157
+ if (this.started && !wasPaused && !wasStopped) {
155
158
  return true;
156
159
  }
157
160
  return yield _super.start.call(this, props);
@@ -164,7 +164,13 @@ class BleAdapter extends adpater_1.default {
164
164
  }
165
165
  start(props = {}) {
166
166
  return __awaiter(this, void 0, void 0, function* () {
167
- if (this.started)
167
+ const wasPaused = this.paused;
168
+ const wasStopped = this.stopped;
169
+ if (wasPaused)
170
+ this.resume();
171
+ if (wasStopped)
172
+ this.stopped = false;
173
+ if (this.started && !wasPaused && !wasStopped)
168
174
  return true;
169
175
  const connected = yield this.connect();
170
176
  if (!connected)
@@ -113,9 +113,12 @@ class BleFmAdapter extends adapter_1.BleControllableAdapter {
113
113
  start(props = {}) {
114
114
  return __awaiter(this, void 0, void 0, function* () {
115
115
  const wasPaused = this.paused;
116
+ const wasStopped = this.stopped;
116
117
  if (wasPaused)
117
118
  this.resume();
118
- if (this.started && !wasPaused)
119
+ if (wasStopped)
120
+ this.stopped = false;
121
+ if (this.started && !wasPaused && !wasStopped)
119
122
  return true;
120
123
  this.logEvent(Object.assign(Object.assign({ message: 'starting device' }, this.getSettings()), { protocol: this.getProtocolName(), props, isStarted: this.started, isConnected: this.getComms().isConnected() }));
121
124
  const { restart = wasPaused } = props;
@@ -40,7 +40,13 @@ class BleTacxFEAdapter extends fm_1.BleFmAdapter {
40
40
  }
41
41
  start(props = {}) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- if (this.started)
43
+ const wasPaused = this.paused;
44
+ const wasStopped = this.stopped;
45
+ if (wasPaused)
46
+ this.resume();
47
+ if (wasStopped)
48
+ this.stopped = false;
49
+ if (this.started && !wasPaused && !wasStopped)
44
50
  return true;
45
51
  if (this.ble.isScanning()) {
46
52
  this.logger.logEvent({ message: 'stop previous scan', isScanning: this.ble.isScanning() });
@@ -40,6 +40,14 @@ class BleWahooAdapter extends fm_1.BleFmAdapter {
40
40
  }
41
41
  start(props = {}) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
+ const wasPaused = this.paused;
44
+ const wasStopped = this.stopped;
45
+ if (wasPaused)
46
+ this.resume();
47
+ if (wasStopped)
48
+ this.stopped = false;
49
+ if (this.started && !wasPaused && !wasStopped)
50
+ return true;
43
51
  this.logger.logEvent({ message: 'start requested', protocol: this.getProtocolName(), props });
44
52
  try {
45
53
  if (this.ble.isScanning()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.0.23",
3
+ "version": "2.0.25",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",