Created
October 23, 2013 21:14
-
-
Save hardillb/7126863 to your computer and use it in GitHub Desktop.
Example Sensorttag node app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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