From dd04d3d657a0694c3125fa99a930268e0d3473ad Mon Sep 17 00:00:00 2001 From: Darryl Quinn Date: Wed, 9 Dec 2015 16:37:37 -0600 Subject: [PATCH] feature: added realtime charts by device --- files/www/cgi-bin/signal2.json | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/files/www/cgi-bin/signal2.json b/files/www/cgi-bin/signal2.json index 147003ff..be977920 100755 --- a/files/www/cgi-bin/signal2.json +++ b/files/www/cgi-bin/signal2.json @@ -55,9 +55,12 @@ if($parms{"realtime"}) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); $d = sprintf ("%02d:%02d:%02d", $hour, $min, $sec); - #if($parms{device} eq '') { + if($parms{device} eq '' or $parms{device} eq 'strongest') { ($s, $n) = get_wifi_signal(get_interface("wifi")); - #} + } else { + my ($dmac, $dname) = $parms{device} =~ /^(.*?)\-(.*)/; + ($s, $n) = get_realtime_signal($dmac); + } $sjson= sprintf("{\"label\":\"%s\",\"y\":%s}",$d,$s); $njson= sprintf("{\"label\":\"%s\",\"y\":%s}",$d,$n); @@ -108,3 +111,20 @@ sub json_header print "Cache-Control: no-store\r\n"; print "\r\n"; } + +sub get_realtime_signal() +{ + my $s, $n; + my ($var) = @_; + return ("-1","-1") if not defined $var; + if (-d "/sys/kernel/debug/ieee80211/phy0/netdev:wlan0/stations/$var") { + $test="GOOD DIR"; + chomp($s = `cat /sys/kernel/debug/ieee80211/phy0/netdev:wlan0/stations/$var/last_signal`); + } else { + $test="BAD DIR"; + #return ("-2","-2"); + return ($var, $test); + } + ($junk, $n) = get_wifi_signal(get_interface("wifi")); + return ($s, $n); +} \ No newline at end of file