@microbit/microbit-connection 0.9.0-apps.alpha.16 → 0.9.0-apps.alpha.17

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 (441) hide show
  1. package/build/{esm/bluetooth.d.ts → cjs/bluetooth/connection.d.ts} +30 -26
  2. package/build/cjs/{bluetooth.js → bluetooth/connection.js} +147 -104
  3. package/build/cjs/bluetooth/connection.js.map +1 -0
  4. package/build/cjs/{bluetooth.test.js → bluetooth/connection.test.js} +9 -9
  5. package/build/cjs/bluetooth/connection.test.js.map +1 -0
  6. package/build/cjs/bluetooth/device-bond-state.js.map +1 -0
  7. package/build/cjs/{bluetooth-device-wrapper.d.ts → bluetooth/device-wrapper.d.ts} +11 -11
  8. package/build/cjs/{bluetooth-device-wrapper.js → bluetooth/device-wrapper.js} +35 -35
  9. package/build/cjs/bluetooth/device-wrapper.js.map +1 -0
  10. package/build/cjs/{flashing → bluetooth/flashing}/flashing-full.d.ts +2 -2
  11. package/build/cjs/{flashing → bluetooth/flashing}/flashing-full.js +4 -4
  12. package/build/cjs/bluetooth/flashing/flashing-full.js.map +1 -0
  13. package/build/cjs/{flashing → bluetooth/flashing}/flashing-makecode.d.ts +1 -1
  14. package/build/cjs/bluetooth/flashing/flashing-makecode.js.map +1 -0
  15. package/build/cjs/{flashing → bluetooth/flashing}/flashing-makecode.test.js +3 -3
  16. package/build/cjs/bluetooth/flashing/flashing-makecode.test.js.map +1 -0
  17. package/build/cjs/{flashing → bluetooth/flashing}/flashing-partial.d.ts +2 -2
  18. package/build/cjs/{flashing → bluetooth/flashing}/flashing-partial.js +5 -5
  19. package/build/cjs/bluetooth/flashing/flashing-partial.js.map +1 -0
  20. package/build/cjs/bluetooth/flashing/flashing-v1.js.map +1 -0
  21. package/build/cjs/{flashing → bluetooth/flashing}/nordic-dfu.d.ts +2 -2
  22. package/build/cjs/{flashing → bluetooth/flashing}/nordic-dfu.js +11 -8
  23. package/build/cjs/bluetooth/flashing/nordic-dfu.js.map +1 -0
  24. package/build/cjs/bluetooth/flashing/zip.js.map +1 -0
  25. package/build/cjs/bluetooth/flashing/zip.test.js.map +1 -0
  26. package/build/cjs/bluetooth/index.d.ts +5 -0
  27. package/build/cjs/bluetooth/index.js +9 -0
  28. package/build/cjs/bluetooth/index.js.map +1 -0
  29. package/build/cjs/{bluetooth-profile.js → bluetooth/profile.js} +1 -1
  30. package/build/cjs/bluetooth/profile.js.map +1 -0
  31. package/build/cjs/{accelerometer-service.d.ts → bluetooth/services/accelerometer-service.d.ts} +2 -3
  32. package/build/cjs/{accelerometer-service.js → bluetooth/services/accelerometer-service.js} +16 -12
  33. package/build/cjs/bluetooth/services/accelerometer-service.js.map +1 -0
  34. package/build/{esm → cjs/bluetooth/services}/button-service.d.ts +2 -3
  35. package/build/cjs/{button-service.js → bluetooth/services/button-service.js} +15 -14
  36. package/build/cjs/bluetooth/services/button-service.js.map +1 -0
  37. package/build/{esm → cjs/bluetooth/services}/device-information-service.d.ts +1 -1
  38. package/build/cjs/{device-information-service.js → bluetooth/services/device-information-service.js} +2 -2
  39. package/build/cjs/bluetooth/services/device-information-service.js.map +1 -0
  40. package/build/cjs/{dfu-service.js → bluetooth/services/dfu-service.js} +2 -2
  41. package/build/cjs/bluetooth/services/dfu-service.js.map +1 -0
  42. package/build/{esm → cjs/bluetooth/services}/led-service.d.ts +2 -3
  43. package/build/cjs/{led-service.js → bluetooth/services/led-service.js} +7 -7
  44. package/build/cjs/bluetooth/services/led-service.js.map +1 -0
  45. package/build/cjs/{magnetometer-service.d.ts → bluetooth/services/magnetometer-service.d.ts} +2 -3
  46. package/build/cjs/{magnetometer-service.js → bluetooth/services/magnetometer-service.js} +18 -14
  47. package/build/cjs/bluetooth/services/magnetometer-service.js.map +1 -0
  48. package/build/{esm → cjs/bluetooth/services}/partial-flashing-service.d.ts +1 -1
  49. package/build/cjs/{partial-flashing-service.js → bluetooth/services/partial-flashing-service.js} +8 -8
  50. package/build/cjs/bluetooth/services/partial-flashing-service.js.map +1 -0
  51. package/build/cjs/{uart-service.d.ts → bluetooth/services/uart-service.d.ts} +2 -2
  52. package/build/cjs/{uart-service.js → bluetooth/services/uart-service.js} +12 -9
  53. package/build/cjs/bluetooth/services/uart-service.js.map +1 -0
  54. package/build/cjs/board-id.d.ts +1 -1
  55. package/build/cjs/board-id.js.map +1 -1
  56. package/build/cjs/device.d.ts +82 -75
  57. package/build/cjs/device.js +40 -126
  58. package/build/cjs/device.js.map +1 -1
  59. package/build/cjs/events.d.ts +9 -108
  60. package/build/cjs/events.js +27 -88
  61. package/build/cjs/events.js.map +1 -1
  62. package/build/cjs/events.test.js +54 -48
  63. package/build/cjs/events.test.js.map +1 -1
  64. package/build/cjs/hex-util.d.ts +1 -0
  65. package/build/cjs/hex-util.js +15 -0
  66. package/build/cjs/hex-util.js.map +1 -0
  67. package/build/cjs/index.d.ts +7 -16
  68. package/build/cjs/index.js +6 -26
  69. package/build/cjs/index.js.map +1 -1
  70. package/build/cjs/radio-bridge/connection.d.ts +39 -0
  71. package/build/cjs/{usb-radio-bridge.js → radio-bridge/connection.js} +39 -25
  72. package/build/cjs/radio-bridge/connection.js.map +1 -0
  73. package/build/cjs/radio-bridge/index.d.ts +4 -0
  74. package/build/cjs/radio-bridge/index.js +9 -0
  75. package/build/cjs/radio-bridge/index.js.map +1 -0
  76. package/build/cjs/{usb-serial-protocol.js → radio-bridge/serial-protocol.js} +1 -1
  77. package/build/cjs/radio-bridge/serial-protocol.js.map +1 -0
  78. package/build/cjs/service-events.d.ts +42 -14
  79. package/build/cjs/service-events.js +6 -36
  80. package/build/cjs/service-events.js.map +1 -1
  81. package/build/{esm/hex-flash-data-source.d.ts → cjs/universal-hex/flash-data-source.d.ts} +1 -2
  82. package/build/cjs/{hex-flash-data-source.js → universal-hex/flash-data-source.js} +7 -15
  83. package/build/cjs/universal-hex/flash-data-source.js.map +1 -0
  84. package/build/cjs/universal-hex/index.d.ts +4 -0
  85. package/build/cjs/universal-hex/index.js +9 -0
  86. package/build/cjs/universal-hex/index.js.map +1 -0
  87. package/build/cjs/usb/arm-debug.d.ts +137 -0
  88. package/build/cjs/usb/arm-debug.js +414 -0
  89. package/build/cjs/usb/arm-debug.js.map +1 -0
  90. package/build/cjs/usb/arm-debug.test.js +333 -0
  91. package/build/cjs/usb/arm-debug.test.js.map +1 -0
  92. package/build/{esm → cjs/usb}/board-serial-info.d.ts +2 -1
  93. package/build/cjs/{board-serial-info.js → usb/board-serial-info.js} +10 -7
  94. package/build/cjs/usb/board-serial-info.js.map +1 -0
  95. package/build/cjs/{board-serial-info.test.js → usb/board-serial-info.test.js} +2 -4
  96. package/build/cjs/usb/board-serial-info.test.js.map +1 -0
  97. package/build/cjs/usb/cdc-saturation.d.ts +36 -0
  98. package/build/cjs/usb/cdc-saturation.js +151 -0
  99. package/build/cjs/usb/cdc-saturation.js.map +1 -0
  100. package/build/cjs/usb/cmsis-dap.d.ts +113 -0
  101. package/build/cjs/usb/cmsis-dap.js +349 -0
  102. package/build/cjs/usb/cmsis-dap.js.map +1 -0
  103. package/build/cjs/usb/cmsis-dap.test.js +350 -0
  104. package/build/cjs/usb/cmsis-dap.test.js.map +1 -0
  105. package/build/cjs/usb/connection.d.ts +81 -0
  106. package/build/cjs/{usb.js → usb/connection.js} +243 -166
  107. package/build/cjs/usb/connection.js.map +1 -0
  108. package/build/cjs/{usb.test.js → usb/connection.test.js} +52 -42
  109. package/build/cjs/usb/connection.test.js.map +1 -0
  110. package/build/cjs/usb/cortex-m.d.ts +72 -0
  111. package/build/cjs/usb/cortex-m.js +165 -0
  112. package/build/cjs/usb/cortex-m.js.map +1 -0
  113. package/build/cjs/usb/cortex-m.test.js +217 -0
  114. package/build/cjs/usb/cortex-m.test.js.map +1 -0
  115. package/build/cjs/usb/daplink.d.ts +69 -0
  116. package/build/cjs/usb/daplink.js +238 -0
  117. package/build/cjs/usb/daplink.js.map +1 -0
  118. package/build/cjs/usb/daplink.test.js +290 -0
  119. package/build/cjs/usb/daplink.test.js.map +1 -0
  120. package/build/cjs/usb/device-wrapper.d.ts +34 -0
  121. package/build/cjs/usb/device-wrapper.js +102 -0
  122. package/build/cjs/usb/device-wrapper.js.map +1 -0
  123. package/build/cjs/usb/index.d.ts +5 -0
  124. package/build/cjs/usb/index.js +10 -0
  125. package/build/cjs/usb/index.js.map +1 -0
  126. package/build/{esm/usb-partial-flashing-utils.d.ts → cjs/usb/partial-flashing-utils.d.ts} +6 -9
  127. package/build/cjs/{usb-partial-flashing-utils.js → usb/partial-flashing-utils.js} +6 -49
  128. package/build/cjs/usb/partial-flashing-utils.js.map +1 -0
  129. package/build/{esm/usb-partial-flashing.d.ts → cjs/usb/partial-flashing.d.ts} +15 -7
  130. package/build/cjs/{usb-partial-flashing.js → usb/partial-flashing.js} +64 -119
  131. package/build/cjs/usb/partial-flashing.js.map +1 -0
  132. package/build/cjs/usb/promise-queue.js.map +1 -0
  133. package/build/cjs/usb/promise-queue.test.js.map +1 -0
  134. package/build/cjs/usb/serial-events.d.ts +21 -0
  135. package/build/cjs/{led.js → usb/serial-events.js} +1 -1
  136. package/build/cjs/usb/serial-events.js.map +1 -0
  137. package/build/cjs/usb/transport.d.ts +42 -0
  138. package/build/cjs/usb/transport.js +155 -0
  139. package/build/cjs/usb/transport.js.map +1 -0
  140. package/build/{cjs/bluetooth.d.ts → esm/bluetooth/connection.d.ts} +30 -26
  141. package/build/esm/{bluetooth.js → bluetooth/connection.js} +141 -98
  142. package/build/esm/bluetooth/connection.js.map +1 -0
  143. package/build/esm/{bluetooth.test.js → bluetooth/connection.test.js} +9 -9
  144. package/build/esm/bluetooth/connection.test.js.map +1 -0
  145. package/build/esm/bluetooth/device-bond-state.js.map +1 -0
  146. package/build/esm/{bluetooth-device-wrapper.d.ts → bluetooth/device-wrapper.d.ts} +11 -11
  147. package/build/esm/{bluetooth-device-wrapper.js → bluetooth/device-wrapper.js} +32 -32
  148. package/build/esm/bluetooth/device-wrapper.js.map +1 -0
  149. package/build/esm/{flashing → bluetooth/flashing}/flashing-full.d.ts +2 -2
  150. package/build/esm/{flashing → bluetooth/flashing}/flashing-full.js +4 -4
  151. package/build/esm/bluetooth/flashing/flashing-full.js.map +1 -0
  152. package/build/esm/{flashing → bluetooth/flashing}/flashing-makecode.d.ts +1 -1
  153. package/build/esm/bluetooth/flashing/flashing-makecode.js.map +1 -0
  154. package/build/esm/{flashing → bluetooth/flashing}/flashing-makecode.test.js +2 -2
  155. package/build/esm/bluetooth/flashing/flashing-makecode.test.js.map +1 -0
  156. package/build/esm/{flashing → bluetooth/flashing}/flashing-partial.d.ts +2 -2
  157. package/build/esm/{flashing → bluetooth/flashing}/flashing-partial.js +4 -4
  158. package/build/esm/bluetooth/flashing/flashing-partial.js.map +1 -0
  159. package/build/esm/bluetooth/flashing/flashing-v1.js.map +1 -0
  160. package/build/esm/{flashing → bluetooth/flashing}/nordic-dfu.d.ts +2 -2
  161. package/build/esm/{flashing → bluetooth/flashing}/nordic-dfu.js +11 -8
  162. package/build/esm/bluetooth/flashing/nordic-dfu.js.map +1 -0
  163. package/build/esm/bluetooth/flashing/zip.js.map +1 -0
  164. package/build/esm/bluetooth/flashing/zip.test.d.ts +1 -0
  165. package/build/esm/bluetooth/flashing/zip.test.js.map +1 -0
  166. package/build/esm/bluetooth/index.d.ts +5 -0
  167. package/build/esm/bluetooth/index.js +5 -0
  168. package/build/esm/bluetooth/index.js.map +1 -0
  169. package/build/esm/{bluetooth-profile.js → bluetooth/profile.js} +1 -1
  170. package/build/{cjs/bluetooth-profile.js.map → esm/bluetooth/profile.js.map} +1 -1
  171. package/build/esm/{accelerometer-service.d.ts → bluetooth/services/accelerometer-service.d.ts} +2 -3
  172. package/build/esm/{accelerometer-service.js → bluetooth/services/accelerometer-service.js} +10 -6
  173. package/build/esm/bluetooth/services/accelerometer-service.js.map +1 -0
  174. package/build/{cjs → esm/bluetooth/services}/button-service.d.ts +2 -3
  175. package/build/esm/{button-service.js → bluetooth/services/button-service.js} +10 -9
  176. package/build/esm/bluetooth/services/button-service.js.map +1 -0
  177. package/build/{cjs → esm/bluetooth/services}/device-information-service.d.ts +1 -1
  178. package/build/esm/{device-information-service.js → bluetooth/services/device-information-service.js} +1 -1
  179. package/build/esm/bluetooth/services/device-information-service.js.map +1 -0
  180. package/build/esm/{dfu-service.js → bluetooth/services/dfu-service.js} +1 -1
  181. package/build/esm/bluetooth/services/dfu-service.js.map +1 -0
  182. package/build/{cjs → esm/bluetooth/services}/led-service.d.ts +2 -3
  183. package/build/esm/{led-service.js → bluetooth/services/led-service.js} +1 -1
  184. package/build/esm/bluetooth/services/led-service.js.map +1 -0
  185. package/build/esm/{magnetometer-service.d.ts → bluetooth/services/magnetometer-service.d.ts} +2 -3
  186. package/build/esm/{magnetometer-service.js → bluetooth/services/magnetometer-service.js} +10 -6
  187. package/build/esm/bluetooth/services/magnetometer-service.js.map +1 -0
  188. package/build/{cjs → esm/bluetooth/services}/partial-flashing-service.d.ts +1 -1
  189. package/build/esm/{partial-flashing-service.js → bluetooth/services/partial-flashing-service.js} +4 -4
  190. package/build/esm/bluetooth/services/partial-flashing-service.js.map +1 -0
  191. package/build/esm/{uart-service.d.ts → bluetooth/services/uart-service.d.ts} +2 -2
  192. package/build/esm/{uart-service.js → bluetooth/services/uart-service.js} +8 -5
  193. package/build/esm/bluetooth/services/uart-service.js.map +1 -0
  194. package/build/esm/board-id.d.ts +1 -1
  195. package/build/esm/board-id.js.map +1 -1
  196. package/build/esm/device.d.ts +82 -75
  197. package/build/esm/device.js +38 -120
  198. package/build/esm/device.js.map +1 -1
  199. package/build/esm/events.d.ts +9 -108
  200. package/build/esm/events.js +26 -86
  201. package/build/esm/events.js.map +1 -1
  202. package/build/esm/events.test.js +55 -49
  203. package/build/esm/events.test.js.map +1 -1
  204. package/build/esm/hex-util.d.ts +1 -0
  205. package/build/esm/hex-util.js +11 -0
  206. package/build/esm/hex-util.js.map +1 -0
  207. package/build/esm/index.d.ts +7 -16
  208. package/build/esm/index.js +6 -10
  209. package/build/esm/index.js.map +1 -1
  210. package/build/esm/radio-bridge/connection.d.ts +39 -0
  211. package/build/esm/{usb-radio-bridge.js → radio-bridge/connection.js} +39 -25
  212. package/build/esm/radio-bridge/connection.js.map +1 -0
  213. package/build/esm/radio-bridge/index.d.ts +4 -0
  214. package/build/esm/radio-bridge/index.js +5 -0
  215. package/build/esm/radio-bridge/index.js.map +1 -0
  216. package/build/esm/{usb-serial-protocol.js → radio-bridge/serial-protocol.js} +1 -1
  217. package/build/esm/radio-bridge/serial-protocol.js.map +1 -0
  218. package/build/esm/service-events.d.ts +42 -14
  219. package/build/esm/service-events.js +5 -34
  220. package/build/esm/service-events.js.map +1 -1
  221. package/build/{cjs/hex-flash-data-source.d.ts → esm/universal-hex/flash-data-source.d.ts} +1 -2
  222. package/build/esm/{hex-flash-data-source.js → universal-hex/flash-data-source.js} +6 -13
  223. package/build/esm/universal-hex/flash-data-source.js.map +1 -0
  224. package/build/esm/universal-hex/index.d.ts +4 -0
  225. package/build/esm/universal-hex/index.js +5 -0
  226. package/build/esm/universal-hex/index.js.map +1 -0
  227. package/build/esm/usb/arm-debug.d.ts +137 -0
  228. package/build/esm/usb/arm-debug.js +409 -0
  229. package/build/esm/usb/arm-debug.js.map +1 -0
  230. package/build/esm/usb/arm-debug.test.d.ts +1 -0
  231. package/build/esm/usb/arm-debug.test.js +331 -0
  232. package/build/esm/usb/arm-debug.test.js.map +1 -0
  233. package/build/{cjs → esm/usb}/board-serial-info.d.ts +2 -1
  234. package/build/esm/{board-serial-info.js → usb/board-serial-info.js} +10 -7
  235. package/build/esm/usb/board-serial-info.js.map +1 -0
  236. package/build/esm/usb/board-serial-info.test.d.ts +1 -0
  237. package/build/esm/{board-serial-info.test.js → usb/board-serial-info.test.js} +2 -4
  238. package/build/esm/usb/board-serial-info.test.js.map +1 -0
  239. package/build/esm/usb/cdc-saturation.d.ts +36 -0
  240. package/build/esm/usb/cdc-saturation.js +148 -0
  241. package/build/esm/usb/cdc-saturation.js.map +1 -0
  242. package/build/esm/usb/cmsis-dap.d.ts +113 -0
  243. package/build/esm/usb/cmsis-dap.js +342 -0
  244. package/build/esm/usb/cmsis-dap.js.map +1 -0
  245. package/build/esm/usb/cmsis-dap.test.d.ts +1 -0
  246. package/build/esm/usb/cmsis-dap.test.js +348 -0
  247. package/build/esm/usb/cmsis-dap.test.js.map +1 -0
  248. package/build/esm/usb/connection.d.ts +81 -0
  249. package/build/esm/{usb.js → usb/connection.js} +239 -161
  250. package/build/esm/usb/connection.js.map +1 -0
  251. package/build/esm/usb/connection.test.d.ts +1 -0
  252. package/build/esm/{usb.test.js → usb/connection.test.js} +47 -37
  253. package/build/esm/usb/connection.test.js.map +1 -0
  254. package/build/esm/usb/cortex-m.d.ts +72 -0
  255. package/build/esm/usb/cortex-m.js +161 -0
  256. package/build/esm/usb/cortex-m.js.map +1 -0
  257. package/build/esm/usb/cortex-m.test.d.ts +1 -0
  258. package/build/esm/usb/cortex-m.test.js +215 -0
  259. package/build/esm/usb/cortex-m.test.js.map +1 -0
  260. package/build/esm/usb/daplink.d.ts +69 -0
  261. package/build/esm/usb/daplink.js +231 -0
  262. package/build/esm/usb/daplink.js.map +1 -0
  263. package/build/esm/usb/daplink.test.d.ts +1 -0
  264. package/build/esm/usb/daplink.test.js +288 -0
  265. package/build/esm/usb/daplink.test.js.map +1 -0
  266. package/build/esm/usb/device-wrapper.d.ts +34 -0
  267. package/build/esm/usb/device-wrapper.js +98 -0
  268. package/build/esm/usb/device-wrapper.js.map +1 -0
  269. package/build/esm/usb/index.d.ts +5 -0
  270. package/build/esm/usb/index.js +5 -0
  271. package/build/esm/usb/index.js.map +1 -0
  272. package/build/{cjs/usb-partial-flashing-utils.d.ts → esm/usb/partial-flashing-utils.d.ts} +6 -9
  273. package/build/esm/{usb-partial-flashing-utils.js → usb/partial-flashing-utils.js} +4 -44
  274. package/build/esm/usb/partial-flashing-utils.js.map +1 -0
  275. package/build/{cjs/usb-partial-flashing.d.ts → esm/usb/partial-flashing.d.ts} +15 -7
  276. package/build/esm/{usb-partial-flashing.js → usb/partial-flashing.js} +62 -94
  277. package/build/esm/usb/partial-flashing.js.map +1 -0
  278. package/build/esm/usb/promise-queue.js.map +1 -0
  279. package/build/esm/usb/promise-queue.test.d.ts +1 -0
  280. package/build/esm/usb/promise-queue.test.js.map +1 -0
  281. package/build/esm/usb/serial-events.d.ts +21 -0
  282. package/build/esm/usb/serial-events.js +2 -0
  283. package/build/esm/usb/serial-events.js.map +1 -0
  284. package/build/esm/usb/transport.d.ts +42 -0
  285. package/build/esm/usb/transport.js +151 -0
  286. package/build/esm/usb/transport.js.map +1 -0
  287. package/package.json +43 -2
  288. package/build/cjs/accelerometer-service.js.map +0 -1
  289. package/build/cjs/accelerometer.d.ts +0 -9
  290. package/build/cjs/accelerometer.js +0 -16
  291. package/build/cjs/accelerometer.js.map +0 -1
  292. package/build/cjs/bluetooth-device-wrapper.js.map +0 -1
  293. package/build/cjs/bluetooth.js.map +0 -1
  294. package/build/cjs/bluetooth.test.js.map +0 -1
  295. package/build/cjs/board-serial-info.js.map +0 -1
  296. package/build/cjs/board-serial-info.test.js.map +0 -1
  297. package/build/cjs/button-service.js.map +0 -1
  298. package/build/cjs/buttons.d.ts +0 -10
  299. package/build/cjs/buttons.js +0 -22
  300. package/build/cjs/buttons.js.map +0 -1
  301. package/build/cjs/constants.d.ts +0 -48
  302. package/build/cjs/constants.js +0 -73
  303. package/build/cjs/constants.js.map +0 -1
  304. package/build/cjs/device-bond-state.js.map +0 -1
  305. package/build/cjs/device-information-service.js.map +0 -1
  306. package/build/cjs/dfu-service.js.map +0 -1
  307. package/build/cjs/flashing/flashing-full.js.map +0 -1
  308. package/build/cjs/flashing/flashing-makecode.js.map +0 -1
  309. package/build/cjs/flashing/flashing-makecode.test.js.map +0 -1
  310. package/build/cjs/flashing/flashing-partial.js.map +0 -1
  311. package/build/cjs/flashing/flashing-v1.js.map +0 -1
  312. package/build/cjs/flashing/nordic-dfu.js.map +0 -1
  313. package/build/cjs/flashing/zip.js.map +0 -1
  314. package/build/cjs/flashing/zip.test.js.map +0 -1
  315. package/build/cjs/hex-flash-data-source.js.map +0 -1
  316. package/build/cjs/led-service.js.map +0 -1
  317. package/build/cjs/led.d.ts +0 -6
  318. package/build/cjs/led.js.map +0 -1
  319. package/build/cjs/magnetometer-service.js.map +0 -1
  320. package/build/cjs/magnetometer.d.ts +0 -9
  321. package/build/cjs/magnetometer.js +0 -16
  322. package/build/cjs/magnetometer.js.map +0 -1
  323. package/build/cjs/partial-flashing-service.js.map +0 -1
  324. package/build/cjs/promise-queue.js.map +0 -1
  325. package/build/cjs/promise-queue.test.js.map +0 -1
  326. package/build/cjs/serial-events.d.ts +0 -20
  327. package/build/cjs/serial-events.js +0 -69
  328. package/build/cjs/serial-events.js.map +0 -1
  329. package/build/cjs/uart-service.js.map +0 -1
  330. package/build/cjs/uart.d.ts +0 -4
  331. package/build/cjs/uart.js +0 -16
  332. package/build/cjs/uart.js.map +0 -1
  333. package/build/cjs/usb-device-wrapper.d.ts +0 -47
  334. package/build/cjs/usb-device-wrapper.js +0 -437
  335. package/build/cjs/usb-device-wrapper.js.map +0 -1
  336. package/build/cjs/usb-partial-flashing-utils.js.map +0 -1
  337. package/build/cjs/usb-partial-flashing.js.map +0 -1
  338. package/build/cjs/usb-radio-bridge.d.ts +0 -24
  339. package/build/cjs/usb-radio-bridge.js.map +0 -1
  340. package/build/cjs/usb-serial-protocol.js.map +0 -1
  341. package/build/cjs/usb.d.ts +0 -66
  342. package/build/cjs/usb.js.map +0 -1
  343. package/build/cjs/usb.test.js.map +0 -1
  344. package/build/esm/accelerometer-service.js.map +0 -1
  345. package/build/esm/accelerometer.d.ts +0 -9
  346. package/build/esm/accelerometer.js +0 -12
  347. package/build/esm/accelerometer.js.map +0 -1
  348. package/build/esm/bluetooth-device-wrapper.js.map +0 -1
  349. package/build/esm/bluetooth-profile.js.map +0 -1
  350. package/build/esm/bluetooth.js.map +0 -1
  351. package/build/esm/bluetooth.test.js.map +0 -1
  352. package/build/esm/board-serial-info.js.map +0 -1
  353. package/build/esm/board-serial-info.test.js.map +0 -1
  354. package/build/esm/button-service.js.map +0 -1
  355. package/build/esm/buttons.d.ts +0 -10
  356. package/build/esm/buttons.js +0 -18
  357. package/build/esm/buttons.js.map +0 -1
  358. package/build/esm/constants.d.ts +0 -48
  359. package/build/esm/constants.js +0 -70
  360. package/build/esm/constants.js.map +0 -1
  361. package/build/esm/device-bond-state.js.map +0 -1
  362. package/build/esm/device-information-service.js.map +0 -1
  363. package/build/esm/dfu-service.js.map +0 -1
  364. package/build/esm/flashing/flashing-full.js.map +0 -1
  365. package/build/esm/flashing/flashing-makecode.js.map +0 -1
  366. package/build/esm/flashing/flashing-makecode.test.js.map +0 -1
  367. package/build/esm/flashing/flashing-partial.js.map +0 -1
  368. package/build/esm/flashing/flashing-v1.js.map +0 -1
  369. package/build/esm/flashing/nordic-dfu.js.map +0 -1
  370. package/build/esm/flashing/zip.js.map +0 -1
  371. package/build/esm/flashing/zip.test.js.map +0 -1
  372. package/build/esm/hex-flash-data-source.js.map +0 -1
  373. package/build/esm/led-service.js.map +0 -1
  374. package/build/esm/led.d.ts +0 -6
  375. package/build/esm/led.js +0 -2
  376. package/build/esm/led.js.map +0 -1
  377. package/build/esm/magnetometer-service.js.map +0 -1
  378. package/build/esm/magnetometer.d.ts +0 -9
  379. package/build/esm/magnetometer.js +0 -12
  380. package/build/esm/magnetometer.js.map +0 -1
  381. package/build/esm/partial-flashing-service.js.map +0 -1
  382. package/build/esm/promise-queue.js.map +0 -1
  383. package/build/esm/promise-queue.test.js.map +0 -1
  384. package/build/esm/serial-events.d.ts +0 -20
  385. package/build/esm/serial-events.js +0 -61
  386. package/build/esm/serial-events.js.map +0 -1
  387. package/build/esm/uart-service.js.map +0 -1
  388. package/build/esm/uart.d.ts +0 -4
  389. package/build/esm/uart.js +0 -12
  390. package/build/esm/uart.js.map +0 -1
  391. package/build/esm/usb-device-wrapper.d.ts +0 -47
  392. package/build/esm/usb-device-wrapper.js +0 -410
  393. package/build/esm/usb-device-wrapper.js.map +0 -1
  394. package/build/esm/usb-partial-flashing-utils.js.map +0 -1
  395. package/build/esm/usb-partial-flashing.js.map +0 -1
  396. package/build/esm/usb-radio-bridge.d.ts +0 -24
  397. package/build/esm/usb-radio-bridge.js.map +0 -1
  398. package/build/esm/usb-serial-protocol.js.map +0 -1
  399. package/build/esm/usb.d.ts +0 -66
  400. package/build/esm/usb.js.map +0 -1
  401. package/build/esm/usb.test.js.map +0 -1
  402. /package/build/cjs/{bluetooth.test.d.ts → bluetooth/connection.test.d.ts} +0 -0
  403. /package/build/cjs/{device-bond-state.d.ts → bluetooth/device-bond-state.d.ts} +0 -0
  404. /package/build/cjs/{device-bond-state.js → bluetooth/device-bond-state.js} +0 -0
  405. /package/build/cjs/{flashing → bluetooth/flashing}/flashing-makecode.js +0 -0
  406. /package/build/cjs/{flashing → bluetooth/flashing}/flashing-makecode.test.d.ts +0 -0
  407. /package/build/cjs/{flashing → bluetooth/flashing}/flashing-v1.d.ts +0 -0
  408. /package/build/cjs/{flashing → bluetooth/flashing}/flashing-v1.js +0 -0
  409. /package/build/cjs/{flashing → bluetooth/flashing}/zip.d.ts +0 -0
  410. /package/build/cjs/{flashing → bluetooth/flashing}/zip.js +0 -0
  411. /package/build/cjs/{flashing → bluetooth/flashing}/zip.test.d.ts +0 -0
  412. /package/build/cjs/{flashing → bluetooth/flashing}/zip.test.js +0 -0
  413. /package/build/cjs/{bluetooth-profile.d.ts → bluetooth/profile.d.ts} +0 -0
  414. /package/build/cjs/{dfu-service.d.ts → bluetooth/services/dfu-service.d.ts} +0 -0
  415. /package/build/cjs/{usb-serial-protocol.d.ts → radio-bridge/serial-protocol.d.ts} +0 -0
  416. /package/build/cjs/{board-serial-info.test.d.ts → usb/arm-debug.test.d.ts} +0 -0
  417. /package/build/{esm → cjs/usb}/board-serial-info.test.d.ts +0 -0
  418. /package/build/cjs/{promise-queue.test.d.ts → usb/cmsis-dap.test.d.ts} +0 -0
  419. /package/build/cjs/{usb.test.d.ts → usb/connection.test.d.ts} +0 -0
  420. /package/build/{esm/bluetooth.test.d.ts → cjs/usb/cortex-m.test.d.ts} +0 -0
  421. /package/build/{esm/flashing/flashing-makecode.test.d.ts → cjs/usb/daplink.test.d.ts} +0 -0
  422. /package/build/cjs/{promise-queue.d.ts → usb/promise-queue.d.ts} +0 -0
  423. /package/build/cjs/{promise-queue.js → usb/promise-queue.js} +0 -0
  424. /package/build/{esm → cjs/usb}/promise-queue.test.d.ts +0 -0
  425. /package/build/cjs/{promise-queue.test.js → usb/promise-queue.test.js} +0 -0
  426. /package/build/esm/{flashing/zip.test.d.ts → bluetooth/connection.test.d.ts} +0 -0
  427. /package/build/esm/{device-bond-state.d.ts → bluetooth/device-bond-state.d.ts} +0 -0
  428. /package/build/esm/{device-bond-state.js → bluetooth/device-bond-state.js} +0 -0
  429. /package/build/esm/{flashing → bluetooth/flashing}/flashing-makecode.js +0 -0
  430. /package/build/esm/{usb.test.d.ts → bluetooth/flashing/flashing-makecode.test.d.ts} +0 -0
  431. /package/build/esm/{flashing → bluetooth/flashing}/flashing-v1.d.ts +0 -0
  432. /package/build/esm/{flashing → bluetooth/flashing}/flashing-v1.js +0 -0
  433. /package/build/esm/{flashing → bluetooth/flashing}/zip.d.ts +0 -0
  434. /package/build/esm/{flashing → bluetooth/flashing}/zip.js +0 -0
  435. /package/build/esm/{flashing → bluetooth/flashing}/zip.test.js +0 -0
  436. /package/build/esm/{bluetooth-profile.d.ts → bluetooth/profile.d.ts} +0 -0
  437. /package/build/esm/{dfu-service.d.ts → bluetooth/services/dfu-service.d.ts} +0 -0
  438. /package/build/esm/{usb-serial-protocol.d.ts → radio-bridge/serial-protocol.d.ts} +0 -0
  439. /package/build/esm/{promise-queue.d.ts → usb/promise-queue.d.ts} +0 -0
  440. /package/build/esm/{promise-queue.js → usb/promise-queue.js} +0 -0
  441. /package/build/esm/{promise-queue.test.js → usb/promise-queue.test.js} +0 -0
@@ -1,15 +1,12 @@
1
- import { AccelerometerData } from "./accelerometer.js";
2
- import { DeviceConnection, FlashDataSource, FlashOptions } from "./device.js";
3
- import { LedMatrix } from "./led.js";
4
- import { Logging } from "./logging.js";
5
- import { MagnetometerData } from "./magnetometer.js";
6
- import { ServiceConnectionEventMap } from "./service-events.js";
1
+ import { DeviceConnection, FlashDataSource, FlashOptions } from "../device.js";
2
+ import { Logging } from "../logging.js";
3
+ import { AccelerometerData, LedMatrix, MagnetometerData, ServiceConnectionEventMap } from "../service-events.js";
7
4
  import { DeviceBondState } from "./device-bond-state.js";
8
- export interface MicrobitWebBluetoothConnectionOptions {
5
+ export interface MicrobitBluetoothConnectionOptions {
9
6
  logging?: Logging;
10
7
  deviceBondState?: DeviceBondState;
11
8
  }
12
- export interface MicrobitWebBluetoothConnection extends DeviceConnection<ServiceConnectionEventMap> {
9
+ export interface MicrobitBluetoothConnection extends DeviceConnection<ServiceConnectionEventMap> {
13
10
  /**
14
11
  * Sets micro:bit name filter for device requesting.
15
12
  *
@@ -19,96 +16,103 @@ export interface MicrobitWebBluetoothConnection extends DeviceConnection<Service
19
16
  /**
20
17
  * Gets micro:bit accelerometer data.
21
18
  *
22
- * @returns accelerometer data or undefined if there is no connection.
19
+ * @returns accelerometer data.
20
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
23
21
  */
24
- getAccelerometerData(): Promise<AccelerometerData | undefined>;
22
+ getAccelerometerData(): Promise<AccelerometerData>;
25
23
  /**
26
24
  * Gets micro:bit accelerometer period.
27
25
  *
28
- * @returns accelerometer period or undefined if there is no connection.
26
+ * @returns accelerometer period.
27
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
29
28
  */
30
- getAccelerometerPeriod(): Promise<number | undefined>;
29
+ getAccelerometerPeriod(): Promise<number>;
31
30
  /**
32
31
  * Sets micro:bit accelerometer period.
33
32
  *
34
33
  * @param value The accelerometer period.
34
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
35
35
  */
36
36
  setAccelerometerPeriod(value: number): Promise<void>;
37
37
  /**
38
38
  * Sets micro:bit LED text.
39
39
  *
40
40
  * @param text The text displayed on micro:bit LED.
41
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
41
42
  */
42
43
  setLedText(text: string): Promise<void>;
43
44
  /**
44
45
  * Gets micro:bit LED scrolling delay.
45
46
  *
46
47
  * @returns LED scrolling delay in milliseconds.
48
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
47
49
  */
48
- getLedScrollingDelay(): Promise<number | undefined>;
50
+ getLedScrollingDelay(): Promise<number>;
49
51
  /**
50
52
  * Sets micro:bit LED scrolling delay.
51
53
  *
52
54
  * @param delayInMillis LED scrolling delay in milliseconds.
55
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
53
56
  */
54
57
  setLedScrollingDelay(delayInMillis: number): Promise<void>;
55
58
  /**
56
59
  * Gets micro:bit LED matrix.
57
60
  *
58
61
  * @returns a boolean matrix representing the micro:bit LED display.
62
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
59
63
  */
60
- getLedMatrix(): Promise<LedMatrix | undefined>;
64
+ getLedMatrix(): Promise<LedMatrix>;
61
65
  /**
62
66
  * Sets micro:bit LED matrix.
63
67
  *
64
68
  * @param matrix an boolean matrix representing the micro:bit LED display.
69
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
65
70
  */
66
71
  setLedMatrix(matrix: LedMatrix): Promise<void>;
67
72
  /**
68
73
  * Gets micro:bit magnetometer data.
69
74
  *
70
75
  * @returns magnetometer data.
76
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
71
77
  */
72
- getMagnetometerData(): Promise<MagnetometerData | undefined>;
78
+ getMagnetometerData(): Promise<MagnetometerData>;
73
79
  /**
74
80
  * Gets micro:bit magnetometer bearing.
75
81
  *
76
82
  * @returns magnetometer bearing.
83
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
77
84
  */
78
- getMagnetometerBearing(): Promise<number | undefined>;
85
+ getMagnetometerBearing(): Promise<number>;
79
86
  /**
80
87
  * Gets micro:bit magnetometer period.
81
88
  *
82
89
  * @returns magnetometer period.
90
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
83
91
  */
84
- getMagnetometerPeriod(): Promise<number | undefined>;
92
+ getMagnetometerPeriod(): Promise<number>;
85
93
  /**
86
94
  * Sets micro:bit magnetometer period.
87
95
  *
88
96
  * @param value magnetometer period.
97
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
89
98
  */
90
99
  setMagnetometerPeriod(value: number): Promise<void>;
91
100
  /**
92
101
  * Triggers micro:bit magnetometer calibration.
102
+ *
103
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
93
104
  */
94
105
  triggerMagnetometerCalibration(): Promise<void>;
95
106
  /**
96
107
  * Write UART messages.
97
108
  *
98
109
  * @param data UART message.
110
+ * @throws {DeviceError} with code `not-connected` if there is no connection.
99
111
  */
100
112
  uartWrite(data: Uint8Array): Promise<void>;
101
- /**
102
- * Flash the micro:bit.
103
- *
104
- * @param dataSource The data to use.
105
- * @param options Flash options and progress callback.
106
- * @throws {DeviceError} On flash failure. The error.code property indicates the failure type.
107
- * @throws {FlashDataError} If data preparation fails.
108
- */
109
113
  flash(dataSource: FlashDataSource, options: FlashOptions): Promise<void>;
110
114
  }
111
115
  /**
112
116
  * A Bluetooth connection factory.
113
117
  */
114
- export declare const createWebBluetoothConnection: (options?: MicrobitWebBluetoothConnectionOptions) => MicrobitWebBluetoothConnection;
118
+ export declare const createBluetoothConnection: (options?: MicrobitBluetoothConnectionOptions) => MicrobitBluetoothConnection;
@@ -6,39 +6,39 @@
6
6
  import { BleClient } from "@capacitor-community/bluetooth-le";
7
7
  import { Capacitor } from "@capacitor/core";
8
8
  import MemoryMap from "nrf-intel-hex";
9
- import { BluetoothDeviceWrapper, isAndroid, scanningTimeoutInMs, } from "./bluetooth-device-wrapper.js";
10
- import { profile } from "./bluetooth-profile.js";
11
- import { AfterRequestDevice, BeforeRequestDevice, ConnectionStatus, ConnectionStatusEvent, DeviceError, FlashDataError, ProgressStage, } from "./device.js";
12
- import { TypedEventTarget } from "./events.js";
13
- import { ConsoleLogging } from "./logging.js";
9
+ import { BluetoothDeviceWrapper, isAndroid, scanningTimeoutInMs, } from "./device-wrapper.js";
10
+ import { profile } from "./profile.js";
11
+ import { ConnectionStatus, DeviceError, FlashDataError, assertConnected, ProgressStage, } from "../device.js";
12
+ import { TypedEventTarget } from "../events.js";
13
+ import { ConsoleLogging } from "../logging.js";
14
14
  import { fullFlash } from "./flashing/flashing-full.js";
15
15
  import partialFlash, { PartialFlashResult, } from "./flashing/flashing-partial.js";
16
- import { throwIfUnavailable } from "./availability.js";
17
- import { truncateHexAfterEof } from "./hex-flash-data-source.js";
16
+ import { throwIfUnavailable } from "../availability.js";
17
+ import { truncateHexAfterEof } from "../hex-util.js";
18
18
  import { DefaultDeviceBondState, } from "./device-bond-state.js";
19
- import { TimeoutError } from "./async-util.js";
19
+ import { TimeoutError } from "../async-util.js";
20
20
  let bleClientInitialized = false;
21
21
  /**
22
22
  * A Bluetooth connection factory.
23
23
  */
24
- export const createWebBluetoothConnection = (options) => new MicrobitWebBluetoothConnectionImpl(options);
24
+ export const createBluetoothConnection = (options) => new MicrobitBluetoothConnectionImpl(options);
25
25
  /**
26
26
  * A Bluetooth connection to a micro:bit device.
27
27
  */
28
- class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
28
+ class MicrobitBluetoothConnectionImpl extends TypedEventTarget {
29
29
  constructor(options = {}) {
30
30
  super();
31
31
  Object.defineProperty(this, "status", {
32
32
  enumerable: true,
33
33
  configurable: true,
34
34
  writable: true,
35
- value: ConnectionStatus.NO_AUTHORIZED_DEVICE
35
+ value: ConnectionStatus.NoAuthorizedDevice
36
36
  });
37
37
  /**
38
- * The USB device we last connected to.
38
+ * The BLE device we last connected to.
39
39
  * Cleared if it is disconnected.
40
40
  */
41
- Object.defineProperty(this, "device", {
41
+ Object.defineProperty(this, "bleDevice", {
42
42
  enumerable: true,
43
43
  configurable: true,
44
44
  writable: true,
@@ -56,7 +56,19 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
56
56
  writable: true,
57
57
  value: void 0
58
58
  });
59
- Object.defineProperty(this, "connection", {
59
+ /**
60
+ * Device-specific state. Created on connect, cleared on disconnect.
61
+ */
62
+ Object.defineProperty(this, "device", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true,
66
+ value: void 0
67
+ });
68
+ /**
69
+ * Cached device property that persists across reconnections until clearDevice.
70
+ */
71
+ Object.defineProperty(this, "cachedBoardVersion", {
60
72
  enumerable: true,
61
73
  configurable: true,
62
74
  writable: true,
@@ -85,10 +97,10 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
85
97
  options.deviceBondState || new DefaultDeviceBondState();
86
98
  }
87
99
  eventActivated(type) {
88
- this.connection?.startNotifications(type);
100
+ this.device?.startNotifications(type);
89
101
  }
90
102
  eventDeactivated(type) {
91
- this.connection?.stopNotifications(type);
103
+ this.device?.stopNotifications(type);
92
104
  }
93
105
  log(v) {
94
106
  this.logging.log(v);
@@ -156,7 +168,8 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
156
168
  }
157
169
  }
158
170
  getBoardVersion() {
159
- return this.connection?.boardVersion;
171
+ assertConnected(this.cachedBoardVersion);
172
+ return this.cachedBoardVersion;
160
173
  }
161
174
  async connect(options) {
162
175
  const progress = options?.progress ?? (() => { });
@@ -168,21 +181,22 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
168
181
  // disconnect before attempting to connect.
169
182
  this.waitForPostFlashDisconnectPromise &&
170
183
  (await this.waitForPostFlashDisconnectPromise);
171
- if (!this.device || !this.connection) {
184
+ if (!this.bleDevice || !this.device) {
172
185
  progress(ProgressStage.FindingDevice);
173
186
  const device = await this.requestDevice(options?.signal);
174
- this.connection = new BluetoothDeviceWrapper(device, this.logging, this.deviceBondState, this.dispatchTypedEvent.bind(this), () => this.getActiveEvents(), {
175
- onConnecting: () => this.setStatus(ConnectionStatus.CONNECTING),
176
- onSuccess: () => this.setStatus(ConnectionStatus.CONNECTED),
177
- onDisconnect: () => this.setStatus(ConnectionStatus.DISCONNECTED),
187
+ this.device = new BluetoothDeviceWrapper(device, this.logging, this.deviceBondState, this.dispatchEvent.bind(this), () => this.getActiveEvents(), {
188
+ onConnecting: () => this.setStatus(ConnectionStatus.Connecting),
189
+ onSuccess: () => this.setStatus(ConnectionStatus.Connected),
190
+ onDisconnect: () => this.setStatus(ConnectionStatus.Disconnected),
178
191
  });
179
192
  }
180
- await this.connection.connect(options);
193
+ await this.device.connect(options);
194
+ this.cachedBoardVersion = this.device.boardVersion;
181
195
  }
182
196
  async disconnect() {
183
197
  try {
184
- if (this.connection) {
185
- await this.connection.disconnect();
198
+ if (this.device) {
199
+ await this.device.disconnect();
186
200
  }
187
201
  }
188
202
  catch (e) {
@@ -192,7 +206,7 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
192
206
  });
193
207
  }
194
208
  finally {
195
- this.setStatus(ConnectionStatus.DISCONNECTED);
209
+ this.setStatus(ConnectionStatus.Disconnected);
196
210
  this.logging.event({
197
211
  type: "Bluetooth-info",
198
212
  message: "disconnected",
@@ -204,105 +218,118 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
204
218
  this.status = newStatus;
205
219
  this.log("Bluetooth connection status " + newStatus);
206
220
  if (this.deferredUpdatesPreviousStatus === undefined) {
207
- this.dispatchTypedEvent("status", new ConnectionStatusEvent(newStatus, previousStatus));
208
- }
209
- }
210
- serialWrite(data) {
211
- if (this.connection) {
212
- // TODO
221
+ this.dispatchEvent("status", {
222
+ status: newStatus,
223
+ previousStatus,
224
+ });
213
225
  }
214
- return Promise.resolve();
215
226
  }
216
227
  async clearDevice() {
217
228
  await this.disconnect();
218
- this.device = undefined;
219
- this.setStatus(ConnectionStatus.NO_AUTHORIZED_DEVICE);
229
+ this.bleDevice = undefined;
230
+ this.cachedBoardVersion = undefined;
231
+ this.setStatus(ConnectionStatus.NoAuthorizedDevice);
220
232
  }
221
233
  setNameFilter(name) {
222
234
  this.nameFilter = name;
223
235
  }
224
236
  async requestDevice(signal) {
225
- // TODO: is this possible to reinstate?
237
+ // Support both the default "BBC micro:bit" name and the shorter "uBit"
238
+ // name used by some MakeCode extensions (e.g. bsiever/microbit-pxt-blehid).
226
239
  // See https://github.com/bsiever/microbit-pxt-blehid/issues/31
227
- // namePrefix: this.nameFilter
228
- // ? `uBit [${this.nameFilter}]`
229
- // : "uBit",
230
- const namePrefix = this.nameFilter
231
- ? `BBC micro:bit [${this.nameFilter}]`
232
- : "BBC micro:bit";
240
+ const namePrefixes = this.nameFilter
241
+ ? [`BBC micro:bit [${this.nameFilter}]`, `uBit [${this.nameFilter}]`]
242
+ : ["BBC micro:bit", "uBit"];
233
243
  // If we have a cached device, check if it still matches the current filter.
234
244
  // If not, clear it so we find a new device.
235
- if (this.device) {
236
- if (this.device.name?.startsWith(namePrefix)) {
237
- return this.device;
245
+ if (this.bleDevice) {
246
+ if (namePrefixes.some((p) => this.bleDevice.name?.startsWith(p))) {
247
+ return this.bleDevice;
238
248
  }
239
- this.log(`Cached device "${this.device.name}" doesn't match filter "${namePrefix}", clearing`);
249
+ this.log(`Cached device "${this.bleDevice.name}" doesn't match filters "${namePrefixes.join(", ")}", clearing`);
240
250
  await this.clearDevice();
241
251
  }
242
- this.dispatchTypedEvent("beforerequestdevice", new BeforeRequestDevice());
252
+ this.dispatchEvent("beforerequestdevice");
243
253
  try {
244
- this.device = Capacitor.isNativePlatform()
245
- ? await this.requestDeviceNative(namePrefix, signal)
246
- : await this.requestDeviceWeb(namePrefix);
247
- if (!this.device) {
248
- this.setStatus(ConnectionStatus.NO_AUTHORIZED_DEVICE);
254
+ this.bleDevice = Capacitor.isNativePlatform()
255
+ ? await this.requestDeviceNative(namePrefixes, signal)
256
+ : await this.requestDeviceWeb(namePrefixes);
257
+ if (!this.bleDevice) {
258
+ this.setStatus(ConnectionStatus.NoAuthorizedDevice);
249
259
  throw new DeviceError({
250
260
  code: "no-device-selected",
251
261
  message: "No device selected",
252
262
  });
253
263
  }
254
- return this.device;
264
+ return this.bleDevice;
255
265
  }
256
266
  finally {
257
- this.dispatchTypedEvent("afterrequestdevice", new AfterRequestDevice());
267
+ this.dispatchEvent("afterrequestdevice");
258
268
  }
259
269
  }
260
270
  async getAccelerometerData() {
261
- return this.connection?.accelerometer.getData();
271
+ assertConnected(this.device);
272
+ return this.device.accelerometer.getData();
262
273
  }
263
274
  async getAccelerometerPeriod() {
264
- return this.connection?.accelerometer.getPeriod();
275
+ assertConnected(this.device);
276
+ return this.device.accelerometer.getPeriod();
265
277
  }
266
278
  async setAccelerometerPeriod(value) {
267
- return this.connection?.accelerometer.setPeriod(value);
279
+ assertConnected(this.device);
280
+ return this.device.accelerometer.setPeriod(value);
268
281
  }
269
282
  async setLedText(text) {
270
- return this.connection?.led.setText(text);
283
+ assertConnected(this.device);
284
+ return this.device.led.setText(text);
271
285
  }
272
286
  async getLedScrollingDelay() {
273
- return this.connection?.led.getScrollingDelay();
287
+ assertConnected(this.device);
288
+ return this.device.led.getScrollingDelay();
274
289
  }
275
290
  async setLedScrollingDelay(delayInMillis) {
276
- await this.connection?.led.setScrollingDelay(delayInMillis);
291
+ assertConnected(this.device);
292
+ await this.device.led.setScrollingDelay(delayInMillis);
277
293
  }
278
294
  async getLedMatrix() {
279
- return await this.connection?.led.getLedMatrix();
295
+ assertConnected(this.device);
296
+ return await this.device.led.getLedMatrix();
280
297
  }
281
298
  async setLedMatrix(matrix) {
282
- await this.connection?.led.setLedMatrix(matrix);
299
+ assertConnected(this.device);
300
+ await this.device.led.setLedMatrix(matrix);
283
301
  }
284
302
  async getMagnetometerData() {
285
- return this.connection?.magnetometer.getData();
303
+ assertConnected(this.device);
304
+ return this.device.magnetometer.getData();
286
305
  }
287
306
  async getMagnetometerPeriod() {
288
- return this.connection?.magnetometer.getPeriod();
307
+ assertConnected(this.device);
308
+ return this.device.magnetometer.getPeriod();
289
309
  }
290
310
  async setMagnetometerPeriod(value) {
291
- return this.connection?.magnetometer.setPeriod(value);
311
+ assertConnected(this.device);
312
+ return this.device.magnetometer.setPeriod(value);
292
313
  }
293
314
  async getMagnetometerBearing() {
294
- return this.connection?.magnetometer.getBearing();
315
+ assertConnected(this.device);
316
+ return this.device.magnetometer.getBearing();
295
317
  }
296
318
  async triggerMagnetometerCalibration() {
297
- await this.connection?.magnetometer.triggerCalibration();
319
+ assertConnected(this.device);
320
+ await this.device.magnetometer.triggerCalibration();
298
321
  }
299
322
  async uartWrite(data) {
300
- await this.connection?.uart.writeData(data);
323
+ assertConnected(this.device);
324
+ await this.device.uart.writeData(data);
301
325
  }
302
326
  /**
303
327
  * Flash the micro:bit.
304
328
  *
305
- * Note that this will always leave the connection disconnected.
329
+ * Always leaves the connection in {@link ConnectionStatus.Disconnected} state.
330
+ * Bluetooth connects directly to the application processor, which reboots
331
+ * after flashing, so the connection is necessarily lost. Call {@link connect}
332
+ * again after flashing to reconnect.
306
333
  *
307
334
  * @param dataSource The data to use.
308
335
  * @param options Flash options and progress callback.
@@ -312,10 +339,10 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
312
339
  try {
313
340
  // We'll disconnect/reconnect multiple times due to device resets, but reporting this is unhelpful.
314
341
  this.deferredUpdatesPreviousStatus = this.status;
315
- if (this.status !== ConnectionStatus.CONNECTED) {
342
+ if (this.status !== ConnectionStatus.Connected) {
316
343
  await this.connect({ progress, signal: options.signal });
317
344
  }
318
- const connection = this.connection;
345
+ const connection = this.device;
319
346
  try {
320
347
  const boardVersion = connection.boardVersion;
321
348
  if (!boardVersion) {
@@ -328,7 +355,7 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
328
355
  if (!memoryMap) {
329
356
  throw new FlashDataError("Could not convert hex to memory map");
330
357
  }
331
- if (!this.device) {
358
+ if (!this.bleDevice) {
332
359
  throw new DeviceError({
333
360
  code: "device-disconnected",
334
361
  message: "No device",
@@ -339,7 +366,8 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
339
366
  if (partialFlashResult === PartialFlashResult.AttemptFullFlash) {
340
367
  await fullFlash(connection, boardVersion, memoryMap, progress);
341
368
  }
342
- else if (partialFlashResult === PartialFlashResult.AlreadyUpToDate ||
369
+ this.dispatchEvent("flash");
370
+ if (partialFlashResult === PartialFlashResult.AlreadyUpToDate ||
343
371
  partialFlashResult === PartialFlashResult.Success) {
344
372
  this.waitForPostFlashDisconnectPromise = (async () => {
345
373
  try {
@@ -363,7 +391,7 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
363
391
  }
364
392
  }
365
393
  })();
366
- this.setStatus(ConnectionStatus.DISCONNECTED);
394
+ this.setStatus(ConnectionStatus.Disconnected);
367
395
  }
368
396
  }
369
397
  catch (e) {
@@ -379,7 +407,10 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
379
407
  finally {
380
408
  const previousStatus = this.deferredUpdatesPreviousStatus;
381
409
  this.deferredUpdatesPreviousStatus = undefined;
382
- this.dispatchTypedEvent("status", new ConnectionStatusEvent(this.status, previousStatus));
410
+ this.dispatchEvent("status", {
411
+ status: this.status,
412
+ previousStatus,
413
+ });
383
414
  }
384
415
  }
385
416
  /**
@@ -387,22 +418,33 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
387
418
  *
388
419
  * @returns device or undefined if user cancels.
389
420
  */
390
- async requestDeviceWeb(namePrefix) {
421
+ async requestDeviceWeb(namePrefixes) {
422
+ const optionalServices = [
423
+ profile.accelerometer.id,
424
+ profile.button.id,
425
+ profile.deviceInformation.id,
426
+ profile.dfuControl.id,
427
+ profile.event.id,
428
+ profile.ioPin.id,
429
+ profile.led.id,
430
+ profile.magnetometer.id,
431
+ profile.temperature.id,
432
+ profile.uart.id,
433
+ ];
434
+ // Temporarily patch navigator.bluetooth.requestDevice to support multiple
435
+ // name prefix filters. The capacitor-ble plugin only supports a single
436
+ // namePrefix, but the Web Bluetooth API supports a filters array.
437
+ // By patching at this level the plugin's internal deviceMap is populated
438
+ // naturally when its own requestDevice completes.
439
+ const orig = navigator.bluetooth.requestDevice.bind(navigator.bluetooth);
391
440
  try {
441
+ navigator.bluetooth.requestDevice = (options) => orig({
442
+ ...options,
443
+ filters: namePrefixes.map((namePrefix) => ({ namePrefix })),
444
+ });
392
445
  return await BleClient.requestDevice({
393
- namePrefix,
394
- optionalServices: [
395
- profile.accelerometer.id,
396
- profile.button.id,
397
- profile.deviceInformation.id,
398
- profile.dfuControl.id,
399
- profile.event.id,
400
- profile.ioPin.id,
401
- profile.led.id,
402
- profile.magnetometer.id,
403
- profile.temperature.id,
404
- profile.uart.id,
405
- ],
446
+ namePrefix: namePrefixes[0],
447
+ optionalServices,
406
448
  });
407
449
  }
408
450
  catch (e) {
@@ -411,6 +453,9 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
411
453
  }
412
454
  throw e;
413
455
  }
456
+ finally {
457
+ navigator.bluetooth.requestDevice = orig;
458
+ }
414
459
  }
415
460
  /**
416
461
  * Finds device with specified name prefix.
@@ -418,19 +463,17 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
418
463
  * @returns device or undefined if none can be found.
419
464
  * @throws DeviceError with code "aborted" if signal is aborted.
420
465
  */
421
- async requestDeviceNative(namePrefix, signal) {
466
+ async requestDeviceNative(namePrefixes, signal) {
422
467
  if (signal?.aborted) {
423
468
  throw new DeviceError({ code: "aborted", message: "Connection aborted" });
424
469
  }
470
+ const matchesAnyPrefix = (name) => !!name && namePrefixes.some((p) => name.startsWith(p));
425
471
  // Check for existing bonded devices.
426
- const bonded = await this.checkBondedDevices((device) => {
427
- const name = device.name;
428
- return !!name && name.startsWith(namePrefix);
429
- });
472
+ const bonded = await this.checkBondedDevices((device) => matchesAnyPrefix(device.name));
430
473
  if (bonded) {
431
474
  return bonded;
432
475
  }
433
- this.log(`Scanning for device - ${namePrefix}`);
476
+ this.log(`Scanning for device - ${namePrefixes.join(", ")}`);
434
477
  let found = false;
435
478
  let aborted = false;
436
479
  const scanPromise = new Promise((resolve) =>
@@ -440,8 +483,8 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
440
483
  // isn't matched by the name filter but the advertising name is in the
441
484
  // localName on the device. So we filter here instead. This happens on
442
485
  // iOS if DFU fails / is interrupted.
443
- if (result.device.name?.startsWith(namePrefix) ||
444
- result.localName?.startsWith(namePrefix)) {
486
+ if (matchesAnyPrefix(result.device.name) ||
487
+ matchesAnyPrefix(result.localName)) {
445
488
  found = true;
446
489
  await BleClient.stopLEScan();
447
490
  resolve(result.device);
@@ -486,4 +529,4 @@ const convertDataToMemoryMap = (data) => {
486
529
  }
487
530
  return MemoryMap.fromHex(truncateHexAfterEof(data));
488
531
  };
489
- //# sourceMappingURL=bluetooth.js.map
532
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/bluetooth/connection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAa,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAIL,gBAAgB,EAGhB,WAAW,EACX,cAAc,EACd,eAAe,EAIf,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAW,cAAc,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,YAAY,EAAE,EACnB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AASxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oB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