incyclist-devices 1.5.10 → 1.5.12
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/LICENSE +0 -0
- package/lib/DeviceSupport.d.ts +36 -36
- package/lib/DeviceSupport.js +82 -82
- package/lib/ant/AntAdapter.d.ts +50 -50
- package/lib/ant/AntAdapter.js +109 -109
- package/lib/ant/AntScanner.d.ts +60 -60
- package/lib/ant/AntScanner.js +651 -651
- package/lib/ant/antfe/AntFEAdapter.d.ts +83 -83
- package/lib/ant/antfe/AntFEAdapter.js +652 -652
- package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +9 -9
- package/lib/ant/antfe/ant-fe-adv-st-mode.js +51 -51
- package/lib/ant/antfe/ant-fe-erg-mode.d.ts +6 -6
- package/lib/ant/antfe/ant-fe-erg-mode.js +14 -14
- package/lib/ant/antfe/ant-fe-st-mode.d.ts +5 -5
- package/lib/ant/antfe/ant-fe-st-mode.js +13 -13
- package/lib/ant/anthrm/AntHrmAdapter.d.ts +16 -16
- package/lib/ant/anthrm/AntHrmAdapter.js +130 -130
- package/lib/ant/antpwr/pwr-adapter.d.ts +49 -49
- package/lib/ant/antpwr/pwr-adapter.js +251 -251
- package/lib/ant/utils.d.ts +1 -1
- package/lib/ant/utils.js +23 -23
- package/lib/antv2/AntAdapter.d.ts +48 -0
- package/lib/antv2/AntAdapter.js +104 -0
- package/lib/antv2/adapter-factory.d.ts +11 -11
- package/lib/antv2/adapter-factory.js +40 -40
- package/lib/antv2/ant-binding.d.ts +13 -13
- package/lib/antv2/ant-binding.js +27 -27
- package/lib/antv2/ant-device.d.ts +51 -51
- package/lib/antv2/ant-device.js +115 -115
- package/lib/antv2/ant-interface.d.ts +37 -37
- package/lib/antv2/ant-interface.js +255 -255
- package/lib/antv2/fe.d.ts +29 -29
- package/lib/antv2/fe.js +262 -262
- package/lib/antv2/hr.d.ts +18 -18
- package/lib/antv2/hr.js +93 -93
- package/lib/antv2/incyclist-protocol.d.ts +37 -37
- package/lib/antv2/incyclist-protocol.js +126 -126
- package/lib/antv2/pwr.d.ts +28 -28
- package/lib/antv2/pwr.js +163 -163
- package/lib/antv2/sensor-factory.d.ts +5 -5
- package/lib/antv2/sensor-factory.js +20 -20
- package/lib/ble/ble-device.d.ts +63 -63
- package/lib/ble/ble-device.js +444 -444
- package/lib/ble/ble-erg-mode.d.ts +18 -18
- package/lib/ble/ble-erg-mode.js +132 -132
- package/lib/ble/ble-interface.d.ts +100 -100
- package/lib/ble/ble-interface.js +721 -721
- package/lib/ble/ble-peripheral.d.ts +36 -36
- package/lib/ble/ble-peripheral.js +200 -200
- package/lib/ble/ble-st-mode.d.ts +15 -15
- package/lib/ble/ble-st-mode.js +95 -95
- package/lib/ble/ble.d.ts +129 -129
- package/lib/ble/ble.js +86 -86
- package/lib/ble/consts.d.ts +14 -14
- package/lib/ble/consts.js +17 -17
- package/lib/ble/elite.d.ts +90 -90
- package/lib/ble/elite.js +322 -322
- package/lib/ble/fm.d.ts +125 -125
- package/lib/ble/fm.js +745 -745
- package/lib/ble/hrm.d.ts +48 -48
- package/lib/ble/hrm.js +134 -134
- package/lib/ble/incyclist-protocol.d.ts +31 -31
- package/lib/ble/incyclist-protocol.js +153 -153
- package/lib/ble/pwr.d.ts +89 -89
- package/lib/ble/pwr.js +321 -321
- package/lib/ble/tacx.d.ts +92 -90
- package/lib/ble/tacx.js +763 -731
- package/lib/ble/wahoo-kickr.d.ts +98 -98
- package/lib/ble/wahoo-kickr.js +496 -496
- package/lib/calculations.d.ts +13 -13
- package/lib/calculations.js +150 -150
- package/lib/cycling-mode.d.ts +76 -76
- package/lib/cycling-mode.js +79 -79
- package/lib/daum/DaumAdapter.d.ts +66 -66
- package/lib/daum/DaumAdapter.js +396 -396
- package/lib/daum/DaumPowerMeterCyclingMode.d.ts +8 -8
- package/lib/daum/DaumPowerMeterCyclingMode.js +21 -21
- package/lib/daum/ERGCyclingMode.d.ts +26 -26
- package/lib/daum/ERGCyclingMode.js +201 -201
- package/lib/daum/SmartTrainerCyclingMode.d.ts +41 -41
- package/lib/daum/SmartTrainerCyclingMode.js +344 -344
- package/lib/daum/classic/DaumClassicAdapter.d.ts +22 -18
- package/lib/daum/classic/DaumClassicAdapter.js +183 -146
- package/lib/daum/classic/DaumClassicCyclingMode.d.ts +13 -13
- package/lib/daum/classic/DaumClassicCyclingMode.js +97 -97
- package/lib/daum/classic/DaumClassicProtocol.d.ts +27 -27
- package/lib/daum/classic/DaumClassicProtocol.js +185 -185
- package/lib/daum/classic/bike.d.ts +68 -64
- package/lib/daum/classic/bike.js +467 -456
- package/lib/daum/classic/utils.d.ts +13 -13
- package/lib/daum/classic/utils.js +143 -143
- package/lib/daum/constants.d.ts +19 -19
- package/lib/daum/constants.js +22 -22
- package/lib/daum/premium/DaumClassicCyclingMode.d.ts +14 -14
- package/lib/daum/premium/DaumClassicCyclingMode.js +86 -86
- package/lib/daum/premium/DaumPremiumAdapter.d.ts +16 -14
- package/lib/daum/premium/DaumPremiumAdapter.js +163 -139
- package/lib/daum/premium/DaumPremiumProtocol.d.ts +32 -32
- package/lib/daum/premium/DaumPremiumProtocol.js +207 -207
- package/lib/daum/premium/bike.d.ts +127 -123
- package/lib/daum/premium/bike.js +904 -894
- package/lib/daum/premium/tcpserial.d.ts +33 -33
- package/lib/daum/premium/tcpserial.js +123 -123
- package/lib/daum/premium/utils.d.ts +62 -62
- package/lib/daum/premium/utils.js +376 -376
- package/lib/device.d.ts +92 -92
- package/lib/device.js +71 -71
- package/lib/kettler/comms.d.ts +59 -59
- package/lib/kettler/comms.js +242 -242
- package/lib/kettler/ergo-racer/ERGCyclingMode.d.ts +25 -25
- package/lib/kettler/ergo-racer/ERGCyclingMode.js +144 -144
- package/lib/kettler/ergo-racer/adapter.d.ts +101 -101
- package/lib/kettler/ergo-racer/adapter.js +639 -639
- package/lib/kettler/ergo-racer/protocol.d.ts +41 -41
- package/lib/kettler/ergo-racer/protocol.js +203 -203
- package/lib/modes/power-base.d.ts +20 -20
- package/lib/modes/power-base.js +70 -70
- package/lib/modes/power-meter.d.ts +20 -20
- package/lib/modes/power-meter.js +78 -78
- package/lib/modes/simulator.d.ts +29 -29
- package/lib/modes/simulator.js +140 -140
- package/lib/protocol.d.ts +74 -74
- package/lib/protocol.js +41 -41
- package/lib/registry.d.ts +8 -8
- package/lib/registry.js +33 -33
- package/lib/simulator/Simulator.d.ts +69 -69
- package/lib/simulator/Simulator.js +288 -288
- package/lib/types/command.d.ts +8 -8
- package/lib/types/command.js +2 -2
- package/lib/types/route.d.ts +24 -24
- package/lib/types/route.js +9 -9
- package/lib/types/user.d.ts +11 -11
- package/lib/types/user.js +9 -9
- package/lib/utils.d.ts +14 -14
- package/lib/utils.js +114 -114
- package/package.json +47 -47
|
@@ -0,0 +1,104 @@
|
|
|
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.DEFAULT_UPDATE_FREQUENCY = void 0;
|
|
7
|
+
const device_1 = __importDefault(require("../device"));
|
|
8
|
+
const device_2 = require("../device");
|
|
9
|
+
const ant_interface_1 = __importDefault(require("./ant-interface"));
|
|
10
|
+
const incyclist_protocol_1 = require("./incyclist-protocol");
|
|
11
|
+
exports.DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
12
|
+
class AntAdapter extends device_1.default {
|
|
13
|
+
constructor(sensor, protocol) {
|
|
14
|
+
super(protocol);
|
|
15
|
+
this.paused = false;
|
|
16
|
+
this.stopped = false;
|
|
17
|
+
this.ignoreHrm = false;
|
|
18
|
+
this.ignoreBike = false;
|
|
19
|
+
this.ignorePower = false;
|
|
20
|
+
this.deviceData = {};
|
|
21
|
+
this.data = {};
|
|
22
|
+
this.updateFrequency = exports.DEFAULT_UPDATE_FREQUENCY;
|
|
23
|
+
this.ant = ant_interface_1.default.getInstance();
|
|
24
|
+
this.sensor = sensor;
|
|
25
|
+
this.onData = this.onDeviceData.bind(this);
|
|
26
|
+
}
|
|
27
|
+
isSame(device) {
|
|
28
|
+
if (!(device instanceof AntAdapter))
|
|
29
|
+
return false;
|
|
30
|
+
const adapter = device;
|
|
31
|
+
return (adapter.getID() === this.getID() && adapter.getProfile() === this.getProfile());
|
|
32
|
+
}
|
|
33
|
+
setSensor(sensor) {
|
|
34
|
+
this.sensor = sensor;
|
|
35
|
+
}
|
|
36
|
+
getID() {
|
|
37
|
+
return this.sensor.getDeviceID().toString();
|
|
38
|
+
}
|
|
39
|
+
setIgnoreHrm(ignore) {
|
|
40
|
+
this.ignoreHrm = ignore;
|
|
41
|
+
}
|
|
42
|
+
setIgnoreBike(ignore) {
|
|
43
|
+
this.ignoreBike = ignore;
|
|
44
|
+
}
|
|
45
|
+
setIgnorePower(ignore) {
|
|
46
|
+
this.ignorePower = ignore;
|
|
47
|
+
}
|
|
48
|
+
getProfile() {
|
|
49
|
+
return (0, incyclist_protocol_1.mapAntProfile)(this.sensor.getProfile());
|
|
50
|
+
}
|
|
51
|
+
getPort() {
|
|
52
|
+
return 'ant';
|
|
53
|
+
}
|
|
54
|
+
getWeight() {
|
|
55
|
+
let userWeight = device_2.DEFAULT_USER_WEIGHT;
|
|
56
|
+
let bikeWeight = device_2.DEFAULT_BIKE_WEIGHT;
|
|
57
|
+
if (this.userSettings && this.userSettings.weight) {
|
|
58
|
+
userWeight = Number(this.userSettings.weight);
|
|
59
|
+
}
|
|
60
|
+
if (this.bikeSettings && this.bikeSettings.weight) {
|
|
61
|
+
bikeWeight = Number(this.bikeSettings.weight);
|
|
62
|
+
}
|
|
63
|
+
return bikeWeight + userWeight;
|
|
64
|
+
}
|
|
65
|
+
isStopped() {
|
|
66
|
+
return this.stopped;
|
|
67
|
+
}
|
|
68
|
+
onDeviceData(data) { }
|
|
69
|
+
onDeviceEvent(data) { }
|
|
70
|
+
onAttached() { }
|
|
71
|
+
update() { }
|
|
72
|
+
check() { }
|
|
73
|
+
connect() { }
|
|
74
|
+
close() { }
|
|
75
|
+
pause() {
|
|
76
|
+
return new Promise(resolve => {
|
|
77
|
+
this.paused = true;
|
|
78
|
+
resolve(true);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
resume() {
|
|
82
|
+
return new Promise(resolve => {
|
|
83
|
+
this.paused = false;
|
|
84
|
+
resolve(true);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
start(props) {
|
|
88
|
+
if (props && props.user)
|
|
89
|
+
this.userSettings = props.user;
|
|
90
|
+
if (props && props.bikeSettings)
|
|
91
|
+
this.bikeSettings = props.bikeSettings;
|
|
92
|
+
return new Promise(resolve => {
|
|
93
|
+
this.stopped = false;
|
|
94
|
+
resolve(true);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
stop() {
|
|
98
|
+
return new Promise(resolve => {
|
|
99
|
+
this.stopped = true;
|
|
100
|
+
resolve(true);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.default = AntAdapter;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import AntProtocol, { AntDeviceSettings } from "./incyclist-protocol";
|
|
2
|
-
import AntAdapter from "./ant-device";
|
|
3
|
-
export default class AdapterFactory {
|
|
4
|
-
static create(settings: {
|
|
5
|
-
configuration?: AntDeviceSettings;
|
|
6
|
-
detected?: {
|
|
7
|
-
profile: string;
|
|
8
|
-
deviceID: number;
|
|
9
|
-
};
|
|
10
|
-
}, protocol: AntProtocol): AntAdapter;
|
|
11
|
-
}
|
|
1
|
+
import AntProtocol, { AntDeviceSettings } from "./incyclist-protocol";
|
|
2
|
+
import AntAdapter from "./ant-device";
|
|
3
|
+
export default class AdapterFactory {
|
|
4
|
+
static create(settings: {
|
|
5
|
+
configuration?: AntDeviceSettings;
|
|
6
|
+
detected?: {
|
|
7
|
+
profile: string;
|
|
8
|
+
deviceID: number;
|
|
9
|
+
};
|
|
10
|
+
}, protocol: AntProtocol): AntAdapter;
|
|
11
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const incyclist_protocol_1 = require("./incyclist-protocol");
|
|
7
|
-
const fe_1 = __importDefault(require("./fe"));
|
|
8
|
-
const hr_1 = __importDefault(require("./hr"));
|
|
9
|
-
const pwr_1 = __importDefault(require("./pwr"));
|
|
10
|
-
const sensor_factory_1 = __importDefault(require("./sensor-factory"));
|
|
11
|
-
const profiles = [
|
|
12
|
-
{ profile: 'PWR', Class: pwr_1.default },
|
|
13
|
-
{ profile: 'HR', Class: hr_1.default },
|
|
14
|
-
{ profile: 'FE', Class: fe_1.default },
|
|
15
|
-
];
|
|
16
|
-
class AdapterFactory {
|
|
17
|
-
static create(settings, protocol) {
|
|
18
|
-
let profile;
|
|
19
|
-
let deviceID;
|
|
20
|
-
if (settings && settings.configuration) {
|
|
21
|
-
profile = (0, incyclist_protocol_1.mapIncyclistProfile)(settings.configuration.profile);
|
|
22
|
-
deviceID = settings.configuration.deviceID;
|
|
23
|
-
}
|
|
24
|
-
else if (settings && settings.detected) {
|
|
25
|
-
profile = settings.detected.profile;
|
|
26
|
-
deviceID = settings.detected.deviceID;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const sensor = sensor_factory_1.default.create(profile, Number(deviceID));
|
|
32
|
-
if (sensor) {
|
|
33
|
-
const info = profiles.find(i => i.profile === profile);
|
|
34
|
-
if (!info)
|
|
35
|
-
return;
|
|
36
|
-
return new info.Class(sensor, protocol);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.default = AdapterFactory;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const incyclist_protocol_1 = require("./incyclist-protocol");
|
|
7
|
+
const fe_1 = __importDefault(require("./fe"));
|
|
8
|
+
const hr_1 = __importDefault(require("./hr"));
|
|
9
|
+
const pwr_1 = __importDefault(require("./pwr"));
|
|
10
|
+
const sensor_factory_1 = __importDefault(require("./sensor-factory"));
|
|
11
|
+
const profiles = [
|
|
12
|
+
{ profile: 'PWR', Class: pwr_1.default },
|
|
13
|
+
{ profile: 'HR', Class: hr_1.default },
|
|
14
|
+
{ profile: 'FE', Class: fe_1.default },
|
|
15
|
+
];
|
|
16
|
+
class AdapterFactory {
|
|
17
|
+
static create(settings, protocol) {
|
|
18
|
+
let profile;
|
|
19
|
+
let deviceID;
|
|
20
|
+
if (settings && settings.configuration) {
|
|
21
|
+
profile = (0, incyclist_protocol_1.mapIncyclistProfile)(settings.configuration.profile);
|
|
22
|
+
deviceID = settings.configuration.deviceID;
|
|
23
|
+
}
|
|
24
|
+
else if (settings && settings.detected) {
|
|
25
|
+
profile = settings.detected.profile;
|
|
26
|
+
deviceID = settings.detected.deviceID;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const sensor = sensor_factory_1.default.create(profile, Number(deviceID));
|
|
32
|
+
if (sensor) {
|
|
33
|
+
const info = profiles.find(i => i.profile === profile);
|
|
34
|
+
if (!info)
|
|
35
|
+
return;
|
|
36
|
+
return new info.Class(sensor, protocol);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = AdapterFactory;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IAntDevice, IChannel } from 'incyclist-ant-plus';
|
|
3
|
-
import { AntInterfaceProps } from './ant-interface';
|
|
4
|
-
export default class AntDeviceBinding implements IAntDevice {
|
|
5
|
-
constructor(props: AntInterfaceProps);
|
|
6
|
-
open(): Promise<boolean>;
|
|
7
|
-
close(): Promise<boolean>;
|
|
8
|
-
getMaxChannels(): number;
|
|
9
|
-
getChannel(): IChannel;
|
|
10
|
-
freeChannel(channel: IChannel): void;
|
|
11
|
-
getDeviceNumber(): number;
|
|
12
|
-
write(data: Buffer): void;
|
|
13
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IAntDevice, IChannel } from 'incyclist-ant-plus';
|
|
3
|
+
import { AntInterfaceProps } from './ant-interface';
|
|
4
|
+
export default class AntDeviceBinding implements IAntDevice {
|
|
5
|
+
constructor(props: AntInterfaceProps);
|
|
6
|
+
open(): Promise<boolean>;
|
|
7
|
+
close(): Promise<boolean>;
|
|
8
|
+
getMaxChannels(): number;
|
|
9
|
+
getChannel(): IChannel;
|
|
10
|
+
freeChannel(channel: IChannel): void;
|
|
11
|
+
getDeviceNumber(): number;
|
|
12
|
+
write(data: Buffer): void;
|
|
13
|
+
}
|
package/lib/antv2/ant-binding.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class AntDeviceBinding {
|
|
4
|
-
constructor(props) { }
|
|
5
|
-
open() {
|
|
6
|
-
throw new Error('Method not implemented.');
|
|
7
|
-
}
|
|
8
|
-
close() {
|
|
9
|
-
throw new Error('Method not implemented.');
|
|
10
|
-
}
|
|
11
|
-
getMaxChannels() {
|
|
12
|
-
throw new Error('Method not implemented.');
|
|
13
|
-
}
|
|
14
|
-
getChannel() {
|
|
15
|
-
throw new Error('Method not implemented.');
|
|
16
|
-
}
|
|
17
|
-
freeChannel(channel) {
|
|
18
|
-
throw new Error('Method not implemented.');
|
|
19
|
-
}
|
|
20
|
-
getDeviceNumber() {
|
|
21
|
-
throw new Error('Method not implemented.');
|
|
22
|
-
}
|
|
23
|
-
write(data) {
|
|
24
|
-
throw new Error('Method not implemented.');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.default = AntDeviceBinding;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class AntDeviceBinding {
|
|
4
|
+
constructor(props) { }
|
|
5
|
+
open() {
|
|
6
|
+
throw new Error('Method not implemented.');
|
|
7
|
+
}
|
|
8
|
+
close() {
|
|
9
|
+
throw new Error('Method not implemented.');
|
|
10
|
+
}
|
|
11
|
+
getMaxChannels() {
|
|
12
|
+
throw new Error('Method not implemented.');
|
|
13
|
+
}
|
|
14
|
+
getChannel() {
|
|
15
|
+
throw new Error('Method not implemented.');
|
|
16
|
+
}
|
|
17
|
+
freeChannel(channel) {
|
|
18
|
+
throw new Error('Method not implemented.');
|
|
19
|
+
}
|
|
20
|
+
getDeviceNumber() {
|
|
21
|
+
throw new Error('Method not implemented.');
|
|
22
|
+
}
|
|
23
|
+
write(data) {
|
|
24
|
+
throw new Error('Method not implemented.');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.default = AntDeviceBinding;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { Device } from '../protocol';
|
|
2
|
-
import { IChannel, ISensor } from 'incyclist-ant-plus';
|
|
3
|
-
import AntProtocol from './incyclist-protocol';
|
|
4
|
-
import AntInterface from './ant-interface';
|
|
5
|
-
import IncyclistDevice, { DeviceAdapter, OnDeviceDataCallback } from '../device';
|
|
6
|
-
export declare const DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
7
|
-
export default class AntAdapter extends IncyclistDevice implements Device {
|
|
8
|
-
sensor: ISensor;
|
|
9
|
-
protocol: AntProtocol;
|
|
10
|
-
ignoreHrm: boolean;
|
|
11
|
-
ignoreBike: boolean;
|
|
12
|
-
ignorePower: boolean;
|
|
13
|
-
lastUpdate?: number;
|
|
14
|
-
data: any;
|
|
15
|
-
deviceData: any;
|
|
16
|
-
updateFrequency: number;
|
|
17
|
-
channel: IChannel;
|
|
18
|
-
ant: AntInterface;
|
|
19
|
-
stopped: boolean;
|
|
20
|
-
paused: boolean;
|
|
21
|
-
userSettings: {
|
|
22
|
-
weight?: number;
|
|
23
|
-
};
|
|
24
|
-
bikeSettings: {
|
|
25
|
-
weight?: number;
|
|
26
|
-
};
|
|
27
|
-
detected: boolean;
|
|
28
|
-
selected: boolean;
|
|
29
|
-
settings: any;
|
|
30
|
-
onDataFn: OnDeviceDataCallback;
|
|
31
|
-
constructor(sensor: ISensor, protocol: AntProtocol, settings?: any);
|
|
32
|
-
isBike(): boolean;
|
|
33
|
-
isPower(): boolean;
|
|
34
|
-
isHrm(): boolean;
|
|
35
|
-
getDisplayName(): string;
|
|
36
|
-
isSame(device: DeviceAdapter): boolean;
|
|
37
|
-
getID(): string;
|
|
38
|
-
getName(): string;
|
|
39
|
-
getProfile(): string;
|
|
40
|
-
getPort(): string;
|
|
41
|
-
getProtocol(): AntProtocol;
|
|
42
|
-
getProtocolName(): string;
|
|
43
|
-
setIgnoreHrm(ignore: any): void;
|
|
44
|
-
setIgnoreBike(ignore: any): void;
|
|
45
|
-
setIgnorePower(ignore: any): void;
|
|
46
|
-
pause(): Promise<boolean>;
|
|
47
|
-
resume(): Promise<boolean>;
|
|
48
|
-
start(props?: any): Promise<any>;
|
|
49
|
-
stop(): Promise<boolean>;
|
|
50
|
-
isStopped(): boolean;
|
|
51
|
-
}
|
|
1
|
+
import { Device } from '../protocol';
|
|
2
|
+
import { IChannel, ISensor } from 'incyclist-ant-plus';
|
|
3
|
+
import AntProtocol from './incyclist-protocol';
|
|
4
|
+
import AntInterface from './ant-interface';
|
|
5
|
+
import IncyclistDevice, { DeviceAdapter, OnDeviceDataCallback } from '../device';
|
|
6
|
+
export declare const DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
7
|
+
export default class AntAdapter extends IncyclistDevice implements Device {
|
|
8
|
+
sensor: ISensor;
|
|
9
|
+
protocol: AntProtocol;
|
|
10
|
+
ignoreHrm: boolean;
|
|
11
|
+
ignoreBike: boolean;
|
|
12
|
+
ignorePower: boolean;
|
|
13
|
+
lastUpdate?: number;
|
|
14
|
+
data: any;
|
|
15
|
+
deviceData: any;
|
|
16
|
+
updateFrequency: number;
|
|
17
|
+
channel: IChannel;
|
|
18
|
+
ant: AntInterface;
|
|
19
|
+
stopped: boolean;
|
|
20
|
+
paused: boolean;
|
|
21
|
+
userSettings: {
|
|
22
|
+
weight?: number;
|
|
23
|
+
};
|
|
24
|
+
bikeSettings: {
|
|
25
|
+
weight?: number;
|
|
26
|
+
};
|
|
27
|
+
detected: boolean;
|
|
28
|
+
selected: boolean;
|
|
29
|
+
settings: any;
|
|
30
|
+
onDataFn: OnDeviceDataCallback;
|
|
31
|
+
constructor(sensor: ISensor, protocol: AntProtocol, settings?: any);
|
|
32
|
+
isBike(): boolean;
|
|
33
|
+
isPower(): boolean;
|
|
34
|
+
isHrm(): boolean;
|
|
35
|
+
getDisplayName(): string;
|
|
36
|
+
isSame(device: DeviceAdapter): boolean;
|
|
37
|
+
getID(): string;
|
|
38
|
+
getName(): string;
|
|
39
|
+
getProfile(): string;
|
|
40
|
+
getPort(): string;
|
|
41
|
+
getProtocol(): AntProtocol;
|
|
42
|
+
getProtocolName(): string;
|
|
43
|
+
setIgnoreHrm(ignore: any): void;
|
|
44
|
+
setIgnoreBike(ignore: any): void;
|
|
45
|
+
setIgnorePower(ignore: any): void;
|
|
46
|
+
pause(): Promise<boolean>;
|
|
47
|
+
resume(): Promise<boolean>;
|
|
48
|
+
start(props?: any): Promise<any>;
|
|
49
|
+
stop(): Promise<boolean>;
|
|
50
|
+
isStopped(): boolean;
|
|
51
|
+
}
|
package/lib/antv2/ant-device.js
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
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
|
-
exports.DEFAULT_UPDATE_FREQUENCY = void 0;
|
|
16
|
-
const incyclist_protocol_1 = require("./incyclist-protocol");
|
|
17
|
-
const ant_interface_1 = __importDefault(require("./ant-interface"));
|
|
18
|
-
const device_1 = __importDefault(require("../device"));
|
|
19
|
-
exports.DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
20
|
-
class AntAdapter extends device_1.default {
|
|
21
|
-
constructor(sensor, protocol, settings) {
|
|
22
|
-
super(protocol, settings);
|
|
23
|
-
this.sensor = sensor;
|
|
24
|
-
this.protocol = protocol;
|
|
25
|
-
this.ignoreHrm = false;
|
|
26
|
-
this.ignoreBike = false;
|
|
27
|
-
this.ignorePower = false;
|
|
28
|
-
this.deviceData = {};
|
|
29
|
-
this.data = {};
|
|
30
|
-
this.updateFrequency = exports.DEFAULT_UPDATE_FREQUENCY;
|
|
31
|
-
this.channel = undefined;
|
|
32
|
-
this.paused = false;
|
|
33
|
-
this.stopped = false;
|
|
34
|
-
this.ant = ant_interface_1.default.getInstance();
|
|
35
|
-
}
|
|
36
|
-
isBike() {
|
|
37
|
-
throw new Error('Method not implemented.');
|
|
38
|
-
}
|
|
39
|
-
isPower() {
|
|
40
|
-
throw new Error('Method not implemented.');
|
|
41
|
-
}
|
|
42
|
-
isHrm() {
|
|
43
|
-
throw new Error('Method not implemented.');
|
|
44
|
-
}
|
|
45
|
-
getDisplayName() {
|
|
46
|
-
throw new Error('Method not implemented.');
|
|
47
|
-
}
|
|
48
|
-
isSame(device) {
|
|
49
|
-
if (!(device instanceof AntAdapter))
|
|
50
|
-
return false;
|
|
51
|
-
const adapter = device;
|
|
52
|
-
return (adapter.getID() === this.getID() && adapter.getProfile() === this.getProfile());
|
|
53
|
-
}
|
|
54
|
-
getID() {
|
|
55
|
-
return this.sensor.getDeviceID().toString();
|
|
56
|
-
}
|
|
57
|
-
getName() {
|
|
58
|
-
const deviceID = this.sensor.getDeviceID();
|
|
59
|
-
const profile = this.sensor.getProfile();
|
|
60
|
-
return `Ant+${profile} ${deviceID}`;
|
|
61
|
-
}
|
|
62
|
-
getProfile() {
|
|
63
|
-
return (0, incyclist_protocol_1.mapAntProfile)(this.sensor.getProfile());
|
|
64
|
-
}
|
|
65
|
-
getPort() {
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
getProtocol() {
|
|
69
|
-
return this.protocol;
|
|
70
|
-
}
|
|
71
|
-
getProtocolName() {
|
|
72
|
-
return this.protocol.getName();
|
|
73
|
-
}
|
|
74
|
-
setIgnoreHrm(ignore) {
|
|
75
|
-
this.ignoreHrm = ignore;
|
|
76
|
-
}
|
|
77
|
-
setIgnoreBike(ignore) {
|
|
78
|
-
this.ignoreBike = ignore;
|
|
79
|
-
}
|
|
80
|
-
setIgnorePower(ignore) {
|
|
81
|
-
this.ignorePower = ignore;
|
|
82
|
-
}
|
|
83
|
-
pause() {
|
|
84
|
-
return new Promise(resolve => {
|
|
85
|
-
this.paused = true;
|
|
86
|
-
resolve(true);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
resume() {
|
|
90
|
-
return new Promise(resolve => {
|
|
91
|
-
this.paused = false;
|
|
92
|
-
resolve(true);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
start(props) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
if (props && props.user)
|
|
98
|
-
this.userSettings = props.user;
|
|
99
|
-
if (props && props.bikeSettings)
|
|
100
|
-
this.bikeSettings = props.bikeSettings;
|
|
101
|
-
this.stopped = false;
|
|
102
|
-
return true;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
stop() {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
this.stopped = true;
|
|
108
|
-
return true;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
isStopped() {
|
|
112
|
-
return this.stopped;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.default = AntAdapter;
|
|
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
|
+
exports.DEFAULT_UPDATE_FREQUENCY = void 0;
|
|
16
|
+
const incyclist_protocol_1 = require("./incyclist-protocol");
|
|
17
|
+
const ant_interface_1 = __importDefault(require("./ant-interface"));
|
|
18
|
+
const device_1 = __importDefault(require("../device"));
|
|
19
|
+
exports.DEFAULT_UPDATE_FREQUENCY = 1000;
|
|
20
|
+
class AntAdapter extends device_1.default {
|
|
21
|
+
constructor(sensor, protocol, settings) {
|
|
22
|
+
super(protocol, settings);
|
|
23
|
+
this.sensor = sensor;
|
|
24
|
+
this.protocol = protocol;
|
|
25
|
+
this.ignoreHrm = false;
|
|
26
|
+
this.ignoreBike = false;
|
|
27
|
+
this.ignorePower = false;
|
|
28
|
+
this.deviceData = {};
|
|
29
|
+
this.data = {};
|
|
30
|
+
this.updateFrequency = exports.DEFAULT_UPDATE_FREQUENCY;
|
|
31
|
+
this.channel = undefined;
|
|
32
|
+
this.paused = false;
|
|
33
|
+
this.stopped = false;
|
|
34
|
+
this.ant = ant_interface_1.default.getInstance();
|
|
35
|
+
}
|
|
36
|
+
isBike() {
|
|
37
|
+
throw new Error('Method not implemented.');
|
|
38
|
+
}
|
|
39
|
+
isPower() {
|
|
40
|
+
throw new Error('Method not implemented.');
|
|
41
|
+
}
|
|
42
|
+
isHrm() {
|
|
43
|
+
throw new Error('Method not implemented.');
|
|
44
|
+
}
|
|
45
|
+
getDisplayName() {
|
|
46
|
+
throw new Error('Method not implemented.');
|
|
47
|
+
}
|
|
48
|
+
isSame(device) {
|
|
49
|
+
if (!(device instanceof AntAdapter))
|
|
50
|
+
return false;
|
|
51
|
+
const adapter = device;
|
|
52
|
+
return (adapter.getID() === this.getID() && adapter.getProfile() === this.getProfile());
|
|
53
|
+
}
|
|
54
|
+
getID() {
|
|
55
|
+
return this.sensor.getDeviceID().toString();
|
|
56
|
+
}
|
|
57
|
+
getName() {
|
|
58
|
+
const deviceID = this.sensor.getDeviceID();
|
|
59
|
+
const profile = this.sensor.getProfile();
|
|
60
|
+
return `Ant+${profile} ${deviceID}`;
|
|
61
|
+
}
|
|
62
|
+
getProfile() {
|
|
63
|
+
return (0, incyclist_protocol_1.mapAntProfile)(this.sensor.getProfile());
|
|
64
|
+
}
|
|
65
|
+
getPort() {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
getProtocol() {
|
|
69
|
+
return this.protocol;
|
|
70
|
+
}
|
|
71
|
+
getProtocolName() {
|
|
72
|
+
return this.protocol.getName();
|
|
73
|
+
}
|
|
74
|
+
setIgnoreHrm(ignore) {
|
|
75
|
+
this.ignoreHrm = ignore;
|
|
76
|
+
}
|
|
77
|
+
setIgnoreBike(ignore) {
|
|
78
|
+
this.ignoreBike = ignore;
|
|
79
|
+
}
|
|
80
|
+
setIgnorePower(ignore) {
|
|
81
|
+
this.ignorePower = ignore;
|
|
82
|
+
}
|
|
83
|
+
pause() {
|
|
84
|
+
return new Promise(resolve => {
|
|
85
|
+
this.paused = true;
|
|
86
|
+
resolve(true);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
resume() {
|
|
90
|
+
return new Promise(resolve => {
|
|
91
|
+
this.paused = false;
|
|
92
|
+
resolve(true);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
start(props) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
if (props && props.user)
|
|
98
|
+
this.userSettings = props.user;
|
|
99
|
+
if (props && props.bikeSettings)
|
|
100
|
+
this.bikeSettings = props.bikeSettings;
|
|
101
|
+
this.stopped = false;
|
|
102
|
+
return true;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
stop() {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
this.stopped = true;
|
|
108
|
+
return true;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
isStopped() {
|
|
112
|
+
return this.stopped;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.default = AntAdapter;
|