@microbit/microbit-connection 0.0.0-tab.change.177 → 0.9.0-apps.alpha.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 (292) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +94 -5
  3. package/build/cjs/accelerometer-service.d.ts +18 -0
  4. package/build/cjs/accelerometer-service.js +105 -0
  5. package/build/cjs/accelerometer-service.js.map +1 -0
  6. package/build/cjs/accelerometer.js +16 -0
  7. package/build/cjs/accelerometer.js.map +1 -0
  8. package/build/{async-util.d.ts → cjs/async-util.d.ts} +9 -0
  9. package/build/cjs/async-util.js +47 -0
  10. package/build/cjs/async-util.js.map +1 -0
  11. package/build/cjs/bluetooth-device-wrapper.d.ts +97 -0
  12. package/build/cjs/bluetooth-device-wrapper.js +486 -0
  13. package/build/cjs/bluetooth-device-wrapper.js.map +1 -0
  14. package/build/{bluetooth-profile.d.ts → cjs/bluetooth-profile.d.ts} +43 -35
  15. package/build/cjs/bluetooth-profile.js +92 -0
  16. package/build/cjs/bluetooth-profile.js.map +1 -0
  17. package/build/cjs/bluetooth.d.ts +112 -0
  18. package/build/cjs/bluetooth.js +458 -0
  19. package/build/cjs/bluetooth.js.map +1 -0
  20. package/build/cjs/board-id.js +81 -0
  21. package/build/cjs/board-id.js.map +1 -0
  22. package/build/cjs/board-serial-info.js +51 -0
  23. package/build/cjs/board-serial-info.js.map +1 -0
  24. package/build/cjs/button-service.d.ts +13 -0
  25. package/build/cjs/button-service.js +66 -0
  26. package/build/cjs/button-service.js.map +1 -0
  27. package/build/cjs/buttons.js +22 -0
  28. package/build/cjs/buttons.js.map +1 -0
  29. package/build/cjs/constants.js +73 -0
  30. package/build/cjs/constants.js.map +1 -0
  31. package/build/cjs/device-information-service.d.ts +6 -0
  32. package/build/cjs/device-information-service.js +34 -0
  33. package/build/cjs/device-information-service.js.map +1 -0
  34. package/build/{device.d.ts → cjs/device.d.ts} +71 -39
  35. package/build/cjs/device.js +147 -0
  36. package/build/cjs/device.js.map +1 -0
  37. package/build/cjs/dfu-service.d.ts +9 -0
  38. package/build/cjs/dfu-service.js +26 -0
  39. package/build/cjs/dfu-service.js.map +1 -0
  40. package/build/{events.d.ts → cjs/events.d.ts} +1 -2
  41. package/build/cjs/events.js +109 -0
  42. package/build/cjs/events.js.map +1 -0
  43. package/build/cjs/flashing/flashing-full.d.ts +14 -0
  44. package/build/cjs/flashing/flashing-full.js +87 -0
  45. package/build/cjs/flashing/flashing-full.js.map +1 -0
  46. package/build/cjs/flashing/flashing-makecode.d.ts +6 -0
  47. package/build/cjs/flashing/flashing-makecode.js +48 -0
  48. package/build/cjs/flashing/flashing-makecode.js.map +1 -0
  49. package/build/cjs/flashing/flashing-partial.d.ts +9 -0
  50. package/build/cjs/flashing/flashing-partial.js +98 -0
  51. package/build/cjs/flashing/flashing-partial.js.map +1 -0
  52. package/build/cjs/flashing/flashing-v1.d.ts +11 -0
  53. package/build/cjs/flashing/flashing-v1.js +24 -0
  54. package/build/cjs/flashing/flashing-v1.js.map +1 -0
  55. package/build/cjs/flashing/nordic-dfu.d.ts +3 -0
  56. package/build/cjs/flashing/nordic-dfu.js +214 -0
  57. package/build/cjs/flashing/nordic-dfu.js.map +1 -0
  58. package/build/cjs/flashing/zip.d.ts +12 -0
  59. package/build/cjs/flashing/zip.js +177 -0
  60. package/build/cjs/flashing/zip.js.map +1 -0
  61. package/build/cjs/hex-flash-data-source.js +26 -0
  62. package/build/cjs/hex-flash-data-source.js.map +1 -0
  63. package/build/cjs/index.d.ts +17 -0
  64. package/build/cjs/index.js +37 -0
  65. package/build/cjs/index.js.map +1 -0
  66. package/build/cjs/led-service.d.ts +18 -0
  67. package/build/cjs/led-service.js +89 -0
  68. package/build/cjs/led-service.js.map +1 -0
  69. package/build/cjs/led.js +3 -0
  70. package/build/cjs/led.js.map +1 -0
  71. package/build/{logging.d.ts → cjs/logging.d.ts} +4 -4
  72. package/build/cjs/logging.js +16 -0
  73. package/build/cjs/logging.js.map +1 -0
  74. package/build/cjs/magnetometer-service.d.ts +18 -0
  75. package/build/cjs/magnetometer-service.js +94 -0
  76. package/build/cjs/magnetometer-service.js.map +1 -0
  77. package/build/cjs/magnetometer.d.ts +9 -0
  78. package/build/cjs/magnetometer.js +16 -0
  79. package/build/cjs/magnetometer.js.map +1 -0
  80. package/build/cjs/package.json +1 -0
  81. package/build/cjs/partial-flashing-service.d.ts +45 -0
  82. package/build/cjs/partial-flashing-service.js +110 -0
  83. package/build/cjs/partial-flashing-service.js.map +1 -0
  84. package/build/cjs/promise-queue.js +78 -0
  85. package/build/cjs/promise-queue.js.map +1 -0
  86. package/build/cjs/serial-events.d.ts +20 -0
  87. package/build/cjs/serial-events.js +69 -0
  88. package/build/cjs/serial-events.js.map +1 -0
  89. package/build/{service-events.d.ts → cjs/service-events.d.ts} +4 -0
  90. package/build/cjs/service-events.js +39 -0
  91. package/build/cjs/service-events.js.map +1 -0
  92. package/build/cjs/setupTests.js.map +1 -0
  93. package/build/cjs/uart-service.d.ts +12 -0
  94. package/build/cjs/uart-service.js +55 -0
  95. package/build/cjs/uart-service.js.map +1 -0
  96. package/build/cjs/uart.d.ts +4 -0
  97. package/build/cjs/uart.js +16 -0
  98. package/build/cjs/uart.js.map +1 -0
  99. package/build/{usb-device-wrapper.d.ts → cjs/usb-device-wrapper.d.ts} +1 -6
  100. package/build/cjs/usb-device-wrapper.js +437 -0
  101. package/build/cjs/usb-device-wrapper.js.map +1 -0
  102. package/build/cjs/usb-partial-flashing-utils.js +133 -0
  103. package/build/cjs/usb-partial-flashing-utils.js.map +1 -0
  104. package/build/{usb-partial-flashing.d.ts → cjs/usb-partial-flashing.d.ts} +3 -5
  105. package/build/cjs/usb-partial-flashing.js +342 -0
  106. package/build/cjs/usb-partial-flashing.js.map +1 -0
  107. package/build/cjs/usb-radio-bridge.d.ts +24 -0
  108. package/build/cjs/usb-radio-bridge.js +515 -0
  109. package/build/cjs/usb-radio-bridge.js.map +1 -0
  110. package/build/cjs/usb-serial-protocol.js +183 -0
  111. package/build/cjs/usb-serial-protocol.js.map +1 -0
  112. package/build/cjs/usb.d.ts +66 -0
  113. package/build/cjs/usb.js +662 -0
  114. package/build/cjs/usb.js.map +1 -0
  115. package/build/esm/accelerometer-service.d.ts +18 -0
  116. package/build/esm/accelerometer-service.js +101 -0
  117. package/build/esm/accelerometer-service.js.map +1 -0
  118. package/build/esm/accelerometer.d.ts +9 -0
  119. package/build/esm/accelerometer.js.map +1 -0
  120. package/build/esm/async-util.d.ts +22 -0
  121. package/build/esm/async-util.js +38 -0
  122. package/build/esm/async-util.js.map +1 -0
  123. package/build/esm/bluetooth-device-wrapper.d.ts +97 -0
  124. package/build/esm/bluetooth-device-wrapper.js +481 -0
  125. package/build/esm/bluetooth-device-wrapper.js.map +1 -0
  126. package/build/esm/bluetooth-profile.d.ts +147 -0
  127. package/build/{bluetooth-profile.js → esm/bluetooth-profile.js} +35 -29
  128. package/build/esm/bluetooth-profile.js.map +1 -0
  129. package/build/esm/bluetooth.d.ts +112 -0
  130. package/build/esm/bluetooth.js +428 -0
  131. package/build/esm/bluetooth.js.map +1 -0
  132. package/build/esm/board-id.d.ts +36 -0
  133. package/build/esm/board-id.js.map +1 -0
  134. package/build/esm/board-serial-info.d.ts +14 -0
  135. package/build/esm/board-serial-info.js.map +1 -0
  136. package/build/esm/button-service.d.ts +13 -0
  137. package/build/esm/button-service.js +62 -0
  138. package/build/esm/button-service.js.map +1 -0
  139. package/build/esm/buttons.d.ts +10 -0
  140. package/build/esm/buttons.js.map +1 -0
  141. package/build/esm/constants.d.ts +48 -0
  142. package/build/esm/constants.js.map +1 -0
  143. package/build/esm/device-information-service.d.ts +6 -0
  144. package/build/esm/device-information-service.js +30 -0
  145. package/build/esm/device-information-service.js.map +1 -0
  146. package/build/esm/device.d.ts +238 -0
  147. package/build/{device.js → esm/device.js} +16 -58
  148. package/build/esm/device.js.map +1 -0
  149. package/build/esm/dfu-service.d.ts +9 -0
  150. package/build/esm/dfu-service.js +22 -0
  151. package/build/esm/dfu-service.js.map +1 -0
  152. package/build/esm/events.d.ts +110 -0
  153. package/build/esm/events.js.map +1 -0
  154. package/build/esm/flashing/flashing-full.d.ts +14 -0
  155. package/build/esm/flashing/flashing-full.js +84 -0
  156. package/build/esm/flashing/flashing-full.js.map +1 -0
  157. package/build/esm/flashing/flashing-makecode.d.ts +6 -0
  158. package/build/esm/flashing/flashing-makecode.js +44 -0
  159. package/build/esm/flashing/flashing-makecode.js.map +1 -0
  160. package/build/esm/flashing/flashing-partial.d.ts +9 -0
  161. package/build/esm/flashing/flashing-partial.js +95 -0
  162. package/build/esm/flashing/flashing-partial.js.map +1 -0
  163. package/build/esm/flashing/flashing-v1.d.ts +11 -0
  164. package/build/esm/flashing/flashing-v1.js +20 -0
  165. package/build/esm/flashing/flashing-v1.js.map +1 -0
  166. package/build/esm/flashing/nordic-dfu.d.ts +3 -0
  167. package/build/esm/flashing/nordic-dfu.js +211 -0
  168. package/build/esm/flashing/nordic-dfu.js.map +1 -0
  169. package/build/esm/flashing/zip.d.ts +12 -0
  170. package/build/esm/flashing/zip.js +174 -0
  171. package/build/esm/flashing/zip.js.map +1 -0
  172. package/build/esm/hex-flash-data-source.d.ts +7 -0
  173. package/build/esm/hex-flash-data-source.js.map +1 -0
  174. package/build/esm/index.d.ts +17 -0
  175. package/build/esm/index.js +12 -0
  176. package/build/esm/index.js.map +1 -0
  177. package/build/esm/led-service.d.ts +18 -0
  178. package/build/esm/led-service.js +85 -0
  179. package/build/esm/led-service.js.map +1 -0
  180. package/build/esm/led.d.ts +6 -0
  181. package/build/esm/led.js.map +1 -0
  182. package/build/esm/logging.d.ts +21 -0
  183. package/build/{logging.js → esm/logging.js} +1 -1
  184. package/build/esm/logging.js.map +1 -0
  185. package/build/esm/magnetometer-service.d.ts +18 -0
  186. package/build/esm/magnetometer-service.js +90 -0
  187. package/build/esm/magnetometer-service.js.map +1 -0
  188. package/build/esm/magnetometer.d.ts +9 -0
  189. package/build/esm/magnetometer.js +12 -0
  190. package/build/esm/magnetometer.js.map +1 -0
  191. package/build/esm/package.json +1 -0
  192. package/build/esm/partial-flashing-service.d.ts +45 -0
  193. package/build/esm/partial-flashing-service.js +106 -0
  194. package/build/esm/partial-flashing-service.js.map +1 -0
  195. package/build/esm/promise-queue.d.ts +27 -0
  196. package/build/esm/promise-queue.js.map +1 -0
  197. package/build/esm/serial-events.d.ts +20 -0
  198. package/build/esm/serial-events.js +61 -0
  199. package/build/esm/serial-events.js.map +1 -0
  200. package/build/esm/service-events.d.ts +17 -0
  201. package/build/{service-events.js → esm/service-events.js} +12 -0
  202. package/build/esm/service-events.js.map +1 -0
  203. package/build/esm/setupTests.d.ts +6 -0
  204. package/build/{setupTests.js.map → esm/setupTests.js.map} +1 -1
  205. package/build/esm/uart-service.d.ts +12 -0
  206. package/build/esm/uart-service.js +51 -0
  207. package/build/esm/uart-service.js.map +1 -0
  208. package/build/esm/uart.d.ts +4 -0
  209. package/build/esm/uart.js +12 -0
  210. package/build/esm/uart.js.map +1 -0
  211. package/build/esm/usb-device-wrapper.d.ts +47 -0
  212. package/build/{usb-device-wrapper.js → esm/usb-device-wrapper.js} +43 -17
  213. package/build/esm/usb-device-wrapper.js.map +1 -0
  214. package/build/esm/usb-partial-flashing-utils.d.ts +17 -0
  215. package/build/esm/usb-partial-flashing-utils.js.map +1 -0
  216. package/build/esm/usb-partial-flashing.d.ts +67 -0
  217. package/build/{usb-partial-flashing.js → esm/usb-partial-flashing.js} +12 -13
  218. package/build/esm/usb-partial-flashing.js.map +1 -0
  219. package/build/esm/usb-radio-bridge.d.ts +24 -0
  220. package/build/{usb-radio-bridge.js → esm/usb-radio-bridge.js} +13 -7
  221. package/build/esm/usb-radio-bridge.js.map +1 -0
  222. package/build/esm/usb-serial-protocol.d.ts +66 -0
  223. package/build/esm/usb-serial-protocol.js.map +1 -0
  224. package/build/esm/usb.d.ts +66 -0
  225. package/build/{usb.js → esm/usb.js} +257 -49
  226. package/build/esm/usb.js.map +1 -0
  227. package/package.json +25 -8
  228. package/typedoc.json +14 -0
  229. package/build/accelerometer-service.d.ts +0 -18
  230. package/build/accelerometer-service.js +0 -102
  231. package/build/accelerometer-service.js.map +0 -1
  232. package/build/accelerometer.js.map +0 -1
  233. package/build/async-util.js +0 -22
  234. package/build/async-util.js.map +0 -1
  235. package/build/bluetooth-device-wrapper.d.ts +0 -57
  236. package/build/bluetooth-device-wrapper.js +0 -433
  237. package/build/bluetooth-device-wrapper.js.map +0 -1
  238. package/build/bluetooth-profile.js.map +0 -1
  239. package/build/bluetooth.d.ts +0 -54
  240. package/build/bluetooth.js +0 -243
  241. package/build/bluetooth.js.map +0 -1
  242. package/build/board-id.js.map +0 -1
  243. package/build/board-serial-info.js.map +0 -1
  244. package/build/button-service.d.ts +0 -13
  245. package/build/button-service.js +0 -76
  246. package/build/button-service.js.map +0 -1
  247. package/build/buttons.js.map +0 -1
  248. package/build/constants.js.map +0 -1
  249. package/build/device.js.map +0 -1
  250. package/build/events.js.map +0 -1
  251. package/build/hex-flash-data-source.js.map +0 -1
  252. package/build/index.d.ts +0 -10
  253. package/build/index.js +0 -8
  254. package/build/index.js.map +0 -1
  255. package/build/led-service.d.ts +0 -20
  256. package/build/led-service.js +0 -116
  257. package/build/led-service.js.map +0 -1
  258. package/build/led.js.map +0 -1
  259. package/build/logging.js.map +0 -1
  260. package/build/promise-queue.js.map +0 -1
  261. package/build/service-events.js.map +0 -1
  262. package/build/usb-device-wrapper.js.map +0 -1
  263. package/build/usb-partial-flashing-utils.js.map +0 -1
  264. package/build/usb-partial-flashing.js.map +0 -1
  265. package/build/usb-radio-bridge.d.ts +0 -41
  266. package/build/usb-radio-bridge.js.map +0 -1
  267. package/build/usb-serial-protocol.js.map +0 -1
  268. package/build/usb.d.ts +0 -54
  269. package/build/usb.js.map +0 -1
  270. package/vite.config.ts +0 -34
  271. /package/build/{accelerometer.d.ts → cjs/accelerometer.d.ts} +0 -0
  272. /package/build/{board-id.d.ts → cjs/board-id.d.ts} +0 -0
  273. /package/build/{board-serial-info.d.ts → cjs/board-serial-info.d.ts} +0 -0
  274. /package/build/{buttons.d.ts → cjs/buttons.d.ts} +0 -0
  275. /package/build/{constants.d.ts → cjs/constants.d.ts} +0 -0
  276. /package/build/{hex-flash-data-source.d.ts → cjs/hex-flash-data-source.d.ts} +0 -0
  277. /package/build/{led.d.ts → cjs/led.d.ts} +0 -0
  278. /package/build/{promise-queue.d.ts → cjs/promise-queue.d.ts} +0 -0
  279. /package/build/{setupTests.d.ts → cjs/setupTests.d.ts} +0 -0
  280. /package/build/{usb-partial-flashing-utils.d.ts → cjs/usb-partial-flashing-utils.d.ts} +0 -0
  281. /package/build/{usb-serial-protocol.d.ts → cjs/usb-serial-protocol.d.ts} +0 -0
  282. /package/build/{accelerometer.js → esm/accelerometer.js} +0 -0
  283. /package/build/{board-id.js → esm/board-id.js} +0 -0
  284. /package/build/{board-serial-info.js → esm/board-serial-info.js} +0 -0
  285. /package/build/{buttons.js → esm/buttons.js} +0 -0
  286. /package/build/{constants.js → esm/constants.js} +0 -0
  287. /package/build/{events.js → esm/events.js} +0 -0
  288. /package/build/{hex-flash-data-source.js → esm/hex-flash-data-source.js} +0 -0
  289. /package/build/{led.js → esm/led.js} +0 -0
  290. /package/build/{promise-queue.js → esm/promise-queue.js} +0 -0
  291. /package/build/{usb-partial-flashing-utils.js → esm/usb-partial-flashing-utils.js} +0 -0
  292. /package/build/{usb-serial-protocol.js → esm/usb-serial-protocol.js} +0 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2025 Micro:bit Educational Foundation and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,10 +1,99 @@
1
- # JavaScript library for micro:bit connections in browsers via USB and Bluetooth
1
+ # micro:bit connection library
2
2
 
3
- This project is a work in progress. We are extracting WebUSB and Web Bluetooth code from the [micro:bit Python Editor](https://github.com/microbit-foundation/python-editor-v3/) and other projects.
3
+ <a href="https://microbit-foundation.github.io/microbit-connection/" class="typedoc-ignore">This documentation is best viewed on the documentation site rather than GitHub or NPM package site.</a>
4
4
 
5
- It is intended to be used by other Micro:bit Educational Foundation projects that need to connect to a BBC micro:bit.
5
+ This is a JavaScript library for micro:bit connections in browsers via USB and Bluetooth.
6
6
 
7
- The API is not stable and it's not yet recommended that third parties use this project.
7
+ This project is a work in progress. We are extracting WebUSB and Web Bluetooth code from the [micro:bit Python Editor](https://github.com/microbit-foundation/python-editor-v3/) and other projects. The API is not stable and it's not yet recommended that third parties use this project unless they are happy to update usage as the API evolves.
8
+
9
+ [Demo page](https://microbit-connection.pages.dev/) for this library.
10
+
11
+ [Alpha releases are now on NPM](https://www.npmjs.com/package/@microbit/microbit-connection).
12
+
13
+ [micro:bit CreateAI](https://github.com/microbit-foundation/ml-trainer/) is already using this library for WebUSB and Web Bluetooth.
14
+
15
+ [This Python Editor PR](https://github.com/microbit-foundation/python-editor-v3/pull/1190) tracks updating the micro:bit Python Editor to use this library.
16
+
17
+ ## Usage
18
+
19
+ ### Flash a micro:bit
20
+
21
+ Instantiate a WebUSB connection using {@link createWebUSBConnection} class and use it to connect to a micro:bit.
22
+
23
+ ```ts
24
+ import { createWebUSBConnection } from "@microbit/microbit-connection";
25
+
26
+ const usb = createWebUSBConnection();
27
+ const connectionStatus = await usb.connect();
28
+
29
+ console.log("Connection status: ", connectionStatus);
30
+ ```
31
+
32
+ {@link ConnectionStatus | Connection status} is `"CONNECTED"` if connection succeeds.
33
+
34
+ Flash a universal hex that supports both V1 and V2:
35
+
36
+ ```ts
37
+ import { createUniversalHexFlashDataSource } from "@microbit/microbit-connection";
38
+
39
+ await usb.flash(createUniversalHexFlashDataSource(universalHexString), {
40
+ partial: true,
41
+ progress: (stage, percentage) => {
42
+ console.log(stage, percentage);
43
+ },
44
+ });
45
+ ```
46
+
47
+ This code will also work for non-universal hex files so is a good default for unknown hex files.
48
+
49
+ Alternatively, you can create and flash a hex for a specific micro:bit version by providing a function that takes a {@link BoardVersion} and returns a hex.
50
+ This can reduce download size or help integrate with APIs that produce a hex for a particular device version.
51
+ This example uses the [@microbit/microbit-fs library](https://microbit-foundation.github.io/microbit-fs/) which can return a hex based on board id.
52
+
53
+ ```ts
54
+ import { MicropythonFsHex, microbitBoardId } from "@microbit/microbit-fs";
55
+ import { BoardId } from "@microbit/microbit-connection";
56
+
57
+ const micropythonFs = new MicropythonFsHex([
58
+ { hex: microPythonV1HexFile, boardId: microbitBoardId.V1 },
59
+ { hex: microPythonV2HexFile, boardId: microbitBoardId.V2 },
60
+ ]);
61
+ // Add files to MicroPython file system here (omitted for simplicity)
62
+ // Flash the device
63
+ await usb.flash(
64
+ async (boardVersion) => {
65
+ const boardId = BoardId.forVersion(boardVersion).id;
66
+ return micropythonFs.getIntelHex(boardId);
67
+ },
68
+ {
69
+ partial: true,
70
+ progress: (stage, percentage) => {
71
+ console.log(stage, percentage);
72
+ },
73
+ },
74
+ );
75
+ ```
76
+
77
+ For more examples of using other methods in the {@link MicrobitWebUSBConnection} class, see our [demo code](https://github.com/microbit-foundation/microbit-connection/blob/main/src/demo.ts) for our [demo site](https://microbit-connection.pages.dev/).
78
+
79
+ ### Connect via Bluetooth
80
+
81
+ By default, the micro:bit's Bluetooth service is not enabled. Visit our [Bluetooth tech site page](https://tech.microbit.org/bluetooth/) to download a hex file that would enable the bluetooth service.
82
+
83
+ Instantiate a Bluetooth connection using {@link createWebBluetoothConnection} class and use it to connect to a micro:bit.
84
+
85
+ ```ts
86
+ import { createWebBluetoothConnection } from "@microbit/microbit-connection";
87
+
88
+ const bluetooth = createWebBluetoothConnection();
89
+ const connectionStatus = await bluetooth.connect();
90
+
91
+ console.log("Connection status: ", connectionStatus);
92
+ ```
93
+
94
+ {@link ConnectionStatus | Connection status} is `"CONNECTED"` if connection succeeds.
95
+
96
+ For more examples of using other methods in the {@link createWebBluetoothConnection} class, see our [demo code](https://github.com/microbit-foundation/microbit-connection/blob/main/src/demo.ts) for our [demo site](https://microbit-connection.pages.dev/).
8
97
 
9
98
  ## License
10
99
 
@@ -22,7 +111,7 @@ $ npx license-checker --direct --summary --production
22
111
 
23
112
  Omit the flags as desired to obtain more detail.
24
113
 
25
- ## Code of Conduct
114
+ ## Code of conduct
26
115
 
27
116
  Trust, partnership, simplicity and passion are our core values we live and
28
117
  breathe in our daily work life and within our projects. Our open-source
@@ -0,0 +1,18 @@
1
+ import { AccelerometerData } from "./accelerometer.js";
2
+ import { Service } from "./bluetooth-device-wrapper.js";
3
+ import { TypedServiceEvent, TypedServiceEventDispatcher } from "./service-events.js";
4
+ export declare class AccelerometerService implements Service {
5
+ private deviceId;
6
+ private dispatchTypedEvent;
7
+ uuid: string;
8
+ static createService(deviceId: string, dispatchTypedEvent: TypedServiceEventDispatcher): AccelerometerService;
9
+ constructor(deviceId: string, dispatchTypedEvent: TypedServiceEventDispatcher);
10
+ getRelevantEvents(): TypedServiceEvent[];
11
+ private dataViewToData;
12
+ getData(): Promise<AccelerometerData>;
13
+ getPeriod(): Promise<number>;
14
+ setPeriod(value: number): Promise<void>;
15
+ startNotifications(type: TypedServiceEvent): Promise<void>;
16
+ stopNotifications(type: TypedServiceEvent): Promise<void>;
17
+ private characteristicForEvent;
18
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccelerometerService = void 0;
4
+ const bluetooth_le_1 = require("@capacitor-community/bluetooth-le");
5
+ const accelerometer_js_1 = require("./accelerometer.js");
6
+ const bluetooth_profile_js_1 = require("./bluetooth-profile.js");
7
+ const device_js_1 = require("./device.js");
8
+ class AccelerometerService {
9
+ static createService(deviceId, dispatchTypedEvent) {
10
+ return new AccelerometerService(deviceId, dispatchTypedEvent);
11
+ }
12
+ constructor(deviceId, dispatchTypedEvent) {
13
+ Object.defineProperty(this, "deviceId", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: deviceId
18
+ });
19
+ Object.defineProperty(this, "dispatchTypedEvent", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: dispatchTypedEvent
24
+ });
25
+ Object.defineProperty(this, "uuid", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: bluetooth_profile_js_1.profile.accelerometer.id
30
+ });
31
+ }
32
+ getRelevantEvents() {
33
+ return ["accelerometerdatachanged"];
34
+ }
35
+ dataViewToData(dataView) {
36
+ return {
37
+ x: dataView.getInt16(0, true),
38
+ y: dataView.getInt16(2, true),
39
+ z: dataView.getInt16(4, true),
40
+ };
41
+ }
42
+ async getData() {
43
+ const dataView = await bluetooth_le_1.BleClient.read(this.deviceId, bluetooth_profile_js_1.profile.accelerometer.id, bluetooth_profile_js_1.profile.accelerometer.characteristics.data.id);
44
+ return this.dataViewToData(dataView);
45
+ }
46
+ async getPeriod() {
47
+ const dataView = await bluetooth_le_1.BleClient.read(this.deviceId, bluetooth_profile_js_1.profile.accelerometer.id, bluetooth_profile_js_1.profile.accelerometer.characteristics.period.id);
48
+ return dataView.getUint16(0, true);
49
+ }
50
+ async setPeriod(value) {
51
+ if (value === 0) {
52
+ // Writing 0 causes the device to crash.
53
+ return;
54
+ }
55
+ // Allowed values: 2, 5, 10, 20, 40, 100, 1000
56
+ // Values passed are rounded up to the allowed values on device.
57
+ // Documentation for allowed values looks wrong.
58
+ // https://lancaster-university.github.io/microbit-docs/ble/profile/#about-the-accelerometer-service
59
+ const dataView = new DataView(new ArrayBuffer(2));
60
+ dataView.setUint16(0, value, true);
61
+ await bluetooth_le_1.BleClient.write(this.deviceId, bluetooth_profile_js_1.profile.accelerometer.id, bluetooth_profile_js_1.profile.accelerometer.characteristics.period.id, dataView);
62
+ }
63
+ async startNotifications(type) {
64
+ const result = this.characteristicForEvent(type);
65
+ if (result) {
66
+ const { service, characteristic } = result;
67
+ try {
68
+ await bluetooth_le_1.BleClient.startNotifications(this.deviceId, service, characteristic, (value) => {
69
+ const data = this.dataViewToData(value);
70
+ this.dispatchTypedEvent("accelerometerdatachanged", new accelerometer_js_1.AccelerometerDataEvent(data));
71
+ });
72
+ }
73
+ catch (e) {
74
+ this.dispatchTypedEvent("backgrounderror", new device_js_1.BackgroundErrorEvent("Failed to start notifications", e));
75
+ }
76
+ }
77
+ }
78
+ async stopNotifications(type) {
79
+ const result = this.characteristicForEvent(type);
80
+ if (result) {
81
+ const { service, characteristic } = result;
82
+ try {
83
+ await bluetooth_le_1.BleClient.stopNotifications(this.deviceId, service, characteristic);
84
+ }
85
+ catch (e) {
86
+ this.dispatchTypedEvent("backgrounderror", new device_js_1.BackgroundErrorEvent("Failed to stop notifications", e));
87
+ }
88
+ }
89
+ }
90
+ characteristicForEvent(type) {
91
+ switch (type) {
92
+ case "accelerometerdatachanged": {
93
+ return {
94
+ service: bluetooth_profile_js_1.profile.accelerometer.id,
95
+ characteristic: bluetooth_profile_js_1.profile.accelerometer.characteristics.data.id,
96
+ };
97
+ }
98
+ default: {
99
+ return undefined;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ exports.AccelerometerService = AccelerometerService;
105
+ //# sourceMappingURL=accelerometer-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accelerometer-service.js","sourceRoot":"","sources":["../../lib/accelerometer-service.ts"],"names":[],"mappings":";;;AAAA,oEAA8D;AAC9D,yDAA+E;AAM/E,iEAAiD;AACjD,2CAAmD;AAEnD,MAAa,oBAAoB;IAG/B,MAAM,CAAC,aAAa,CAClB,QAAgB,EAChB,kBAA+C;QAE/C,OAAO,IAAI,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAChE,CAAC;IAED,YACU,QAAgB,EAChB,kBAA+C;QADvD;;;;mBAAQ,QAAQ;WAAQ;QACxB;;;;mBAAQ,kBAAkB;WAA6B;QAXzD;;;;mBAAO,8BAAO,CAAC,aAAa,CAAC,EAAE;WAAC;IAY7B,CAAC;IAEJ,iBAAiB;QACf,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACtC,CAAC;IAEO,cAAc,CAAC,QAAkB;QACvC,OAAO;YACL,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC;YAC7B,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC;YAC7B,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC;SAC9B,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,QAAQ,GAAG,MAAM,wBAAS,CAAC,IAAI,CACnC,IAAI,CAAC,QAAQ,EACb,8BAAO,CAAC,aAAa,CAAC,EAAE,EACxB,8BAAO,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAC9C,CAAC;QACF,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,QAAQ,GAAG,MAAM,wBAAS,CAAC,IAAI,CACnC,IAAI,CAAC,QAAQ,EACb,8BAAO,CAAC,aAAa,CAAC,EAAE,EACxB,8BAAO,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAChD,CAAC;QACF,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAa;QAC3B,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,wCAAwC;YACxC,OAAO;QACT,CAAC;QACD,8CAA8C;QAC9C,gEAAgE;QAChE,gDAAgD;QAChD,oGAAoG;QACpG,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACnC,MAAM,wBAAS,CAAC,KAAK,CACnB,IAAI,CAAC,QAAQ,EACb,8BAAO,CAAC,aAAa,CAAC,EAAE,EACxB,8BAAO,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,EAC/C,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,IAAuB;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;YAC3C,IAAI,CAAC;gBACH,MAAM,wBAAS,CAAC,kBAAkB,CAChC,IAAI,CAAC,QAAQ,EACb,OAAO,EACP,cAAc,EACd,CAAC,KAAK,EAAE,EAAE;oBACR,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;oBACxC,IAAI,CAAC,kBAAkB,CACrB,0BAA0B,EAC1B,IAAI,yCAAsB,CAAC,IAAI,CAAC,CACjC,CAAC;gBACJ,CAAC,CACF,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,kBAAkB,CACrB,iBAAiB,EACjB,IAAI,gCAAoB,CAAC,+BAA+B,EAAE,CAAC,CAAC,CAC7D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAuB;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;YAC3C,IAAI,CAAC;gBACH,MAAM,wBAAS,CAAC,iBAAiB,CAC/B,IAAI,CAAC,QAAQ,EACb,OAAO,EACP,cAAc,CACf,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,kBAAkB,CACrB,iBAAiB,EACjB,IAAI,gCAAoB,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAC5D,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAEO,sBAAsB,CAAC,IAAuB;QACpD,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,0BAA0B,CAAC,CAAC,CAAC;gBAChC,OAAO;oBACL,OAAO,EAAE,8BAAO,CAAC,aAAa,CAAC,EAAE;oBACjC,cAAc,EAAE,8BAAO,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;iBAC9D,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA1HD,oDA0HC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccelerometerDataEvent = void 0;
4
+ class AccelerometerDataEvent extends Event {
5
+ constructor(data) {
6
+ super("accelerometerdatachanged");
7
+ Object.defineProperty(this, "data", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: data
12
+ });
13
+ }
14
+ }
15
+ exports.AccelerometerDataEvent = AccelerometerDataEvent;
16
+ //# sourceMappingURL=accelerometer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accelerometer.js","sourceRoot":"","sources":["../../lib/accelerometer.ts"],"names":[],"mappings":";;;AAMA,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAA4B,IAAuB;QACjD,KAAK,CAAC,0BAA0B,CAAC,CAAC;QADxB;;;;mBAAgB,IAAI;WAAmB;IAEnD,CAAC;CACF;AAJD,wDAIC"}
@@ -5,9 +5,18 @@
5
5
  */
6
6
  export declare class TimeoutError extends Error {
7
7
  }
8
+ export declare class DisconnectError extends Error {
9
+ constructor(message?: string);
10
+ }
8
11
  /**
9
12
  * Utility to time out an action after a delay.
10
13
  *
11
14
  * The action cannot be cancelled; it may still proceed after the timeout.
12
15
  */
13
16
  export declare function withTimeout<T>(actionPromise: Promise<T>, timeout: number): Promise<T>;
17
+ export declare function delay(millis: number): Promise<unknown>;
18
+ export declare function timeoutErrorAfter<T>(millis: number, message?: string): Promise<T>;
19
+ export declare function disconnectErrorCallback<T>(message?: string): {
20
+ promise: Promise<T>;
21
+ callback: () => void | undefined;
22
+ };
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DisconnectError = exports.TimeoutError = void 0;
4
+ exports.withTimeout = withTimeout;
5
+ exports.delay = delay;
6
+ exports.timeoutErrorAfter = timeoutErrorAfter;
7
+ exports.disconnectErrorCallback = disconnectErrorCallback;
8
+ /**
9
+ * (c) 2021, Micro:bit Educational Foundation and contributors
10
+ *
11
+ * SPDX-License-Identifier: MIT
12
+ */
13
+ class TimeoutError extends Error {
14
+ }
15
+ exports.TimeoutError = TimeoutError;
16
+ class DisconnectError extends Error {
17
+ constructor(message = "Disconnect") {
18
+ super(message);
19
+ }
20
+ }
21
+ exports.DisconnectError = DisconnectError;
22
+ /**
23
+ * Utility to time out an action after a delay.
24
+ *
25
+ * The action cannot be cancelled; it may still proceed after the timeout.
26
+ */
27
+ async function withTimeout(actionPromise, timeout) {
28
+ return Promise.race([
29
+ actionPromise,
30
+ timeoutErrorAfter(timeout),
31
+ ]);
32
+ }
33
+ async function delay(millis) {
34
+ return new Promise((resolve) => setTimeout(resolve, millis));
35
+ }
36
+ async function timeoutErrorAfter(millis, message = "Timeout") {
37
+ await delay(millis);
38
+ throw new TimeoutError(message);
39
+ }
40
+ function disconnectErrorCallback(message = "Disconnect") {
41
+ let callback;
42
+ const promise = new Promise((_, reject) => {
43
+ callback = () => reject(new DisconnectError(message));
44
+ });
45
+ return { promise, callback: callback };
46
+ }
47
+ //# sourceMappingURL=async-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-util.js","sourceRoot":"","sources":["../../lib/async-util.ts"],"names":[],"mappings":";;;AAkBA,kCAQC;AAED,sBAEC;AAED,8CAMC;AAED,0DAMC;AA9CD;;;;GAIG;AACH,MAAa,YAAa,SAAQ,KAAK;CAAG;AAA1C,oCAA0C;AAE1C,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,UAAkB,YAAY;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAJD,0CAIC;AAED;;;;GAIG;AACI,KAAK,UAAU,WAAW,CAC/B,aAAyB,EACzB,OAAe;IAEf,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,aAAa;QACb,iBAAiB,CAAC,OAAO,CAAC;KAC3B,CAAe,CAAC;AACnB,CAAC;AAEM,KAAK,UAAU,KAAK,CAAC,MAAc;IACxC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC/D,CAAC;AAEM,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,UAAkB,SAAS;IAE3B,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,MAAM,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,uBAAuB,CAAI,UAAkB,YAAY;IACvE,IAAI,QAAgC,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC3C,QAAQ,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAS,EAAE,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors
3
+ *
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { BleDevice, TimeoutOptions } from "@capacitor-community/bluetooth-le";
7
+ import { AccelerometerService } from "./accelerometer-service.js";
8
+ import { ButtonService } from "./button-service.js";
9
+ import { DeviceInformationService } from "./device-information-service.js";
10
+ import { BoardVersion } from "./device.js";
11
+ import { LedService } from "./led-service.js";
12
+ import { Logging, LoggingEvent } from "./logging.js";
13
+ import { MagnetometerService } from "./magnetometer-service.js";
14
+ import { ServiceConnectionEventMap, TypedServiceEvent, TypedServiceEventDispatcher } from "./service-events.js";
15
+ import { UARTService } from "./uart-service.js";
16
+ export declare const bondingTimeoutInMs = 40000;
17
+ export declare const connectTimeoutInMs = 10000;
18
+ export declare const scanningTimeoutInMs = 10000;
19
+ export declare const isAndroid: () => boolean;
20
+ export interface Service {
21
+ readonly uuid: string;
22
+ getRelevantEvents(): TypedServiceEvent[];
23
+ startNotifications(type: TypedServiceEvent): Promise<void>;
24
+ stopNotifications(type: TypedServiceEvent): Promise<void>;
25
+ }
26
+ interface ConnectCallbacks {
27
+ onConnecting: () => void;
28
+ onReconnecting: () => void;
29
+ onFail: () => void;
30
+ onSuccess: () => void;
31
+ }
32
+ export declare class BluetoothDeviceWrapper implements Logging {
33
+ readonly device: BleDevice;
34
+ private logging;
35
+ private currentEvents;
36
+ private callbacks;
37
+ private duringExplicitConnectDisconnect;
38
+ private connected;
39
+ private isReconnect;
40
+ private serviceIds;
41
+ accelerometer: AccelerometerService;
42
+ buttons: ButtonService;
43
+ deviceInformation: DeviceInformationService;
44
+ led: LedService;
45
+ magnetometer: MagnetometerService;
46
+ uart: UARTService;
47
+ /**
48
+ * Only defined after connection.
49
+ */
50
+ boardVersion: BoardVersion | undefined;
51
+ private services;
52
+ private waitingForDisconnectEventCallbacks;
53
+ private internalNotificationListeners;
54
+ constructor(device: BleDevice, logging: Logging, dispatchTypedEvent: TypedServiceEventDispatcher, currentEvents: () => Array<keyof ServiceConnectionEventMap>, callbacks: ConnectCallbacks);
55
+ connect(): Promise<void>;
56
+ private connectInternal;
57
+ disconnect(): Promise<void>;
58
+ private disconnectInternal;
59
+ reconnect(): Promise<void>;
60
+ handleDisconnectEvent: () => Promise<void>;
61
+ getBoardVersion(): Promise<BoardVersion>;
62
+ startNotifications(type: TypedServiceEvent): Promise<void>;
63
+ stopNotifications(type: TypedServiceEvent): Promise<void>;
64
+ private getServicesForEvent;
65
+ startInternalNotifications(serviceId: string, characteristicId: string, options?: TimeoutOptions): Promise<void>;
66
+ subscribe(serviceId: string, characteristicId: string, callback: (data: Uint8Array) => void): void;
67
+ unsubscribe(serviceId: string, characteristicId: string, callback: (data: Uint8Array) => void): void;
68
+ stopInternalNotifications(serviceId: string, characteristicId: string): Promise<void>;
69
+ /**
70
+ * Write to characteristic and wait for a notification response.
71
+ *
72
+ * It is the responsibility of the caller to have started notifications
73
+ * for the characteristic.
74
+ */
75
+ writeForNotification(serviceId: string, characteristicId: string, value: DataView, notificationId: number, isFinalNotification?: (p: Uint8Array) => boolean): Promise<Uint8Array>;
76
+ waitForDisconnect(timeout: number): Promise<void>;
77
+ /**
78
+ * Suitable for running a series of BLE interactions with an overall timeout
79
+ * and general disconnection
80
+ */
81
+ raceDisconnectAndTimeout<T>(promise: Promise<T>, options?: {
82
+ actionName?: string;
83
+ timeout?: number;
84
+ }): Promise<T>;
85
+ private disconnectErrorPromise;
86
+ event(event: LoggingEvent): void;
87
+ log(message: string): void;
88
+ error(message: string, e?: unknown): void;
89
+ private getNotificationKey;
90
+ /**
91
+ * Bonds with device and handles the post-bond device state only returning
92
+ * when we can reattempt a connection with the device.
93
+ */
94
+ private connectHandlingBond;
95
+ private bondConnectDeviceInternal;
96
+ }
97
+ export {};