Skip to content

Instantly share code, notes, and snippets.

@gorhgorh
Created February 12, 2015 15:16
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 gorhgorh/022859ee97190e91754a to your computer and use it in GitHub Desktop.
Save gorhgorh/022859ee97190e91754a to your computer and use it in GitHub Desktop.
var SensorTag = require('sensortag');
console.log("looking for a sensorTag");
SensorTag.discover(function(sensorTag) {
console.log("found one");
sensorTag.connect(function() {
console.log("connected to sensortag");
sensorTag.discoverServicesAndCharacteristics(function() {
console.log("characteristics discovered");
sensorTag.notifySimpleKey(function() {
console.log('simplekey notify correctly set up');
});
});
sensorTag.on('simpleKeyChange', function(left, right) {
if (left) {
console.log('left pressed');
} else if (right) {
console.log('right pressed');
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment