Skip to content

Commit

Permalink
Add acarsdec and vdlm2dec JSON support over UDP
Browse files Browse the repository at this point in the history
  • Loading branch information
Ysurac committed Feb 17, 2018
1 parent c9fe9aa commit e662370
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 4 additions & 2 deletions install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@
<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec</option>
<option value="acarsjson" <?php if (isset($source['format']) && $source['format'] == 'acarsjson') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec</option>
<option value="acarsjsonudp" <?php if (isset($source['format']) && $source['format'] == 'acarsjsonudp') print 'selected'; ?>>ACARS from acarsdec json and vdlm2dec over UDP</option>
<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
Expand Down Expand Up @@ -677,7 +678,8 @@
<option value="flightgearsp">FlightGear Singleplayer</option>
<option value="acars">ACARS from acarsdec/acarsdeco2 over UDP</option>
<option value="acarssbs3">ACARS SBS-3 over TCP</option>
<option value="acarsjson">ACARS from acarsdec json and vdlm2dec</option>
<option value="acarsjson">ACARS from acarsdec json and vdlm2dec</option>
<option value="acarsjsonudp">ACARS from acarsdec json and vdlm2dec over UDP</option>
<option value="ais">NMEA AIS over TCP</option>
<option value="airwhere">AirWhere website</option>
<option value="hidnseek_callback">HidnSeek Callback</option>
Expand Down
17 changes: 14 additions & 3 deletions scripts/daemon-spotter.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function connect_all($hosts) {
if ($globalDebug) echo 'Connect to all...'."\n";
foreach ($hosts as $id => $value) {
$host = $value['host'];
$udp = false;
$globalSources[$id]['last_exec'] = 0;
// Here we check type of source(s)
if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
Expand Down Expand Up @@ -291,9 +292,10 @@ function connect_all($hosts) {
$hostn = $globalSources[$id]['host'];
}
$Common = new Common();
if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
$s = $Common->create_socket($hostn,$port, $errno, $errstr);
} else {
$udp = true;
$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
}
if ($s) {
Expand Down Expand Up @@ -323,7 +325,8 @@ function connect_all($hosts) {
} else $globalSources[$id]['format'] = 'sbs';
//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
}
if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
} else {
if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
sleep(10);
Expand Down Expand Up @@ -1667,7 +1670,7 @@ function connect_all($hosts) {
}
}
//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
//$last_exec[$id]['last'] = time();
//$read = array( $sockets[$id] );
$read = $sockets;
Expand Down Expand Up @@ -1773,6 +1776,14 @@ function connect_all($hosts) {
$ACARS->add(trim($buffer));
socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
$ACARS->deleteLiveAcarsData();
} elseif ($format === 'acarsjsonudp') {
if ($globalDebug) echo 'ACARS : '.$buffer."\n";
$line = json_decode(trim($buffer), true);
if (!empty($line)) {
$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
$ACARS->deleteLiveAcarsData();
}
socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
} elseif ($format === 'flightgearmp') {
if (substr($buffer,0,1) != '#') {
$data = array();
Expand Down

0 comments on commit e662370

Please sign in to comment.