From 26b8b15d2b2ed29b56f17d7de94019a4564f10c6 Mon Sep 17 00:00:00 2001 From: dg9vh Date: Sat, 14 May 2016 18:51:40 +0000 Subject: [PATCH] Correct Headline \(Repeater or Hotspot\), better \'last linked to\' for DMR, now shows also TGs, Config for MMDVM.ini-Filename, TNX to Tony Corbett --- config/config.php | 1 + include/functions.php | 51 ++++++++++++++++++++++++++++------------ include/repeaterinfo.php | 2 +- index.php | 8 ++++++- 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/config/config.php b/config/config.php index 9b5d550..5ff516b 100644 --- a/config/config.php +++ b/config/config.php @@ -4,6 +4,7 @@ define("MMDVMLOGPATH", "/mnt/ramdisk/"); // hint: add trailing / !!! define("MMDVMLOGPREFIX", "MMDVM"); define("MMDVMLOGFILE", MMDVMLOGPATH . MMDVMLOGPREFIX . "-" . date("Y-m-d") . ".log"); define("MMDVMINIPATH", "/etc/mmdvm/"); // hint: add trailing / !!! +define("MMDVMINIFILENAME", "MMDVM.ini"); define("MMDVMHOSTPATH", "/usr/local/bin/"); // hint: add trailing / !!! // enter exact path to your log files. diff --git a/include/functions.php b/include/functions.php index 98a35c2..0df532b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -22,7 +22,7 @@ function isProcessRunning($processname) { function getMMDVMConfig() { // loads MMDVM.ini into array for further use $mmdvmconfigs = array(); - if ($configs = fopen(MMDVMINIPATH."MMDVM.ini", 'r')) { + if ($configs = fopen(MMDVMINIPATH."/".MMDVMINIFILENAME, 'r')) { while ($config = fgets($configs)) { array_push($mmdvmconfigs, trim ( $config, " \t\n\r\0\x0B")); } @@ -337,13 +337,12 @@ function getActualLink($logLines, $mode) { case "DMR Slot 1": foreach ($logLines as $logLine) { if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 1") { - $from = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6); - if (strlen($from) == 4 && startsWith($from,"4")) { - if ($from == "4000") { - return "not linked"; - } else { - return $from; - } + $to = ""; + if (strpos($logLine,"to")) { + $to = trim(substr($logLine, strpos($logLine,"to") + 3)); + } + if ($to !== "") { + return $to; } } } @@ -352,13 +351,12 @@ function getActualLink($logLines, $mode) { case "DMR Slot 2": foreach ($logLines as $logLine) { if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 2") { - $from = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6); - if (strlen($from) == 4 && startsWith($from,"4")) { - if ($from == "4000") { - return "not linked"; - } else { - return $from; - } + $to = ""; + if (strpos($logLine,"to")) { + $to = trim(substr($logLine, strpos($logLine,"to") + 3)); + } + if ($to !== "") { + return $to; } } } @@ -368,6 +366,29 @@ function getActualLink($logLines, $mode) { return "something went wrong!"; } +function getActualReflector($logLines, $mode) { + // returns actual link state of specific mode +//M: 2016-05-02 07:04:10.504 D-Star link status set to "Verlinkt zu DCS002 S" +//M: 2016-04-03 16:16:18.638 DMR Slot 2, received network voice header from 4000 to 2625094 +//M: 2016-04-03 19:30:03.099 DMR Slot 2, received network voice header from 4020 to 2625094 + array_multisort($logLines,SORT_DESC); + + foreach ($logLines as $logLine) { + if(substr($logLine, 27, strpos($logLine,",") - 27) == "DMR Slot 2") { + $from = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6); + + if (strlen($from) == 4 && startsWith($from,"4")) { + if ($from == "4000") { + return "Reflector not linked"; + } else { + return "Reflector ".$from; + } + } + } + } + return "Reflector not linked"; +} + //Some basic inits $mmdvmconfigs = getMMDVMConfig(); $logLines = getLog(); diff --git a/include/repeaterinfo.php b/include/repeaterinfo.php index d986b7d..c6ce05b 100644 --- a/include/repeaterinfo.php +++ b/include/repeaterinfo.php @@ -15,7 +15,7 @@ echo"".getActualMode($lastHeard, $mmdvmconfigs).""; echo"".getActualLink($logLines, "D-Star").""; echo"".getActualLink($logLines, "DMR Slot 1").""; - echo"".getActualLink($logLines, "DMR Slot 2").""; + echo"".getActualLink($logLines, "DMR Slot 2")."/". getActualReflector($logLines, "DMR Slot 2") .""; echo"\n"; ?> diff --git a/index.php b/index.php index 5847d8c..cf3cc53 100644 --- a/index.php +++ b/index.php @@ -26,7 +26,13 @@ include "include/functions.php";