nodehelium
v0.2.2
Published
Node.js Helium API wrapper
Downloads
8
Keywords
Readme
nodehelium
This is a Node.js library that wraps libhelium.
Example
var helium = require('nodehelium');
// create a helium connection
obj = new helium.Helium();
// open it
obj.open();
var token = "PbOkU4Jo+NObbPe27MJGNQ==";
var mac = "000000fffff00002";
var i = 0;
// set up the message callback
obj.on( 'message', function(data) {
console.log("Message ");
console.log(data);
if (i >= 5) {
console.log("unsubscribing from", mac)
obj.unsubscribe(mac);
setTimeout(function() {
console.log("closing helium connection");
obj.close();}, 5000);
}
i++;
});
// subscribe to a device
obj.subscribe(mac, token);
// send the device a message
obj.send(mac, token, "hello from node.js");
Installing
OSX
Install libhelium from the OSX package
Then you should be able to npm install nodehelium
.
Debian/Ubuntu/Centos/Fedora
Install libuv and libhelium from the packagecloud packages
Then npm install nodehelium
should work.
Source
Build libuv and libhelium from source and install them. When building libu be sure to export CFLAGS="-fPIC" before running './configure' and 'make'. Then npm install nodehelium
.
The reason libuv is needed is because libhelium uses a newer libuv than nodejs 0.10.x uses, and we have to rewrite the symbol table in libhelium and libuv so it doesn't conflict with the libuv symbols in node.js. This hack should be unnecessary after nodejs 0.12 is released.