Misfit Bolt Javascript Interface
Thin wrapper around sandeepmistry/noble, that helps Misfit Bolt bulbs discovery, and allows turning them on/off and changing their color and brightness, as well as reading their currently set values.
Prerequisites
To connect to the Misfit Bolt, you need BLE capabilities.
See sandeepmistry/noble prerequisites for more details.
Setup
npm install misfit-bolt
API Methods
discover
Type static
Arguments
- callback (function): function to be invoked once a Bolt is discovered. Takes a
Bolt
instance as first argument. - uuids (Array, optional): list of Bolt uuid to discover.
Returns
undefined
Example
Bolt.discover(function(bolt) {
}, ['29852E52-67A0-490A-BC55-7FAB809AD0C0']);
connect
Type instance
Arguments
- callback (function): gets called when connection is complete.
Returns
instance
Example
bolt.connect(function() {
});
disconnect
Type instance
Arguments
- callback (function, optional): gets called when disconnection is complete.
Returns
instance
Example
bolt.disconnect();
on
Type instance
Arguments
none
Returns
instance
Example
bolt.on();
off
Type instance
Arguments
none
Returns
instance
Example
bolt.off();
set
Type instance
Arguments
- value (String): value to set on bulb. Mostly in the form or RGBA. Accepts "CLTMP 3200,0" or "CLTMP 3200,1" (used for toggle on / off). Other undocumented formats might exist.
Returns
instance
Example
bolt.set("228,41,15,10");
setRGBA
Type instance
Arguments
- value (Array): value to set on bulb. Although not enforced yet, should be in the form of
[red, gree, blue, alpha]
.
Returns
instance
Example
bolt.setRGBA([228,41,15,10]);
get
Type instance
Arguments
- callback (function): function invoked when value is available. Return value of
String
type.
Returns
instance
Example
bolt.get(function(value) {
});
getRGBA
Type instance
Arguments
- callback (function): function invoked when value is available. Return value of
Array
type.
Returns
instance
Example
bolt.get(function(rgbaValue) {
});
Usage
Bolt.discover(function(bolt) {
bolt.connect(function() {
var i = 0,
colors = [[228,41,15,10],
[216,62,36,10],
[205,55,56,10],
[211,27,76,10],
[166,18,97,10]];
setInterval(function(){
var color = colors[i++ % colors.length];
bolt.setRGBA.apply(bolt, color);
}, 500);
});
});
TODO
Notes