Reputation: 17870
Is there an API, shell command or AppleScript for getting an accurate reading of the current WiFi strength in Mac OSX?
FYI I can also open a browser and use JavaScript if it has that value available.
What I'm trying to do is check WiFi strength for different spots in my kitchen or living room. I need to check WiFi strength for each spot. If it's low I move to a new spot. The WiFi bars that OSX displays is not enough data for me.
Upvotes: 4
Views: 1722
Reputation: 1932
There is a built-in airport command which will do it. It's location is:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
For convenience, you can create a link which will let you run the command from anywhere.
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
To get info about the current wireless network
airport -I
http://osxdaily.com/2007/01/18/airport-the-little-known-command-line-wireless-utility/
Assuming you've created the link, an AppleScript that converts the value to percentage and displays a notification:
set wirelessRSSI to do shell script "airport -I | grep CtlRSSI | sed -e 's/^.*: //g'"
set wirelessStrength to (wirelessRSSI + 100) * 2
display notification "Wireless sigal quality: " & wirelessStrength & "%"
Upvotes: 3
Reputation: 63974
This is an well-hidden gem. Just navigate in the Finder to the folder
/System/Library/CoreServices/Applications
and run the
Wireless Diagnostics.app
It has many builtin tools.
Before you click "Continue" (in the 1st window) you should check the "Window" menu for the available tools:
About the above tools:
About report sending:
date_string.wdmon
)Summary:
Window menu
as I told it already in my answer.Warning users about the data collection is a good thing. Thank you for your explicit warning.
Upvotes: 0
Reputation: 203554
Here's a simple Python script which uses the CoreWLAN
framework:
#!/usr/bin/python
from AppKit import CWInterface
IFACE = 'en0'
NAME = 'MyWifiNetwork'
interface = CWInterface.interfaceWithName_(IFACE)
results, error = interface.scanForNetworksWithName_error_(NAME, None)
for result in results:
print 'SSID:', result.ssid()
print 'RSSI:', result.rssiValue()
Upvotes: 4
Reputation: 36482
I must admit that I don't know whether OS X has information like a received strength indicator easily accessible.
What I can tell you from an RF communication's engineer's perspective is that the displayed signal strength is everything but accurate, and it's even less usable to really predict how well communication will work.
As you said, the bars aren't enough information for anyone -- and the fact that there are already five different amounts of bars you can have usually greatly exaggerates the accuracy with which these things are available to the operating system. WiFi quality is so much more than received signal strength that you can't directly map bars to quality. I really don't know why GUIs keep including that measure instead of e.g. a measure of how many packets get lost along the way (which is actually something that an OS can observer).
I assume you want to do something like "if WiFi A is weak, switch to WiFi B", or similar. I think the right way to do that is actually two steps up the OSI layer model, at least. I'd personally just set up a server somewhere on the internet that replies to UDP packets and is pingable. Then, you'd just use standard ping to figure out whether latency is still acceptable, and use short UDP to the server packets to figure out how much packet loss you see (you can do that via ping
and ICMP, too, but that won't normally allow you to send a couple of hundred packets per second -- which is what I'd do periodically).
Upvotes: 1