feature: added realtime charts by device

This commit is contained in:
Darryl Quinn 2015-12-09 16:37:37 -06:00
parent c81127f2a4
commit dd04d3d657
1 changed files with 22 additions and 2 deletions

View File

@ -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);
}