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.
|
|
245
|
-
const
|
|
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 &&
|
|
318
|
-
distance =
|
|
316
|
+
if (this.distanceInternal !== undefined && cyclingData.distanceInternal !== undefined) {
|
|
317
|
+
distance = cyclingData.distanceInternal - this.distanceInternal;
|
|
319
318
|
}
|
|
320
|
-
if (
|
|
321
|
-
this.distanceInternal =
|
|
319
|
+
if (cyclingData.distanceInternal !== undefined)
|
|
320
|
+
this.distanceInternal = cyclingData.distanceInternal;
|
|
322
321
|
let data = {
|
|
323
|
-
speed:
|
|
324
|
-
slope:
|
|
325
|
-
power: (0, utils_1.intVal)(
|
|
326
|
-
cadence: (0, utils_1.intVal)(
|
|
327
|
-
heartrate: (0, utils_1.intVal)(
|
|
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:
|
|
331
|
-
deviceDistanceCounter:
|
|
329
|
+
deviceTime: cyclingData.time,
|
|
330
|
+
deviceDistanceCounter: cyclingData.distanceInternal
|
|
332
331
|
};
|
|
333
332
|
if (this.ignoreHrm)
|
|
334
333
|
delete data.heartrate;
|