You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+89-6Lines changed: 89 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,99 @@
1
-
# JavaScript library for micro:bitconnections in browsers via USB and Bluetooth
1
+
# micro:bitconnection library
2
2
3
-
This project is a work in progress. We are extracting WebUSB and Web Bluetooth code from the [micro:bit Python Editor](https://github.com/microbit-foundation/python-editor-v3/) and other projects.
3
+
[This documentation is best viewed on the documentation site rather than GitHub](https://microbit-foundation.github.io/microbit-connection/).
4
4
5
-
It is intended to be used by other Micro:bitEducational Foundation projects that need to connect to a BBC micro:bit.
5
+
This is a JavaScript library for micro:bitconnections in browsers via USB and Bluetooth.
6
6
7
-
The API is not stable and it's not yet recommended that third parties use this project unless they are happy to update usage as the API evolves.
7
+
This project is a work in progress. We are extracting WebUSB and Web Bluetooth code from the [micro:bit Python Editor](https://github.com/microbit-foundation/python-editor-v3/) and other projects. The API is not stable and it's not yet recommended that third parties use this project unless they are happy to update usage as the API evolves.
8
+
9
+
[Demo page](https://microbit-connection.pages.dev/) for this library.
8
10
9
11
[Alpha releases are now on NPM](https://www.npmjs.com/package/@microbit/microbit-connection).
10
12
13
+
[micro:bit CreateAI](https://github.com/microbit-foundation/ml-trainer/) is already using this library for WebUSB and Web Bluetooth.
14
+
11
15
[This Python Editor PR](https://github.com/microbit-foundation/python-editor-v3/pull/1190) tracks updating the micro:bit Python Editor to use this library.
12
16
13
-
[micro:bit CreateAI](https://github.com/microbit-foundation/ml-trainer/) is already using this library for WebUSB and Web Bluetooth.
17
+
## Usage
18
+
19
+
### Flash a micro:bit
20
+
21
+
Instantiate a WebUSB connection using {@link MicrobitWebUSBConnection} class and use it to connect to a micro:bit.
This code will also work for non-universal hex files so is a good default for unknown hex files.
48
+
49
+
Alternatively, you can create and flash a hex for a specific micro:bit version by providing a function that takes a {@link BoardVersion} and returns a hex.
50
+
This can reduce download size or help integrate with APIs that produce a hex for a particular device version.
51
+
This example uses the [@microbit/microbit-fs library](https://microbit-foundation.github.io/microbit-fs/) which can return a hex based on board id.
For more examples of using other methods in the {@link MicrobitWebUSBConnection} class, see our [demo code](https://github.com/microbit-foundation/microbit-connection/blob/main/src/demo.ts) for our [demo site](https://microbit-connection.pages.dev/).
78
+
79
+
### Connect via Bluetooth
80
+
81
+
By default, the micro:bit's Bluetooth service is not enabled. Visit our [Bluetooth tech site page](https://tech.microbit.org/bluetooth/) to download a hex file that would enable the bluetooth service.
82
+
83
+
Instantiate a Bluetooth connection using {@link MicrobitWebBluetoothConnection} class and use it to connect to a micro:bit.
{@link ConnectionStatus | Connection status} is `"CONNECTED"` if connection succeeds.
95
+
96
+
For more examples of using other methods in the {@link MicrobitWebBluetoothConnection} class, see our [demo code](https://github.com/microbit-foundation/microbit-connection/blob/main/src/demo.ts) for our [demo site](https://microbit-connection.pages.dev/).
0 commit comments