Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix no signal level from the card #88

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/net_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,41 @@ def networkdictionary():
cards = {}
for card in nlist:
if 'wlan' in card:
# 20230601 JES
# alternative way to get the signal level
sta = f"ifconfig {card} list sta | tail -1"
wifiplus = Popen(sta, shell=True, stdout=PIPE,
universal_newlines=True)
qual = 0
percentage = -1
for line in wifiplus.stdout:
rssi = float(line[33:37].strip())
# with this formula, level is not
# maximum despite the computer is
# almost touching the router
#qual = 2 * ( (rssi * (-1) ) + 100)
# this formula increase the percentage
# and the icon shows maximum level
qual = 2 * ( (rssi * (-1) ) + 113)
# 20230601 JES
# debug
#print("net_api.py> rssi:%s qual:%s " % (str(rssi),str(qual) ) )

scanv = f"ifconfig {card} list scan | grep -va BSSID"
wifi = Popen(scanv, shell=True, stdout=PIPE,
universal_newlines=True)
connectioninfo = {}
for line in wifi.stdout:
# don't sort empty ssid
# don't sort empty ssid
# Window, MacOS and Linux does not show does
if line[:5] == " ":
continue
ssid = line[:33].strip()
info = line[:83][33:].strip().split()
percentage = barpercent(info[3])
# 20230601 JES
# debug
#print("net_api.py> ssid:%s percentage:%s" % (ssid , percentage) )
# if ssid exist and percentage is higher keep it
# else add the new one if percentage is higher
if ssid in connectioninfo:
Expand All @@ -191,6 +214,17 @@ def networkdictionary():
"connection": "Connected",
"ssid": ssid,
}
# 20230601 JES
# if connected then percentage
# shoudn't be zero
# use the quality calculated before
#print("net_api.py> percentage:%s" % percentage )
#print("net_api.py> connectioninfo: %s" % connectioninfo[ssid])
if connectioninfo[ssid][4] == 0:
info[4] = qual
connectioninfo[ssid] = info
#print("net_api.py> ssid:%s percentage:%s" % (ssid, connectioninfo[ssid][4]) )

seconddictionary = {
'state': connectionstat,
'info': connectioninfo
Expand Down