incyclist-devices 1.4.70 → 1.4.73

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.
@@ -198,18 +198,24 @@ class BleInterface extends ble_1.BleInterfaceClass {
198
198
  return [];
199
199
  }
200
200
  const get = (deviceTypes, fnCompare) => {
201
- return deviceTypes.filter(DeviceType => {
201
+ const types = deviceTypes.filter(DeviceType => {
202
202
  const C = DeviceType;
203
- if (!C.services)
204
- return false;
205
- return C.services.find((s) => fnCompare(s));
203
+ let found = false;
204
+ if (C.services)
205
+ found = C.services.find((s) => fnCompare(s));
206
+ return found;
206
207
  });
208
+ return types;
207
209
  };
208
210
  if (typeof services === 'string') {
209
- return get(deviceTypes, (s) => s === (0, ble_1.uuid)(services));
211
+ return get(deviceTypes, (s) => (0, ble_1.uuid)(s) === (0, ble_1.uuid)(services));
210
212
  }
211
213
  if (Array.isArray(services)) {
212
- return get(deviceTypes, s => services.map(ble_1.uuid).includes(s));
214
+ const sids = services.map(ble_1.uuid);
215
+ return get(deviceTypes, s => {
216
+ const res = sids.includes((0, ble_1.uuid)(s));
217
+ return res;
218
+ });
213
219
  }
214
220
  return [];
215
221
  }
@@ -579,7 +585,12 @@ class BleInterface extends ble_1.BleInterfaceClass {
579
585
  const d = this.createDevice(DeviceClass, peripheral, characteristics);
580
586
  if (!d)
581
587
  return;
582
- yield d.connect();
588
+ try {
589
+ yield d.connect();
590
+ }
591
+ catch (err) {
592
+ this.logEvent({ message: 'error', fn: 'onPeripheralFound()', error: err.message || err, stack: err.stack });
593
+ }
583
594
  if (scanForDevice) {
584
595
  if ((id && id !== '' && d.id === id) ||
585
596
  (address && address !== '' && d.address === address) ||
package/lib/ble/fm.d.ts CHANGED
@@ -8,6 +8,9 @@ import { DeviceProtocol } from '../DeviceProtocol';
8
8
  import { EventLogger } from 'gd-eventlog';
9
9
  import CyclingMode from '../CyclingMode';
10
10
  import { IncyclistBikeData } from '../CyclingMode';
11
+ export declare const FTMS_CP = "2ad9";
12
+ export declare const FTMS_STATUS = "2ada";
13
+ export declare const INDOOR_BIKE_DATA = "2ad2";
11
14
  declare type PowerData = {
12
15
  instantaneousPower?: number;
13
16
  balance?: number;
package/lib/ble/fm.js CHANGED
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.FmAdapter = void 0;
15
+ exports.FmAdapter = exports.INDOOR_BIKE_DATA = exports.FTMS_STATUS = exports.FTMS_CP = void 0;
16
16
  const ble_device_1 = require("./ble-device");
17
17
  const ble_interface_1 = __importDefault(require("./ble-interface"));
18
18
  const Device_1 = __importDefault(require("../Device"));
@@ -20,9 +20,9 @@ const gd_eventlog_1 = require("gd-eventlog");
20
20
  const power_meter_1 = __importDefault(require("../modes/power-meter"));
21
21
  const ble_st_mode_1 = __importDefault(require("./ble-st-mode"));
22
22
  const ble_erg_mode_1 = __importDefault(require("./ble-erg-mode"));
23
- const FTMS_CP = '2ad9';
24
- const FTMS_STATUS = '2ada';
25
- const INDOOR_BIKE_DATA = '2ad2';
23
+ exports.FTMS_CP = '2ad9';
24
+ exports.FTMS_STATUS = '2ada';
25
+ exports.INDOOR_BIKE_DATA = '2ad2';
26
26
  const cwABike = {
27
27
  race: 0.35,
28
28
  triathlon: 0.29,
@@ -99,9 +99,9 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
99
99
  isMatching(characteristics) {
100
100
  if (!characteristics)
101
101
  return false;
102
- const hasStatus = characteristics.find(c => c === FTMS_STATUS) !== undefined;
103
- const hasCP = characteristics.find(c => c === FTMS_CP) !== undefined;
104
- const hasIndoorBike = characteristics.find(c => c === INDOOR_BIKE_DATA) !== undefined;
102
+ const hasStatus = characteristics.find(c => c === exports.FTMS_STATUS) !== undefined;
103
+ const hasCP = characteristics.find(c => c === exports.FTMS_CP) !== undefined;
104
+ const hasIndoorBike = characteristics.find(c => c === exports.INDOOR_BIKE_DATA) !== undefined;
105
105
  return hasStatus && hasCP && hasIndoorBike;
106
106
  }
107
107
  subscribeWriteResponse(cuuid) {
@@ -131,7 +131,7 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
131
131
  });
132
132
  return __awaiter(this, void 0, void 0, function* () {
133
133
  try {
134
- yield this.subscribeWriteResponse(FTMS_CP);
134
+ yield this.subscribeWriteResponse(exports.FTMS_CP);
135
135
  yield _super.initDevice.call(this);
136
136
  yield this.getFitnessMachineFeatures();
137
137
  this.logEvent({ message: 'device info', deviceInfo: this.deviceInfo, features: this.features });
@@ -310,13 +310,13 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
310
310
  const uuid = characteristic.toLocaleLowerCase();
311
311
  let res = undefined;
312
312
  switch (uuid) {
313
- case INDOOR_BIKE_DATA:
313
+ case exports.INDOOR_BIKE_DATA:
314
314
  res = this.parseIndoorBikeData(data);
315
315
  break;
316
316
  case '2a37':
317
317
  res = this.parseHrm(data);
318
318
  break;
319
- case FTMS_STATUS:
319
+ case exports.FTMS_STATUS:
320
320
  res = this.parseFitnessMachineStatus(data);
321
321
  break;
322
322
  case '2a63':
@@ -334,7 +334,7 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
334
334
  return __awaiter(this, void 0, void 0, function* () {
335
335
  try {
336
336
  this.logEvent({ message: 'fmts:write', data: data.toString('hex') });
337
- const res = yield this.write(FTMS_CP, data);
337
+ const res = yield this.write(exports.FTMS_CP, data);
338
338
  const responseData = Buffer.from(res);
339
339
  const opCode = responseData.readUInt8(0);
340
340
  const request = responseData.readUInt8(1);
@@ -486,7 +486,7 @@ class BleFitnessMachineDevice extends ble_device_1.BleDevice {
486
486
  }
487
487
  exports.default = BleFitnessMachineDevice;
488
488
  BleFitnessMachineDevice.services = ['1826'];
489
- BleFitnessMachineDevice.characteristics = ['2acc', INDOOR_BIKE_DATA, '2ad6', '2ad8', FTMS_CP, FTMS_STATUS];
489
+ BleFitnessMachineDevice.characteristics = ['2acc', exports.INDOOR_BIKE_DATA, '2ad6', '2ad8', exports.FTMS_CP, exports.FTMS_STATUS];
490
490
  ble_interface_1.default.register('BleFitnessMachineDevice', 'fm', BleFitnessMachineDevice, BleFitnessMachineDevice.services);
491
491
  class FmAdapter extends Device_1.default {
492
492
  constructor(device, protocol) {
package/lib/ble/tacx.d.ts CHANGED
@@ -30,6 +30,7 @@ export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineD
30
30
  data: BleFeBikeData;
31
31
  hasFECData: boolean;
32
32
  constructor(props?: any);
33
+ isMatching(characteristics: string[]): boolean;
33
34
  init(): Promise<boolean>;
34
35
  getProfile(): string;
35
36
  getServiceUUids(): string[];
package/lib/ble/tacx.js CHANGED
@@ -77,6 +77,13 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
77
77
  this.data = {};
78
78
  this.hasFECData = false;
79
79
  }
80
+ isMatching(characteristics) {
81
+ if (!characteristics)
82
+ return false;
83
+ const hasTacxCP = characteristics.find(c => c === TACX_FE_C_RX) !== undefined && characteristics.find(c => c === TACX_FE_C_TX) !== undefined;
84
+ const hasFTMS = characteristics.find(c => c === fm_1.FTMS_CP) !== undefined;
85
+ return hasTacxCP && !hasFTMS;
86
+ }
80
87
  init() {
81
88
  const _super = Object.create(null, {
82
89
  initDevice: { get: () => super.initDevice }
@@ -36,7 +36,7 @@ const ble_interface_1 = __importDefault(require("./ble-interface"));
36
36
  const Device_1 = require("../Device");
37
37
  const gd_eventlog_1 = require("gd-eventlog");
38
38
  const fm_1 = __importStar(require("./fm"));
39
- const WAHOO_ADVANCED_FTMS = 'a026e00b';
39
+ const WAHOO_ADVANCED_FTMS = 'a026ee0b';
40
40
  const WAHOO_ADVANCED_TRAINER_CP = 'a026e005';
41
41
  const cwABike = {
42
42
  race: 0.35,
@@ -59,6 +59,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
59
59
  if (!characteristics)
60
60
  return false;
61
61
  const hasWahooCP = characteristics.find(c => c === WAHOO_ADVANCED_TRAINER_CP) !== undefined;
62
+ const hasFTMS = characteristics.find(c => c === fm_1.FTMS_CP) !== undefined;
62
63
  return hasWahooCP;
63
64
  }
64
65
  init() {
@@ -197,6 +198,8 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
197
198
  if (this.hasControl)
198
199
  return true;
199
200
  this.logEvent({ message: 'requestControl' });
201
+ this.hasControl = true;
202
+ return;
200
203
  const data = Buffer.alloc(2);
201
204
  data.writeUInt8(0xEE, 0);
202
205
  data.writeUInt8(0xFC, 1);
@@ -265,8 +268,9 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
265
268
  setSimGrade(slope) {
266
269
  return __awaiter(this, void 0, void 0, function* () {
267
270
  const value = (Math.min(1, Math.max(-1, slope)) + 1.0) * 65535 / 2.0;
271
+ const slopeVal = Math.floor(value);
268
272
  const data = Buffer.alloc(2);
269
- data.writeInt16LE(Math.round(value), 0);
273
+ data.writeInt16LE(slopeVal, 0);
270
274
  const res = yield this.writeWahooFtmsMessage(70, data);
271
275
  return res;
272
276
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.4.70",
3
+ "version": "1.4.73",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",