wifi-control-node icon indicating copy to clipboard operation
wifi-control-node copied to clipboard

Scanning on OSX returns no networks intermittently

Open corymsmith opened this issue 10 years ago • 6 comments

For some reason it returns 0 networks repeatedly when theres about 5 within range and 2 within 6 feet of my laptop, any ideas?

corymsmith avatar Dec 16 '15 21:12 corymsmith

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
  });

msolters avatar Dec 16 '15 21:12 msolters

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 :)

corymsmith avatar Dec 28 '15 03:12 corymsmith

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.

msolters avatar Dec 28 '15 20:12 msolters

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.

corymsmith avatar Jan 01 '16 05:01 corymsmith

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 avatar Mar 27 '16 04:03 msolters

@msolters your workaround sounds fair enough :) thanks +1

cedricve avatar Jun 15 '16 11:06 cedricve