How can I retrieve the signal strength of nearby wireless LAN networks on Windows using Python?
I would like to either show or graph the values.
How can I retrieve the signal strength of nearby wireless LAN networks on Windows using Python?
I would like to either show or graph the values.
@fmark I just wanted to say THANK YOU so much for this awesome post. At my work I have been trying to get RSSI from the connected AP in Windows, and you deserve many thanks for me finally getting it done. I'm currently listing all APs, but I'm working on modifying it. I wanted to offer a recommendation towards your code. I'm not very experienced with C or the Python CTypes module, but I think I might have found a possible bug. I'm really not sure what difference it makes, but I noticed:
You define enums like this:
But then other times you define something very similar like this:
I think the second snippit should be modeled like the first, but I could be wrong. Here was my idea:
This way those values would get correctly mapped to DOT11_PHY_TYPE. Perhaps I am completely wrong, but for future folks like myself, I just wanted whatever is stumbled on here to be correct :) Thanks again, @fmark.
If you don't want to deal with Windows API you could use method shown here with a slight modification.
You can use this command:
using this code
This will give you additiona "Signal" information as a percentage. This can be converted to RSSI using this method.
Well you could invoke the system command to get that info (Linux = iwlist), parse the result, and display it.
So.. I based myself on @fmarks code (which was a live-safer for me), and you should add the WlanScan function, or else the RSSI values will not refresh.
Here is my extended code!
All props to @fmarks!
If you are on Windows, you probably want to use the WLAN API, which provides the 'WlanGetAvailableNetworkList()' function (see the API docs for usage). I am not aware of any python wrappers for
WLANAPI.DLL
so you may have to wrap it yourself using ctypes. I have a preliminary script that does this (works-for-me), but it may be crufty. You'll want to read the documentation to understand the meaning of all the fields:On linux, you have a couple of choices:
The standard options is to parse the output of
iwlist -scan
. However, if you are currently connected to a wlan and not running as root, it only returns the currently connected wlan.If you need more than this, the best way is to query the wireless manager daemon. On modern, linuxes, this is usually NetworkManager, although wicd is becoming more popular. Both of these managers can be queried using
dbus
. Unless you can control what the clients have on their systems, you might need to support both of these options, or at least one option and have a fallback foriwlist
.