@microbit/microbit-connection 0.9.0-apps.alpha.9 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -27
- package/build/cjs/async-util.d.ts +3 -1
- package/build/cjs/async-util.js +5 -1
- package/build/cjs/async-util.js.map +1 -1
- package/build/cjs/availability.js.map +1 -1
- package/build/cjs/bluetooth/ble-error.d.ts +10 -0
- package/build/cjs/bluetooth/ble-error.js +47 -0
- package/build/cjs/bluetooth/ble-error.js.map +1 -0
- package/build/cjs/bluetooth/connection.d.ts +378 -0
- package/build/cjs/bluetooth/connection.js +623 -0
- package/build/cjs/bluetooth/connection.js.map +1 -0
- package/build/cjs/bluetooth/device-bond-state.d.ts +14 -0
- package/build/cjs/bluetooth/device-bond-state.js +26 -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} +36 -21
- package/build/cjs/{bluetooth-device-wrapper.js → bluetooth/device-wrapper.js} +174 -147
- package/build/cjs/bluetooth/device-wrapper.js.map +1 -0
- package/build/{esm → cjs/bluetooth}/flashing/flashing-full.d.ts +2 -2
- package/build/cjs/{flashing → bluetooth/flashing}/flashing-full.js +6 -5
- 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-partial.d.ts +10 -0
- package/build/cjs/bluetooth/flashing/flashing-partial.js +145 -0
- 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 +40 -14
- 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/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/cjs/{accelerometer-service.d.ts → bluetooth/services/accelerometer-service.d.ts} +2 -3
- package/build/cjs/{accelerometer-service.js → bluetooth/services/accelerometer-service.js} +17 -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} +24 -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/bluetooth/services/device-information-service.js +29 -0
- 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/bluetooth/services/event-service.d.ts +48 -0
- package/build/cjs/bluetooth/services/event-service.js +273 -0
- package/build/cjs/bluetooth/services/event-service.js.map +1 -0
- package/build/cjs/bluetooth/services/io-pin-service.d.ts +65 -0
- package/build/cjs/bluetooth/services/io-pin-service.js +173 -0
- package/build/cjs/bluetooth/services/io-pin-service.js.map +1 -0
- package/build/{esm → cjs/bluetooth/services}/led-service.d.ts +2 -3
- package/build/cjs/{led-service.js → bluetooth/services/led-service.js} +10 -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} +19 -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/bluetooth/services/temperature-service.d.ts +14 -0
- package/build/cjs/bluetooth/services/temperature-service.js +80 -0
- package/build/cjs/bluetooth/services/temperature-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} +21 -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 +191 -101
- package/build/cjs/device.js +47 -110
- package/build/cjs/device.js.map +1 -1
- package/build/cjs/events.d.ts +8 -108
- package/build/cjs/events.js +27 -88
- package/build/cjs/events.js.map +1 -1
- 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 +8 -16
- package/build/cjs/index.js +9 -28
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/logging.js.map +1 -1
- package/build/cjs/microbit-events.d.ts +67 -0
- package/build/cjs/microbit-events.js +55 -0
- package/build/cjs/microbit-events.js.map +1 -0
- package/build/cjs/radio-bridge/connection.d.ts +52 -0
- package/build/cjs/{usb-radio-bridge.js → radio-bridge/connection.js} +84 -96
- 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 +92 -15
- package/build/cjs/service-events.js +6 -36
- package/build/cjs/service-events.js.map +1 -1
- package/build/{esm/hex-flash-data-source.d.ts → cjs/universal-hex/flash-data-source.d.ts} +1 -1
- package/build/cjs/{hex-flash-data-source.js → universal-hex/flash-data-source.js} +6 -3
- 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/{esm → cjs/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/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/connection.d.ts +96 -0
- package/build/cjs/{usb.js → usb/connection.js} +257 -173
- package/build/cjs/usb/connection.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/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/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/{esm/usb-partial-flashing.d.ts → cjs/usb/partial-flashing.d.ts} +37 -11
- package/build/cjs/{usb-partial-flashing.js → usb/partial-flashing.js} +170 -134
- package/build/cjs/usb/partial-flashing.js.map +1 -0
- package/build/cjs/usb/promise-queue.js.map +1 -0
- package/build/cjs/usb/serial-events.d.ts +16 -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.d.ts +3 -1
- package/build/esm/async-util.js +5 -1
- package/build/esm/async-util.js.map +1 -1
- package/build/esm/availability.js.map +1 -1
- package/build/esm/bluetooth/ble-error.d.ts +10 -0
- package/build/esm/bluetooth/ble-error.js +42 -0
- package/build/esm/bluetooth/ble-error.js.map +1 -0
- package/build/esm/bluetooth/connection.d.ts +378 -0
- package/build/esm/bluetooth/connection.js +593 -0
- package/build/esm/bluetooth/connection.js.map +1 -0
- package/build/esm/bluetooth/device-bond-state.d.ts +14 -0
- package/build/esm/bluetooth/device-bond-state.js +22 -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} +36 -21
- package/build/esm/{bluetooth-device-wrapper.js → bluetooth/device-wrapper.js} +172 -146
- package/build/esm/bluetooth/device-wrapper.js.map +1 -0
- package/build/{cjs → esm/bluetooth}/flashing/flashing-full.d.ts +2 -2
- package/build/esm/{flashing → bluetooth/flashing}/flashing-full.js +6 -5
- 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-partial.d.ts +10 -0
- package/build/esm/bluetooth/flashing/flashing-partial.js +142 -0
- 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 +40 -14
- 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/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/esm/{accelerometer-service.d.ts → bluetooth/services/accelerometer-service.d.ts} +2 -3
- package/build/esm/{accelerometer-service.js → bluetooth/services/accelerometer-service.js} +11 -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} +20 -10
- 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/bluetooth/services/device-information-service.js +25 -0
- 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/bluetooth/services/event-service.d.ts +48 -0
- package/build/esm/bluetooth/services/event-service.js +269 -0
- package/build/esm/bluetooth/services/event-service.js.map +1 -0
- package/build/esm/bluetooth/services/io-pin-service.d.ts +65 -0
- package/build/esm/bluetooth/services/io-pin-service.js +169 -0
- package/build/esm/bluetooth/services/io-pin-service.js.map +1 -0
- package/build/{cjs → esm/bluetooth/services}/led-service.d.ts +2 -3
- package/build/esm/{led-service.js → bluetooth/services/led-service.js} +4 -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} +11 -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/bluetooth/services/temperature-service.d.ts +14 -0
- package/build/esm/bluetooth/services/temperature-service.js +76 -0
- package/build/esm/bluetooth/services/temperature-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} +18 -6
- 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 +191 -101
- package/build/esm/device.js +45 -104
- package/build/esm/device.js.map +1 -1
- package/build/esm/events.d.ts +8 -108
- package/build/esm/events.js +26 -86
- package/build/esm/events.js.map +1 -1
- 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 +8 -16
- package/build/esm/index.js +7 -11
- package/build/esm/index.js.map +1 -1
- package/build/esm/logging.js.map +1 -1
- package/build/esm/microbit-events.d.ts +67 -0
- package/build/esm/microbit-events.js +52 -0
- package/build/esm/microbit-events.js.map +1 -0
- package/build/esm/radio-bridge/connection.d.ts +52 -0
- package/build/esm/{usb-radio-bridge.js → radio-bridge/connection.js} +84 -96
- 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 +92 -15
- package/build/esm/service-events.js +5 -34
- package/build/esm/service-events.js.map +1 -1
- package/build/{cjs/hex-flash-data-source.d.ts → esm/universal-hex/flash-data-source.d.ts} +1 -1
- package/build/esm/{hex-flash-data-source.js → universal-hex/flash-data-source.js} +6 -3
- 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/{cjs → esm/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/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/connection.d.ts +96 -0
- package/build/esm/{usb.js → usb/connection.js} +253 -168
- package/build/esm/usb/connection.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/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/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/{cjs/usb-partial-flashing.d.ts → esm/usb/partial-flashing.d.ts} +37 -11
- package/build/esm/{usb-partial-flashing.js → usb/partial-flashing.js} +169 -110
- package/build/esm/usb/partial-flashing.js.map +1 -0
- package/build/esm/usb/promise-queue.js.map +1 -0
- package/build/esm/usb/serial-events.d.ts +16 -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 +61 -14
- 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.d.ts +0 -112
- package/build/cjs/bluetooth.js +0 -457
- 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-information-service.js +0 -34
- 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.d.ts +0 -9
- package/build/cjs/flashing/flashing-partial.js +0 -98
- 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/setupTests.d.ts +0 -6
- package/build/cjs/setupTests.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.d.ts +0 -112
- package/build/esm/bluetooth.js +0 -427
- 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-information-service.js +0 -30
- 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.d.ts +0 -9
- package/build/esm/flashing/flashing-partial.js +0 -95
- 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/setupTests.d.ts +0 -6
- package/build/esm/setupTests.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/{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/{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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-id.js","sourceRoot":"","sources":["../../
|
|
1
|
+
{"version":3,"file":"board-id.js","sourceRoot":"","sources":["../../src/board-id.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH;;GAEG;AACH,MAAa,OAAO;IAIlB,YAA4B,EAAU;QAA1B;;;;mBAAgB,EAAE;WAAQ;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,oCAAoC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACnC,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC;IAClD,CAAC;IAED,IAAI;QACF,OAAO,CACL,IAAI,CAAC,EAAE,KAAK,MAAM;YAClB,IAAI,CAAC,EAAE,KAAK,MAAM;YAClB,IAAI,CAAC,EAAE,KAAK,MAAM;YAClB,IAAI,CAAC,EAAE,KAAK,MAAM,CACnB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,KAAa;QACxB,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,YAA0B;QAC1C,QAAQ,YAAY,EAAE,CAAC;YACrB,KAAK,IAAI;gBACP,OAAO,IAAI,CAAC,YAAY,CAAC;YAC3B,KAAK,IAAI;gBACP,OAAO,IAAI,CAAC,YAAY,CAAC;QAC7B,CAAC;IACH,CAAC;;AA5DH,0BA6DC;AA5DgB;;;;WAAe,IAAI,OAAO,CAAC,MAAM,CAAC;EAAtB,CAAuB;AACnC;;;;WAAe,IAAI,OAAO,CAAC,MAAM,CAAC;EAAtB,CAAuB"}
|
package/build/cjs/device.d.ts
CHANGED
|
@@ -3,99 +3,128 @@
|
|
|
3
3
|
*
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { TypedEventTarget, ValueIsEvent } from "./events.js";
|
|
7
6
|
/**
|
|
8
7
|
* Connection availability status returned by checkAvailability().
|
|
9
8
|
* Used for pre-flight UX decisions before attempting to connect.
|
|
10
9
|
*/
|
|
11
10
|
export type ConnectionAvailabilityStatus = "available" | "unsupported" | "disabled" | "permission-denied" | "location-disabled";
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* Error codes identifying specific failure modes.
|
|
14
13
|
*
|
|
15
|
-
*
|
|
14
|
+
* Each code represents a distinct category of failure that apps can
|
|
15
|
+
* match on to decide what message to show or what recovery to attempt.
|
|
16
|
+
* New codes may be added in future minor releases.
|
|
17
|
+
*
|
|
18
|
+
* Codes are annotated with **USB**, **BLE**, or **USB, BLE** to indicate
|
|
19
|
+
* which connection types can produce them. USB-only apps can ignore
|
|
20
|
+
* BLE-only codes.
|
|
16
21
|
*/
|
|
17
22
|
export type DeviceErrorCode =
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
"no-device-selected"
|
|
22
|
-
/**
|
|
23
|
-
* Device not found, perhaps because it doesn't have new enough firmware (for V1).
|
|
24
|
+
* **BLE.** The operation was cancelled via an `AbortSignal`
|
|
25
|
+
* supplied by the caller. No user-facing error is needed.
|
|
24
26
|
*/
|
|
25
|
-
|
|
27
|
+
"aborted"
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
29
|
+
* **USB, BLE.** The user dismissed the device-picker dialog without
|
|
30
|
+
* selecting a device. Typically no error message is needed — the user
|
|
31
|
+
* chose not to proceed.
|
|
28
32
|
*/
|
|
29
|
-
| "
|
|
33
|
+
| "no-device-selected"
|
|
30
34
|
/**
|
|
31
|
-
* The
|
|
35
|
+
* **USB, BLE.** The connection type is not supported on this platform
|
|
36
|
+
* or browser. Corresponds to {@link ConnectionAvailabilityStatus}
|
|
37
|
+
* `"unsupported"`.
|
|
32
38
|
*/
|
|
33
|
-
| "
|
|
39
|
+
| "unsupported"
|
|
34
40
|
/**
|
|
35
|
-
*
|
|
41
|
+
* **BLE.** Bluetooth is turned off at the OS level. Prompt the user
|
|
42
|
+
* to enable it in system settings. Corresponds to
|
|
43
|
+
* {@link ConnectionAvailabilityStatus} `"disabled"`.
|
|
36
44
|
*/
|
|
37
|
-
| "
|
|
45
|
+
| "disabled"
|
|
38
46
|
/**
|
|
39
|
-
*
|
|
47
|
+
* **BLE.** The app does not have the required Bluetooth permissions
|
|
48
|
+
* (iOS/Android). Prompt the user to grant permission in system
|
|
49
|
+
* settings. Corresponds to {@link ConnectionAvailabilityStatus}
|
|
50
|
+
* `"permission-denied"`.
|
|
40
51
|
*/
|
|
41
|
-
| "
|
|
52
|
+
| "permission-denied"
|
|
42
53
|
/**
|
|
43
|
-
*
|
|
54
|
+
* **BLE.** Location services are disabled. Required on Android
|
|
55
|
+
* versions before 12 for Bluetooth scanning. Prompt the user to
|
|
56
|
+
* enable location in system settings. Corresponds to
|
|
57
|
+
* {@link ConnectionAvailabilityStatus} `"location-disabled"`.
|
|
44
58
|
*/
|
|
45
|
-
| "
|
|
59
|
+
| "location-disabled"
|
|
46
60
|
/**
|
|
47
|
-
*
|
|
61
|
+
* **USB, BLE.** A method was called that requires an active
|
|
62
|
+
* connection, but no connection is currently open. Call
|
|
63
|
+
* {@link DeviceConnection.connect} first.
|
|
48
64
|
*/
|
|
49
|
-
| "
|
|
65
|
+
| "not-connected"
|
|
50
66
|
/**
|
|
51
|
-
*
|
|
67
|
+
* **USB.** The USB interface could not be claimed, usually because
|
|
68
|
+
* another browser tab or application already has an open connection
|
|
69
|
+
* to the device.
|
|
52
70
|
*/
|
|
53
|
-
| "
|
|
71
|
+
| "device-in-use"
|
|
54
72
|
/**
|
|
55
|
-
*
|
|
73
|
+
* **USB, BLE.** The device disconnected during an operation.
|
|
74
|
+
* The physical USB or Bluetooth connection was lost.
|
|
56
75
|
*/
|
|
57
|
-
| "
|
|
76
|
+
| "device-disconnected"
|
|
58
77
|
/**
|
|
59
|
-
*
|
|
78
|
+
* **USB, BLE.** A communication timeout — the device did not respond
|
|
79
|
+
* within the expected time. This may indicate the device is busy,
|
|
80
|
+
* hung, or that the connection is degraded.
|
|
60
81
|
*/
|
|
61
|
-
| "
|
|
82
|
+
| "timeout"
|
|
62
83
|
/**
|
|
63
|
-
*
|
|
84
|
+
* **USB, BLE.** A communication failure that does not match any more
|
|
85
|
+
* specific code. Typical handling: prompt the user to physically
|
|
86
|
+
* disconnect and reconnect the device, then retry.
|
|
64
87
|
*/
|
|
65
|
-
| "
|
|
88
|
+
| "connection-error"
|
|
66
89
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
90
|
+
* **USB.** The USB device was found but lacks the expected CMSIS-DAP
|
|
91
|
+
* interface. On micro:bit V1 this indicates the DAPLink firmware is
|
|
92
|
+
* too old and needs updating.
|
|
69
93
|
*/
|
|
70
|
-
| "
|
|
94
|
+
| "firmware-update-required"
|
|
71
95
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
96
|
+
* **BLE.** The micro:bit's Bluetooth pairing/bonding information has
|
|
97
|
+
* been lost (e.g. after a firmware reflash). The user needs to
|
|
98
|
+
* re-pair the device. Currently only detected on iOS.
|
|
74
99
|
*/
|
|
75
|
-
| "
|
|
100
|
+
| "pairing-information-lost";
|
|
76
101
|
/**
|
|
77
|
-
*
|
|
78
|
-
* Aligns with ConnectionAvailabilityStatus "permission-denied".
|
|
102
|
+
* Stages reported by the progress callback during connection and flashing.
|
|
79
103
|
*/
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Connecting
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
export declare const ProgressStage: {
|
|
105
|
+
/** Checking permissions and availability before connecting. */
|
|
106
|
+
readonly Initializing: "Initializing";
|
|
107
|
+
/** Finding device. */
|
|
108
|
+
readonly FindingDevice: "FindingDevice";
|
|
109
|
+
/** Checking that a bond is established. Only applicable on Native platforms. */
|
|
110
|
+
readonly CheckingBond: "CheckingBond";
|
|
111
|
+
/** Resetting device in preparation for flashing. Only applicable on Native platforms. */
|
|
112
|
+
readonly ResettingDevice: "ResettingDevice";
|
|
113
|
+
/** Connecting for flashing. */
|
|
114
|
+
readonly Connecting: "Connecting";
|
|
115
|
+
/** Partial flashing. */
|
|
116
|
+
readonly PartialFlashing: "PartialFlashing";
|
|
117
|
+
/** Full flashing. */
|
|
118
|
+
readonly FullFlashing: "FullFlashing";
|
|
119
|
+
};
|
|
120
|
+
export type ProgressStage = (typeof ProgressStage)[keyof typeof ProgressStage];
|
|
93
121
|
/**
|
|
94
122
|
* Progress callback for tracking operation stages (connection and flashing).
|
|
95
123
|
*
|
|
96
124
|
* @param stage - The current stage of the operation
|
|
97
125
|
* @param progress - Optional progress value (0-1) for PartialFlashing and FullFlashing stages.
|
|
98
|
-
* Initializing, FindingDevice,
|
|
126
|
+
* Initializing, FindingDevice, CheckingBond (only for native platforms),
|
|
127
|
+
* ResettingDevice (only for native platforms), and Connecting stages are called once
|
|
99
128
|
* without progress values to indicate stage entry.
|
|
100
129
|
*
|
|
101
130
|
* @example
|
|
@@ -119,15 +148,21 @@ export type ProgressCallback = (stage: ProgressStage, progress?: number) => void
|
|
|
119
148
|
*/
|
|
120
149
|
export declare class DeviceError extends Error {
|
|
121
150
|
code: DeviceErrorCode;
|
|
122
|
-
constructor({ code, message }: {
|
|
151
|
+
constructor({ code, message, cause, }: {
|
|
123
152
|
code: DeviceErrorCode;
|
|
124
153
|
message?: string;
|
|
154
|
+
cause?: unknown;
|
|
125
155
|
});
|
|
126
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Asserts that a connection is active, throwing a {@link DeviceError}
|
|
159
|
+
* with code `"not-connected"` if it is not.
|
|
160
|
+
*/
|
|
161
|
+
export declare function assertConnected<T>(connection: T | undefined): asserts connection is T;
|
|
127
162
|
/**
|
|
128
163
|
* Tracks connection status.
|
|
129
164
|
*/
|
|
130
|
-
export declare
|
|
165
|
+
export declare const ConnectionStatus: {
|
|
131
166
|
/**
|
|
132
167
|
* No device available.
|
|
133
168
|
*
|
|
@@ -137,36 +172,57 @@ export declare enum ConnectionStatus {
|
|
|
137
172
|
* Use checkAvailability() to determine whether the connection type is
|
|
138
173
|
* supported before attempting to connect.
|
|
139
174
|
*/
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
-
*/
|
|
148
|
-
CONNECTED = "CONNECTED",
|
|
149
|
-
/**
|
|
150
|
-
* Connecting.
|
|
151
|
-
*/
|
|
152
|
-
CONNECTING = "CONNECTING",
|
|
153
|
-
/**
|
|
154
|
-
* Reconnecting. When there is unexpected disruption in the connection,
|
|
155
|
-
* a reconnection is attempted.
|
|
156
|
-
*/
|
|
157
|
-
RECONNECTING = "RECONNECTING",
|
|
175
|
+
readonly NoAuthorizedDevice: "NoAuthorizedDevice";
|
|
176
|
+
/** Authorized device available but we haven't connected to it. */
|
|
177
|
+
readonly Disconnected: "Disconnected";
|
|
178
|
+
/** Connected. */
|
|
179
|
+
readonly Connected: "Connected";
|
|
180
|
+
/** Connecting. */
|
|
181
|
+
readonly Connecting: "Connecting";
|
|
158
182
|
/**
|
|
159
183
|
* Paused due to tab visibility. The connection was temporarily suspended
|
|
160
184
|
* because the browser tab became hidden. Reconnection will be attempted
|
|
161
185
|
* automatically when the tab becomes visible again.
|
|
162
186
|
*/
|
|
163
|
-
|
|
164
|
-
}
|
|
187
|
+
readonly Paused: "Paused";
|
|
188
|
+
};
|
|
189
|
+
export type ConnectionStatus = (typeof ConnectionStatus)[keyof typeof ConnectionStatus];
|
|
190
|
+
/**
|
|
191
|
+
* Controls bonding behaviour and post-bond device mode on native platforms.
|
|
192
|
+
*
|
|
193
|
+
* - `"pairing"` — Bond if needed, then reset the device into pairing mode.
|
|
194
|
+
* Use when you intend to flash immediately after connecting.
|
|
195
|
+
* - `"application"` — Bond if needed, then reset the device into application
|
|
196
|
+
* mode. Use when you want to interact with BLE services (sensors, UART, …)
|
|
197
|
+
* on firmware that has BLE enabled in application mode.
|
|
198
|
+
* - `"none"` — Skip bonding entirely and just connect. Use for open-link
|
|
199
|
+
* firmware where no bonding is required.
|
|
200
|
+
*
|
|
201
|
+
* Ignored on web platforms where the browser manages pairing transparently.
|
|
202
|
+
*/
|
|
203
|
+
export type BondMode = "pairing" | "application" | "none";
|
|
165
204
|
export interface ConnectOptions {
|
|
166
205
|
/**
|
|
167
206
|
* Optional progress callback for tracking connection stages.
|
|
168
207
|
*/
|
|
169
208
|
progress?: ProgressCallback;
|
|
209
|
+
/**
|
|
210
|
+
* Optional AbortSignal to abort the connection attempt.
|
|
211
|
+
* When aborted, the connect promise will reject with a DeviceError
|
|
212
|
+
* with code "aborted".
|
|
213
|
+
*
|
|
214
|
+
* Note: Currently only aborts during the FindingDevice stage on native
|
|
215
|
+
* platforms. Web platform device selection (browser picker) cannot be
|
|
216
|
+
* aborted programmatically.
|
|
217
|
+
*/
|
|
218
|
+
signal?: AbortSignal;
|
|
219
|
+
/**
|
|
220
|
+
* Controls bonding and post-bond device mode on native platforms.
|
|
221
|
+
* Ignored on web. Default: `"pairing"`.
|
|
222
|
+
*
|
|
223
|
+
* @see {@link BondMode}
|
|
224
|
+
*/
|
|
225
|
+
bondMode?: BondMode;
|
|
170
226
|
}
|
|
171
227
|
export interface FlashOptions {
|
|
172
228
|
/**
|
|
@@ -186,34 +242,48 @@ export interface FlashOptions {
|
|
|
186
242
|
* Smallest possible progress increment to limit callback rate.
|
|
187
243
|
*/
|
|
188
244
|
minimumProgressIncrement?: number;
|
|
245
|
+
/**
|
|
246
|
+
* Optional AbortSignal to abort the flash operation.
|
|
247
|
+
* When aborted, the flash promise will reject with a DeviceError
|
|
248
|
+
* with code "aborted".
|
|
249
|
+
*
|
|
250
|
+
* Note: Currently only aborts during the FindingDevice stage on native
|
|
251
|
+
* platforms. Once a device is found and flashing begins, the operation
|
|
252
|
+
* cannot be aborted.
|
|
253
|
+
*/
|
|
254
|
+
signal?: AbortSignal;
|
|
189
255
|
}
|
|
190
256
|
export declare class FlashDataError extends Error {
|
|
191
257
|
}
|
|
192
258
|
export type FlashDataSource = (boardVersion: BoardVersion) => Promise<string | Uint8Array>;
|
|
193
259
|
export type BoardVersion = "V1" | "V2";
|
|
194
|
-
export
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
constructor(status: ConnectionStatus, previousStatus: ConnectionStatus);
|
|
198
|
-
}
|
|
199
|
-
export declare class BeforeRequestDevice extends Event {
|
|
200
|
-
constructor();
|
|
201
|
-
}
|
|
202
|
-
export declare class AfterRequestDevice extends Event {
|
|
203
|
-
constructor();
|
|
260
|
+
export interface ConnectionStatusChange {
|
|
261
|
+
status: ConnectionStatus;
|
|
262
|
+
previousStatus: ConnectionStatus;
|
|
204
263
|
}
|
|
205
|
-
export
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
constructor(errorMessage: string, error?: unknown | undefined);
|
|
264
|
+
export interface BackgroundErrorData {
|
|
265
|
+
error: DeviceError;
|
|
266
|
+
event?: string;
|
|
209
267
|
}
|
|
210
|
-
export
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
268
|
+
export interface DeviceConnectionEventMap {
|
|
269
|
+
status: ConnectionStatusChange;
|
|
270
|
+
backgrounderror: BackgroundErrorData;
|
|
271
|
+
beforerequestdevice: void;
|
|
272
|
+
afterrequestdevice: void;
|
|
273
|
+
flash: void;
|
|
215
274
|
}
|
|
216
|
-
export interface DeviceConnection
|
|
275
|
+
export interface DeviceConnection {
|
|
276
|
+
addEventListener(type: "status", listener: (data: ConnectionStatusChange) => void): void;
|
|
277
|
+
addEventListener(type: "backgrounderror", listener: (data: BackgroundErrorData) => void): void;
|
|
278
|
+
addEventListener(type: "beforerequestdevice", listener: () => void): void;
|
|
279
|
+
addEventListener(type: "afterrequestdevice", listener: () => void): void;
|
|
280
|
+
addEventListener(type: "flash", listener: () => void): void;
|
|
281
|
+
removeEventListener(type: "status", listener: (data: ConnectionStatusChange) => void): void;
|
|
282
|
+
removeEventListener(type: "backgrounderror", listener: (data: BackgroundErrorData) => void): void;
|
|
283
|
+
removeEventListener(type: "beforerequestdevice", listener: () => void): void;
|
|
284
|
+
removeEventListener(type: "afterrequestdevice", listener: () => void): void;
|
|
285
|
+
removeEventListener(type: "flash", listener: () => void): void;
|
|
286
|
+
readonly type: string;
|
|
217
287
|
status: ConnectionStatus;
|
|
218
288
|
/**
|
|
219
289
|
* Initializes the device.
|
|
@@ -235,29 +305,49 @@ export interface DeviceConnection<M extends ValueIsEvent<M>> extends TypedEventT
|
|
|
235
305
|
/**
|
|
236
306
|
* Connects to a currently paired device or requests pairing.
|
|
237
307
|
*
|
|
238
|
-
* @param options Optional connection options including progress callback.
|
|
308
|
+
* @param options Optional connection options including progress callback and abort signal.
|
|
239
309
|
* @throws {DeviceError} On connection failure. The error.code property indicates the failure type.
|
|
240
310
|
*/
|
|
241
311
|
connect(options?: ConnectOptions): Promise<void>;
|
|
242
312
|
/**
|
|
243
313
|
* Get the board version.
|
|
244
314
|
*
|
|
245
|
-
*
|
|
315
|
+
* Cached after the first successful connection until {@link clearDevice}
|
|
316
|
+
* is called, so remains available after disconnection.
|
|
317
|
+
*
|
|
318
|
+
* @returns the board version.
|
|
319
|
+
* @throws {DeviceError} with code `not-connected` if no device has been connected.
|
|
246
320
|
*/
|
|
247
|
-
getBoardVersion(): BoardVersion
|
|
321
|
+
getBoardVersion(): BoardVersion;
|
|
248
322
|
/**
|
|
249
323
|
* Disconnect from the device.
|
|
250
324
|
*/
|
|
251
325
|
disconnect(): Promise<void>;
|
|
252
326
|
/**
|
|
253
|
-
*
|
|
327
|
+
* Flash the micro:bit.
|
|
328
|
+
*
|
|
329
|
+
* Not all connection types support flashing. For example, radio bridge
|
|
330
|
+
* connections do not support flashing, and Bluetooth connections only
|
|
331
|
+
* support flashing on native platforms (not Web).
|
|
332
|
+
*
|
|
333
|
+
* Post-flash connection state differs by transport:
|
|
334
|
+
*
|
|
335
|
+
* - **USB**: The connection remains in {@link ConnectionStatus.Connected} state.
|
|
336
|
+
* USB connects to the micro:bit's interface chip (running DAPLink firmware),
|
|
337
|
+
* which is not affected by flashing the application processor, so the
|
|
338
|
+
* connection persists and serial communication is automatically reinitialised.
|
|
254
339
|
*
|
|
255
|
-
*
|
|
340
|
+
* - **Bluetooth**: The connection is always left in {@link ConnectionStatus.Disconnected}
|
|
341
|
+
* state. Bluetooth connects to the application processor directly, which
|
|
342
|
+
* reboots after flashing, so the connection is necessarily lost. Callers
|
|
343
|
+
* must call {@link connect} again after flashing.
|
|
256
344
|
*
|
|
257
|
-
* @param
|
|
258
|
-
* @
|
|
345
|
+
* @param dataSource The data to use.
|
|
346
|
+
* @param options Flash options and progress callback.
|
|
347
|
+
* @throws {DeviceError} On flash failure. The error.code property indicates the failure type.
|
|
348
|
+
* @throws {FlashDataError} If data preparation fails.
|
|
259
349
|
*/
|
|
260
|
-
|
|
350
|
+
flash?(dataSource: FlashDataSource, options: FlashOptions): Promise<void>;
|
|
261
351
|
/**
|
|
262
352
|
* Clear device to enable chooseDevice.
|
|
263
353
|
*/
|
package/build/cjs/device.js
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* (c) 2021, Micro:bit Educational Foundation and contributors
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: MIT
|
|
6
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
exports.FlashDataError = exports.ConnectionStatus = exports.DeviceError = exports.ProgressStage = void 0;
|
|
9
|
+
exports.assertConnected = assertConnected;
|
|
10
|
+
/**
|
|
11
|
+
* Stages reported by the progress callback during connection and flashing.
|
|
12
|
+
*/
|
|
13
|
+
exports.ProgressStage = {
|
|
14
|
+
/** Checking permissions and availability before connecting. */
|
|
15
|
+
Initializing: "Initializing",
|
|
16
|
+
/** Finding device. */
|
|
17
|
+
FindingDevice: "FindingDevice",
|
|
18
|
+
/** Checking that a bond is established. Only applicable on Native platforms. */
|
|
19
|
+
CheckingBond: "CheckingBond",
|
|
20
|
+
/** Resetting device in preparation for flashing. Only applicable on Native platforms. */
|
|
21
|
+
ResettingDevice: "ResettingDevice",
|
|
22
|
+
/** Connecting for flashing. */
|
|
23
|
+
Connecting: "Connecting",
|
|
24
|
+
/** Partial flashing. */
|
|
25
|
+
PartialFlashing: "PartialFlashing",
|
|
26
|
+
/** Full flashing. */
|
|
27
|
+
FullFlashing: "FullFlashing",
|
|
28
|
+
};
|
|
12
29
|
/**
|
|
13
30
|
* Error type used for all interactions with this module.
|
|
14
31
|
*
|
|
@@ -19,8 +36,8 @@ var ProgressStage;
|
|
|
19
36
|
* English.
|
|
20
37
|
*/
|
|
21
38
|
class DeviceError extends Error {
|
|
22
|
-
constructor({ code, message }) {
|
|
23
|
-
super(message);
|
|
39
|
+
constructor({ code, message, cause, }) {
|
|
40
|
+
super(message, { cause });
|
|
24
41
|
Object.defineProperty(this, "code", {
|
|
25
42
|
enumerable: true,
|
|
26
43
|
configurable: true,
|
|
@@ -31,11 +48,19 @@ class DeviceError extends Error {
|
|
|
31
48
|
}
|
|
32
49
|
}
|
|
33
50
|
exports.DeviceError = DeviceError;
|
|
51
|
+
/**
|
|
52
|
+
* Asserts that a connection is active, throwing a {@link DeviceError}
|
|
53
|
+
* with code `"not-connected"` if it is not.
|
|
54
|
+
*/
|
|
55
|
+
function assertConnected(connection) {
|
|
56
|
+
if (!connection) {
|
|
57
|
+
throw new DeviceError({ code: "not-connected", message: "Not connected" });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
34
60
|
/**
|
|
35
61
|
* Tracks connection status.
|
|
36
62
|
*/
|
|
37
|
-
|
|
38
|
-
(function (ConnectionStatus) {
|
|
63
|
+
exports.ConnectionStatus = {
|
|
39
64
|
/**
|
|
40
65
|
* No device available.
|
|
41
66
|
*
|
|
@@ -45,109 +70,21 @@ var ConnectionStatus;
|
|
|
45
70
|
* Use checkAvailability() to determine whether the connection type is
|
|
46
71
|
* supported before attempting to connect.
|
|
47
72
|
*/
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
*/
|
|
56
|
-
ConnectionStatus["CONNECTED"] = "CONNECTED";
|
|
57
|
-
/**
|
|
58
|
-
* Connecting.
|
|
59
|
-
*/
|
|
60
|
-
ConnectionStatus["CONNECTING"] = "CONNECTING";
|
|
61
|
-
/**
|
|
62
|
-
* Reconnecting. When there is unexpected disruption in the connection,
|
|
63
|
-
* a reconnection is attempted.
|
|
64
|
-
*/
|
|
65
|
-
ConnectionStatus["RECONNECTING"] = "RECONNECTING";
|
|
73
|
+
NoAuthorizedDevice: "NoAuthorizedDevice",
|
|
74
|
+
/** Authorized device available but we haven't connected to it. */
|
|
75
|
+
Disconnected: "Disconnected",
|
|
76
|
+
/** Connected. */
|
|
77
|
+
Connected: "Connected",
|
|
78
|
+
/** Connecting. */
|
|
79
|
+
Connecting: "Connecting",
|
|
66
80
|
/**
|
|
67
81
|
* Paused due to tab visibility. The connection was temporarily suspended
|
|
68
82
|
* because the browser tab became hidden. Reconnection will be attempted
|
|
69
83
|
* automatically when the tab becomes visible again.
|
|
70
84
|
*/
|
|
71
|
-
|
|
72
|
-
}
|
|
85
|
+
Paused: "Paused",
|
|
86
|
+
};
|
|
73
87
|
class FlashDataError extends Error {
|
|
74
88
|
}
|
|
75
89
|
exports.FlashDataError = FlashDataError;
|
|
76
|
-
class ConnectionStatusEvent extends Event {
|
|
77
|
-
constructor(status, previousStatus) {
|
|
78
|
-
super("status");
|
|
79
|
-
Object.defineProperty(this, "status", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
configurable: true,
|
|
82
|
-
writable: true,
|
|
83
|
-
value: status
|
|
84
|
-
});
|
|
85
|
-
Object.defineProperty(this, "previousStatus", {
|
|
86
|
-
enumerable: true,
|
|
87
|
-
configurable: true,
|
|
88
|
-
writable: true,
|
|
89
|
-
value: previousStatus
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.ConnectionStatusEvent = ConnectionStatusEvent;
|
|
94
|
-
class BeforeRequestDevice extends Event {
|
|
95
|
-
constructor() {
|
|
96
|
-
super("beforerequestdevice");
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.BeforeRequestDevice = BeforeRequestDevice;
|
|
100
|
-
class AfterRequestDevice extends Event {
|
|
101
|
-
constructor() {
|
|
102
|
-
super("afterrequestdevice");
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
exports.AfterRequestDevice = AfterRequestDevice;
|
|
106
|
-
class BackgroundErrorEvent extends Event {
|
|
107
|
-
constructor(errorMessage, error) {
|
|
108
|
-
super("backgrounderror");
|
|
109
|
-
Object.defineProperty(this, "errorMessage", {
|
|
110
|
-
enumerable: true,
|
|
111
|
-
configurable: true,
|
|
112
|
-
writable: true,
|
|
113
|
-
value: errorMessage
|
|
114
|
-
});
|
|
115
|
-
Object.defineProperty(this, "error", {
|
|
116
|
-
enumerable: true,
|
|
117
|
-
configurable: true,
|
|
118
|
-
writable: true,
|
|
119
|
-
value: error
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.BackgroundErrorEvent = BackgroundErrorEvent;
|
|
124
|
-
class DeviceConnectionEventMap {
|
|
125
|
-
constructor() {
|
|
126
|
-
Object.defineProperty(this, "status", {
|
|
127
|
-
enumerable: true,
|
|
128
|
-
configurable: true,
|
|
129
|
-
writable: true,
|
|
130
|
-
value: void 0
|
|
131
|
-
});
|
|
132
|
-
Object.defineProperty(this, "backgrounderror", {
|
|
133
|
-
enumerable: true,
|
|
134
|
-
configurable: true,
|
|
135
|
-
writable: true,
|
|
136
|
-
value: void 0
|
|
137
|
-
});
|
|
138
|
-
Object.defineProperty(this, "beforerequestdevice", {
|
|
139
|
-
enumerable: true,
|
|
140
|
-
configurable: true,
|
|
141
|
-
writable: true,
|
|
142
|
-
value: void 0
|
|
143
|
-
});
|
|
144
|
-
Object.defineProperty(this, "afterrequestdevice", {
|
|
145
|
-
enumerable: true,
|
|
146
|
-
configurable: true,
|
|
147
|
-
writable: true,
|
|
148
|
-
value: void 0
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
exports.DeviceConnectionEventMap = DeviceConnectionEventMap;
|
|
153
90
|
//# sourceMappingURL=device.js.map
|
package/build/cjs/device.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../
|
|
1
|
+
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/device.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAgMH,0CAMC;AAhFD;;GAEG;AACU,QAAA,aAAa,GAAG;IAC3B,+DAA+D;IAC/D,YAAY,EAAE,cAAc;IAC5B,sBAAsB;IACtB,aAAa,EAAE,eAAe;IAC9B,gFAAgF;IAChF,YAAY,EAAE,cAAc;IAC5B,yFAAyF;IACzF,eAAe,EAAE,iBAAiB;IAClC,+BAA+B;IAC/B,UAAU,EAAE,YAAY;IACxB,wBAAwB;IACxB,eAAe,EAAE,iBAAiB;IAClC,qBAAqB;IACrB,YAAY,EAAE,cAAc;CACpB,CAAC;AA2BX;;;;;;;;GAQG;AACH,MAAa,WAAY,SAAQ,KAAK;IAEpC,YAAY,EACV,IAAI,EACJ,OAAO,EACP,KAAK,GAKN;QACC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAV5B;;;;;WAAsB;QAWpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAdD,kCAcC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAC7B,UAAyB;IAEzB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,WAAW,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED;;GAEG;AACU,QAAA,gBAAgB,GAAG;IAC9B;;;;;;;;OAQG;IACH,kBAAkB,EAAE,oBAAoB;IACxC,kEAAkE;IAClE,YAAY,EAAE,cAAc;IAC5B,iBAAiB;IACjB,SAAS,EAAE,WAAW;IACtB,kBAAkB;IAClB,UAAU,EAAE,YAAY;IACxB;;;;OAIG;IACH,MAAM,EAAE,QAAQ;CACR,CAAC;AA0EX,MAAa,cAAe,SAAQ,KAAK;CAAG;AAA5C,wCAA4C"}
|