Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to access OS X wi-fi data using Python? (Signal strength, for example)

I am just curious whether it would be possible to use any Python tools to poll wi-fi signal strength in OS X. Most of my searches are just yielding Python tools for Linux, but none for OS X.

If not, are there any other ways to get such data programmatically?

like image 304
Saxophlutist Avatar asked Mar 02 '13 00:03

Saxophlutist


2 Answers

The answer to this question describes how to load the CoreWLAN framework. Once you've done that, you can use the CWInterface class to find the RSSI, amongst other stats:

import objc
objc.loadBundle('CoreWLAN',
                bundle_path='/System/Library/Frameworks/CoreWLAN.framework',
                module_globals=globals())

for iname in CWInterface.interfaceNames():
  interface = CWInterface.interfaceWithName_(iname)
  print """
Interface:      %s
SSID:           %s
Transmit Rate:  %s
Transmit Power: %s
RSSI:           %s""" % (iname, interface.ssid(), interface.transmitRate(),
                         interface.transmitPower(), interface.rssi())

See the CWInterface docs for the full list of available properties.

like image 119
jatoben Avatar answered Sep 18 '22 17:09

jatoben


For mac there is a Command line tool called airport. You can manually adjust any wi-fi settings, network card settings, troubleshoot networks, change security types used on a connection, capture packets into a pcap file, join and leave networks, forget a wifi network, prioritize routers and networks, see signal strength and interference etc.

Its usually in here - /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

You can just type this for help

airport
airport -h

Using this and subprocess together you should be able to do most of these things in python

like image 20
medakeshav Avatar answered Sep 17 '22 17:09

medakeshav