incyclist-devices 2.1.0 → 2.1.1
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/lib/adapters.d.ts +1 -1
- package/lib/antv2/adapter-factory.d.ts +4 -15
- package/lib/antv2/adapter.d.ts +15 -15
- package/lib/antv2/adapter.js +67 -21
- package/lib/antv2/ant-interface.d.ts +3 -11
- package/lib/antv2/ant-interface.js +1 -1
- package/lib/antv2/base/adapter.d.ts +62 -0
- package/lib/antv2/base/adapter.js +360 -0
- package/lib/antv2/base/ant-interface.d.ts +35 -0
- package/lib/antv2/base/ant-interface.js +285 -0
- package/lib/antv2/base/binding.d.ts +13 -0
- package/lib/antv2/base/binding.js +27 -0
- package/lib/antv2/cad/adapter.d.ts +10 -0
- package/lib/antv2/cad/adapter.js +25 -0
- package/lib/antv2/cad/index.d.ts +2 -0
- package/lib/antv2/cad/index.js +7 -0
- package/lib/antv2/consts.d.ts +2 -0
- package/lib/antv2/consts.js +5 -0
- package/lib/antv2/factories/adapter-factory.d.ts +14 -0
- package/lib/antv2/factories/adapter-factory.js +65 -0
- package/lib/antv2/factories/sensor-factory.d.ts +5 -0
- package/lib/antv2/factories/sensor-factory.js +22 -0
- package/lib/antv2/fe/adapter.d.ts +24 -29
- package/lib/antv2/fe/adapter.js +208 -225
- package/lib/antv2/hr/adapter.d.ts +6 -15
- package/lib/antv2/hr/adapter.js +7 -55
- package/lib/antv2/hr copy/adapter.d.ts +11 -0
- package/lib/antv2/hr copy/adapter.js +30 -0
- package/lib/antv2/hr copy/index.d.ts +2 -0
- package/lib/antv2/hr copy/index.js +7 -0
- package/lib/antv2/index.d.ts +5 -4
- package/lib/antv2/index.js +4 -2
- package/lib/antv2/pwr/adapter.d.ts +9 -33
- package/lib/antv2/pwr/adapter.js +19 -140
- package/lib/antv2/types.d.ts +23 -4
- package/lib/base/adpater.d.ts +39 -60
- package/lib/base/adpater.js +139 -161
- package/lib/base/consts.d.ts +4 -0
- package/lib/base/consts.js +9 -0
- package/lib/ble/adapter-factory.d.ts +10 -11
- package/lib/ble/base/adapter.d.ts +7 -14
- package/lib/ble/base/adapter.js +2 -36
- package/lib/ble/ble-interface.d.ts +5 -7
- package/lib/ble/cp/adapter.d.ts +6 -8
- package/lib/ble/cp/adapter.js +8 -27
- package/lib/ble/elite/adapter.d.ts +7 -8
- package/lib/ble/elite/adapter.js +5 -25
- package/lib/ble/fm/adapter.d.ts +6 -7
- package/lib/ble/fm/adapter.js +13 -34
- package/lib/ble/hr/adapter.d.ts +5 -8
- package/lib/ble/hr/adapter.js +2 -2
- package/lib/ble/peripheral-cache.d.ts +2 -3
- package/lib/ble/tacx/adapter.d.ts +2 -3
- package/lib/ble/tacx/adapter.js +8 -8
- package/lib/ble/types.d.ts +1 -2
- package/lib/ble/wahoo/adapter.d.ts +2 -2
- package/lib/ble/wahoo/adapter.js +6 -6
- package/lib/ble/wahoo/comms.js +16 -16
- package/lib/factories/adapters.d.ts +7 -0
- package/lib/factories/adapters.js +49 -0
- package/lib/factories/index.d.ts +3 -0
- package/lib/factories/index.js +10 -0
- package/lib/factories/interfaces.d.ts +7 -0
- package/lib/factories/interfaces.js +27 -0
- package/lib/index.d.ts +5 -6
- package/lib/index.js +4 -9
- package/lib/interfaces.d.ts +1 -1
- package/lib/modes/ant-fe-adv-st-mode.d.ts +1 -1
- package/lib/modes/antble-erg.d.ts +1 -1
- package/lib/modes/antble-smarttrainer.d.ts +2 -2
- package/lib/modes/base.d.ts +5 -5
- package/lib/modes/daum-classic-standard.d.ts +3 -2
- package/lib/modes/daum-erg.d.ts +3 -3
- package/lib/modes/daum-premium-standard.d.ts +3 -2
- package/lib/modes/daum-smarttrainer.d.ts +3 -2
- package/lib/modes/kettler-erg.d.ts +3 -3
- package/lib/modes/power-base.d.ts +3 -3
- package/lib/modes/power-base.js +2 -2
- package/lib/modes/power-meter.d.ts +3 -2
- package/lib/modes/simulator.d.ts +2 -1
- package/lib/modes/types.d.ts +2 -13
- package/lib/serial/SinglePathScanner.d.ts +17 -0
- package/lib/serial/SinglePathScanner.js +87 -0
- package/lib/serial/adapter-factory.d.ts +6 -6
- package/lib/serial/adapter.d.ts +6 -11
- package/lib/serial/base/adapter.d.ts +17 -0
- package/lib/serial/base/adapter.js +67 -0
- package/lib/serial/base/comms.d.ts +62 -0
- package/lib/serial/base/comms.js +280 -0
- package/lib/serial/base/serial-interface.d.ts +36 -0
- package/lib/serial/base/serial-interface.js +288 -0
- package/lib/serial/base/serial-scanner.d.ts +16 -0
- package/lib/serial/base/serial-scanner.js +87 -0
- package/lib/serial/base/serialport.d.ts +17 -0
- package/lib/serial/base/serialport.js +87 -0
- package/lib/serial/comms.d.ts +2 -2
- package/lib/serial/daum/DaumAdapter.d.ts +12 -24
- package/lib/serial/daum/DaumAdapter.js +40 -59
- package/lib/serial/daum/classic/PROTOCOL_NAME.d.ts +2 -0
- package/lib/serial/daum/classic/PROTOCOL_NAME.js +5 -0
- package/lib/serial/daum/classic/adapter.d.ts +8 -20
- package/lib/serial/daum/classic/adapter.js +28 -58
- package/lib/serial/daum/classic/comms.d.ts +4 -6
- package/lib/serial/daum/classic/comms.js +2 -2
- package/lib/serial/daum/classic/consts.d.ts +2 -0
- package/lib/serial/daum/classic/consts.js +5 -0
- package/lib/serial/daum/classic/mock.js +4 -3
- package/lib/serial/daum/classic/types.d.ts +8 -10
- package/lib/serial/daum/classic/utils.d.ts +1 -2
- package/lib/serial/daum/consts.d.ts +0 -19
- package/lib/serial/daum/consts.js +0 -22
- package/lib/serial/daum/premium/adapter.d.ts +8 -11
- package/lib/serial/daum/premium/adapter.js +27 -53
- package/lib/serial/daum/premium/comms.d.ts +4 -7
- package/lib/serial/daum/premium/comms.js +23 -22
- package/lib/serial/daum/premium/mock.d.ts +1 -1
- package/lib/serial/daum/premium/mock.js +2 -2
- package/lib/serial/daum/premium/types.d.ts +32 -17
- package/lib/serial/daum/premium/types.js +8 -8
- package/lib/serial/daum/premium/utils.d.ts +2 -3
- package/lib/serial/daum/premium/utils.js +3 -3
- package/lib/serial/daum/types.d.ts +4 -1
- package/lib/serial/daum/types.js +9 -1
- package/lib/serial/factories/adapter-factory.d.ts +14 -0
- package/lib/serial/factories/adapter-factory.js +30 -0
- package/lib/serial/index.d.ts +8 -5
- package/lib/serial/index.js +15 -15
- package/lib/serial/kettler/comms.d.ts +1 -1
- package/lib/serial/kettler/ergo-racer/adapter.d.ts +11 -18
- package/lib/serial/kettler/ergo-racer/adapter.js +9 -21
- package/lib/serial/kettler/types.d.ts +8 -0
- package/lib/serial/kettler/types.js +2 -0
- package/lib/serial/serial-interface.d.ts +2 -32
- package/lib/serial/serial-interface.js +3 -76
- package/lib/serial/serial-scanner.d.ts +16 -0
- package/lib/serial/serial-scanner.js +87 -0
- package/lib/serial/serialport.d.ts +1 -13
- package/lib/serial/types.d.ts +45 -0
- package/lib/serial/types.js +9 -0
- package/lib/simulator/Simulator.d.ts +10 -13
- package/lib/simulator/Simulator.js +11 -23
- package/lib/types/Command.d.ts +8 -0
- package/lib/types/Command.js +2 -0
- package/lib/types/adapter.d.ts +22 -33
- package/lib/types/adapter.js +0 -68
- package/lib/types/command.d.ts +0 -8
- package/lib/types/command.js +0 -2
- package/lib/types/data.d.ts +12 -1
- package/lib/types/device.d.ts +8 -23
- package/lib/types/device.js +9 -8
- package/lib/types/index.d.ts +6 -0
- package/lib/types/index.js +22 -0
- package/lib/types/route.d.ts +0 -19
- package/lib/types/route.js +0 -2
- package/lib/types/types.d.ts +8 -0
- package/lib/types/types.js +2 -0
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/utils.js +22 -4
- package/package.json +1 -1
package/lib/adapters.d.ts
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import { Profile } from "incyclist-ant-plus";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { Controllable } from "../types/adapter";
|
|
6
|
-
import { DeviceProperties } from "../types/device";
|
|
7
|
-
export type AntAdapterInfo = {
|
|
8
|
-
antProfile: Profile;
|
|
9
|
-
incyclistProfile: LegacyProfile;
|
|
10
|
-
Adapter: typeof AntAdapter<Controllable<DeviceProperties>, BaseDeviceData, DeviceData>;
|
|
11
|
-
};
|
|
12
|
-
export type AdapterQuery = {
|
|
13
|
-
antProfile?: Profile;
|
|
14
|
-
incyclistProfile?: LegacyProfile;
|
|
15
|
-
};
|
|
2
|
+
import AntAdapter from "./base/adapter";
|
|
3
|
+
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile, BaseDeviceData } from "./types";
|
|
4
|
+
import { AntAdapterInfo, AdapterQuery } from "./types";
|
|
16
5
|
export default class AntAdapterFactory {
|
|
17
6
|
static _instance: AntAdapterFactory;
|
|
18
7
|
adapters: AntAdapterInfo[];
|
|
19
8
|
static getInstance(): AntAdapterFactory;
|
|
20
9
|
constructor();
|
|
21
|
-
register<TDeviceData extends BaseDeviceData
|
|
10
|
+
register<TDeviceData extends BaseDeviceData>(antProfile: Profile, incyclistProfile: LegacyProfile, Adapter: typeof AntAdapter<TDeviceData>): void;
|
|
22
11
|
getAdapter(query?: AdapterQuery): any;
|
|
23
12
|
createInstance(settings: AntDeviceSettings, props?: AntDeviceProperties): any;
|
|
24
13
|
createFromDetected(profile: Profile, deviceID: number, props?: AntDeviceProperties): any;
|
package/lib/antv2/adapter.d.ts
CHANGED
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
import { IChannel, ISensor, Profile } from 'incyclist-ant-plus';
|
|
3
3
|
import AntInterface from './ant-interface';
|
|
4
4
|
import IncyclistDevice from '../base/adpater';
|
|
5
|
-
import { AntDeviceProperties, AntDeviceSettings } from './types';
|
|
6
|
-
import {
|
|
7
|
-
export
|
|
8
|
-
export type BaseDeviceData = {
|
|
9
|
-
DeviceID: number;
|
|
10
|
-
ManId?: number;
|
|
11
|
-
};
|
|
12
|
-
export default class AntAdapter<DC extends Controllable<AntDeviceProperties>, TDeviceData extends BaseDeviceData, TData> extends IncyclistDevice<DC, AntDeviceProperties> {
|
|
5
|
+
import { AntDeviceProperties, AntDeviceSettings, BaseDeviceData } from './types';
|
|
6
|
+
import { IAdapter, IncyclistAdapterData, IncyclistBikeData } from '../types';
|
|
7
|
+
export default class AntAdapter<TDeviceData extends BaseDeviceData> extends IncyclistDevice<AntDeviceProperties> {
|
|
13
8
|
sensor: ISensor;
|
|
14
|
-
|
|
15
|
-
data: TData;
|
|
9
|
+
data: IncyclistAdapterData;
|
|
16
10
|
deviceData: TDeviceData;
|
|
17
11
|
updateFrequency: number;
|
|
18
12
|
channel: IChannel;
|
|
@@ -23,32 +17,38 @@ export default class AntAdapter<DC extends Controllable<AntDeviceProperties>, TD
|
|
|
23
17
|
bikeSettings: {
|
|
24
18
|
weight?: number;
|
|
25
19
|
};
|
|
26
|
-
onDataFn: (data:
|
|
20
|
+
onDataFn: (data: IncyclistAdapterData) => void;
|
|
27
21
|
startupRetryPause: number;
|
|
28
22
|
protected ivDataTimeout: NodeJS.Timeout;
|
|
29
23
|
protected lastDataTS: number;
|
|
30
24
|
protected dataMsgCount: number;
|
|
31
25
|
protected ivWaitForData: NodeJS.Timeout;
|
|
32
26
|
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
33
|
-
logEvent(event: any): void;
|
|
34
27
|
createSensor(settings: AntDeviceSettings): ISensor;
|
|
35
28
|
isEqual(settings: AntDeviceSettings): boolean;
|
|
36
29
|
connect(): Promise<boolean>;
|
|
37
30
|
close(): Promise<boolean>;
|
|
38
31
|
resetData(): void;
|
|
39
|
-
isSame(device:
|
|
32
|
+
isSame(device: IAdapter): boolean;
|
|
40
33
|
hasData(): boolean;
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
mapData(deviceData: TDeviceData): IncyclistBikeData;
|
|
35
|
+
transformData(data: IncyclistBikeData): void;
|
|
36
|
+
mapToAdapterData(deviceData: any): void;
|
|
37
|
+
onDeviceData(deviceData: TDeviceData): void;
|
|
38
|
+
isWaitingForData(): boolean;
|
|
39
|
+
waitForData(timeout: number): Promise<boolean>;
|
|
43
40
|
getID(): string;
|
|
44
41
|
getName(): string;
|
|
45
42
|
getInterface(): string;
|
|
46
43
|
getProfile(): Profile;
|
|
44
|
+
getLogData(data: any, excludeList: any): any;
|
|
45
|
+
triggerTimeoutCheck(): void;
|
|
47
46
|
startDataTimeoutCheck(): void;
|
|
48
47
|
stopDataTimeoutCheck(): void;
|
|
49
48
|
check(): Promise<boolean>;
|
|
50
49
|
checkCapabilities(): Promise<void>;
|
|
51
50
|
initControl(): Promise<void>;
|
|
51
|
+
sendUpdate(request: any): void;
|
|
52
52
|
start(props?: AntDeviceProperties): Promise<boolean>;
|
|
53
53
|
stop(): Promise<boolean>;
|
|
54
54
|
}
|
package/lib/antv2/adapter.js
CHANGED
|
@@ -12,15 +12,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.DEFAULT_UPDATE_FREQUENCY = void 0;
|
|
16
15
|
const ant_interface_1 = __importDefault(require("./ant-interface"));
|
|
17
16
|
const adpater_1 = __importDefault(require("../base/adpater"));
|
|
18
17
|
const types_1 = require("./types");
|
|
18
|
+
const types_2 = require("../types");
|
|
19
19
|
const utils_1 = require("../utils/utils");
|
|
20
|
-
const capabilities_1 = require("../types/capabilities");
|
|
21
20
|
const utils_2 = require("./utils");
|
|
22
|
-
|
|
23
|
-
const NO_DATA_TIMEOUT = 5000;
|
|
21
|
+
const consts_1 = require("./consts");
|
|
24
22
|
const INTERFACE_NAME = 'ant';
|
|
25
23
|
class AntAdapter extends adpater_1.default {
|
|
26
24
|
constructor(settings, props) {
|
|
@@ -35,20 +33,10 @@ class AntAdapter extends adpater_1.default {
|
|
|
35
33
|
this.deviceData = {};
|
|
36
34
|
this.data = {};
|
|
37
35
|
this.dataMsgCount = 0;
|
|
38
|
-
this.updateFrequency =
|
|
36
|
+
this.updateFrequency = consts_1.DEFAULT_UPDATE_FREQUENCY;
|
|
39
37
|
this.channel = undefined;
|
|
40
38
|
this.ant = ant_interface_1.default.getInstance();
|
|
41
39
|
}
|
|
42
|
-
logEvent(event) {
|
|
43
|
-
if (!this.logger || this.paused)
|
|
44
|
-
return;
|
|
45
|
-
this.logger.logEvent(event);
|
|
46
|
-
const w = global.window;
|
|
47
|
-
if ((w === null || w === void 0 ? void 0 : w.DEVICE_DEBUG) || process.env.BLE_DEBUG || process.env.ANT_DEBUG) {
|
|
48
|
-
const logText = '~~~ ANT:' + this.logger.getName();
|
|
49
|
-
console.log(logText, event);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
40
|
createSensor(settings) {
|
|
53
41
|
throw new Error('Method not implemented.');
|
|
54
42
|
}
|
|
@@ -86,13 +74,49 @@ class AntAdapter extends adpater_1.default {
|
|
|
86
74
|
hasData() {
|
|
87
75
|
return this.dataMsgCount > 0;
|
|
88
76
|
}
|
|
77
|
+
mapData(deviceData) {
|
|
78
|
+
throw new Error('message not implemented');
|
|
79
|
+
}
|
|
80
|
+
transformData(data) {
|
|
81
|
+
throw new Error('message not implemented');
|
|
82
|
+
}
|
|
83
|
+
mapToAdapterData(deviceData) {
|
|
84
|
+
throw new Error('message not implemented');
|
|
85
|
+
}
|
|
89
86
|
onDeviceData(deviceData) {
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
this.dataMsgCount++;
|
|
88
|
+
this.lastDataTS = Date.now();
|
|
89
|
+
try {
|
|
90
|
+
const { ManId } = this.deviceData;
|
|
91
|
+
this.deviceData = Object.assign({}, deviceData);
|
|
92
|
+
if (!ManId && deviceData.ManId) {
|
|
93
|
+
this.emit('device-info', { device: this.getSettings(), manufacturer: (0, utils_2.getBrand)(deviceData.ManId) });
|
|
94
|
+
}
|
|
95
|
+
if (!this.started || this.isStopped())
|
|
96
|
+
return;
|
|
97
|
+
this.triggerTimeoutCheck();
|
|
98
|
+
if (!this.canEmitData())
|
|
99
|
+
return;
|
|
100
|
+
const logData = this.getLogData(deviceData, ['PairedDevices', 'RawData']);
|
|
101
|
+
this.logEvent({ message: 'onDeviceData', data: logData, paused: this.paused });
|
|
102
|
+
if (this.isControllable()) {
|
|
103
|
+
let incyclistData = this.mapData(deviceData);
|
|
104
|
+
incyclistData = this.getCyclingMode().updateData(incyclistData);
|
|
105
|
+
this.transformData(incyclistData);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.mapToAdapterData(deviceData);
|
|
109
|
+
}
|
|
110
|
+
this.emitData(this.data);
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
console.log('~~~ERROR', err);
|
|
114
|
+
this.logEvent({ message: 'error', fn: 'onDeviceData()', error: err.message || err, stack: err.stack });
|
|
94
115
|
}
|
|
95
116
|
}
|
|
117
|
+
isWaitingForData() {
|
|
118
|
+
return this.ivWaitForData !== undefined && this.ivWaitForData !== null;
|
|
119
|
+
}
|
|
96
120
|
waitForData(timeout) {
|
|
97
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
122
|
const startTs = Date.now();
|
|
@@ -138,13 +162,25 @@ class AntAdapter extends adpater_1.default {
|
|
|
138
162
|
return (0, utils_2.mapLegacyProfile)(settings.profile);
|
|
139
163
|
}
|
|
140
164
|
}
|
|
165
|
+
getLogData(data, excludeList) {
|
|
166
|
+
const logData = JSON.parse(JSON.stringify(data));
|
|
167
|
+
excludeList.forEach((key) => {
|
|
168
|
+
delete logData[key];
|
|
169
|
+
});
|
|
170
|
+
return logData;
|
|
171
|
+
}
|
|
172
|
+
triggerTimeoutCheck() {
|
|
173
|
+
if (!this.ivDataTimeout && this.dataMsgCount > 0) {
|
|
174
|
+
this.startDataTimeoutCheck();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
141
177
|
startDataTimeoutCheck() {
|
|
142
178
|
if (this.ivDataTimeout)
|
|
143
179
|
return;
|
|
144
180
|
this.ivDataTimeout = setInterval(() => {
|
|
145
181
|
if (!this.lastDataTS)
|
|
146
182
|
return;
|
|
147
|
-
if (this.lastDataTS + NO_DATA_TIMEOUT < Date.now()) {
|
|
183
|
+
if (this.lastDataTS + consts_1.NO_DATA_TIMEOUT < Date.now()) {
|
|
148
184
|
this.emit('disconnected', Date.now() - this.lastDataTS);
|
|
149
185
|
}
|
|
150
186
|
}, 1000);
|
|
@@ -177,6 +213,16 @@ class AntAdapter extends adpater_1.default {
|
|
|
177
213
|
return;
|
|
178
214
|
});
|
|
179
215
|
}
|
|
216
|
+
sendUpdate(request) {
|
|
217
|
+
if (!this.isControllable())
|
|
218
|
+
return;
|
|
219
|
+
if (this.isPaused() || this.isStopped())
|
|
220
|
+
return;
|
|
221
|
+
if (!this.hasCapability(types_2.IncyclistCapability.Control))
|
|
222
|
+
this.getCyclingMode().sendBikeUpdate(request);
|
|
223
|
+
else
|
|
224
|
+
throw new Error('method not implemented');
|
|
225
|
+
}
|
|
180
226
|
start(props = {}) {
|
|
181
227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
228
|
if (this.started && !this.stopped) {
|
|
@@ -212,7 +258,7 @@ class AntAdapter extends adpater_1.default {
|
|
|
212
258
|
try {
|
|
213
259
|
yield this.waitForData(startupTimeout - 100);
|
|
214
260
|
yield this.checkCapabilities();
|
|
215
|
-
if (this.hasCapability(
|
|
261
|
+
if (this.hasCapability(types_2.IncyclistCapability.Control))
|
|
216
262
|
yield this.initControl();
|
|
217
263
|
this.started = true;
|
|
218
264
|
if (to)
|
|
@@ -2,17 +2,9 @@
|
|
|
2
2
|
import EventEmitter from "events";
|
|
3
3
|
import { EventLogger } from "gd-eventlog";
|
|
4
4
|
import { IAntDevice, IChannel, ISensor } from "incyclist-ant-plus";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { AntDeviceSettings, AntScanProps } from "./types";
|
|
9
|
-
export interface AntInterfaceProps extends InterfaceProps {
|
|
10
|
-
startupTimeout?: number;
|
|
11
|
-
}
|
|
12
|
-
export interface ConnectState {
|
|
13
|
-
connected: boolean;
|
|
14
|
-
connecting: boolean;
|
|
15
|
-
}
|
|
5
|
+
import { AntDeviceSettings, AntScanProps, AntInterfaceProps, ConnectState } from "./types";
|
|
6
|
+
import { IncyclistInterface } from "../types";
|
|
7
|
+
import AntDeviceBinding from "./base/binding";
|
|
16
8
|
export default class AntInterface extends EventEmitter implements IncyclistInterface {
|
|
17
9
|
static _instance: AntInterface;
|
|
18
10
|
static INTERFACE_NAME: string;
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const events_1 = __importDefault(require("events"));
|
|
16
16
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
17
|
-
const sensor_factory_1 = __importDefault(require("./sensor-factory"));
|
|
17
|
+
const sensor_factory_1 = __importDefault(require("./factories/sensor-factory"));
|
|
18
18
|
class AntInterface extends events_1.default {
|
|
19
19
|
static getInstance(props = {}) {
|
|
20
20
|
if (AntInterface._instance === undefined)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IChannel, ISensor, Profile } from 'incyclist-ant-plus';
|
|
3
|
+
import AntInterface from './ant-interface';
|
|
4
|
+
import IncyclistDevice from '../../base/adpater';
|
|
5
|
+
import { AntDeviceProperties, AntDeviceSettings, LegacyProfile, BaseDeviceData } from '../types';
|
|
6
|
+
import { IAdapter, IncyclistAdapterData, IncyclistBikeData } from '../../types';
|
|
7
|
+
export default class AntAdapter<TDeviceData extends BaseDeviceData> extends IncyclistDevice<AntDeviceProperties> {
|
|
8
|
+
sensor: ISensor;
|
|
9
|
+
data: IncyclistAdapterData;
|
|
10
|
+
deviceData: TDeviceData;
|
|
11
|
+
updateFrequency: number;
|
|
12
|
+
channel: IChannel;
|
|
13
|
+
ant: AntInterface;
|
|
14
|
+
userSettings: {
|
|
15
|
+
weight?: number;
|
|
16
|
+
};
|
|
17
|
+
bikeSettings: {
|
|
18
|
+
weight?: number;
|
|
19
|
+
};
|
|
20
|
+
onDataFn: (data: IncyclistAdapterData) => void;
|
|
21
|
+
startupRetryPause: number;
|
|
22
|
+
protected ivDataTimeout: NodeJS.Timeout;
|
|
23
|
+
protected lastDataTS: number;
|
|
24
|
+
protected dataMsgCount: number;
|
|
25
|
+
protected ivWaitForData: NodeJS.Timeout;
|
|
26
|
+
protected promiseWaitForData: Promise<boolean>;
|
|
27
|
+
constructor(settings: AntDeviceSettings, props?: AntDeviceProperties);
|
|
28
|
+
getProfileName(): Profile;
|
|
29
|
+
getLegacyProfileName(): LegacyProfile;
|
|
30
|
+
createSensor(settings: AntDeviceSettings): ISensor;
|
|
31
|
+
isEqual(settings: AntDeviceSettings): boolean;
|
|
32
|
+
connect(): Promise<boolean>;
|
|
33
|
+
close(): Promise<boolean>;
|
|
34
|
+
resetData(): void;
|
|
35
|
+
isSame(device: IAdapter): boolean;
|
|
36
|
+
hasData(): boolean;
|
|
37
|
+
mapData(deviceData: TDeviceData): IncyclistBikeData;
|
|
38
|
+
transformData(data: IncyclistBikeData, deviceData: TDeviceData): void;
|
|
39
|
+
mapToAdapterData(deviceData: any): void;
|
|
40
|
+
onDeviceData(deviceData: TDeviceData): void;
|
|
41
|
+
isWaitingForData(): boolean;
|
|
42
|
+
_wait(): Promise<boolean>;
|
|
43
|
+
waitForData(timeout: number): Promise<boolean>;
|
|
44
|
+
getID(): string;
|
|
45
|
+
getName(): string;
|
|
46
|
+
getUniqueName(): string;
|
|
47
|
+
getDisplayName(): string;
|
|
48
|
+
getInterface(): string;
|
|
49
|
+
getProfile(): Profile;
|
|
50
|
+
getLogData(data: any, excludeList: any): any;
|
|
51
|
+
triggerTimeoutCheck(): void;
|
|
52
|
+
startDataTimeoutCheck(): void;
|
|
53
|
+
stopDataTimeoutCheck(): void;
|
|
54
|
+
check(): Promise<boolean>;
|
|
55
|
+
checkCapabilities(): Promise<void>;
|
|
56
|
+
initControl(): Promise<void>;
|
|
57
|
+
getDefaultStartupTimeout(): number;
|
|
58
|
+
sendUpdate(request: any): void;
|
|
59
|
+
start(props?: AntDeviceProperties): Promise<boolean>;
|
|
60
|
+
stop(): Promise<boolean>;
|
|
61
|
+
startSensor(): Promise<boolean>;
|
|
62
|
+
}
|