@hangtime/grip-connect 0.4.1 → 0.5.0

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 (171) hide show
  1. package/README.md +58 -45
  2. package/dist/characteristic.d.ts +1 -1
  3. package/dist/characteristic.js +1 -0
  4. package/dist/commands/forceboard.d.ts +6 -0
  5. package/dist/commands/forceboard.js +5 -0
  6. package/dist/commands/index.d.ts +3 -2
  7. package/dist/commands/index.js +3 -2
  8. package/dist/index.d.ts +1 -13
  9. package/dist/index.js +3 -23
  10. package/dist/interfaces/base.interface.d.ts +5 -0
  11. package/dist/interfaces/device/climbro.interface.d.ts +3 -0
  12. package/dist/interfaces/device/climbro.interface.js +1 -0
  13. package/dist/interfaces/device/entralpi.interface.d.ts +3 -0
  14. package/dist/interfaces/device/entralpi.interface.js +1 -0
  15. package/dist/interfaces/device/forceboard.interface.d.ts +3 -0
  16. package/dist/interfaces/device/forceboard.interface.js +1 -0
  17. package/dist/interfaces/device/kilterboard.interface.d.ts +3 -0
  18. package/dist/interfaces/device/kilterboard.interface.js +1 -0
  19. package/dist/interfaces/device/motherboard.interface.d.ts +10 -0
  20. package/dist/interfaces/device/motherboard.interface.js +1 -0
  21. package/dist/interfaces/device/mysmartboard.interface.d.ts +3 -0
  22. package/dist/interfaces/device/mysmartboard.interface.js +1 -0
  23. package/dist/interfaces/device/progressor.interface.d.ts +3 -0
  24. package/dist/interfaces/device/progressor.interface.js +1 -0
  25. package/dist/interfaces/device/wh-c06.interface.d.ts +3 -0
  26. package/dist/interfaces/device/wh-c06.interface.js +1 -0
  27. package/dist/interfaces/device.interface.d.ts +76 -0
  28. package/dist/interfaces/device.interface.js +1 -0
  29. package/dist/is-active.d.ts +11 -7
  30. package/dist/is-active.js +20 -10
  31. package/dist/is-device.d.ts +19 -13
  32. package/dist/is-device.js +19 -13
  33. package/dist/models/base.model.d.ts +7 -0
  34. package/dist/models/base.model.js +10 -0
  35. package/dist/models/device/climbro.model.d.ts +9 -0
  36. package/dist/models/device/climbro.model.js +13 -0
  37. package/dist/models/device/entralpi.model.d.ts +43 -0
  38. package/dist/models/device/entralpi.model.js +246 -0
  39. package/dist/models/device/forceboard.model.d.ts +23 -0
  40. package/dist/models/device/forceboard.model.js +201 -0
  41. package/dist/models/device/kilterboard.model.d.ts +85 -0
  42. package/dist/models/device/kilterboard.model.js +213 -0
  43. package/dist/models/device/motherboard.model.d.ts +76 -0
  44. package/dist/models/device/motherboard.model.js +391 -0
  45. package/dist/models/device/mysmartboard.model.d.ts +9 -0
  46. package/dist/models/device/mysmartboard.model.js +13 -0
  47. package/dist/models/device/progressor.model.d.ts +32 -0
  48. package/dist/models/device/progressor.model.js +177 -0
  49. package/dist/models/device/wh-c06.model.d.ts +15 -0
  50. package/dist/models/device/wh-c06.model.js +97 -0
  51. package/dist/models/device.model.d.ts +45 -0
  52. package/dist/models/device.model.js +140 -0
  53. package/dist/models/index.d.ts +8 -0
  54. package/dist/models/index.js +8 -0
  55. package/dist/notify.js +1 -1
  56. package/dist/read.d.ts +1 -1
  57. package/dist/read.js +1 -5
  58. package/dist/stop.d.ts +1 -1
  59. package/dist/stop.js +1 -2
  60. package/dist/write.d.ts +2 -2
  61. package/dist/write.js +24 -26
  62. package/package.json +4 -2
  63. package/src/characteristic.ts +2 -1
  64. package/src/commands/forceboard.ts +6 -0
  65. package/src/commands/index.ts +4 -2
  66. package/src/index.ts +14 -27
  67. package/src/interfaces/base.interface.ts +5 -0
  68. package/src/interfaces/device/climbro.interface.ts +4 -0
  69. package/src/interfaces/device/entralpi.interface.ts +4 -0
  70. package/src/interfaces/device/forceboard.interface.ts +4 -0
  71. package/src/interfaces/device/kilterboard.interface.ts +4 -0
  72. package/src/interfaces/device/motherboard.interface.ts +11 -0
  73. package/src/interfaces/device/mysmartboard.interface.ts +4 -0
  74. package/src/interfaces/device/progressor.interface.ts +4 -0
  75. package/src/interfaces/device/wh-c06.interface.ts +4 -0
  76. package/src/interfaces/device.interface.ts +85 -0
  77. package/src/is-active.ts +22 -10
  78. package/src/is-device.ts +23 -16
  79. package/src/models/base.model.ts +16 -0
  80. package/src/models/device/climbro.model.ts +15 -0
  81. package/src/models/device/entralpi.model.ts +264 -0
  82. package/src/models/device/forceboard.model.ts +206 -0
  83. package/src/models/device/kilterboard.model.ts +229 -0
  84. package/src/models/device/motherboard.model.ts +430 -0
  85. package/src/models/device/mysmartboard.model.ts +15 -0
  86. package/src/models/device/progressor.model.ts +184 -0
  87. package/src/models/device/wh-c06.model.ts +118 -0
  88. package/src/models/device.model.ts +159 -0
  89. package/src/models/index.ts +15 -0
  90. package/src/notify.ts +1 -1
  91. package/src/read.ts +2 -5
  92. package/src/stop.ts +2 -3
  93. package/src/write.ts +25 -27
  94. package/dist/battery.d.ts +0 -12
  95. package/dist/battery.js +0 -37
  96. package/dist/calibration.d.ts +0 -7
  97. package/dist/calibration.js +0 -21
  98. package/dist/connect.d.ts +0 -8
  99. package/dist/connect.js +0 -163
  100. package/dist/data/entralpi.d.ts +0 -5
  101. package/dist/data/entralpi.js +0 -33
  102. package/dist/data/index.d.ts +0 -4
  103. package/dist/data/index.js +0 -4
  104. package/dist/data/motherboard.d.ts +0 -10
  105. package/dist/data/motherboard.js +0 -141
  106. package/dist/data/progressor.d.ts +0 -9
  107. package/dist/data/progressor.js +0 -78
  108. package/dist/data/wh-c06.d.ts +0 -5
  109. package/dist/data/wh-c06.js +0 -38
  110. package/dist/devices/climbro.d.ts +0 -6
  111. package/dist/devices/climbro.js +0 -8
  112. package/dist/devices/entralpi.d.ts +0 -5
  113. package/dist/devices/entralpi.js +0 -59
  114. package/dist/devices/index.d.ts +0 -7
  115. package/dist/devices/index.js +0 -7
  116. package/dist/devices/kilterboard.d.ts +0 -10
  117. package/dist/devices/kilterboard.js +0 -34
  118. package/dist/devices/motherboard.d.ts +0 -5
  119. package/dist/devices/motherboard.js +0 -81
  120. package/dist/devices/mysmartboard.d.ts +0 -6
  121. package/dist/devices/mysmartboard.js +0 -8
  122. package/dist/devices/progressor.d.ts +0 -5
  123. package/dist/devices/progressor.js +0 -37
  124. package/dist/devices/wh-c06.d.ts +0 -6
  125. package/dist/devices/wh-c06.js +0 -17
  126. package/dist/disconnect.d.ts +0 -6
  127. package/dist/disconnect.js +0 -12
  128. package/dist/firmware.d.ts +0 -12
  129. package/dist/firmware.js +0 -37
  130. package/dist/hardware.d.ts +0 -11
  131. package/dist/hardware.js +0 -25
  132. package/dist/is-connected.d.ts +0 -7
  133. package/dist/is-connected.js +0 -13
  134. package/dist/led.d.ts +0 -24
  135. package/dist/led.js +0 -196
  136. package/dist/manufacturer.d.ts +0 -11
  137. package/dist/manufacturer.js +0 -25
  138. package/dist/serial.d.ts +0 -11
  139. package/dist/serial.js +0 -30
  140. package/dist/stream.d.ts +0 -8
  141. package/dist/stream.js +0 -41
  142. package/dist/text.d.ts +0 -14
  143. package/dist/text.js +0 -33
  144. package/dist/types/devices.d.ts +0 -38
  145. package/src/battery.ts +0 -39
  146. package/src/calibration.ts +0 -23
  147. package/src/connect.ts +0 -187
  148. package/src/data/entralpi.ts +0 -41
  149. package/src/data/index.ts +0 -7
  150. package/src/data/motherboard.ts +0 -163
  151. package/src/data/progressor.ts +0 -79
  152. package/src/data/wh-c06.ts +0 -47
  153. package/src/devices/climbro.ts +0 -10
  154. package/src/devices/entralpi.ts +0 -61
  155. package/src/devices/index.ts +0 -13
  156. package/src/devices/kilterboard.ts +0 -37
  157. package/src/devices/motherboard.ts +0 -83
  158. package/src/devices/mysmartboard.ts +0 -10
  159. package/src/devices/progressor.ts +0 -38
  160. package/src/devices/wh-c06.ts +0 -19
  161. package/src/disconnect.ts +0 -14
  162. package/src/firmware.ts +0 -39
  163. package/src/hardware.ts +0 -27
  164. package/src/is-connected.ts +0 -15
  165. package/src/led.ts +0 -211
  166. package/src/manufacturer.ts +0 -27
  167. package/src/serial.ts +0 -32
  168. package/src/stream.ts +0 -43
  169. package/src/text.ts +0 -35
  170. package/src/types/devices.ts +0 -39
  171. /package/dist/{types/devices.js → interfaces/base.interface.js} +0 -0
package/README.md CHANGED
@@ -4,10 +4,12 @@
4
4
 
5
5
  The objective of this project is to create a Web Bluetooth API client that can establish connections with various
6
6
  Force-Sensing Hangboards / Dynamometers / Plates / LED system boards used by climbers. Examples of such tools include
7
- the [Griptonite Motherboard](https://griptonite.io/shop/motherboard/), [Climbro](https://climbro.com/),
8
- [mySmartBoard](https://www.smartboard-climbing.com/), [Entralpi](https://entralpi.com/),
9
- [Tindeq Progressor](https://tindeq.com/) or
10
- [Weiheng WH-C06](https://weihengmanufacturer.com/products/wh-c06-bluetooth-300kg-hanging-scale/).
7
+ the [Griptonite Motherboard](https://griptonite.io/shop/motherboard/),
8
+ [Tindeq Progressor](https://tindeq.com/product/progressor/),
9
+ [PitchSix Force Board](https://pitchsix.com/products/force-board-portable),
10
+ [Weiheng WH-C06](https://weihengmanufacturer.com/products/wh-c06-bluetooth-300kg-hanging-scale/),
11
+ [Entralpi](https://entralpi.com/), [Climbro](https://climbro.com/), or
12
+ [mySmartBoard](https://www.smartboard-climbing.com/)
11
13
 
12
14
  And LED system boards from [Aurora Climbing](https://auroraclimbing.com/) like the
13
15
  [Kilter Board](https://settercloset.com/pages/the-kilter-board),
@@ -29,6 +31,8 @@ Learn more: [Docs](https://stevie-ray.github.io/hangtime-grip-connect/) -
29
31
  [Chart](https://grip-connect.vercel.app/) - [Flappy Bird](https://grip-connect-flappy-bird.vercel.app/) -
30
32
  [Kilter Board](https://grip-connect-kilter-board.vercel.app/?route=p1083r15p1117r15p1164r12p1185r12p1233r13p1282r13p1303r13p1372r13p1392r14p1505r15)
31
33
 
34
+ ![Force-Sensing Climbing Devices](https://github.com/user-attachments/assets/c1a8ef3b-8d94-47b6-84a6-f73893e948d6)
35
+
32
36
  ## Install
33
37
 
34
38
  This project can be found in the [NPM package registry](https://www.npmjs.com/package/@hangtime/grip-connect).
@@ -46,13 +50,15 @@ Simply importing the utilities you need from `@hangtime/grip-connect`.
46
50
  ```
47
51
 
48
52
  ```js
49
- import { Motherboard, active, battery, connect, disconnect, firmware, notify, stream } from "@hangtime/grip-connect"
53
+ import { Motherboard, active, connect, disconnect, notify } from "@hangtime/grip-connect"
50
54
 
51
55
  const motherboardButton = document.querySelector("#motherboard")
52
56
 
53
57
  motherboardButton.addEventListener("click", () => {
54
- connect(
55
- Motherboard,
58
+ // setup device
59
+ const motherboard = new Motherboard()
60
+ // connect to device
61
+ motherboard.connect(
56
62
  async () => {
57
63
  // Listen for stream notifications
58
64
  notify((data) => {
@@ -60,24 +66,28 @@ motherboardButton.addEventListener("click", () => {
60
66
  console.log(data)
61
67
  })
62
68
 
63
- // Check if device is being used
64
- active((value) => {
65
- console.log(value)
66
- })
67
-
68
- // Read info: battery + firmware
69
- const batteryLevel = await battery(Motherboard)
69
+ // Reactive check if device is active
70
+ active(
71
+ (isActive) => {
72
+ console.log(isActive)
73
+ },
74
+ // Optionally using a weight threshold and duration
75
+ { threshold: 2.5, duration: 1000 },
76
+ )
77
+
78
+ // Read device specific data: battery + firmware
79
+ const batteryLevel = await motherboard.battery()
70
80
  console.log(batteryLevel)
71
81
 
72
- const firmwareVersion = await firmware(Motherboard)
82
+ const firmwareVersion = await motherboard.firmware()
73
83
  console.log(firmwareVersion)
74
84
 
75
85
  // LEDs: "green", "red", "orange", or no argument to turn off
76
- // await led(Motherboard, "red")
77
- // await led(Motherboard)
86
+ // await motherboard.led(Motherboard, "red")
87
+ // await motherboard.led(Motherboard)
78
88
 
79
89
  // Start weight streaming (for a minute) remove parameter for a continues stream
80
- await stream(Motherboard, 60000)
90
+ await motherboard.stream(60000)
81
91
 
82
92
  // Manualy tare the device when the stream is running
83
93
  // await tare(5000)
@@ -87,15 +97,14 @@ motherboardButton.addEventListener("click", () => {
87
97
 
88
98
  // Download data as CSV, JSON, or XML (default: CSV) format => timestamp, frame, battery, samples, masses
89
99
  // download('json')
90
-
91
- // Disconnect from device after we are done
92
- disconnect(Motherboard)
93
100
  },
94
101
  (error) => {
95
102
  // Optinal custom error handeling
96
103
  console.error(error.message)
97
104
  },
98
105
  )
106
+ // Disconnect from device after we are done
107
+ motherboard.disconnect(Motherboard)
99
108
  })
100
109
  ```
101
110
 
@@ -107,7 +116,8 @@ motherboardButton.addEventListener("click", () => {
107
116
  - By default [watchAdvertisements](https://chromestatus.com/feature/5180688812736512) isn't supported . For Chrome,
108
117
  enable it at `chrome://flags/#enable-experimental-web-platform-features`.
109
118
  - ✅ Kilter Board
110
- - Entralpi (not verified)
119
+ - Entralpi / Lefu Scale
120
+ - ⏳ PitchSix Force Board
111
121
  - ➡️ Climbro
112
122
  - ➡️ Smartboard Climbing - mySmartBoard
113
123
 
@@ -117,28 +127,31 @@ motherboardButton.addEventListener("click", () => {
117
127
  `chrome://bluetooth-internals/#devices` and press `Start Scan` to look for your device, click on `Inspect` and share all
118
128
  available services with us.
119
129
 
120
- | | Motherboard | Progressor | WH-C06 | Entralpi | Kilter Board | Climbro | mySmartBoard |
121
- | ---------------------------------------------------------------------------------------- | ----------- | ---------- | ------ | -------- | ------------ | ------- | ------------ |
122
- | [Battery](https://stevie-ray.github.io/hangtime-grip-connect/api/battery.html) | ✅ | ✅ | | | | | |
123
- | [Calibration](https://stevie-ray.github.io/hangtime-grip-connect/api/calibration.html) | ✅ | | | | | | |
124
- | [Connect](https://stevie-ray.github.io/hangtime-grip-connect/api/connect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | |
125
- | [Disconnect](https://stevie-ray.github.io/hangtime-grip-connect/api/disconnect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | |
126
- | [Download](https://stevie-ray.github.io/hangtime-grip-connect/api/download.html) | ✅ | ✅ | | | | | |
127
- | [Firmware](https://stevie-ray.github.io/hangtime-grip-connect/api/firmware.html) | ✅ | ✅ | | | | | |
128
- | [Hardware](https://stevie-ray.github.io/hangtime-grip-connect/api/hardware.html) | ✅ | | | | | | |
129
- | [isActive](https://stevie-ray.github.io/hangtime-grip-connect/api/is-active.html) | || ✅ | ✅ | | | |
130
- | [isConnected](https://stevie-ray.github.io/hangtime-grip-connect/api/is-connected.html) | ✅ | ✅ | ✅ | ✅ || | |
131
- | [isDevice](https://stevie-ray.github.io/hangtime-grip-connect/api/is-device.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | |
132
- | [Led](https://stevie-ray.github.io/hangtime-grip-connect/api/led.html) | ✅ | | | | ✅ | | |
133
- | [Manufacturer](https://stevie-ray.github.io/hangtime-grip-connect/api/manufacturer.html) | ✅ | | | | | | |
134
- | [Notify](https://stevie-ray.github.io/hangtime-grip-connect/api/notify.html) | ✅ ||| ✅ | | | |
135
- | [Read](https://stevie-ray.github.io/hangtime-grip-connect/api/read.html) || | | | | | |
136
- | [Serial](https://stevie-ray.github.io/hangtime-grip-connect/api/serial.html) | ✅ | | | | | | |
137
- | [Stop](https://stevie-ray.github.io/hangtime-grip-connect/api/stop.html) | ✅ || | | | | |
138
- | [Stream](https://stevie-ray.github.io/hangtime-grip-connect/api/stream.html) | ✅ || | | | | |
139
- | [Tare](https://stevie-ray.github.io/hangtime-grip-connect/api/tare.html) |||| ✅ | | | |
140
- | [Text](https://stevie-ray.github.io/hangtime-grip-connect/api/text.html) | ✅ | | | | | | |
141
- | [Write](https://stevie-ray.github.io/hangtime-grip-connect/api/write.html) | ✅ | ✅ | | | | | |
130
+ | | Motherboard | Progressor | WH-C06 | Entralpi | Kilter Board | Force Board | Climbro | mySmartBoard |
131
+ | ---------------------------------------------------------------------------------------- | ----------- | ---------- | ------ | -------- | ------------ | ----------- | ------- | ------------ |
132
+ | [Battery](https://stevie-ray.github.io/hangtime-grip-connect/api/battery.html) | ✅ | ✅ | || | ✅ | | |
133
+ | [Calibration](https://stevie-ray.github.io/hangtime-grip-connect/api/calibration.html) | ✅ | | | | | | | |
134
+ | [Connect](https://stevie-ray.github.io/hangtime-grip-connect/api/connect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | |
135
+ | [Disconnect](https://stevie-ray.github.io/hangtime-grip-connect/api/disconnect.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | | |
136
+ | [Download](https://stevie-ray.github.io/hangtime-grip-connect/api/download.html) | ✅ | ✅ | | | | | | |
137
+ | [Firmware](https://stevie-ray.github.io/hangtime-grip-connect/api/firmware.html) | ✅ | ✅ | || | | | |
138
+ | [Hardware](https://stevie-ray.github.io/hangtime-grip-connect/api/hardware.html) | ✅ | | || | | | |
139
+ | [Humidity](https://stevie-ray.github.io/hangtime-grip-connect/api/humidity.html) | | | | | | ✅ | | |
140
+ | [isActive](https://stevie-ray.github.io/hangtime-grip-connect/api/is-active.html) | ✅ | ✅ | ✅ | ✅ | | | | |
141
+ | [isConnected](https://stevie-ray.github.io/hangtime-grip-connect/api/is-connected.html) | ✅ | ✅ | ✅ | ✅ | ✅ | | | |
142
+ | [isDevice](https://stevie-ray.github.io/hangtime-grip-connect/api/is-device.html) | ✅ |||| ✅ | | | |
143
+ | [Led](https://stevie-ray.github.io/hangtime-grip-connect/api/led.html) | ✅ | | | || | | |
144
+ | [Manufacturer](https://stevie-ray.github.io/hangtime-grip-connect/api/manufacturer.html) | ✅ | | | ✅ | | ✅ | | |
145
+ | [Model](#) | | | || | | | |
146
+ | [Notify](https://stevie-ray.github.io/hangtime-grip-connect/api/notify.html) | ✅ |||| | | | |
147
+ | [Read](https://stevie-ray.github.io/hangtime-grip-connect/api/read.html) | ✅ | | | | | | | |
148
+ | [Serial](https://stevie-ray.github.io/hangtime-grip-connect/api/serial.html) | ✅ | | | | | | | |
149
+ | [Software](#) | | | | ✅ | | | | |
150
+ | [Stop](https://stevie-ray.github.io/hangtime-grip-connect/api/stop.html) | ✅ || | | | | | |
151
+ | [Stream](https://stevie-ray.github.io/hangtime-grip-connect/api/stream.html) | ✅ | ✅ | | | | | | |
152
+ | [Tare](https://stevie-ray.github.io/hangtime-grip-connect/api/tare.html) | ✅ | ✅ | ✅ | ✅ | | | | |
153
+ | [Text](https://stevie-ray.github.io/hangtime-grip-connect/api/text.html) | ✅ | | | | | | | |
154
+ | [Write](https://stevie-ray.github.io/hangtime-grip-connect/api/write.html) | ✅ | ✅ | | | | | | |
142
155
 
143
156
  ## Development
144
157
 
@@ -164,7 +177,7 @@ A special thank you to:
164
177
  - [@1-max-1](https://github.com/1-max-1) for the docs on his Kilter Board
165
178
  [simulator](https://github.com/1-max-1/fake_kilter_board) that I coverted to
166
179
  [hangtime-arduino-kilterboard](https://github.com/Stevie-Ray/hangtime-arduino-kilterboard).
167
- - [@sebws](https://github.com/sebw) for a [code sample](https://github.com/sebws/Crane) of the Weiheng WH-C06 App.
180
+ - [@sebws](https://github.com/sebws) for a [code sample](https://github.com/sebws/Crane) of the Weiheng WH-C06 App.
168
181
 
169
182
  ## Disclaimer
170
183
 
@@ -1,4 +1,4 @@
1
- import type { Device } from "./types/devices";
1
+ import type { Device } from "./models/device.model";
2
2
  /**
3
3
  * Retrieves the characteristic from the device's service.
4
4
  * @param {Device} board - The device.
@@ -17,4 +17,5 @@ export const getCharacteristic = (board, serviceId, characteristicId) => {
17
17
  }
18
18
  }
19
19
  // Return undefined if the service or characteristic is not found
20
+ return undefined;
20
21
  };
@@ -0,0 +1,6 @@
1
+ import type { Commands } from "../types/commands";
2
+ /**
3
+ * Warning:
4
+ * Using other commands can seriously harm your device
5
+ */
6
+ export declare const ForceBoardCommands: Commands;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Warning:
3
+ * Using other commands can seriously harm your device
4
+ */
5
+ export const ForceBoardCommands = {};
@@ -1,6 +1,7 @@
1
1
  export { ClimbroCommands } from "./climbro";
2
2
  export { EntralpiCommands } from "./entralpi";
3
+ export { ForceBoardCommands } from "./forceboard";
3
4
  export { MotherboardCommands } from "./motherboard";
4
- export { WHC06Commands } from "./wh-c06";
5
- export { ProgressorCommands } from "./progressor";
6
5
  export { mySmartBoardCommands } from "./mysmartboard";
6
+ export { ProgressorCommands } from "./progressor";
7
+ export { WHC06Commands } from "./wh-c06";
@@ -1,6 +1,7 @@
1
1
  export { ClimbroCommands } from "./climbro";
2
2
  export { EntralpiCommands } from "./entralpi";
3
+ export { ForceBoardCommands } from "./forceboard";
3
4
  export { MotherboardCommands } from "./motherboard";
4
- export { WHC06Commands } from "./wh-c06";
5
- export { ProgressorCommands } from "./progressor";
6
5
  export { mySmartBoardCommands } from "./mysmartboard";
6
+ export { ProgressorCommands } from "./progressor";
7
+ export { WHC06Commands } from "./wh-c06";
package/dist/index.d.ts CHANGED
@@ -1,19 +1,7 @@
1
- export { Climbro, Entralpi, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor } from "./devices/index";
1
+ export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor, } from "./models/index";
2
2
  export { isEntralpi, isKilterboard, isMotherboard, isWHC06, isProgressor } from "./is-device";
3
- export { calibration } from "./calibration";
4
3
  export { download } from "./download";
5
- export { connect } from "./connect";
6
- export { disconnect } from "./disconnect";
7
4
  export { active, isActive } from "./is-active";
8
- export { isConnected } from "./is-connected";
9
- export { battery } from "./battery";
10
- export { firmware } from "./firmware";
11
- export { hardware } from "./hardware";
12
- export { manufacturer } from "./manufacturer";
13
- export { text } from "./text";
14
- export { serial } from "./serial";
15
- export { led } from "./led";
16
5
  export { notify } from "./notify";
17
6
  export { stop } from "./stop";
18
- export { stream } from "./stream";
19
7
  export { tare } from "./tare";
package/dist/index.js CHANGED
@@ -1,29 +1,9 @@
1
- // Export device types
2
- export { Climbro, Entralpi, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor } from "./devices/index";
3
- // Export isDevice functions
1
+ export { Climbro, Entralpi, ForceBoard, KilterBoard, Motherboard, mySmartBoard, WHC06, Progressor, } from "./models/index";
2
+ // helpers
4
3
  export { isEntralpi, isKilterboard, isMotherboard, isWHC06, isProgressor } from "./is-device";
5
- // Export calibration function
6
- export { calibration } from "./calibration";
7
- // Export download function
4
+ // functions
8
5
  export { download } from "./download";
9
- // Export connection related functions
10
- export { connect } from "./connect";
11
- export { disconnect } from "./disconnect";
12
6
  export { active, isActive } from "./is-active";
13
- export { isConnected } from "./is-connected";
14
- // Export information retrieval functions
15
- export { battery } from "./battery";
16
- export { firmware } from "./firmware";
17
- // Export "Motherboard exclusive" functions
18
- export { hardware } from "./hardware";
19
- export { manufacturer } from "./manufacturer";
20
- export { text } from "./text";
21
- export { serial } from "./serial";
22
- // Export led retrieval function
23
- export { led } from "./led";
24
- // Export notification related function
25
7
  export { notify } from "./notify";
26
- // Export stream related functions
27
8
  export { stop } from "./stop";
28
- export { stream } from "./stream";
29
9
  export { tare } from "./tare";
@@ -0,0 +1,5 @@
1
+ export interface IBase {
2
+ id?: string;
3
+ createdAt?: Date;
4
+ updatedAt?: Date;
5
+ }
@@ -0,0 +1,3 @@
1
+ import type { IDevice } from "../device.interface";
2
+ export interface IClimbro extends IDevice {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { IDevice } from "../device.interface";
2
+ export interface IEntralpi extends IDevice {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { IDevice } from "../device.interface";
2
+ export interface IForceBoard extends IDevice {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { IDevice } from "../device.interface";
2
+ export interface IKilterBoard extends IDevice {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { IDevice } from "../device.interface";
2
+ export interface IMotherboard extends IDevice {
3
+ /**
4
+ * Applies calibration to a sample value.
5
+ * @param sample - The sample value to calibrate.
6
+ * @param calibration - The calibration data.
7
+ * @returns The calibrated sample value.
8
+ */
9
+ applyCalibration(sample: number, calibration: number[][]): number;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { IDevice } from "../device.interface";
2
+ export interface ImySmartBoard extends IDevice {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { IDevice } from "../device.interface";
2
+ export interface IProgressor extends IDevice {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { IDevice } from "../device.interface";
2
+ export interface IWHC06 extends IDevice {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,76 @@
1
+ import type { IBase } from "./base.interface";
2
+ /**
3
+ * Represents a characteristic of a Bluetooth service.
4
+ */
5
+ interface Characteristic {
6
+ /** Name of the characteristic */
7
+ name: string;
8
+ /** Identifier of the characteristic */
9
+ id: string;
10
+ /** UUID of the characteristic */
11
+ uuid: string;
12
+ /** Reference to the characteristic object */
13
+ characteristic?: BluetoothRemoteGATTCharacteristic;
14
+ }
15
+ /**
16
+ * Represents a Bluetooth service.
17
+ */
18
+ export interface Service {
19
+ /** Name of the service */
20
+ name: string;
21
+ /** Identifier of the service */
22
+ id: string;
23
+ /** UUID of the service */
24
+ uuid: string;
25
+ /** Array of characteristics belonging to this service */
26
+ characteristics: Characteristic[];
27
+ }
28
+ /**
29
+ * Represents a Bluetooth device.
30
+ */
31
+ export interface IDevice extends IBase {
32
+ /** Filters to indentify the device */
33
+ filters: BluetoothLEScanFilter[];
34
+ /** Array of services provided by the device */
35
+ services: Service[];
36
+ /** Reference to the BluetoothDevice object representing this device */
37
+ bluetooth?: BluetoothDevice;
38
+ /**
39
+ * Handles the 'disconnected' event.
40
+ * @param {Event} event - The 'disconnected' event.
41
+ */
42
+ onDisconnected(event: Event): void;
43
+ /**
44
+ * Handles notifications received from a characteristic.
45
+ * @param {Event} event - The notification event.
46
+ */
47
+ handleNotifications(event: Event): void;
48
+ /**
49
+ * Handles the 'connected' event.
50
+ * @param {Function} onSuccess - Callback function to execute on successful connection.
51
+ */
52
+ onConnected(onSuccess: () => void): Promise<void>;
53
+ /**
54
+ * Returns UUIDs of all services associated with the device.
55
+ * @returns {string[]} Array of service UUIDs.
56
+ */
57
+ getAllServiceUUIDs(): string[];
58
+ /**
59
+ * Connects to a Bluetooth device.
60
+ * @param {Function} [onSuccess] - Optional callback function to execute on successful connection. Default logs success.
61
+ * @param {Function} [onError] - Optional callback function to execute on error. Default logs the error.
62
+ */
63
+ connect(onSuccess?: () => void, onError?: (error: Error) => void): Promise<void>;
64
+ /**
65
+ * Checks if a Bluetooth device is connected.
66
+ * @returns {boolean} A boolean indicating whether the device is connected.
67
+ */
68
+ isConnected(): boolean;
69
+ /**
70
+ * Disconnects the device if it is currently connected.
71
+ * - Checks if the device is connected via it's GATT server.
72
+ * - If the device is connected, it attempts to gracefully disconnect.
73
+ */
74
+ disconnect(): void;
75
+ }
76
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -9,16 +9,24 @@ type IsActiveCallback = (value: boolean) => void;
9
9
  */
10
10
  export declare let isActive: boolean;
11
11
  /**
12
- * Sets the callback function to be called when the activity status changes.
12
+ * Sets the callback function to be called when the activity status changes,
13
+ * and optionally sets the configuration for threshold and duration.
13
14
  *
14
15
  * This function allows you to specify a callback that will be invoked whenever
15
16
  * the activity status changes, indicating whether the device is currently active.
17
+ * It also allows optionally configuring the threshold and duration used to determine activity.
16
18
  *
17
19
  * @param {IsActiveCallback} callback - The callback function to be set. This function
18
20
  * receives a boolean value indicating the new activity status.
21
+ * @param {object} [options] - Optional configuration object containing the threshold and duration.
22
+ * @param {number} [options.threshold=2.5] - The threshold value for determining activity.
23
+ * @param {number} [options.duration=1000] - The duration (in milliseconds) to monitor the input for activity.
19
24
  * @returns {void}
20
25
  */
21
- export declare const active: (callback: IsActiveCallback) => void;
26
+ export declare const active: (callback: IsActiveCallback, options?: {
27
+ threshold?: number;
28
+ duration?: number;
29
+ }) => void;
22
30
  /**
23
31
  * Checks if a dynamic value is active based on a threshold and duration.
24
32
  *
@@ -27,11 +35,7 @@ export declare const active: (callback: IsActiveCallback) => void;
27
35
  * the previous state, the callback function is called with the updated activity status.
28
36
  *
29
37
  * @param {number} input - The dynamic value to check for activity status.
30
- * @param {number} [threshold=2.5] - The threshold value to determine if the input is considered active.
31
- * Defaults to 2.5 if not provided.
32
- * @param {number} [duration=1000] - The duration (in milliseconds) to monitor the input for activity.
33
- * Defaults to 1000 milliseconds if not provided.
34
38
  * @returns {Promise<void>} A promise that resolves once the activity check is complete.
35
39
  */
36
- export declare const checkActivity: (input: number, threshold?: number, duration?: number) => Promise<void>;
40
+ export declare const checkActivity: (input: number) => Promise<void>;
37
41
  export {};
package/dist/is-active.js CHANGED
@@ -5,17 +5,31 @@ let activeCallback;
5
5
  */
6
6
  export let isActive = false;
7
7
  /**
8
- * Sets the callback function to be called when the activity status changes.
8
+ * Configuration for threshold and duration.
9
+ */
10
+ let config = { threshold: 2.5, duration: 1000 };
11
+ /**
12
+ * Sets the callback function to be called when the activity status changes,
13
+ * and optionally sets the configuration for threshold and duration.
9
14
  *
10
15
  * This function allows you to specify a callback that will be invoked whenever
11
16
  * the activity status changes, indicating whether the device is currently active.
17
+ * It also allows optionally configuring the threshold and duration used to determine activity.
12
18
  *
13
19
  * @param {IsActiveCallback} callback - The callback function to be set. This function
14
20
  * receives a boolean value indicating the new activity status.
21
+ * @param {object} [options] - Optional configuration object containing the threshold and duration.
22
+ * @param {number} [options.threshold=2.5] - The threshold value for determining activity.
23
+ * @param {number} [options.duration=1000] - The duration (in milliseconds) to monitor the input for activity.
15
24
  * @returns {void}
16
25
  */
17
- export const active = (callback) => {
26
+ export const active = (callback, options) => {
18
27
  activeCallback = callback;
28
+ // Update the config values only if provided, otherwise use defaults
29
+ config = {
30
+ threshold: options?.threshold ?? config.threshold, // Use new threshold if provided, else use default
31
+ duration: options?.duration ?? config.duration, // Use new duration if provided, else use default
32
+ };
19
33
  };
20
34
  /**
21
35
  * Checks if a dynamic value is active based on a threshold and duration.
@@ -25,18 +39,14 @@ export const active = (callback) => {
25
39
  * the previous state, the callback function is called with the updated activity status.
26
40
  *
27
41
  * @param {number} input - The dynamic value to check for activity status.
28
- * @param {number} [threshold=2.5] - The threshold value to determine if the input is considered active.
29
- * Defaults to 2.5 if not provided.
30
- * @param {number} [duration=1000] - The duration (in milliseconds) to monitor the input for activity.
31
- * Defaults to 1000 milliseconds if not provided.
32
42
  * @returns {Promise<void>} A promise that resolves once the activity check is complete.
33
43
  */
34
- export const checkActivity = (input, threshold = 2.5, duration = 1000) => {
44
+ export const checkActivity = (input) => {
35
45
  return new Promise((resolve) => {
36
46
  // Check the activity status after the specified duration
37
47
  setTimeout(() => {
38
- // Determine the activity status based on the threshold
39
- const activeNow = input > threshold;
48
+ // Determine the activity status based on the stored threshold in the config
49
+ const activeNow = input > config.threshold;
40
50
  if (isActive !== activeNow) {
41
51
  isActive = activeNow;
42
52
  if (activeCallback) {
@@ -44,6 +54,6 @@ export const checkActivity = (input, threshold = 2.5, duration = 1000) => {
44
54
  }
45
55
  }
46
56
  resolve();
47
- }, duration);
57
+ }, config.duration);
48
58
  });
49
59
  };
@@ -1,28 +1,34 @@
1
- import type { Device } from "./types/devices";
2
- /**
3
- * Checks if the given device is a Motherboard.
4
- * @param {Device} [board] - The device to check.
5
- * @returns {boolean} `true` if the device has a filter with the name "Motherboard", otherwise `false`.
6
- */
7
- export declare const isMotherboard: (board?: Device) => boolean;
8
- /**
9
- * Checks if the given device is a Progressor.
10
- * @param {Device} [board] - The device to check.
11
- * @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
12
- */
13
- export declare const isProgressor: (board?: Device) => boolean;
1
+ import type { Device } from "./models/device.model";
14
2
  /**
15
3
  * Checks if the given device is an Entralpi device.
16
4
  * @param {Device} [board] - The device to check.
17
5
  * @returns {boolean} `true` if the device has a filter with the name "ENTRALPI", otherwise `false`.
18
6
  */
19
7
  export declare const isEntralpi: (board?: Device) => boolean;
8
+ /**
9
+ * Checks if the given device is a Force Board.
10
+ * @param {Device} [board] - The device to check.
11
+ * @returns {boolean} `true` if the device has a filter with the name "Force Board", otherwise `false`.
12
+ */
13
+ export declare const isForceBoard: (board?: Device) => boolean;
20
14
  /**
21
15
  * Checks if the given device is a Kilterboard.
22
16
  * @param {Device} [board] - The device to check.
23
17
  * @returns {boolean} `true` if the device has a service UUID matching the Kilterboard Aurora UUID, otherwise `false`.
24
18
  */
25
19
  export declare const isKilterboard: (board?: Device) => boolean;
20
+ /**
21
+ * Checks if the given device is a Motherboard.
22
+ * @param {Device} [board] - The device to check.
23
+ * @returns {boolean} `true` if the device has a filter with the name "Motherboard", otherwise `false`.
24
+ */
25
+ export declare const isMotherboard: (board?: Device) => boolean;
26
+ /**
27
+ * Checks if the given device is a Progressor.
28
+ * @param {Device} [board] - The device to check.
29
+ * @returns {boolean} `true` if the device has a filter with a namePrefix of "Progressor", otherwise `false`.
30
+ */
31
+ export declare const isProgressor: (board?: Device) => boolean;
26
32
  /**
27
33
  * Checks if the given device is a WH-C06.
28
34
  * @param {Device} [board] - The device to check.