misfit-bolt
Advanced tools
Comparing version 0.0.1 to 0.0.2
15
index.js
@@ -24,6 +24,16 @@ 'use strict'; | ||
this.peripheral.connect(() => { | ||
debug('connected'); | ||
debug(`connected: ${this.peripheral.uuid}`); | ||
this.peripheral.discoverAllServicesAndCharacteristics((error, services, characteristics) => { | ||
debug('got light'); | ||
this.light = characteristics[0]; | ||
var characteristic; | ||
for (var i = 0; i < characteristics.length; i ++) { | ||
characteristic = characteristics[i]; | ||
if(characteristic.uuid == 'fff1') { | ||
this.light = characteristic; | ||
} | ||
} | ||
if (!characteristic) { | ||
throw new Error('Bolt#connect : could not find light characteristic'); | ||
} | ||
done(); | ||
@@ -54,2 +64,3 @@ }); | ||
var buffer = new Buffer(string); | ||
debug(`set light: ${string}`) | ||
this.light.write(buffer); | ||
@@ -56,0 +67,0 @@ } |
@@ -32,3 +32,3 @@ /*jshint expr: true*/ | ||
it('sets peripheral parameter as instance property', () => { | ||
sinon.match(peripheral, bolt.peripheral); | ||
chai.expect(peripheral).to.equal(bolt.peripheral); | ||
}); | ||
@@ -51,3 +51,3 @@ | ||
var connectSpy, discoverLightSpy, | ||
characteristics = ['foo']; | ||
characteristics = [{uuid: 'foo'},{uuid:'fff1'}]; | ||
@@ -75,3 +75,3 @@ before((done) => { | ||
it('sets first characteristic as `light` instance property', () => { | ||
sinon.match(bolt.light, characteristics[0]); | ||
chai.expect(bolt.light).to.deep.equal(characteristics[1]); | ||
}); | ||
@@ -78,0 +78,0 @@ |
{ | ||
"name": "misfit-bolt", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Misfit Bolt Javascript Interface", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,6 +0,6 @@ | ||
# misfit-bolt | ||
Misfit Bolt Javascript Interface | ||
# Misfit Bolt Javascript Interface | ||
Thin wrapper on the top of [sandeepmistry/noble](https://github.com/sandeepmistry/noble), that discovers Misfit Bolt bulbs, and allows turning them on/off and changing their color, as well as reading their currently set color. | ||
## Prerequisites | ||
@@ -11,14 +11,10 @@ | ||
## Setup | ||
```bash | ||
npm install | ||
npm install misfit-bolt | ||
``` | ||
## Test | ||
```bash | ||
npm test | ||
``` | ||
## API | ||
@@ -66,2 +62,3 @@ | ||
## Example | ||
@@ -87,3 +84,8 @@ | ||
## TODO | ||
- CLI tool | ||
## Notes | ||
Inspired by [fayep's Python implementation](https://github.com/fayep/bolt) | ||
- Inspired by [fayep's Python implementation](https://github.com/fayep/bolt) | ||
- PRs welcomed! |
13810
334
89