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,8 +28,12 @@
$_SESSION['ax1_message_text'] = $_POST['ax1_message_text'];
$_SESSION['ax1_message_path'] = $_POST['ax1_message_path'];
$_SESSION['ax1_message_destination'] = $_POST['ax1_message_destination'];
}
if ($_POST['ax2_message_text']) {
$_SESSION['ax2_message_text'] = $_POST['ax2_message_text'];
$_SESSION['ax2_message_path'] = $_POST['ax2_message_path'];
$_SESSION['ax2_message_destination'] = $_POST['ax2_message_destination'];
}
header("HTTP/1.1 303 See Other");
header("Location: http://$_SERVER[HTTP_HOST]/send_message.php");
@@ -78,6 +82,26 @@
# Wait for the changes to take effect
sleep(1);
}
else if (isset($_SESSION['ax2_message_text'])){
$ax2_message_text = $_SESSION['ax2_message_text'];
$ax2_message_path = $_SESSION['ax2_message_path'];
$ax2_message_destination = $_SESSION['ax2_message_destination'];
//echo "Send ax2: $ax2_message_text, $ax2_message_path, $ax2_message_destination";
# Send message. NOTE: send_message.sh should be executable by www-data. Also, the ax0 transmit directory should be writable by www-data
if ($ax2_message_path == "none")
$execuatable_string = sprintf("/home/marcel/ham/aprs_utils/send_message.sh -i ax2 -c \"%s\" -m \"%s\"", $ax2_message_destination, $ax2_message_text);
else
$execuatable_string = sprintf("/home/marcel/ham/aprs_utils/send_message.sh -i ax2 -c \"%s\" -p \"%s\" -m \"%s\"", $ax2_message_destination, $ax2_message_path, $ax2_message_text);
//$execuatable_string = sprintf("/home/marcel/ham/aprs_utils/send_message.sh -i ax2 -c \"%s\" -p \"%s\" -m \"%s\"", $ax2_message_destination, $ax2_message_path, $ax2_message_text);
//echo exec("/home/marcel/ham/aprs_utils/send_message.sh -i ax2 -c $ax1_message_destination -p $ax1_message_path -m $ax2_message_text");
//echo ("$execuatable_string");
exec("$execuatable_string");
# Wait for the changes to take effect
sleep(1);
}
session_unset();
session_destroy();
@@ -225,6 +249,29 @@
$ax1_message2_path = search_parameter_in_config_file("ax1_message2_path");
$ax1_message3_path = search_parameter_in_config_file("ax1_message3_path");
$ax1_message4_path = search_parameter_in_config_file("ax1_message4_path");
$ax2_name = search_parameter_in_config_file("ax2_name");
$ax2_frequency = search_parameter_in_config_file("ax2_frequency");
$ax2_message1_id = search_parameter_in_config_file("ax2_message1_id");
$ax2_message2_id = search_parameter_in_config_file("ax2_message2_id");
$ax2_message3_id = search_parameter_in_config_file("ax2_message3_id");
$ax2_message4_id = search_parameter_in_config_file("ax2_message4_id");
$ax2_message1_text = search_parameter_in_config_file("ax2_message1_text");
$ax2_message2_text = search_parameter_in_config_file("ax2_message2_text");
$ax2_message3_text = search_parameter_in_config_file("ax2_message3_text");
$ax2_message4_text = search_parameter_in_config_file("ax2_message4_text");
$ax2_message1_destination = search_parameter_in_config_file("ax2_message1_destination");
$ax2_message2_destination = search_parameter_in_config_file("ax2_message2_destination");
$ax2_message3_destination = search_parameter_in_config_file("ax2_message3_destination");
$ax2_message4_destination = search_parameter_in_config_file("ax2_message4_destination");
$ax2_message1_path = search_parameter_in_config_file("ax2_message1_path");
$ax2_message2_path = search_parameter_in_config_file("ax2_message2_path");
$ax2_message3_path = search_parameter_in_config_file("ax2_message3_path");
$ax2_message4_path = search_parameter_in_config_file("ax2_message4_path");
?>
@@ -245,6 +292,16 @@
<li onclick="openForm_ax0_message3()"><b><?php echo $ax0_message3_id; ?></b></li>
<li onclick="openForm_ax0_message4()"><b><?php echo $ax0_message4_id; ?></b></li>
</ul>
<ul>
<li><h3><?php echo $ax2_name ?> (<?php echo $ax2_frequency ?>)</h3></li>
<li onclick="openForm_ax2_message0()">Send new message</li>
<li><b>Predefined messages:</b></li>
<li onclick="openForm_ax2_message1()"><b><?php echo $ax2_message1_id; ?></b></li>
<li onclick="openForm_ax2_message2()"><b><?php echo $ax2_message2_id; ?></b></li>
<li onclick="openForm_ax2_message3()"><b><?php echo $ax2_message3_id; ?></b></li>
<li onclick="openForm_ax2_message4()"><b><?php echo $ax2_message4_id; ?></b></li>
</ul>
</div>
<div class="col-6 col-s-9" id="main_page">
@@ -298,7 +355,22 @@
?>
</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_send_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>
@@ -340,6 +412,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>
@@ -717,6 +806,188 @@
</div>
</div>
</div>
<div class="loginPopup">
<div class="formPopup" id="popupForm_ax2_message0">
<form action="" class="formContainer" method="post">
<h2>Message <?php echo $ax2_frequency ?></h2>
<label for="email">
<strong>Message</strong>
</label>
<input type="text" id="email" placeholder="Message" name="ax2_message_text" required>
<label for="psw">
<strong>Destination</strong>
</label>
<input type="text" id="email" placeholder="Destination" name="ax2_message_destination" required>
<label for="path">
<strong>Path<br></strong>
</label>
<div class="radioLeft">
<input type="radio" class="formContainer radio" id="path_none" name="ax2_message_path" value="none" checked>
<label for="path_none">none</label><br>
<input type="radio" class="formContainer radio" id="path_wide21" name="ax2_message_path" value="WIDE2-1" <?php if ($ax2_message0_path == "WIDE2-1") echo "checked"; ?> >
<label for="path_wide21">WIDE2-1</label><br>
<input type="radio" class="formContainer radio" id="path_wide22" name="ax2_message_path" value="WIDE2-2" <?php if ($ax2_message0_path == "WIDE2-2") echo "checked"; ?> >
<label for="path_wide22">WIDE2-2</label><br>
<input type="radio" class="formContainer radio" id="path_wide33" name="ax2_message_path" value="WIDE3-3" <?php if ($ax2_message0_path == "WIDE3-3") echo "checked"; ?> >
<label for="path_wide33">WIDE3-3</label><br>
</div>
<div id="submit_ax2_message0"><button type="submit" class="btn" onclick="SubmitClicked_ax2_message0()">Submit</button></div>
<div id="submit_done_ax2_message0" style="display:none;"><button type="button" class="btn wait"><img src="images/preload.gif">Please wait...</button></div>
<div id="cancel_ax2_message0"><button type="button" class="btn cancel" onclick="closeForm_ax2_message0()">Cancel</button>
</form>
</div>
</div>
</div>
<div class="loginPopup">
<div class="formPopup" id="popupForm_ax2_message1">
<form action="" class="formContainer" method="post">
<h2>Message <?php echo $ax2_frequency ?></h2>
<label for="email">
<strong>Message</strong>
</label>
<input type="text" id="email" placeholder="Message" name="ax2_message_text" value="<?php echo $ax2_message1_text; ?>" required>
<label for="psw">
<strong>Destination</strong>
</label>
<input type="text" id="email" placeholder="Destination" name="ax2_message_destination" value="<?php echo $ax2_message1_destination; ?>" required>
<label for="path">
<strong>Path<br></strong>
</label>
<div class="radioLeft">
<input type="radio" class="formContainer radio" id="path_none" name="ax2_message_path" value="none" <?php if ($ax1_message2_path == "none") echo "checked"; ?>>
<label for="path_none">none</label><br>
<input type="radio" class="formContainer radio" id="path_wide21" name="ax2_message_path" value="WIDE2-1" <?php if ($ax2_message1_path == "WIDE2-1") echo "checked"; ?> >
<label for="path_wide21">WIDE2-1</label><br>
<input type="radio" class="formContainer radio" id="path_wide22" name="ax2_message_path" value="WIDE2-2" <?php if ($ax2_message1_path == "WIDE2-2") echo "checked"; ?> >
<label for="path_wide22">WIDE2-2</label><br>
<input type="radio" class="formContainer radio" id="path_wide33" name="ax2_message_path" value="WIDE3-3" <?php if ($ax2_message1_path == "WIDE3-3") echo "checked"; ?> >
<label for="path_wide33">WIDE3-3</label><br>
</div>
<div id="submit_ax2_message1"><button type="submit" class="btn" onclick="SubmitClicked_ax2_message1()">Submit</button></div>
<div id="submit_done_ax2_message1" style="display:none;"><button type="button" class="btn wait"><img src="images/preload.gif">Please wait...</button></div>
<div id="cancel_ax2_message1"><button type="button" class="btn cancel" onclick="closeForm_ax2_message1()">Cancel</button>
</form>
</div>
</div>
</div>
<div class="loginPopup">
<div class="formPopup" id="popupForm_ax2_message2">
<form action="" class="formContainer" method="post">
<h2>Message <?php echo $ax2_frequency ?></h2>
<label for="email">
<strong>Message</strong>
</label>
<input type="text" id="email" placeholder="Message" name="ax2_message_text" value="<?php echo $ax2_message2_text; ?>" required>
<label for="psw">
<strong>Destination</strong>
</label>
<input type="text" id="email" placeholder="Destination" name="ax2_message_destination" value="<?php echo $ax2_message2_destination; ?>" required>
<label for="path">
<strong>Path<br></strong>
</label>
<div class="radioLeft">
<input type="radio" class="formContainer radio" id="path_none" name="ax2_message_path" value="none" <?php if ($ax2_message2_path == "none") echo "checked"; ?>>
<label for="path_none">none</label><br>
<input type="radio" class="formContainer radio" id="path_wide21" name="ax2_message_path" value="WIDE2-1" <?php if ($ax2_message2_path == "WIDE2-1") echo "checked"; ?> >
<label for="path_wide21">WIDE2-1</label><br>
<input type="radio" class="formContainer radio" id="path_wide22" name="ax2_message_path" value="WIDE2-2" <?php if ($ax2_message2_path == "WIDE2-2") echo "checked"; ?> >
<label for="path_wide22">WIDE2-2</label><br>
<input type="radio" class="formContainer radio" id="path_wide33" name="ax2_message_path" value="WIDE3-3" <?php if ($ax2_message2_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_message2()">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_message2()">Cancel</button>
</form>
</div>
</div>
</div>
<div class="loginPopup">
<div class="formPopup" id="popupForm_ax2_message3">
<form action="" class="formContainer" method="post">
<h2>Message <?php echo $ax2_frequency ?></h2>
<label for="email">
<strong>Message</strong>
</label>
<input type="text" id="email" placeholder="Message" name="ax2_message_text" value="<?php echo $ax2_message3_text; ?>" required>
<label for="psw">
<strong>Destination</strong>
</label>
<input type="text" id="email" placeholder="Destination" name="ax2_message_destination" value="<?php echo $ax2_message3_destination; ?>" required>
<label for="path">
<strong>Path<br></strong>
</label>
<div class="radioLeft">
<input type="radio" class="formContainer radio" id="path_none" name="ax2_message_path" value="none" <?php if ($ax2_message3_path == "none") echo "checked"; ?>>
<label for="path_none">none</label><br>
<input type="radio" class="formContainer radio" id="path_wide21" name="ax2_message_path" value="WIDE2-1" <?php if ($ax2_message3_path == "WIDE2-1") echo "checked"; ?> >
<label for="path_wide21">WIDE2-1</label><br>
<input type="radio" class="formContainer radio" id="path_wide22" name="ax2_message_path" value="WIDE2-2" <?php if ($ax2_message3_path == "WIDE2-2") echo "checked"; ?> >
<label for="path_wide22">WIDE2-2</label><br>
<input type="radio" class="formContainer radio" id="path_wide33" name="ax2_message_path" value="WIDE3-3" <?php if ($ax2_message3_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_message3()">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_message3()">Cancel</button>
</form>
</div>
</div>
</div>
<div class="loginPopup">
<div class="formPopup" id="popupForm_ax2_message4">
<form action="" class="formContainer" method="post">
<h2>Message <?php echo $ax2_frequency ?></h2>
<label for="email">
<strong>Message</strong>
</label>
<input type="text" id="email" placeholder="Message" name="ax2_message_text" value="<?php echo $ax2_message4_text; ?>" required>
<label for="psw">
<strong>Destination</strong>
</label>
<input type="text" id="email" placeholder="Destination" name="ax2_message_destination" value="<?php echo $ax2_message4_destination; ?>" required>
<label for="path">
<strong>Path<br></strong>
</label>
<div class="radioLeft">
<input type="radio" class="formContainer radio" id="path_none" name="ax2_message_path" value="none" <?php if ($ax2_message4_path == "none") echo "checked"; ?>>
<label for="path_none">none</label><br>
<input type="radio" class="formContainer radio" id="path_wide21" name="ax2_message_path" value="WIDE2-1" <?php if ($ax2_message4_path == "WIDE2-1") echo "checked"; ?> >
<label for="path_wide21">WIDE2-1</label><br>
<input type="radio" class="formContainer radio" id="path_wide22" name="ax2_message_path" value="WIDE2-2" <?php if ($ax2_message4_path == "WIDE2-2") echo "checked"; ?> >
<label for="path_wide22">WIDE2-2</label><br>
<input type="radio" class="formContainer radio" id="path_wide33" name="ax2_message_path" value="WIDE3-3" <?php if ($ax2_message4_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_message4()">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_message4()">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>
</div>
@@ -784,6 +1055,37 @@
document.getElementById("popupForm_ax1_message4").style.display = "none";
}
function openForm_ax2_message0() {
document.getElementById("popupForm_ax2_message0").style.display = "block";
}
function closeForm_ax2_message0() {
document.getElementById("popupForm_ax2_message0").style.display = "none";
}
function openForm_ax2_message1() {
document.getElementById("popupForm_ax2_message1").style.display = "block";
}
function closeForm_ax2_message1() {
document.getElementById("popupForm_ax2_message1").style.display = "none";
}
function openForm_ax2_message2() {
document.getElementById("popupForm_ax2_message2").style.display = "block";
}
function closeForm_ax2_message2() {
document.getElementById("popupForm_ax2_message2").style.display = "none";
}
function openForm_ax2_message3() {
document.getElementById("popupForm_ax2_message3").style.display = "block";
}
function closeForm_ax2_message3() {
document.getElementById("popupForm_ax2_message3").style.display = "none";
}
function openForm_ax2_message4() {
document.getElementById("popupForm_ax2_message4").style.display = "block";
}
function closeForm_ax2_message4() {
document.getElementById("popupForm_ax2_message4").style.display = "none";
}
function show_send_messages() {
document.getElementById("main_page").style.display = "none";
document.getElementById("received_messages").style.display = "none";
@@ -820,6 +1122,41 @@
modify this software provided this
notice appears on all copies.
*/
function SubmitClicked_ax2_message0()
{
document.getElementById("submit_ax2_message0").style.display = "none"; // to undisplay
document.getElementById("submit_done_ax2_message0").style.display = "block"; // to display
document.getElementById("cancel_ax2_message0").style.display = "none"; // to display
return true;
}
function SubmitClicked_ax2_message1()
{
document.getElementById("submit_ax2_message1").style.display = "none"; // to undisplay
document.getElementById("submit_done_ax2_message1").style.display = "block"; // to display
document.getElementById("cancel_ax2_message1").style.display = "none"; // to display
return true;
}function SubmitClicked_ax2_message2()
{
document.getElementById("submit_ax2_message2").style.display = "none"; // to undisplay
document.getElementById("submit_done_ax2_message2").style.display = "block"; // to display
document.getElementById("cancel_ax2_message2").style.display = "none"; // to display
return true;
}
function SubmitClicked_ax2_message3()
{
document.getElementById("submit_ax2_message3").style.display = "none"; // to undisplay
document.getElementById("submit_done_ax2_message3").style.display = "block"; // to display
document.getElementById("cancel_ax2_message3").style.display = "none"; // to display
return true;
}
function SubmitClicked_ax2_message4()
{
document.getElementById("submit_ax2_message4").style.display = "none"; // to undisplay
document.getElementById("submit_done_ax2_message4").style.display = "block"; // to display
document.getElementById("cancel_ax2_message4").style.display = "none"; // to display
return true;
}
function SubmitClicked_ax1_message0()
{
document.getElementById("submit_ax1_message0").style.display = "none"; // to undisplay