summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Backlund <tmb@mageia.org>2013-01-24 17:41:13 +0000
committerThomas Backlund <tmb@mageia.org>2013-01-24 17:41:13 +0000
commita216a538fe68f7a2415c41081c6b8db37e35a002 (patch)
treebc1e30f080c91cf41b5d1800a74f31e29b3919bc /lib
parent93a2f2fc39888a0402b2b52c5bb54176822ce251 (diff)
downloaddrakx-net-a216a538fe68f7a2415c41081c6b8db37e35a002.tar
drakx-net-a216a538fe68f7a2415c41081c6b8db37e35a002.tar.gz
drakx-net-a216a538fe68f7a2415c41081c6b8db37e35a002.tar.bz2
drakx-net-a216a538fe68f7a2415c41081c6b8db37e35a002.tar.xz
drakx-net-a216a538fe68f7a2415c41081c6b8db37e35a002.zip
monitor: allow wpa_cli to report signale strength in dBm (Derek Jennings, #8228)
Diffstat (limited to 'lib')
-rw-r--r--lib/network/monitor.pm13
1 files changed, 12 insertions, 1 deletions
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))) {