Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ble-bean

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ble-bean - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

63

examples/bean_example.js

@@ -12,8 +12,39 @@ /*jslint node: true */

var pinState = 0;
//every 10 seconds change pin
var togglePin = function(){
console.log('toggling');
if(pinState){
pinState = 0;
connectedBean.write(new Buffer([0x91,0x00,0x00]),function(error){
if(error)
console.log(error);
console.log('toggled', pinState);
});
}else{
pinState = 1;
connectedBean.write(new Buffer([0x91,0x20,0x00]),function(error){
if(error)
console.log(error);
console.log('toggled', pinState);
});
}
// board.digitalWrite(5, pinState);
setTimeout(togglePin, 10000);
}
var readyBean = function(){
connectedBean.on("accell", function(x,y,z, valid, seq){
console.log("x:\t" + x + "\ty:\t" + y + "\tz:\t" + z );
});
togglePin();
// connectedBean.on("accell", function(x,y,z, valid, seq){
// console.log("x:\t" + x + "\ty:\t" + y + "\tz:\t" + z );
// });
connectedBean.on("read", function(data, valid, seq, size){

@@ -25,16 +56,16 @@ var status = valid ? "valid" : "invalid";

intervalId = setInterval(function() {
// intervalId = setInterval(function() {
//set random led colors between 0-255. I find red overpowering so red between 0-64
connectedBean.setColor(new Buffer([getRandomInt(0,64),getRandomInt(0,255),getRandomInt(0,255)]),
function(){
console.log("set led");
});
// //set random led colors between 0-255. I find red overpowering so red between 0-64
// connectedBean.setColor(new Buffer([getRandomInt(0,64),getRandomInt(0,255),getRandomInt(0,255)]),
// function(){
// console.log("set led");
// });
connectedBean.requestAccell(
function(){
console.log("requested accell");
});
// connectedBean.requestAccell(
// function(){
// console.log("requested accell");
// });
},1000);
// },1000);

@@ -87,4 +118,4 @@ };

console.log("found");
connectedScratch = new scratchAPI.Scratch(service);
connectedScratch.on('ready', readyScratch);
// connectedScratch = new scratchAPI.Scratch(service);
// connectedScratch.on('ready', readyScratch);
}

@@ -91,0 +122,0 @@ });

@@ -99,10 +99,12 @@ /*jslint node: true */

Bean.prototype.write = function(data, done){
this.send(commands.MSG_ID_SERIAL_DATA, data, done);
}
Bean.prototype.setColor = function(color,done){
this.send(commands.MSG_ID_CC_LED_WRITE_ALL,color,done);
this.send(commands.MSG_ID_CC_LED_WRITE_ALL, color, done);
};
Bean.prototype.requestAccell = function(done){
var cmd = commands.MSG_ID_CC_ACCEL_READ;
var payload = new Buffer([]);
this.send(cmd,payload,done);
this.send(commands.MSG_ID_CC_ACCEL_READ, new Buffer([]), done);
};
{
"name": "ble-bean",
"version": "0.6.0",
"version": "0.7.0",
"description": "Lightblue Bean BLE Services",

@@ -5,0 +5,0 @@ "main": "lib/bean.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc