@microbit/microbit-connection 0.9.0-apps.alpha.15 → 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.
- package/build/cjs/async-util.js.map +1 -1
- package/build/cjs/async-util.test.d.ts +1 -0
- package/build/cjs/async-util.test.js +20 -0
- package/build/cjs/async-util.test.js.map +1 -0
- package/build/cjs/availability.js.map +1 -1
- package/build/{esm/bluetooth.d.ts → cjs/bluetooth/connection.d.ts} +30 -26
- package/build/cjs/{bluetooth.js → bluetooth/connection.js} +183 -106
- package/build/cjs/bluetooth/connection.js.map +1 -0
- package/build/cjs/bluetooth/connection.test.d.ts +1 -0
- package/build/cjs/bluetooth/connection.test.js +88 -0
- package/build/cjs/bluetooth/connection.test.js.map +1 -0
- package/build/cjs/bluetooth/device-bond-state.js.map +1 -0
- package/build/cjs/{bluetooth-device-wrapper.d.ts → bluetooth/device-wrapper.d.ts} +22 -11
- package/build/cjs/{bluetooth-device-wrapper.js → bluetooth/device-wrapper.js} +99 -42
- package/build/cjs/bluetooth/device-wrapper.js.map +1 -0
- package/build/cjs/{flashing → bluetooth/flashing}/flashing-full.d.ts +2 -2
- package/build/cjs/{flashing → bluetooth/flashing}/flashing-full.js +4 -4
- package/build/cjs/bluetooth/flashing/flashing-full.js.map +1 -0
- package/build/cjs/bluetooth/flashing/flashing-makecode.d.ts +10 -0
- package/build/cjs/{flashing → bluetooth/flashing}/flashing-makecode.js +5 -2
- package/build/cjs/bluetooth/flashing/flashing-makecode.js.map +1 -0
- package/build/cjs/bluetooth/flashing/flashing-makecode.test.d.ts +1 -0
- package/build/cjs/bluetooth/flashing/flashing-makecode.test.js +253 -0
- package/build/cjs/bluetooth/flashing/flashing-makecode.test.js.map +1 -0
- package/build/cjs/{flashing → bluetooth/flashing}/flashing-partial.d.ts +3 -2
- package/build/cjs/{flashing → bluetooth/flashing}/flashing-partial.js +17 -3
- package/build/cjs/bluetooth/flashing/flashing-partial.js.map +1 -0
- package/build/cjs/bluetooth/flashing/flashing-v1.js.map +1 -0
- package/build/cjs/{flashing → bluetooth/flashing}/nordic-dfu.d.ts +2 -2
- package/build/cjs/{flashing → bluetooth/flashing}/nordic-dfu.js +25 -11
- package/build/cjs/bluetooth/flashing/nordic-dfu.js.map +1 -0
- package/build/cjs/bluetooth/flashing/zip.js.map +1 -0
- package/build/cjs/bluetooth/flashing/zip.test.d.ts +1 -0
- package/build/cjs/bluetooth/flashing/zip.test.js +96 -0
- package/build/cjs/bluetooth/flashing/zip.test.js.map +1 -0
- package/build/cjs/bluetooth/index.d.ts +5 -0
- package/build/cjs/bluetooth/index.js +9 -0
- package/build/cjs/bluetooth/index.js.map +1 -0
- package/build/cjs/{bluetooth-profile.d.ts → bluetooth/profile.d.ts} +8 -0
- package/build/cjs/{bluetooth-profile.js → bluetooth/profile.js} +7 -1
- package/build/cjs/bluetooth/profile.js.map +1 -0
- package/build/{esm → cjs/bluetooth/services}/accelerometer-service.d.ts +2 -3
- package/build/cjs/{accelerometer-service.js → bluetooth/services/accelerometer-service.js} +16 -12
- package/build/cjs/bluetooth/services/accelerometer-service.js.map +1 -0
- package/build/{esm → cjs/bluetooth/services}/button-service.d.ts +2 -3
- package/build/cjs/{button-service.js → bluetooth/services/button-service.js} +15 -14
- package/build/cjs/bluetooth/services/button-service.js.map +1 -0
- package/build/{esm → cjs/bluetooth/services}/device-information-service.d.ts +1 -1
- package/build/cjs/{device-information-service.js → bluetooth/services/device-information-service.js} +2 -2
- package/build/cjs/bluetooth/services/device-information-service.js.map +1 -0
- package/build/cjs/{dfu-service.js → bluetooth/services/dfu-service.js} +2 -2
- package/build/cjs/bluetooth/services/dfu-service.js.map +1 -0
- package/build/cjs/{led-service.d.ts → bluetooth/services/led-service.d.ts} +2 -3
- package/build/cjs/{led-service.js → bluetooth/services/led-service.js} +7 -7
- package/build/cjs/bluetooth/services/led-service.js.map +1 -0
- package/build/cjs/{magnetometer-service.d.ts → bluetooth/services/magnetometer-service.d.ts} +2 -3
- package/build/cjs/{magnetometer-service.js → bluetooth/services/magnetometer-service.js} +18 -14
- package/build/cjs/bluetooth/services/magnetometer-service.js.map +1 -0
- package/build/{esm → cjs/bluetooth/services}/partial-flashing-service.d.ts +1 -1
- package/build/cjs/{partial-flashing-service.js → bluetooth/services/partial-flashing-service.js} +8 -8
- package/build/cjs/bluetooth/services/partial-flashing-service.js.map +1 -0
- package/build/cjs/{uart-service.d.ts → bluetooth/services/uart-service.d.ts} +2 -2
- package/build/cjs/{uart-service.js → bluetooth/services/uart-service.js} +12 -9
- package/build/cjs/bluetooth/services/uart-service.js.map +1 -0
- package/build/cjs/board-id.d.ts +1 -1
- package/build/cjs/board-id.js.map +1 -1
- package/build/cjs/device.d.ts +82 -75
- package/build/cjs/device.js +40 -126
- package/build/cjs/device.js.map +1 -1
- package/build/cjs/events.d.ts +9 -108
- package/build/cjs/events.js +27 -88
- package/build/cjs/events.js.map +1 -1
- package/build/cjs/events.test.d.ts +1 -0
- package/build/cjs/events.test.js +115 -0
- package/build/cjs/events.test.js.map +1 -0
- package/build/cjs/hex-util.d.ts +1 -0
- package/build/cjs/hex-util.js +15 -0
- package/build/cjs/hex-util.js.map +1 -0
- package/build/cjs/index.d.ts +7 -16
- package/build/cjs/index.js +6 -26
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/logging.js.map +1 -1
- package/build/cjs/radio-bridge/connection.d.ts +39 -0
- package/build/cjs/{usb-radio-bridge.js → radio-bridge/connection.js} +39 -25
- package/build/cjs/radio-bridge/connection.js.map +1 -0
- package/build/cjs/radio-bridge/index.d.ts +4 -0
- package/build/cjs/radio-bridge/index.js +9 -0
- package/build/cjs/radio-bridge/index.js.map +1 -0
- package/build/cjs/{usb-serial-protocol.js → radio-bridge/serial-protocol.js} +1 -1
- package/build/cjs/radio-bridge/serial-protocol.js.map +1 -0
- package/build/cjs/service-events.d.ts +42 -14
- package/build/cjs/service-events.js +6 -36
- package/build/cjs/service-events.js.map +1 -1
- package/build/cjs/setupTests.js +8 -0
- package/build/cjs/setupTests.js.map +1 -1
- package/build/{esm/hex-flash-data-source.d.ts → cjs/universal-hex/flash-data-source.d.ts} +1 -2
- package/build/cjs/{hex-flash-data-source.js → universal-hex/flash-data-source.js} +7 -15
- package/build/cjs/universal-hex/flash-data-source.js.map +1 -0
- package/build/cjs/universal-hex/index.d.ts +4 -0
- package/build/cjs/universal-hex/index.js +9 -0
- package/build/cjs/universal-hex/index.js.map +1 -0
- package/build/cjs/usb/arm-debug.d.ts +137 -0
- package/build/cjs/usb/arm-debug.js +414 -0
- package/build/cjs/usb/arm-debug.js.map +1 -0
- package/build/cjs/usb/arm-debug.test.d.ts +1 -0
- package/build/cjs/usb/arm-debug.test.js +333 -0
- package/build/cjs/usb/arm-debug.test.js.map +1 -0
- package/build/cjs/{board-serial-info.d.ts → usb/board-serial-info.d.ts} +2 -1
- package/build/cjs/{board-serial-info.js → usb/board-serial-info.js} +10 -7
- package/build/cjs/usb/board-serial-info.js.map +1 -0
- package/build/cjs/usb/board-serial-info.test.d.ts +1 -0
- package/build/cjs/usb/board-serial-info.test.js +46 -0
- package/build/cjs/usb/board-serial-info.test.js.map +1 -0
- package/build/cjs/usb/cdc-saturation.d.ts +36 -0
- package/build/cjs/usb/cdc-saturation.js +151 -0
- package/build/cjs/usb/cdc-saturation.js.map +1 -0
- package/build/cjs/usb/cmsis-dap.d.ts +113 -0
- package/build/cjs/usb/cmsis-dap.js +349 -0
- package/build/cjs/usb/cmsis-dap.js.map +1 -0
- package/build/cjs/usb/cmsis-dap.test.d.ts +1 -0
- package/build/cjs/usb/cmsis-dap.test.js +350 -0
- package/build/cjs/usb/cmsis-dap.test.js.map +1 -0
- package/build/cjs/usb/connection.d.ts +81 -0
- package/build/cjs/{usb.js → usb/connection.js} +243 -166
- package/build/cjs/usb/connection.js.map +1 -0
- package/build/cjs/usb/connection.test.d.ts +1 -0
- package/build/cjs/usb/connection.test.js +266 -0
- package/build/cjs/usb/connection.test.js.map +1 -0
- package/build/cjs/usb/cortex-m.d.ts +72 -0
- package/build/cjs/usb/cortex-m.js +165 -0
- package/build/cjs/usb/cortex-m.js.map +1 -0
- package/build/cjs/usb/cortex-m.test.d.ts +1 -0
- package/build/cjs/usb/cortex-m.test.js +217 -0
- package/build/cjs/usb/cortex-m.test.js.map +1 -0
- package/build/cjs/usb/daplink.d.ts +69 -0
- package/build/cjs/usb/daplink.js +238 -0
- package/build/cjs/usb/daplink.js.map +1 -0
- package/build/cjs/usb/daplink.test.d.ts +1 -0
- package/build/cjs/usb/daplink.test.js +290 -0
- package/build/cjs/usb/daplink.test.js.map +1 -0
- package/build/cjs/usb/device-wrapper.d.ts +34 -0
- package/build/cjs/usb/device-wrapper.js +102 -0
- package/build/cjs/usb/device-wrapper.js.map +1 -0
- package/build/cjs/usb/index.d.ts +5 -0
- package/build/cjs/usb/index.js +10 -0
- package/build/cjs/usb/index.js.map +1 -0
- package/build/{esm/usb-partial-flashing-utils.d.ts → cjs/usb/partial-flashing-utils.d.ts} +6 -9
- package/build/cjs/{usb-partial-flashing-utils.js → usb/partial-flashing-utils.js} +6 -49
- package/build/cjs/usb/partial-flashing-utils.js.map +1 -0
- package/build/cjs/{usb-partial-flashing.d.ts → usb/partial-flashing.d.ts} +15 -7
- package/build/cjs/{usb-partial-flashing.js → usb/partial-flashing.js} +64 -119
- package/build/cjs/usb/partial-flashing.js.map +1 -0
- package/build/cjs/usb/promise-queue.js.map +1 -0
- package/build/cjs/usb/promise-queue.test.d.ts +1 -0
- package/build/cjs/usb/promise-queue.test.js +68 -0
- package/build/cjs/usb/promise-queue.test.js.map +1 -0
- package/build/cjs/usb/serial-events.d.ts +21 -0
- package/build/cjs/{led.js → usb/serial-events.js} +1 -1
- package/build/cjs/usb/serial-events.js.map +1 -0
- package/build/cjs/usb/transport.d.ts +42 -0
- package/build/cjs/usb/transport.js +155 -0
- package/build/cjs/usb/transport.js.map +1 -0
- package/build/esm/async-util.js.map +1 -1
- package/build/esm/async-util.test.d.ts +1 -0
- package/build/esm/async-util.test.js +18 -0
- package/build/esm/async-util.test.js.map +1 -0
- package/build/esm/availability.js.map +1 -1
- package/build/{cjs/bluetooth.d.ts → esm/bluetooth/connection.d.ts} +30 -26
- package/build/esm/{bluetooth.js → bluetooth/connection.js} +177 -100
- package/build/esm/bluetooth/connection.js.map +1 -0
- package/build/esm/bluetooth/connection.test.d.ts +1 -0
- package/build/esm/bluetooth/connection.test.js +86 -0
- package/build/esm/bluetooth/connection.test.js.map +1 -0
- package/build/esm/bluetooth/device-bond-state.js.map +1 -0
- package/build/esm/{bluetooth-device-wrapper.d.ts → bluetooth/device-wrapper.d.ts} +22 -11
- package/build/esm/{bluetooth-device-wrapper.js → bluetooth/device-wrapper.js} +97 -41
- package/build/esm/bluetooth/device-wrapper.js.map +1 -0
- package/build/esm/{flashing → bluetooth/flashing}/flashing-full.d.ts +2 -2
- package/build/esm/{flashing → bluetooth/flashing}/flashing-full.js +4 -4
- package/build/esm/bluetooth/flashing/flashing-full.js.map +1 -0
- package/build/esm/bluetooth/flashing/flashing-makecode.d.ts +10 -0
- package/build/esm/{flashing → bluetooth/flashing}/flashing-makecode.js +5 -2
- package/build/esm/bluetooth/flashing/flashing-makecode.js.map +1 -0
- package/build/esm/bluetooth/flashing/flashing-makecode.test.d.ts +1 -0
- package/build/esm/bluetooth/flashing/flashing-makecode.test.js +248 -0
- package/build/esm/bluetooth/flashing/flashing-makecode.test.js.map +1 -0
- package/build/esm/{flashing → bluetooth/flashing}/flashing-partial.d.ts +3 -2
- package/build/esm/{flashing → bluetooth/flashing}/flashing-partial.js +17 -3
- package/build/esm/bluetooth/flashing/flashing-partial.js.map +1 -0
- package/build/esm/bluetooth/flashing/flashing-v1.js.map +1 -0
- package/build/esm/{flashing → bluetooth/flashing}/nordic-dfu.d.ts +2 -2
- package/build/esm/{flashing → bluetooth/flashing}/nordic-dfu.js +25 -11
- package/build/esm/bluetooth/flashing/nordic-dfu.js.map +1 -0
- package/build/esm/bluetooth/flashing/zip.js.map +1 -0
- package/build/esm/bluetooth/flashing/zip.test.d.ts +1 -0
- package/build/esm/bluetooth/flashing/zip.test.js +94 -0
- package/build/esm/bluetooth/flashing/zip.test.js.map +1 -0
- package/build/esm/bluetooth/index.d.ts +5 -0
- package/build/esm/bluetooth/index.js +5 -0
- package/build/esm/bluetooth/index.js.map +1 -0
- package/build/esm/{bluetooth-profile.d.ts → bluetooth/profile.d.ts} +8 -0
- package/build/esm/{bluetooth-profile.js → bluetooth/profile.js} +7 -1
- package/build/{cjs/bluetooth-profile.js.map → esm/bluetooth/profile.js.map} +1 -1
- package/build/{cjs → esm/bluetooth/services}/accelerometer-service.d.ts +2 -3
- package/build/esm/{accelerometer-service.js → bluetooth/services/accelerometer-service.js} +10 -6
- package/build/esm/bluetooth/services/accelerometer-service.js.map +1 -0
- package/build/{cjs → esm/bluetooth/services}/button-service.d.ts +2 -3
- package/build/esm/{button-service.js → bluetooth/services/button-service.js} +10 -9
- package/build/esm/bluetooth/services/button-service.js.map +1 -0
- package/build/{cjs → esm/bluetooth/services}/device-information-service.d.ts +1 -1
- package/build/esm/{device-information-service.js → bluetooth/services/device-information-service.js} +1 -1
- package/build/esm/bluetooth/services/device-information-service.js.map +1 -0
- package/build/esm/{dfu-service.js → bluetooth/services/dfu-service.js} +1 -1
- package/build/esm/bluetooth/services/dfu-service.js.map +1 -0
- package/build/esm/{led-service.d.ts → bluetooth/services/led-service.d.ts} +2 -3
- package/build/esm/{led-service.js → bluetooth/services/led-service.js} +1 -1
- package/build/esm/bluetooth/services/led-service.js.map +1 -0
- package/build/esm/{magnetometer-service.d.ts → bluetooth/services/magnetometer-service.d.ts} +2 -3
- package/build/esm/{magnetometer-service.js → bluetooth/services/magnetometer-service.js} +10 -6
- package/build/esm/bluetooth/services/magnetometer-service.js.map +1 -0
- package/build/{cjs → esm/bluetooth/services}/partial-flashing-service.d.ts +1 -1
- package/build/esm/{partial-flashing-service.js → bluetooth/services/partial-flashing-service.js} +4 -4
- package/build/esm/bluetooth/services/partial-flashing-service.js.map +1 -0
- package/build/esm/{uart-service.d.ts → bluetooth/services/uart-service.d.ts} +2 -2
- package/build/esm/{uart-service.js → bluetooth/services/uart-service.js} +8 -5
- package/build/esm/bluetooth/services/uart-service.js.map +1 -0
- package/build/esm/board-id.d.ts +1 -1
- package/build/esm/board-id.js.map +1 -1
- package/build/esm/device.d.ts +82 -75
- package/build/esm/device.js +38 -120
- package/build/esm/device.js.map +1 -1
- package/build/esm/events.d.ts +9 -108
- package/build/esm/events.js +26 -86
- package/build/esm/events.js.map +1 -1
- package/build/esm/events.test.d.ts +1 -0
- package/build/esm/events.test.js +113 -0
- package/build/esm/events.test.js.map +1 -0
- package/build/esm/hex-util.d.ts +1 -0
- package/build/esm/hex-util.js +11 -0
- package/build/esm/hex-util.js.map +1 -0
- package/build/esm/index.d.ts +7 -16
- package/build/esm/index.js +6 -10
- package/build/esm/index.js.map +1 -1
- package/build/esm/logging.js.map +1 -1
- package/build/esm/radio-bridge/connection.d.ts +39 -0
- package/build/esm/{usb-radio-bridge.js → radio-bridge/connection.js} +39 -25
- package/build/esm/radio-bridge/connection.js.map +1 -0
- package/build/esm/radio-bridge/index.d.ts +4 -0
- package/build/esm/radio-bridge/index.js +5 -0
- package/build/esm/radio-bridge/index.js.map +1 -0
- package/build/esm/{usb-serial-protocol.js → radio-bridge/serial-protocol.js} +1 -1
- package/build/esm/radio-bridge/serial-protocol.js.map +1 -0
- package/build/esm/service-events.d.ts +42 -14
- package/build/esm/service-events.js +5 -34
- package/build/esm/service-events.js.map +1 -1
- package/build/esm/setupTests.js +7 -0
- package/build/esm/setupTests.js.map +1 -1
- package/build/{cjs/hex-flash-data-source.d.ts → esm/universal-hex/flash-data-source.d.ts} +1 -2
- package/build/esm/{hex-flash-data-source.js → universal-hex/flash-data-source.js} +6 -13
- package/build/esm/universal-hex/flash-data-source.js.map +1 -0
- package/build/esm/universal-hex/index.d.ts +4 -0
- package/build/esm/universal-hex/index.js +5 -0
- package/build/esm/universal-hex/index.js.map +1 -0
- package/build/esm/usb/arm-debug.d.ts +137 -0
- package/build/esm/usb/arm-debug.js +409 -0
- package/build/esm/usb/arm-debug.js.map +1 -0
- package/build/esm/usb/arm-debug.test.d.ts +1 -0
- package/build/esm/usb/arm-debug.test.js +331 -0
- package/build/esm/usb/arm-debug.test.js.map +1 -0
- package/build/esm/{board-serial-info.d.ts → usb/board-serial-info.d.ts} +2 -1
- package/build/esm/{board-serial-info.js → usb/board-serial-info.js} +10 -7
- package/build/esm/usb/board-serial-info.js.map +1 -0
- package/build/esm/usb/board-serial-info.test.d.ts +1 -0
- package/build/esm/usb/board-serial-info.test.js +44 -0
- package/build/esm/usb/board-serial-info.test.js.map +1 -0
- package/build/esm/usb/cdc-saturation.d.ts +36 -0
- package/build/esm/usb/cdc-saturation.js +148 -0
- package/build/esm/usb/cdc-saturation.js.map +1 -0
- package/build/esm/usb/cmsis-dap.d.ts +113 -0
- package/build/esm/usb/cmsis-dap.js +342 -0
- package/build/esm/usb/cmsis-dap.js.map +1 -0
- package/build/esm/usb/cmsis-dap.test.d.ts +1 -0
- package/build/esm/usb/cmsis-dap.test.js +348 -0
- package/build/esm/usb/cmsis-dap.test.js.map +1 -0
- package/build/esm/usb/connection.d.ts +81 -0
- package/build/esm/{usb.js → usb/connection.js} +239 -161
- package/build/esm/usb/connection.js.map +1 -0
- package/build/esm/usb/connection.test.d.ts +1 -0
- package/build/esm/usb/connection.test.js +264 -0
- package/build/esm/usb/connection.test.js.map +1 -0
- package/build/esm/usb/cortex-m.d.ts +72 -0
- package/build/esm/usb/cortex-m.js +161 -0
- package/build/esm/usb/cortex-m.js.map +1 -0
- package/build/esm/usb/cortex-m.test.d.ts +1 -0
- package/build/esm/usb/cortex-m.test.js +215 -0
- package/build/esm/usb/cortex-m.test.js.map +1 -0
- package/build/esm/usb/daplink.d.ts +69 -0
- package/build/esm/usb/daplink.js +231 -0
- package/build/esm/usb/daplink.js.map +1 -0
- package/build/esm/usb/daplink.test.d.ts +1 -0
- package/build/esm/usb/daplink.test.js +288 -0
- package/build/esm/usb/daplink.test.js.map +1 -0
- package/build/esm/usb/device-wrapper.d.ts +34 -0
- package/build/esm/usb/device-wrapper.js +98 -0
- package/build/esm/usb/device-wrapper.js.map +1 -0
- package/build/esm/usb/index.d.ts +5 -0
- package/build/esm/usb/index.js +5 -0
- package/build/esm/usb/index.js.map +1 -0
- package/build/{cjs/usb-partial-flashing-utils.d.ts → esm/usb/partial-flashing-utils.d.ts} +6 -9
- package/build/esm/{usb-partial-flashing-utils.js → usb/partial-flashing-utils.js} +4 -44
- package/build/esm/usb/partial-flashing-utils.js.map +1 -0
- package/build/esm/{usb-partial-flashing.d.ts → usb/partial-flashing.d.ts} +15 -7
- package/build/esm/{usb-partial-flashing.js → usb/partial-flashing.js} +62 -94
- package/build/esm/usb/partial-flashing.js.map +1 -0
- package/build/esm/usb/promise-queue.js.map +1 -0
- package/build/esm/usb/promise-queue.test.d.ts +1 -0
- package/build/esm/usb/promise-queue.test.js +66 -0
- package/build/esm/usb/promise-queue.test.js.map +1 -0
- package/build/esm/usb/serial-events.d.ts +21 -0
- package/build/esm/usb/serial-events.js +2 -0
- package/build/esm/usb/serial-events.js.map +1 -0
- package/build/esm/usb/transport.d.ts +42 -0
- package/build/esm/usb/transport.js +151 -0
- package/build/esm/usb/transport.js.map +1 -0
- package/package.json +55 -15
- package/LICENSE.md +0 -21
- package/README.md +0 -125
- package/build/cjs/accelerometer-service.js.map +0 -1
- package/build/cjs/accelerometer.d.ts +0 -9
- package/build/cjs/accelerometer.js +0 -16
- package/build/cjs/accelerometer.js.map +0 -1
- package/build/cjs/bluetooth-device-wrapper.js.map +0 -1
- package/build/cjs/bluetooth.js.map +0 -1
- package/build/cjs/board-serial-info.js.map +0 -1
- package/build/cjs/button-service.js.map +0 -1
- package/build/cjs/buttons.d.ts +0 -10
- package/build/cjs/buttons.js +0 -22
- package/build/cjs/buttons.js.map +0 -1
- package/build/cjs/constants.d.ts +0 -48
- package/build/cjs/constants.js +0 -73
- package/build/cjs/constants.js.map +0 -1
- package/build/cjs/device-bond-state.js.map +0 -1
- package/build/cjs/device-information-service.js.map +0 -1
- package/build/cjs/dfu-service.js.map +0 -1
- package/build/cjs/flashing/flashing-full.js.map +0 -1
- package/build/cjs/flashing/flashing-makecode.d.ts +0 -6
- package/build/cjs/flashing/flashing-makecode.js.map +0 -1
- package/build/cjs/flashing/flashing-partial.js.map +0 -1
- package/build/cjs/flashing/flashing-v1.js.map +0 -1
- package/build/cjs/flashing/nordic-dfu.js.map +0 -1
- package/build/cjs/flashing/zip.js.map +0 -1
- package/build/cjs/hex-flash-data-source.js.map +0 -1
- package/build/cjs/led-service.js.map +0 -1
- package/build/cjs/led.d.ts +0 -6
- package/build/cjs/led.js.map +0 -1
- package/build/cjs/magnetometer-service.js.map +0 -1
- package/build/cjs/magnetometer.d.ts +0 -9
- package/build/cjs/magnetometer.js +0 -16
- package/build/cjs/magnetometer.js.map +0 -1
- package/build/cjs/partial-flashing-service.js.map +0 -1
- package/build/cjs/promise-queue.js.map +0 -1
- package/build/cjs/serial-events.d.ts +0 -20
- package/build/cjs/serial-events.js +0 -69
- package/build/cjs/serial-events.js.map +0 -1
- package/build/cjs/uart-service.js.map +0 -1
- package/build/cjs/uart.d.ts +0 -4
- package/build/cjs/uart.js +0 -16
- package/build/cjs/uart.js.map +0 -1
- package/build/cjs/usb-device-wrapper.d.ts +0 -47
- package/build/cjs/usb-device-wrapper.js +0 -437
- package/build/cjs/usb-device-wrapper.js.map +0 -1
- package/build/cjs/usb-partial-flashing-utils.js.map +0 -1
- package/build/cjs/usb-partial-flashing.js.map +0 -1
- package/build/cjs/usb-radio-bridge.d.ts +0 -24
- package/build/cjs/usb-radio-bridge.js.map +0 -1
- package/build/cjs/usb-serial-protocol.js.map +0 -1
- package/build/cjs/usb.d.ts +0 -66
- package/build/cjs/usb.js.map +0 -1
- package/build/esm/accelerometer-service.js.map +0 -1
- package/build/esm/accelerometer.d.ts +0 -9
- package/build/esm/accelerometer.js +0 -12
- package/build/esm/accelerometer.js.map +0 -1
- package/build/esm/bluetooth-device-wrapper.js.map +0 -1
- package/build/esm/bluetooth-profile.js.map +0 -1
- package/build/esm/bluetooth.js.map +0 -1
- package/build/esm/board-serial-info.js.map +0 -1
- package/build/esm/button-service.js.map +0 -1
- package/build/esm/buttons.d.ts +0 -10
- package/build/esm/buttons.js +0 -18
- package/build/esm/buttons.js.map +0 -1
- package/build/esm/constants.d.ts +0 -48
- package/build/esm/constants.js +0 -70
- package/build/esm/constants.js.map +0 -1
- package/build/esm/device-bond-state.js.map +0 -1
- package/build/esm/device-information-service.js.map +0 -1
- package/build/esm/dfu-service.js.map +0 -1
- package/build/esm/flashing/flashing-full.js.map +0 -1
- package/build/esm/flashing/flashing-makecode.d.ts +0 -6
- package/build/esm/flashing/flashing-makecode.js.map +0 -1
- package/build/esm/flashing/flashing-partial.js.map +0 -1
- package/build/esm/flashing/flashing-v1.js.map +0 -1
- package/build/esm/flashing/nordic-dfu.js.map +0 -1
- package/build/esm/flashing/zip.js.map +0 -1
- package/build/esm/hex-flash-data-source.js.map +0 -1
- package/build/esm/led-service.js.map +0 -1
- package/build/esm/led.d.ts +0 -6
- package/build/esm/led.js +0 -2
- package/build/esm/led.js.map +0 -1
- package/build/esm/magnetometer-service.js.map +0 -1
- package/build/esm/magnetometer.d.ts +0 -9
- package/build/esm/magnetometer.js +0 -12
- package/build/esm/magnetometer.js.map +0 -1
- package/build/esm/partial-flashing-service.js.map +0 -1
- package/build/esm/promise-queue.js.map +0 -1
- package/build/esm/serial-events.d.ts +0 -20
- package/build/esm/serial-events.js +0 -61
- package/build/esm/serial-events.js.map +0 -1
- package/build/esm/uart-service.js.map +0 -1
- package/build/esm/uart.d.ts +0 -4
- package/build/esm/uart.js +0 -12
- package/build/esm/uart.js.map +0 -1
- package/build/esm/usb-device-wrapper.d.ts +0 -47
- package/build/esm/usb-device-wrapper.js +0 -410
- package/build/esm/usb-device-wrapper.js.map +0 -1
- package/build/esm/usb-partial-flashing-utils.js.map +0 -1
- package/build/esm/usb-partial-flashing.js.map +0 -1
- package/build/esm/usb-radio-bridge.d.ts +0 -24
- package/build/esm/usb-radio-bridge.js.map +0 -1
- package/build/esm/usb-serial-protocol.js.map +0 -1
- package/build/esm/usb.d.ts +0 -66
- package/build/esm/usb.js.map +0 -1
- package/typedoc.json +0 -14
- /package/build/cjs/{device-bond-state.d.ts → bluetooth/device-bond-state.d.ts} +0 -0
- /package/build/cjs/{device-bond-state.js → bluetooth/device-bond-state.js} +0 -0
- /package/build/cjs/{flashing → bluetooth/flashing}/flashing-v1.d.ts +0 -0
- /package/build/cjs/{flashing → bluetooth/flashing}/flashing-v1.js +0 -0
- /package/build/cjs/{flashing → bluetooth/flashing}/zip.d.ts +0 -0
- /package/build/cjs/{flashing → bluetooth/flashing}/zip.js +0 -0
- /package/build/cjs/{dfu-service.d.ts → bluetooth/services/dfu-service.d.ts} +0 -0
- /package/build/cjs/{usb-serial-protocol.d.ts → radio-bridge/serial-protocol.d.ts} +0 -0
- /package/build/cjs/{promise-queue.d.ts → usb/promise-queue.d.ts} +0 -0
- /package/build/cjs/{promise-queue.js → usb/promise-queue.js} +0 -0
- /package/build/esm/{device-bond-state.d.ts → bluetooth/device-bond-state.d.ts} +0 -0
- /package/build/esm/{device-bond-state.js → bluetooth/device-bond-state.js} +0 -0
- /package/build/esm/{flashing → bluetooth/flashing}/flashing-v1.d.ts +0 -0
- /package/build/esm/{flashing → bluetooth/flashing}/flashing-v1.js +0 -0
- /package/build/esm/{flashing → bluetooth/flashing}/zip.d.ts +0 -0
- /package/build/esm/{flashing → bluetooth/flashing}/zip.js +0 -0
- /package/build/esm/{dfu-service.d.ts → bluetooth/services/dfu-service.d.ts} +0 -0
- /package/build/esm/{usb-serial-protocol.d.ts → radio-bridge/serial-protocol.d.ts} +0 -0
- /package/build/esm/{promise-queue.d.ts → usb/promise-queue.d.ts} +0 -0
- /package/build/esm/{promise-queue.js → usb/promise-queue.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (c) 2021, Micro:bit Educational Foundation and contributors
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { TimeoutError, withTimeout } from "./async-util.js";
|
|
8
|
+
describe("withTimeout", () => {
|
|
9
|
+
it("times out", async () => {
|
|
10
|
+
const neverResolves = new Promise(() => { });
|
|
11
|
+
await expect(() => withTimeout(neverResolves, 0)).rejects.toThrowError(TimeoutError);
|
|
12
|
+
});
|
|
13
|
+
it("returns the value", async () => {
|
|
14
|
+
const resolvesWithValue = async () => "foo";
|
|
15
|
+
expect(await withTimeout(resolvesWithValue(), 10)).toEqual("foo");
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=async-util.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-util.test.js","sourceRoot":"","sources":["../../src/async-util.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE5D,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;QACzB,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC5C,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CACpE,YAAY,CACb,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;QACjC,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC;QAC5C,MAAM,CAAC,MAAM,WAAW,CAAC,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"availability.js","sourceRoot":"","sources":["../../
|
|
1
|
+
{"version":3,"file":"availability.js","sourceRoot":"","sources":["../../src/availability.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAgC,WAAW,EAAE,MAAM,aAAa,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,MAAoC,EAC9B,EAAE;IACR,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,WAAW;YACd,OAAO;QACT,KAAK,aAAa;YAChB,MAAM,IAAI,WAAW,CAAC;gBACpB,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,+BAA+B;aACzC,CAAC,CAAC;QACL,KAAK,UAAU;YACb,MAAM,IAAI,WAAW,CAAC;gBACpB,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,wBAAwB;aAClC,CAAC,CAAC;QACL,KAAK,mBAAmB;YACtB,MAAM,IAAI,WAAW,CAAC;gBACpB,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE,mBAAmB;aAC7B,CAAC,CAAC;QACL,KAAK,mBAAmB;YACtB,MAAM,IAAI,WAAW,CAAC;gBACpB,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE,4BAA4B;aACtC,CAAC,CAAC;IACP,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { LedMatrix } from "
|
|
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
|
|
5
|
+
export interface MicrobitBluetoothConnectionOptions {
|
|
9
6
|
logging?: Logging;
|
|
10
7
|
deviceBondState?: DeviceBondState;
|
|
11
8
|
}
|
|
12
|
-
export interface
|
|
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
|
|
19
|
+
* @returns accelerometer data.
|
|
20
|
+
* @throws {DeviceError} with code `not-connected` if there is no connection.
|
|
23
21
|
*/
|
|
24
|
-
getAccelerometerData(): Promise<AccelerometerData
|
|
22
|
+
getAccelerometerData(): Promise<AccelerometerData>;
|
|
25
23
|
/**
|
|
26
24
|
* Gets micro:bit accelerometer period.
|
|
27
25
|
*
|
|
28
|
-
* @returns accelerometer period
|
|
26
|
+
* @returns accelerometer period.
|
|
27
|
+
* @throws {DeviceError} with code `not-connected` if there is no connection.
|
|
29
28
|
*/
|
|
30
|
-
getAccelerometerPeriod(): Promise<number
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
118
|
+
export declare const createBluetoothConnection: (options?: MicrobitBluetoothConnectionOptions) => MicrobitBluetoothConnection;
|
|
@@ -6,38 +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 "./
|
|
10
|
-
import { profile } from "./
|
|
11
|
-
import {
|
|
12
|
-
import { TypedEventTarget } from "
|
|
13
|
-
import { ConsoleLogging } from "
|
|
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 "
|
|
17
|
-
import { truncateHexAfterEof } from "
|
|
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
20
|
let bleClientInitialized = false;
|
|
20
21
|
/**
|
|
21
22
|
* A Bluetooth connection factory.
|
|
22
23
|
*/
|
|
23
|
-
export const
|
|
24
|
+
export const createBluetoothConnection = (options) => new MicrobitBluetoothConnectionImpl(options);
|
|
24
25
|
/**
|
|
25
26
|
* A Bluetooth connection to a micro:bit device.
|
|
26
27
|
*/
|
|
27
|
-
class
|
|
28
|
+
class MicrobitBluetoothConnectionImpl extends TypedEventTarget {
|
|
28
29
|
constructor(options = {}) {
|
|
29
30
|
super();
|
|
30
31
|
Object.defineProperty(this, "status", {
|
|
31
32
|
enumerable: true,
|
|
32
33
|
configurable: true,
|
|
33
34
|
writable: true,
|
|
34
|
-
value: ConnectionStatus.
|
|
35
|
+
value: ConnectionStatus.NoAuthorizedDevice
|
|
35
36
|
});
|
|
36
37
|
/**
|
|
37
|
-
* The
|
|
38
|
+
* The BLE device we last connected to.
|
|
38
39
|
* Cleared if it is disconnected.
|
|
39
40
|
*/
|
|
40
|
-
Object.defineProperty(this, "
|
|
41
|
+
Object.defineProperty(this, "bleDevice", {
|
|
41
42
|
enumerable: true,
|
|
42
43
|
configurable: true,
|
|
43
44
|
writable: true,
|
|
@@ -55,7 +56,19 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
55
56
|
writable: true,
|
|
56
57
|
value: void 0
|
|
57
58
|
});
|
|
58
|
-
|
|
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", {
|
|
59
72
|
enumerable: true,
|
|
60
73
|
configurable: true,
|
|
61
74
|
writable: true,
|
|
@@ -73,15 +86,21 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
73
86
|
writable: true,
|
|
74
87
|
value: void 0
|
|
75
88
|
});
|
|
89
|
+
Object.defineProperty(this, "waitForPostFlashDisconnectPromise", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: void 0
|
|
94
|
+
});
|
|
76
95
|
this.logging = options.logging || new ConsoleLogging();
|
|
77
96
|
this.deviceBondState =
|
|
78
97
|
options.deviceBondState || new DefaultDeviceBondState();
|
|
79
98
|
}
|
|
80
99
|
eventActivated(type) {
|
|
81
|
-
this.
|
|
100
|
+
this.device?.startNotifications(type);
|
|
82
101
|
}
|
|
83
102
|
eventDeactivated(type) {
|
|
84
|
-
this.
|
|
103
|
+
this.device?.stopNotifications(type);
|
|
85
104
|
}
|
|
86
105
|
log(v) {
|
|
87
106
|
this.logging.log(v);
|
|
@@ -149,7 +168,8 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
149
168
|
}
|
|
150
169
|
}
|
|
151
170
|
getBoardVersion() {
|
|
152
|
-
|
|
171
|
+
assertConnected(this.cachedBoardVersion);
|
|
172
|
+
return this.cachedBoardVersion;
|
|
153
173
|
}
|
|
154
174
|
async connect(options) {
|
|
155
175
|
const progress = options?.progress ?? (() => { });
|
|
@@ -157,21 +177,26 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
157
177
|
// because on Android/iOS that's the appropriate time to ask for permissions.
|
|
158
178
|
progress(ProgressStage.Initializing);
|
|
159
179
|
throwIfUnavailable(await this.checkAvailability());
|
|
160
|
-
|
|
180
|
+
// After partial flashing, we will need to wait for connection to fully
|
|
181
|
+
// disconnect before attempting to connect.
|
|
182
|
+
this.waitForPostFlashDisconnectPromise &&
|
|
183
|
+
(await this.waitForPostFlashDisconnectPromise);
|
|
184
|
+
if (!this.bleDevice || !this.device) {
|
|
161
185
|
progress(ProgressStage.FindingDevice);
|
|
162
186
|
const device = await this.requestDevice(options?.signal);
|
|
163
|
-
this.
|
|
164
|
-
onConnecting: () => this.setStatus(ConnectionStatus.
|
|
165
|
-
onSuccess: () => this.setStatus(ConnectionStatus.
|
|
166
|
-
onDisconnect: () => this.setStatus(ConnectionStatus.
|
|
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),
|
|
167
191
|
});
|
|
168
192
|
}
|
|
169
|
-
await this.
|
|
193
|
+
await this.device.connect(options);
|
|
194
|
+
this.cachedBoardVersion = this.device.boardVersion;
|
|
170
195
|
}
|
|
171
196
|
async disconnect() {
|
|
172
197
|
try {
|
|
173
|
-
if (this.
|
|
174
|
-
await this.
|
|
198
|
+
if (this.device) {
|
|
199
|
+
await this.device.disconnect();
|
|
175
200
|
}
|
|
176
201
|
}
|
|
177
202
|
catch (e) {
|
|
@@ -181,7 +206,7 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
181
206
|
});
|
|
182
207
|
}
|
|
183
208
|
finally {
|
|
184
|
-
this.setStatus(ConnectionStatus.
|
|
209
|
+
this.setStatus(ConnectionStatus.Disconnected);
|
|
185
210
|
this.logging.event({
|
|
186
211
|
type: "Bluetooth-info",
|
|
187
212
|
message: "disconnected",
|
|
@@ -193,105 +218,118 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
193
218
|
this.status = newStatus;
|
|
194
219
|
this.log("Bluetooth connection status " + newStatus);
|
|
195
220
|
if (this.deferredUpdatesPreviousStatus === undefined) {
|
|
196
|
-
this.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (this.connection) {
|
|
201
|
-
// TODO
|
|
221
|
+
this.dispatchEvent("status", {
|
|
222
|
+
status: newStatus,
|
|
223
|
+
previousStatus,
|
|
224
|
+
});
|
|
202
225
|
}
|
|
203
|
-
return Promise.resolve();
|
|
204
226
|
}
|
|
205
227
|
async clearDevice() {
|
|
206
228
|
await this.disconnect();
|
|
207
|
-
this.
|
|
208
|
-
this.
|
|
229
|
+
this.bleDevice = undefined;
|
|
230
|
+
this.cachedBoardVersion = undefined;
|
|
231
|
+
this.setStatus(ConnectionStatus.NoAuthorizedDevice);
|
|
209
232
|
}
|
|
210
233
|
setNameFilter(name) {
|
|
211
234
|
this.nameFilter = name;
|
|
212
235
|
}
|
|
213
236
|
async requestDevice(signal) {
|
|
214
|
-
//
|
|
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).
|
|
215
239
|
// See https://github.com/bsiever/microbit-pxt-blehid/issues/31
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
const namePrefix = this.nameFilter
|
|
220
|
-
? `BBC micro:bit [${this.nameFilter}]`
|
|
221
|
-
: "BBC micro:bit";
|
|
240
|
+
const namePrefixes = this.nameFilter
|
|
241
|
+
? [`BBC micro:bit [${this.nameFilter}]`, `uBit [${this.nameFilter}]`]
|
|
242
|
+
: ["BBC micro:bit", "uBit"];
|
|
222
243
|
// If we have a cached device, check if it still matches the current filter.
|
|
223
244
|
// If not, clear it so we find a new device.
|
|
224
|
-
if (this.
|
|
225
|
-
if (this.
|
|
226
|
-
return this.
|
|
245
|
+
if (this.bleDevice) {
|
|
246
|
+
if (namePrefixes.some((p) => this.bleDevice.name?.startsWith(p))) {
|
|
247
|
+
return this.bleDevice;
|
|
227
248
|
}
|
|
228
|
-
this.log(`Cached device "${this.
|
|
249
|
+
this.log(`Cached device "${this.bleDevice.name}" doesn't match filters "${namePrefixes.join(", ")}", clearing`);
|
|
229
250
|
await this.clearDevice();
|
|
230
251
|
}
|
|
231
|
-
this.
|
|
252
|
+
this.dispatchEvent("beforerequestdevice");
|
|
232
253
|
try {
|
|
233
|
-
this.
|
|
234
|
-
? await this.requestDeviceNative(
|
|
235
|
-
: await this.requestDeviceWeb(
|
|
236
|
-
if (!this.
|
|
237
|
-
this.setStatus(ConnectionStatus.
|
|
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);
|
|
238
259
|
throw new DeviceError({
|
|
239
260
|
code: "no-device-selected",
|
|
240
261
|
message: "No device selected",
|
|
241
262
|
});
|
|
242
263
|
}
|
|
243
|
-
return this.
|
|
264
|
+
return this.bleDevice;
|
|
244
265
|
}
|
|
245
266
|
finally {
|
|
246
|
-
this.
|
|
267
|
+
this.dispatchEvent("afterrequestdevice");
|
|
247
268
|
}
|
|
248
269
|
}
|
|
249
270
|
async getAccelerometerData() {
|
|
250
|
-
|
|
271
|
+
assertConnected(this.device);
|
|
272
|
+
return this.device.accelerometer.getData();
|
|
251
273
|
}
|
|
252
274
|
async getAccelerometerPeriod() {
|
|
253
|
-
|
|
275
|
+
assertConnected(this.device);
|
|
276
|
+
return this.device.accelerometer.getPeriod();
|
|
254
277
|
}
|
|
255
278
|
async setAccelerometerPeriod(value) {
|
|
256
|
-
|
|
279
|
+
assertConnected(this.device);
|
|
280
|
+
return this.device.accelerometer.setPeriod(value);
|
|
257
281
|
}
|
|
258
282
|
async setLedText(text) {
|
|
259
|
-
|
|
283
|
+
assertConnected(this.device);
|
|
284
|
+
return this.device.led.setText(text);
|
|
260
285
|
}
|
|
261
286
|
async getLedScrollingDelay() {
|
|
262
|
-
|
|
287
|
+
assertConnected(this.device);
|
|
288
|
+
return this.device.led.getScrollingDelay();
|
|
263
289
|
}
|
|
264
290
|
async setLedScrollingDelay(delayInMillis) {
|
|
265
|
-
|
|
291
|
+
assertConnected(this.device);
|
|
292
|
+
await this.device.led.setScrollingDelay(delayInMillis);
|
|
266
293
|
}
|
|
267
294
|
async getLedMatrix() {
|
|
268
|
-
|
|
295
|
+
assertConnected(this.device);
|
|
296
|
+
return await this.device.led.getLedMatrix();
|
|
269
297
|
}
|
|
270
298
|
async setLedMatrix(matrix) {
|
|
271
|
-
|
|
299
|
+
assertConnected(this.device);
|
|
300
|
+
await this.device.led.setLedMatrix(matrix);
|
|
272
301
|
}
|
|
273
302
|
async getMagnetometerData() {
|
|
274
|
-
|
|
303
|
+
assertConnected(this.device);
|
|
304
|
+
return this.device.magnetometer.getData();
|
|
275
305
|
}
|
|
276
306
|
async getMagnetometerPeriod() {
|
|
277
|
-
|
|
307
|
+
assertConnected(this.device);
|
|
308
|
+
return this.device.magnetometer.getPeriod();
|
|
278
309
|
}
|
|
279
310
|
async setMagnetometerPeriod(value) {
|
|
280
|
-
|
|
311
|
+
assertConnected(this.device);
|
|
312
|
+
return this.device.magnetometer.setPeriod(value);
|
|
281
313
|
}
|
|
282
314
|
async getMagnetometerBearing() {
|
|
283
|
-
|
|
315
|
+
assertConnected(this.device);
|
|
316
|
+
return this.device.magnetometer.getBearing();
|
|
284
317
|
}
|
|
285
318
|
async triggerMagnetometerCalibration() {
|
|
286
|
-
|
|
319
|
+
assertConnected(this.device);
|
|
320
|
+
await this.device.magnetometer.triggerCalibration();
|
|
287
321
|
}
|
|
288
322
|
async uartWrite(data) {
|
|
289
|
-
|
|
323
|
+
assertConnected(this.device);
|
|
324
|
+
await this.device.uart.writeData(data);
|
|
290
325
|
}
|
|
291
326
|
/**
|
|
292
327
|
* Flash the micro:bit.
|
|
293
328
|
*
|
|
294
|
-
*
|
|
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.
|
|
295
333
|
*
|
|
296
334
|
* @param dataSource The data to use.
|
|
297
335
|
* @param options Flash options and progress callback.
|
|
@@ -301,10 +339,10 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
301
339
|
try {
|
|
302
340
|
// We'll disconnect/reconnect multiple times due to device resets, but reporting this is unhelpful.
|
|
303
341
|
this.deferredUpdatesPreviousStatus = this.status;
|
|
304
|
-
if (this.status !== ConnectionStatus.
|
|
342
|
+
if (this.status !== ConnectionStatus.Connected) {
|
|
305
343
|
await this.connect({ progress, signal: options.signal });
|
|
306
344
|
}
|
|
307
|
-
const connection = this.
|
|
345
|
+
const connection = this.device;
|
|
308
346
|
try {
|
|
309
347
|
const boardVersion = connection.boardVersion;
|
|
310
348
|
if (!boardVersion) {
|
|
@@ -317,7 +355,7 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
317
355
|
if (!memoryMap) {
|
|
318
356
|
throw new FlashDataError("Could not convert hex to memory map");
|
|
319
357
|
}
|
|
320
|
-
if (!this.
|
|
358
|
+
if (!this.bleDevice) {
|
|
321
359
|
throw new DeviceError({
|
|
322
360
|
code: "device-disconnected",
|
|
323
361
|
message: "No device",
|
|
@@ -328,10 +366,32 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
328
366
|
if (partialFlashResult === PartialFlashResult.AttemptFullFlash) {
|
|
329
367
|
await fullFlash(connection, boardVersion, memoryMap, progress);
|
|
330
368
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
369
|
+
this.dispatchEvent("flash");
|
|
370
|
+
if (partialFlashResult === PartialFlashResult.AlreadyUpToDate ||
|
|
371
|
+
partialFlashResult === PartialFlashResult.Success) {
|
|
372
|
+
this.waitForPostFlashDisconnectPromise = (async () => {
|
|
373
|
+
try {
|
|
374
|
+
if (connection.connected) {
|
|
375
|
+
this.log("Wait for post partial flash disconnect...");
|
|
376
|
+
await connection.waitForDisconnect(10_000);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
catch (e) {
|
|
380
|
+
if (e instanceof TimeoutError) {
|
|
381
|
+
this.log("Wait for post partial flash disconnect timed out.");
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
this.error("Error waiting for post partial flash disconnect", e);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
finally {
|
|
388
|
+
this.waitForPostFlashDisconnectPromise = undefined;
|
|
389
|
+
if (connection.connected) {
|
|
390
|
+
await this.disconnect();
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
})();
|
|
394
|
+
this.setStatus(ConnectionStatus.Disconnected);
|
|
335
395
|
}
|
|
336
396
|
}
|
|
337
397
|
catch (e) {
|
|
@@ -339,13 +399,18 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
339
399
|
throw e;
|
|
340
400
|
}
|
|
341
401
|
finally {
|
|
342
|
-
|
|
402
|
+
if (!this.waitForPostFlashDisconnectPromise) {
|
|
403
|
+
await this.disconnect();
|
|
404
|
+
}
|
|
343
405
|
}
|
|
344
406
|
}
|
|
345
407
|
finally {
|
|
346
408
|
const previousStatus = this.deferredUpdatesPreviousStatus;
|
|
347
409
|
this.deferredUpdatesPreviousStatus = undefined;
|
|
348
|
-
this.
|
|
410
|
+
this.dispatchEvent("status", {
|
|
411
|
+
status: this.status,
|
|
412
|
+
previousStatus,
|
|
413
|
+
});
|
|
349
414
|
}
|
|
350
415
|
}
|
|
351
416
|
/**
|
|
@@ -353,22 +418,33 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
353
418
|
*
|
|
354
419
|
* @returns device or undefined if user cancels.
|
|
355
420
|
*/
|
|
356
|
-
async requestDeviceWeb(
|
|
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);
|
|
357
440
|
try {
|
|
441
|
+
navigator.bluetooth.requestDevice = (options) => orig({
|
|
442
|
+
...options,
|
|
443
|
+
filters: namePrefixes.map((namePrefix) => ({ namePrefix })),
|
|
444
|
+
});
|
|
358
445
|
return await BleClient.requestDevice({
|
|
359
|
-
namePrefix,
|
|
360
|
-
optionalServices
|
|
361
|
-
profile.accelerometer.id,
|
|
362
|
-
profile.button.id,
|
|
363
|
-
profile.deviceInformation.id,
|
|
364
|
-
profile.dfuControl.id,
|
|
365
|
-
profile.event.id,
|
|
366
|
-
profile.ioPin.id,
|
|
367
|
-
profile.led.id,
|
|
368
|
-
profile.magnetometer.id,
|
|
369
|
-
profile.temperature.id,
|
|
370
|
-
profile.uart.id,
|
|
371
|
-
],
|
|
446
|
+
namePrefix: namePrefixes[0],
|
|
447
|
+
optionalServices,
|
|
372
448
|
});
|
|
373
449
|
}
|
|
374
450
|
catch (e) {
|
|
@@ -377,6 +453,9 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
377
453
|
}
|
|
378
454
|
throw e;
|
|
379
455
|
}
|
|
456
|
+
finally {
|
|
457
|
+
navigator.bluetooth.requestDevice = orig;
|
|
458
|
+
}
|
|
380
459
|
}
|
|
381
460
|
/**
|
|
382
461
|
* Finds device with specified name prefix.
|
|
@@ -384,19 +463,17 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
384
463
|
* @returns device or undefined if none can be found.
|
|
385
464
|
* @throws DeviceError with code "aborted" if signal is aborted.
|
|
386
465
|
*/
|
|
387
|
-
async requestDeviceNative(
|
|
466
|
+
async requestDeviceNative(namePrefixes, signal) {
|
|
388
467
|
if (signal?.aborted) {
|
|
389
468
|
throw new DeviceError({ code: "aborted", message: "Connection aborted" });
|
|
390
469
|
}
|
|
470
|
+
const matchesAnyPrefix = (name) => !!name && namePrefixes.some((p) => name.startsWith(p));
|
|
391
471
|
// Check for existing bonded devices.
|
|
392
|
-
const bonded = await this.checkBondedDevices((device) =>
|
|
393
|
-
const name = device.name;
|
|
394
|
-
return !!name && name.startsWith(namePrefix);
|
|
395
|
-
});
|
|
472
|
+
const bonded = await this.checkBondedDevices((device) => matchesAnyPrefix(device.name));
|
|
396
473
|
if (bonded) {
|
|
397
474
|
return bonded;
|
|
398
475
|
}
|
|
399
|
-
this.log(`Scanning for device - ${
|
|
476
|
+
this.log(`Scanning for device - ${namePrefixes.join(", ")}`);
|
|
400
477
|
let found = false;
|
|
401
478
|
let aborted = false;
|
|
402
479
|
const scanPromise = new Promise((resolve) =>
|
|
@@ -406,8 +483,8 @@ class MicrobitWebBluetoothConnectionImpl extends TypedEventTarget {
|
|
|
406
483
|
// isn't matched by the name filter but the advertising name is in the
|
|
407
484
|
// localName on the device. So we filter here instead. This happens on
|
|
408
485
|
// iOS if DFU fails / is interrupted.
|
|
409
|
-
if (result.device.name
|
|
410
|
-
result.localName
|
|
486
|
+
if (matchesAnyPrefix(result.device.name) ||
|
|
487
|
+
matchesAnyPrefix(result.localName)) {
|
|
411
488
|
found = true;
|
|
412
489
|
await BleClient.stopLEScan();
|
|
413
490
|
resolve(result.device);
|
|
@@ -452,4 +529,4 @@ const convertDataToMemoryMap = (data) => {
|
|
|
452
529
|
}
|
|
453
530
|
return MemoryMap.fromHex(truncateHexAfterEof(data));
|
|
454
531
|
};
|
|
455
|
-
//# sourceMappingURL=
|
|
532
|
+
//# sourceMappingURL=connection.js.map
|