-
Notifications
You must be signed in to change notification settings - Fork 2
Apps Bluetooth support & 1.0 breaking changes #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
101 commits
Select commit
Hold shift + click to select a range
fa96588
Apps branch for experimentation
microbit-matt-hillsdon 163073e
Fix packaging issues
microbit-matt-hillsdon 37e521e
More packaging fixes
microbit-matt-hillsdon a842639
Fix web scenarios
microbit-matt-hillsdon ce98672
Initializing is a pre-connect not pre-flash stage
microbit-matt-hillsdon af4bdd8
Breaking: Model the disconnect for hidden tabs explicitly (#72)
microbit-matt-hillsdon e9cb85c
Rename for clarity
microbit-matt-hillsdon d366e59
Fix pause state during flash issue
microbit-matt-hillsdon 90a9e79
Breaking: Move to a dynamic model of permission checks (#73)
microbit-matt-hillsdon 55e26b8
Send previous status in connection events (#74)
microbit-matt-hillsdon 65549d9
Attempt connection multiple times, retrieve latest services before st…
microbit-grace 2ada7cd
Discover services right after connecting (#78)
microbit-grace c375a2c
Wait for disconnect after partial flashing success (#80)
microbit-matt-hillsdon 41865e2
Fix name filter issue (#82)
microbit-matt-hillsdon cc516fb
Add ability to abort connect, new error type, and progress stages (#84)
microbit-matt-hillsdon 802344e
Remove auto reconnect, `ConnectionStatus.Reconnecting`, and discardin…
microbit-grace 742b8dc
Optimise BLE partial flashing and support V1 thin hex files (#86)
microbit-matt-hillsdon 39e4a26
Add `deviceBondState` option to Bluetooth connection and remove specu…
microbit-grace 8c8751f
Move demo to a separate app from the package (#88)
microbit-matt-hillsdon 42bd15a
Add capacitor demo app to monorepo and build all workspaces in CI (#89)
microbit-matt-hillsdon 0dc9655
Wait for post partial flash disconnect in connect (#91)
microbit-grace 6661729
Skip partial flash when application hash already matches device (#92)
microbit-matt-hillsdon f7834dd
Move Capacitor packages to peer dependencies (#94)
microbit-matt-hillsdon 92c9d63
Current hex files
microbit-matt-hillsdon a5ffd18
Add AGENTS/CLAUDE.md
microbit-matt-hillsdon 9ae27f6
Fix iOS DFU with open-link security firmware (#99)
microbit-matt-hillsdon 144524b
Fix flashing over a program without partial flashing service (#98)
microbit-grace 271d01f
Fall back to DFU characteristics for iOS pairing trigger (#100)
microbit-matt-hillsdon 1bb1064
Skip partial flash if we get zero hash value (#101)
microbit-matt-hillsdon dec7b81
Sync after build for capacitor demo
microbit-matt-hillsdon ab9ca11
Update known issues; updated Podfile.lock
microbit-matt-hillsdon 4efefdf
Allow cap sync to fail in CI.
microbit-matt-hillsdon 170d820
Reinstate "uBit" BLE name prefix support (#95)
microbit-matt-hillsdon f81a087
Add missing V2 init packet hash (#93)
microbit-matt-hillsdon 74091d8
Breaking: reorganize for better tree shaking (#96)
microbit-matt-hillsdon fc07daa
Make the pause behavior optional (#102)
microbit-matt-hillsdon eb212cc
Attempt a workaround for the bad response issue (#77)
microbit-matt-hillsdon c56c4ae
Remove serial event state that's available from super class (#56)
microbit-matt-hillsdon d8d62cf
Use DAPLink vendor command for serial (#103)
microbit-matt-hillsdon 1dcfac9
Breaking: Switch to throwing DeviceError when not connected
microbit-matt-hillsdon 62d98e7
Breaking: Replace EventTarget with custom typed event system
microbit-matt-hillsdon 8289c97
Move flash event to DeviceConnectionEventMap and dispatch from Bluetooth
microbit-matt-hillsdon 4f5514e
Document post-flash connection state differences
microbit-matt-hillsdon 985d343
Breaking: Move serialWrite from DeviceConnection to USB-specific inte…
microbit-matt-hillsdon 52a9458
Merge pull request #104 from microbit-foundation/throw-not-connected
microbit-matt-hillsdon df2a97c
Document radio bridge as experimental / limited
microbit-matt-hillsdon 775a3f2
Merge pull request #105 from microbit-foundation/drop-event-target
microbit-matt-hillsdon 0ec8881
Merge pull request #106 from microbit-foundation/document-post-connec…
microbit-matt-hillsdon cb5df72
Merge pull request #107 from microbit-foundation/no-serial-for-bluetooth
microbit-matt-hillsdon dca3fd7
Merge pull request #108 from microbit-foundation/tidy-radio-bridge
microbit-matt-hillsdon 9829707
Inline CMSIS-DAP protocol handling, removing dapjs dependency
microbit-matt-hillsdon 94b76d8
Improve serial data handling around flash
microbit-matt-hillsdon 3596992
Fix partial flash retry by reinitializing SWD.
microbit-matt-hillsdon 8c4ffa9
Error handling and logging review
microbit-matt-hillsdon dd0007d
Reorg the USB code including a layer split for the cmsis-dap code
microbit-matt-hillsdon c53d8c2
Deduplicate ABORT_ALL constant between cmsis-dap and arm-debug
microbit-matt-hillsdon a722189
Simplify device wrapper and clarify naming across USB and Bluetooth
microbit-matt-hillsdon 4cf0934
Add test coverage extracting interfaces to support this
microbit-matt-hillsdon 9c48307
Simplify the error handler
microbit-matt-hillsdon d239473
Saturate DAPLink CDC buffers before flash to prevent serial data loss
microbit-matt-hillsdon bcc6a86
Add a human-in-the-loop hardware test runner
microbit-matt-hillsdon 55c1844
Merge pull request #110 from microbit-foundation/own-dap
microbit-matt-hillsdon e6efec5
Move DAPLink vendor commands and FICR constants to where they're used…
microbit-matt-hillsdon 7eab3cc
Breaking: Reorganize into directory-based entrypoints
microbit-matt-hillsdon 676d921
Rename DAPOperation to match the rest
microbit-matt-hillsdon cffcb03
Remove ChromeOS 105 WebUSB workaround
microbit-matt-hillsdon 709e9eb
Breaking: Replace enums with as-const objects and union types
microbit-matt-hillsdon e037c2b
Breaking: Clean up public API surface
microbit-matt-hillsdon dbd14c2
Update README for recent API changes
microbit-matt-hillsdon 129e9d9
Simplify code example
microbit-matt-hillsdon edc7274
Suppress serialreset when pausing USB connection on tab switch
microbit-matt-hillsdon 64b165f
Fix UICR not updated during WebUSB partial flashing (#113)
microbit-matt-hillsdon 0f8637b
Don't trigger knock-on errors in the tests
microbit-matt-hillsdon ab8c2b3
Merge branch 'apps' of github.com:microbit-foundation/microbit-connec…
microbit-matt-hillsdon e1d71c3
Add basic SSL so I can test cross platform
microbit-matt-hillsdon 392686a
Breaking: rationalise DeviceErrorCode values and error handling (#114)
microbit-matt-hillsdon fcfded5
Merge the demo apps; rethink listener types
microbit-matt-hillsdon 892d0de
Fix/test radio bridge
microbit-matt-hillsdon 32819fc
Improve pain points in the demo: LED types, type narrowing
microbit-matt-hillsdon 45166c6
Fix up references to old demo name
microbit-matt-hillsdon b61ae74
Audit fix
microbit-matt-hillsdon 1bbab0b
Align radio bridge error handling
microbit-matt-hillsdon c982f7d
Renames for clarity
microbit-matt-hillsdon 69d7ce7
Missing app files
microbit-matt-hillsdon 281889f
Remove team info from demo
microbit-matt-hillsdon 5635105
Merge pull request #115 from microbit-foundation/demo-apps
microbit-matt-hillsdon 4a432d1
Fix TypeDoc entry points to match reorganized source structure (#116)
microbit-matt-hillsdon ef9a8f7
Simplify overloads for buttons
microbit-matt-hillsdon e5c6eae
Fall back to skipping hash when crypto.subtle is unavailable (#117)
microbit-matt-hillsdon a69b660
Add temperature, pin services (#122)
microbit-matt-hillsdon 12ea250
Add event service for gestures, button/logo actions, and raw message …
microbit-matt-hillsdon b4bcc50
Migration notes (#125)
microbit-matt-hillsdon e70490a
Add bondMode option to ConnectOptions for native BLE (#123)
microbit-matt-hillsdon 35f08d6
Exclude tests from the package (#131)
microbit-matt-hillsdon 2ab2b6a
Deploy the docs for semver stable tags only (#129)
microbit-matt-hillsdon ca12927
Replace hardcoded dist-tag (#128)
microbit-matt-hillsdon 27b9200
Format the whole repo with prettier (#132)
microbit-matt-hillsdon 2ec8d27
Include README and LICENSE in published package; fix stale branch ref…
microbit-matt-hillsdon f7bb524
Remove stale TODO list
microbit-matt-hillsdon 3420907
Remove soon to be out of date info
microbit-matt-hillsdon 5796bc7
Remove TODO after Windows testing (#133)
microbit-matt-hillsdon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| node_modules | ||
|
|
||
| # Build / dist output | ||
| build | ||
| dist | ||
| docs/build | ||
|
|
||
| # Capacitor native projects (have their own tooling) | ||
| apps/*/android | ||
| apps/*/ios | ||
|
|
||
| # Generated / vendored binaries and lockfiles | ||
| apps/*/public/hex-files | ||
| hex-files | ||
| packages/microbit-connection/examples | ||
| package-lock.json | ||
| *.hex |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # microbit-connection | ||
|
|
||
| TypeScript library for connecting to BBC micro:bit devices via USB and Bluetooth (BLE), including partial and full (DFU) flashing. Published as `@microbit/microbit-connection` on NPM. | ||
|
|
||
| ## Monorepo structure | ||
|
|
||
| npm workspaces monorepo: | ||
|
|
||
| - **`packages/microbit-connection/`** — The library. Dual ESM + CJS build. | ||
| - **`apps/demo/`** — Vite + React demo app with Capacitor support for mobile. | ||
| - **`third-party/`** — Vendored dependencies (patched dapjs). | ||
|
|
||
| ## Commands | ||
|
|
||
| ``` | ||
| npm run build:lib # Build the library (ESM + CJS) | ||
| npm run build # Build everything (lib + demo) | ||
| npm run dev # Run demo app dev server | ||
| npm test # Run tests (vitest) | ||
| npm run format # Prettier format | ||
| npm run format:check # Prettier check | ||
| npm run docs # Generate TypeDoc docs | ||
| ``` | ||
|
|
||
| From the library package directory (`packages/microbit-connection/`): | ||
|
|
||
| - `npx vitest run` — Run tests once | ||
| - `npx vitest` — Run tests in watch mode | ||
|
|
||
| ## Key source areas | ||
|
|
||
| The library source is in `packages/microbit-connection/src/`: | ||
|
|
||
| - **Connection types**: `usb.ts` (WebUSB), `bluetooth.ts` (Web Bluetooth), `usb-radio-bridge.ts` (radio bridge via USB) | ||
| - **Flashing**: `flashing/` directory — `flashing-partial.ts` (partial flash over BLE/USB), `flashing-full.ts` (full flash), `nordic-dfu.ts` (DFU via Capacitor plugin), `flashing-v1.ts` (V1-specific) | ||
| - **BLE services**: `accelerometer-service.ts`, `button-service.ts`, `uart-service.ts`, `led-service.ts`, `magnetometer-service.ts`, `dfu-service.ts`, `partial-flashing-service.ts`, `device-information-service.ts` | ||
| - **Shared**: `device.ts` (core types/interfaces), `events.ts` (typed event target), `bluetooth-profile.ts` (UUIDs), `board-id.ts` | ||
|
|
||
| ## Architecture notes | ||
|
|
||
| - Factory functions (`createWebUSBConnection`, `createWebBluetoothConnection`, `createRadioBridgeConnection`) are the public API entry points | ||
| - Capacitor platform support: native BLE via `@capacitor-community/bluetooth-le`, native DFU via `@microbit/capacitor-community-nordic-dfu` (from `../nordic-dfu/`). These are peer dependencies. | ||
| - `Capacitor.isNativePlatform()` is used to branch between web and native code paths. | ||
|
|
||
| ## Related projects | ||
|
|
||
| Note: these paths rely on an {org}/{repo} scheme for checkouts that might not hold for all developers. If projects are not available then ask the user. | ||
|
|
||
| ### Capacitor plugins | ||
|
|
||
| - **`../nordic-dfu/`** — Capacitor plugin wrapping the Nordic DFU libraries (iOS: iOSDFULibrary, Android: Android-DFU-Library). The iOS plugin code (`ios/Plugin/Plugin.swift`) configures the DFU initiator. | ||
|
|
||
| ### Native apps (reference implementations) | ||
|
|
||
| - **`../microbit-ios/`** — The official micro:bit iOS app. Its DFU flow in `Source/irmLink.m` (lines ~3810-3885) is the reference for how DFU should work on iOS. The bundled `Pods/iOSDFULibrary/` contains the iOS DFU library source, useful for understanding scan/reconnect behaviour. | ||
| - **`../microbit-android/`** — The official micro:bit Android app. Its DFU setup in `app/src/main/java/.../ProjectActivity.java` is the reference for Android DFU options. | ||
|
|
||
| ### Firmware and bootloader | ||
|
|
||
| - **`../v2-bootloader/`** — micro:bit V2 bootloader. Key files: | ||
| - `bootloader/microbit/config/sdk_config.h` — build config (`NRF_DFU_BLE_REQUIRES_BONDS`, `NRF_DFU_BLE_ADV_NAME`) | ||
| - `nRF5SDK_mods/components/libraries/bootloader/ble_dfu/nrf_dfu_ble.c` — BLE transport with micro:bit-specific runtime patches (peer data validation, write permission downgrade, advertising name handling) | ||
| - `bootloader/main.c` — DFU observer and LED display symbols | ||
| - **`../../lancaster-university/codal-microbit-v2/`** — micro:bit V2 runtime (CODAL). BLE stack configuration in `source/bluetooth/MicroBitBLEManager.cpp`. | ||
| - **`../../lancaster-university/microbit-dal/`** — micro:bit V1 runtime (DAL). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @AGENTS.md |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.