Skip to content

Instantly share code, notes, and snippets.

@nonoo
Created April 21, 2014 08:24
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
PHP script for sending location APRS message to APRS-IS.
#!/usr/bin/php5
<?php
$aprs_callsign = '';
$aprs_passcode = 0;
$aprs_altinfeet = 2080;
// W is the WX icon. See http://wa8lmf.net/aprs/APRS_symbols.htm
// Use GPS coordinate format, see http://www.csgnetwork.com/gpscoordconv.html
$aprs_coord = '4740.55N/01829.60EW';
$aprs_comment = 'Gerecse WX - www.ha5kdr.hu';
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket) {
$result = socket_connect($socket, 'hun.aprs2.net', 14580);
if ($result) {
// Authenticating
$tosend = "user $aprs_callsign pass $aprs_passcode\n";
socket_write($socket, $tosend, strlen($tosend));
$authstartat = time();
$authenticated = false;
while ($msgin = socket_read($socket, 1000, PHP_NORMAL_READ)) {
if (strpos($msgin, "$aprs_callsign verified") !== FALSE) {
$authenticated = true;
break;
}
// Timeout handling
if (time()-$authstartat > 5)
break;
}
if ($authenticated) {
// Sending position
$tosend = "$aprs_callsign>APRS,TCPIP*:@" . date('Hmi') . "z$aprs_coord/A=" .
str_pad($aprs_altinfeet, 6, '0', STR_PAD_LEFT) . " $aprs_comment\n";
socket_write($socket, $tosend, strlen($tosend));
echo $tosend;
}
}
socket_close($socket);
}
?>
@jared-w-smith
Copy link

Please note that date('Hmi') is incorrect. This is hours, month, seconds. It should be date('His') for hours, minutes, seconds.

@danthepilotman
Copy link

Just used your code (modified for my needs) to send my WX station data to the APRS server. Thanks for posting this for other to use. I'll add a link to my code once it's ready to publish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment