incyclist-devices 2.0.26 → 2.0.27

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.
@@ -50,7 +50,7 @@ export default class DaumAdapterBase extends SerialIncyclistDevice implements Da
50
50
  sendRequests(): Promise<void>;
51
51
  bikeSync(): Promise<void>;
52
52
  updateData(prev: any, bikeData: any): IncyclistBikeData;
53
- transformData(): DeviceData;
53
+ transformData(cyclingData: IncyclistBikeData): DeviceData;
54
54
  sendRequest(request: any): Promise<any>;
55
55
  refreshRequests(): void;
56
56
  processClientRequest(request: any): Promise<unknown>;
@@ -241,16 +241,17 @@ class DaumAdapterBase extends adapter_1.SerialIncyclistDevice {
241
241
  this.updateBusy = true;
242
242
  this.getCurrentBikeData()
243
243
  .then(bikeData => {
244
- this.updateData(this.cyclingData, bikeData);
245
- const data = this.transformData();
244
+ this.logEvent({ message: 'bike data', data: bikeData });
245
+ const incyclistData = this.updateData(this.cyclingData, bikeData);
246
+ const data = this.transformData(incyclistData);
246
247
  this.updateBusy = false;
247
248
  this.emitData(data);
248
249
  })
249
250
  .catch(err => {
250
251
  this.logEvent({ message: 'bike update error', error: err.message, stack: err.stack });
251
252
  const { isPedalling, power, pedalRpm, speed, distanceInternal, heartrate, slope } = this.cyclingData;
252
- this.updateData(this.cyclingData, { isPedalling, power, pedalRpm, speed, distanceInternal, heartrate, slope });
253
- this.transformData();
253
+ const incyclistData = this.updateData(this.cyclingData, { isPedalling, power, pedalRpm, speed, distanceInternal, heartrate, slope });
254
+ this.transformData(incyclistData);
254
255
  this.updateBusy = false;
255
256
  });
256
257
  });
@@ -310,25 +311,23 @@ class DaumAdapterBase extends adapter_1.SerialIncyclistDevice {
310
311
  this.cyclingData = this.getCyclingMode().updateData(data);
311
312
  return this.cyclingData;
312
313
  }
313
- transformData() {
314
- if (this.cyclingData === undefined)
315
- return;
314
+ transformData(cyclingData) {
316
315
  let distance = 0;
317
- if (this.distanceInternal !== undefined && this.cyclingData.distanceInternal !== undefined) {
318
- distance = this.cyclingData.distanceInternal - this.distanceInternal;
316
+ if (this.distanceInternal !== undefined && cyclingData.distanceInternal !== undefined) {
317
+ distance = cyclingData.distanceInternal - this.distanceInternal;
319
318
  }
320
- if (this.cyclingData.distanceInternal !== undefined)
321
- this.distanceInternal = this.cyclingData.distanceInternal;
319
+ if (cyclingData.distanceInternal !== undefined)
320
+ this.distanceInternal = cyclingData.distanceInternal;
322
321
  let data = {
323
- speed: this.cyclingData.speed,
324
- slope: this.cyclingData.slope,
325
- power: (0, utils_1.intVal)(this.cyclingData.power),
326
- cadence: (0, utils_1.intVal)(this.cyclingData.pedalRpm),
327
- heartrate: (0, utils_1.intVal)(this.cyclingData.heartrate),
322
+ speed: cyclingData.speed || 0,
323
+ slope: cyclingData.slope,
324
+ power: (0, utils_1.intVal)(cyclingData.power || 0),
325
+ cadence: (0, utils_1.intVal)(cyclingData.pedalRpm),
326
+ heartrate: (0, utils_1.intVal)(cyclingData.heartrate),
328
327
  distance,
329
328
  timestamp: Date.now(),
330
- deviceTime: this.cyclingData.time,
331
- deviceDistanceCounter: this.cyclingData.distanceInternal
329
+ deviceTime: cyclingData.time,
330
+ deviceDistanceCounter: cyclingData.distanceInternal
332
331
  };
333
332
  if (this.ignoreHrm)
334
333
  delete data.heartrate;
@@ -169,6 +169,7 @@ class DaumClassicAdapter extends DaumAdapter_1.default {
169
169
  if (!this.startPromise) {
170
170
  if (isRelaunch) {
171
171
  yield this.stop();
172
+ this.bike.resumeLogging();
172
173
  }
173
174
  this.startPromise = this.performStart(props, isRelaunch);
174
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.0.26",
3
+ "version": "2.0.27",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",