Erratic times between scan discovery
See original GitHub issueI’m currently using noble on a MacBook running Sierra and trying to discover a Puck.js that’s advertising a counter variable which indicates button presses. I never actually connect the Puck.js, I just read the values it’s advertising.
I’ve noticed that there can be quite a range in the amount of time between each on('discover')
event being emitted. For example, the following (simplified) code.
const noble = require('noble');
noble.on('stateChange', (state) => {
if (state === 'poweredOn') {
noble.startScanning([], true);
} else {
noble.stopScanning();
}
});
let lastDate = Date.now();
noble.on('discover', () => {
const now = Date.now();
const diff = (now - lastDate) / 1000;
console.log(`Discovered! Time since last reading: ${diff}s.`);
lastDate = now;
});
Produces the following output:
Noble seems to be able to discover at most once every 1.5 seconds, but sometimes it can be 20+ seconds between discoveries. Granted, I’m using Noble in quite a hacky way (checking an advertised counter variable to see if the button has been pressed) but I wanted to find out if there was anything I could be doing to make the time between these discoveries be more consistently around the 1.5 second mark.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
@joshfarrant thanks for the update. It looks like something internal with CoreBluetooth/blued on macOS which is requires Apple’s help. I’ll close this for now since you have a workaround.
@joshfarrant thanks for your clarification, but I have this problem with my Raspberry Pi zero actually! after few seconds it cannot discover any BLE device.