incyclist-devices 1.5.38 → 2.0.0
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.
- package/README.MD +238 -0
- package/lib/adapters.d.ts +7 -0
- package/lib/adapters.js +49 -0
- package/lib/antv2/adapter-factory.d.ts +21 -10
- package/lib/antv2/adapter-factory.js +51 -33
- package/lib/antv2/adapter.d.ts +65 -0
- package/lib/antv2/adapter.js +310 -0
- package/lib/antv2/ant-interface.d.ts +17 -11
- package/lib/antv2/ant-interface.js +41 -31
- package/lib/antv2/{ant-binding.d.ts → binding.d.ts} +1 -1
- package/lib/antv2/{ant-binding.js → binding.js} +1 -1
- package/lib/antv2/fe/adapter.d.ts +28 -0
- package/lib/antv2/{fe.js → fe/adapter.js} +106 -90
- package/lib/antv2/fe/index.d.ts +2 -0
- package/lib/antv2/fe/index.js +7 -0
- package/lib/antv2/hr/adapter.d.ts +15 -0
- package/lib/antv2/hr/adapter.js +76 -0
- package/lib/antv2/hr/index.d.ts +2 -0
- package/lib/antv2/hr/index.js +7 -0
- package/lib/antv2/index.d.ts +7 -0
- package/lib/antv2/index.js +20 -0
- package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +9 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-adv-st-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-erg-mode.d.ts +6 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-erg-mode.js +1 -1
- package/lib/antv2/modes/ant-fe-st-mode.d.ts +5 -0
- package/lib/{ant/antfe → antv2/modes}/ant-fe-st-mode.js +1 -1
- package/lib/antv2/pwr/adapter.d.ts +24 -0
- package/lib/antv2/pwr/adapter.js +141 -0
- package/lib/antv2/pwr/index.d.ts +2 -0
- package/lib/antv2/pwr/index.js +7 -0
- package/lib/antv2/sensor-factory.d.ts +2 -2
- package/lib/antv2/types.d.ts +22 -0
- package/lib/antv2/types.js +5 -0
- package/lib/antv2/utils.d.ts +4 -0
- package/lib/antv2/utils.js +192 -0
- package/lib/base/adpater.d.ts +68 -0
- package/lib/base/adpater.js +183 -0
- package/lib/ble/adapter-factory.d.ts +33 -0
- package/lib/ble/adapter-factory.js +105 -0
- package/lib/ble/base/adapter.d.ts +53 -0
- package/lib/ble/base/adapter.js +290 -0
- package/lib/ble/base/comms-utils.d.ts +7 -0
- package/lib/ble/base/comms-utils.js +91 -0
- package/lib/ble/{ble-device.d.ts → base/comms.d.ts} +31 -16
- package/lib/ble/{ble-device.js → base/comms.js} +193 -55
- package/lib/ble/bindings/index.d.ts +2 -0
- package/lib/ble/bindings/index.js +8 -0
- package/lib/ble/bindings/linux.d.ts +15 -0
- package/lib/ble/bindings/linux.js +39 -0
- package/lib/ble/bindings/mock.d.ts +9 -0
- package/lib/ble/bindings/mock.js +108 -0
- package/lib/ble/bindings/types.d.ts +57 -0
- package/lib/ble/bindings/types.js +96 -0
- package/lib/ble/ble-interface.d.ts +38 -59
- package/lib/ble/ble-interface.js +254 -462
- package/lib/ble/ble-peripheral.d.ts +7 -5
- package/lib/ble/ble-peripheral.js +52 -21
- package/lib/ble/consts.d.ts +3 -0
- package/lib/ble/consts.js +4 -1
- package/lib/ble/cp/adapter.d.ts +22 -0
- package/lib/ble/cp/adapter.js +111 -0
- package/lib/ble/cp/comm.d.ts +31 -0
- package/lib/ble/cp/comm.js +125 -0
- package/lib/ble/cp/index.d.ts +4 -0
- package/lib/ble/cp/index.js +10 -0
- package/lib/ble/cp/types.d.ts +13 -0
- package/lib/ble/cp/types.js +2 -0
- package/lib/ble/elite/adapter.d.ts +19 -0
- package/lib/ble/elite/adapter.js +120 -0
- package/lib/ble/elite/comms.d.ts +32 -0
- package/lib/ble/elite/comms.js +126 -0
- package/lib/ble/elite/index.d.ts +3 -0
- package/lib/ble/elite/index.js +10 -0
- package/lib/ble/fm/adapter.d.ts +22 -0
- package/lib/ble/fm/adapter.js +249 -0
- package/lib/ble/fm/comms.d.ts +50 -0
- package/lib/ble/{fm.js → fm/comms.js} +34 -277
- package/lib/ble/fm/consts.d.ts +6 -0
- package/lib/ble/fm/consts.js +9 -0
- package/lib/ble/fm/index.d.ts +5 -0
- package/lib/ble/fm/index.js +13 -0
- package/lib/ble/fm/types.d.ts +30 -0
- package/lib/ble/fm/types.js +2 -0
- package/lib/ble/hr/adapter.d.ts +14 -0
- package/lib/ble/hr/adapter.js +45 -0
- package/lib/ble/hr/comm.d.ts +19 -0
- package/lib/ble/hr/comm.js +56 -0
- package/lib/ble/hr/index.d.ts +4 -0
- package/lib/ble/hr/index.js +10 -0
- package/lib/ble/hr/mock.d.ts +7 -0
- package/lib/ble/hr/mock.js +47 -0
- package/lib/ble/hr/types.d.ts +5 -0
- package/lib/ble/hr/types.js +2 -0
- package/lib/ble/index.d.ts +9 -0
- package/lib/ble/index.js +26 -0
- package/lib/ble/peripheral-cache.d.ts +43 -0
- package/lib/ble/peripheral-cache.js +107 -0
- package/lib/ble/tacx/adapter.d.ts +10 -0
- package/lib/ble/tacx/adapter.js +99 -0
- package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +11 -43
- package/lib/ble/{tacx.js → tacx/comms.js} +23 -155
- package/lib/ble/tacx/index.d.ts +4 -0
- package/lib/ble/tacx/index.js +10 -0
- package/lib/ble/tacx/types.d.ts +25 -0
- package/lib/ble/tacx/types.js +2 -0
- package/lib/ble/types.d.ts +128 -0
- package/lib/ble/types.js +2 -0
- package/lib/ble/utils.d.ts +17 -0
- package/lib/ble/utils.js +54 -0
- package/lib/ble/wahoo/adapter.d.ts +9 -0
- package/lib/ble/wahoo/adapter.js +95 -0
- package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +11 -44
- package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +29 -129
- package/lib/ble/wahoo/index.d.ts +4 -0
- package/lib/ble/wahoo/index.js +10 -0
- package/lib/ble/wahoo/types.d.ts +19 -0
- package/lib/ble/wahoo/types.js +2 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +34 -0
- package/lib/interfaces.d.ts +7 -0
- package/lib/interfaces.js +27 -0
- package/lib/{ble → modes}/ble-erg-mode.d.ts +4 -4
- package/lib/{ble → modes}/ble-erg-mode.js +2 -2
- package/lib/{ble → modes}/ble-st-mode.d.ts +3 -3
- package/lib/{ble → modes}/ble-st-mode.js +1 -1
- package/lib/{cycling-mode.d.ts → modes/cycling-mode.d.ts} +8 -8
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +8 -4
- package/lib/modes/power-meter.d.ts +3 -3
- package/lib/modes/simulator.d.ts +2 -2
- package/lib/modes/simulator.js +1 -1
- package/lib/serial/adapter-factory.d.ts +12 -0
- package/lib/serial/adapter-factory.js +30 -0
- package/lib/serial/adapter.d.ts +21 -0
- package/lib/serial/adapter.js +61 -0
- package/lib/serial/bindings/tcp.d.ts +45 -0
- package/lib/serial/bindings/tcp.js +284 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/{daum → serial/daum}/DaumAdapter.d.ts +14 -23
- package/lib/{daum → serial/daum}/DaumAdapter.js +57 -97
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.d.ts +2 -2
- package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.js +1 -1
- package/lib/{daum → serial/daum}/ERGCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/ERGCyclingMode.js +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.d.ts +3 -3
- package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.js +4 -3
- package/lib/serial/daum/classic/adapter.d.ts +29 -0
- package/lib/{daum/classic/DaumClassicAdapter.js → serial/daum/classic/adapter.js} +77 -50
- package/lib/{daum/classic/bike.d.ts → serial/daum/classic/comms.d.ts} +14 -16
- package/lib/{daum/classic/bike.js → serial/daum/classic/comms.js} +68 -152
- package/lib/serial/daum/classic/mock.d.ts +96 -0
- package/lib/serial/daum/classic/mock.js +365 -0
- package/lib/{daum/classic/DaumClassicCyclingMode.d.ts → serial/daum/classic/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/classic/DaumClassicCyclingMode.js → serial/daum/classic/modes/daum-classic.js} +2 -2
- package/lib/{daum → serial/daum}/classic/utils.d.ts +1 -1
- package/lib/serial/daum/premium/adapter.d.ts +25 -0
- package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +107 -47
- package/lib/{daum/premium/bike.d.ts → serial/daum/premium/comms.d.ts} +26 -54
- package/lib/{daum/premium/bike.js → serial/daum/premium/comms.js} +215 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +289 -0
- package/lib/{daum/premium/DaumClassicCyclingMode.d.ts → serial/daum/premium/modes/daum-classic.d.ts} +3 -3
- package/lib/{daum/premium/DaumClassicCyclingMode.js → serial/daum/premium/modes/daum-classic.js} +2 -2
- package/lib/serial/daum/premium/types.d.ts +12 -0
- package/lib/serial/daum/premium/types.js +2 -0
- package/lib/{daum → serial/daum}/premium/utils.d.ts +8 -11
- package/lib/{daum → serial/daum}/premium/utils.js +22 -63
- package/lib/serial/index.d.ts +9 -0
- package/lib/serial/index.js +49 -0
- package/lib/{kettler → serial/kettler}/comms.d.ts +8 -6
- package/lib/{kettler → serial/kettler}/comms.js +71 -32
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.d.ts +14 -28
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +102 -169
- package/lib/serial/kettler/ergo-racer/mock.d.ts +66 -0
- package/lib/serial/kettler/ergo-racer/mock.js +216 -0
- package/lib/{kettler/ergo-racer/ERGCyclingMode.d.ts → serial/kettler/ergo-racer/modes/erg.d.ts} +4 -4
- package/lib/{kettler/ergo-racer/ERGCyclingMode.js → serial/kettler/ergo-racer/modes/erg.js} +2 -2
- package/lib/serial/serial-interface.d.ts +60 -0
- package/lib/serial/serial-interface.js +309 -0
- package/lib/simulator/Simulator.d.ts +12 -25
- package/lib/simulator/Simulator.js +26 -87
- package/lib/types/adapter.d.ts +39 -0
- package/lib/types/adapter.js +2 -0
- package/lib/types/capabilities.d.ts +8 -0
- package/lib/types/capabilities.js +12 -0
- package/lib/types/data.d.ts +12 -0
- package/lib/types/data.js +2 -0
- package/lib/types/device.d.ts +32 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +18 -0
- package/lib/types/interface.js +2 -0
- package/lib/types/route.d.ts +2 -2
- package/lib/types/user.d.ts +1 -1
- package/lib/{utils.d.ts → utils/utils.d.ts} +1 -0
- package/lib/{utils.js → utils/utils.js} +5 -1
- package/package.json +16 -14
- package/lib/DeviceSupport.d.ts +0 -36
- package/lib/DeviceSupport.js +0 -82
- package/lib/ant/AntAdapter.d.ts +0 -50
- package/lib/ant/AntAdapter.js +0 -109
- package/lib/ant/AntScanner.d.ts +0 -60
- package/lib/ant/AntScanner.js +0 -651
- package/lib/ant/antfe/AntFEAdapter.d.ts +0 -83
- package/lib/ant/antfe/AntFEAdapter.js +0 -652
- package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +0 -9
- package/lib/ant/antfe/ant-fe-erg-mode.d.ts +0 -6
- package/lib/ant/antfe/ant-fe-st-mode.d.ts +0 -5
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +0 -16
- package/lib/ant/anthrm/AntHrmAdapter.js +0 -130
- package/lib/ant/antpwr/pwr-adapter.d.ts +0 -49
- package/lib/ant/antpwr/pwr-adapter.js +0 -251
- package/lib/ant/utils.d.ts +0 -1
- package/lib/ant/utils.js +0 -23
- package/lib/antv2/AntAdapter.d.ts +0 -48
- package/lib/antv2/AntAdapter.js +0 -104
- package/lib/antv2/ant-device.d.ts +0 -59
- package/lib/antv2/ant-device.js +0 -161
- package/lib/antv2/fe.d.ts +0 -32
- package/lib/antv2/hr.d.ts +0 -18
- package/lib/antv2/hr.js +0 -102
- package/lib/antv2/incyclist-protocol.d.ts +0 -37
- package/lib/antv2/incyclist-protocol.js +0 -126
- package/lib/antv2/pwr.d.ts +0 -28
- package/lib/antv2/pwr.js +0 -171
- package/lib/ble/ble.d.ts +0 -129
- package/lib/ble/ble.js +0 -86
- package/lib/ble/elite.d.ts +0 -90
- package/lib/ble/elite.js +0 -322
- package/lib/ble/fm.d.ts +0 -125
- package/lib/ble/hrm.d.ts +0 -48
- package/lib/ble/hrm.js +0 -134
- package/lib/ble/incyclist-protocol.d.ts +0 -31
- package/lib/ble/incyclist-protocol.js +0 -153
- package/lib/ble/pwr.d.ts +0 -89
- package/lib/ble/pwr.js +0 -322
- package/lib/daum/classic/DaumClassicAdapter.d.ts +0 -28
- package/lib/daum/classic/DaumClassicProtocol.d.ts +0 -27
- package/lib/daum/classic/DaumClassicProtocol.js +0 -185
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +0 -16
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +0 -32
- package/lib/daum/premium/DaumPremiumProtocol.js +0 -207
- package/lib/daum/premium/tcpserial.d.ts +0 -33
- package/lib/daum/premium/tcpserial.js +0 -123
- package/lib/device.d.ts +0 -94
- package/lib/device.js +0 -76
- package/lib/kettler/ergo-racer/protocol.d.ts +0 -41
- package/lib/kettler/ergo-racer/protocol.js +0 -203
- package/lib/protocol.d.ts +0 -74
- package/lib/protocol.js +0 -41
- package/lib/registry.d.ts +0 -8
- package/lib/registry.js +0 -33
- package/lib/serialport/bindings/tcp.d.ts +0 -20
- package/lib/serialport/bindings/tcp.js +0 -33
- package/lib/serialport/index.d.ts +0 -2
- package/lib/serialport/index.js +0 -29
- package/lib/serialport/serialport.d.ts +0 -29
- package/lib/serialport/serialport.js +0 -87
- /package/lib/{cycling-mode.js → modes/cycling-mode.js} +0 -0
- /package/lib/{daum → serial/daum}/classic/utils.js +0 -0
- /package/lib/{daum → serial/daum}/constants.d.ts +0 -0
- /package/lib/{daum → serial/daum}/constants.js +0 -0
- /package/lib/{serialport.d.ts → serial/serialport.d.ts} +0 -0
- /package/lib/{serialport.js → serial/serialport.js} +0 -0
- /package/lib/{calculations.d.ts → utils/calculations.d.ts} +0 -0
- /package/lib/{calculations.js → utils/calculations.js} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import BleInterface from './ble-interface';
|
|
2
|
+
import BleAdapterFactory from './adapter-factory';
|
|
3
|
+
import { BleHrmAdapter } from './hr';
|
|
4
|
+
import { BlePwrAdapter } from './cp';
|
|
5
|
+
import { BleFmAdapter } from './fm';
|
|
6
|
+
import { BleWahooAdapter } from './wahoo';
|
|
7
|
+
import { BleTacxAdapter } from './tacx';
|
|
8
|
+
import { BleDeviceSettings, BleInterfaceProps } from './types';
|
|
9
|
+
export { BleAdapterFactory, BleInterface, BleInterfaceProps, BleDeviceSettings, BleHrmAdapter, BlePwrAdapter, BleFmAdapter, BleWahooAdapter, BleTacxAdapter };
|
package/lib/ble/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BleTacxAdapter = exports.BleWahooAdapter = exports.BleFmAdapter = exports.BlePwrAdapter = exports.BleHrmAdapter = exports.BleInterface = exports.BleAdapterFactory = void 0;
|
|
7
|
+
const ble_interface_1 = __importDefault(require("./ble-interface"));
|
|
8
|
+
exports.BleInterface = ble_interface_1.default;
|
|
9
|
+
const adapter_factory_1 = __importDefault(require("./adapter-factory"));
|
|
10
|
+
exports.BleAdapterFactory = adapter_factory_1.default;
|
|
11
|
+
const hr_1 = require("./hr");
|
|
12
|
+
Object.defineProperty(exports, "BleHrmAdapter", { enumerable: true, get: function () { return hr_1.BleHrmAdapter; } });
|
|
13
|
+
const cp_1 = require("./cp");
|
|
14
|
+
Object.defineProperty(exports, "BlePwrAdapter", { enumerable: true, get: function () { return cp_1.BlePwrAdapter; } });
|
|
15
|
+
const fm_1 = require("./fm");
|
|
16
|
+
Object.defineProperty(exports, "BleFmAdapter", { enumerable: true, get: function () { return fm_1.BleFmAdapter; } });
|
|
17
|
+
const wahoo_1 = require("./wahoo");
|
|
18
|
+
Object.defineProperty(exports, "BleWahooAdapter", { enumerable: true, get: function () { return wahoo_1.BleWahooAdapter; } });
|
|
19
|
+
const tacx_1 = require("./tacx");
|
|
20
|
+
Object.defineProperty(exports, "BleTacxAdapter", { enumerable: true, get: function () { return tacx_1.BleTacxAdapter; } });
|
|
21
|
+
const af = adapter_factory_1.default.getInstance();
|
|
22
|
+
af.register('hr', hr_1.BleHrmAdapter, hr_1.BleHrmComms);
|
|
23
|
+
af.register('cp', cp_1.BlePwrAdapter, cp_1.BlePwrComms);
|
|
24
|
+
af.register('fm', fm_1.BleFmAdapter, fm_1.BleFmComms);
|
|
25
|
+
af.register('wahoo', wahoo_1.BleWahooAdapter, wahoo_1.BleWahooComms);
|
|
26
|
+
af.register('tacx', tacx_1.BleTacxAdapter, tacx_1.BleTacxComms);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import BleAdapter from "./base/adapter";
|
|
2
|
+
import BlePeripheralConnector from "./ble-peripheral";
|
|
3
|
+
import { BleCharacteristic, BlePeripheral } from "./types";
|
|
4
|
+
export interface PeripheralState {
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
isConfigured: boolean;
|
|
7
|
+
isInterrupted: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface PeripheralCacheItem {
|
|
10
|
+
address: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
ts: number;
|
|
14
|
+
peripheral: BlePeripheral;
|
|
15
|
+
state?: PeripheralState;
|
|
16
|
+
characteristics?: BleCharacteristic[];
|
|
17
|
+
connector?: BlePeripheralConnector;
|
|
18
|
+
}
|
|
19
|
+
export default class BlePeripheralCache {
|
|
20
|
+
peripherals: PeripheralCacheItem[];
|
|
21
|
+
findAdapter(adapter: BleAdapter): PeripheralCacheItem;
|
|
22
|
+
getConnector(peripheral: BlePeripheral): BlePeripheralConnector;
|
|
23
|
+
getPeripheral(query: {
|
|
24
|
+
id?: string;
|
|
25
|
+
address?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}): BlePeripheral;
|
|
28
|
+
handleStopScan(): void;
|
|
29
|
+
find(query: {
|
|
30
|
+
name?: string;
|
|
31
|
+
id?: string;
|
|
32
|
+
address?: string;
|
|
33
|
+
peripheral?: BlePeripheral;
|
|
34
|
+
}): PeripheralCacheItem;
|
|
35
|
+
filter(services: string[]): PeripheralCacheItem[];
|
|
36
|
+
protected _findIndex(query: {
|
|
37
|
+
name?: string;
|
|
38
|
+
id?: string;
|
|
39
|
+
address?: string;
|
|
40
|
+
}): number;
|
|
41
|
+
add(item: PeripheralCacheItem): PeripheralCacheItem;
|
|
42
|
+
remove(query: PeripheralCacheItem | BlePeripheral): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ble_peripheral_1 = __importDefault(require("./ble-peripheral"));
|
|
7
|
+
class BlePeripheralCache {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.peripherals = [];
|
|
10
|
+
}
|
|
11
|
+
findAdapter(adapter) {
|
|
12
|
+
return this.find(adapter.getSettings());
|
|
13
|
+
}
|
|
14
|
+
getConnector(peripheral) {
|
|
15
|
+
const info = this.find({ address: peripheral.address });
|
|
16
|
+
if (!info) {
|
|
17
|
+
const item = this.add({ address: peripheral.address, ts: Date.now(), peripheral });
|
|
18
|
+
return item.connector;
|
|
19
|
+
}
|
|
20
|
+
return info.connector;
|
|
21
|
+
}
|
|
22
|
+
getPeripheral(query) {
|
|
23
|
+
const info = this.find(query);
|
|
24
|
+
return info ? info.peripheral : undefined;
|
|
25
|
+
}
|
|
26
|
+
handleStopScan() {
|
|
27
|
+
const ongoing = this.peripherals.filter(i => i.state && i.state.isLoading);
|
|
28
|
+
if (ongoing)
|
|
29
|
+
ongoing.forEach(i => { i.state.isInterrupted = true; });
|
|
30
|
+
}
|
|
31
|
+
find(query) {
|
|
32
|
+
const { peripheral } = query;
|
|
33
|
+
const { name, address, id } = peripheral ? peripheral : query;
|
|
34
|
+
if (!name && !address && !id)
|
|
35
|
+
throw new Error('illegal query, one of <id>,<name>,<address> needs to be provided');
|
|
36
|
+
if (address)
|
|
37
|
+
return this.peripherals.find(i => i.address === address);
|
|
38
|
+
else if (name)
|
|
39
|
+
return this.peripherals.find(i => i.name === name);
|
|
40
|
+
else if (id)
|
|
41
|
+
return this.peripherals.find(i => i.id === id);
|
|
42
|
+
}
|
|
43
|
+
filter(services) {
|
|
44
|
+
if (services.length === 0) {
|
|
45
|
+
return this.peripherals;
|
|
46
|
+
}
|
|
47
|
+
return this.peripherals.filter(i => {
|
|
48
|
+
const announced = i.peripheral.services.map(s => s.uuid);
|
|
49
|
+
const requested = services;
|
|
50
|
+
return (announced.find(s => requested.includes(s)));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
_findIndex(query) {
|
|
54
|
+
const { name, address, id } = query;
|
|
55
|
+
if (!name && !address && !id)
|
|
56
|
+
throw new Error('illegal query, one of <id>,<name>,<address> needs to be provided');
|
|
57
|
+
if (address)
|
|
58
|
+
return this.peripherals.findIndex(i => i.address === address);
|
|
59
|
+
else if (name)
|
|
60
|
+
return this.peripherals.findIndex(i => i.name === name);
|
|
61
|
+
else if (id)
|
|
62
|
+
return this.peripherals.findIndex(i => i.id === id);
|
|
63
|
+
}
|
|
64
|
+
add(item) {
|
|
65
|
+
const { address, name, id } = item;
|
|
66
|
+
const { ts, peripheral, state, characteristics } = item;
|
|
67
|
+
const cachedItem = this.find({ address, name, id });
|
|
68
|
+
if (cachedItem) {
|
|
69
|
+
cachedItem.ts = ts;
|
|
70
|
+
cachedItem.peripheral = peripheral;
|
|
71
|
+
if (state)
|
|
72
|
+
cachedItem.state = state;
|
|
73
|
+
if (characteristics) {
|
|
74
|
+
cachedItem.characteristics = characteristics;
|
|
75
|
+
}
|
|
76
|
+
if (!cachedItem.connector) {
|
|
77
|
+
cachedItem.connector = item.connector || new ble_peripheral_1.default(cachedItem.peripheral);
|
|
78
|
+
}
|
|
79
|
+
return cachedItem;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const newItem = Object.assign({}, item);
|
|
83
|
+
if (newItem.peripheral && !newItem.connector)
|
|
84
|
+
newItem.connector = new ble_peripheral_1.default(item.peripheral);
|
|
85
|
+
this.peripherals.push(newItem);
|
|
86
|
+
return newItem;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
remove(query) {
|
|
90
|
+
const item = query;
|
|
91
|
+
const isCacheItem = item.peripheral !== undefined;
|
|
92
|
+
let cachedItemIdx;
|
|
93
|
+
if (isCacheItem) {
|
|
94
|
+
const { address, name, id } = item;
|
|
95
|
+
cachedItemIdx = this._findIndex({ address, name, id });
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const peripheral = query;
|
|
99
|
+
const { address } = peripheral;
|
|
100
|
+
cachedItemIdx = this._findIndex({ address });
|
|
101
|
+
}
|
|
102
|
+
if (cachedItemIdx == -1)
|
|
103
|
+
return;
|
|
104
|
+
this.peripherals.splice(cachedItemIdx);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.default = BlePeripheralCache;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BleFmAdapter } from '../fm';
|
|
2
|
+
import BleAdapter from '../base/adapter';
|
|
3
|
+
import { DeviceProperties } from '../../types/device';
|
|
4
|
+
import { BleDeviceSettings, BleStartProperties } from '../types';
|
|
5
|
+
export default class BleTacxFEAdapter extends BleFmAdapter {
|
|
6
|
+
constructor(settings: BleDeviceSettings, props?: DeviceProperties);
|
|
7
|
+
isSame(device: BleAdapter): boolean;
|
|
8
|
+
getProfile(): string;
|
|
9
|
+
start(props?: BleStartProperties): Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
16
|
+
const fm_1 = require("../fm");
|
|
17
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
18
|
+
const adpater_1 = require("../../base/adpater");
|
|
19
|
+
const capabilities_1 = require("../../types/capabilities");
|
|
20
|
+
class BleTacxFEAdapter extends fm_1.BleFmAdapter {
|
|
21
|
+
constructor(settings, props) {
|
|
22
|
+
super(settings, props);
|
|
23
|
+
this.logger = new gd_eventlog_1.EventLogger('BLE-FEC-Tacx');
|
|
24
|
+
const { id, address, name } = settings;
|
|
25
|
+
const logger = this.logger;
|
|
26
|
+
const ble = this.ble;
|
|
27
|
+
this.device = new comms_1.default({ id, address, name, ble, logger });
|
|
28
|
+
this.capabilities = [
|
|
29
|
+
capabilities_1.IncyclistCapability.Power, capabilities_1.IncyclistCapability.Speed, capabilities_1.IncyclistCapability.Cadence,
|
|
30
|
+
capabilities_1.IncyclistCapability.Control
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
isSame(device) {
|
|
34
|
+
if (!(device instanceof BleTacxFEAdapter))
|
|
35
|
+
return false;
|
|
36
|
+
return this.isEqual(device.settings);
|
|
37
|
+
}
|
|
38
|
+
getProfile() {
|
|
39
|
+
return 'Smart Trainer';
|
|
40
|
+
}
|
|
41
|
+
start(props = {}) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (this.started)
|
|
44
|
+
return true;
|
|
45
|
+
if (this.ble.isScanning()) {
|
|
46
|
+
this.logger.logEvent({ message: 'stop previous scan', isScanning: this.ble.isScanning() });
|
|
47
|
+
yield this.ble.stopScan();
|
|
48
|
+
}
|
|
49
|
+
const connected = yield this.connect();
|
|
50
|
+
if (!connected)
|
|
51
|
+
throw new Error(`could not start device, reason:could not connect`);
|
|
52
|
+
this.logger.logEvent({ message: 'start requested', protocol: this.getProtocolName(), props });
|
|
53
|
+
try {
|
|
54
|
+
const comms = this.device;
|
|
55
|
+
if (comms) {
|
|
56
|
+
this.device = comms;
|
|
57
|
+
const mode = this.getCyclingMode();
|
|
58
|
+
if (mode && mode.getSetting('bikeType')) {
|
|
59
|
+
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
60
|
+
comms.setCrr(fm_1.cRR);
|
|
61
|
+
switch (bikeType) {
|
|
62
|
+
case 'race':
|
|
63
|
+
comms.setCw(fm_1.cwABike.race);
|
|
64
|
+
break;
|
|
65
|
+
case 'triathlon':
|
|
66
|
+
comms.setCw(fm_1.cwABike.triathlon);
|
|
67
|
+
break;
|
|
68
|
+
case 'mountain':
|
|
69
|
+
comms.setCw(fm_1.cwABike.mountain);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const { user, wheelDiameter, gearRatio, bikeWeight = adpater_1.DEFAULT_BIKE_WEIGHT } = props || {};
|
|
74
|
+
const userWeight = (user && user.weight ? user.weight : adpater_1.DEFAULT_USER_WEIGHT);
|
|
75
|
+
comms.sendTrackResistance(0.0);
|
|
76
|
+
comms.sendUserConfiguration(userWeight, bikeWeight, wheelDiameter, gearRatio);
|
|
77
|
+
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
78
|
+
yield this.sendUpdate(startRequest);
|
|
79
|
+
comms.on('data', (data) => {
|
|
80
|
+
this.onDeviceData(data);
|
|
81
|
+
});
|
|
82
|
+
this.resetData();
|
|
83
|
+
this.stopped = false;
|
|
84
|
+
this.started = true;
|
|
85
|
+
this.paused = false;
|
|
86
|
+
if (comms.features.heartrate && !this.hasCapability(capabilities_1.IncyclistCapability.HeartRate)) {
|
|
87
|
+
this.capabilities.push(capabilities_1.IncyclistCapability.HeartRate);
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
94
|
+
throw new Error(`could not start device, reason:${err.message}`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.default = BleTacxFEAdapter;
|
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import BleFitnessMachineDevice
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
EquipmentType?: 'Treadmill' | 'Elliptical' | 'StationaryBike' | 'Rower' | 'Climber' | 'NordicSkier' | 'Trainer' | 'General';
|
|
9
|
-
RealSpeed?: number;
|
|
10
|
-
VirtualSpeed?: number;
|
|
11
|
-
HeartRateSource?: 'HandContact' | 'EM' | 'ANT+';
|
|
12
|
-
State?: 'OFF' | 'READY' | 'IN_USE' | 'FINISHED';
|
|
13
|
-
EventCount?: number;
|
|
14
|
-
AccumulatedPower?: number;
|
|
15
|
-
TrainerStatus?: number;
|
|
16
|
-
TargetStatus?: 'OnTarget' | 'LowSpeed' | 'HighSpeed';
|
|
17
|
-
HwVersion?: number;
|
|
18
|
-
ManId?: number;
|
|
19
|
-
ModelNum?: number;
|
|
20
|
-
SwVersion?: number;
|
|
21
|
-
SerialNumber?: number;
|
|
22
|
-
}
|
|
23
|
-
declare type CrankData = {
|
|
24
|
-
revolutions?: number;
|
|
25
|
-
time?: number;
|
|
26
|
-
cntUpdateMissing?: number;
|
|
27
|
-
};
|
|
2
|
+
import { LegacyProfile } from "../../antv2/types";
|
|
3
|
+
import { CrankData } from "../cp";
|
|
4
|
+
import { IndoorBikeData } from "../fm";
|
|
5
|
+
import BleFitnessMachineDevice from "../fm/comms";
|
|
6
|
+
import { BleProtocol, IBlePeripheralConnector } from "../types";
|
|
7
|
+
import { BleFeBikeData } from "./types";
|
|
28
8
|
export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineDevice {
|
|
9
|
+
static protocol: BleProtocol;
|
|
29
10
|
static services: string[];
|
|
30
11
|
static characteristics: string[];
|
|
31
12
|
static PROFILE: string;
|
|
@@ -40,15 +21,13 @@ export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineD
|
|
|
40
21
|
tacxRx: string;
|
|
41
22
|
tacxTx: string;
|
|
42
23
|
constructor(props?: any);
|
|
43
|
-
isMatching(characteristics: string[]): boolean;
|
|
24
|
+
static isMatching(characteristics: string[]): boolean;
|
|
44
25
|
setCharacteristicUUIDs(uuids: string[]): void;
|
|
45
|
-
subscribeAll(conn?:
|
|
26
|
+
subscribeAll(conn?: IBlePeripheralConnector): Promise<void>;
|
|
46
27
|
init(): Promise<boolean>;
|
|
47
|
-
getProfile():
|
|
28
|
+
getProfile(): LegacyProfile;
|
|
29
|
+
getProtocol(): BleProtocol;
|
|
48
30
|
getServiceUUids(): string[];
|
|
49
|
-
isBike(): boolean;
|
|
50
|
-
isPower(): boolean;
|
|
51
|
-
isHrm(): boolean;
|
|
52
31
|
requestControl(): Promise<boolean>;
|
|
53
32
|
parseCrankData(crankData: any): {
|
|
54
33
|
rpm?: undefined;
|
|
@@ -79,14 +58,3 @@ export default class TacxAdvancedFitnessMachineDevice extends BleFitnessMachineD
|
|
|
79
58
|
setSlope(slope: any): Promise<boolean>;
|
|
80
59
|
reset(): void;
|
|
81
60
|
}
|
|
82
|
-
export declare class TacxBleFEAdapter extends FmAdapter {
|
|
83
|
-
static PROFILE: string;
|
|
84
|
-
device: TacxAdvancedFitnessMachineDevice;
|
|
85
|
-
constructor(device: BleDeviceClass, protocol: BleProtocol);
|
|
86
|
-
isSame(device: DeviceAdapter): boolean;
|
|
87
|
-
getProfile(): string;
|
|
88
|
-
start(props?: any): Promise<any>;
|
|
89
|
-
pause(): Promise<boolean>;
|
|
90
|
-
resume(): Promise<boolean>;
|
|
91
|
-
}
|
|
92
|
-
export {};
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,23 +12,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
13
|
};
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const gd_eventlog_1 = require("gd-eventlog");
|
|
39
|
-
const fm_1 = __importStar(require("./fm"));
|
|
40
|
-
const consts_1 = require("./consts");
|
|
41
|
-
const SYNC_BYTE = 0xA4;
|
|
42
|
-
const DEFAULT_CHANNEL = 5;
|
|
43
|
-
const ACKNOWLEDGED_DATA = 0x4F;
|
|
44
|
-
const PROFILE_ID = 'Tacx SmartTrainer';
|
|
45
|
-
const cwABike = {
|
|
46
|
-
race: 0.35,
|
|
47
|
-
triathlon: 0.29,
|
|
48
|
-
mountain: 0.57
|
|
49
|
-
};
|
|
50
|
-
const cRR = 0.0036;
|
|
15
|
+
const _1 = require(".");
|
|
16
|
+
const consts_1 = require("../consts");
|
|
17
|
+
const comms_1 = __importDefault(require("../fm/comms"));
|
|
18
|
+
const utils_1 = require("../utils");
|
|
51
19
|
var ANTMessages;
|
|
52
20
|
(function (ANTMessages) {
|
|
53
21
|
ANTMessages[ANTMessages["calibrationCommand"] = 1] = "calibrationCommand";
|
|
@@ -66,7 +34,11 @@ var ANTMessages;
|
|
|
66
34
|
ANTMessages[ANTMessages["manufactererData"] = 80] = "manufactererData";
|
|
67
35
|
ANTMessages[ANTMessages["productInformation"] = 81] = "productInformation";
|
|
68
36
|
})(ANTMessages || (ANTMessages = {}));
|
|
69
|
-
|
|
37
|
+
const PROFILE_ID = 'Tacx SmartTrainer';
|
|
38
|
+
const SYNC_BYTE = 0xA4;
|
|
39
|
+
const DEFAULT_CHANNEL = 5;
|
|
40
|
+
const ACKNOWLEDGED_DATA = 0x4F;
|
|
41
|
+
class TacxAdvancedFitnessMachineDevice extends comms_1.default {
|
|
70
42
|
constructor(props) {
|
|
71
43
|
super(props);
|
|
72
44
|
this.prevCrankData = undefined;
|
|
@@ -79,52 +51,24 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
79
51
|
this.tacxRx = consts_1.TACX_FE_C_RX;
|
|
80
52
|
this.tacxTx = consts_1.TACX_FE_C_TX;
|
|
81
53
|
}
|
|
82
|
-
isMatching(characteristics) {
|
|
54
|
+
static isMatching(characteristics) {
|
|
83
55
|
if (!characteristics)
|
|
84
56
|
return false;
|
|
85
|
-
const hasTacxCP = characteristics.find(c => (0,
|
|
86
|
-
characteristics.find(c => (0,
|
|
57
|
+
const hasTacxCP = characteristics.find(c => (0, utils_1.matches)(c, consts_1.TACX_FE_C_RX)) !== undefined &&
|
|
58
|
+
characteristics.find(c => (0, utils_1.matches)(c, consts_1.TACX_FE_C_TX)) !== undefined;
|
|
87
59
|
return hasTacxCP;
|
|
88
60
|
}
|
|
89
61
|
setCharacteristicUUIDs(uuids) {
|
|
90
62
|
uuids.forEach(c => {
|
|
91
|
-
if ((0,
|
|
63
|
+
if ((0, utils_1.matches)(c, consts_1.TACX_FE_C_RX))
|
|
92
64
|
this.tacxRx = c;
|
|
93
|
-
if ((0,
|
|
65
|
+
if ((0, utils_1.matches)(c, consts_1.TACX_FE_C_TX))
|
|
94
66
|
this.tacxTx = c;
|
|
95
67
|
});
|
|
96
68
|
}
|
|
97
69
|
subscribeAll(conn) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const timeout = Date.now() + 5500;
|
|
101
|
-
const iv = setInterval(() => {
|
|
102
|
-
const subscriptionStatus = characteristics.map(c => this.subscribedCharacteristics.find(s => s === c) !== undefined);
|
|
103
|
-
const done = subscriptionStatus.filter(s => s === true).length === characteristics.length;
|
|
104
|
-
if (done || Date.now() > timeout) {
|
|
105
|
-
clearInterval(iv);
|
|
106
|
-
resolve();
|
|
107
|
-
}
|
|
108
|
-
}, 100);
|
|
109
|
-
try {
|
|
110
|
-
const connector = conn || this.ble.getConnector(this.peripheral);
|
|
111
|
-
for (let i = 0; i < characteristics.length; i++) {
|
|
112
|
-
const c = characteristics[i];
|
|
113
|
-
const isAlreadySubscribed = connector.isSubscribed(c);
|
|
114
|
-
if (!isAlreadySubscribed) {
|
|
115
|
-
connector.removeAllListeners(c);
|
|
116
|
-
connector.on(c, (uuid, data) => {
|
|
117
|
-
this.onData(uuid, data);
|
|
118
|
-
});
|
|
119
|
-
connector.subscribe(c);
|
|
120
|
-
this.subscribedCharacteristics.push(c);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (err) {
|
|
125
|
-
this.logEvent({ message: 'Error', fn: 'subscribeAll()', error: err.message, stack: err.stack });
|
|
126
|
-
}
|
|
127
|
-
});
|
|
70
|
+
const characteristics = [consts_1.CSC_MEASUREMENT, consts_1.CSP_MEASUREMENT, consts_1.INDOOR_BIKE_DATA, consts_1.FTMS_STATUS, consts_1.FTMS_CP, consts_1.TACX_FE_C_RX];
|
|
71
|
+
return this.subscribeMultiple(characteristics, conn);
|
|
128
72
|
}
|
|
129
73
|
init() {
|
|
130
74
|
const _super = Object.create(null, {
|
|
@@ -132,8 +76,7 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
132
76
|
});
|
|
133
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
78
|
try {
|
|
135
|
-
yield _super.initDevice.call(this);
|
|
136
|
-
return true;
|
|
79
|
+
return yield _super.initDevice.call(this);
|
|
137
80
|
}
|
|
138
81
|
catch (err) {
|
|
139
82
|
this.logEvent({ message: 'error', fn: 'TacxAdvancedFitnessMachineDevice.init()', error: err.message || err, stack: err.stack });
|
|
@@ -142,20 +85,14 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
142
85
|
});
|
|
143
86
|
}
|
|
144
87
|
getProfile() {
|
|
145
|
-
return
|
|
88
|
+
return 'Smart Trainer';
|
|
89
|
+
}
|
|
90
|
+
getProtocol() {
|
|
91
|
+
return _1.BleTacxComms.protocol;
|
|
146
92
|
}
|
|
147
93
|
getServiceUUids() {
|
|
148
94
|
return TacxAdvancedFitnessMachineDevice.services;
|
|
149
95
|
}
|
|
150
|
-
isBike() {
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
isPower() {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
isHrm() {
|
|
157
|
-
return this.hasService('180d');
|
|
158
|
-
}
|
|
159
96
|
requestControl() {
|
|
160
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
98
|
return true;
|
|
@@ -484,7 +421,7 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
484
421
|
try {
|
|
485
422
|
const uuid = characteristic.toLocaleLowerCase();
|
|
486
423
|
let res = undefined;
|
|
487
|
-
if (uuid && (0,
|
|
424
|
+
if (uuid && (0, utils_1.matches)(uuid, this.tacxRx)) {
|
|
488
425
|
res = this.parseFECMessage(data);
|
|
489
426
|
}
|
|
490
427
|
else {
|
|
@@ -689,77 +626,8 @@ class TacxAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
689
626
|
}
|
|
690
627
|
}
|
|
691
628
|
exports.default = TacxAdvancedFitnessMachineDevice;
|
|
629
|
+
TacxAdvancedFitnessMachineDevice.protocol = 'tacx';
|
|
692
630
|
TacxAdvancedFitnessMachineDevice.services = [consts_1.TACX_FE_C_BLE];
|
|
693
631
|
TacxAdvancedFitnessMachineDevice.characteristics = ['2acc', '2ad2', '2ad6', '2ad8', '2ad9', '2ada', consts_1.TACX_FE_C_RX, consts_1.TACX_FE_C_TX];
|
|
694
632
|
TacxAdvancedFitnessMachineDevice.PROFILE = PROFILE_ID;
|
|
695
633
|
TacxAdvancedFitnessMachineDevice.detectionPriority = 10;
|
|
696
|
-
ble_interface_1.default.register('TacxBleFEDevice', 'tacx-ble-fec', TacxAdvancedFitnessMachineDevice, TacxAdvancedFitnessMachineDevice.services);
|
|
697
|
-
class TacxBleFEAdapter extends fm_1.FmAdapter {
|
|
698
|
-
constructor(device, protocol) {
|
|
699
|
-
super(device, protocol);
|
|
700
|
-
this.device = device;
|
|
701
|
-
this.ble = protocol.ble;
|
|
702
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
703
|
-
this.logger = new gd_eventlog_1.EventLogger('BLE-FEC-Tacx');
|
|
704
|
-
if (this.device)
|
|
705
|
-
this.device.setLogger(this.logger);
|
|
706
|
-
}
|
|
707
|
-
isSame(device) {
|
|
708
|
-
if (!(device instanceof TacxBleFEAdapter))
|
|
709
|
-
return false;
|
|
710
|
-
const adapter = device;
|
|
711
|
-
return (adapter.getName() === this.getName() && adapter.getProfile() === this.getProfile());
|
|
712
|
-
}
|
|
713
|
-
getProfile() {
|
|
714
|
-
return TacxBleFEAdapter.PROFILE;
|
|
715
|
-
}
|
|
716
|
-
start(props) {
|
|
717
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
718
|
-
this.logger.logEvent({ message: 'tacx: start requested', profile: this.getProfile(), props });
|
|
719
|
-
if (this.ble.isScanning())
|
|
720
|
-
yield this.ble.stopScan();
|
|
721
|
-
try {
|
|
722
|
-
const bleDevice = yield this.ble.connectDevice(this.device);
|
|
723
|
-
bleDevice.setLogger(this.logger);
|
|
724
|
-
if (bleDevice) {
|
|
725
|
-
this.device = bleDevice;
|
|
726
|
-
const mode = this.getCyclingMode();
|
|
727
|
-
if (mode && mode.getSetting('bikeType')) {
|
|
728
|
-
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
729
|
-
this.device.setCrr(cRR);
|
|
730
|
-
switch (bikeType) {
|
|
731
|
-
case 'race':
|
|
732
|
-
this.device.setCw(cwABike.race);
|
|
733
|
-
break;
|
|
734
|
-
case 'triathlon':
|
|
735
|
-
this.device.setCw(cwABike.triathlon);
|
|
736
|
-
break;
|
|
737
|
-
case 'mountain':
|
|
738
|
-
this.device.setCw(cwABike.mountain);
|
|
739
|
-
break;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
const { user, wheelDiameter, gearRatio } = props || {};
|
|
743
|
-
const userWeight = (user && user.weight ? user.weight : device_1.DEFAULT_USER_WEIGHT);
|
|
744
|
-
const bikeWeight = device_1.DEFAULT_BIKE_WEIGHT;
|
|
745
|
-
this.device.sendTrackResistance(0.0);
|
|
746
|
-
this.device.sendUserConfiguration(userWeight, bikeWeight, wheelDiameter, gearRatio);
|
|
747
|
-
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
748
|
-
yield this.sendUpdate(startRequest);
|
|
749
|
-
bleDevice.on('data', (data) => {
|
|
750
|
-
this.onDeviceData(data);
|
|
751
|
-
});
|
|
752
|
-
return true;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
catch (err) {
|
|
756
|
-
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
757
|
-
throw new Error(`could not start device, reason:${err.message}`);
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
pause() { this.paused = true; return Promise.resolve(true); }
|
|
762
|
-
resume() { this.paused = false; return Promise.resolve(true); }
|
|
763
|
-
}
|
|
764
|
-
exports.TacxBleFEAdapter = TacxBleFEAdapter;
|
|
765
|
-
TacxBleFEAdapter.PROFILE = PROFILE_ID;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BleTacxComms = exports.BleTacxAdapter = void 0;
|
|
7
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
8
|
+
exports.BleTacxComms = comms_1.default;
|
|
9
|
+
const adapter_1 = __importDefault(require("./adapter"));
|
|
10
|
+
exports.BleTacxAdapter = adapter_1.default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IndoorBikeData } from "../fm";
|
|
2
|
+
export interface BleFeBikeData extends IndoorBikeData {
|
|
3
|
+
EquipmentType?: 'Treadmill' | 'Elliptical' | 'StationaryBike' | 'Rower' | 'Climber' | 'NordicSkier' | 'Trainer' | 'General';
|
|
4
|
+
RealSpeed?: number;
|
|
5
|
+
VirtualSpeed?: number;
|
|
6
|
+
HeartRateSource?: 'HandContact' | 'EM' | 'ANT+';
|
|
7
|
+
State?: 'OFF' | 'READY' | 'IN_USE' | 'FINISHED';
|
|
8
|
+
EventCount?: number;
|
|
9
|
+
AccumulatedPower?: number;
|
|
10
|
+
TrainerStatus?: number;
|
|
11
|
+
TargetStatus?: 'OnTarget' | 'LowSpeed' | 'HighSpeed';
|
|
12
|
+
HwVersion?: number;
|
|
13
|
+
ManId?: number;
|
|
14
|
+
ModelNum?: number;
|
|
15
|
+
SwVersion?: number;
|
|
16
|
+
SerialNumber?: number;
|
|
17
|
+
}
|
|
18
|
+
export type MessageInfo = {
|
|
19
|
+
message: string;
|
|
20
|
+
ts: number;
|
|
21
|
+
uuid: string;
|
|
22
|
+
};
|
|
23
|
+
export type MessageLog = {
|
|
24
|
+
[uuid: string]: MessageInfo;
|
|
25
|
+
};
|