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,128 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import EventEmitter from "events";
|
|
4
|
+
import { EventLogger } from "gd-eventlog";
|
|
5
|
+
import { DeviceProperties, DeviceSettings, DeviceStartProperties, IncyclistScanProps } from "../types/device";
|
|
6
|
+
import { InterfaceProps } from "../types/interface";
|
|
7
|
+
export type BleProtocol = 'hr' | 'fm' | 'cp' | 'tacx' | 'wahoo' | 'elite';
|
|
8
|
+
export type BleInterfaceState = 'unknown' | 'resetting' | 'unsupported' | 'unauthorized' | 'poweredOff' | 'poweredOn';
|
|
9
|
+
export interface BleBinding extends EventEmitter {
|
|
10
|
+
startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean, callback?: (error?: Error) => void): void;
|
|
11
|
+
stopScanning(callback?: () => void): void;
|
|
12
|
+
_bindings: any;
|
|
13
|
+
state: BleInterfaceState;
|
|
14
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
15
|
+
}
|
|
16
|
+
export interface BleScanProps extends IncyclistScanProps {
|
|
17
|
+
protocol?: BleProtocol;
|
|
18
|
+
protocols?: BleProtocol[];
|
|
19
|
+
isBackgroundScan?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface BleDeviceConstructProps extends BleDeviceProps {
|
|
22
|
+
log?: boolean;
|
|
23
|
+
logger?: EventLogger;
|
|
24
|
+
peripheral?: BlePeripheral;
|
|
25
|
+
}
|
|
26
|
+
export interface BleDeviceSettings extends DeviceSettings {
|
|
27
|
+
id?: string;
|
|
28
|
+
protocol: BleProtocol;
|
|
29
|
+
profile?: string;
|
|
30
|
+
address?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface BleDetectedDevice extends BleDeviceSettings {
|
|
34
|
+
peripheral: BlePeripheral;
|
|
35
|
+
}
|
|
36
|
+
export interface BleDeviceProperties extends DeviceProperties {
|
|
37
|
+
wheelDiameter?: number;
|
|
38
|
+
gearRatio?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface BleStartProperties extends DeviceStartProperties {
|
|
41
|
+
wheelDiameter?: number;
|
|
42
|
+
gearRatio?: number;
|
|
43
|
+
restart?: boolean;
|
|
44
|
+
scanOnly?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface BleInterfaceProps extends InterfaceProps {
|
|
47
|
+
binding?: BleBinding;
|
|
48
|
+
timeout?: number;
|
|
49
|
+
reconnect?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export type BleService = {
|
|
52
|
+
uuid: string;
|
|
53
|
+
};
|
|
54
|
+
export type DiscoverResult = {
|
|
55
|
+
services: BleService[];
|
|
56
|
+
characteristics: BleCharacteristic[];
|
|
57
|
+
};
|
|
58
|
+
export interface BlePeripheral extends EventEmitter, BlePeripheralIdentifier {
|
|
59
|
+
services: [];
|
|
60
|
+
advertisement: any;
|
|
61
|
+
state: string;
|
|
62
|
+
connectAsync(): Promise<void>;
|
|
63
|
+
disconnect(cb: (err?: Error) => void): Promise<void>;
|
|
64
|
+
discoverSomeServicesAndCharacteristicsAsync(serviceUUIDs: string[], characteristicUUIDs: string[]): Promise<DiscoverResult>;
|
|
65
|
+
}
|
|
66
|
+
export interface IBlePeripheralConnector {
|
|
67
|
+
connect(): Promise<void>;
|
|
68
|
+
reconnect(): Promise<void>;
|
|
69
|
+
initialize(enforce: boolean): Promise<void>;
|
|
70
|
+
isSubscribed(characteristicUuid: string): boolean;
|
|
71
|
+
subscribeAll(callback: (characteristicUuid: string, data: any) => void): Promise<string[]>;
|
|
72
|
+
subscribe(characteristicUuid: string, timeout?: number): Promise<boolean>;
|
|
73
|
+
onDisconnect(): void;
|
|
74
|
+
onData(characteristicUuid: string, data: any): void;
|
|
75
|
+
on(characteristicUuid: string, callback: (characteristicUuid: string, data: any) => void): void;
|
|
76
|
+
off(characteristicUuid: string, callback: (characteristicUuid: string, data: any) => void): void;
|
|
77
|
+
removeAllListeners(characteristicUuid: string): void;
|
|
78
|
+
getState(): string;
|
|
79
|
+
getCharachteristics(): BleCharacteristic[];
|
|
80
|
+
getServices(): string[];
|
|
81
|
+
getPeripheral(): BlePeripheral;
|
|
82
|
+
}
|
|
83
|
+
export interface BleCharacteristic extends EventEmitter {
|
|
84
|
+
uuid: string;
|
|
85
|
+
properties: string[];
|
|
86
|
+
_serviceUuid?: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
subscribe(callback: (err: Error | undefined) => void): void;
|
|
89
|
+
unsubscribe(callback: (err: Error | undefined) => void): void;
|
|
90
|
+
read(callback: (err: Error | undefined, data: Buffer) => void): void;
|
|
91
|
+
write(data: Buffer, withoutResponse: boolean, callback?: (err: Error | undefined) => void): void;
|
|
92
|
+
}
|
|
93
|
+
export type BleDeviceProps = {
|
|
94
|
+
id?: string;
|
|
95
|
+
address?: string;
|
|
96
|
+
name?: string;
|
|
97
|
+
services?: string[];
|
|
98
|
+
peripheral?: BlePeripheral;
|
|
99
|
+
};
|
|
100
|
+
export type BleCommsConnectProps = {
|
|
101
|
+
timeout?: number;
|
|
102
|
+
reconnect?: boolean;
|
|
103
|
+
};
|
|
104
|
+
export interface BleWriteProps {
|
|
105
|
+
withoutResponse?: boolean;
|
|
106
|
+
timeout?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface BlePeripheralIdentifier {
|
|
109
|
+
id?: string;
|
|
110
|
+
address?: string;
|
|
111
|
+
name?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface BlePeripheralDescription extends BlePeripheralIdentifier {
|
|
114
|
+
profile: string;
|
|
115
|
+
}
|
|
116
|
+
export interface ConnectState {
|
|
117
|
+
isConnecting: boolean;
|
|
118
|
+
isConnected: boolean;
|
|
119
|
+
isDisconnecting: boolean;
|
|
120
|
+
}
|
|
121
|
+
export type BleDeviceInfo = {
|
|
122
|
+
manufacturer?: string;
|
|
123
|
+
hwRevision?: string;
|
|
124
|
+
swRevision?: string;
|
|
125
|
+
fwRevision?: string;
|
|
126
|
+
model?: string;
|
|
127
|
+
serialNo?: string;
|
|
128
|
+
};
|
package/lib/ble/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LegacyProfile } from "../antv2/types";
|
|
2
|
+
import { BleCharacteristic, BlePeripheral, BleProtocol } from "./types";
|
|
3
|
+
type MappingRecord = {
|
|
4
|
+
profile: LegacyProfile;
|
|
5
|
+
protocol: BleProtocol;
|
|
6
|
+
};
|
|
7
|
+
export declare function mapLegacyProfile(profile: string): MappingRecord;
|
|
8
|
+
export declare function uuid(s: string): string;
|
|
9
|
+
export declare function matches(uuid1: string, uuid2: string): boolean;
|
|
10
|
+
export declare function getPeripheralInfo(p: BlePeripheral): {
|
|
11
|
+
id: string;
|
|
12
|
+
name: any;
|
|
13
|
+
address: string;
|
|
14
|
+
services: any;
|
|
15
|
+
};
|
|
16
|
+
export declare function getCharachteristicsInfo(c: BleCharacteristic): string;
|
|
17
|
+
export {};
|
package/lib/ble/utils.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCharachteristicsInfo = exports.getPeripheralInfo = exports.matches = exports.uuid = exports.mapLegacyProfile = void 0;
|
|
4
|
+
function mapLegacyProfile(profile) {
|
|
5
|
+
switch (profile) {
|
|
6
|
+
case 'Smart Trainer': return { profile: 'Smart Trainer', protocol: 'fm' };
|
|
7
|
+
case 'Elite Smart Trainer': return { profile: 'Smart Trainer', protocol: 'elite' };
|
|
8
|
+
case 'Heartrate Monitor': return { profile: 'Heartrate Monitor', protocol: 'hr' };
|
|
9
|
+
case 'Power Meter': return { profile: 'Power Meter', protocol: 'cp' };
|
|
10
|
+
case 'Tacx Smart Trainer': return { profile: 'Smart Trainer', protocol: 'tacx' };
|
|
11
|
+
case 'Wahoo Smart Trainer': return { profile: 'Smart Trainer', protocol: 'wahoo' };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.mapLegacyProfile = mapLegacyProfile;
|
|
15
|
+
function uuid(s) {
|
|
16
|
+
if (s) {
|
|
17
|
+
if (s.includes('-')) {
|
|
18
|
+
const parts = s.split('-');
|
|
19
|
+
const uuidNo = parseInt('0x' + parts[0]);
|
|
20
|
+
return uuidNo.toString(16).toLowerCase();
|
|
21
|
+
}
|
|
22
|
+
return s;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.uuid = uuid;
|
|
26
|
+
function matches(uuid1, uuid2) {
|
|
27
|
+
const ul1 = uuid1.toLowerCase();
|
|
28
|
+
const ul2 = uuid2.toLowerCase();
|
|
29
|
+
if (uuid(ul1) === uuid(ul2))
|
|
30
|
+
return true;
|
|
31
|
+
if (ul1.length < ul2.length && ul2.startsWith(ul1))
|
|
32
|
+
return true;
|
|
33
|
+
if (ul1.length > ul2.length && ul1.startsWith(ul2))
|
|
34
|
+
return true;
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
exports.matches = matches;
|
|
38
|
+
function getPeripheralInfo(p) {
|
|
39
|
+
const { id, name, address, advertisement, services } = p;
|
|
40
|
+
if (advertisement) {
|
|
41
|
+
return { id, name: advertisement.localName, address, services: advertisement.serviceUuids };
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return { id, name, address, services };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.getPeripheralInfo = getPeripheralInfo;
|
|
48
|
+
function getCharachteristicsInfo(c) {
|
|
49
|
+
const { uuid, properties, name, _serviceUuid } = c;
|
|
50
|
+
const nameStr = name ? ` (${name})` : '';
|
|
51
|
+
const serviceStr = _serviceUuid ? `${_serviceUuid}:` : '';
|
|
52
|
+
return `${serviceStr}${uuid}${nameStr} ${properties}`;
|
|
53
|
+
}
|
|
54
|
+
exports.getCharachteristicsInfo = getCharachteristicsInfo;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BleFmAdapter } from '../fm';
|
|
2
|
+
import BleAdapter from '../base/adapter';
|
|
3
|
+
import { BleDeviceProperties, BleDeviceSettings, BleStartProperties } from '../types';
|
|
4
|
+
export default class BleWahooAdapter extends BleFmAdapter {
|
|
5
|
+
constructor(settings: BleDeviceSettings, props?: BleDeviceProperties);
|
|
6
|
+
isSame(device: BleAdapter): boolean;
|
|
7
|
+
getProfile(): string;
|
|
8
|
+
start(props?: BleStartProperties): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
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 BleWahooAdapter extends fm_1.BleFmAdapter {
|
|
21
|
+
constructor(settings, props) {
|
|
22
|
+
super(settings, props);
|
|
23
|
+
this.logger = new gd_eventlog_1.EventLogger('BLE-WahooFM');
|
|
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 BleWahooAdapter))
|
|
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
|
+
this.logger.logEvent({ message: 'start requested', protocol: this.getProtocolName(), props });
|
|
44
|
+
try {
|
|
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
|
+
const comms = this.device;
|
|
53
|
+
if (comms) {
|
|
54
|
+
const mode = this.getCyclingMode();
|
|
55
|
+
if (mode && mode.getSetting('bikeType')) {
|
|
56
|
+
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
57
|
+
comms.setCrr(fm_1.cRR);
|
|
58
|
+
switch (bikeType) {
|
|
59
|
+
case 'race':
|
|
60
|
+
comms.setCw(fm_1.cwABike.race);
|
|
61
|
+
break;
|
|
62
|
+
case 'triathlon':
|
|
63
|
+
comms.setCw(fm_1.cwABike.triathlon);
|
|
64
|
+
break;
|
|
65
|
+
case 'mountain':
|
|
66
|
+
comms.setCw(fm_1.cwABike.mountain);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const { user, bikeWeight = adpater_1.DEFAULT_BIKE_WEIGHT } = props || {};
|
|
71
|
+
const weight = (user && user.weight ? Number(user.weight) : adpater_1.DEFAULT_USER_WEIGHT) + bikeWeight;
|
|
72
|
+
yield comms.setSimMode(weight, comms.getCrr(), comms.getCw());
|
|
73
|
+
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
74
|
+
yield this.sendUpdate(startRequest);
|
|
75
|
+
comms.on('data', (data) => {
|
|
76
|
+
this.onDeviceData(data);
|
|
77
|
+
});
|
|
78
|
+
if (comms.features.heartrate && !this.hasCapability(capabilities_1.IncyclistCapability.HeartRate)) {
|
|
79
|
+
this.capabilities.push(capabilities_1.IncyclistCapability.HeartRate);
|
|
80
|
+
}
|
|
81
|
+
this.resetData();
|
|
82
|
+
this.stopped = false;
|
|
83
|
+
this.started = true;
|
|
84
|
+
this.paused = false;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
90
|
+
throw new Error(`could not start device, reason:${err.message}`);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = BleWahooAdapter;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import BleFitnessMachineDevice
|
|
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, BleWriteProps, IBlePeripheralConnector } from "../types";
|
|
6
7
|
export declare const enum OpCode {
|
|
7
8
|
unlock = 32,
|
|
8
9
|
setResistanceMode = 64,
|
|
@@ -15,31 +16,8 @@ export declare const enum OpCode {
|
|
|
15
16
|
setSimWindSpeed = 71,
|
|
16
17
|
setWheelCircumference = 72
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
averageSpeed?: number;
|
|
21
|
-
cadence?: number;
|
|
22
|
-
averageCadence?: number;
|
|
23
|
-
totalDistance?: number;
|
|
24
|
-
resistanceLevel?: number;
|
|
25
|
-
instantaneousPower?: number;
|
|
26
|
-
averagePower?: number;
|
|
27
|
-
expendedEnergy?: number;
|
|
28
|
-
heartrate?: number;
|
|
29
|
-
metabolicEquivalent?: number;
|
|
30
|
-
time?: number;
|
|
31
|
-
remainingTime?: number;
|
|
32
|
-
raw?: string;
|
|
33
|
-
targetPower?: number;
|
|
34
|
-
targetInclination?: number;
|
|
35
|
-
status?: string;
|
|
36
|
-
};
|
|
37
|
-
declare type CrankData = {
|
|
38
|
-
revolutions?: number;
|
|
39
|
-
time?: number;
|
|
40
|
-
cntUpdateMissing?: number;
|
|
41
|
-
};
|
|
42
|
-
export default class WahooAdvancedFitnessMachineDevice extends BleFitnessMachineDevice {
|
|
19
|
+
export default class BleWahooDevice extends BleFitnessMachineDevice {
|
|
20
|
+
static protocol: BleProtocol;
|
|
43
21
|
static services: string[];
|
|
44
22
|
static characteristics: string[];
|
|
45
23
|
static detectionPriority: number;
|
|
@@ -58,20 +36,19 @@ export default class WahooAdvancedFitnessMachineDevice extends BleFitnessMachine
|
|
|
58
36
|
cw: number;
|
|
59
37
|
};
|
|
60
38
|
constructor(props?: any);
|
|
61
|
-
isMatching(characteristics: string[]): boolean;
|
|
39
|
+
static isMatching(characteristics: string[]): boolean;
|
|
62
40
|
init(): Promise<boolean>;
|
|
63
41
|
setCharacteristicUUIDs(uuids: string[]): void;
|
|
64
|
-
getProfile():
|
|
42
|
+
getProfile(): LegacyProfile;
|
|
43
|
+
getProtocol(): BleProtocol;
|
|
65
44
|
getServiceUUids(): string[];
|
|
66
|
-
isBike(): boolean;
|
|
67
|
-
isPower(): boolean;
|
|
68
|
-
isHrm(): boolean;
|
|
69
45
|
parseCrankData(crankData: any): {
|
|
70
46
|
rpm: number;
|
|
71
47
|
time: any;
|
|
72
48
|
};
|
|
73
49
|
parsePower(_data: Buffer): IndoorBikeData;
|
|
74
50
|
onData(characteristic: string, data: Buffer): boolean;
|
|
51
|
+
subscribeAll(conn?: IBlePeripheralConnector): Promise<void>;
|
|
75
52
|
writeWahooFtmsMessage(requestedOpCode: number, data: Buffer, props?: BleWriteProps): Promise<boolean>;
|
|
76
53
|
requestControl(): Promise<boolean>;
|
|
77
54
|
setPowerAdjusting(): void;
|
|
@@ -86,13 +63,3 @@ export default class WahooAdvancedFitnessMachineDevice extends BleFitnessMachine
|
|
|
86
63
|
setSlope(slope: any): Promise<boolean>;
|
|
87
64
|
reset(): void;
|
|
88
65
|
}
|
|
89
|
-
export declare class WahooAdvancedFmAdapter extends FmAdapter {
|
|
90
|
-
device: WahooAdvancedFitnessMachineDevice;
|
|
91
|
-
constructor(device: BleDeviceClass, protocol: BleProtocol);
|
|
92
|
-
isSame(device: DeviceAdapter): boolean;
|
|
93
|
-
getProfile(): string;
|
|
94
|
-
start(props?: any): Promise<any>;
|
|
95
|
-
pause(): Promise<boolean>;
|
|
96
|
-
resume(): Promise<boolean>;
|
|
97
|
-
}
|
|
98
|
-
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,22 +12,13 @@ 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
|
|
39
|
-
const fm_1 = __importStar(require("./fm"));
|
|
40
|
-
const consts_1 = require("./consts");
|
|
41
|
-
const WAHOO_ADVANCED_FTMS = 'a026ee0b';
|
|
42
|
-
const cwABike = {
|
|
43
|
-
race: 0.35,
|
|
44
|
-
triathlon: 0.29,
|
|
45
|
-
mountain: 0.57
|
|
46
|
-
};
|
|
47
|
-
const cRR = 0.0036;
|
|
15
|
+
const _1 = require(".");
|
|
16
|
+
const adpater_1 = require("../../base/adpater");
|
|
17
|
+
const consts_1 = require("../consts");
|
|
18
|
+
const comms_1 = __importDefault(require("../fm/comms"));
|
|
19
|
+
const utils_1 = require("../utils");
|
|
48
20
|
const ErgWriteDelay = 2000;
|
|
49
|
-
class
|
|
21
|
+
class BleWahooDevice extends comms_1.default {
|
|
50
22
|
constructor(props) {
|
|
51
23
|
super(props);
|
|
52
24
|
this.prevCrankData = undefined;
|
|
@@ -55,15 +27,15 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
55
27
|
this.tsPrevWrite = undefined;
|
|
56
28
|
this.prevSlope = undefined;
|
|
57
29
|
this.isRequestControlBusy = false;
|
|
58
|
-
this.weight =
|
|
30
|
+
this.weight = adpater_1.DEFAULT_BIKE_WEIGHT + adpater_1.DEFAULT_USER_WEIGHT;
|
|
59
31
|
this.data = {};
|
|
60
32
|
this.wahooCP = consts_1.WAHOO_ADVANCED_TRAINER_CP;
|
|
61
33
|
}
|
|
62
|
-
isMatching(characteristics) {
|
|
34
|
+
static isMatching(characteristics) {
|
|
63
35
|
if (!characteristics)
|
|
64
36
|
return false;
|
|
65
|
-
const hasWahooCP = characteristics.find(c => (0,
|
|
66
|
-
const hasFTMS = characteristics.find(c => (0,
|
|
37
|
+
const hasWahooCP = characteristics.find(c => (0, utils_1.matches)(c, consts_1.WAHOO_ADVANCED_TRAINER_CP)) !== undefined;
|
|
38
|
+
const hasFTMS = characteristics.find(c => (0, utils_1.matches)(c, consts_1.FTMS_CP)) !== undefined;
|
|
67
39
|
return hasWahooCP && !hasFTMS;
|
|
68
40
|
}
|
|
69
41
|
init() {
|
|
@@ -79,8 +51,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
79
51
|
}
|
|
80
52
|
catch (err) {
|
|
81
53
|
}
|
|
82
|
-
yield _super.initDevice.call(this);
|
|
83
|
-
return true;
|
|
54
|
+
return yield _super.initDevice.call(this);
|
|
84
55
|
}
|
|
85
56
|
catch (err) {
|
|
86
57
|
this.logEvent({ message: 'error', fn: 'WahooAdvancedFitnessMachineDevice.init()', error: err.message || err, stack: err.stack });
|
|
@@ -91,24 +62,18 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
91
62
|
setCharacteristicUUIDs(uuids) {
|
|
92
63
|
this.logEvent({ message: 'set uuids', uuids });
|
|
93
64
|
uuids.forEach(c => {
|
|
94
|
-
if ((0,
|
|
65
|
+
if ((0, utils_1.matches)(c, consts_1.WAHOO_ADVANCED_TRAINER_CP))
|
|
95
66
|
this.wahooCP = c;
|
|
96
67
|
});
|
|
97
68
|
}
|
|
98
69
|
getProfile() {
|
|
99
|
-
return '
|
|
100
|
-
}
|
|
101
|
-
getServiceUUids() {
|
|
102
|
-
return WahooAdvancedFitnessMachineDevice.services;
|
|
103
|
-
}
|
|
104
|
-
isBike() {
|
|
105
|
-
return true;
|
|
70
|
+
return 'Smart Trainer';
|
|
106
71
|
}
|
|
107
|
-
|
|
108
|
-
return
|
|
72
|
+
getProtocol() {
|
|
73
|
+
return _1.BleWahooComms.protocol;
|
|
109
74
|
}
|
|
110
|
-
|
|
111
|
-
return
|
|
75
|
+
getServiceUUids() {
|
|
76
|
+
return BleWahooDevice.services;
|
|
112
77
|
}
|
|
113
78
|
parseCrankData(crankData) {
|
|
114
79
|
if (!this.prevCrankData)
|
|
@@ -178,16 +143,16 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
178
143
|
const uuid = characteristic.toLowerCase();
|
|
179
144
|
let res = undefined;
|
|
180
145
|
switch (uuid) {
|
|
181
|
-
case
|
|
146
|
+
case consts_1.CSP_MEASUREMENT:
|
|
182
147
|
res = this.parsePower(data);
|
|
183
148
|
break;
|
|
184
|
-
case
|
|
149
|
+
case consts_1.INDOOR_BIKE_DATA:
|
|
185
150
|
res = this.parseIndoorBikeData(data);
|
|
186
151
|
break;
|
|
187
|
-
case
|
|
152
|
+
case consts_1.HR_MEASUREMENT:
|
|
188
153
|
res = this.parseHrm(data);
|
|
189
154
|
break;
|
|
190
|
-
case
|
|
155
|
+
case consts_1.FTMS_STATUS:
|
|
191
156
|
res = this.parseFitnessMachineStatus(data);
|
|
192
157
|
break;
|
|
193
158
|
default:
|
|
@@ -200,6 +165,9 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
200
165
|
}
|
|
201
166
|
return true;
|
|
202
167
|
}
|
|
168
|
+
subscribeAll(conn) {
|
|
169
|
+
return this.subscribeMultiple([consts_1.CSP_MEASUREMENT, consts_1.INDOOR_BIKE_DATA, consts_1.HR_MEASUREMENT, consts_1.FTMS_STATUS, this.wahooCP], conn);
|
|
170
|
+
}
|
|
203
171
|
writeWahooFtmsMessage(requestedOpCode, data, props) {
|
|
204
172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
205
173
|
try {
|
|
@@ -423,76 +391,8 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
423
391
|
this.simModeSettings = undefined;
|
|
424
392
|
}
|
|
425
393
|
}
|
|
426
|
-
exports.default =
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
class WahooAdvancedFmAdapter extends fm_1.FmAdapter {
|
|
432
|
-
constructor(device, protocol) {
|
|
433
|
-
super(device, protocol);
|
|
434
|
-
this.device = device;
|
|
435
|
-
this.ble = protocol.ble;
|
|
436
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
437
|
-
this.logger = new gd_eventlog_1.EventLogger('BLE-WahooFM');
|
|
438
|
-
if (this.device)
|
|
439
|
-
this.device.setLogger(this.logger);
|
|
440
|
-
}
|
|
441
|
-
isSame(device) {
|
|
442
|
-
if (!(device instanceof WahooAdvancedFmAdapter))
|
|
443
|
-
return false;
|
|
444
|
-
const adapter = device;
|
|
445
|
-
return (adapter.getName() === this.getName() && adapter.getProfile() === this.getProfile());
|
|
446
|
-
}
|
|
447
|
-
getProfile() {
|
|
448
|
-
return 'Wahoo Smart Trainer';
|
|
449
|
-
}
|
|
450
|
-
start(props) {
|
|
451
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
452
|
-
this.logger.logEvent({ message: 'wahoo: start requested', profile: this.getProfile(), props, isScanning: this.ble.isScanning() });
|
|
453
|
-
try {
|
|
454
|
-
this.logger.logEvent({ message: 'wahoo: stop previous scan', isScanning: this.ble.isScanning() });
|
|
455
|
-
if (this.ble.isScanning())
|
|
456
|
-
yield this.ble.stopScan();
|
|
457
|
-
this.logger.logEvent({ message: 'wahoo trying device connect' });
|
|
458
|
-
const bleDevice = yield this.ble.connectDevice(this.device);
|
|
459
|
-
this.logger.logEvent({ message: 'wahoo device connected', connected: (bleDevice !== null && bleDevice !== undefined) });
|
|
460
|
-
if (bleDevice) {
|
|
461
|
-
this.device = bleDevice;
|
|
462
|
-
const mode = this.getCyclingMode();
|
|
463
|
-
if (mode && mode.getSetting('bikeType')) {
|
|
464
|
-
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
465
|
-
this.device.setCrr(cRR);
|
|
466
|
-
switch (bikeType) {
|
|
467
|
-
case 'race':
|
|
468
|
-
this.device.setCw(cwABike.race);
|
|
469
|
-
break;
|
|
470
|
-
case 'triathlon':
|
|
471
|
-
this.device.setCw(cwABike.triathlon);
|
|
472
|
-
break;
|
|
473
|
-
case 'mountain':
|
|
474
|
-
this.device.setCw(cwABike.mountain);
|
|
475
|
-
break;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
const { user } = props || {};
|
|
479
|
-
const weight = (user && user.weight ? Number(user.weight) : device_1.DEFAULT_USER_WEIGHT) + device_1.DEFAULT_BIKE_WEIGHT;
|
|
480
|
-
yield this.device.setSimMode(weight, this.device.getCrr(), this.device.getCw());
|
|
481
|
-
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
482
|
-
yield this.sendUpdate(startRequest);
|
|
483
|
-
bleDevice.on('data', (data) => {
|
|
484
|
-
this.onDeviceData(data);
|
|
485
|
-
});
|
|
486
|
-
return true;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
catch (err) {
|
|
490
|
-
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
491
|
-
throw new Error(`could not start device, reason:${err.message}`);
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
pause() { this.paused = true; return Promise.resolve(true); }
|
|
496
|
-
resume() { this.paused = false; return Promise.resolve(true); }
|
|
497
|
-
}
|
|
498
|
-
exports.WahooAdvancedFmAdapter = WahooAdvancedFmAdapter;
|
|
394
|
+
exports.default = BleWahooDevice;
|
|
395
|
+
BleWahooDevice.protocol = 'wahoo';
|
|
396
|
+
BleWahooDevice.services = [consts_1.CSP];
|
|
397
|
+
BleWahooDevice.characteristics = ['2acc', '2ad2', '2ad6', '2ad8', '2ad9', '2ada', consts_1.WAHOO_ADVANCED_TRAINER_CP];
|
|
398
|
+
BleWahooDevice.detectionPriority = 5;
|
|
@@ -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.BleWahooComms = exports.BleWahooAdapter = void 0;
|
|
7
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
8
|
+
exports.BleWahooComms = comms_1.default;
|
|
9
|
+
const adapter_1 = __importDefault(require("./adapter"));
|
|
10
|
+
exports.BleWahooAdapter = adapter_1.default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type IndoorBikeData = {
|
|
2
|
+
speed?: number;
|
|
3
|
+
averageSpeed?: number;
|
|
4
|
+
cadence?: number;
|
|
5
|
+
averageCadence?: number;
|
|
6
|
+
totalDistance?: number;
|
|
7
|
+
resistanceLevel?: number;
|
|
8
|
+
instantaneousPower?: number;
|
|
9
|
+
averagePower?: number;
|
|
10
|
+
expendedEnergy?: number;
|
|
11
|
+
heartrate?: number;
|
|
12
|
+
metabolicEquivalent?: number;
|
|
13
|
+
time?: number;
|
|
14
|
+
remainingTime?: number;
|
|
15
|
+
raw?: string;
|
|
16
|
+
targetPower?: number;
|
|
17
|
+
targetInclination?: number;
|
|
18
|
+
status?: string;
|
|
19
|
+
};
|