Package Exports
- ble-bean
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ble-bean) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
##BLE-Bean Non Official api for the LightBlue Bean http://punchthrough.com/bean/
ble-bean is set up a litte differently than other libraries. I'm playing with exposing services and characteristics, rather than the device. You need to use noble to search for services, and create an instance of Bean or Scratch. See the example.
###INSTALL
npm install ble-bean####Bean:
You can wite data which can be read on arduino with Serial.read - in this instance 91,00,00 is firmata for all pins on port 0 low
connectedBean.write(new Buffer([0x91,0x00,0x00]),callback(error));You can read the raw data from the device with:
connectedBean.on("read", callback(data, valid, seq, size));
Or theres a job specific emitters to do parsing for you, like accelerometer:
connectedBean.on("accell", callback(x, y, z, valid, seq));To read the accelerometer though, you need to ask it to take a reading with:
connectedBean.requestAccell(callback(error));You can set the led color (in this case to a random color) with:
connectedBean.setColor(new Buffer([getRandomInt(0,64),getRandomInt(0,255),getRandomInt(0,255)]), callback(error));If theres something I haven implemented you can create it yourself with the send command. See commands.js for commandBuffers to use:
connectedBean.send(commandBuffer, dataBuffer, callback(error));####Scratch:
Scratch characteristics are 5 other characterists you can send and receive data on from the Arduino. See the reference page for more info: http://punchthrough.com/bean/arduino-reference/
You can write to the first scratch like:
connectedScratch.write1("scratch1", new Buffer([]), callback(error));And you could listen for data on it like:
connectedScratch.on("scratch1", callback(data));###CHANGELOG 0.1.0 first
0.2.0 cleaned up scanning in the example and the package.json file
0.3.0 and 0.4.0 add scratch characteristics with notify fix acellerometer readings better logging in example, took console.log out of library
0.5.0 scale acceleromter readings added readme with changelog
0.6.0 only emit command specific emits when packets are valid refactor for cleaner code add write scratch characteristics
0.7.0 add write serial data to bean characteristic
0.7.1 Better readme, no code changes.