bbc-microbit
Advanced tools
Comparing version 0.1.0 to 0.2.0
36
API.md
@@ -11,3 +11,4 @@ # node-bbc-microbit API | ||
1. [Temperature](#temperature) | ||
1. [UART](#uart) | ||
1. [UART](#uart) | ||
1. [Event](#event-5) | ||
@@ -372,1 +373,34 @@ ## Require module | ||
``` | ||
## [Event](https://lancaster-university.github.io/microbit-docs/ble/event-service/) | ||
### Micro:bit Events | ||
Events come in two varieties, reflected by the two corresponding characteristics: | ||
Micro:bit Events emanate from the micro:bit and may be notified to the connected client. | ||
Client Events emanate from the connected client and may be written to the connected micro:bit | ||
### Write event | ||
```javascript | ||
microbit.writeEvent(id, value, callback); | ||
``` | ||
### Subscription | ||
```javascript | ||
microbit.subscribeEvents(id, value, callback(error)); | ||
microbit.unsubscribeEvent(callback(error)); | ||
``` | ||
#### Event | ||
```javascript | ||
microbit.on('event', function(id, value) { | ||
// ... | ||
}); | ||
``` |
@@ -12,2 +12,4 @@ /* | ||
* | ||
* http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html for hex files and micro:bit info | ||
* | ||
*/ | ||
@@ -14,0 +16,0 @@ |
@@ -12,2 +12,4 @@ /* | ||
* | ||
* http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html for hex files and micro:bit info | ||
* | ||
*/ | ||
@@ -14,0 +16,0 @@ |
@@ -12,2 +12,3 @@ /* | ||
* | ||
* http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html for hex files and micro:bit info | ||
*/ | ||
@@ -14,0 +15,0 @@ |
@@ -10,2 +10,3 @@ var NobleDevice = require('noble-device'); | ||
var UartService = require('./uart-service'); | ||
var EventService = require('./event-service'); | ||
@@ -34,2 +35,3 @@ function BBCMicrobit() { | ||
NobleDevice.Util.mixin(BBCMicrobit, UartService); | ||
NobleDevice.Util.mixin(BBCMicrobit, EventService); | ||
@@ -46,3 +48,3 @@ BBCMicrobit.prototype.toString = function() { | ||
if (error) { | ||
return callback(); | ||
return callback(error); | ||
} | ||
@@ -49,0 +51,0 @@ |
{ | ||
"name": "bbc-microbit", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Control a BBC micro:bit from Node.js using BLE ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,3 +8,3 @@ # node-bbc-microbit | ||
* See [noble prerequisites](https://github.com/sandeepmistry/noble). | ||
* Requires a custom firmware build on the micro:bit. This build removes pairing security and enables all BLE services. | ||
* Requires a custom firmware build on the micro:bit. This build removes pairing security and enables all BLE services. The source code of the custom firmware can be found [here](https://github.com/sandeepmistry/node-bbc-microbit-firmware). | ||
@@ -11,0 +11,0 @@ ### Flashing micro:bit firmware |
509512
29
1328