Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Last active June 29, 2019 02:36
Show Gist options
  • Save joshschmelzle/d9c62e9a88dee1cff12469e221a3a2ed to your computer and use it in GitHub Desktop.
Save joshschmelzle/d9c62e9a88dee1cff12469e221a3a2ed to your computer and use it in GitHub Desktop.
Convert Signal Quality to RSSI using Python (short version)
"""
- there are known issues with this approach.
- consider that this does not force the driver to refresh it's RSSI reading.
- if you want to monitor RSSI, you need to use the wlanapi.
"""
import subprocess
command = ['netsh', 'wlan', 'show', 'interface']
out = subprocess.check_output(command)
out = out.decode("utf-8").lower()
for line in out.splitlines():
paramater = line.split(":", 1)[0].strip()
try:
value = line.split(":", 1)[1].strip()
except IndexError:
continue
if "signal" in line:
quality = int(value.replace("%", ""))
if quality <= 0:
dbm = -100
elif quality >= 100:
dbm = -50
else:
dbm = (quality / 2) - 100
dbm = int(dbm)
print("quality,dbm")
print("{},{}".format(quality,dbm))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment