Skip to content

Instantly share code, notes, and snippets.

@hardillb
Created October 23, 2013 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hardillb/7126863 to your computer and use it in GitHub Desktop.
Save hardillb/7126863 to your computer and use it in GitHub Desktop.
Example Sensorttag node app
var SensorTag = require('sensortag');
var node = {};
console.log("starting");
SensorTag.discover(function(sensorTag){
console.log("discovered: " + sensorTag);
console.log(tag);
node.st = tag;
console.log(node);
node.st.connect(function(){
console.log("connected: " + node);
node.st.discoverServicesAndCharacteristics(function(){
node.st.enableIrTemperature(function(){});
node.st.on('irTemperatureChange',
function(objectTemperature, ambientTemperature){
console.log('\tobject temperature = %d °C', objectTemperature.toFixed(1));
console.log('\tambient temperature = %d °C', ambientTemperature.toFixed(1));
});
node.st.enableBarometricPressure(function(){});
node.st.on('barometricPressureChange', function(pressure){
console.log('\tpressure = %d mb', pressure.toFixed(1));
});
node.st.notifyBarometricPressure(function(){
console.log("pressure notify enabled");
});
node.st.notifyIrTemperature(function(){
console.log("temp notify enabled");
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment