Skip to content

Instantly share code, notes, and snippets.

@maciej
Created April 23, 2014 14:39
Show Gist options
  • Save maciej/11217917 to your computer and use it in GitHub Desktop.
Save maciej/11217917 to your computer and use it in GitHub Desktop.
NodeJS iBeacon scanner
// Requires NodeJS and "noble" module: https://github.com/sandeepmistry/noble
// Based on: https://github.com/sandeepmistry/noble/issues/62
var noble = require('noble');
noble.on('stateChange', function(state) {
if (state === 'poweredOn' ) {
noble.startScanning([], false);
} else {
noble.stopScanning();
}
});
noble.on('discover', function(peripheral) {
peripheral.connect(function(error) {});
peripheral.on('connect',function(){});
peripheral.on('rssiUpdate',function(rssi){
console.log({"uuid": peripheral.uuid, "rssi": peripheral.rssi });
});
setInterval(function(){
peripheral.updateRssi();
}, 100);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment