-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
405 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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,46 @@ | ||
# micro:bit Web Bluetooth | ||
|
||
Web Bluetooth library for micro:bit implementing the [micro:bit Bluetooth Profile](https://lancaster-university.github.io/microbit-docs/resources/bluetooth/bluetooth_profile.html). | ||
|
||
## Prerequisites | ||
|
||
[Node.js > v8.14.0](https://nodejs.org), which includes `npm` | ||
|
||
## Installation | ||
|
||
```bash | ||
$ npm install microbit-web-bluetooth | ||
``` | ||
|
||
## Usage | ||
|
||
Include the package in your web page, exposing a global named `microbit`: | ||
|
||
```html | ||
<script type="text/javascript" src="microbit.umd.js"></script> | ||
``` | ||
|
||
Use `window.navigator.bluetooth.requestDevice()` to obtain a bluetooth device or use the [requestMicrobit()](globals.html#requestmicrobit) helper to discover a micro:bit: | ||
|
||
```javascript | ||
const device = await microbit.requestMicrobit(window.navigator.bluetooth); | ||
``` | ||
|
||
Use [getServices()](globals.html#getservices) to return an array of available services: | ||
|
||
```javascript | ||
const services = await microbit.getServices(device); | ||
``` | ||
|
||
Services returned could be any of the following: | ||
|
||
- [deviceInformationService](classes/deviceinformationservice.html) | ||
- [uartService](classes/uartservice.html) | ||
- [ledService](classes/ledservice.html) | ||
- [buttonService](classes/buttonservice.html) | ||
- [temperatureService](classes/temperatureservice.html) | ||
- [accelerometerService](classes/accelerometerservice.html) | ||
- [magnetometerService](classes/magnetometerservice.html) | ||
- [eventService](classes/eventservice.html) | ||
|
||
Refer to the [web example](https://github.com/thegecko/microbit-web-bluetooth/blob/master/examples/index.html) ([running](https://thegecko.github.io/microbit-web-bluetooth/examples/index.html)) for a full example for each supported service. |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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 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
Oops, something went wrong.