incyclist-devices 2.3.5 → 2.3.7

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.
@@ -294,6 +294,7 @@ class BleAdapter extends adpater_1.default {
294
294
  if (wasPaused)
295
295
  this.resume();
296
296
  if (!this.isStarting()) {
297
+ this.logEvent({ message: 'start result: interrupted', device: this.getName(), interface: this.getInterface(), protocol: this.getProtocolName() });
297
298
  this.started = false;
298
299
  this.stopped = true;
299
300
  return false;
@@ -247,6 +247,14 @@ class BleInterface extends events_1.default {
247
247
  }
248
248
  reconnect() {
249
249
  return __awaiter(this, void 0, void 0, function* () {
250
+ let error;
251
+ try {
252
+ throw new Error('');
253
+ }
254
+ catch (err) {
255
+ error = err;
256
+ }
257
+ this.logEvent({ message: 'reconnecting interface', stack: error.stack });
250
258
  yield this.disconnect();
251
259
  yield this.connect(true);
252
260
  });
@@ -22,6 +22,6 @@ export default class BleCyclingPowerDevice extends TBleSensor {
22
22
  };
23
23
  parsePower(_data: Uint8Array): PowerData;
24
24
  protected getRequiredCharacteristics(): Array<string>;
25
- onData(characteristic: string, data: Buffer): boolean;
25
+ onData(characteristic: string, characteristicData: Buffer): boolean;
26
26
  reset(): void;
27
27
  }
@@ -77,7 +77,8 @@ class BleCyclingPowerDevice extends sensor_1.TBleSensor {
77
77
  getRequiredCharacteristics() {
78
78
  return [consts_1.CSP_MEASUREMENT];
79
79
  }
80
- onData(characteristic, data) {
80
+ onData(characteristic, characteristicData) {
81
+ const data = Buffer.from(characteristicData);
81
82
  const hasData = super.onData(characteristic, data);
82
83
  if (!hasData)
83
84
  return false;
@@ -16,6 +16,6 @@ export declare class BleCyclingSpeedCadenceDevice extends TBleSensor {
16
16
  constructor(peripheral: any, props?: any);
17
17
  protected getRequiredCharacteristics(): Array<string>;
18
18
  getFeatures(): Promise<BleCSCFeatures>;
19
- onData(characteristic: string, data: Buffer): boolean;
19
+ onData(characteristic: string, characteristicData: Buffer): boolean;
20
20
  reset(): void;
21
21
  }
@@ -38,7 +38,8 @@ class BleCyclingSpeedCadenceDevice extends sensor_1.TBleSensor {
38
38
  }
39
39
  });
40
40
  }
41
- onData(characteristic, data) {
41
+ onData(characteristic, characteristicData) {
42
+ const data = Buffer.from(characteristicData);
42
43
  const hasData = super.onData(characteristic, data);
43
44
  if (!hasData)
44
45
  return false;
@@ -213,6 +213,8 @@ class BleFmAdapter extends adapter_1.default {
213
213
  return __awaiter(this, arguments, void 0, function* (request, enforced = false) {
214
214
  if (!enforced && (this.paused || !this.device))
215
215
  return;
216
+ if (!enforced && (this.stopped && !this.isStarting()))
217
+ return;
216
218
  try {
217
219
  const update = this.getCyclingMode().sendBikeUpdate(request);
218
220
  this.logEvent({ message: 'send bike update requested', profile: this.getProfile(), update, request });
@@ -21,7 +21,7 @@ export default class BleFitnessMachineDevice extends TBleSensor {
21
21
  get features(): IndoorBikeFeatures;
22
22
  reset(): void;
23
23
  protected getRequiredCharacteristics(): Array<string>;
24
- onData(characteristic: string, data: Buffer): boolean;
24
+ onData(characteristic: string, characteristicData: Buffer): boolean;
25
25
  setCrr(crr: number): void;
26
26
  getCrr(): number;
27
27
  setCw(cw: number): void;
@@ -35,7 +35,8 @@ class BleFitnessMachineDevice extends sensor_1.TBleSensor {
35
35
  getRequiredCharacteristics() {
36
36
  return [consts_1.INDOOR_BIKE_DATA, '2a37', consts_1.FTMS_STATUS];
37
37
  }
38
- onData(characteristic, data) {
38
+ onData(characteristic, characteristicData) {
39
+ const data = Buffer.from(characteristicData);
39
40
  try {
40
41
  const hasData = super.onData(characteristic, data);
41
42
  if (!hasData)
@@ -13,5 +13,5 @@ export default class BleHrmDevice extends TBleSensor {
13
13
  parseHrm(_data: Uint8Array): HrmData;
14
14
  reset(): void;
15
15
  protected getRequiredCharacteristics(): Array<string>;
16
- onData(characteristic: string, data: Buffer): boolean;
16
+ onData(characteristic: string, characteristicData: Buffer): boolean;
17
17
  }
@@ -32,7 +32,8 @@ class BleHrmDevice extends sensor_1.TBleSensor {
32
32
  getRequiredCharacteristics() {
33
33
  return [consts_1.HR_MEASUREMENT];
34
34
  }
35
- onData(characteristic, data) {
35
+ onData(characteristic, characteristicData) {
36
+ const data = Buffer.from(characteristicData);
36
37
  const hasData = super.onData(characteristic, data);
37
38
  if (!hasData)
38
39
  return;
@@ -26,7 +26,7 @@ export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineD
26
26
  constructor(peripheral: any, props?: any);
27
27
  reset(): void;
28
28
  protected getRequiredCharacteristics(): Array<string>;
29
- onData(characteristic: string, data: Buffer): boolean;
29
+ onData(characteristic: string, characteristicData: Buffer): boolean;
30
30
  protected isDuplicate(characteristic: string, data: Buffer): boolean;
31
31
  setTargetPower(power: number): Promise<boolean>;
32
32
  setSlope(slope: any): Promise<boolean>;
@@ -36,7 +36,8 @@ class TacxAdvancedFitnessMachineDevice extends sensor_1.default {
36
36
  getRequiredCharacteristics() {
37
37
  return [consts_1.INDOOR_BIKE_DATA, '2a37', consts_1.FTMS_STATUS, consts_1.CSP_MEASUREMENT, consts_1.CSC_MEASUREMENT, this.tacxRx];
38
38
  }
39
- onData(characteristic, data) {
39
+ onData(characteristic, characteristicData) {
40
+ const data = Buffer.from(characteristicData);
40
41
  const isDuplicate = this.isDuplicate(characteristic, data);
41
42
  if (isDuplicate) {
42
43
  return false;
@@ -75,7 +76,7 @@ class TacxAdvancedFitnessMachineDevice extends sensor_1.default {
75
76
  return res;
76
77
  }
77
78
  catch (err) {
78
- this.logEvent({ message: 'error', fn: 'tacx.onData()', error: err.message || err, stack: err.stack });
79
+ this.logEvent({ message: 'error', fn: 'tacx.onData()', error: err.message || err, stack: err.stack, dataType: typeof (characteristicData) });
79
80
  }
80
81
  }
81
82
  isDuplicate(characteristic, data) {
@@ -427,7 +428,7 @@ class TacxAdvancedFitnessMachineDevice extends sensor_1.default {
427
428
  res.raw = data.toString('hex');
428
429
  }
429
430
  catch (err) {
430
- this.logEvent({ message: 'error', fn: 'parseFECMessage()', error: err.message || err, stack: err.stack });
431
+ this.logEvent({ message: 'error', fn: 'parseFECMessage()', error: err.message || err, stack: err.stack, dataType: typeof (data) });
431
432
  }
432
433
  return res;
433
434
  }
@@ -27,7 +27,7 @@ export default class BleWahooDevice extends BleFitnessMachineDevice {
27
27
  isMatching(serviceUUIDs: string[]): boolean;
28
28
  reset(): void;
29
29
  protected getRequiredCharacteristics(): Array<string>;
30
- onData(characteristic: string, data: Buffer): boolean;
30
+ onData(characteristic: string, characteristicData: Buffer): boolean;
31
31
  requestControl(): Promise<boolean>;
32
32
  setTargetPower(power: number): Promise<boolean>;
33
33
  setSlope(slope: any): Promise<boolean>;
@@ -42,7 +42,8 @@ class BleWahooDevice extends sensor_1.default {
42
42
  getRequiredCharacteristics() {
43
43
  return [consts_2.INDOOR_BIKE_DATA, consts_2.FTMS_STATUS, consts_2.CSP_MEASUREMENT, consts_2.HR_MEASUREMENT];
44
44
  }
45
- onData(characteristic, data) {
45
+ onData(characteristic, characteristicData) {
46
+ const data = Buffer.from(characteristicData);
46
47
  const uuid = (0, utils_1.beautifyUUID)(characteristic).toLowerCase();
47
48
  let res;
48
49
  switch (uuid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",