-
-
Save taka-wang/915f403e3b969ae7f57c to your computer and use it in GitHub Desktop.
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
// 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