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"