summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--lib/network/monitor.pm13
2 files changed, 13 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index e293a62..8c433aa 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+- monitor: allow wpa_cli to report signale strength in dBm (Derek Jennings, #8228)
- drakhosts: fix translation domain (Yuri Chornoivan, mga#8629)
- fix untranslatable strings (Yuri Chornoivan, mga#8638, #8640 & #8628)
diff --git a/lib/network/monitor.pm b/lib/network/monitor.pm
index b1dc9ac..c6b60d8 100644
--- a/lib/network/monitor.pm
+++ b/lib/network/monitor.pm
@@ -32,7 +32,7 @@ sub list_wireless {
}
if ($results && $list) {
#- bssid / frequency / signal level / flags / ssid
- while ($results =~ /^((?:[0-9a-f]{2}:){5}[0-9a-f]{2})\t(\d+)\t(\d+)\t(.*?)\t(.*)$/mg) {
+ while ($results =~ /^((?:[0-9a-f]{2}:){5}[0-9a-f]{2})\t(\d+)\t(-?\d+)\t(.*?)\t(.*)$/mg) {
my ($ap, $frequency, $signal_strength, $flags, $essid) = ($1, $2, $3, $4, $5);
$networks{$ap}{ap} ||= $ap;
#- wpa_supplicant may list the network two times, use ||=
@@ -48,8 +48,19 @@ sub list_wireless {
#- this should be standardized at some point
$_->{signal_strength} = int($_->{signal_strength}/3.5)
foreach values %networks;
+ }
+# TODO - Check if all drivers now report signal strength in dBm
+ if (any { $_->{signal_strength} < 0 } values %networks) {
+ #- wpa_supplicant now reports signal in dBm
+ #- convert to % scale assuming -45 =100% -98 = 1%
+ foreach (values %networks) {
+ $_->{signal_strength} = int(100*(98+$_->{signal_strength})/53);
+ $_->{signal_strength} = 100 if $_->{signal_strength} > 100;
+ $_->{signal_strength} = 1 if $_->{signal_strength} < 1;
+ }
}
+
#- network id / ssid / bssid / flags
while ($list =~ /^(\d+)\t(.*?)\t(.*?)\t(.*)$/mg) {
foreach my $net (uniq(if_($networks{$3}, $networks{$3}), grep { $_->{essid} eq $2 } values(%networks))) {