Skip to content

Instantly share code, notes, and snippets.

@sandeepmistry
Last active July 17, 2018 19:50
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 sandeepmistry/6183917 to your computer and use it in GitHub Desktop.
Save sandeepmistry/6183917 to your computer and use it in GitHub Desktop.
noble scan, and advertisement info print out on discovery.
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();
});
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
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"]
@Kazi-Yako
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment