Scanning on OSX returns no networks intermittently
For some reason it returns 0 networks repeatedly when theres about 5 within range and 2 within 6 feet of my laptop, any ideas?
Well this module basically just runs a variety of shell commands depending on what OS its being executed from. So the only way we can test this is to take those same commands, and run them manually in a terminal!
Can you copy paste the verbose log output that gets dumped when you run the following?
WiFiControl.init({
debug: true
});
This seems to only happen if I do a scan right after a reset. We've added a 5 second delay which seems to work but definitely not ideal :)
Well, on OSX the network reset procedure basically consists of toggling the physical power to your wireless interface.
So I'm not too surprised that if we request scan results within a few hundred ms of powering up the chip we're not getting accurate results.
The problem is, we don't proceed until the results of the following command report that the interface is powered:
networksetup -getairportpower [interface name]
I could always add a delay right after this step, but that doesn't seem responsible -- 5000ms is a lot of time. I wonder if there's some other way we can use the OSX CLI to report that a network interface is not only powered but ready to scan.
I completely agree that adding a timeout on your side isn't the right solution but not sure what options there are as I haven't dig into the CLI tools all that much.
Well I can only suggest implementing a retry system in your application code. E.G. define a function that does the scanning, and if the results are empty, re-run that same function with a setTimeout of like 500ms or so. Then terminate after N retries. That way you can repeatedly scan a known number of times.
@msolters your workaround sounds fair enough :) thanks +1