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
package/lib/ble/ble.d.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from "events";
|
|
3
|
-
import BlePeripheralConnector from "./ble-peripheral";
|
|
4
|
-
export declare type ConnectProps = {
|
|
5
|
-
timeout?: number;
|
|
6
|
-
reconnect?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export interface BleDeviceIdentifier {
|
|
9
|
-
id?: string;
|
|
10
|
-
address?: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface ConnectState {
|
|
14
|
-
isConnecting: boolean;
|
|
15
|
-
isConnected: boolean;
|
|
16
|
-
isDisconnecting: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare type BleDeviceInfo = {
|
|
19
|
-
manufacturer?: string;
|
|
20
|
-
hwRevision?: string;
|
|
21
|
-
swRevision?: string;
|
|
22
|
-
fwRevision?: string;
|
|
23
|
-
model?: string;
|
|
24
|
-
serialNo?: string;
|
|
25
|
-
};
|
|
26
|
-
export interface BleDeviceDescription {
|
|
27
|
-
id?: string;
|
|
28
|
-
address: string;
|
|
29
|
-
name?: string;
|
|
30
|
-
profile: string;
|
|
31
|
-
}
|
|
32
|
-
export declare abstract class BleDeviceClass extends EventEmitter {
|
|
33
|
-
static services: string[];
|
|
34
|
-
id?: string;
|
|
35
|
-
address?: string;
|
|
36
|
-
name?: string;
|
|
37
|
-
peripheral?: BlePeripheral;
|
|
38
|
-
connectState: ConnectState;
|
|
39
|
-
getConnectState(): ConnectState;
|
|
40
|
-
isConnected(): boolean;
|
|
41
|
-
abstract getProfile(): string;
|
|
42
|
-
abstract getServiceUUids(): string[];
|
|
43
|
-
abstract connect(props?: ConnectProps): Promise<boolean>;
|
|
44
|
-
abstract disconnect(): Promise<boolean>;
|
|
45
|
-
abstract getDeviceInfo(): Promise<BleDeviceInfo>;
|
|
46
|
-
abstract getServices(): string[];
|
|
47
|
-
setCharacteristicUUIDs(uuids: string[]): void;
|
|
48
|
-
}
|
|
49
|
-
export interface BleWriteProps {
|
|
50
|
-
withoutResponse?: boolean;
|
|
51
|
-
timeout?: number;
|
|
52
|
-
}
|
|
53
|
-
export interface BleBinding extends EventEmitter {
|
|
54
|
-
startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean, callback?: (error?: Error) => void): void;
|
|
55
|
-
stopScanning(callback?: () => void): void;
|
|
56
|
-
_bindings: any;
|
|
57
|
-
state: string;
|
|
58
|
-
}
|
|
59
|
-
export declare type ScanProps = {
|
|
60
|
-
timeout?: number;
|
|
61
|
-
deviceTypes?: (typeof BleDeviceClass)[];
|
|
62
|
-
requested?: BleDeviceClass | BleDeviceDescription;
|
|
63
|
-
isBackgroundScan?: boolean;
|
|
64
|
-
};
|
|
65
|
-
export declare class BleBindingWrapper {
|
|
66
|
-
protected binding: BleBinding;
|
|
67
|
-
constructor(binding: BleBinding);
|
|
68
|
-
open(): {
|
|
69
|
-
err: Error;
|
|
70
|
-
opened: boolean;
|
|
71
|
-
};
|
|
72
|
-
get(): BleBinding;
|
|
73
|
-
}
|
|
74
|
-
export declare abstract class BleInterfaceClass extends EventEmitter {
|
|
75
|
-
binding: BleBinding;
|
|
76
|
-
constructor(props?: {
|
|
77
|
-
binding?: BleBinding;
|
|
78
|
-
});
|
|
79
|
-
abstract connect(props: ConnectProps): Promise<boolean>;
|
|
80
|
-
abstract scan(props: ScanProps): Promise<BleDeviceClass[]>;
|
|
81
|
-
abstract stopScan(): Promise<boolean>;
|
|
82
|
-
abstract disconnect(): Promise<boolean>;
|
|
83
|
-
abstract onDisconnect(peripheral: BlePeripheral): void;
|
|
84
|
-
abstract isScanning(): boolean;
|
|
85
|
-
abstract addConnectedDevice(device: BleDeviceClass): void;
|
|
86
|
-
abstract removeConnectedDevice(device: BleDeviceClass): void;
|
|
87
|
-
abstract findConnected(device: BleDeviceClass | BlePeripheral): BleDeviceClass;
|
|
88
|
-
abstract getConnector(peripheral: BlePeripheral): BlePeripheralConnector;
|
|
89
|
-
abstract findPeripheral(peripheral: BlePeripheral | {
|
|
90
|
-
id?: string;
|
|
91
|
-
address?: string;
|
|
92
|
-
name?: string;
|
|
93
|
-
}): BlePeripheral;
|
|
94
|
-
getBinding(): BleBinding;
|
|
95
|
-
setBinding(binding: BleBinding): void;
|
|
96
|
-
}
|
|
97
|
-
export interface BlePeripheral extends EventEmitter, BleDeviceIdentifier {
|
|
98
|
-
services: string[];
|
|
99
|
-
advertisement: any;
|
|
100
|
-
state: string;
|
|
101
|
-
connectAsync(): Promise<void>;
|
|
102
|
-
disconnect(cb: (err?: Error) => void): Promise<void>;
|
|
103
|
-
discoverSomeServicesAndCharacteristicsAsync(serviceUUIDs: string[], characteristicUUIDs: string[]): Promise<any>;
|
|
104
|
-
}
|
|
105
|
-
export interface BleCharacteristic extends EventEmitter {
|
|
106
|
-
uuid: string;
|
|
107
|
-
properties: string[];
|
|
108
|
-
subscribe(callback: (err: Error) => void): void;
|
|
109
|
-
read(callback: (err: Error, data: Buffer) => void): void;
|
|
110
|
-
write(data: Buffer, withoutResponse: boolean, callback?: (err: Error) => void): void;
|
|
111
|
-
}
|
|
112
|
-
export declare type BleDeviceProps = {
|
|
113
|
-
id?: string;
|
|
114
|
-
address?: string;
|
|
115
|
-
name?: string;
|
|
116
|
-
services?: string[];
|
|
117
|
-
ble: BleInterfaceClass;
|
|
118
|
-
peripheral?: BlePeripheral;
|
|
119
|
-
};
|
|
120
|
-
export declare enum BleState {
|
|
121
|
-
UNKNOWN = "unknown",
|
|
122
|
-
RESETTING = "resetting",
|
|
123
|
-
UNSUPPORTED = "unsupported",
|
|
124
|
-
UNAUTHORIZED = "unauthorized",
|
|
125
|
-
POWERED_OFF = "poweredOff",
|
|
126
|
-
POWERED_ON = "poweredOn"
|
|
127
|
-
}
|
|
128
|
-
export declare const uuid: (s: any) => any;
|
|
129
|
-
export declare const matches: (uuid1: any, uuid2: any) => boolean;
|
package/lib/ble/ble.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
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.matches = exports.uuid = exports.BleState = exports.BleInterfaceClass = exports.BleBindingWrapper = exports.BleDeviceClass = void 0;
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
class BleDeviceClass extends events_1.default {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.connectState = { isConnecting: false, isConnected: false, isDisconnecting: false };
|
|
12
|
-
}
|
|
13
|
-
getConnectState() {
|
|
14
|
-
return this.connectState;
|
|
15
|
-
}
|
|
16
|
-
isConnected() {
|
|
17
|
-
return this.connectState.isConnected;
|
|
18
|
-
}
|
|
19
|
-
setCharacteristicUUIDs(uuids) { }
|
|
20
|
-
}
|
|
21
|
-
exports.BleDeviceClass = BleDeviceClass;
|
|
22
|
-
BleDeviceClass.services = [];
|
|
23
|
-
class BleBindingWrapper {
|
|
24
|
-
constructor(binding) {
|
|
25
|
-
this.binding = binding;
|
|
26
|
-
this.binding = binding;
|
|
27
|
-
}
|
|
28
|
-
open() {
|
|
29
|
-
const binding = this.binding._bindings;
|
|
30
|
-
const binding_init = binding.init.bind(binding);
|
|
31
|
-
try {
|
|
32
|
-
binding_init();
|
|
33
|
-
return { err: null, opened: true };
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
const error = err;
|
|
37
|
-
const opened = false;
|
|
38
|
-
return { err: error, opened };
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
get() {
|
|
42
|
-
return this.binding;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.BleBindingWrapper = BleBindingWrapper;
|
|
46
|
-
class BleInterfaceClass extends events_1.default {
|
|
47
|
-
constructor(props = {}) {
|
|
48
|
-
super();
|
|
49
|
-
this.setBinding(props.binding);
|
|
50
|
-
}
|
|
51
|
-
getBinding() { return this.binding; }
|
|
52
|
-
setBinding(binding) { this.binding = binding; }
|
|
53
|
-
}
|
|
54
|
-
exports.BleInterfaceClass = BleInterfaceClass;
|
|
55
|
-
var BleState;
|
|
56
|
-
(function (BleState) {
|
|
57
|
-
BleState["UNKNOWN"] = "unknown";
|
|
58
|
-
BleState["RESETTING"] = "resetting";
|
|
59
|
-
BleState["UNSUPPORTED"] = "unsupported";
|
|
60
|
-
BleState["UNAUTHORIZED"] = "unauthorized";
|
|
61
|
-
BleState["POWERED_OFF"] = "poweredOff";
|
|
62
|
-
BleState["POWERED_ON"] = "poweredOn";
|
|
63
|
-
})(BleState = exports.BleState || (exports.BleState = {}));
|
|
64
|
-
const uuid = (s) => {
|
|
65
|
-
if (s) {
|
|
66
|
-
if (s.includes('-')) {
|
|
67
|
-
const parts = s.split('-');
|
|
68
|
-
const uuidNo = parseInt('0x' + parts[0]);
|
|
69
|
-
return uuidNo.toString(16).toLowerCase();
|
|
70
|
-
}
|
|
71
|
-
return s;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
exports.uuid = uuid;
|
|
75
|
-
const matches = (uuid1, uuid2) => {
|
|
76
|
-
const ul1 = uuid1.toLowerCase();
|
|
77
|
-
const ul2 = uuid2.toLowerCase();
|
|
78
|
-
if ((0, exports.uuid)(ul1) === (0, exports.uuid)(ul2))
|
|
79
|
-
return true;
|
|
80
|
-
if (ul1.length < ul2.length && ul2.startsWith(ul1))
|
|
81
|
-
return true;
|
|
82
|
-
if (ul1.length > ul2.length && ul1.startsWith(ul2))
|
|
83
|
-
return true;
|
|
84
|
-
return false;
|
|
85
|
-
};
|
|
86
|
-
exports.matches = matches;
|
package/lib/ble/elite.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { BleDevice } from './ble-device';
|
|
3
|
-
import BleInterface from './ble-interface';
|
|
4
|
-
import BleProtocol from './incyclist-protocol';
|
|
5
|
-
import { BleDeviceClass } from './ble';
|
|
6
|
-
import DeviceAdapter, { DeviceData } from '../device';
|
|
7
|
-
import { DeviceProtocol } from '../protocol';
|
|
8
|
-
import { EventLogger } from 'gd-eventlog';
|
|
9
|
-
import CyclingMode from '../cycling-mode';
|
|
10
|
-
import { IncyclistBikeData } from '../cycling-mode';
|
|
11
|
-
export declare const ELITE_TRAINER_SVC = "347b0001";
|
|
12
|
-
declare type PowerData = {
|
|
13
|
-
instantaneousPower?: number;
|
|
14
|
-
balance?: number;
|
|
15
|
-
accTorque?: number;
|
|
16
|
-
time: number;
|
|
17
|
-
rpm: number;
|
|
18
|
-
raw?: string;
|
|
19
|
-
};
|
|
20
|
-
declare type CrankData = {
|
|
21
|
-
revolutions?: number;
|
|
22
|
-
time?: number;
|
|
23
|
-
cntUpdateMissing?: number;
|
|
24
|
-
};
|
|
25
|
-
export default class BleEliteDevice extends BleDevice {
|
|
26
|
-
static services: string[];
|
|
27
|
-
static characteristics: string[];
|
|
28
|
-
static detectionPriority: number;
|
|
29
|
-
instantaneousPower: number;
|
|
30
|
-
balance: number;
|
|
31
|
-
accTorque: number;
|
|
32
|
-
rpm: number;
|
|
33
|
-
timeOffset: number;
|
|
34
|
-
time: number;
|
|
35
|
-
currentCrankData: CrankData;
|
|
36
|
-
prevCrankData: CrankData;
|
|
37
|
-
constructor(props?: any);
|
|
38
|
-
isMatching(characteristics: string[]): boolean;
|
|
39
|
-
init(): Promise<boolean>;
|
|
40
|
-
getProfile(): string;
|
|
41
|
-
getServiceUUids(): string[];
|
|
42
|
-
parseCrankData(crankData: any): {
|
|
43
|
-
rpm: number;
|
|
44
|
-
time: any;
|
|
45
|
-
};
|
|
46
|
-
parsePower(_data: Uint8Array): PowerData;
|
|
47
|
-
onData(characteristic: string, data: Buffer): boolean;
|
|
48
|
-
reset(): void;
|
|
49
|
-
}
|
|
50
|
-
export declare class EliteAdapter extends DeviceAdapter {
|
|
51
|
-
device: BleEliteDevice;
|
|
52
|
-
ignore: boolean;
|
|
53
|
-
ble: BleInterface;
|
|
54
|
-
protocol: DeviceProtocol;
|
|
55
|
-
paused: boolean;
|
|
56
|
-
logger: EventLogger;
|
|
57
|
-
mode: CyclingMode;
|
|
58
|
-
distanceInternal: number;
|
|
59
|
-
prevDataTS: number;
|
|
60
|
-
userSettings: {
|
|
61
|
-
weight?: number;
|
|
62
|
-
};
|
|
63
|
-
bikeSettings: {
|
|
64
|
-
weight?: number;
|
|
65
|
-
};
|
|
66
|
-
constructor(device: BleDeviceClass, protocol: BleProtocol);
|
|
67
|
-
isBike(): boolean;
|
|
68
|
-
isHrm(): boolean;
|
|
69
|
-
isPower(): boolean;
|
|
70
|
-
isSame(device: DeviceAdapter): boolean;
|
|
71
|
-
getProfile(): string;
|
|
72
|
-
getName(): string;
|
|
73
|
-
getDisplayName(): string;
|
|
74
|
-
getCyclingMode(): CyclingMode;
|
|
75
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
76
|
-
getSupportedCyclingModes(): any[];
|
|
77
|
-
getPort(): string;
|
|
78
|
-
getWeight(): number;
|
|
79
|
-
setIgnoreBike(ignore: any): void;
|
|
80
|
-
setIgnorePower(ignore: any): void;
|
|
81
|
-
onDeviceData(deviceData: PowerData): void;
|
|
82
|
-
mapData(deviceData: PowerData): IncyclistBikeData;
|
|
83
|
-
transformData(bikeData: IncyclistBikeData): DeviceData;
|
|
84
|
-
start(props?: any): Promise<any>;
|
|
85
|
-
stop(): Promise<boolean>;
|
|
86
|
-
sendUpdate(request: any): Promise<void>;
|
|
87
|
-
pause(): Promise<boolean>;
|
|
88
|
-
resume(): Promise<boolean>;
|
|
89
|
-
}
|
|
90
|
-
export {};
|
package/lib/ble/elite.js
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.EliteAdapter = exports.ELITE_TRAINER_SVC = void 0;
|
|
35
|
-
const ble_device_1 = require("./ble-device");
|
|
36
|
-
const ble_interface_1 = __importDefault(require("./ble-interface"));
|
|
37
|
-
const ble_1 = require("./ble");
|
|
38
|
-
const device_1 = __importStar(require("../device"));
|
|
39
|
-
const gd_eventlog_1 = require("gd-eventlog");
|
|
40
|
-
const consts_1 = require("./consts");
|
|
41
|
-
const power_meter_1 = __importDefault(require("../modes/power-meter"));
|
|
42
|
-
exports.ELITE_TRAINER_SVC = '347b0001';
|
|
43
|
-
class BleEliteDevice extends ble_device_1.BleDevice {
|
|
44
|
-
constructor(props) {
|
|
45
|
-
super(props);
|
|
46
|
-
this.instantaneousPower = undefined;
|
|
47
|
-
this.balance = undefined;
|
|
48
|
-
this.accTorque = undefined;
|
|
49
|
-
this.rpm = undefined;
|
|
50
|
-
this.timeOffset = 0;
|
|
51
|
-
this.time = undefined;
|
|
52
|
-
this.currentCrankData = undefined;
|
|
53
|
-
this.prevCrankData = undefined;
|
|
54
|
-
}
|
|
55
|
-
isMatching(characteristics) {
|
|
56
|
-
if (!characteristics)
|
|
57
|
-
return false;
|
|
58
|
-
const hasCPMeasurement = characteristics.find(c => c === consts_1.CSP_MEASUREMENT) !== undefined;
|
|
59
|
-
const hasCPFeature = characteristics.find(c => c === consts_1.CSP_FEATURE) !== undefined;
|
|
60
|
-
return hasCPMeasurement && hasCPFeature;
|
|
61
|
-
}
|
|
62
|
-
init() {
|
|
63
|
-
const _super = Object.create(null, {
|
|
64
|
-
init: { get: () => super.init }
|
|
65
|
-
});
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
try {
|
|
68
|
-
yield _super.init.call(this);
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
return Promise.resolve(false);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
getProfile() {
|
|
76
|
-
return 'Power Meter';
|
|
77
|
-
}
|
|
78
|
-
getServiceUUids() {
|
|
79
|
-
return BleEliteDevice.services;
|
|
80
|
-
}
|
|
81
|
-
parseCrankData(crankData) {
|
|
82
|
-
if (!this.prevCrankData)
|
|
83
|
-
this.prevCrankData = { revolutions: 0, time: 0, cntUpdateMissing: -1 };
|
|
84
|
-
const c = this.currentCrankData = crankData;
|
|
85
|
-
const p = this.prevCrankData;
|
|
86
|
-
let rpm = this.rpm;
|
|
87
|
-
let hasUpdate = c.time !== p.time;
|
|
88
|
-
if (hasUpdate) {
|
|
89
|
-
let time = c.time - p.time;
|
|
90
|
-
let revs = c.revolutions - p.revolutions;
|
|
91
|
-
if (c.time < p.time) {
|
|
92
|
-
time += 0x10000;
|
|
93
|
-
this.timeOffset += 0x10000;
|
|
94
|
-
}
|
|
95
|
-
if (c.revolutions < p.revolutions)
|
|
96
|
-
revs += 0x10000;
|
|
97
|
-
rpm = 1024 * 60 * revs / time;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
if (p.cntUpdateMissing < 0 || p.cntUpdateMissing > 2) {
|
|
101
|
-
rpm = 0;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const cntUpdateMissing = p.cntUpdateMissing;
|
|
105
|
-
this.prevCrankData = this.currentCrankData;
|
|
106
|
-
if (hasUpdate)
|
|
107
|
-
this.prevCrankData.cntUpdateMissing = 0;
|
|
108
|
-
else
|
|
109
|
-
this.prevCrankData.cntUpdateMissing = cntUpdateMissing + 1;
|
|
110
|
-
return { rpm, time: this.timeOffset + c.time };
|
|
111
|
-
}
|
|
112
|
-
parsePower(_data) {
|
|
113
|
-
const data = Buffer.from(_data);
|
|
114
|
-
try {
|
|
115
|
-
let offset = 4;
|
|
116
|
-
const flags = data.readUInt16LE(0);
|
|
117
|
-
this.instantaneousPower = data.readUInt16LE(2);
|
|
118
|
-
if (flags & 0x1)
|
|
119
|
-
this.balance = data.readUInt8(offset++);
|
|
120
|
-
if (flags & 0x4) {
|
|
121
|
-
this.accTorque = data.readUInt16LE(offset);
|
|
122
|
-
offset += 2;
|
|
123
|
-
}
|
|
124
|
-
if (flags & 0x10) {
|
|
125
|
-
}
|
|
126
|
-
if (flags & 0x20) {
|
|
127
|
-
const crankData = {
|
|
128
|
-
revolutions: data.readUInt16LE(offset),
|
|
129
|
-
time: data.readUInt16LE(offset + 2)
|
|
130
|
-
};
|
|
131
|
-
const { rpm, time } = this.parseCrankData(crankData);
|
|
132
|
-
this.rpm = rpm;
|
|
133
|
-
this.time = time;
|
|
134
|
-
offset += 4;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
catch (err) {
|
|
138
|
-
}
|
|
139
|
-
const { instantaneousPower, balance, accTorque, rpm, time } = this;
|
|
140
|
-
return { instantaneousPower, balance, accTorque, rpm, time, raw: `2a63:${data.toString('hex')}` };
|
|
141
|
-
}
|
|
142
|
-
onData(characteristic, data) {
|
|
143
|
-
const hasData = super.onData(characteristic, data);
|
|
144
|
-
if (!hasData)
|
|
145
|
-
return false;
|
|
146
|
-
if ((0, ble_1.matches)(characteristic, consts_1.CSP_MEASUREMENT)) {
|
|
147
|
-
const res = this.parsePower(data);
|
|
148
|
-
this.emit('data', res);
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
reset() {
|
|
154
|
-
this.instantaneousPower = undefined;
|
|
155
|
-
this.balance = undefined;
|
|
156
|
-
this.accTorque = undefined;
|
|
157
|
-
this.rpm = undefined;
|
|
158
|
-
this.timeOffset = 0;
|
|
159
|
-
this.time = undefined;
|
|
160
|
-
this.currentCrankData = undefined;
|
|
161
|
-
this.prevCrankData = undefined;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
exports.default = BleEliteDevice;
|
|
165
|
-
BleEliteDevice.services = [exports.ELITE_TRAINER_SVC];
|
|
166
|
-
BleEliteDevice.characteristics = [consts_1.CSP_MEASUREMENT, consts_1.CSP_FEATURE, '2a5d', '2a3c'];
|
|
167
|
-
BleEliteDevice.detectionPriority = 10;
|
|
168
|
-
ble_interface_1.default.register('BleCyclingPowerDevice', 'cp', BleEliteDevice, BleEliteDevice.services);
|
|
169
|
-
class EliteAdapter extends device_1.default {
|
|
170
|
-
constructor(device, protocol) {
|
|
171
|
-
super(protocol);
|
|
172
|
-
this.ignore = false;
|
|
173
|
-
this.paused = false;
|
|
174
|
-
this.distanceInternal = 0;
|
|
175
|
-
this.device = device;
|
|
176
|
-
this.ble = protocol.ble;
|
|
177
|
-
this.mode = this.getDefaultCyclingMode();
|
|
178
|
-
this.logger = new gd_eventlog_1.EventLogger('Ble-Elite');
|
|
179
|
-
}
|
|
180
|
-
isBike() { return true; }
|
|
181
|
-
isHrm() { return false; }
|
|
182
|
-
isPower() { return true; }
|
|
183
|
-
isSame(device) {
|
|
184
|
-
if (!(device instanceof EliteAdapter))
|
|
185
|
-
return false;
|
|
186
|
-
const adapter = device;
|
|
187
|
-
return (adapter.getName() === this.getName() && adapter.getProfile() === this.getProfile());
|
|
188
|
-
}
|
|
189
|
-
getProfile() {
|
|
190
|
-
return 'Elite Smart Trainer';
|
|
191
|
-
}
|
|
192
|
-
getName() {
|
|
193
|
-
return `${this.device.name}`;
|
|
194
|
-
}
|
|
195
|
-
getDisplayName() {
|
|
196
|
-
const { name, instantaneousPower: power } = this.device;
|
|
197
|
-
const powerStr = power ? ` (${power})` : '';
|
|
198
|
-
return `${name}${powerStr}`;
|
|
199
|
-
}
|
|
200
|
-
getCyclingMode() {
|
|
201
|
-
if (!this.mode)
|
|
202
|
-
this.mode = this.getDefaultCyclingMode();
|
|
203
|
-
return this.mode;
|
|
204
|
-
}
|
|
205
|
-
getDefaultCyclingMode() {
|
|
206
|
-
return new power_meter_1.default(this);
|
|
207
|
-
}
|
|
208
|
-
getSupportedCyclingModes() {
|
|
209
|
-
return [power_meter_1.default];
|
|
210
|
-
}
|
|
211
|
-
getPort() {
|
|
212
|
-
return 'ble';
|
|
213
|
-
}
|
|
214
|
-
getWeight() {
|
|
215
|
-
let userWeight = device_1.DEFAULT_USER_WEIGHT;
|
|
216
|
-
let bikeWeight = device_1.DEFAULT_BIKE_WEIGHT;
|
|
217
|
-
if (this.userSettings && this.userSettings.weight) {
|
|
218
|
-
userWeight = Number(this.userSettings.weight);
|
|
219
|
-
}
|
|
220
|
-
if (this.bikeSettings && this.bikeSettings.weight) {
|
|
221
|
-
bikeWeight = Number(this.bikeSettings.weight);
|
|
222
|
-
}
|
|
223
|
-
return bikeWeight + userWeight;
|
|
224
|
-
}
|
|
225
|
-
setIgnoreBike(ignore) {
|
|
226
|
-
this.ignore = ignore;
|
|
227
|
-
}
|
|
228
|
-
setIgnorePower(ignore) {
|
|
229
|
-
this.ignore = ignore;
|
|
230
|
-
}
|
|
231
|
-
onDeviceData(deviceData) {
|
|
232
|
-
if (this.prevDataTS && Date.now() - this.prevDataTS < 1000)
|
|
233
|
-
return;
|
|
234
|
-
this.prevDataTS = Date.now();
|
|
235
|
-
this.logger.logEvent({ message: 'onDeviceData', data: deviceData });
|
|
236
|
-
let incyclistData = this.mapData(deviceData);
|
|
237
|
-
incyclistData = this.getCyclingMode().updateData(incyclistData);
|
|
238
|
-
const data = this.transformData(incyclistData);
|
|
239
|
-
if (this.onDataFn && !this.ignore && !this.paused)
|
|
240
|
-
this.onDataFn(data);
|
|
241
|
-
}
|
|
242
|
-
mapData(deviceData) {
|
|
243
|
-
const data = {
|
|
244
|
-
isPedalling: false,
|
|
245
|
-
power: 0,
|
|
246
|
-
pedalRpm: undefined,
|
|
247
|
-
speed: 0,
|
|
248
|
-
heartrate: 0,
|
|
249
|
-
distanceInternal: 0,
|
|
250
|
-
slope: undefined,
|
|
251
|
-
time: undefined
|
|
252
|
-
};
|
|
253
|
-
data.power = (deviceData.instantaneousPower !== undefined ? deviceData.instantaneousPower : data.power);
|
|
254
|
-
data.pedalRpm = (deviceData.rpm !== undefined ? deviceData.rpm : data.pedalRpm);
|
|
255
|
-
data.time = (deviceData.time !== undefined ? deviceData.time : data.time);
|
|
256
|
-
data.isPedalling = data.pedalRpm > 0 || (data.pedalRpm === undefined && data.power > 0);
|
|
257
|
-
return data;
|
|
258
|
-
}
|
|
259
|
-
transformData(bikeData) {
|
|
260
|
-
if (this.ignore) {
|
|
261
|
-
return {};
|
|
262
|
-
}
|
|
263
|
-
if (bikeData === undefined)
|
|
264
|
-
return;
|
|
265
|
-
let distance = 0;
|
|
266
|
-
if (this.distanceInternal !== undefined && bikeData.distanceInternal !== undefined) {
|
|
267
|
-
distance = Math.round(bikeData.distanceInternal - this.distanceInternal);
|
|
268
|
-
}
|
|
269
|
-
if (bikeData.distanceInternal !== undefined)
|
|
270
|
-
this.distanceInternal = bikeData.distanceInternal;
|
|
271
|
-
let data = {
|
|
272
|
-
speed: bikeData.speed,
|
|
273
|
-
slope: bikeData.slope,
|
|
274
|
-
power: bikeData.power !== undefined ? Math.round(bikeData.power) : undefined,
|
|
275
|
-
cadence: bikeData.pedalRpm !== undefined ? Math.round(bikeData.pedalRpm) : undefined,
|
|
276
|
-
distance,
|
|
277
|
-
timestamp: Date.now()
|
|
278
|
-
};
|
|
279
|
-
return data;
|
|
280
|
-
}
|
|
281
|
-
start(props) {
|
|
282
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
-
if (props && props.user)
|
|
284
|
-
this.userSettings = props.user;
|
|
285
|
-
if (props && props.bikeSettings)
|
|
286
|
-
this.bikeSettings = props.bikeSettings;
|
|
287
|
-
this.logger.logEvent({ message: 'csp: start requested', profile: this.getProfile(), props });
|
|
288
|
-
try {
|
|
289
|
-
const bleDevice = yield this.ble.connectDevice(this.device);
|
|
290
|
-
if (bleDevice) {
|
|
291
|
-
this.device = bleDevice;
|
|
292
|
-
bleDevice.on('data', (data) => {
|
|
293
|
-
this.onDeviceData(data);
|
|
294
|
-
});
|
|
295
|
-
return true;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
catch (err) {
|
|
299
|
-
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
300
|
-
throw new Error(`could not start device, reason:${err.message}`);
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
stop() {
|
|
305
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
-
this.logger.logEvent({ message: 'stop requested', profile: this.getProfile() });
|
|
307
|
-
this.distanceInternal = 0;
|
|
308
|
-
this.device.reset();
|
|
309
|
-
return this.device.disconnect();
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
sendUpdate(request) {
|
|
313
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
314
|
-
if (this.paused)
|
|
315
|
-
return;
|
|
316
|
-
this.getCyclingMode().sendBikeUpdate(request);
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
pause() { this.paused = true; return Promise.resolve(true); }
|
|
320
|
-
resume() { this.paused = false; return Promise.resolve(true); }
|
|
321
|
-
}
|
|
322
|
-
exports.EliteAdapter = EliteAdapter;
|