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
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBrand = void 0;
4
+ const brands = [
5
+ 'Garmin,1',
6
+ 'garmin_fr405_antfs,2',
7
+ 'Zephyr,3',
8
+ 'Dayton,4',
9
+ 'idt,5',
10
+ 'SRM,6',
11
+ 'Quarq,7',
12
+ 'ibike,8',
13
+ 'Saris,9',
14
+ 'spark_hk,10',
15
+ 'Tanita,11',
16
+ 'echowell,12',
17
+ 'Dynastream_oem,13',
18
+ 'Nautilus,14',
19
+ 'Dynastream,15',
20
+ 'Timex,16',
21
+ 'Metrigear,17',
22
+ 'Xelic,18',
23
+ 'Beurer,19',
24
+ 'Cardiosport,20',
25
+ 'A&D,21',
26
+ 'Hmm,22',
27
+ 'Suunto,23',
28
+ 'Thita Elektronik,24',
29
+ 'Gpulse,25',
30
+ 'Clean Mobile,26',
31
+ 'Pedal Brain,27',
32
+ 'Peaksware,28',
33
+ 'Saxonar,29',
34
+ 'Lemond Fitness,30',
35
+ 'Dexcom,31',
36
+ 'Wahoo,32',
37
+ 'Octane,33',
38
+ 'Archinoetics,34',
39
+ 'The Hurt Box,35',
40
+ 'Citizen Systems,36',
41
+ 'Magellan,37',
42
+ 'Osynce,38',
43
+ 'Holux,39',
44
+ 'Concept2,40',
45
+ 'One Giant Leap,42',
46
+ 'Ace Sensor,43',
47
+ 'Brim Brothers,44',
48
+ 'Xplova,45',
49
+ 'Perception Digital,46',
50
+ 'Bf1systems,47',
51
+ 'Pioneer,48',
52
+ 'Spantec,49',
53
+ 'Metalogics,50',
54
+ '4iiiis,51',
55
+ 'Seiko,52',
56
+ 'Seiko,53',
57
+ 'Ifor Powell,54',
58
+ 'Maxwell Guider,55',
59
+ 'Star rac,56',
60
+ 'Breakaway,57',
61
+ 'Alatech,58',
62
+ 'Mio,59',
63
+ 'Rotor,60',
64
+ 'Geonaute,61',
65
+ 'Id Bike,62',
66
+ 'Specialized,63',
67
+ 'Wtek,64',
68
+ 'Physical Enterprises,65',
69
+ 'North Pole,66',
70
+ 'Bkool,67',
71
+ 'Cateye,68',
72
+ 'Stages,69',
73
+ 'Sigma,70',
74
+ 'Tomtom,71',
75
+ 'Peripedal,72',
76
+ 'Wattbike,73',
77
+ 'Moxy,76',
78
+ 'Ciclosport,77',
79
+ 'Powerbahn,78',
80
+ 'Acorn,79',
81
+ 'Lifebeam,80',
82
+ 'Bontrager,81',
83
+ 'Wellgo,82',
84
+ 'Scosche,83',
85
+ 'Magura,84',
86
+ 'Woodway,85',
87
+ 'Elite,86',
88
+ 'Nielsen Kellerman,87',
89
+ 'DK City,88',
90
+ 'Tacx,89',
91
+ 'Direction,90',
92
+ 'Magtonic,91',
93
+ '1partcarbon,92',
94
+ 'Inside Ride,93',
95
+ 'Sound Of Motion,94',
96
+ 'Stryd,95',
97
+ 'icg,96',
98
+ 'MiPulse,97',
99
+ 'Bsx Athletics,98',
100
+ 'Look,99',
101
+ 'Campagnolo,100',
102
+ 'Body Bike Smart,101',
103
+ 'Praxisworks,102',
104
+ 'Limits,103',
105
+ 'Topaction,104',
106
+ 'Cosinuss,105',
107
+ 'Fitcare,106',
108
+ 'Magene,107',
109
+ 'Giant,108',
110
+ 'Tigrasport,109',
111
+ 'Salutron,110',
112
+ 'Technogym,111',
113
+ 'Bryton,112',
114
+ 'Latitude,113',
115
+ 'Soaring,114',
116
+ 'Igpsport,115',
117
+ 'Thinkrider,116',
118
+ 'Gopher,117',
119
+ 'Waterrower,118',
120
+ 'Orangetheory,119',
121
+ 'Inpeak,120',
122
+ 'Kinetic,121',
123
+ 'Johnson,122',
124
+ 'Polar,123',
125
+ 'Seesense,124',
126
+ 'NCI,125',
127
+ 'Development,255',
128
+ 'Healthandlife,257',
129
+ 'Lezyne,258',
130
+ 'Scribe,259',
131
+ 'Zwift,260',
132
+ 'Watteam,261',
133
+ 'Recon,262',
134
+ 'Favero,263',
135
+ 'Dynovelo,264',
136
+ 'Strava,265',
137
+ 'Precor,266',
138
+ 'Bryton,267',
139
+ 'Sram,268',
140
+ 'Navman,269',
141
+ 'Cobi,270',
142
+ 'Spivi,271',
143
+ 'Mio Magellan,272',
144
+ 'Evesports,273',
145
+ 'Sensitivus Gauge,274',
146
+ 'Podoon,275',
147
+ 'Life Time Fitness,276',
148
+ 'Falco,277',
149
+ 'Minoura,278',
150
+ 'Cycliq,279',
151
+ 'Luxottica,280',
152
+ 'Trainer Road,281',
153
+ 'The Sufferfest,282',
154
+ 'Fullspeedahead,283',
155
+ 'Virtualtraining,284',
156
+ 'Feedbacksports,285',
157
+ 'Omata,286',
158
+ 'VDO,287',
159
+ 'Magneticdays,288',
160
+ 'Hammerhead,289',
161
+ 'Kinetic By Kurt,290',
162
+ 'Shapelog,291',
163
+ 'Dabuziduo,292',
164
+ 'Jetblack,293',
165
+ 'Coros,294',
166
+ 'Virtugo,295',
167
+ 'Velosense,296',
168
+ 'Cycligentinc,297',
169
+ 'Actigraphcorp,5759'
170
+ ];
171
+ const brandLookup = brands.map(str => {
172
+ const [name, id] = str.split(',');
173
+ return { name, id: Number(id) };
174
+ });
175
+ const getBrand = (manId) => {
176
+ const found = brandLookup.find(l => l.id === manId);
177
+ if (found)
178
+ return found.name;
179
+ return;
180
+ };
181
+ exports.getBrand = getBrand;
@@ -0,0 +1,56 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from "stream";
3
+ import CyclingMode from "../modes/cycling-mode";
4
+ import { DeviceProperties, DeviceSettings } from "../types/device";
5
+ import { Bike, IncyclistDeviceAdapter, OnDeviceDataCallback } from '../types/adapter';
6
+ import { User } from "../types/user";
7
+ import { IncyclistCapability } from "../types/capabilities";
8
+ import { EventLogger } from "gd-eventlog";
9
+ export declare const DEFAULT_BIKE_WEIGHT = 10;
10
+ export declare const DEFAULT_USER_WEIGHT = 75;
11
+ export declare const DEFAULT_PROPS: DeviceProperties;
12
+ export default class IncyclistDevice extends EventEmitter implements IncyclistDeviceAdapter {
13
+ onDataFn: OnDeviceDataCallback;
14
+ settings: DeviceSettings;
15
+ props: DeviceProperties;
16
+ capabilities: IncyclistCapability[];
17
+ protected logger: EventLogger;
18
+ started: boolean;
19
+ stopped: boolean;
20
+ paused: boolean;
21
+ constructor(settings: DeviceSettings, props?: DeviceProperties);
22
+ connect(): Promise<boolean>;
23
+ close(): Promise<boolean>;
24
+ check(): Promise<boolean>;
25
+ isEqual(settings: DeviceSettings): void;
26
+ getCapabilities(): IncyclistCapability[];
27
+ hasCapability(capability: IncyclistCapability): boolean;
28
+ update(): void;
29
+ start(props?: DeviceProperties): Promise<boolean>;
30
+ stop(): Promise<boolean>;
31
+ pause(): Promise<boolean>;
32
+ resume(): Promise<boolean>;
33
+ logEvent(event: any): void;
34
+ sendUpdate(request: any): void;
35
+ getID(): string;
36
+ getDisplayName(): string;
37
+ getName(): string;
38
+ getSettings(): DeviceSettings;
39
+ getInterface(): string;
40
+ onData(callback: OnDeviceDataCallback): void;
41
+ isStopped(): boolean;
42
+ isStarted(): boolean;
43
+ isPaused(): boolean;
44
+ }
45
+ export declare class ControllableDevice extends IncyclistDevice implements Bike {
46
+ cyclingMode: CyclingMode;
47
+ user?: User;
48
+ constructor(settings: DeviceSettings, props?: DeviceProperties);
49
+ setUser(user: User): void;
50
+ setBikeProps(props: DeviceProperties): void;
51
+ getWeight(): number;
52
+ getSupportedCyclingModes(): any[];
53
+ getDefaultCyclingMode(): CyclingMode;
54
+ setCyclingMode(mode: CyclingMode | string, settings?: any): void;
55
+ getCyclingMode(): CyclingMode;
56
+ }
@@ -0,0 +1,144 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ControllableDevice = exports.DEFAULT_PROPS = exports.DEFAULT_USER_WEIGHT = exports.DEFAULT_BIKE_WEIGHT = void 0;
13
+ const stream_1 = require("stream");
14
+ exports.DEFAULT_BIKE_WEIGHT = 10;
15
+ exports.DEFAULT_USER_WEIGHT = 75;
16
+ exports.DEFAULT_PROPS = {
17
+ userWeight: exports.DEFAULT_USER_WEIGHT,
18
+ bikeWeight: exports.DEFAULT_BIKE_WEIGHT
19
+ };
20
+ class IncyclistDevice extends stream_1.EventEmitter {
21
+ constructor(settings, props) {
22
+ super();
23
+ this.onDataFn = undefined;
24
+ this.settings = settings;
25
+ this.props = props || {};
26
+ this.capabilities = [];
27
+ this.started = false;
28
+ this.stopped = false;
29
+ this.paused = false;
30
+ }
31
+ connect() { throw new Error('not implemented'); }
32
+ close() { throw new Error('not implemented'); }
33
+ check() { throw new Error("Method not implemented."); }
34
+ isEqual(settings) { throw new Error("Method not implemented."); }
35
+ getCapabilities() { return this.capabilities; }
36
+ hasCapability(capability) {
37
+ return this.capabilities.find(c => c === capability) !== undefined;
38
+ }
39
+ update() { throw new Error("Method not implemented."); }
40
+ start(props) { throw new Error("Method not implemented."); }
41
+ stop() { throw new Error("Method not implemented."); }
42
+ pause() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ this.paused = true;
45
+ return true;
46
+ });
47
+ }
48
+ resume() {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ this.paused = false;
51
+ return true;
52
+ });
53
+ }
54
+ logEvent(event) {
55
+ if (!this.logger)
56
+ return;
57
+ this.logger.logEvent(event);
58
+ }
59
+ sendUpdate(request) { throw new Error("Method not implemented."); }
60
+ getID() { throw new Error('not implemented'); }
61
+ getDisplayName() {
62
+ return this.getName();
63
+ }
64
+ getName() {
65
+ return this.settings.name;
66
+ }
67
+ getSettings() {
68
+ return this.settings;
69
+ }
70
+ getInterface() {
71
+ return typeof this.settings.interface === 'string' ? this.settings.interface : this.settings.interface.getName();
72
+ }
73
+ onData(callback) {
74
+ this.onDataFn = callback;
75
+ }
76
+ isStopped() {
77
+ return this.stopped;
78
+ }
79
+ isStarted() {
80
+ return this.started;
81
+ }
82
+ isPaused() {
83
+ return this.paused;
84
+ }
85
+ }
86
+ exports.default = IncyclistDevice;
87
+ class ControllableDevice extends IncyclistDevice {
88
+ constructor(settings, props) {
89
+ super(settings, props);
90
+ this.cyclingMode = this.getDefaultCyclingMode();
91
+ this.user = {};
92
+ }
93
+ setUser(user) {
94
+ this.user = user;
95
+ if (!user.weight)
96
+ this.user.weight = exports.DEFAULT_USER_WEIGHT;
97
+ }
98
+ setBikeProps(props) {
99
+ const { user, userWeight, bikeWeight } = props || {};
100
+ if (user)
101
+ this.setUser(user);
102
+ if (userWeight)
103
+ this.user.weight = userWeight;
104
+ const keys = Object.keys(props);
105
+ keys.forEach(k => {
106
+ const p = props[k];
107
+ if (p === null)
108
+ delete this.props[k];
109
+ else if (p !== undefined)
110
+ this.props[k] = p;
111
+ });
112
+ }
113
+ getWeight() {
114
+ const { user = {}, props = exports.DEFAULT_PROPS } = this;
115
+ const userWeight = user.weight || props.userWeight || exports.DEFAULT_USER_WEIGHT;
116
+ const bikeWeight = props.bikeWeight || exports.DEFAULT_BIKE_WEIGHT;
117
+ return userWeight + bikeWeight;
118
+ }
119
+ getSupportedCyclingModes() { throw new Error('not implemented'); }
120
+ getDefaultCyclingMode() { throw new Error('not implemented'); }
121
+ setCyclingMode(mode, settings) {
122
+ let selectedMode;
123
+ if (typeof mode === 'string') {
124
+ const supported = this.getSupportedCyclingModes();
125
+ const CyclingModeClass = supported.find(M => { const m = new M(this); return m.getName() === mode; });
126
+ if (CyclingModeClass) {
127
+ this.cyclingMode = new CyclingModeClass(this, settings);
128
+ return;
129
+ }
130
+ selectedMode = this.getDefaultCyclingMode();
131
+ }
132
+ else {
133
+ selectedMode = mode;
134
+ }
135
+ this.cyclingMode = selectedMode;
136
+ this.cyclingMode.setSettings(settings);
137
+ }
138
+ getCyclingMode() {
139
+ if (!this.cyclingMode)
140
+ this.setCyclingMode(this.getDefaultCyclingMode());
141
+ return this.cyclingMode;
142
+ }
143
+ }
144
+ exports.ControllableDevice = ControllableDevice;
@@ -0,0 +1,31 @@
1
+ import { DeviceProperties } from "../types/device";
2
+ import { BleComms } from "./ble-comms";
3
+ import BleAdapter from "./adapter";
4
+ import { BleDeviceSettings } from "./types";
5
+ export interface BleAdapterInfo {
6
+ protocol: string;
7
+ profile: string;
8
+ Adapter: typeof BleAdapter;
9
+ Comm: typeof BleComms;
10
+ }
11
+ export declare function mapLegacyProfile(profile: any): {
12
+ profile: any;
13
+ protocol: string;
14
+ };
15
+ export default class BleAdapterFactory {
16
+ static _instance: BleAdapterFactory;
17
+ adapters: BleAdapterInfo[];
18
+ static getInstance(): BleAdapterFactory;
19
+ constructor();
20
+ getAdapter(protocol: string): BleAdapterInfo;
21
+ getAllAdapters(): BleAdapterInfo[];
22
+ createInstance(settings: BleDeviceSettings, props?: DeviceProperties): BleAdapter;
23
+ register(protocol: string, profile: string, Adapter: typeof BleAdapter, Comm: typeof BleComms): void;
24
+ getAllSupportedDeviceTypes(): (typeof BleComms)[];
25
+ getAllSupportedServices(): string[];
26
+ getDeviceClasses(peripheral: any, props?: {
27
+ deviceTypes?: (typeof BleComms)[];
28
+ profile?: string;
29
+ services?: string[];
30
+ }): (typeof BleComms)[];
31
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapLegacyProfile = void 0;
4
+ const utils_1 = require("./utils");
5
+ function mapLegacyProfile(profile) {
6
+ switch (profile) {
7
+ case 'Smart Trainer': return { profile: 'Smart Trainer', protocol: 'fm' };
8
+ case 'Elite Smart Trainer': return { profile: 'Smart Trainer', protocol: 'elite' };
9
+ case 'Heartrate Monitor': return { profile: 'Heartrate Monitor', protocol: 'hr' };
10
+ case 'Power Meter': return { profile: 'Power Meter', protocol: 'cp' };
11
+ case 'Tacx Smart Trainer': return { profile: 'Smart Trainer', protocol: 'tacx' };
12
+ case 'Wahoo Smart Trainer': return { profile: 'Smart Trainer', protocol: 'wahoo' };
13
+ }
14
+ return { profile, protocol: 'Ble' };
15
+ }
16
+ exports.mapLegacyProfile = mapLegacyProfile;
17
+ class BleAdapterFactory {
18
+ static getInstance() {
19
+ if (!BleAdapterFactory._instance)
20
+ BleAdapterFactory._instance = new BleAdapterFactory();
21
+ return BleAdapterFactory._instance;
22
+ }
23
+ constructor() {
24
+ this.adapters = [];
25
+ }
26
+ getAdapter(protocol) {
27
+ return this.adapters.find(a => a.protocol === protocol);
28
+ }
29
+ getAllAdapters() {
30
+ return this.adapters;
31
+ }
32
+ createInstance(settings, props) {
33
+ let { profile, protocol } = settings;
34
+ const adapterSettings = Object.assign({}, settings);
35
+ if (protocol === 'BLE') {
36
+ const mapping = mapLegacyProfile(profile);
37
+ protocol = mapping.protocol;
38
+ profile = mapping.profile;
39
+ adapterSettings.protocol = protocol;
40
+ adapterSettings.profile = profile;
41
+ }
42
+ const info = this.getAdapter(protocol);
43
+ if (!info || !info.Adapter)
44
+ return;
45
+ const adapter = new info.Adapter(adapterSettings, props);
46
+ return adapter;
47
+ }
48
+ register(protocol, profile, Adapter, Comm) {
49
+ const info = Object.assign({}, { protocol, profile, Adapter, Comm });
50
+ const existing = this.adapters.findIndex(a => a.protocol === protocol);
51
+ if (existing)
52
+ this.adapters[existing] = info;
53
+ else
54
+ this.adapters.push(info);
55
+ }
56
+ getAllSupportedDeviceTypes() {
57
+ const supported = BleAdapterFactory.getInstance().getAllAdapters();
58
+ return supported.map(info => info.Comm);
59
+ }
60
+ getAllSupportedServices() {
61
+ const supported = BleAdapterFactory.getInstance().getAllAdapters();
62
+ const res = [];
63
+ if (supported && supported.length > 0) {
64
+ supported.forEach(info => {
65
+ if (info && info.Comm && info.Comm.services) {
66
+ info.Comm.services.forEach(s => {
67
+ if (!res.includes(s))
68
+ res.push(s);
69
+ });
70
+ }
71
+ });
72
+ }
73
+ return res;
74
+ }
75
+ getDeviceClasses(peripheral, props = {}) {
76
+ let DeviceClasses;
77
+ const { deviceTypes, profile, services = peripheral.advertisement.serviceUuids } = props;
78
+ if ((!deviceTypes || deviceTypes.length === 0)) {
79
+ const classes = this.getAllSupportedDeviceTypes();
80
+ DeviceClasses = (0, utils_1.getDevicesFromServices)(classes, services);
81
+ }
82
+ else {
83
+ DeviceClasses = (0, utils_1.getDevicesFromServices)(deviceTypes, services);
84
+ }
85
+ if (profile && DeviceClasses && DeviceClasses.length > 0) {
86
+ DeviceClasses = DeviceClasses.filter(C => {
87
+ const device = new C({ peripheral });
88
+ if (device.getProfile() !== profile)
89
+ return false;
90
+ return true;
91
+ });
92
+ }
93
+ return DeviceClasses;
94
+ }
95
+ }
96
+ exports.default = BleAdapterFactory;
@@ -0,0 +1,41 @@
1
+ import IncyclistDevice from "../base/adpater";
2
+ import CyclingMode from "../modes/cycling-mode";
3
+ import { Bike } from "../types/adapter";
4
+ import { DeviceData } from "../types/data";
5
+ import { DeviceProperties } from "../types/device";
6
+ import { User } from "../types/user";
7
+ import { BleComms } from "./ble-comms";
8
+ import BleInterface from "./ble-interface";
9
+ import { BleDeviceSettings } from "./types";
10
+ export default class BleAdapter extends IncyclistDevice {
11
+ ble: BleInterface;
12
+ deviceData: any;
13
+ data: DeviceData;
14
+ dataMsgCount: number;
15
+ lastUpdate?: number;
16
+ lastDataTS: number;
17
+ updateFrequency: number;
18
+ device: BleComms;
19
+ constructor(settings: BleDeviceSettings, props?: DeviceProperties);
20
+ isEqual(settings: BleDeviceSettings): boolean;
21
+ resetData(): void;
22
+ getInterface(): string;
23
+ getProtocolName(): string;
24
+ getID(): string;
25
+ getName(): string;
26
+ onDeviceData(deviceData: any): void;
27
+ start(props?: DeviceProperties): Promise<any>;
28
+ stop(): Promise<boolean>;
29
+ }
30
+ export declare class BleControllableAdapter extends BleAdapter implements Bike {
31
+ cyclingMode: CyclingMode;
32
+ user?: User;
33
+ constructor(settings: BleDeviceSettings, props?: DeviceProperties);
34
+ setUser(user: User): void;
35
+ setBikeProps(props: DeviceProperties): void;
36
+ getWeight(): number;
37
+ getSupportedCyclingModes(): any[];
38
+ getDefaultCyclingMode(): CyclingMode;
39
+ setCyclingMode(mode: CyclingMode | string, settings?: any): void;
40
+ getCyclingMode(): CyclingMode;
41
+ }