npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ble-bean

v2.1.1

Published

Lightblue Bean BLE Services

Downloads

32

Readme

#BLE-Bean Non Official api for the LightBlue Bean

I recommend you familiarize yourself with the Bean first, but the gist is it has a BLE transceiver and an Arduino onboard. You can program regular Arduino sketches on the Arduino, but the BLE transceiver is available no matter what sketch you have on the bean.

Second it might be helpful to familiarize yourself with noble as this library is built on noble-device.

#Install

npm install ble-bean

#Use To get started You include this library and ask the library to discover a bean:

var Bean = require('ble-bean');
Bean.discover(function(bean){

}

But you're not done yet, inside the discover you need to ask the bean to set itself up:

bean.connectAndSetup(function(){

}

When that returns you're finally ready to use the ble-bean api:

bean.requestTemp(callback);
bean.requestAccell(callback);
bean.setColor(color, callback); //where color is a buffer of r,g,b hex values
bean.write(data, callback); //where data is a buffer

Huge gotcha here though, the callback to all api commands DO NOT GIVE YOU BACK YOUR DATA, they simply confirms that the request has left your computer.

The data response is based on emitters. You need to listen for the event you're interested in. We offer:

  • serial - which returns data, valid - serial data from the Arduino
  • accell - which returns x, y, z, valid - accelerometer data from bean
  • temp - which returns temp, valid - accelerometer data from bean
  • raw - which returns packet, length, valid, command - which returns raw command packet from bean before it gets turned into accell, serial, temp, etc (with gst and gatt headers stripped)

Each of the events offers a valid flag to see if the checksum matched up, etc. It probably doesn't matter to you unless you're doing something mission critical.

Theres are also five scratch characteristics available on the bean. These are just another way to send data to your Arduino:

bean.readOne(callback); //explicit read from characteristic
bean.notifyOne(readCallback, callback); //listen for all data from characteristic
bean.writeOne(callback); //write data to characteristic
bean.unnotifyOne(readCallback, callback); //stop listening for all data from characteristic

For a fairly exhaustive example that connects, listens for serial data, sets the led color randomly, asks the bean for temp and accell data every second, and disconnects cleanly when you control-c, from bean directory run:

node examples/bean_example.js

###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 accelerometer readings better logging in example, took console.log out of library

0.5.0 scale accelerometer 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.

0.8.0 New Serial event for parsed serial data called 'serial'

1.0.0 Emitter callback signatures changed!! 'read' emitter became 'raw' accell and serial changed removing the sequence since its handled internally now. Added requestTemp.

2.0.0 Move to new noble-device pattern which significantly removes noble cruft from implementation. Changes the scratch characteristic API. Example has cleaner disconnect code.

2.0.1 Clean and split up examples

2.0.2 Fixed bug in Scratch write implementation clean up firmata example

2.1.0 newer firmwares are gating serial SEND during first x seconds, added unGate function to disable