dbursem/ogn-client-php

OGN client implementation

2.1.1 2019-04-18 09:54 UTC

This package is auto-updated.

Last update: 2024-04-18 20:44:58 UTC


README

This client can be used to track aircraft and save their logs to a database. Saving other beacons is not (yet) supported.

Install

  • run composer require dbursem/ogn-client-php. Check http://getcomposer.org for more info on composer.
  • install the database schema from the ogn-client-db.sql file.
  • Copy the example directory to your install directory
  • Copy the aprsbot.cfg.php file to local.aprsbot.cfg.php and edit it with your personal settings. OGN server and port are already in it.
  • Set the filter to a valid APRS filter. If you leave it empty, a filter will be used that selects only the airplanes in the database.

Usage

  • Call the example aprsbot from the commandline with php aprsbot.php.
  • you'll see some debug info and hopefully logs will be added to your database.
  • set debug to false in aprsbot.php (line 7) to stop the debug messages.

Be noted: This is a daemon that should run in the background indefinately. All it does is saving coordinates to a database. There's no use in trying to call it through a webserver, as there's no output other than the debug messages.

Minimal steps to create your own aprsbot:

  • Create an instance of APRS:
$aprs = new dbursem\phpaprs\APRS();
  • Connect to the APRS host
if ($aprs->connect(HOST, PORT, MYCALL, PASSCODE, $filter) == FALSE) 
{
    die( "Connect failed\n");
}
  • Create an instance of OGNClient:
$ogn = new OGNClient\OGNClient(DB_NAME,DB_USER,DB_PASS,DB_HOST, $debug);
  • Create a loop to handle the input/output and save records to the database
while (1)
{
    if (time() - $lastbeacon > BEACON_INTERVAL) 
    {
        //send beacon (every 5 minutes) to keep connection alive
        echo "Send beacon\n";
        $aprs->sendPacket($beacon);
        $lastbeacon = time();
    }
    $aprs->ioloop(5);    // handle Socket I/O events
    $ogn->savePositions(); //save received positions to database 
}

About the igc.php file

This code won't work as-is, I only bundled the file to serve as an example of how to generate an IGC file from the logs in ognlogs. Create your own functions to do this in your environment or wait till I have time to make A proper class for it.

check the openlayers igc example if you want to show the IGC in a webbrowser.

As said before, this class has some rough edges so handle with care!