first test of talker alias

This commit is contained in:
dg9vh 2017-02-13 20:48:20 +00:00
parent c560baacce
commit 745f317d3d
5 changed files with 95 additions and 5 deletions

View file

@ -19,9 +19,32 @@ if ($_GET['section'] == "mode") {
echo $mode;
}
if ($_GET['section'] == "lastHeard") {
$lastHeard = getLastHeard($reverseLogLinesMMDVM, FALSE);
$lastHeardList = getLastHeard($reverseLogLinesMMDVM, FALSE);
$lastHeard = Array();
for ($i = 0; $i < count($lastHeardList); $i++) {
$listElem = $lastHeardList[$i];
// Generate a canonicalized call for QRZ and name lookups
$call_canon = preg_replace('/\s+\w$/', '', $listElem[2]);
if (defined("ENABLEXTDLOOKUP")) {
$listElem[11] ="";
array_push($lastHeard, $listElem);
} else {
$listElem[10] ="";
array_push($lastHeard, $listElem);
}
}
echo '{"data": '.json_encode($lastHeard)."}";
}
/*
for ($i = 0; $i < count($localTXList); $i++) {
$listElem = $localTXList[$i];
if (defined("ENABLEXTDLOOKUP")) {
$listElem[11] ="";
} else {
$listElem[10] ="";
}
echo '{"data": '.json_encode($lastHeard)."}";
}*/
if ($_GET['section'] == "localTx") {
$localTXList = getHeardList($reverseLogLinesMMDVM, FALSE);
$lastHeard = Array();
@ -30,6 +53,7 @@ if ($_GET['section'] == "localTx") {
// Generate a canonicalized call for QRZ and name lookups
$call_canon = preg_replace('/\s+\w$/', '', $listElem[2]);
if (defined("ENABLEXTDLOOKUP")) {
$listElem[11] ="";
if ($listElem[6] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF" || $listElem[1]=="P25")) {
$listElem[3] = getName($call_canon);
if ($listElem[2] !== "??????????") {
@ -46,6 +70,7 @@ if ($_GET['section'] == "localTx") {
array_push($lastHeard, $listElem);
}
} else {
$listElem[10] ="";
if ($listElem[5] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF" || $listElem[1]=="P25")) {
if ($listElem[2] !== "??????????") {
if (!is_numeric($listElem[2])) {

View file

@ -189,14 +189,14 @@ function getMMDVMLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
//$logLines = explode("\n", `grep M: $logPath`);
$logLines = explode("\n", `egrep -h "from|end|watchdog|lost" $logPath`);
$logLines = explode("\n", `egrep -h "from|end|watchdog|lost|Alias|0000" $logPath`);
return $logLines;
}
function getShortMMDVMLog() {
// Open Logfile and copy loglines into LogLines-Array()
$logPath = MMDVMLOGPATH."/".MMDVMLOGPREFIX."-".date("Y-m-d").".log";
$logLines = explode("\n", `egrep -h "from|end|watchdog|lost" $logPath | tail -100`);
$logLines = explode("\n", `egrep -h "from|end|watchdog|lost|Alias|0000" $logPath | tail -100`);
return $logLines;
}
@ -214,16 +214,23 @@ function getYSFGatewayLog() {
// M: 2016-04-29 19:43:21.839 DMR Slot 2, received network voice header from DL1ESZ to TG 9
// M: 2016-04-30 14:57:43.072 DMR Slot 2, received RF voice header from DG9VH to 5000
// M: 2016-09-16 09:14:12.886 P25, received RF from DF2ET to TG10100
// M: 2017-02-13 15:53:30.990 DMR Slot 2, Embedded Talker Alias Header
// M: 2017-02-13 15:53:30.991 0000: 04 00 5E 49 57 38 44 59 94 *..^IW8DY.*
// M: 2017-02-13 15:53:31.252 DMR Slot 2, Embedded Talker Alias Block 1
// M: 2017-02-13 15:53:31.253 0000: 05 00 20 47 69 6F 76 61 DC *.. Giova.*
function getHeardList($logLines, $onlyLast) {
$heardList = array();
$ts1duration = "";
$ts1loss = "";
$ts1ber = "";
$ts1rssi = "";
$ts1alias = "---";
$ts2duration = "";
$ts2loss = "";
$ts2ber = "";
$ts2rssi = "";
$ts2alias = "---";
$dstarduration = "";
$dstarloss = "";
$dstarber = "";
@ -232,7 +239,10 @@ function getHeardList($logLines, $onlyLast) {
$ysfloss = "";
$ysfber = "";
$ysfrssi = "";
$alias = "";
foreach ($logLines as $logLine) {
//echo $logLine;
$duration = "";
$loss = "";
$ber = "";
@ -251,6 +261,24 @@ function getHeardList($logLines, $onlyLast) {
} else if(strpos($logLine,"bad LC received")) {
continue;
}
//$alias = substr($logLine, 27, 5);
if(strpos($logLine, "0000") > 0){
$decodedAlias = decodeAlias($logLine);
if ($alias =="")
$alias =$decodedAlias;
else
$alias =$decodedAlias.$alias;
}
if (strpos($logLine,"Embedded Talker Alias")) {
switch (substr($logLine, 27, strpos($logLine,",") - 27)) {
case "DMR Slot 1":
$ts1alias = $alias;
break;
case "DMR Slot 2":
$ts2alias = $alias;
break;
}
}
if(strpos($logLine,"end of") || strpos($logLine,"watchdog has expired") || strpos($logLine,"ended RF data") || strpos($logLine,"ended network") || strpos($logLine,"transmission lost")) {
$lineTokens = explode(", ",$logLine);
@ -400,12 +428,14 @@ function getHeardList($logLines, $onlyLast) {
$loss = $ts1loss;
$ber = $ts1ber;
$rssi = $ts1rssi;
$alias = $ts1alias;
break;
case "DMR Slot 2":
$duration = $ts2duration;
$loss = $ts2loss;
$ber = $ts2ber;
$rssi = $ts2rssi;
$alias = $ts2alias;
break;
case "YSF":
$duration = $ysfduration;
@ -425,14 +455,18 @@ function getHeardList($logLines, $onlyLast) {
if ( strlen($callsign) < 11 ) {
$name = "";
if (defined("ENABLEXTDLOOKUP")) {
array_push($heardList, array(convertTimezone($timestamp), $mode, $callsign, $name, $id, $target, $source, $duration, $loss, $ber, $rssi));
array_push($heardList, array(convertTimezone($timestamp), $mode, $callsign, $name, $id, $target, $source, $duration, $loss, $ber, $rssi, $alias));
$alias = "";
} else {
array_push($heardList, array(convertTimezone($timestamp), $mode, $callsign, $id, $target, $source, $duration, $loss, $ber, $rssi));
array_push($heardList, array(convertTimezone($timestamp), $mode, $callsign, $id, $target, $source, $duration, $loss, $ber, $rssi, $alias));
$alias = "";
}
$duration = "";
$loss ="";
$ber = "";
$rssi = "";
$ts1alias = "---";
$ts2alias = "---";
if ($onlyLast && count($heardList )> 4) {
return $heardList;
}
@ -770,4 +804,18 @@ function getName($callsign) {
}
}
// 00000000001111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000111111111122
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901
// M: 2017-02-13 15:53:30.991 0000: 04 00 5E 49 57 38 44 59 94 *..^IW8DY.*
// M: 2017-02-13 15:53:31.253 0000: 05 00 20 47 69 6F 76 61 DC *.. Giova.*
function decodeAlias($logLine) {
$tok1 = encode(substr($logLine, 40, 2));
$tok2 = encode(substr($logLine, 43, 2));
$tok3 = encode(substr($logLine, 46, 2));
$tok4 = encode(substr($logLine, 49, 2));
$tok5 = encode(substr($logLine, 52, 2));
$tok6 = encode(substr($logLine, 55, 2));
$tok7 = encode(dechex(hexdec(substr($logLine, 58, 2))/2));
return $tok1.$tok2.$tok3.$tok4.$tok5.$tok6.$tok7;
}
?>

View file

@ -112,4 +112,15 @@ function convertTimezone($timestamp) {
$date->setTimezone(new DateTimeZone(TIMEZONE));
return $date->format('Y-m-d H:i:s');
}
function encode($hex) {
$validchars = " abcdefghijklmnopqrstuvwxyzäöüßABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜ0123456789";
$str = '';
$chrval = hexdec(substr($hex,$i,2));
$str = chr($chrval);
if (strpos($validchars, $str)>=0)
return $str;
else
return "";
}
?>

View file

@ -16,6 +16,7 @@
<?php
}
?>
<th>Talker Alias</th>
<th>DSTAR-ID</th>
<th>Target</th>
<th>Source</th>

View file

@ -21,6 +21,9 @@ echo"-->";
$counter = 0;
foreach ($lastHeard as $listElem) {
$counter +=1;
echo"<!--";
var_dump($listElem);
echo"-->";
if (defined("ENABLEXTDLOOKUP") && $listElem[7] == null || !defined("ENABLEXTDLOOKUP") && $listElem[6] == null) {
echo "<tr>";
echo"<td nowrap>$listElem[0]</td>";
@ -41,6 +44,7 @@ foreach ($lastHeard as $listElem) {
if (defined("ENABLEXTDLOOKUP")) {
//echo "<td nowrap>".getName($listElem[2])."</td>";
echo"<td nowrap>$listElem[3]</td>";
echo"<td nowrap>$listElem[11]</td>";
echo"<td nowrap>$listElem[4]</td>";
echo"<td nowrap>$listElem[5]</td>";
if ($listElem[6] == "RF"){
@ -53,6 +57,7 @@ foreach ($lastHeard as $listElem) {
$diff = $d2->getTimestamp() - $d1->getTimestamp();
echo"<td nowrap>$diff s</td>";
} else {
echo"<td nowrap>$listElem[10]</td>";
echo"<td nowrap>$listElem[3]</td>";
echo"<td nowrap>$listElem[4]</td>";
if ($listElem[5] == "RF"){