show DMR Master-state with label, green=connected, red=not connected to master
This commit is contained in:
parent
0ee265c647
commit
148b65bb09
3 changed files with 34 additions and 2 deletions
|
@ -38,6 +38,31 @@ function getFirmwareVersion() {
|
||||||
echo $firmware;
|
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() {
|
function getMMDVMConfig() {
|
||||||
// loads MMDVM.ini into array for further use
|
// loads MMDVM.ini into array for further use
|
||||||
$conf = array();
|
$conf = array();
|
||||||
|
|
|
@ -58,8 +58,15 @@
|
||||||
if (getEnabled("DMR", $mmdvmconfigs) == 1) {
|
if (getEnabled("DMR", $mmdvmconfigs) == 1) {
|
||||||
echo"<td>".getConfigItem("DMR", "ColorCode", $mmdvmconfigs)."</td>";
|
echo"<td>".getConfigItem("DMR", "ColorCode", $mmdvmconfigs)."</td>";
|
||||||
if (getEnabled("DMR Network", $mmdvmconfigs) == 1) {
|
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
|
<td><span class="label <?php
|
||||||
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == 1) {
|
if (getConfigItem("DMR Network", "Slot1", $mmdvmconfigs) == 1) {
|
||||||
echo 'label-success">enabled';
|
echo 'label-success">enabled';
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
define("VERSION", "20161024-1");
|
define("VERSION", "20161025-1");
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue