Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Migration guide (v0 → v1)

These breaking changes are currently available as `0.9.0-apps.alpha.N` pre-releases on npm. Once testing is complete they will be published as `1.0.0`.
This guide covers the breaking changes between `0.x` and `1.0`.

## Subpath exports

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

A TypeScript library for connecting to micro:bit devices via USB and Bluetooth. Works in browsers (via WebUSB and Web Bluetooth) and in native iOS/Android apps (Bluetooth only, via [Capacitor](https://capacitorjs.com/)).

[Available on NPM](https://www.npmjs.com/package/@microbit/microbit-connection). Migrating from an earlier version? See the [migration guide](https://github.com/microbit-foundation/microbit-connection/blob/apps/MIGRATION.md).
[Available on NPM](https://www.npmjs.com/package/@microbit/microbit-connection). Migrating from an earlier version? See the [migration guide](https://github.com/microbit-foundation/microbit-connection/blob/main/MIGRATION.md).

### Demo apps

- [Demo app](https://microbit-connection.pages.dev/) ([source](apps/demo/)) — WebUSB, Web Bluetooth, and Capacitor for native mobile
- [Demo app](https://microbit-connection.pages.dev/) ([source](https://github.com/microbit-foundation/microbit-connection/tree/main/apps/demo)) — WebUSB, Web Bluetooth, and Capacitor for native mobile

### Projects using this library

Expand Down Expand Up @@ -112,7 +112,7 @@ To disable this behaviour, pass `pauseOnHidden: false`:
const usb = createUSBConnection({ pauseOnHidden: false });
```

For more examples see the [demo app source](apps/demo/src/).
For more examples see the [demo app source](https://github.com/microbit-foundation/microbit-connection/tree/main/apps/demo/src).

### Connect via Bluetooth

Expand All @@ -129,7 +129,7 @@ await bluetooth.connect();
console.log("Connection status: ", bluetooth.status); // "Connected"
```

For more examples see the [demo app source](apps/demo/src/).
For more examples see the [demo app source](https://github.com/microbit-foundation/microbit-connection/tree/main/apps/demo/src).

### Error handling

Expand Down Expand Up @@ -161,11 +161,11 @@ Open link hex files are not common. The most common source is the micro:bit Crea

### No suitable services on the micro:bit to flash

- **Hex with no partial flashing or DFU control service (V1)**: This is currently the case for CreateAI data collection hex files for micro:bit V1. There's nothing that can be done via Bluetooth. When the apps branch of CreateAI is released this will eventually resolve itself (or at least, we'll stop creating more such micro:bits). Workaround: flash via WebUSB or drag and drop from a computer. The equivalent V2 hex does have the Secure DFU service (but not partial flashing) which we support.
- **Hex with no partial flashing or DFU control service (V1)**: Some older CreateAI data-collection hex files for micro:bit V1 fall into this category. There's nothing that can be done via Bluetooth. Workaround: flash via WebUSB or drag and drop from a computer. The equivalent V2 hex does have the Secure DFU service (but not partial flashing) which we support.

## Hardware testing

The [hardware test app](apps/hardware-test/) is a human-in-the-loop test runner for USB flashing. It covers partial and full flash, flash fallback paths, serial data integrity after flash, and reconnection after unplug. Run it with:
The [hardware test app](https://github.com/microbit-foundation/microbit-connection/tree/main/apps/hardware-test) is a human-in-the-loop test runner for USB flashing. It covers partial and full flash, flash fallback paths, serial data integrity after flash, and reconnection after unplug. Run it with:

```bash
cd apps/hardware-test
Expand All @@ -178,7 +178,7 @@ The tests prompt you for physical actions (plugging/unplugging) and verify the r

This software is under the MIT open source license.

[SPDX-License-Identifier: MIT](LICENSE)
[SPDX-License-Identifier: MIT](https://github.com/microbit-foundation/microbit-connection/blob/main/LICENSE.md)

We use dependencies via the NPM registry as specified by the package.json file under common Open Source licenses.

Expand Down
3 changes: 3 additions & 0 deletions packages/microbit-connection/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copied in by prepack from the repo root, removed by postpack.
README.md
LICENSE.md
8 changes: 6 additions & 2 deletions packages/microbit-connection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"module": "./build/esm/index.js",
"types": "./build/esm/index.d.ts",
"files": [
"build"
"build",
"README.md",
"LICENSE.md"
],
"sideEffects": false,
"exports": {
Expand Down Expand Up @@ -67,7 +69,9 @@
"build": "npm run build:lib",
"docs": "typedoc",
"ci": "npm run build:lib && npm run test",
"test": "vitest"
"test": "vitest",
"prepack": "cp ../../README.md ../../LICENSE.md .",
"postpack": "rm -f README.md LICENSE.md"
Comment on lines +73 to +74
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By npm pack. The monorepo restructure means we need to grab the root ones for the package build as it doesn't have its own readme.

},
"devDependencies": {
"@types/node": "^20.14.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/microbit-connection/src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type DeviceErrorCode =
// -- User cancelled (no error UI needed) --

/**
* **BLE.** The operation was cancelled via an {@link AbortSignal}
* **BLE.** The operation was cancelled via an `AbortSignal`
* supplied by the caller. No user-facing error is needed.
*/
| "aborted"
Expand Down
4 changes: 2 additions & 2 deletions packages/microbit-connection/src/service-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface PinValue {
*
* Contains only the input pins whose values changed since the last
* notification, up to a firmware limit of 10 pins per event
* (lowest-numbered first). Use {@link MicrobitBluetoothConnection.readPins}
* (lowest-numbered first). Use {@link @microbit/microbit-connection/bluetooth!MicrobitBluetoothConnection.readPins}
* to read all input pins on demand.
*/
export interface PinData {
Expand All @@ -72,7 +72,7 @@ export interface ButtonActionData {

/**
* A raw event from the micro:bit's message bus, received via the
* BLE Event Service. Use {@link MicrobitBluetoothConnection.subscribeToEvent}
* BLE Event Service. Use {@link @microbit/microbit-connection/bluetooth!MicrobitBluetoothConnection.subscribeToEvent}
* to register which events the micro:bit should forward.
*/
export interface MicrobitEventData {
Expand Down
Loading