2013-11-14 23:11:16 -07:00
|
|
|
#!/usr/bin/perl
|
2015-01-18 12:36:49 -07:00
|
|
|
=for commnet
|
|
|
|
|
2015-03-09 17:39:04 -06:00
|
|
|
Part of AREDN -- Used for creating Amateur Radio Emergency Data Networks
|
2015-12-10 10:14:43 -07:00
|
|
|
Copyright (C) 2015 Darryl Quinn
|
2015-01-18 12:36:49 -07:00
|
|
|
See Contributors file for additional contributors
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation version 3 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-03-09 17:39:04 -06:00
|
|
|
Additional Terms:
|
|
|
|
|
|
|
|
Additional use restrictions exist on the AREDN(TM) trademark and logo.
|
|
|
|
See AREDNLicense.txt for more info.
|
|
|
|
|
|
|
|
Attributions to the AREDN Project must be retained in the source code.
|
|
|
|
If importing this code into a new or existing project attribution
|
|
|
|
to the AREDN project must be added to the source code.
|
|
|
|
|
|
|
|
You must not misrepresent the origin of the material conained within.
|
|
|
|
|
|
|
|
Modified versions must be modified to attribute to the original source
|
|
|
|
and be marked in reasonable ways as differentiate it from the original
|
|
|
|
version.
|
2015-01-18 12:36:49 -07:00
|
|
|
=cut
|
2013-11-14 23:11:16 -07:00
|
|
|
|
|
|
|
$debug = 0;
|
|
|
|
|
2013-12-02 13:04:54 -07:00
|
|
|
BEGIN {push @INC, '/www/cgi-bin'};
|
2013-11-14 23:11:16 -07:00
|
|
|
use perlfunc;
|
|
|
|
|
2015-12-15 23:45:29 -07:00
|
|
|
chomp ($tzone=`date +%Z`);
|
2015-12-10 10:14:43 -07:00
|
|
|
read_query_string();
|
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
# collect some variables
|
|
|
|
$node = nvram_get("node");
|
|
|
|
$node = "NOCALL" unless $node;
|
|
|
|
|
2015-12-10 10:14:43 -07:00
|
|
|
if($parms{"realtime"} )
|
2013-11-14 23:11:16 -07:00
|
|
|
{
|
2015-12-10 10:14:43 -07:00
|
|
|
$dmode="Realtime";
|
|
|
|
} else {
|
|
|
|
$dmode="Archived";
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
|
2015-12-10 10:14:43 -07:00
|
|
|
http_header();
|
|
|
|
html_header("$node $dmode signal strength", 0);
|
|
|
|
|
|
|
|
$header = <<EOF;
|
|
|
|
<script src="/js/jquery-2.1.4.min.js"></script>
|
|
|
|
<script src="/js/jquery.canvasjs.min.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var dps=[[{"label":"Init","y":-95}],[{"label":"Init","y":-95}]];
|
|
|
|
|
|
|
|
// Read a page's GET URL variables and return them as an associative array.
|
|
|
|
function getUrlVars()
|
2013-11-14 23:11:16 -07:00
|
|
|
{
|
2015-12-10 10:14:43 -07:00
|
|
|
var vars = [], hash;
|
|
|
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
|
|
|
for(var i = 0; i < hashes.length; i++)
|
|
|
|
{
|
|
|
|
hash = hashes[i].split('=');
|
|
|
|
vars.push(hash[0]);
|
|
|
|
vars[hash[0]] = hash[1];
|
|
|
|
}
|
|
|
|
return vars;
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
|
2015-12-10 10:14:43 -07:00
|
|
|
\$(document).ready(function () {
|
|
|
|
var MAXPOINTS=10;
|
|
|
|
var chart = new CanvasJS.Chart("chartContainer", {
|
|
|
|
zoomEnabled: true,
|
2016-01-19 18:58:00 -07:00
|
|
|
zoomType: "xy",
|
2016-01-19 18:39:31 -07:00
|
|
|
exportEnabled: true,
|
2015-12-10 10:14:43 -07:00
|
|
|
backgroundColor: "#E7E7E7",
|
|
|
|
title: {
|
|
|
|
text: "$dmode Signal to Noise"
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
horizontalAlign: "right", // left, center ,right
|
|
|
|
verticalAlign: "center", // top, center, bottom
|
|
|
|
},
|
|
|
|
axisX: {
|
2015-12-15 23:45:29 -07:00
|
|
|
title: "Time (in $tzone)",
|
2015-12-10 10:14:43 -07:00
|
|
|
labelFontSize: 10,
|
|
|
|
labelAngle: -45,
|
|
|
|
},
|
|
|
|
axisY: {
|
2015-12-10 23:35:37 -07:00
|
|
|
title: "dBm",
|
2015-12-10 10:14:43 -07:00
|
|
|
interlacedColor: "#F0F8FF",
|
|
|
|
},
|
|
|
|
data: [
|
|
|
|
{
|
2016-01-05 21:12:24 -07:00
|
|
|
type: "spline",
|
2015-12-10 10:14:43 -07:00
|
|
|
showInLegend: true,
|
|
|
|
legendText: "Signal",
|
2015-12-15 23:45:29 -07:00
|
|
|
toolTipContent: "Signal: {y}dBm @ {label}",
|
2015-12-10 10:14:43 -07:00
|
|
|
dataPoints: dps[0]
|
|
|
|
},{
|
|
|
|
type: "line",
|
|
|
|
showInLegend: true,
|
|
|
|
legendText: "Noise",
|
2015-12-15 23:45:29 -07:00
|
|
|
toolTipContent: "Noise: {y}dBm @ {label}",
|
2015-12-10 10:14:43 -07:00
|
|
|
dataPoints: dps[1]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
}); // --- chart
|
|
|
|
|
|
|
|
var updateArchiveChart = function () {
|
|
|
|
\$.getJSON("/cgi-bin/signal.json?device=$parms{device}", function (result) {
|
|
|
|
chart.options.data[0].dataPoints = result[0];
|
|
|
|
chart.options.data[1].dataPoints = result[1];
|
|
|
|
chart.render();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var updateRealtimeChart = function () {
|
|
|
|
\$.getJSON("/cgi-bin/signal.json?realtime=1&device=$parms{device}", function (result) {
|
|
|
|
dps[0].push(result[0][0]);
|
|
|
|
dps[1].push(result[1][0]);
|
|
|
|
chart.render();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var dmode = getUrlVars()["realtime"];
|
|
|
|
|
|
|
|
if(dmode) {
|
|
|
|
updateRealtimeChart();
|
|
|
|
setInterval(function() {updateRealtimeChart()}, 1000);
|
|
|
|
} else {
|
|
|
|
updateArchiveChart();
|
|
|
|
setInterval(function() {updateArchiveChart()}, 60000);
|
|
|
|
}
|
|
|
|
chart.render();
|
|
|
|
}); // --- document.ready
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
$page = <<EOF;
|
|
|
|
<body>
|
|
|
|
<center>
|
|
|
|
<div class="TopBanner">
|
|
|
|
<div class="LogoDiv"><img src="/AREDN.png" class="AREDNLogo"></img></div>
|
|
|
|
</div>
|
|
|
|
<h1><big>$node</big></h1><hr>
|
|
|
|
<nobr>
|
2015-12-11 16:10:57 -07:00
|
|
|
<button onclick="window.location.href='/cgi-bin/signal'">Archive</button>
|
|
|
|
<button onclick="window.location.href='/cgi-bin/signal?realtime=1'">Realtime</button>
|
|
|
|
<button onclick="window.location.href='/cgi-bin/status'">Quit</button>
|
|
|
|
<br />
|
2015-12-10 10:14:43 -07:00
|
|
|
<div id="deviceSelector">
|
|
|
|
<form name="deviceSelector" method="GET" action="/cgi-bin/signal">
|
|
|
|
Selected Device: <select name="device" onChange="this.form.submit();">
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# get a list of files from /tmp/snrlog
|
|
|
|
my @files = `ls -1A /tmp/snrlog`;
|
|
|
|
$parms{device}="" if(!/$parms{device}/ ~~ @files);
|
|
|
|
|
2016-01-09 21:55:53 -07:00
|
|
|
# default to "Strongest Signal" for Realtime
|
|
|
|
if(! $parms{device} and $parms{realtime}) {
|
2015-12-10 10:14:43 -07:00
|
|
|
$page = $page . "<option selected value='strongest'>Strongest Signal</option>";
|
2016-01-09 21:55:53 -07:00
|
|
|
}
|
2015-12-10 10:14:43 -07:00
|
|
|
|
2016-01-09 21:55:53 -07:00
|
|
|
$firstSel=1;
|
2015-12-10 10:14:43 -07:00
|
|
|
# iterate over each file
|
|
|
|
foreach $logfile (@files)
|
2013-11-14 23:11:16 -07:00
|
|
|
{
|
2015-12-10 10:14:43 -07:00
|
|
|
chomp($logfile);
|
|
|
|
my ($dmac, $dname) = $logfile =~ /^(.*?)\-(.*)/;
|
2016-01-09 21:55:53 -07:00
|
|
|
$dname=$dmac if($dname eq '');
|
|
|
|
if($parms{device} eq $logfile or (!$parms{realtime} and $firstSel)) {
|
2015-12-10 10:14:43 -07:00
|
|
|
$page = $page . "<option selected value='$logfile'>$dname</option>\n";
|
2016-01-09 21:55:53 -07:00
|
|
|
$firstSel=0;
|
2015-12-10 10:14:43 -07:00
|
|
|
} else {
|
|
|
|
$page = $page . "<option value='$logfile'>$dname</option>\n";
|
|
|
|
}
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|
|
|
|
|
2015-12-10 10:14:43 -07:00
|
|
|
$page = $page . "</select>\n";
|
|
|
|
$page = $page . "<input type='hidden' name='realtime' value='1'></input>\n" if($parms{realtime} eq "1");
|
|
|
|
$page = $page . <<EOF;
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div id="chartContainer" style="width: 800px; height: 380px;"></div>
|
|
|
|
</center>
|
|
|
|
EOF
|
|
|
|
|
|
|
|
print $header;
|
|
|
|
print $page;
|
2013-11-14 23:11:16 -07:00
|
|
|
show_debug_info();
|
2015-12-10 10:14:43 -07:00
|
|
|
print "</body></html>";
|
2013-11-14 23:11:16 -07:00
|
|
|
|
2015-12-10 10:14:43 -07:00
|
|
|
sub DEBUGEXIT()
|
|
|
|
{
|
|
|
|
my ($text) = @_;
|
|
|
|
http_header();
|
|
|
|
html_header("$node setup", 1);
|
|
|
|
print "DEBUG-";
|
|
|
|
print $text;
|
|
|
|
print "</body>";
|
|
|
|
exit;
|
|
|
|
}
|