Created
December 9, 2015 02:56
-
-
Save brghena/0729612baae067912595 to your computer and use it in GitHub Desktop.
Noble/Bleno Interference Example
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
#!/usr/bin/env node | |
var bleno = require('bleno'); | |
bleno.on('stateChange', function(state) { | |
console.log("StateChange: " + state); | |
if (state === 'poweredOn') { | |
console.log("Starting adv..."); | |
bleno.startAdvertising('Bleno/Noble Test'); | |
} else { | |
console.log("Stopping adv"); | |
bleno.stopAdvertising(); | |
} | |
}); | |
bleno.on('advertisingStop', function() { | |
console.log('Advertising stopped'); | |
}); | |
bleno.on('advertisingStartError', function(error) { | |
console.log('Advertising start with error: ' + error); | |
}); | |
bleno.on('advertisingStart', function(error) { | |
console.log('Advertising started: ' + error); | |
}); |
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
#!/usr/bin/env node | |
var noble = require('noble'); | |
noble.on('stateChange', function(state) { | |
console.log("StateChange: " + state); | |
if (state === 'poweredOn') { | |
console.log("Starting scan..."); | |
noble.startScanning([], true); | |
} | |
}); | |
noble.on('scanStop', function() { | |
console.log("scanStop"); | |
}); | |
noble.on('warning', function(message) { | |
console.log("Warning: " + message); | |
}); | |
noble.on('discover', function(peripheral) { | |
console.log("Found a peripheral: " + peripheral.address); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bleno / Noble libraries interference example.
Starting either script while the other is already running will cause the first to stop functioning without any callback.