Last active
July 17, 2018 19:50
-
-
Save sandeepmistry/6183917 to your computer and use it in GitHub Desktop.
noble scan, and advertisement info print out on discovery.
This file contains hidden or 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 noble = require('noble'); | |
noble.on('stateChange', function(state) { | |
if (state === 'poweredOn') { | |
noble.startScanning(); | |
} else { | |
noble.stopScanning(); | |
} | |
}); | |
noble.on('discover', function(peripheral) { | |
console.log('peripheral discovered:'); | |
console.log('\thello my local name is:'); | |
console.log('\t\t' + peripheral.advertisement.localName); | |
console.log('\tand I am advertising the following services:'); | |
console.log('\t\t' + JSON.stringify(peripheral.advertisement.serviceUuids)); | |
console.log(); | |
}); | |
This file contains hidden or 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
My output: | |
* 1st discovered device is a StickNfind (maybe blacklist?) | |
* 2nd discovered device is a SensorTag (does not advertise any services) | |
* 3rd discovered device is BluetoothBlue, based on 426c7565746f6f74682042756c620000 service uuid advertised (maybe blacklist?) | |
* 4th discovered device is a Robosmart, based on ff10 service uuid advertised |
This file contains hidden or 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
peripheral discovered: | |
hello my local name is: | |
StickNfind | |
and I am advertising the following services: | |
[] | |
peripheral discovered: | |
hello my local name is: | |
SensorTag | |
and I am advertising the following services: | |
[] | |
peripheral discovered: | |
hello my local name is: | |
Bluetooth Bulb | |
and I am advertising the following services: | |
["1800","426c7565746f6f74682042756c620000"] | |
peripheral discovered: | |
hello my local name is: | |
Soffit 3 | |
and I am advertising the following services: | |
["ff10","ff20"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can this noble library work with react-native? OnDiscover does not detect any beacon with react-native? I am using Ibeacons, eddystone and beacon pros. Thanks!