incyclist-devices 2.0.26 → 2.0.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.
@@ -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>;
@@ -235,22 +235,21 @@ class DaumAdapterBase extends adapter_1.SerialIncyclistDevice {
235
235
  }
236
236
  update() {
237
237
  return __awaiter(this, void 0, void 0, function* () {
238
- this.logEvent({ message: 'bike update request', stopped: this.stopped, updateBusy: this.updateBusy });
239
238
  if (this.stopped)
240
239
  return;
241
240
  this.updateBusy = true;
242
241
  this.getCurrentBikeData()
243
242
  .then(bikeData => {
244
- this.updateData(this.cyclingData, bikeData);
245
- const data = this.transformData();
243
+ const incyclistData = this.updateData(this.cyclingData, bikeData);
244
+ const data = this.transformData(incyclistData);
246
245
  this.updateBusy = false;
247
246
  this.emitData(data);
248
247
  })
249
248
  .catch(err => {
250
249
  this.logEvent({ message: 'bike update error', error: err.message, stack: err.stack });
251
250
  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();
251
+ const incyclistData = this.updateData(this.cyclingData, { isPedalling, power, pedalRpm, speed, distanceInternal, heartrate, slope });
252
+ this.transformData(incyclistData);
254
253
  this.updateBusy = false;
255
254
  });
256
255
  });
@@ -310,25 +309,23 @@ class DaumAdapterBase extends adapter_1.SerialIncyclistDevice {
310
309
  this.cyclingData = this.getCyclingMode().updateData(data);
311
310
  return this.cyclingData;
312
311
  }
313
- transformData() {
314
- if (this.cyclingData === undefined)
315
- return;
312
+ transformData(cyclingData) {
316
313
  let distance = 0;
317
- if (this.distanceInternal !== undefined && this.cyclingData.distanceInternal !== undefined) {
318
- distance = this.cyclingData.distanceInternal - this.distanceInternal;
314
+ if (this.distanceInternal !== undefined && cyclingData.distanceInternal !== undefined) {
315
+ distance = cyclingData.distanceInternal - this.distanceInternal;
319
316
  }
320
- if (this.cyclingData.distanceInternal !== undefined)
321
- this.distanceInternal = this.cyclingData.distanceInternal;
317
+ if (cyclingData.distanceInternal !== undefined)
318
+ this.distanceInternal = cyclingData.distanceInternal;
322
319
  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),
320
+ speed: cyclingData.speed || 0,
321
+ slope: cyclingData.slope,
322
+ power: (0, utils_1.intVal)(cyclingData.power || 0),
323
+ cadence: (0, utils_1.intVal)(cyclingData.pedalRpm),
324
+ heartrate: (0, utils_1.intVal)(cyclingData.heartrate),
328
325
  distance,
329
326
  timestamp: Date.now(),
330
- deviceTime: this.cyclingData.time,
331
- deviceDistanceCounter: this.cyclingData.distanceInternal
327
+ deviceTime: cyclingData.time,
328
+ deviceDistanceCounter: cyclingData.distanceInternal
332
329
  };
333
330
  if (this.ignoreHrm)
334
331
  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
  }
@@ -38,7 +38,7 @@ export default class Daum8008 {
38
38
  getPort(): string;
39
39
  isConnected(): boolean;
40
40
  pauseLogging(): void;
41
- resumLogging(): void;
41
+ resumeLogging(): void;
42
42
  logEvent(e: any): void;
43
43
  connect(): Promise<boolean>;
44
44
  close(): Promise<void>;
@@ -52,7 +52,7 @@ class Daum8008 {
52
52
  pauseLogging() {
53
53
  this.isLoggingPaused = true;
54
54
  }
55
- resumLogging() {
55
+ resumeLogging() {
56
56
  this.isLoggingPaused = false;
57
57
  }
58
58
  logEvent(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.0.26",
3
+ "version": "2.0.28",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",