incyclist-devices 2.3.15 → 2.3.17

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.
@@ -217,10 +217,16 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
217
217
  const OpCode = data.readUInt8(0);
218
218
  switch (OpCode) {
219
219
  case 8:
220
- this.data.targetPower = data.readInt16LE(1);
220
+ if (data.length >= 3)
221
+ this.data.targetPower = data.readInt16LE(1);
222
+ else
223
+ this.logEvent({ message: 'warning', fn: 'parseFitnessMachineStatus()', warning: 'invalid message - message too short', data: data.toString('hex') });
221
224
  break;
222
225
  case 6:
223
- this.data.targetInclination = data.readInt16LE(1) / 10;
226
+ if (data.length >= 3)
227
+ this.data.targetInclination = data.readInt16LE(1) / 10;
228
+ else
229
+ this.logEvent({ message: 'warning', fn: 'parseFitnessMachineStatus()', warning: 'invalid message - message too short', data: data.toString('hex') });
224
230
  break;
225
231
  case 4:
226
232
  this.data.status = "STARTED";
@@ -230,7 +236,7 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
230
236
  this.data.status = "STOPPED";
231
237
  break;
232
238
  case 20:
233
- {
239
+ if (data.length >= 2) {
234
240
  const spinDownStatus = data.readUInt8(1);
235
241
  switch (spinDownStatus) {
236
242
  case 1:
@@ -248,10 +254,14 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
248
254
  default: break;
249
255
  }
250
256
  }
257
+ else {
258
+ this.logEvent({ message: 'warning', fn: 'parseFitnessMachineStatus()', warning: 'invalid message - message too short', data: data.toString('hex') });
259
+ }
260
+ break;
251
261
  }
252
262
  }
253
263
  catch (err) {
254
- this.logEvent({ message: 'error', fn: 'parseFitnessMachineStatus()', error: err.message | err, stack: err.stack });
264
+ this.logEvent({ message: 'error', fn: 'parseFitnessMachineStatus()', error: err.message, data: data.toString('hex'), stack: err.stack });
255
265
  }
256
266
  return Object.assign(Object.assign({}, this.data), { raw: `2ada:${data.toString('hex')}` });
257
267
  }
@@ -1,7 +1,7 @@
1
1
  import { IncyclistDeviceAdapter } from "../base/adpater";
2
2
  import { DeviceProperties, DeviceSettings } from "../types/device";
3
3
  export default class AdapterFactory {
4
- static adapters: IncyclistDeviceAdapter[];
4
+ protected static adapters: IncyclistDeviceAdapter[];
5
5
  static reset(): void;
6
6
  static create(settings: DeviceSettings, props?: DeviceProperties): any;
7
7
  }
@@ -40,10 +40,7 @@ class AdapterFactory {
40
40
  adapter = ble_1.BleAdapterFactory.getInstance('ble').createInstance(settings, props);
41
41
  break;
42
42
  case device_1.INTERFACE.DC:
43
- {
44
- const factory = ble_1.BleAdapterFactory.getInstance('wifi');
45
- adapter = ble_1.BleAdapterFactory.getInstance('wifi').createInstance(settings, props);
46
- }
43
+ adapter = ble_1.BleAdapterFactory.getInstance('wifi').createInstance(settings, props);
47
44
  break;
48
45
  case device_1.INTERFACE.SIMULATOR:
49
46
  adapter = new Simulator_1.Simulator(settings, props);
@@ -25,10 +25,10 @@ class SmartTrainerCyclingMode extends power_base_1.default {
25
25
  }
26
26
  checkSlope(request, newRequest = {}) {
27
27
  if (request.slope !== undefined) {
28
- newRequest.slope = parseFloat(request.slope.toFixed(1));
28
+ const targetSlope = newRequest.slope = parseFloat(request.slope.toFixed(1));
29
29
  this.data.slope = newRequest.slope;
30
30
  try {
31
- const slopeAdj = this.getSetting('slopeAdj');
31
+ const slopeAdj = targetSlope >= 0 ? this.getSetting('slopeAdj') : this.getSetting('slopeAdjDown');
32
32
  if (slopeAdj !== undefined)
33
33
  newRequest.slope = newRequest.slope * slopeAdj / 100;
34
34
  }
@@ -59,6 +59,7 @@ class SmartTrainerCyclingMode extends power_base_1.default {
59
59
  catch (err) {
60
60
  this.logger.logEvent({ message: "error", fn: 'sendBikeUpdate()', error: err.message, stack: err.stack });
61
61
  }
62
+ console.log('#sendBikeUpdate', newRequest);
62
63
  return newRequest;
63
64
  }
64
65
  }
@@ -68,7 +69,8 @@ SmartTrainerCyclingMode.config = {
68
69
  description: "Calculates speed based on power and slope. Slope is set to the device",
69
70
  properties: [
70
71
  { key: 'bikeType', name: 'Bike Type', description: '', type: types_1.CyclingModeProperyType.SingleSelect, options: ['Race', 'Mountain', 'Triathlon'], default: 'Race' },
71
- { key: 'slopeAdj', name: 'Slope Adjustment', description: 'Percentage of slope that should be sent to the SmartTrainer. Should be used in case the slopes are feeling too hard', type: types_1.CyclingModeProperyType.Integer, default: 100, min: 0, max: 200 }
72
+ { key: 'slopeAdj', name: 'Bike Reality Factor', description: 'Percentage of slope that should be sent to the SmartTrainer. Should be used in case the slopes are feeling too hard', type: types_1.CyclingModeProperyType.Integer, default: 100, min: 0, max: 200 },
73
+ { key: 'slopeAdjDown', name: 'Bike Reality Factor downhill', description: 'Percentage of slope that should be sent during downhill sections. Should be used to avoid spinning out', type: types_1.CyclingModeProperyType.Integer, default: 50, min: 0, max: 100 }
72
74
  ]
73
75
  };
74
76
  exports.default = SmartTrainerCyclingMode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.3.15",
3
+ "version": "2.3.17",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",