LoRa radio can be controlled via command line and web interface

This commit is contained in:
2022-01-31 17:10:42 +01:00
parent e2b8a4b085
commit 1eea07e765
11 changed files with 668 additions and 16 deletions

View File

@@ -28,6 +28,11 @@
$_SESSION['period_ax1'] = $_POST['period_ax1'];
$_SESSION['path_ax1'] = $_POST['path_ax1'];
}
if ($_POST['comment_ax2']) {
$_SESSION['comment_ax2'] = $_POST['comment_ax2'];
$_SESSION['period_ax2'] = $_POST['period_ax2'];
$_SESSION['path_ax2'] = $_POST['path_ax2'];
}
header("HTTP/1.1 303 See Other");
header("Location: http://$_SERVER[HTTP_HOST]/index.php");
@@ -54,7 +59,15 @@
# Wait for the changes to take effect
sleep(1);
}
else if (isset($_SESSION['comment_ax2'])){
$comment_ax2 = $_SESSION['comment_ax2'];
$period_ax2 = $_SESSION['period_ax2'];
$path_ax2 = $_SESSION['path_ax2'];
//echo "Set ax2: $comment_ax2, $period_ax2, $path_ax2";
save_settings("ax2", $period_ax2, 0, $path_ax2, 0, $comment_ax2);
# Wait for the changes to take effect
sleep(1);
}
session_unset();
session_destroy();
@@ -124,6 +137,11 @@
if ($c) change_parameter_value("ax1_beacon_path", $c);
if ($e) change_parameter_value("ax1_beacon_comment", $e);
}
else if ($form == "ax2" ) {
change_parameter_value("ax2_beacon_time", $a);
if ($c) change_parameter_value("ax2_beacon_path", $c);
if ($e) change_parameter_value("ax2_beacon_comment", $e);
}
# now make new file with new configuration for the main loop to find.
shell_exec("cp $destination_config_file $newly_made_config_file");
@@ -168,6 +186,12 @@
$ax1_beacon_time = search_parameter_in_config_file("ax1_beacon_time");
$ax1_beacon_path = search_parameter_in_config_file("ax1_beacon_path");
$ax2_name = search_parameter_in_config_file("ax2_name");
$ax2_frequency = search_parameter_in_config_file("ax2_frequency");
$ax2_beacon_comment = search_parameter_in_config_file("ax2_beacon_comment");
$ax2_beacon_time = search_parameter_in_config_file("ax2_beacon_time");
$ax2_beacon_path = search_parameter_in_config_file("ax2_beacon_path");
?>
<div class="header">
@@ -184,6 +208,13 @@
<li onclick="openForm_ax0()">Beacon interval: <b><?php if ($ax0_beacon_time == 0) echo "OFF";else echo $ax0_beacon_time; ?></b></li>
<li onclick="openForm_ax0()">Path: <b><?php echo $ax0_beacon_path; ?></b></li>
</ul>
<ul>
<li><h3><?php echo $ax2_name ?> (<?php echo $ax2_frequency ?>)</h3></li>
<li onclick="openForm_ax2()">Beacon: <b><?php echo $ax2_beacon_comment; ?></b></li>
<li onclick="openForm_ax2()">Beacon interval: <b><?php if ($ax2_beacon_time == 0) echo "OFF";else echo $ax2_beacon_time; ?></b></li>
<li onclick="openForm_ax2()">Path: <b><?php echo $ax2_beacon_path; ?></b></li>
</ul>
</div>
<div class="col-6 col-s-9" id="main_page">
@@ -213,7 +244,7 @@
<h1>Heard last 24 hours</h1>
<div class="col-6 col-s-12">
<div class="col-4 col-s-12">
<h1><?php echo $ax0_frequency ?></h1>
<h3 align="center">
<b style="color:Blue">DIRECT</b><br><br>
@@ -240,7 +271,7 @@
</h3>
</div>
<div class="col-6 col-s-12">
<div class="col-4 col-s-12">
<h1><?php echo $ax1_frequency ?></h1>
<h3 align="center">
<b style="color:Blue">DIRECT</b><br><br>
@@ -266,6 +297,34 @@
?>
</h3>
</div>
<div class="col-4 col-s-12">
<h1><?php echo $ax2_frequency ?></h1>
<h3 align="center">
<b style="color:Blue">DIRECT</b><br><br>
<?php
$csv = array_map('str_getcsv', file("/home/marcel/ham/aprs_utils/aprs_log/aprs_stations_heard_direct.log"));
for ($i = 0; $i < count($csv); $i++) {
if ($csv[$i][1] == "ax2") {
echo $csv[$i][2];
echo "<br>";
}
}
echo "<br><b style=\"color:Blue\">DIGIPEATED</b><br><br>";
$csv = array_map('str_getcsv', file("/home/marcel/ham/aprs_utils/aprs_log/aprs_stations_heard_digipeated.log"));
for ($i = 0; $i < count($csv); $i++) {
if ($csv[$i][1] == "ax2") {
echo $csv[$i][2];
echo "<br>";
}
}
?>
</h3>
</div>
<a href=""><h1 style="color:Black;" onclick="show_main_page()"><i class="fa fa-arrow-left" aria-hidden="true"></i>&nbsp; Back</h1></a>
</div>
@@ -310,6 +369,23 @@
?>
</h3>
<h2 align="left"><?php echo $ax2_name ?> (<?php echo $ax2_frequency ?>)</h2>
<h3 align="left">
<?php
$csv = array_map('str_getcsv', file("/home/marcel/ham/aprs_utils/aprs_log/aprs_received_messages.log"));
for ($i = 0; $i < count($csv); $i++) {
if ($csv[$i][1] == "ax2") {
echo $csv[$i][2];
echo ": ";
echo $csv[$i][4];
echo "<br>";
}
}
?>
</h3>
<a href=""><h1 style="color:Black;" onclick="show_main_page()"><i class="fa fa-arrow-left" aria-hidden="true"></i>&nbsp; Back</h1></a>
</div>
@@ -391,6 +467,39 @@
</form>
</div>
</div>
<div class="loginPopup">
<div class="formPopup" id="popup_ax2_beacon">
<form action="" class="formContainer" method="post">
<h2>Beacon <?php echo $ax2_frequency ?></h2>
<label for="email">
<strong>Comment</strong>
</label>
<input type="text" id="email" placeholder="comment" name="comment_ax2" value="<?php echo $ax2_beacon_comment; ?>" required>
<label for="psw">
<strong>Period</strong>
</label>
<input type="number" id="psw" placeholder="Period" name="period_ax2" min="0" max="60" step="10" value="<?php echo $ax2_beacon_time; ?>" required>
<label for="path">
<strong>Path<br></strong>
</label>
<div class="radioLeft">
<input type="radio" class="formContainer radio" id="path_none" name="path_ax2" value="none"<?php if ($ax2_beacon_path == "none") echo "checked"; ?>>
<label for="path_none">none</label><br>
<input type="radio" class="formContainer radio" id="path_wide21" name="path_ax2" value="WIDE2-1" <?php if ($ax2_beacon_path == "WIDE2-1") echo "checked"; ?> >
<label for="path_wide21">WIDE2-1</label><br>
<input type="radio" class="formContainer radio" id="path_wide22" name="path_ax2" value="WIDE2-2" <?php if ($ax2_beacon_path == "WIDE2-2") echo "checked"; ?> >
<label for="path_wide22">WIDE2-2</label><br>
<input type="radio" class="formContainer radio" id="path_wide33" name="path_ax2" value="WIDE3-3" <?php if ($ax2_beacon_path == "WIDE3-3") echo "checked"; ?> >
<label for="path_wide33">WIDE3-3</label><br>
</div>
<div id="submit_ax2"><button type="submit" class="btn" onclick="SubmitClicked_ax2()">Submit</button></div>
<div id="submit_done_ax2" style="display:none;"><button type="button" class="btn wait"><img src="images/preload.gif">Please wait...</button></div>
<div id="cancel_ax2"><button type="button" class="btn cancel" onclick="closeForm_ax2()">Cancel</button>
</form>
</div>
</div>
</div>
<div class="footer">
<p>Open source hardware and software. Visit https://www.meezenest.nl/mees for more information.</p>
@@ -409,6 +518,12 @@
function closeForm_ax1() {
document.getElementById("popup_ax1_beacon").style.display = "none";
}
function openForm_ax2() {
document.getElementById("popup_ax2_beacon").style.display = "block";
}
function closeForm_ax2() {
document.getElementById("popup_ax2_beacon").style.display = "none";
}
function show_heard_stations() {
document.getElementById("main_page").style.display = "none";
@@ -446,6 +561,14 @@
modify this software provided this
notice appears on all copies.
*/
function SubmitClicked_ax2()
{
document.getElementById("submit_ax2").style.display = "none"; // to undisplay
document.getElementById("submit_done_ax2").style.display = "block"; // to display
document.getElementById("cancel_ax2").style.display = "none"; // to display
return true;
}
function SubmitClicked_ax1()
{
document.getElementById("submit_ax1").style.display = "none"; // to undisplay
@@ -453,6 +576,7 @@
document.getElementById("cancel_ax1").style.display = "none"; // to display
return true;
}
function SubmitClicked_ax0()
{