show DMR Master-state with label, green=connected, red=not connected to master

This commit is contained in:
dg9vh 2016-10-25 13:54:03 +00:00
parent 0ee265c647
commit 148b65bb09
3 changed files with 34 additions and 2 deletions

View file

@ -38,6 +38,31 @@ function getFirmwareVersion() {
echo $firmware;
}
function getDMRMasterState() {
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
$logLines = explode("\n", `egrep -h "(DMR, Logged into the master successfully)|(DMR, Closing DMR Network)" $logPath`);
$state = -1;
foreach($logLines as $logLine) {
if (strpos($logLine, "successfully") > 0) {
$state = 1;
}
if (strpos($logLine, "Closing") > 0) {
$state = 0;
}
}
if ($state >= 0) {
$fp = fopen('/tmp/DMRMasterState.txt', 'w');
fwrite($fp, $state);
fclose($fp);
} else {
$fp = fopen('/tmp/DMRMasterState.txt', 'r');
$contents = fread($fp, filesize("/tmp/DMRMasterState.txt"));
$state = $contents;
}
return $state;
}
function getMMDVMConfig() {
// loads MMDVM.ini into array for further use
$conf = array();

View file

@ -58,8 +58,15 @@
if (getEnabled("DMR", $mmdvmconfigs) == 1) {
echo"<td>".getConfigItem("DMR", "ColorCode", $mmdvmconfigs)."</td>";
if (getEnabled("DMR Network", $mmdvmconfigs) == 1) {
echo"<td>".getConfigItem("DMR Network", "Address", $mmdvmconfigs)."</td>";
echo"<td>";
if (getDMRMasterState()) {
echo "<span class=\"label label-success\">";
} else {
echo "<span class=\"label label-danger\">";
}
echo getConfigItem("DMR Network", "Address", $mmdvmconfigs)."</td>";
?>
</span>
<td><span class="label <?php
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == 1) {
echo 'label-success">enabled';

View file

@ -1,3 +1,3 @@
<?php
define("VERSION", "20161024-1");
define("VERSION", "20161025-1");
?>