function txtmsg(phpaprs\APRS $aprs, $msg, $dest, $from = FALSE, $path = FALSE) { $msg = new phpaprs\packets\APRS_Message($msg, $dest); if ($from == FALSE) { $msg->setCallsign(MYCALL); } else { $msg->setCallsign($from); } if ($path != FALSE) { $msg->setPath($path); } $aprs->sendPacket($msg); }
// example.php : Example phpAPRS bot use dbursem\phpaprs; use dbursem\phpaprs\packets; $debug = true; require "../vendor/autoload.php"; require "utils/message.php"; require "utils/position.php"; require "utils/status.php"; require "utils/utils.php"; if (file_exists("local.aprsbot.cfg.php")) { require "local.aprsbot.cfg.php"; } else { require "aprsbot.cfg.php"; } $aprs = new phpaprs\APRS(); $aprs->_debug = $debug; $beacon = new packets\APRS_Item(BEACON_LATITUDE, BEACON_LONGITUDE, MYCALL, BEACON_SYMBOL, BEACON_STATUS); $beacon->setCallsign(MYCALL); $filter = FILTER; if ($aprs->connect(HOST, PORT, MYCALL, PASSCODE, $filter) == FALSE) { die("Connect failed\n"); } $lastbeacon = 1; // Setup our callbacks to process incoming stuff $aprs->addCallback(APRSCODE_MESSAGE, "*", "handlemessage"); $aprs->addCallback(APRSCODE_STATUS, "*", "handlestatus"); $aprs->addCallback(APRSCODE_POSITION, "*", "handleposition"); while (1) { // Beacon every BEACON_INTERVAL seconds if (time() - $lastbeacon > BEACON_INTERVAL) {
<?php use dbursem\phpaprs; use dbursem\phpaprs\packets; use dbursem\OGNClient; $debug = true; //automatically include required vendor namespaces require "../vendor/autoload.php"; //include config file if (file_exists("local.aprsbot.cfg.php")) { require "local.aprsbot.cfg.php"; } else { require "aprsbot.cfg.php"; } //initiate APRS and OGNClient $aprs = new phpaprs\APRS(); $aprs->_debug = $debug; $ogn = new OGNClient\OGNClient(DB_NAME, DB_USER, DB_PASS, DB_HOST, $debug); //prepare our own beacon message $beacon = new packets\APRS_Item(BEACON_LATITUDE, BEACON_LONGITUDE, MYCALL, BEACON_SYMBOL, BEACON_STATUS); $beacon->setCallsign(MYCALL); //update the airplane table with most recent DDB data $ogn->updateAirplaneTable(); //optionally provide an array of aircraft registrations you want to add to the airplane table // set the APRS filter (to specify what messages we want to receive) $filter = FILTER; if (empty($filter)) { $filter = $ogn->getFilter(); } // connect to OGN's APRS Server if ($aprs->connect(HOST, PORT, MYCALL, PASSCODE, $filter) == FALSE) {