incyclist-devices 1.5.38 → 2.0.0-beta.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/README.MD +0 -0
- package/lib/adapters.d.ts +6 -0
- package/lib/adapters.js +30 -0
- package/lib/antv2/adapter-factory.d.ts +20 -10
- package/lib/antv2/adapter-factory.js +49 -33
- package/lib/antv2/adapter.d.ts +64 -0
- package/lib/antv2/adapter.js +299 -0
- package/lib/antv2/ant-interface.d.ts +11 -9
- package/lib/antv2/ant-interface.js +15 -11
- package/lib/antv2/fe/adapter.d.ts +25 -0
- package/lib/antv2/{fe.js → fe/adapter.js} +48 -72
- package/lib/antv2/fe/index.d.ts +2 -0
- package/lib/antv2/fe/index.js +7 -0
- package/lib/antv2/hr/adapter.d.ts +14 -0
- package/lib/antv2/hr/adapter.js +73 -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 +22 -0
- package/lib/antv2/{pwr.js → pwr/adapter.js} +38 -76
- package/lib/antv2/pwr/index.d.ts +2 -0
- package/lib/antv2/pwr/index.js +7 -0
- package/lib/antv2/types.d.ts +19 -0
- package/lib/antv2/types.js +2 -0
- package/lib/antv2/utils.d.ts +1 -0
- package/lib/antv2/utils.js +181 -0
- package/lib/base/adpater.d.ts +56 -0
- package/lib/base/adpater.js +144 -0
- package/lib/ble/adapter-factory.d.ts +31 -0
- package/lib/ble/adapter-factory.js +96 -0
- package/lib/ble/adapter.d.ts +41 -0
- package/lib/ble/adapter.js +188 -0
- package/lib/ble/{ble-device.d.ts → ble-comms.d.ts} +9 -4
- package/lib/ble/{ble-device.js → ble-comms.js} +23 -11
- package/lib/ble/ble-interface.d.ts +15 -24
- package/lib/ble/ble-interface.js +32 -137
- package/lib/ble/ble-peripheral.d.ts +3 -3
- package/lib/ble/ble-peripheral.js +14 -14
- package/lib/ble/ble.d.ts +9 -81
- package/lib/ble/ble.js +1 -39
- package/lib/ble/consts.d.ts +2 -0
- package/lib/ble/consts.js +3 -1
- package/lib/ble/cp/adapter.d.ts +23 -0
- package/lib/ble/cp/adapter.js +124 -0
- package/lib/ble/cp/comm.d.ts +28 -0
- package/lib/ble/cp/comm.js +140 -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 +20 -0
- package/lib/ble/elite/adapter.js +127 -0
- package/lib/ble/elite/comms.d.ts +28 -0
- package/lib/ble/elite/comms.js +139 -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 +21 -0
- package/lib/ble/fm/adapter.js +190 -0
- package/lib/ble/fm/comms.d.ts +50 -0
- package/lib/ble/{fm.js → fm/comms.js} +3 -224
- 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 +25 -0
- package/lib/ble/fm/types.js +2 -0
- package/lib/ble/hr/adapter.d.ts +17 -0
- package/lib/ble/hr/adapter.js +62 -0
- package/lib/ble/hr/comm.d.ts +15 -0
- package/lib/ble/hr/comm.js +52 -0
- package/lib/ble/hr/index.d.ts +4 -0
- package/lib/ble/hr/index.js +10 -0
- package/lib/ble/hr/types.d.ts +5 -0
- package/lib/ble/hr/types.js +2 -0
- package/lib/ble/index.d.ts +8 -0
- package/lib/ble/index.js +26 -0
- package/lib/ble/tacx/adapter.d.ts +10 -0
- package/lib/ble/tacx/adapter.js +93 -0
- package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +6 -38
- package/lib/ble/{tacx.js → tacx/comms.js} +13 -112
- 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 +101 -0
- package/lib/ble/types.js +19 -0
- package/lib/ble/utils.d.ts +7 -0
- package/lib/ble/utils.js +95 -0
- package/lib/ble/wahoo/adapter.d.ts +9 -0
- package/lib/ble/wahoo/adapter.js +93 -0
- package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +5 -39
- package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +14 -112
- 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/device.d.ts +0 -94
- package/lib/device.js +0 -76
- package/lib/index.d.ts +12 -0
- package/lib/index.js +38 -0
- package/lib/interfaces.d.ts +6 -0
- package/lib/interfaces.js +23 -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 +4 -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 +16 -0
- package/lib/serial/adapter.js +42 -0
- package/lib/serial/bindings/tcp.d.ts +44 -0
- package/lib/serial/bindings/tcp.js +270 -0
- package/lib/serial/comm.d.ts +7 -0
- package/lib/serial/comm.js +2 -0
- package/lib/{daum → serial/daum}/DaumAdapter.d.ts +13 -22
- package/lib/{daum → serial/daum}/DaumAdapter.js +44 -90
- 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 +24 -0
- package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +99 -46
- 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} +208 -420
- package/lib/serial/daum/premium/mock.d.ts +75 -0
- package/lib/serial/daum/premium/mock.js +290 -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 +13 -24
- package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +87 -130
- 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 +58 -0
- package/lib/serial/serial-interface.js +283 -0
- package/lib/simulator/Simulator.d.ts +10 -25
- package/lib/simulator/Simulator.js +19 -83
- package/lib/types/adapter.d.ts +32 -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 +29 -0
- package/lib/types/device.js +11 -0
- package/lib/types/interface.d.ts +14 -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 +15 -11
- 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/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/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/antv2/{ant-binding.d.ts → binding.d.ts} +0 -0
- /package/lib/antv2/{ant-binding.js → binding.js} +0 -0
- /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/utils.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getServicesFromDevice = exports.getServicesFromDeviceTypes = exports.getDevicesFromServices = exports.getBestDeviceMatch = exports.matches = exports.uuid = void 0;
|
|
4
|
+
function uuid(s) {
|
|
5
|
+
if (s) {
|
|
6
|
+
if (s.includes('-')) {
|
|
7
|
+
const parts = s.split('-');
|
|
8
|
+
const uuidNo = parseInt('0x' + parts[0]);
|
|
9
|
+
return uuidNo.toString(16).toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
return s;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.uuid = uuid;
|
|
15
|
+
function matches(uuid1, uuid2) {
|
|
16
|
+
const ul1 = uuid1.toLowerCase();
|
|
17
|
+
const ul2 = uuid2.toLowerCase();
|
|
18
|
+
if (uuid(ul1) === uuid(ul2))
|
|
19
|
+
return true;
|
|
20
|
+
if (ul1.length < ul2.length && ul2.startsWith(ul1))
|
|
21
|
+
return true;
|
|
22
|
+
if (ul1.length > ul2.length && ul1.startsWith(ul2))
|
|
23
|
+
return true;
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
exports.matches = matches;
|
|
27
|
+
function getBestDeviceMatch(DeviceClasses) {
|
|
28
|
+
if (!DeviceClasses || DeviceClasses.length === 0)
|
|
29
|
+
return;
|
|
30
|
+
const details = DeviceClasses.map(c => ({ name: c.prototype.constructor.name, priority: c.detectionPriority || 0, class: c }));
|
|
31
|
+
details.sort((a, b) => b.priority - a.priority);
|
|
32
|
+
return details[0].class;
|
|
33
|
+
}
|
|
34
|
+
exports.getBestDeviceMatch = getBestDeviceMatch;
|
|
35
|
+
function getDevicesFromServices(deviceTypes, services) {
|
|
36
|
+
if (!deviceTypes || !Array.isArray(deviceTypes) || deviceTypes.length === 0) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
const get = (deviceTypes, fnCompare) => {
|
|
40
|
+
const types = deviceTypes.filter(DeviceType => {
|
|
41
|
+
const C = DeviceType;
|
|
42
|
+
let found = false;
|
|
43
|
+
if (C.services)
|
|
44
|
+
found = C.services.find((s) => fnCompare(s));
|
|
45
|
+
return found;
|
|
46
|
+
});
|
|
47
|
+
return types;
|
|
48
|
+
};
|
|
49
|
+
if (typeof services === 'string') {
|
|
50
|
+
return get(deviceTypes, (s) => matches(s, services));
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(services)) {
|
|
53
|
+
const sids = services.map(uuid);
|
|
54
|
+
return get(deviceTypes, s => {
|
|
55
|
+
const res = sids.find((service) => matches(s, service));
|
|
56
|
+
return res !== undefined;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
exports.getDevicesFromServices = getDevicesFromServices;
|
|
62
|
+
function getServicesFromDeviceTypes(deviceTypes) {
|
|
63
|
+
let services = [];
|
|
64
|
+
try {
|
|
65
|
+
if (!deviceTypes || !Array.isArray(deviceTypes) || deviceTypes.length === 0) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
deviceTypes.forEach(DeviceType => {
|
|
69
|
+
if (DeviceType.services) {
|
|
70
|
+
const dtServices = DeviceType.services;
|
|
71
|
+
dtServices.forEach(s => {
|
|
72
|
+
if (!services.find(s2 => s2 === s))
|
|
73
|
+
services.push(s);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
console.log(err);
|
|
80
|
+
}
|
|
81
|
+
return services;
|
|
82
|
+
}
|
|
83
|
+
exports.getServicesFromDeviceTypes = getServicesFromDeviceTypes;
|
|
84
|
+
function getServicesFromDevice(device) {
|
|
85
|
+
if (!device)
|
|
86
|
+
return [];
|
|
87
|
+
const services = [];
|
|
88
|
+
const dServices = device.getServiceUUids();
|
|
89
|
+
dServices.forEach(s => {
|
|
90
|
+
if (!services.find(s2 => s2 === s))
|
|
91
|
+
services.push(s);
|
|
92
|
+
});
|
|
93
|
+
return services;
|
|
94
|
+
}
|
|
95
|
+
exports.getServicesFromDevice = getServicesFromDevice;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BleFmAdapter } from '../fm';
|
|
2
|
+
import BleAdapter from '../adapter';
|
|
3
|
+
import { BleDeviceProperties, BleDeviceSettings, BleStartProperties } from '../types';
|
|
4
|
+
export default class BleWahooAdapter extends BleFmAdapter {
|
|
5
|
+
constructor(settings: BleDeviceSettings, props?: BleDeviceProperties);
|
|
6
|
+
isSame(device: BleAdapter): boolean;
|
|
7
|
+
getProfile(): string;
|
|
8
|
+
start(props?: BleStartProperties): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
16
|
+
const fm_1 = require("../fm");
|
|
17
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
18
|
+
const adpater_1 = require("../../base/adpater");
|
|
19
|
+
const capabilities_1 = require("../../types/capabilities");
|
|
20
|
+
class BleWahooAdapter extends fm_1.BleFmAdapter {
|
|
21
|
+
constructor(settings, props) {
|
|
22
|
+
super(settings, props);
|
|
23
|
+
this.logger = new gd_eventlog_1.EventLogger('BLE-WahooFM');
|
|
24
|
+
const { id, address, name } = settings;
|
|
25
|
+
const logger = this.logger;
|
|
26
|
+
const ble = this.ble;
|
|
27
|
+
this.device = new comms_1.default({ id, address, name, ble, logger });
|
|
28
|
+
this.capabilities = [
|
|
29
|
+
capabilities_1.IncyclistCapability.Power, capabilities_1.IncyclistCapability.Speed, capabilities_1.IncyclistCapability.Cadence,
|
|
30
|
+
capabilities_1.IncyclistCapability.Control
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
isSame(device) {
|
|
34
|
+
if (!(device instanceof BleWahooAdapter))
|
|
35
|
+
return false;
|
|
36
|
+
return this.isEqual(device.settings);
|
|
37
|
+
}
|
|
38
|
+
getProfile() {
|
|
39
|
+
return 'Smart Trainer';
|
|
40
|
+
}
|
|
41
|
+
start(props = {}) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
this.logger.logEvent({ message: 'start requested', protocol: this.getProtocolName(), props });
|
|
44
|
+
try {
|
|
45
|
+
if (this.ble.isScanning()) {
|
|
46
|
+
this.logger.logEvent({ message: 'stop previous scan', isScanning: this.ble.isScanning() });
|
|
47
|
+
yield this.ble.stopScan();
|
|
48
|
+
}
|
|
49
|
+
const bleDevice = yield this.ble.connectDevice(this.device);
|
|
50
|
+
if (bleDevice) {
|
|
51
|
+
this.device = bleDevice;
|
|
52
|
+
const mode = this.getCyclingMode();
|
|
53
|
+
if (mode && mode.getSetting('bikeType')) {
|
|
54
|
+
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
55
|
+
bleDevice.setCrr(fm_1.cRR);
|
|
56
|
+
switch (bikeType) {
|
|
57
|
+
case 'race':
|
|
58
|
+
bleDevice.setCw(fm_1.cwABike.race);
|
|
59
|
+
break;
|
|
60
|
+
case 'triathlon':
|
|
61
|
+
bleDevice.setCw(fm_1.cwABike.triathlon);
|
|
62
|
+
break;
|
|
63
|
+
case 'mountain':
|
|
64
|
+
bleDevice.setCw(fm_1.cwABike.mountain);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const { user, bikeWeight = adpater_1.DEFAULT_BIKE_WEIGHT } = props || {};
|
|
69
|
+
const weight = (user && user.weight ? Number(user.weight) : adpater_1.DEFAULT_USER_WEIGHT) + bikeWeight;
|
|
70
|
+
yield bleDevice.setSimMode(weight, bleDevice.getCrr(), bleDevice.getCw());
|
|
71
|
+
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
72
|
+
yield this.sendUpdate(startRequest);
|
|
73
|
+
bleDevice.on('data', (data) => {
|
|
74
|
+
this.onDeviceData(data);
|
|
75
|
+
});
|
|
76
|
+
if (bleDevice.isHrm() && !this.hasCapability(capabilities_1.IncyclistCapability.HeartRate)) {
|
|
77
|
+
this.capabilities.push(capabilities_1.IncyclistCapability.HeartRate);
|
|
78
|
+
}
|
|
79
|
+
this.resetData();
|
|
80
|
+
this.stopped = false;
|
|
81
|
+
this.started = true;
|
|
82
|
+
this.paused = false;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
88
|
+
throw new Error(`could not start device, reason:${err.message}`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.default = BleWahooAdapter;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import { CrankData } from "../cp";
|
|
3
|
+
import { IndoorBikeData } from "../fm";
|
|
4
|
+
import BleFitnessMachineDevice from "../fm/comms";
|
|
5
|
+
import { BleWriteProps } from "../types";
|
|
6
6
|
export declare const enum OpCode {
|
|
7
7
|
unlock = 32,
|
|
8
8
|
setResistanceMode = 64,
|
|
@@ -15,31 +15,7 @@ export declare const enum OpCode {
|
|
|
15
15
|
setSimWindSpeed = 71,
|
|
16
16
|
setWheelCircumference = 72
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
speed?: number;
|
|
20
|
-
averageSpeed?: number;
|
|
21
|
-
cadence?: number;
|
|
22
|
-
averageCadence?: number;
|
|
23
|
-
totalDistance?: number;
|
|
24
|
-
resistanceLevel?: number;
|
|
25
|
-
instantaneousPower?: number;
|
|
26
|
-
averagePower?: number;
|
|
27
|
-
expendedEnergy?: number;
|
|
28
|
-
heartrate?: number;
|
|
29
|
-
metabolicEquivalent?: number;
|
|
30
|
-
time?: number;
|
|
31
|
-
remainingTime?: number;
|
|
32
|
-
raw?: string;
|
|
33
|
-
targetPower?: number;
|
|
34
|
-
targetInclination?: number;
|
|
35
|
-
status?: string;
|
|
36
|
-
};
|
|
37
|
-
declare type CrankData = {
|
|
38
|
-
revolutions?: number;
|
|
39
|
-
time?: number;
|
|
40
|
-
cntUpdateMissing?: number;
|
|
41
|
-
};
|
|
42
|
-
export default class WahooAdvancedFitnessMachineDevice extends BleFitnessMachineDevice {
|
|
18
|
+
export default class BleWahooDevice extends BleFitnessMachineDevice {
|
|
43
19
|
static services: string[];
|
|
44
20
|
static characteristics: string[];
|
|
45
21
|
static detectionPriority: number;
|
|
@@ -86,13 +62,3 @@ export default class WahooAdvancedFitnessMachineDevice extends BleFitnessMachine
|
|
|
86
62
|
setSlope(slope: any): Promise<boolean>;
|
|
87
63
|
reset(): void;
|
|
88
64
|
}
|
|
89
|
-
export declare class WahooAdvancedFmAdapter extends FmAdapter {
|
|
90
|
-
device: WahooAdvancedFitnessMachineDevice;
|
|
91
|
-
constructor(device: BleDeviceClass, protocol: BleProtocol);
|
|
92
|
-
isSame(device: DeviceAdapter): boolean;
|
|
93
|
-
getProfile(): string;
|
|
94
|
-
start(props?: any): Promise<any>;
|
|
95
|
-
pause(): Promise<boolean>;
|
|
96
|
-
resume(): Promise<boolean>;
|
|
97
|
-
}
|
|
98
|
-
export {};
|
|
@@ -1,23 +1,4 @@
|
|
|
1
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
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,22 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
13
|
};
|
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const gd_eventlog_1 = require("gd-eventlog");
|
|
39
|
-
const fm_1 = __importStar(require("./fm"));
|
|
40
|
-
const consts_1 = require("./consts");
|
|
41
|
-
const WAHOO_ADVANCED_FTMS = 'a026ee0b';
|
|
42
|
-
const cwABike = {
|
|
43
|
-
race: 0.35,
|
|
44
|
-
triathlon: 0.29,
|
|
45
|
-
mountain: 0.57
|
|
46
|
-
};
|
|
47
|
-
const cRR = 0.0036;
|
|
15
|
+
const adpater_1 = require("../../base/adpater");
|
|
16
|
+
const consts_1 = require("../consts");
|
|
17
|
+
const comms_1 = __importDefault(require("../fm/comms"));
|
|
18
|
+
const utils_1 = require("../utils");
|
|
48
19
|
const ErgWriteDelay = 2000;
|
|
49
|
-
class
|
|
20
|
+
class BleWahooDevice extends comms_1.default {
|
|
50
21
|
constructor(props) {
|
|
51
22
|
super(props);
|
|
52
23
|
this.prevCrankData = undefined;
|
|
@@ -55,15 +26,15 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
55
26
|
this.tsPrevWrite = undefined;
|
|
56
27
|
this.prevSlope = undefined;
|
|
57
28
|
this.isRequestControlBusy = false;
|
|
58
|
-
this.weight =
|
|
29
|
+
this.weight = adpater_1.DEFAULT_BIKE_WEIGHT + adpater_1.DEFAULT_USER_WEIGHT;
|
|
59
30
|
this.data = {};
|
|
60
31
|
this.wahooCP = consts_1.WAHOO_ADVANCED_TRAINER_CP;
|
|
61
32
|
}
|
|
62
33
|
isMatching(characteristics) {
|
|
63
34
|
if (!characteristics)
|
|
64
35
|
return false;
|
|
65
|
-
const hasWahooCP = characteristics.find(c => (0,
|
|
66
|
-
const hasFTMS = characteristics.find(c => (0,
|
|
36
|
+
const hasWahooCP = characteristics.find(c => (0, utils_1.matches)(c, consts_1.WAHOO_ADVANCED_TRAINER_CP)) !== undefined;
|
|
37
|
+
const hasFTMS = characteristics.find(c => (0, utils_1.matches)(c, consts_1.FTMS_CP)) !== undefined;
|
|
67
38
|
return hasWahooCP && !hasFTMS;
|
|
68
39
|
}
|
|
69
40
|
init() {
|
|
@@ -91,7 +62,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
91
62
|
setCharacteristicUUIDs(uuids) {
|
|
92
63
|
this.logEvent({ message: 'set uuids', uuids });
|
|
93
64
|
uuids.forEach(c => {
|
|
94
|
-
if ((0,
|
|
65
|
+
if ((0, utils_1.matches)(c, consts_1.WAHOO_ADVANCED_TRAINER_CP))
|
|
95
66
|
this.wahooCP = c;
|
|
96
67
|
});
|
|
97
68
|
}
|
|
@@ -99,7 +70,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
99
70
|
return 'Wahoo Smart Trainer';
|
|
100
71
|
}
|
|
101
72
|
getServiceUUids() {
|
|
102
|
-
return
|
|
73
|
+
return BleWahooDevice.services;
|
|
103
74
|
}
|
|
104
75
|
isBike() {
|
|
105
76
|
return true;
|
|
@@ -423,76 +394,7 @@ class WahooAdvancedFitnessMachineDevice extends fm_1.default {
|
|
|
423
394
|
this.simModeSettings = undefined;
|
|
424
395
|
}
|
|
425
396
|
}
|
|
426
|
-
exports.default =
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
ble_interface_1.default.register('WahooAdvancedFitnessMachineDevice', 'wahoo-fm', WahooAdvancedFitnessMachineDevice, WahooAdvancedFitnessMachineDevice.services);
|
|
431
|
-
class WahooAdvancedFmAdapter extends fm_1.FmAdapter {
|
|
432
|
-
constructor(device, protocol) {
|
|
433
|
-
super(device, protocol);
|
|
434
|
-
this.device = device;
|
|
435
|
-
this.ble = protocol.ble;
|
|
436
|
-
this.cyclingMode = this.getDefaultCyclingMode();
|
|
437
|
-
this.logger = new gd_eventlog_1.EventLogger('BLE-WahooFM');
|
|
438
|
-
if (this.device)
|
|
439
|
-
this.device.setLogger(this.logger);
|
|
440
|
-
}
|
|
441
|
-
isSame(device) {
|
|
442
|
-
if (!(device instanceof WahooAdvancedFmAdapter))
|
|
443
|
-
return false;
|
|
444
|
-
const adapter = device;
|
|
445
|
-
return (adapter.getName() === this.getName() && adapter.getProfile() === this.getProfile());
|
|
446
|
-
}
|
|
447
|
-
getProfile() {
|
|
448
|
-
return 'Wahoo Smart Trainer';
|
|
449
|
-
}
|
|
450
|
-
start(props) {
|
|
451
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
452
|
-
this.logger.logEvent({ message: 'wahoo: start requested', profile: this.getProfile(), props, isScanning: this.ble.isScanning() });
|
|
453
|
-
try {
|
|
454
|
-
this.logger.logEvent({ message: 'wahoo: stop previous scan', isScanning: this.ble.isScanning() });
|
|
455
|
-
if (this.ble.isScanning())
|
|
456
|
-
yield this.ble.stopScan();
|
|
457
|
-
this.logger.logEvent({ message: 'wahoo trying device connect' });
|
|
458
|
-
const bleDevice = yield this.ble.connectDevice(this.device);
|
|
459
|
-
this.logger.logEvent({ message: 'wahoo device connected', connected: (bleDevice !== null && bleDevice !== undefined) });
|
|
460
|
-
if (bleDevice) {
|
|
461
|
-
this.device = bleDevice;
|
|
462
|
-
const mode = this.getCyclingMode();
|
|
463
|
-
if (mode && mode.getSetting('bikeType')) {
|
|
464
|
-
const bikeType = mode.getSetting('bikeType').toLowerCase();
|
|
465
|
-
this.device.setCrr(cRR);
|
|
466
|
-
switch (bikeType) {
|
|
467
|
-
case 'race':
|
|
468
|
-
this.device.setCw(cwABike.race);
|
|
469
|
-
break;
|
|
470
|
-
case 'triathlon':
|
|
471
|
-
this.device.setCw(cwABike.triathlon);
|
|
472
|
-
break;
|
|
473
|
-
case 'mountain':
|
|
474
|
-
this.device.setCw(cwABike.mountain);
|
|
475
|
-
break;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
const { user } = props || {};
|
|
479
|
-
const weight = (user && user.weight ? Number(user.weight) : device_1.DEFAULT_USER_WEIGHT) + device_1.DEFAULT_BIKE_WEIGHT;
|
|
480
|
-
yield this.device.setSimMode(weight, this.device.getCrr(), this.device.getCw());
|
|
481
|
-
const startRequest = this.getCyclingMode().getBikeInitRequest();
|
|
482
|
-
yield this.sendUpdate(startRequest);
|
|
483
|
-
bleDevice.on('data', (data) => {
|
|
484
|
-
this.onDeviceData(data);
|
|
485
|
-
});
|
|
486
|
-
return true;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
catch (err) {
|
|
490
|
-
this.logger.logEvent({ message: 'start result: error', error: err.message, profile: this.getProfile() });
|
|
491
|
-
throw new Error(`could not start device, reason:${err.message}`);
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
pause() { this.paused = true; return Promise.resolve(true); }
|
|
496
|
-
resume() { this.paused = false; return Promise.resolve(true); }
|
|
497
|
-
}
|
|
498
|
-
exports.WahooAdvancedFmAdapter = WahooAdvancedFmAdapter;
|
|
397
|
+
exports.default = BleWahooDevice;
|
|
398
|
+
BleWahooDevice.services = [consts_1.CSP];
|
|
399
|
+
BleWahooDevice.characteristics = ['2acc', '2ad2', '2ad6', '2ad8', '2ad9', '2ada', consts_1.WAHOO_ADVANCED_TRAINER_CP];
|
|
400
|
+
BleWahooDevice.detectionPriority = 5;
|
|
@@ -0,0 +1,10 @@
|
|
|
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.BleWahooComms = exports.BleWahooAdapter = void 0;
|
|
7
|
+
const comms_1 = __importDefault(require("./comms"));
|
|
8
|
+
exports.BleWahooComms = comms_1.default;
|
|
9
|
+
const adapter_1 = __importDefault(require("./adapter"));
|
|
10
|
+
exports.BleWahooAdapter = adapter_1.default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type IndoorBikeData = {
|
|
2
|
+
speed?: number;
|
|
3
|
+
averageSpeed?: number;
|
|
4
|
+
cadence?: number;
|
|
5
|
+
averageCadence?: number;
|
|
6
|
+
totalDistance?: number;
|
|
7
|
+
resistanceLevel?: number;
|
|
8
|
+
instantaneousPower?: number;
|
|
9
|
+
averagePower?: number;
|
|
10
|
+
expendedEnergy?: number;
|
|
11
|
+
heartrate?: number;
|
|
12
|
+
metabolicEquivalent?: number;
|
|
13
|
+
time?: number;
|
|
14
|
+
remainingTime?: number;
|
|
15
|
+
raw?: string;
|
|
16
|
+
targetPower?: number;
|
|
17
|
+
targetInclination?: number;
|
|
18
|
+
status?: string;
|
|
19
|
+
};
|
package/lib/device.d.ts
CHANGED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { DeviceProtocol, Device } from './protocol';
|
|
3
|
-
import CyclingMode from './cycling-mode';
|
|
4
|
-
import EventEmitter from 'events';
|
|
5
|
-
export declare const DEFAULT_BIKE_WEIGHT = 10;
|
|
6
|
-
export declare const DEFAULT_USER_WEIGHT = 75;
|
|
7
|
-
export declare type DeviceData = {
|
|
8
|
-
speed?: number;
|
|
9
|
-
slope?: number;
|
|
10
|
-
power?: number;
|
|
11
|
-
cadence?: number;
|
|
12
|
-
heartrate?: number;
|
|
13
|
-
distance?: number;
|
|
14
|
-
timestamp?: number;
|
|
15
|
-
deviceTime?: number;
|
|
16
|
-
deviceDistanceCounter?: number;
|
|
17
|
-
internalDistanceCounter?: number;
|
|
18
|
-
};
|
|
19
|
-
export declare type OnDeviceDataCallback = (data: DeviceData) => void;
|
|
20
|
-
export declare type OnDeviceStartCallback = (completed: number, total: number) => void;
|
|
21
|
-
export interface Bike {
|
|
22
|
-
setCyclingMode(mode: CyclingMode | string, settings?: any): void;
|
|
23
|
-
getSupportedCyclingModes(): Array<any>;
|
|
24
|
-
getCyclingMode(): CyclingMode;
|
|
25
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
26
|
-
setUserSettings(userSettings: any): void;
|
|
27
|
-
setBikeSettings(bikeSettings: any): void;
|
|
28
|
-
}
|
|
29
|
-
export interface DeviceAdapter extends Device {
|
|
30
|
-
isBike(): boolean;
|
|
31
|
-
isPower(): boolean;
|
|
32
|
-
isHrm(): boolean;
|
|
33
|
-
isSame(device: DeviceAdapter): boolean;
|
|
34
|
-
getID(): string;
|
|
35
|
-
getDisplayName(): string;
|
|
36
|
-
getName(): string;
|
|
37
|
-
getPort(): string;
|
|
38
|
-
getProtocol(): DeviceProtocol;
|
|
39
|
-
getProtocolName(): string;
|
|
40
|
-
setIgnoreHrm(ignore: boolean): void;
|
|
41
|
-
setIgnorePower(ignore: boolean): void;
|
|
42
|
-
setIgnoreBike(ignore: boolean): void;
|
|
43
|
-
select(): void;
|
|
44
|
-
unselect(): void;
|
|
45
|
-
isSelected(): boolean;
|
|
46
|
-
setDetected(detected?: boolean): void;
|
|
47
|
-
isDetected(): boolean;
|
|
48
|
-
start(props?: any): Promise<any>;
|
|
49
|
-
stop(): Promise<boolean>;
|
|
50
|
-
pause(): Promise<boolean>;
|
|
51
|
-
resume(): Promise<boolean>;
|
|
52
|
-
sendUpdate(request: any): void;
|
|
53
|
-
onData(callback: OnDeviceDataCallback): void;
|
|
54
|
-
}
|
|
55
|
-
export default class IncyclistDevice extends EventEmitter implements DeviceAdapter {
|
|
56
|
-
protocol: DeviceProtocol;
|
|
57
|
-
detected: boolean;
|
|
58
|
-
selected: boolean;
|
|
59
|
-
onDataFn: OnDeviceDataCallback;
|
|
60
|
-
settings: any;
|
|
61
|
-
constructor(proto: DeviceProtocol, settings?: any);
|
|
62
|
-
isBike(): boolean;
|
|
63
|
-
isPower(): boolean;
|
|
64
|
-
isHrm(): boolean;
|
|
65
|
-
isSame(device: DeviceAdapter): boolean;
|
|
66
|
-
getID(): string;
|
|
67
|
-
getDisplayName(): string;
|
|
68
|
-
getName(): string;
|
|
69
|
-
getPort(): string;
|
|
70
|
-
getProtocol(): DeviceProtocol;
|
|
71
|
-
getProtocolName(): string;
|
|
72
|
-
getSupportedCyclingModes(): any[];
|
|
73
|
-
getDefaultCyclingMode(): CyclingMode;
|
|
74
|
-
setCyclingMode(mode: CyclingMode | string, settings?: any): void;
|
|
75
|
-
getCyclingMode(): CyclingMode;
|
|
76
|
-
setIgnoreHrm(ignore: any): void;
|
|
77
|
-
setIgnorePower(ignore: any): void;
|
|
78
|
-
setIgnoreBike(ignore: any): void;
|
|
79
|
-
select(): void;
|
|
80
|
-
unselect(): void;
|
|
81
|
-
isSelected(): boolean;
|
|
82
|
-
setDetected(detected?: boolean): void;
|
|
83
|
-
isDetected(): boolean;
|
|
84
|
-
update(): void;
|
|
85
|
-
check(): void;
|
|
86
|
-
connect(): void;
|
|
87
|
-
close(): void;
|
|
88
|
-
start(props?: any): Promise<any>;
|
|
89
|
-
stop(): Promise<boolean>;
|
|
90
|
-
pause(): Promise<boolean>;
|
|
91
|
-
resume(): Promise<boolean>;
|
|
92
|
-
sendUpdate(request: any): void;
|
|
93
|
-
onData(callback: OnDeviceDataCallback): void;
|
|
94
|
-
}
|
package/lib/device.js
CHANGED
|
@@ -1,76 +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.DEFAULT_USER_WEIGHT = exports.DEFAULT_BIKE_WEIGHT = void 0;
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
exports.DEFAULT_BIKE_WEIGHT = 10;
|
|
9
|
-
exports.DEFAULT_USER_WEIGHT = 75;
|
|
10
|
-
class IncyclistDevice extends events_1.default {
|
|
11
|
-
constructor(proto, settings) {
|
|
12
|
-
super();
|
|
13
|
-
this.protocol = proto;
|
|
14
|
-
this.detected = false;
|
|
15
|
-
this.selected = false;
|
|
16
|
-
this.onDataFn = undefined;
|
|
17
|
-
this.settings = settings || {};
|
|
18
|
-
}
|
|
19
|
-
isBike() { throw new Error('not implemented'); }
|
|
20
|
-
isPower() { throw new Error('not implemented'); }
|
|
21
|
-
isHrm() { throw new Error('not implemented'); }
|
|
22
|
-
isSame(device) { throw new Error('not implemented'); }
|
|
23
|
-
getID() { throw new Error('not implemented'); }
|
|
24
|
-
getDisplayName() { return this.getName(); }
|
|
25
|
-
getName() { throw new Error('not implemented'); }
|
|
26
|
-
getPort() { throw new Error('not implemented'); }
|
|
27
|
-
getProtocol() { return this.protocol; }
|
|
28
|
-
getProtocolName() {
|
|
29
|
-
return this.protocol ? this.protocol.getName() : undefined;
|
|
30
|
-
}
|
|
31
|
-
getSupportedCyclingModes() { throw new Error('not implemented'); }
|
|
32
|
-
getDefaultCyclingMode() { throw new Error('not implemented'); }
|
|
33
|
-
setCyclingMode(mode, settings) {
|
|
34
|
-
let selectedMode;
|
|
35
|
-
if (typeof mode === 'string') {
|
|
36
|
-
const supported = this.getSupportedCyclingModes();
|
|
37
|
-
const CyclingModeClass = supported.find(M => { const m = new M(this); return m.getName() === mode; });
|
|
38
|
-
if (CyclingModeClass) {
|
|
39
|
-
this.settings.cyclingMode = new CyclingModeClass(this, settings);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
selectedMode = this.getDefaultCyclingMode();
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
selectedMode = mode;
|
|
46
|
-
}
|
|
47
|
-
this.settings.cyclingMode = selectedMode;
|
|
48
|
-
this.settings.cyclingMode.setSettings(settings);
|
|
49
|
-
}
|
|
50
|
-
getCyclingMode() {
|
|
51
|
-
if (!this.settings.cyclingMode)
|
|
52
|
-
this.setCyclingMode(this.getDefaultCyclingMode());
|
|
53
|
-
return this.settings.cyclingMode;
|
|
54
|
-
}
|
|
55
|
-
setIgnoreHrm(ignore) { }
|
|
56
|
-
setIgnorePower(ignore) { }
|
|
57
|
-
setIgnoreBike(ignore) { }
|
|
58
|
-
select() { this.selected = true; }
|
|
59
|
-
unselect() { this.selected = false; }
|
|
60
|
-
isSelected() { return this.selected; }
|
|
61
|
-
setDetected(detected = true) { this.detected = detected; }
|
|
62
|
-
isDetected() { return this.detected; }
|
|
63
|
-
update() { }
|
|
64
|
-
check() { }
|
|
65
|
-
connect() { }
|
|
66
|
-
close() { }
|
|
67
|
-
start(props) { throw new Error('not implemented'); }
|
|
68
|
-
stop() { throw new Error('not implemented'); }
|
|
69
|
-
pause() { throw new Error('not implemented'); }
|
|
70
|
-
resume() { throw new Error('not implemented'); }
|
|
71
|
-
sendUpdate(request) { }
|
|
72
|
-
onData(callback) {
|
|
73
|
-
this.onDataFn = callback;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.default = IncyclistDevice;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { INTERFACE } from './types/device';
|
|
2
|
+
import InterfaceFactory from './interfaces';
|
|
3
|
+
import AdapterFactory from './adapters';
|
|
4
|
+
import { IncyclistInterface } from './types/interface';
|
|
5
|
+
import { IncyclistDeviceAdapter } from './types/adapter';
|
|
6
|
+
import { IncyclistCapability } from './types/capabilities';
|
|
7
|
+
import { DeviceData } from './types/data';
|
|
8
|
+
import { SerialPortProvider, useSerialPortProvider, SerialInterface, TCPBinding, DaumPremiumAdapter, DaumClassicAdapter, KettlerRacerAdapter } from './serial';
|
|
9
|
+
import { AntAdapterFactory, AntFEAdapter, AntHrAdapter, AntPwrAdapter, AntDeviceSettings, AntScanProps, AntInterface } from './antv2';
|
|
10
|
+
import { BleAdapterFactory, BleInterface, BleHrmAdapter, BlePwrAdapter, BleFmAdapter, BleWahooAdapter, BleTacxAdapter } from './ble';
|
|
11
|
+
import { CyclingModeProperyType } from './modes/cycling-mode';
|
|
12
|
+
export { IncyclistInterface, INTERFACE, InterfaceFactory, AdapterFactory, IncyclistDeviceAdapter, DeviceData, IncyclistCapability, AntAdapterFactory, AntFEAdapter, AntHrAdapter, AntPwrAdapter, AntDeviceSettings, AntScanProps, AntInterface, CyclingModeProperyType, BleAdapterFactory, BleInterface, BleHrmAdapter, BlePwrAdapter, BleFmAdapter, BleWahooAdapter, BleTacxAdapter, SerialPortProvider, useSerialPortProvider, SerialInterface, TCPBinding, DaumClassicAdapter, DaumPremiumAdapter, KettlerRacerAdapter };
|