incyclist-devices 1.5.11 → 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 -22
- package/lib/daum/classic/DaumClassicAdapter.js +183 -183
- 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 -68
- package/lib/daum/classic/bike.js +467 -467
- 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 -16
- package/lib/daum/premium/DaumPremiumAdapter.js +163 -163
- 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 -127
- package/lib/daum/premium/bike.js +904 -904
- 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
|
@@ -1,153 +1,153 @@
|
|
|
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
|
-
const gd_eventlog_1 = require("gd-eventlog");
|
|
35
|
-
const protocol_1 = __importStar(require("../protocol"));
|
|
36
|
-
const registry_1 = __importDefault(require("../registry"));
|
|
37
|
-
const ble_1 = require("./ble");
|
|
38
|
-
const ble_interface_1 = __importDefault(require("./ble-interface"));
|
|
39
|
-
const fm_1 = __importStar(require("./fm"));
|
|
40
|
-
const hrm_1 = __importStar(require("./hrm"));
|
|
41
|
-
const pwr_1 = __importStar(require("./pwr"));
|
|
42
|
-
const wahoo_kickr_1 = __importStar(require("./wahoo-kickr"));
|
|
43
|
-
const tacx_1 = __importStar(require("./tacx"));
|
|
44
|
-
const elite_1 = __importStar(require("./elite"));
|
|
45
|
-
class BleProtocol extends protocol_1.default {
|
|
46
|
-
constructor(binding) {
|
|
47
|
-
super();
|
|
48
|
-
const b = binding || BleProtocol._defaultBinding;
|
|
49
|
-
this.logger = new gd_eventlog_1.EventLogger('BLE');
|
|
50
|
-
this.ble = ble_interface_1.default.getInstance({ binding: b, logger: this.logger });
|
|
51
|
-
BleProtocol._instances.push(this);
|
|
52
|
-
}
|
|
53
|
-
static setDefaultBinding(binding) {
|
|
54
|
-
BleProtocol._defaultBinding = binding;
|
|
55
|
-
BleProtocol._instances.forEach((p) => {
|
|
56
|
-
if (p.ble && !p.ble.getBinding()) {
|
|
57
|
-
p.ble.setBinding(binding);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
setBinding(binding) {
|
|
62
|
-
if (this.ble)
|
|
63
|
-
this.ble.setBinding(binding);
|
|
64
|
-
}
|
|
65
|
-
createDevice(bleDevice) {
|
|
66
|
-
const fromDevice = bleDevice instanceof ble_1.BleDeviceClass;
|
|
67
|
-
const profile = bleDevice instanceof ble_1.BleDeviceClass ? bleDevice.getProfile() : bleDevice.profile;
|
|
68
|
-
const props = () => {
|
|
69
|
-
const { id, name, address } = bleDevice;
|
|
70
|
-
return { id, name, address };
|
|
71
|
-
};
|
|
72
|
-
switch (profile.toLowerCase()) {
|
|
73
|
-
case 'hr':
|
|
74
|
-
case 'heartrate monitor':
|
|
75
|
-
return new hrm_1.HrmAdapter(fromDevice ? bleDevice : new hrm_1.default(props()), this);
|
|
76
|
-
case 'fm':
|
|
77
|
-
case 'smart trainer':
|
|
78
|
-
case 'wahoo smart trainer':
|
|
79
|
-
case 'fitness machine':
|
|
80
|
-
case 'elite smart trainer':
|
|
81
|
-
case tacx_1.default.PROFILE.toLowerCase():
|
|
82
|
-
let device;
|
|
83
|
-
if (fromDevice)
|
|
84
|
-
device = bleDevice;
|
|
85
|
-
else {
|
|
86
|
-
device = this.ble.findDeviceInCache(Object.assign(Object.assign({}, props()), { profile }));
|
|
87
|
-
}
|
|
88
|
-
if (profile.toLowerCase() === 'wahoo smart trainer') {
|
|
89
|
-
device = device || new wahoo_kickr_1.default(props());
|
|
90
|
-
return new wahoo_kickr_1.WahooAdvancedFmAdapter(device, this);
|
|
91
|
-
}
|
|
92
|
-
if (profile.toLowerCase() === 'elite smart trainer') {
|
|
93
|
-
device = device || new elite_1.default(props());
|
|
94
|
-
return new elite_1.EliteAdapter(device, this);
|
|
95
|
-
}
|
|
96
|
-
else if (profile === tacx_1.default.PROFILE) {
|
|
97
|
-
device = device || new tacx_1.default(props());
|
|
98
|
-
return new tacx_1.TacxBleFEAdapter(device, this);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
device = device || new fm_1.default(props());
|
|
102
|
-
return new fm_1.FmAdapter(device, this);
|
|
103
|
-
}
|
|
104
|
-
case 'cp':
|
|
105
|
-
case 'power meter':
|
|
106
|
-
return new pwr_1.PwrAdapter(fromDevice ? bleDevice : new pwr_1.default(props()), this);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
getName() { return 'BLE'; }
|
|
110
|
-
getInterfaces() { return [protocol_1.INTERFACE.BLE]; }
|
|
111
|
-
isBike() { return true; }
|
|
112
|
-
isHrm() { return true; }
|
|
113
|
-
isPower() { return true; }
|
|
114
|
-
add(settings) {
|
|
115
|
-
this.logger.logEvent({ message: 'adding device', settings });
|
|
116
|
-
const device = this.createDevice(settings);
|
|
117
|
-
return device;
|
|
118
|
-
}
|
|
119
|
-
scan(props) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
try {
|
|
122
|
-
this.ble.on('device', (bleDevice) => {
|
|
123
|
-
if (props && props.onDeviceFound) {
|
|
124
|
-
const device = this.createDevice(bleDevice);
|
|
125
|
-
props.onDeviceFound(device, this);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
this.logger.logEvent({ message: 'scan started' });
|
|
129
|
-
const supportedDeviceTypes = this.ble.getAllSupportedDeviceTypes();
|
|
130
|
-
yield this.ble.scan({ deviceTypes: supportedDeviceTypes, timeout: 20000 });
|
|
131
|
-
if (props && props.onScanFinished) {
|
|
132
|
-
props.onScanFinished(props.id);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (err) {
|
|
136
|
-
this.logger.logEvent({ message: 'error', error: err.message });
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
stopScan() {
|
|
141
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
yield this.ble.stopScan();
|
|
143
|
-
return;
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
isScanning() {
|
|
147
|
-
return this.ble.isScanning();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.default = BleProtocol;
|
|
151
|
-
BleProtocol._defaultBinding = undefined;
|
|
152
|
-
BleProtocol._instances = [];
|
|
153
|
-
registry_1.default.register(new BleProtocol());
|
|
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
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
35
|
+
const protocol_1 = __importStar(require("../protocol"));
|
|
36
|
+
const registry_1 = __importDefault(require("../registry"));
|
|
37
|
+
const ble_1 = require("./ble");
|
|
38
|
+
const ble_interface_1 = __importDefault(require("./ble-interface"));
|
|
39
|
+
const fm_1 = __importStar(require("./fm"));
|
|
40
|
+
const hrm_1 = __importStar(require("./hrm"));
|
|
41
|
+
const pwr_1 = __importStar(require("./pwr"));
|
|
42
|
+
const wahoo_kickr_1 = __importStar(require("./wahoo-kickr"));
|
|
43
|
+
const tacx_1 = __importStar(require("./tacx"));
|
|
44
|
+
const elite_1 = __importStar(require("./elite"));
|
|
45
|
+
class BleProtocol extends protocol_1.default {
|
|
46
|
+
constructor(binding) {
|
|
47
|
+
super();
|
|
48
|
+
const b = binding || BleProtocol._defaultBinding;
|
|
49
|
+
this.logger = new gd_eventlog_1.EventLogger('BLE');
|
|
50
|
+
this.ble = ble_interface_1.default.getInstance({ binding: b, logger: this.logger });
|
|
51
|
+
BleProtocol._instances.push(this);
|
|
52
|
+
}
|
|
53
|
+
static setDefaultBinding(binding) {
|
|
54
|
+
BleProtocol._defaultBinding = binding;
|
|
55
|
+
BleProtocol._instances.forEach((p) => {
|
|
56
|
+
if (p.ble && !p.ble.getBinding()) {
|
|
57
|
+
p.ble.setBinding(binding);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
setBinding(binding) {
|
|
62
|
+
if (this.ble)
|
|
63
|
+
this.ble.setBinding(binding);
|
|
64
|
+
}
|
|
65
|
+
createDevice(bleDevice) {
|
|
66
|
+
const fromDevice = bleDevice instanceof ble_1.BleDeviceClass;
|
|
67
|
+
const profile = bleDevice instanceof ble_1.BleDeviceClass ? bleDevice.getProfile() : bleDevice.profile;
|
|
68
|
+
const props = () => {
|
|
69
|
+
const { id, name, address } = bleDevice;
|
|
70
|
+
return { id, name, address };
|
|
71
|
+
};
|
|
72
|
+
switch (profile.toLowerCase()) {
|
|
73
|
+
case 'hr':
|
|
74
|
+
case 'heartrate monitor':
|
|
75
|
+
return new hrm_1.HrmAdapter(fromDevice ? bleDevice : new hrm_1.default(props()), this);
|
|
76
|
+
case 'fm':
|
|
77
|
+
case 'smart trainer':
|
|
78
|
+
case 'wahoo smart trainer':
|
|
79
|
+
case 'fitness machine':
|
|
80
|
+
case 'elite smart trainer':
|
|
81
|
+
case tacx_1.default.PROFILE.toLowerCase():
|
|
82
|
+
let device;
|
|
83
|
+
if (fromDevice)
|
|
84
|
+
device = bleDevice;
|
|
85
|
+
else {
|
|
86
|
+
device = this.ble.findDeviceInCache(Object.assign(Object.assign({}, props()), { profile }));
|
|
87
|
+
}
|
|
88
|
+
if (profile.toLowerCase() === 'wahoo smart trainer') {
|
|
89
|
+
device = device || new wahoo_kickr_1.default(props());
|
|
90
|
+
return new wahoo_kickr_1.WahooAdvancedFmAdapter(device, this);
|
|
91
|
+
}
|
|
92
|
+
if (profile.toLowerCase() === 'elite smart trainer') {
|
|
93
|
+
device = device || new elite_1.default(props());
|
|
94
|
+
return new elite_1.EliteAdapter(device, this);
|
|
95
|
+
}
|
|
96
|
+
else if (profile === tacx_1.default.PROFILE) {
|
|
97
|
+
device = device || new tacx_1.default(props());
|
|
98
|
+
return new tacx_1.TacxBleFEAdapter(device, this);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
device = device || new fm_1.default(props());
|
|
102
|
+
return new fm_1.FmAdapter(device, this);
|
|
103
|
+
}
|
|
104
|
+
case 'cp':
|
|
105
|
+
case 'power meter':
|
|
106
|
+
return new pwr_1.PwrAdapter(fromDevice ? bleDevice : new pwr_1.default(props()), this);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
getName() { return 'BLE'; }
|
|
110
|
+
getInterfaces() { return [protocol_1.INTERFACE.BLE]; }
|
|
111
|
+
isBike() { return true; }
|
|
112
|
+
isHrm() { return true; }
|
|
113
|
+
isPower() { return true; }
|
|
114
|
+
add(settings) {
|
|
115
|
+
this.logger.logEvent({ message: 'adding device', settings });
|
|
116
|
+
const device = this.createDevice(settings);
|
|
117
|
+
return device;
|
|
118
|
+
}
|
|
119
|
+
scan(props) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
try {
|
|
122
|
+
this.ble.on('device', (bleDevice) => {
|
|
123
|
+
if (props && props.onDeviceFound) {
|
|
124
|
+
const device = this.createDevice(bleDevice);
|
|
125
|
+
props.onDeviceFound(device, this);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
this.logger.logEvent({ message: 'scan started' });
|
|
129
|
+
const supportedDeviceTypes = this.ble.getAllSupportedDeviceTypes();
|
|
130
|
+
yield this.ble.scan({ deviceTypes: supportedDeviceTypes, timeout: 20000 });
|
|
131
|
+
if (props && props.onScanFinished) {
|
|
132
|
+
props.onScanFinished(props.id);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
this.logger.logEvent({ message: 'error', error: err.message });
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
stopScan() {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
yield this.ble.stopScan();
|
|
143
|
+
return;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
isScanning() {
|
|
147
|
+
return this.ble.isScanning();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.default = BleProtocol;
|
|
151
|
+
BleProtocol._defaultBinding = undefined;
|
|
152
|
+
BleProtocol._instances = [];
|
|
153
|
+
registry_1.default.register(new BleProtocol());
|
package/lib/ble/pwr.d.ts
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
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
|
-
declare type PowerData = {
|
|
12
|
-
instantaneousPower?: number;
|
|
13
|
-
balance?: number;
|
|
14
|
-
accTorque?: number;
|
|
15
|
-
time: number;
|
|
16
|
-
rpm: number;
|
|
17
|
-
raw?: string;
|
|
18
|
-
};
|
|
19
|
-
declare type CrankData = {
|
|
20
|
-
revolutions?: number;
|
|
21
|
-
time?: number;
|
|
22
|
-
cntUpdateMissing?: number;
|
|
23
|
-
};
|
|
24
|
-
export default class BleCyclingPowerDevice extends BleDevice {
|
|
25
|
-
static services: string[];
|
|
26
|
-
static characteristics: string[];
|
|
27
|
-
static detectionPriority: number;
|
|
28
|
-
instantaneousPower: number;
|
|
29
|
-
balance: number;
|
|
30
|
-
accTorque: number;
|
|
31
|
-
rpm: number;
|
|
32
|
-
timeOffset: number;
|
|
33
|
-
time: number;
|
|
34
|
-
currentCrankData: CrankData;
|
|
35
|
-
prevCrankData: CrankData;
|
|
36
|
-
constructor(props?: any);
|
|
37
|
-
isMatching(characteristics: string[]): boolean;
|
|
38
|
-
init(): Promise<boolean>;
|
|
39
|
-
getProfile(): string;
|
|
40
|
-
getServiceUUids(): string[];
|
|
41
|
-
parseCrankData(crankData: any): {
|
|
42
|
-
rpm: number;
|
|
43
|
-
time: any;
|
|
44
|
-
};
|
|
45
|
-
parsePower(_data: Uint8Array): PowerData;
|
|
46
|
-
onData(characteristic: string, data: Buffer): boolean;
|
|
47
|
-
reset(): void;
|
|
48
|
-
}
|
|
49
|
-
export declare class PwrAdapter extends DeviceAdapter {
|
|
50
|
-
device: BleCyclingPowerDevice;
|
|
51
|
-
ignore: boolean;
|
|
52
|
-
ble: BleInterface;
|
|
53
|
-
protocol: DeviceProtocol;
|
|
54
|
-
paused: boolean;
|
|
55
|
-
logger: EventLogger;
|
|
56
|
-
mode: CyclingMode;
|
|
57
|
-
distanceInternal: number;
|
|
58
|
-
prevDataTS: number;
|
|
59
|
-
userSettings: {
|
|
60
|
-
weight?: number;
|
|
61
|
-
};
|
|
62
|
-
bikeSettings: {
|
|
63
|
-
weight?: number;
|
|
64
|
-
};
|
|
65
|
-
constructor(device: BleDeviceClass, protocol: BleProtocol);
|
|
66
|
-
isBike(): boolean;
|
|
67
|
-
isHrm(): boolean;
|
|
68
|
-
isPower(): boolean;
|
|
69
|
-
isSame(device: DeviceAdapter): boolean;
|
|
70
|
-
getProfile(): string;
|
|
71
|
-
getName(): string;
|
|
72
|
-
getDisplayName(): string;
|
|
73
|
-
getCyclingMode(): CyclingMode;
|
|
74
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
75
|
-
getSupportedCyclingModes(): any[];
|
|
76
|
-
getPort(): string;
|
|
77
|
-
getWeight(): number;
|
|
78
|
-
setIgnoreBike(ignore: any): void;
|
|
79
|
-
setIgnorePower(ignore: any): void;
|
|
80
|
-
onDeviceData(deviceData: PowerData): void;
|
|
81
|
-
mapData(deviceData: PowerData): IncyclistBikeData;
|
|
82
|
-
transformData(bikeData: IncyclistBikeData): DeviceData;
|
|
83
|
-
start(props?: any): Promise<any>;
|
|
84
|
-
stop(): Promise<boolean>;
|
|
85
|
-
sendUpdate(request: any): Promise<void>;
|
|
86
|
-
pause(): Promise<boolean>;
|
|
87
|
-
resume(): Promise<boolean>;
|
|
88
|
-
}
|
|
89
|
-
export {};
|
|
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
|
+
declare type PowerData = {
|
|
12
|
+
instantaneousPower?: number;
|
|
13
|
+
balance?: number;
|
|
14
|
+
accTorque?: number;
|
|
15
|
+
time: number;
|
|
16
|
+
rpm: number;
|
|
17
|
+
raw?: string;
|
|
18
|
+
};
|
|
19
|
+
declare type CrankData = {
|
|
20
|
+
revolutions?: number;
|
|
21
|
+
time?: number;
|
|
22
|
+
cntUpdateMissing?: number;
|
|
23
|
+
};
|
|
24
|
+
export default class BleCyclingPowerDevice extends BleDevice {
|
|
25
|
+
static services: string[];
|
|
26
|
+
static characteristics: string[];
|
|
27
|
+
static detectionPriority: number;
|
|
28
|
+
instantaneousPower: number;
|
|
29
|
+
balance: number;
|
|
30
|
+
accTorque: number;
|
|
31
|
+
rpm: number;
|
|
32
|
+
timeOffset: number;
|
|
33
|
+
time: number;
|
|
34
|
+
currentCrankData: CrankData;
|
|
35
|
+
prevCrankData: CrankData;
|
|
36
|
+
constructor(props?: any);
|
|
37
|
+
isMatching(characteristics: string[]): boolean;
|
|
38
|
+
init(): Promise<boolean>;
|
|
39
|
+
getProfile(): string;
|
|
40
|
+
getServiceUUids(): string[];
|
|
41
|
+
parseCrankData(crankData: any): {
|
|
42
|
+
rpm: number;
|
|
43
|
+
time: any;
|
|
44
|
+
};
|
|
45
|
+
parsePower(_data: Uint8Array): PowerData;
|
|
46
|
+
onData(characteristic: string, data: Buffer): boolean;
|
|
47
|
+
reset(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare class PwrAdapter extends DeviceAdapter {
|
|
50
|
+
device: BleCyclingPowerDevice;
|
|
51
|
+
ignore: boolean;
|
|
52
|
+
ble: BleInterface;
|
|
53
|
+
protocol: DeviceProtocol;
|
|
54
|
+
paused: boolean;
|
|
55
|
+
logger: EventLogger;
|
|
56
|
+
mode: CyclingMode;
|
|
57
|
+
distanceInternal: number;
|
|
58
|
+
prevDataTS: number;
|
|
59
|
+
userSettings: {
|
|
60
|
+
weight?: number;
|
|
61
|
+
};
|
|
62
|
+
bikeSettings: {
|
|
63
|
+
weight?: number;
|
|
64
|
+
};
|
|
65
|
+
constructor(device: BleDeviceClass, protocol: BleProtocol);
|
|
66
|
+
isBike(): boolean;
|
|
67
|
+
isHrm(): boolean;
|
|
68
|
+
isPower(): boolean;
|
|
69
|
+
isSame(device: DeviceAdapter): boolean;
|
|
70
|
+
getProfile(): string;
|
|
71
|
+
getName(): string;
|
|
72
|
+
getDisplayName(): string;
|
|
73
|
+
getCyclingMode(): CyclingMode;
|
|
74
|
+
getDefaultCyclingMode(): CyclingMode;
|
|
75
|
+
getSupportedCyclingModes(): any[];
|
|
76
|
+
getPort(): string;
|
|
77
|
+
getWeight(): number;
|
|
78
|
+
setIgnoreBike(ignore: any): void;
|
|
79
|
+
setIgnorePower(ignore: any): void;
|
|
80
|
+
onDeviceData(deviceData: PowerData): void;
|
|
81
|
+
mapData(deviceData: PowerData): IncyclistBikeData;
|
|
82
|
+
transformData(bikeData: IncyclistBikeData): DeviceData;
|
|
83
|
+
start(props?: any): Promise<any>;
|
|
84
|
+
stop(): Promise<boolean>;
|
|
85
|
+
sendUpdate(request: any): Promise<void>;
|
|
86
|
+
pause(): Promise<boolean>;
|
|
87
|
+
resume(): Promise<boolean>;
|
|
88
|
+
}
|
|
89
|
+
export {};
|