This tutorial is a more in-depth look at some of the code behind the SpaceBlue project. Specifically, it goes over some of the finer points in the node.js app that integrates information from the RedBear BLE Shield and then sends it via Spacebrew. This project uses the Noble library for connecting node to BLE.
The code for the entire project is available on Github here. This tutorial will explain certain points about the node app, spacebrew_and_BLE.js, which is here.
As a preliminary matter, you need to make sure certain files are in the same folder as your app. The spacebrew.js library needs to be in there. Additionally, you need to have the Spacebrew and the Noble modules installed in your node_modules folder.
Also note that this node app uses the public Spacebrew playground. If you want to use your local server, you can un-comment the line of code that reads: sb.server = "localhost";. In that case, you need to make sure any other apps also use the localhost, and that you're running the Spacebrew server on your localhost as well.
General setup:
First, note that the way the app works is that it connects to two specific BLE Shields, tests their RSSI (Received Signal Strength Indication) every 100th of a second, and then averages the last 100 values in order to send it to Processing. As a result, we set up two arrays to hold this information. Because these arrays will hold data from specific shields, we named them accordingly: