incyclist-devices 1.5.37 → 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.
Files changed (251) hide show
  1. package/README.MD +0 -0
  2. package/lib/adapters.d.ts +6 -0
  3. package/lib/adapters.js +30 -0
  4. package/lib/antv2/adapter-factory.d.ts +20 -10
  5. package/lib/antv2/adapter-factory.js +49 -33
  6. package/lib/antv2/adapter.d.ts +64 -0
  7. package/lib/antv2/adapter.js +299 -0
  8. package/lib/antv2/ant-interface.d.ts +11 -9
  9. package/lib/antv2/ant-interface.js +15 -11
  10. package/lib/antv2/fe/adapter.d.ts +25 -0
  11. package/lib/antv2/{fe.js → fe/adapter.js} +48 -72
  12. package/lib/antv2/fe/index.d.ts +2 -0
  13. package/lib/antv2/fe/index.js +7 -0
  14. package/lib/antv2/hr/adapter.d.ts +14 -0
  15. package/lib/antv2/hr/adapter.js +73 -0
  16. package/lib/antv2/hr/index.d.ts +2 -0
  17. package/lib/antv2/hr/index.js +7 -0
  18. package/lib/antv2/index.d.ts +7 -0
  19. package/lib/antv2/index.js +20 -0
  20. package/lib/antv2/modes/ant-fe-adv-st-mode.d.ts +9 -0
  21. package/lib/{ant/antfe → antv2/modes}/ant-fe-adv-st-mode.js +1 -1
  22. package/lib/antv2/modes/ant-fe-erg-mode.d.ts +6 -0
  23. package/lib/{ant/antfe → antv2/modes}/ant-fe-erg-mode.js +1 -1
  24. package/lib/antv2/modes/ant-fe-st-mode.d.ts +5 -0
  25. package/lib/{ant/antfe → antv2/modes}/ant-fe-st-mode.js +1 -1
  26. package/lib/antv2/pwr/adapter.d.ts +22 -0
  27. package/lib/antv2/{pwr.js → pwr/adapter.js} +38 -76
  28. package/lib/antv2/pwr/index.d.ts +2 -0
  29. package/lib/antv2/pwr/index.js +7 -0
  30. package/lib/antv2/types.d.ts +19 -0
  31. package/lib/antv2/types.js +2 -0
  32. package/lib/antv2/utils.d.ts +1 -0
  33. package/lib/antv2/utils.js +181 -0
  34. package/lib/base/adpater.d.ts +56 -0
  35. package/lib/base/adpater.js +144 -0
  36. package/lib/ble/adapter-factory.d.ts +31 -0
  37. package/lib/ble/adapter-factory.js +96 -0
  38. package/lib/ble/adapter.d.ts +41 -0
  39. package/lib/ble/adapter.js +188 -0
  40. package/lib/ble/{ble-device.d.ts → ble-comms.d.ts} +9 -4
  41. package/lib/ble/{ble-device.js → ble-comms.js} +23 -11
  42. package/lib/ble/ble-interface.d.ts +15 -24
  43. package/lib/ble/ble-interface.js +32 -137
  44. package/lib/ble/ble-peripheral.d.ts +3 -3
  45. package/lib/ble/ble-peripheral.js +14 -14
  46. package/lib/ble/ble.d.ts +9 -81
  47. package/lib/ble/ble.js +1 -39
  48. package/lib/ble/consts.d.ts +2 -0
  49. package/lib/ble/consts.js +3 -1
  50. package/lib/ble/cp/adapter.d.ts +23 -0
  51. package/lib/ble/cp/adapter.js +124 -0
  52. package/lib/ble/cp/comm.d.ts +28 -0
  53. package/lib/ble/cp/comm.js +140 -0
  54. package/lib/ble/cp/index.d.ts +4 -0
  55. package/lib/ble/cp/index.js +10 -0
  56. package/lib/ble/cp/types.d.ts +13 -0
  57. package/lib/ble/cp/types.js +2 -0
  58. package/lib/ble/elite/adapter.d.ts +20 -0
  59. package/lib/ble/elite/adapter.js +127 -0
  60. package/lib/ble/elite/comms.d.ts +28 -0
  61. package/lib/ble/elite/comms.js +139 -0
  62. package/lib/ble/elite/index.d.ts +3 -0
  63. package/lib/ble/elite/index.js +10 -0
  64. package/lib/ble/fm/adapter.d.ts +21 -0
  65. package/lib/ble/fm/adapter.js +190 -0
  66. package/lib/ble/fm/comms.d.ts +50 -0
  67. package/lib/ble/{fm.js → fm/comms.js} +3 -224
  68. package/lib/ble/fm/consts.d.ts +6 -0
  69. package/lib/ble/fm/consts.js +9 -0
  70. package/lib/ble/fm/index.d.ts +5 -0
  71. package/lib/ble/fm/index.js +13 -0
  72. package/lib/ble/fm/types.d.ts +25 -0
  73. package/lib/ble/fm/types.js +2 -0
  74. package/lib/ble/hr/adapter.d.ts +17 -0
  75. package/lib/ble/hr/adapter.js +62 -0
  76. package/lib/ble/hr/comm.d.ts +15 -0
  77. package/lib/ble/hr/comm.js +52 -0
  78. package/lib/ble/hr/index.d.ts +4 -0
  79. package/lib/ble/hr/index.js +10 -0
  80. package/lib/ble/hr/types.d.ts +5 -0
  81. package/lib/ble/hr/types.js +2 -0
  82. package/lib/ble/index.d.ts +8 -0
  83. package/lib/ble/index.js +26 -0
  84. package/lib/ble/tacx/adapter.d.ts +10 -0
  85. package/lib/ble/tacx/adapter.js +93 -0
  86. package/lib/ble/{tacx.d.ts → tacx/comms.d.ts} +6 -38
  87. package/lib/ble/{tacx.js → tacx/comms.js} +13 -112
  88. package/lib/ble/tacx/index.d.ts +4 -0
  89. package/lib/ble/tacx/index.js +10 -0
  90. package/lib/ble/tacx/types.d.ts +25 -0
  91. package/lib/ble/tacx/types.js +2 -0
  92. package/lib/ble/types.d.ts +101 -0
  93. package/lib/ble/types.js +19 -0
  94. package/lib/ble/utils.d.ts +7 -0
  95. package/lib/ble/utils.js +95 -0
  96. package/lib/ble/wahoo/adapter.d.ts +9 -0
  97. package/lib/ble/wahoo/adapter.js +93 -0
  98. package/lib/ble/{wahoo-kickr.d.ts → wahoo/comms.d.ts} +5 -39
  99. package/lib/ble/{wahoo-kickr.js → wahoo/comms.js} +14 -112
  100. package/lib/ble/wahoo/index.d.ts +4 -0
  101. package/lib/ble/wahoo/index.js +10 -0
  102. package/lib/ble/wahoo/types.d.ts +19 -0
  103. package/lib/ble/wahoo/types.js +2 -0
  104. package/lib/device.d.ts +0 -94
  105. package/lib/device.js +0 -76
  106. package/lib/index.d.ts +12 -0
  107. package/lib/index.js +38 -0
  108. package/lib/interfaces.d.ts +6 -0
  109. package/lib/interfaces.js +23 -0
  110. package/lib/{ble → modes}/ble-erg-mode.d.ts +4 -4
  111. package/lib/{ble → modes}/ble-erg-mode.js +2 -2
  112. package/lib/{ble → modes}/ble-st-mode.d.ts +3 -3
  113. package/lib/{ble → modes}/ble-st-mode.js +1 -1
  114. package/lib/{cycling-mode.d.ts → modes/cycling-mode.d.ts} +8 -8
  115. package/lib/modes/power-base.d.ts +3 -3
  116. package/lib/modes/power-base.js +4 -4
  117. package/lib/modes/power-meter.d.ts +3 -3
  118. package/lib/modes/simulator.d.ts +2 -2
  119. package/lib/modes/simulator.js +1 -1
  120. package/lib/serial/adapter-factory.d.ts +12 -0
  121. package/lib/serial/adapter-factory.js +30 -0
  122. package/lib/serial/adapter.d.ts +16 -0
  123. package/lib/serial/adapter.js +42 -0
  124. package/lib/serial/bindings/tcp.d.ts +44 -0
  125. package/lib/serial/bindings/tcp.js +270 -0
  126. package/lib/serial/comm.d.ts +7 -0
  127. package/lib/serial/comm.js +2 -0
  128. package/lib/{daum → serial/daum}/DaumAdapter.d.ts +13 -22
  129. package/lib/{daum → serial/daum}/DaumAdapter.js +44 -90
  130. package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.d.ts +2 -2
  131. package/lib/{daum → serial/daum}/DaumPowerMeterCyclingMode.js +1 -1
  132. package/lib/{daum → serial/daum}/ERGCyclingMode.d.ts +3 -3
  133. package/lib/{daum → serial/daum}/ERGCyclingMode.js +3 -3
  134. package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.d.ts +3 -3
  135. package/lib/{daum → serial/daum}/SmartTrainerCyclingMode.js +4 -3
  136. package/lib/serial/daum/classic/adapter.d.ts +29 -0
  137. package/lib/{daum/classic/DaumClassicAdapter.js → serial/daum/classic/adapter.js} +77 -50
  138. package/lib/{daum/classic/bike.d.ts → serial/daum/classic/comms.d.ts} +14 -16
  139. package/lib/{daum/classic/bike.js → serial/daum/classic/comms.js} +68 -152
  140. package/lib/serial/daum/classic/mock.d.ts +96 -0
  141. package/lib/serial/daum/classic/mock.js +365 -0
  142. package/lib/{daum/classic/DaumClassicCyclingMode.d.ts → serial/daum/classic/modes/daum-classic.d.ts} +3 -3
  143. package/lib/{daum/classic/DaumClassicCyclingMode.js → serial/daum/classic/modes/daum-classic.js} +2 -2
  144. package/lib/{daum → serial/daum}/classic/utils.d.ts +1 -1
  145. package/lib/serial/daum/premium/adapter.d.ts +24 -0
  146. package/lib/{daum/premium/DaumPremiumAdapter.js → serial/daum/premium/adapter.js} +99 -46
  147. package/lib/{daum/premium/bike.d.ts → serial/daum/premium/comms.d.ts} +26 -54
  148. package/lib/{daum/premium/bike.js → serial/daum/premium/comms.js} +214 -420
  149. package/lib/serial/daum/premium/mock.d.ts +75 -0
  150. package/lib/serial/daum/premium/mock.js +290 -0
  151. package/lib/{daum/premium/DaumClassicCyclingMode.d.ts → serial/daum/premium/modes/daum-classic.d.ts} +3 -3
  152. package/lib/{daum/premium/DaumClassicCyclingMode.js → serial/daum/premium/modes/daum-classic.js} +2 -2
  153. package/lib/serial/daum/premium/types.d.ts +12 -0
  154. package/lib/serial/daum/premium/types.js +2 -0
  155. package/lib/{daum → serial/daum}/premium/utils.d.ts +8 -11
  156. package/lib/{daum → serial/daum}/premium/utils.js +22 -63
  157. package/lib/serial/index.d.ts +9 -0
  158. package/lib/serial/index.js +49 -0
  159. package/lib/{kettler → serial/kettler}/comms.d.ts +8 -6
  160. package/lib/{kettler → serial/kettler}/comms.js +71 -32
  161. package/lib/{kettler → serial/kettler}/ergo-racer/adapter.d.ts +13 -24
  162. package/lib/{kettler → serial/kettler}/ergo-racer/adapter.js +87 -130
  163. package/lib/serial/kettler/ergo-racer/mock.d.ts +66 -0
  164. package/lib/serial/kettler/ergo-racer/mock.js +216 -0
  165. package/lib/{kettler/ergo-racer/ERGCyclingMode.d.ts → serial/kettler/ergo-racer/modes/erg.d.ts} +4 -4
  166. package/lib/{kettler/ergo-racer/ERGCyclingMode.js → serial/kettler/ergo-racer/modes/erg.js} +2 -2
  167. package/lib/serial/serial-interface.d.ts +58 -0
  168. package/lib/serial/serial-interface.js +283 -0
  169. package/lib/simulator/Simulator.d.ts +10 -25
  170. package/lib/simulator/Simulator.js +19 -83
  171. package/lib/types/adapter.d.ts +32 -0
  172. package/lib/types/adapter.js +2 -0
  173. package/lib/types/capabilities.d.ts +8 -0
  174. package/lib/types/capabilities.js +12 -0
  175. package/lib/types/data.d.ts +12 -0
  176. package/lib/types/data.js +2 -0
  177. package/lib/types/device.d.ts +29 -0
  178. package/lib/types/device.js +11 -0
  179. package/lib/types/interface.d.ts +14 -0
  180. package/lib/types/interface.js +2 -0
  181. package/lib/types/route.d.ts +2 -2
  182. package/lib/types/user.d.ts +1 -1
  183. package/lib/{utils.d.ts → utils/utils.d.ts} +1 -0
  184. package/lib/{utils.js → utils/utils.js} +5 -1
  185. package/package.json +15 -11
  186. package/lib/DeviceSupport.d.ts +0 -36
  187. package/lib/DeviceSupport.js +0 -82
  188. package/lib/ant/AntAdapter.d.ts +0 -50
  189. package/lib/ant/AntAdapter.js +0 -109
  190. package/lib/ant/AntScanner.d.ts +0 -60
  191. package/lib/ant/AntScanner.js +0 -651
  192. package/lib/ant/antfe/AntFEAdapter.d.ts +0 -83
  193. package/lib/ant/antfe/AntFEAdapter.js +0 -652
  194. package/lib/ant/antfe/ant-fe-adv-st-mode.d.ts +0 -9
  195. package/lib/ant/antfe/ant-fe-erg-mode.d.ts +0 -6
  196. package/lib/ant/antfe/ant-fe-st-mode.d.ts +0 -5
  197. package/lib/ant/anthrm/AntHrmAdapter.d.ts +0 -16
  198. package/lib/ant/anthrm/AntHrmAdapter.js +0 -130
  199. package/lib/ant/antpwr/pwr-adapter.d.ts +0 -49
  200. package/lib/ant/antpwr/pwr-adapter.js +0 -251
  201. package/lib/ant/utils.d.ts +0 -1
  202. package/lib/ant/utils.js +0 -23
  203. package/lib/antv2/AntAdapter.d.ts +0 -48
  204. package/lib/antv2/AntAdapter.js +0 -104
  205. package/lib/antv2/ant-device.d.ts +0 -59
  206. package/lib/antv2/ant-device.js +0 -161
  207. package/lib/antv2/fe.d.ts +0 -32
  208. package/lib/antv2/hr.d.ts +0 -18
  209. package/lib/antv2/hr.js +0 -102
  210. package/lib/antv2/incyclist-protocol.d.ts +0 -37
  211. package/lib/antv2/incyclist-protocol.js +0 -126
  212. package/lib/antv2/pwr.d.ts +0 -28
  213. package/lib/ble/elite.d.ts +0 -90
  214. package/lib/ble/elite.js +0 -322
  215. package/lib/ble/fm.d.ts +0 -125
  216. package/lib/ble/hrm.d.ts +0 -48
  217. package/lib/ble/hrm.js +0 -134
  218. package/lib/ble/incyclist-protocol.d.ts +0 -31
  219. package/lib/ble/incyclist-protocol.js +0 -153
  220. package/lib/ble/pwr.d.ts +0 -89
  221. package/lib/ble/pwr.js +0 -322
  222. package/lib/daum/classic/DaumClassicAdapter.d.ts +0 -28
  223. package/lib/daum/classic/DaumClassicProtocol.d.ts +0 -27
  224. package/lib/daum/classic/DaumClassicProtocol.js +0 -185
  225. package/lib/daum/premium/DaumPremiumAdapter.d.ts +0 -16
  226. package/lib/daum/premium/DaumPremiumProtocol.d.ts +0 -32
  227. package/lib/daum/premium/DaumPremiumProtocol.js +0 -207
  228. package/lib/daum/premium/tcpserial.d.ts +0 -33
  229. package/lib/daum/premium/tcpserial.js +0 -123
  230. package/lib/kettler/ergo-racer/protocol.d.ts +0 -41
  231. package/lib/kettler/ergo-racer/protocol.js +0 -203
  232. package/lib/protocol.d.ts +0 -74
  233. package/lib/protocol.js +0 -41
  234. package/lib/registry.d.ts +0 -8
  235. package/lib/registry.js +0 -33
  236. package/lib/serialport/bindings/tcp.d.ts +0 -20
  237. package/lib/serialport/bindings/tcp.js +0 -33
  238. package/lib/serialport/index.d.ts +0 -2
  239. package/lib/serialport/index.js +0 -29
  240. package/lib/serialport/serialport.d.ts +0 -29
  241. package/lib/serialport/serialport.js +0 -87
  242. /package/lib/antv2/{ant-binding.d.ts → binding.d.ts} +0 -0
  243. /package/lib/antv2/{ant-binding.js → binding.js} +0 -0
  244. /package/lib/{cycling-mode.js → modes/cycling-mode.js} +0 -0
  245. /package/lib/{daum → serial/daum}/classic/utils.js +0 -0
  246. /package/lib/{daum → serial/daum}/constants.d.ts +0 -0
  247. /package/lib/{daum → serial/daum}/constants.js +0 -0
  248. /package/lib/{serialport.d.ts → serial/serialport.d.ts} +0 -0
  249. /package/lib/{serialport.js → serial/serialport.js} +0 -0
  250. /package/lib/{calculations.d.ts → utils/calculations.d.ts} +0 -0
  251. /package/lib/{calculations.js → utils/calculations.js} +0 -0
@@ -13,23 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const gd_eventlog_1 = require("gd-eventlog");
16
- const utils_1 = require("../utils");
16
+ const utils_1 = require("../utils/utils");
17
17
  const ble_1 = require("./ble");
18
- const ble_2 = require("./ble");
18
+ const ble_comms_1 = require("./ble-comms");
19
19
  const ble_peripheral_1 = __importDefault(require("./ble-peripheral"));
20
+ const adapter_factory_1 = __importDefault(require("./adapter-factory"));
21
+ const utils_2 = require("./utils");
20
22
  const CONNECT_TIMEOUT = 5000;
21
23
  const DEFAULT_SCAN_TIMEOUT = 20000;
22
24
  class BleInterface extends ble_1.BleInterfaceClass {
23
- constructor(props = {}) {
24
- super(props);
25
- this.scanState = { isScanning: false, isConnecting: false, timeout: undefined, isBackgroundScan: false };
26
- this.connectState = { isConnecting: false, isConnected: false, isInitSuccess: false };
27
- this.devices = [];
28
- this.peripheralCache = [];
29
- if (props.logger)
30
- this.logger = props.logger;
31
- this.logger = new gd_eventlog_1.EventLogger('BLE');
32
- }
33
25
  static getInstance(props = {}) {
34
26
  if (!BleInterface._instance) {
35
27
  BleInterface._instance = new BleInterface(props);
@@ -47,10 +39,18 @@ class BleInterface extends ble_1.BleInterfaceClass {
47
39
  }
48
40
  return BleInterface._instance;
49
41
  }
50
- static register(id, type, Class, services) {
51
- if (this.deviceClasses.find(i => i.id === id))
52
- return;
53
- this.deviceClasses.push({ id, type, Class, services });
42
+ constructor(props = {}) {
43
+ super(props);
44
+ this.scanState = { isScanning: false, isConnecting: false, timeout: undefined, isBackgroundScan: false };
45
+ this.connectState = { isConnecting: false, isConnected: false, isInitSuccess: false };
46
+ this.devices = [];
47
+ this.peripheralCache = [];
48
+ if (props.logger)
49
+ this.logger = props.logger;
50
+ this.logger = new gd_eventlog_1.EventLogger('BLE');
51
+ }
52
+ getAdapterFactory() {
53
+ return adapter_factory_1.default.getInstance();
54
54
  }
55
55
  logEvent(event) {
56
56
  if (this.logger) {
@@ -77,14 +77,14 @@ class BleInterface extends ble_1.BleInterfaceClass {
77
77
  if (this.connectState.isConnected) {
78
78
  return resolve(true);
79
79
  }
80
- this.logEvent({ message: 'connect request', });
80
+ this.logEvent({ message: 'Ble connect request', });
81
81
  if (!this.getBinding())
82
82
  return Promise.reject(new Error('no binding defined'));
83
83
  this.connectState.timeout = setTimeout(() => {
84
84
  this.connectState.isConnected = false;
85
85
  this.connectState.isConnecting = false;
86
86
  this.connectState.timeout = null;
87
- this.logEvent({ message: 'connect result: timeout' });
87
+ this.logEvent({ message: 'Ble connect result: timeout' });
88
88
  reject(new Error('timeout'));
89
89
  }, timeout);
90
90
  try {
@@ -139,7 +139,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
139
139
  this.getBinding().on('stateChange', this.onStateChange.bind(this));
140
140
  this.connectState.isConnected = true;
141
141
  this.connectState.isConnecting = false;
142
- this.logEvent({ message: 'connect result: success' });
142
+ this.logEvent({ message: 'Ble connect result: success' });
143
143
  return resolve(true);
144
144
  }
145
145
  else {
@@ -154,7 +154,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
154
154
  if (this.connectState.timeout)
155
155
  clearTimeout(this.connectState.timeout);
156
156
  this.connectState.timeout = null;
157
- this.logEvent({ message: 'connect result: error', error: err.message });
157
+ this.logEvent({ message: 'Ble connect result: error', error: err.message });
158
158
  return reject(new Error('bluetooth unavailable, cause: ' + err.message));
159
159
  }
160
160
  });
@@ -189,83 +189,6 @@ class BleInterface extends ble_1.BleInterfaceClass {
189
189
  isConnected() {
190
190
  return this.connectState.isConnected;
191
191
  }
192
- getDevicesFromServices(deviceTypes, services) {
193
- if (!deviceTypes || !Array.isArray(deviceTypes) || deviceTypes.length === 0) {
194
- return [];
195
- }
196
- const get = (deviceTypes, fnCompare) => {
197
- const types = deviceTypes.filter(DeviceType => {
198
- const C = DeviceType;
199
- let found = false;
200
- if (C.services)
201
- found = C.services.find((s) => fnCompare(s));
202
- return found;
203
- });
204
- return types;
205
- };
206
- if (typeof services === 'string') {
207
- return get(deviceTypes, (s) => (0, ble_2.matches)(s, services));
208
- }
209
- if (Array.isArray(services)) {
210
- const sids = services.map(ble_1.uuid);
211
- return get(deviceTypes, s => {
212
- const res = sids.find((service) => (0, ble_2.matches)(s, service));
213
- return res !== undefined;
214
- });
215
- }
216
- return [];
217
- }
218
- getAllSupportedServices() {
219
- const supported = BleInterface.deviceClasses;
220
- const res = [];
221
- if (supported && supported.length > 0) {
222
- supported.forEach(dc => {
223
- if (dc && dc.services) {
224
- dc.services.forEach(s => {
225
- if (!res.includes(s))
226
- res.push(s);
227
- });
228
- }
229
- });
230
- }
231
- return res;
232
- }
233
- getAllSupportedDeviceTypes() {
234
- const supported = BleInterface.deviceClasses;
235
- return supported.map(dc => dc.Class);
236
- }
237
- getServicesFromDeviceTypes(deviceTypes) {
238
- let services = [];
239
- try {
240
- if (!deviceTypes || !Array.isArray(deviceTypes) || deviceTypes.length === 0) {
241
- return [];
242
- }
243
- deviceTypes.forEach(DeviceType => {
244
- if (DeviceType.services) {
245
- const dtServices = DeviceType.services;
246
- dtServices.forEach(s => {
247
- if (!services.find(s2 => s2 === s))
248
- services.push(s);
249
- });
250
- }
251
- });
252
- }
253
- catch (err) {
254
- console.log(err);
255
- }
256
- return services;
257
- }
258
- getServicesFromDevice(device) {
259
- if (!device)
260
- return [];
261
- const services = [];
262
- const dServices = device.getServiceUUids();
263
- dServices.forEach(s => {
264
- if (!services.find(s2 => s2 === s))
265
- services.push(s);
266
- });
267
- return services;
268
- }
269
192
  waitForConnectFinished(timeout) {
270
193
  const waitStart = Date.now();
271
194
  const waitTimeout = waitStart + timeout;
@@ -341,31 +264,11 @@ class BleInterface extends ble_1.BleInterfaceClass {
341
264
  return characteristics;
342
265
  });
343
266
  }
344
- getDeviceClasses(peripheral, props = {}) {
345
- let DeviceClasses;
346
- const { deviceTypes, profile, services = peripheral.advertisement.serviceUuids } = props;
347
- if ((!deviceTypes || deviceTypes.length === 0)) {
348
- const classes = BleInterface.deviceClasses.map(c => c.Class);
349
- DeviceClasses = this.getDevicesFromServices(classes, services);
350
- }
351
- else {
352
- DeviceClasses = this.getDevicesFromServices(deviceTypes, services);
353
- }
354
- if (profile && DeviceClasses && DeviceClasses.length > 0) {
355
- DeviceClasses = DeviceClasses.filter(C => {
356
- const device = new C({ peripheral });
357
- if (device.getProfile() !== profile)
358
- return false;
359
- return true;
360
- });
361
- }
362
- return DeviceClasses;
363
- }
364
- createDevice(DeviceClass, peripheral, characteristics) {
267
+ createDeviceComms(DeviceClass, peripheral, characteristics) {
365
268
  try {
366
269
  const C = DeviceClass;
367
270
  const device = new C({ peripheral });
368
- const cids = characteristics ? characteristics.map(c => (0, ble_1.uuid)(c.uuid)) : [];
271
+ const cids = characteristics ? characteristics.map(c => (0, utils_2.uuid)(c.uuid)) : [];
369
272
  this.logEvent({ message: 'trying to create device', peripheral: peripheral.address, characteristics: cids, profile: device.getProfile() });
370
273
  const existingDevice = this.devices.find(i => i.device.id === device.id && i.device.getProfile() === device.getProfile());
371
274
  if (existingDevice)
@@ -387,7 +290,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
387
290
  connectDevice(requested, timeout = DEFAULT_SCAN_TIMEOUT + CONNECT_TIMEOUT) {
388
291
  return __awaiter(this, void 0, void 0, function* () {
389
292
  const { id, name, address } = requested;
390
- const profile = requested instanceof ble_1.BleDeviceClass ?
293
+ const profile = requested instanceof ble_comms_1.BleComms ?
391
294
  (requested.getProfile && typeof (requested.getProfile) === 'function' ? requested.getProfile() : undefined) :
392
295
  requested.profile;
393
296
  this.logEvent({ message: 'connectDevice', id, name, address, profile, isbusy: this.scanState.isConnecting });
@@ -406,10 +309,10 @@ class BleInterface extends ble_1.BleInterfaceClass {
406
309
  if (peripheralInfo) {
407
310
  if (!peripheralInfo.characteristic) {
408
311
  yield this.getCharacteristics(peripheralInfo.periphal);
409
- const DeviceClasses = this.getDeviceClasses(peripheralInfo.peripheral, { profile });
312
+ const DeviceClasses = this.getAdapterFactory().getDeviceClasses(peripheralInfo.peripheral, { profile });
410
313
  if (!DeviceClasses || DeviceClasses.length === 0)
411
314
  return;
412
- const devices = DeviceClasses.map(C => this.createDevice(C, peripheralInfo.periphal, peripheralInfo.characteristics));
315
+ const devices = DeviceClasses.map(C => this.createDeviceComms(C, peripheralInfo.periphal, peripheralInfo.characteristics));
413
316
  if (devices && devices.length > 0) {
414
317
  for (let i = 0; i < devices.length; i++) {
415
318
  const idx = this.devices.push({ device: devices[i], isConnected: false }) - 1;
@@ -484,24 +387,17 @@ class BleInterface extends ble_1.BleInterfaceClass {
484
387
  }, 100);
485
388
  });
486
389
  }
487
- getBestDeviceMatch(DeviceClasses) {
488
- if (!DeviceClasses || DeviceClasses.length === 0)
489
- return;
490
- const details = DeviceClasses.map(c => ({ name: c.prototype.constructor.name, priority: c.detectionPriority || 0, class: c }));
491
- details.sort((a, b) => b.priority - a.priority);
492
- return details[0].class;
493
- }
494
390
  scan(props) {
495
391
  return __awaiter(this, void 0, void 0, function* () {
496
392
  const { timeout = DEFAULT_SCAN_TIMEOUT, deviceTypes = [], requested } = props;
497
393
  let profile;
498
394
  if (requested)
499
- profile = requested instanceof ble_1.BleDeviceClass ?
395
+ profile = requested instanceof ble_comms_1.BleComms ?
500
396
  (requested.getProfile && typeof (requested.getProfile) === 'function' ? requested.getProfile() : undefined) :
501
397
  requested.profile;
502
398
  const { id, address, name } = requested || {};
503
399
  const scanForDevice = (requested !== null && requested !== undefined);
504
- const services = (!deviceTypes || deviceTypes.length === 0) ? this.getAllSupportedServices() : this.getServicesFromDeviceTypes(deviceTypes);
400
+ const services = (!deviceTypes || deviceTypes.length === 0) ? this.getAdapterFactory().getAllSupportedServices() : (0, utils_2.getServicesFromDeviceTypes)(deviceTypes);
505
401
  const bleBinding = this.getBinding();
506
402
  if (!bleBinding)
507
403
  return Promise.reject(new Error('no binding defined'));
@@ -521,7 +417,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
521
417
  }
522
418
  else {
523
419
  opStr = 'scan';
524
- const supported = BleInterface.deviceClasses.map(dc => ({ id: dc.id, type: dc.type, services: dc.services }));
420
+ const supported = adapter_factory_1.default.getInstance().getAllAdapters().map(i => i.protocol);
525
421
  this.logEvent({ message: 'scan start', services, supported });
526
422
  }
527
423
  if (this.scanState.isScanning) {
@@ -585,15 +481,15 @@ class BleInterface extends ble_1.BleInterfaceClass {
585
481
  const services = connectedServices ? connectedServices.map(cs => cs.uuid) : undefined;
586
482
  const connectedPeripheral = connector.getPeripheral();
587
483
  const { id, name, address, advertisement = {} } = connectedPeripheral;
588
- const DeviceClasses = this.getDeviceClasses(connectedPeripheral, { profile, services }) || [];
484
+ const DeviceClasses = this.getAdapterFactory().getDeviceClasses(connectedPeripheral, { profile, services }) || [];
589
485
  this.logEvent({ message: 'BLE scan: device connected', peripheral: { id, name, address, services: advertisement.serviceUuids }, services, classes: DeviceClasses.map(c => c.prototype.constructor.name) });
590
486
  let cntFound = 0;
591
- const DeviceClass = this.getBestDeviceMatch(DeviceClasses);
487
+ const DeviceClass = (0, utils_2.getBestDeviceMatch)(DeviceClasses);
592
488
  if (!DeviceClass)
593
489
  return;
594
490
  if (scanForDevice && cntFound > 0)
595
491
  return;
596
- const d = this.createDevice(DeviceClass, peripheral, characteristics);
492
+ const d = this.createDeviceComms(DeviceClass, peripheral, characteristics);
597
493
  if (!d) {
598
494
  this.logEvent({ message: `${opStr}: could not create device `, DeviceClass });
599
495
  return;
@@ -643,7 +539,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
643
539
  this.logEvent({ message: `${opStr}: start scanning`, requested: scanForDevice ? { name, address, profile } : undefined, timeout });
644
540
  let services = [];
645
541
  if (scanForDevice && name && !name.toLowerCase().startsWith('tacx')) {
646
- if (props.requested instanceof ble_1.BleDeviceClass) {
542
+ if (props.requested instanceof ble_comms_1.BleComms) {
647
543
  const device = props.requested;
648
544
  services = (device.getServices()) || [];
649
545
  }
@@ -718,4 +614,3 @@ class BleInterface extends ble_1.BleInterfaceClass {
718
614
  }
719
615
  }
720
616
  exports.default = BleInterface;
721
- BleInterface.deviceClasses = [];
@@ -1,6 +1,6 @@
1
- import { BleCharacteristic, BlePeripheral } from "./ble";
1
+ import { BleCharacteristic, BlePeripheral, IBlePeripheralConnector } from './types';
2
2
  import BleInterface from "./ble-interface";
3
- export declare type ConnectorState = {
3
+ export type ConnectorState = {
4
4
  isConnected: boolean;
5
5
  isConnecting: boolean;
6
6
  isInitialized: boolean;
@@ -8,7 +8,7 @@ export declare type ConnectorState = {
8
8
  isSubscribing: boolean;
9
9
  subscribed?: string[];
10
10
  };
11
- export default class BlePeripheralConnector {
11
+ export default class BlePeripheralConnector implements IBlePeripheralConnector {
12
12
  private state;
13
13
  private services;
14
14
  private characteristics;
@@ -12,9 +12,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const ble_1 = require("./ble");
16
15
  const gd_eventlog_1 = require("gd-eventlog");
17
16
  const events_1 = __importDefault(require("events"));
17
+ const utils_1 = require("./utils");
18
18
  class BlePeripheralConnector {
19
19
  constructor(ble, peripheral) {
20
20
  this.ble = ble;
@@ -42,7 +42,7 @@ class BlePeripheralConnector {
42
42
  this.logEvent({ message: 'connect', peripheral: this.peripheral.address, state: this.state });
43
43
  this.state.isConnecting = true;
44
44
  try {
45
- this.peripheral.on('connect', () => { console.log('~~~ peripheral connected', this.peripheral); });
45
+ this.peripheral.on('connect', () => { });
46
46
  this.peripheral.on('disconnect', () => { this.onDisconnect(); });
47
47
  if (!this.state.isConnected || (this.peripheral && this.peripheral.state !== 'connected')) {
48
48
  yield this.peripheral.connectAsync();
@@ -57,7 +57,7 @@ class BlePeripheralConnector {
57
57
  }
58
58
  reconnect() {
59
59
  return __awaiter(this, void 0, void 0, function* () {
60
- this.connect();
60
+ yield this.connect();
61
61
  });
62
62
  }
63
63
  onDisconnect() {
@@ -91,7 +91,7 @@ class BlePeripheralConnector {
91
91
  });
92
92
  }
93
93
  isSubscribed(characteristicUuid) {
94
- return this.state.subscribed.find(c => c === characteristicUuid || (0, ble_1.uuid)(c) === characteristicUuid || c === (0, ble_1.uuid)(characteristicUuid)) !== undefined;
94
+ return this.state.subscribed.find(c => c === characteristicUuid || (0, utils_1.uuid)(c) === characteristicUuid || c === (0, utils_1.uuid)(characteristicUuid)) !== undefined;
95
95
  }
96
96
  subscribeAll(callback) {
97
97
  return __awaiter(this, void 0, void 0, function* () {
@@ -106,12 +106,12 @@ class BlePeripheralConnector {
106
106
  const isNotify = c.properties.find(p => p === 'notify');
107
107
  if (isNotify && subscribed.find(uuid => uuid === c.uuid) === undefined) {
108
108
  c.on('data', (data, _isNotification) => {
109
- this.onData((0, ble_1.uuid)(c.uuid), data);
109
+ this.onData((0, utils_1.uuid)(c.uuid), data);
110
110
  });
111
111
  if (callback) {
112
- this.on((0, ble_1.uuid)(c.uuid), callback);
112
+ this.on((0, utils_1.uuid)(c.uuid), callback);
113
113
  }
114
- this.logEvent({ message: 'subscribe', peripheral: this.peripheral.address, characteristic: c.uuid, uuid: (0, ble_1.uuid)(c.uuid) });
114
+ this.logEvent({ message: 'subscribe', peripheral: this.peripheral.address, characteristic: c.uuid, uuid: (0, utils_1.uuid)(c.uuid) });
115
115
  if (this.state.subscribed.find(uuid => uuid === c.uuid) === undefined) {
116
116
  try {
117
117
  yield this.subscribe(c.uuid, 3000);
@@ -133,10 +133,10 @@ class BlePeripheralConnector {
133
133
  });
134
134
  }
135
135
  subscribe(characteristicUuid, timeout) {
136
- this.logEvent({ message: 'subscribe attempt', characteristic: characteristicUuid, characteristics: this.characteristics.map(c => ({ characteristic: c.uuid, uuid: (0, ble_1.uuid)(c.uuid) })) });
136
+ this.logEvent({ message: 'subscribe attempt', characteristic: characteristicUuid, characteristics: this.characteristics.map(c => ({ characteristic: c.uuid, uuid: (0, utils_1.uuid)(c.uuid) })) });
137
137
  return new Promise((resolve, reject) => {
138
138
  try {
139
- const characteristic = this.characteristics.find(c => (0, ble_1.uuid)(c.uuid) === (0, ble_1.uuid)(characteristicUuid) || (0, ble_1.uuid)(c.uuid) === (0, ble_1.uuid)(characteristicUuid));
139
+ const characteristic = this.characteristics.find(c => (0, utils_1.uuid)(c.uuid) === (0, utils_1.uuid)(characteristicUuid) || (0, utils_1.uuid)(c.uuid) === (0, utils_1.uuid)(characteristicUuid));
140
140
  if (!characteristic) {
141
141
  reject(new Error('Characteristic not found'));
142
142
  return;
@@ -144,7 +144,7 @@ class BlePeripheralConnector {
144
144
  this.logEvent({ message: 'subscribe', peripheral: this.peripheral.address, characteristic: characteristic.uuid });
145
145
  characteristic.removeAllListeners('data');
146
146
  characteristic.on('data', (data, _isNotification) => {
147
- this.onData((0, ble_1.uuid)(characteristicUuid), data);
147
+ this.onData((0, utils_1.uuid)(characteristicUuid), data);
148
148
  });
149
149
  let to;
150
150
  if (timeout) {
@@ -171,18 +171,18 @@ class BlePeripheralConnector {
171
171
  });
172
172
  }
173
173
  onData(characteristicUuid, data) {
174
- this.emitter.emit((0, ble_1.uuid)(characteristicUuid), characteristicUuid, data);
174
+ this.emitter.emit((0, utils_1.uuid)(characteristicUuid), characteristicUuid, data);
175
175
  }
176
176
  on(characteristicUuid, callback) {
177
177
  if (callback)
178
- this.emitter.on((0, ble_1.uuid)(characteristicUuid), callback);
178
+ this.emitter.on((0, utils_1.uuid)(characteristicUuid), callback);
179
179
  }
180
180
  off(characteristicUuid, callback) {
181
181
  if (callback)
182
- this.emitter.off((0, ble_1.uuid)(characteristicUuid), callback);
182
+ this.emitter.off((0, utils_1.uuid)(characteristicUuid), callback);
183
183
  }
184
184
  removeAllListeners(characteristicUuid) {
185
- this.emitter.removeAllListeners((0, ble_1.uuid)(characteristicUuid));
185
+ this.emitter.removeAllListeners((0, utils_1.uuid)(characteristicUuid));
186
186
  }
187
187
  getState() {
188
188
  return this.peripheral.state;
package/lib/ble/ble.d.ts CHANGED
@@ -1,65 +1,18 @@
1
1
  /// <reference types="node" />
2
2
  import EventEmitter from "events";
3
+ import { BleComms } from "./ble-comms";
3
4
  import BlePeripheralConnector from "./ble-peripheral";
4
- export declare type ConnectProps = {
5
- timeout?: number;
6
- reconnect?: boolean;
7
- };
8
- export interface BleDeviceIdentifier {
9
- id?: string;
10
- address?: string;
11
- name?: string;
12
- }
13
- export interface ConnectState {
14
- isConnecting: boolean;
15
- isConnected: boolean;
16
- isDisconnecting: boolean;
17
- }
18
- export declare type BleDeviceInfo = {
19
- manufacturer?: string;
20
- hwRevision?: string;
21
- swRevision?: string;
22
- fwRevision?: string;
23
- model?: string;
24
- serialNo?: string;
25
- };
26
- export interface BleDeviceDescription {
27
- id?: string;
28
- address: string;
29
- name?: string;
30
- profile: string;
31
- }
32
- export declare abstract class BleDeviceClass extends EventEmitter {
33
- static services: string[];
34
- id?: string;
35
- address?: string;
36
- name?: string;
37
- peripheral?: BlePeripheral;
38
- connectState: ConnectState;
39
- getConnectState(): ConnectState;
40
- isConnected(): boolean;
41
- abstract getProfile(): string;
42
- abstract getServiceUUids(): string[];
43
- abstract connect(props?: ConnectProps): Promise<boolean>;
44
- abstract disconnect(): Promise<boolean>;
45
- abstract getDeviceInfo(): Promise<BleDeviceInfo>;
46
- abstract getServices(): string[];
47
- setCharacteristicUUIDs(uuids: string[]): void;
48
- }
49
- export interface BleWriteProps {
50
- withoutResponse?: boolean;
51
- timeout?: number;
52
- }
5
+ import { BleDeviceCommsClass, BleDeviceSettings, BlePeripheral, ConnectProps } from "./types";
53
6
  export interface BleBinding extends EventEmitter {
54
7
  startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean, callback?: (error?: Error) => void): void;
55
8
  stopScanning(callback?: () => void): void;
56
9
  _bindings: any;
57
10
  state: string;
58
11
  }
59
- export declare type ScanProps = {
12
+ export type BleScanProps = {
60
13
  timeout?: number;
61
- deviceTypes?: (typeof BleDeviceClass)[];
62
- requested?: BleDeviceClass | BleDeviceDescription;
14
+ deviceTypes?: (typeof BleComms)[];
15
+ requested?: BleComms | BleDeviceSettings;
63
16
  isBackgroundScan?: boolean;
64
17
  };
65
18
  export declare class BleBindingWrapper {
@@ -77,14 +30,14 @@ export declare abstract class BleInterfaceClass extends EventEmitter {
77
30
  binding?: BleBinding;
78
31
  });
79
32
  abstract connect(props: ConnectProps): Promise<boolean>;
80
- abstract scan(props: ScanProps): Promise<BleDeviceClass[]>;
33
+ abstract scan(props: BleScanProps): Promise<BleDeviceCommsClass[]>;
81
34
  abstract stopScan(): Promise<boolean>;
82
35
  abstract disconnect(): Promise<boolean>;
83
36
  abstract onDisconnect(peripheral: BlePeripheral): void;
84
37
  abstract isScanning(): boolean;
85
- abstract addConnectedDevice(device: BleDeviceClass): void;
86
- abstract removeConnectedDevice(device: BleDeviceClass): void;
87
- abstract findConnected(device: BleDeviceClass | BlePeripheral): BleDeviceClass;
38
+ abstract addConnectedDevice(device: BleDeviceCommsClass): void;
39
+ abstract removeConnectedDevice(device: BleDeviceCommsClass): void;
40
+ abstract findConnected(device: BleDeviceCommsClass | BlePeripheral): BleDeviceCommsClass;
88
41
  abstract getConnector(peripheral: BlePeripheral): BlePeripheralConnector;
89
42
  abstract findPeripheral(peripheral: BlePeripheral | {
90
43
  id?: string;
@@ -94,29 +47,6 @@ export declare abstract class BleInterfaceClass extends EventEmitter {
94
47
  getBinding(): BleBinding;
95
48
  setBinding(binding: BleBinding): void;
96
49
  }
97
- export interface BlePeripheral extends EventEmitter, BleDeviceIdentifier {
98
- services: string[];
99
- advertisement: any;
100
- state: string;
101
- connectAsync(): Promise<void>;
102
- disconnect(cb: (err?: Error) => void): Promise<void>;
103
- discoverSomeServicesAndCharacteristicsAsync(serviceUUIDs: string[], characteristicUUIDs: string[]): Promise<any>;
104
- }
105
- export interface BleCharacteristic extends EventEmitter {
106
- uuid: string;
107
- properties: string[];
108
- subscribe(callback: (err: Error) => void): void;
109
- read(callback: (err: Error, data: Buffer) => void): void;
110
- write(data: Buffer, withoutResponse: boolean, callback?: (err: Error) => void): void;
111
- }
112
- export declare type BleDeviceProps = {
113
- id?: string;
114
- address?: string;
115
- name?: string;
116
- services?: string[];
117
- ble: BleInterfaceClass;
118
- peripheral?: BlePeripheral;
119
- };
120
50
  export declare enum BleState {
121
51
  UNKNOWN = "unknown",
122
52
  RESETTING = "resetting",
@@ -125,5 +55,3 @@ export declare enum BleState {
125
55
  POWERED_OFF = "poweredOff",
126
56
  POWERED_ON = "poweredOn"
127
57
  }
128
- export declare const uuid: (s: any) => any;
129
- export declare const matches: (uuid1: any, uuid2: any) => boolean;
package/lib/ble/ble.js CHANGED
@@ -3,23 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.matches = exports.uuid = exports.BleState = exports.BleInterfaceClass = exports.BleBindingWrapper = exports.BleDeviceClass = void 0;
6
+ exports.BleState = exports.BleInterfaceClass = exports.BleBindingWrapper = void 0;
7
7
  const events_1 = __importDefault(require("events"));
8
- class BleDeviceClass extends events_1.default {
9
- constructor() {
10
- super(...arguments);
11
- this.connectState = { isConnecting: false, isConnected: false, isDisconnecting: false };
12
- }
13
- getConnectState() {
14
- return this.connectState;
15
- }
16
- isConnected() {
17
- return this.connectState.isConnected;
18
- }
19
- setCharacteristicUUIDs(uuids) { }
20
- }
21
- exports.BleDeviceClass = BleDeviceClass;
22
- BleDeviceClass.services = [];
23
8
  class BleBindingWrapper {
24
9
  constructor(binding) {
25
10
  this.binding = binding;
@@ -61,26 +46,3 @@ var BleState;
61
46
  BleState["POWERED_OFF"] = "poweredOff";
62
47
  BleState["POWERED_ON"] = "poweredOn";
63
48
  })(BleState = exports.BleState || (exports.BleState = {}));
64
- const uuid = (s) => {
65
- if (s) {
66
- if (s.includes('-')) {
67
- const parts = s.split('-');
68
- const uuidNo = parseInt('0x' + parts[0]);
69
- return uuidNo.toString(16).toLowerCase();
70
- }
71
- return s;
72
- }
73
- };
74
- exports.uuid = uuid;
75
- const matches = (uuid1, uuid2) => {
76
- const ul1 = uuid1.toLowerCase();
77
- const ul2 = uuid2.toLowerCase();
78
- if ((0, exports.uuid)(ul1) === (0, exports.uuid)(ul2))
79
- return true;
80
- if (ul1.length < ul2.length && ul2.startsWith(ul1))
81
- return true;
82
- if (ul1.length > ul2.length && ul1.startsWith(ul2))
83
- return true;
84
- return false;
85
- };
86
- exports.matches = matches;
@@ -11,4 +11,6 @@ export declare const CSP_FEATURE = "2a65";
11
11
  export declare const CSC = "1816";
12
12
  export declare const CSC_MEASUREMENT = "2a5b";
13
13
  export declare const WAHOO_ADVANCED_TRAINER_CP = "a026e005";
14
+ export declare const WAHOO_ADVANCED_FTMS = "a026ee0b";
14
15
  export declare const WAHOO_ADVANCED_TRAINER_CP_FULL = "A026E005-0A7D-4AB3-97FA-F1500F9FEB8B";
16
+ export declare const ELITE_TRAINER_SVC = "347b0001";
package/lib/ble/consts.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WAHOO_ADVANCED_TRAINER_CP_FULL = exports.WAHOO_ADVANCED_TRAINER_CP = exports.CSC_MEASUREMENT = exports.CSC = 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;
3
+ exports.ELITE_TRAINER_SVC = exports.WAHOO_ADVANCED_TRAINER_CP_FULL = exports.WAHOO_ADVANCED_FTMS = exports.WAHOO_ADVANCED_TRAINER_CP = exports.CSC_MEASUREMENT = exports.CSC = 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';
@@ -14,4 +14,6 @@ exports.CSP_FEATURE = '2a65';
14
14
  exports.CSC = '1816';
15
15
  exports.CSC_MEASUREMENT = '2a5b';
16
16
  exports.WAHOO_ADVANCED_TRAINER_CP = 'a026e005';
17
+ exports.WAHOO_ADVANCED_FTMS = 'a026ee0b';
17
18
  exports.WAHOO_ADVANCED_TRAINER_CP_FULL = 'A026E005-0A7D-4AB3-97FA-F1500F9FEB8B';
19
+ exports.ELITE_TRAINER_SVC = '347b0001';
@@ -0,0 +1,23 @@
1
+ import CyclingMode from '../../modes/cycling-mode';
2
+ import { IncyclistBikeData } from '../../modes/cycling-mode';
3
+ import { BleControllableAdapter } from '../adapter';
4
+ import { DeviceProperties } from '../../types/device';
5
+ import { PowerData } from './types';
6
+ import { DeviceData } from '../../types/data';
7
+ import { BleDeviceSettings } from '../types';
8
+ import IncyclistDevice from '../../base/adpater';
9
+ export default class PwrAdapter extends BleControllableAdapter {
10
+ distanceInternal: number;
11
+ constructor(settings: BleDeviceSettings, props?: DeviceProperties);
12
+ isSame(device: IncyclistDevice): boolean;
13
+ getProfile(): string;
14
+ getName(): string;
15
+ getDisplayName(): string;
16
+ getDefaultCyclingMode(): CyclingMode;
17
+ getSupportedCyclingModes(): any[];
18
+ onDeviceData(deviceData: PowerData): void;
19
+ mapData(deviceData: PowerData): IncyclistBikeData;
20
+ transformData(bikeData: IncyclistBikeData): DeviceData;
21
+ sendUpdate(request: any): Promise<void>;
22
+ stop(): Promise<boolean>;
23
+ }