Instantly share code, notes, and snippets.

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);
}
?>
@michelinok

This comment has been minimized.

Show comment
Hide comment
@michelinok

michelinok Jan 7, 2017

Hi!,
my location on google maps is 43.671202 / 10.576086

What is the value for $aprs_coord ? i'm not able to do the conversion...

michelinok commented Jan 7, 2017

Hi!,
my location on google maps is 43.671202 / 10.576086

What is the value for $aprs_coord ? i'm not able to do the conversion...

@michelinok

This comment has been minimized.

Show comment
Hide comment
@michelinok

michelinok Jan 7, 2017

Quite strange...the script worked only one time....next tryes did not update data but no error at all...any idea?

michelinok commented Jan 7, 2017

Quite strange...the script worked only one time....next tryes did not update data but no error at all...any idea?

@jared-w-smith

This comment has been minimized.

Show comment
Hide comment
@jared-w-smith

jared-w-smith Aug 10, 2017

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

jared-w-smith commented Aug 10, 2017

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

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