PHP script for sending location APRS message to APRS-IS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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); | |
} | |
?> |
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
Please note that date('Hmi') is incorrect. This is hours, month, seconds. It should be date('His') for hours, minutes, seconds.