incyclist-devices 1.4.80 → 1.4.83
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/DeviceSupport.d.ts +11 -0
- package/lib/DeviceSupport.js +18 -0
- package/lib/ble/ble-interface.js +1 -1
- package/lib/ble/ble.js +2 -2
- package/lib/ble/consts.d.ts +4 -0
- package/lib/ble/consts.js +5 -1
- package/lib/ble/pwr.js +6 -7
- package/lib/ble/wahoo-kickr.js +5 -6
- package/package.json +1 -1
package/lib/DeviceSupport.d.ts
CHANGED
|
@@ -20,4 +20,15 @@ declare const Protocols: {
|
|
|
20
20
|
KettlerRacerProtocol: typeof KettlerRacerProtocol;
|
|
21
21
|
BleProtocol: typeof BleProtocol;
|
|
22
22
|
};
|
|
23
|
+
export interface FeatureList {
|
|
24
|
+
[key: string]: boolean;
|
|
25
|
+
}
|
|
26
|
+
export default class DeviceSupport {
|
|
27
|
+
static _features: FeatureList;
|
|
28
|
+
static init(props?: {
|
|
29
|
+
features?: FeatureList;
|
|
30
|
+
}): void;
|
|
31
|
+
static hasFeature(feature: string): boolean;
|
|
32
|
+
static setFeature(key: string, value: boolean): void;
|
|
33
|
+
}
|
|
23
34
|
export { DeviceProtocolBase, DeviceProtocol, DeviceRegistry, INTERFACE, DeviceAdapter as Device, Protocols, AntScanner, BleProtocol, CyclingModeProperyType, BleInterface, BleHrmDevice, BleCyclingPowerDevice, BleFitnessMachineDevice, WahooAdvancedFitnessMachineDevice };
|
package/lib/DeviceSupport.js
CHANGED
|
@@ -58,3 +58,21 @@ const Protocols = {
|
|
|
58
58
|
BleProtocol: incyclist_protocol_1.default
|
|
59
59
|
};
|
|
60
60
|
exports.Protocols = Protocols;
|
|
61
|
+
class DeviceSupport {
|
|
62
|
+
static init(props = {}) {
|
|
63
|
+
if (props.features) {
|
|
64
|
+
this._features = props.features;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static hasFeature(feature) {
|
|
68
|
+
const featureVal = this._features[feature];
|
|
69
|
+
if (featureVal === undefined)
|
|
70
|
+
return false;
|
|
71
|
+
return featureVal;
|
|
72
|
+
}
|
|
73
|
+
static setFeature(key, value) {
|
|
74
|
+
this._features[key] = value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.default = DeviceSupport;
|
|
78
|
+
DeviceSupport._features = {};
|
package/lib/ble/ble-interface.js
CHANGED
|
@@ -212,7 +212,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
|
|
|
212
212
|
if (Array.isArray(services)) {
|
|
213
213
|
const sids = services.map(ble_1.uuid);
|
|
214
214
|
return get(deviceTypes, s => {
|
|
215
|
-
const res = sids.find((
|
|
215
|
+
const res = sids.find((service) => (0, ble_2.matches)(s, service));
|
|
216
216
|
return res !== undefined;
|
|
217
217
|
});
|
|
218
218
|
}
|
package/lib/ble/ble.js
CHANGED
|
@@ -73,10 +73,10 @@ const uuid = (s) => {
|
|
|
73
73
|
};
|
|
74
74
|
exports.uuid = uuid;
|
|
75
75
|
const matches = (uuid1, uuid2) => {
|
|
76
|
-
if ((0, exports.uuid)(uuid1) === (0, exports.uuid)(uuid2))
|
|
77
|
-
return true;
|
|
78
76
|
const ul1 = uuid1.toLowerCase();
|
|
79
77
|
const ul2 = uuid2.toLowerCase();
|
|
78
|
+
if ((0, exports.uuid)(ul1) === (0, exports.uuid)(ul2))
|
|
79
|
+
return true;
|
|
80
80
|
if (ul1.length < ul2.length && ul2.startsWith(ul1))
|
|
81
81
|
return true;
|
|
82
82
|
if (ul1.length > ul2.length && ul1.startsWith(ul2))
|
package/lib/ble/consts.d.ts
CHANGED
|
@@ -5,3 +5,7 @@ export declare const FTMS = "1826";
|
|
|
5
5
|
export declare const FTMS_CP = "2ad9";
|
|
6
6
|
export declare const FTMS_STATUS = "2ada";
|
|
7
7
|
export declare const INDOOR_BIKE_DATA = "2ad2";
|
|
8
|
+
export declare const CSP = "1818";
|
|
9
|
+
export declare const CSP_MEASUREMENT = "2a63";
|
|
10
|
+
export declare const CSP_FEATURE = "2a65";
|
|
11
|
+
export declare const WAHOO_ADVANCED_TRAINER_CP = "a026e005";
|
package/lib/ble/consts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INDOOR_BIKE_DATA = exports.FTMS_STATUS = exports.FTMS_CP = exports.FTMS = exports.TACX_FE_C_TX = exports.TACX_FE_C_RX = exports.TACX_FE_C_BLE = void 0;
|
|
3
|
+
exports.WAHOO_ADVANCED_TRAINER_CP = exports.CSP_FEATURE = exports.CSP_MEASUREMENT = exports.CSP = exports.INDOOR_BIKE_DATA = exports.FTMS_STATUS = exports.FTMS_CP = exports.FTMS = exports.TACX_FE_C_TX = exports.TACX_FE_C_RX = exports.TACX_FE_C_BLE = void 0;
|
|
4
4
|
exports.TACX_FE_C_BLE = '6e40fec1';
|
|
5
5
|
exports.TACX_FE_C_RX = '6e40fec2';
|
|
6
6
|
exports.TACX_FE_C_TX = '6e40fec3';
|
|
@@ -8,3 +8,7 @@ exports.FTMS = '1826';
|
|
|
8
8
|
exports.FTMS_CP = '2ad9';
|
|
9
9
|
exports.FTMS_STATUS = '2ada';
|
|
10
10
|
exports.INDOOR_BIKE_DATA = '2ad2';
|
|
11
|
+
exports.CSP = '1818';
|
|
12
|
+
exports.CSP_MEASUREMENT = '2a63';
|
|
13
|
+
exports.CSP_FEATURE = '2a65';
|
|
14
|
+
exports.WAHOO_ADVANCED_TRAINER_CP = 'a026e005';
|
package/lib/ble/pwr.js
CHANGED
|
@@ -36,9 +36,8 @@ const ble_device_1 = require("./ble-device");
|
|
|
36
36
|
const ble_interface_1 = __importDefault(require("./ble-interface"));
|
|
37
37
|
const Device_1 = __importStar(require("../Device"));
|
|
38
38
|
const gd_eventlog_1 = require("gd-eventlog");
|
|
39
|
+
const consts_1 = require("./consts");
|
|
39
40
|
const power_meter_1 = __importDefault(require("../modes/power-meter"));
|
|
40
|
-
const CP_MEASUREMENT = '2a63';
|
|
41
|
-
const CP_FEATURE = '2a65';
|
|
42
41
|
class BleCyclingPowerDevice extends ble_device_1.BleDevice {
|
|
43
42
|
constructor(props) {
|
|
44
43
|
super(props);
|
|
@@ -54,8 +53,8 @@ class BleCyclingPowerDevice extends ble_device_1.BleDevice {
|
|
|
54
53
|
isMatching(characteristics) {
|
|
55
54
|
if (!characteristics)
|
|
56
55
|
return false;
|
|
57
|
-
const hasCPMeasurement = characteristics.find(c => c ===
|
|
58
|
-
const hasCPFeature = characteristics.find(c => c ===
|
|
56
|
+
const hasCPMeasurement = characteristics.find(c => c === consts_1.CSP_MEASUREMENT) !== undefined;
|
|
57
|
+
const hasCPFeature = characteristics.find(c => c === consts_1.CSP_FEATURE) !== undefined;
|
|
59
58
|
return hasCPMeasurement && hasCPFeature;
|
|
60
59
|
}
|
|
61
60
|
init() {
|
|
@@ -143,7 +142,7 @@ class BleCyclingPowerDevice extends ble_device_1.BleDevice {
|
|
|
143
142
|
const isDuplicate = this.checkForDuplicate(characteristic, data);
|
|
144
143
|
if (isDuplicate)
|
|
145
144
|
return;
|
|
146
|
-
if (characteristic.toLocaleLowerCase() ===
|
|
145
|
+
if (characteristic.toLocaleLowerCase() === consts_1.CSP_MEASUREMENT) {
|
|
147
146
|
const res = this.parsePower(data);
|
|
148
147
|
this.emit('data', res);
|
|
149
148
|
}
|
|
@@ -160,8 +159,8 @@ class BleCyclingPowerDevice extends ble_device_1.BleDevice {
|
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
161
|
exports.default = BleCyclingPowerDevice;
|
|
163
|
-
BleCyclingPowerDevice.services = [
|
|
164
|
-
BleCyclingPowerDevice.characteristics = [
|
|
162
|
+
BleCyclingPowerDevice.services = [consts_1.CSP];
|
|
163
|
+
BleCyclingPowerDevice.characteristics = [consts_1.CSP_MEASUREMENT, consts_1.CSP_FEATURE, '2a5d', '2a3c'];
|
|
165
164
|
ble_interface_1.default.register('BleCyclingPowerDevice', 'cp', BleCyclingPowerDevice, BleCyclingPowerDevice.services);
|
|
166
165
|
class PwrAdapter extends Device_1.default {
|
|
167
166
|
constructor(device, protocol) {
|
package/lib/ble/wahoo-kickr.js
CHANGED
|
@@ -39,7 +39,6 @@ const gd_eventlog_1 = require("gd-eventlog");
|
|
|
39
39
|
const fm_1 = __importStar(require("./fm"));
|
|
40
40
|
const consts_1 = require("./consts");
|
|
41
41
|
const WAHOO_ADVANCED_FTMS = 'a026ee0b';
|
|
42
|
-
const WAHOO_ADVANCED_TRAINER_CP = 'a026e005';
|
|
43
42
|
const cwABike = {
|
|
44
43
|
race: 0.35,
|
|
45
44
|
triathlon: 0.29,
|
|
@@ -56,12 +55,12 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
56
55
|
this.tsPrevWrite = undefined;
|
|
57
56
|
this.prevSlope = undefined;
|
|
58
57
|
this.data = {};
|
|
59
|
-
this.wahooCP = WAHOO_ADVANCED_TRAINER_CP;
|
|
58
|
+
this.wahooCP = consts_1.WAHOO_ADVANCED_TRAINER_CP;
|
|
60
59
|
}
|
|
61
60
|
isMatching(characteristics) {
|
|
62
61
|
if (!characteristics)
|
|
63
62
|
return false;
|
|
64
|
-
const hasWahooCP = characteristics.find(c => (0, ble_1.matches)(c, WAHOO_ADVANCED_TRAINER_CP)) !== undefined;
|
|
63
|
+
const hasWahooCP = characteristics.find(c => (0, ble_1.matches)(c, consts_1.WAHOO_ADVANCED_TRAINER_CP)) !== undefined;
|
|
65
64
|
const hasFTMS = characteristics.find(c => (0, ble_1.matches)(c, consts_1.FTMS_CP)) !== undefined;
|
|
66
65
|
return hasWahooCP && !hasFTMS;
|
|
67
66
|
}
|
|
@@ -83,7 +82,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
83
82
|
}
|
|
84
83
|
setCharacteristicUUIDs(uuids) {
|
|
85
84
|
uuids.forEach(c => {
|
|
86
|
-
if ((0, ble_1.matches)(c, WAHOO_ADVANCED_TRAINER_CP))
|
|
85
|
+
if ((0, ble_1.matches)(c, consts_1.WAHOO_ADVANCED_TRAINER_CP))
|
|
87
86
|
this.wahooCP = c;
|
|
88
87
|
});
|
|
89
88
|
}
|
|
@@ -336,8 +335,8 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
336
335
|
}
|
|
337
336
|
}
|
|
338
337
|
exports.default = WahooAdvancedFitnessMachineDevice;
|
|
339
|
-
WahooAdvancedFitnessMachineDevice.services = [
|
|
340
|
-
WahooAdvancedFitnessMachineDevice.characteristics = ['2acc', '2ad2', '2ad6', '2ad8', '2ad9', '2ada', WAHOO_ADVANCED_TRAINER_CP];
|
|
338
|
+
WahooAdvancedFitnessMachineDevice.services = [consts_1.CSP];
|
|
339
|
+
WahooAdvancedFitnessMachineDevice.characteristics = ['2acc', '2ad2', '2ad6', '2ad8', '2ad9', '2ada', consts_1.WAHOO_ADVANCED_TRAINER_CP];
|
|
341
340
|
ble_interface_1.default.register('WahooAdvancedFitnessMachineDevice', 'wahoo-fm', WahooAdvancedFitnessMachineDevice, WahooAdvancedFitnessMachineDevice.services);
|
|
342
341
|
class WahooAdvancedFmAdapter extends fm_1.FmAdapter {
|
|
343
342
|
constructor(device, protocol) {
|