Subscribing to OGN data using Perl

Subscribing to OGN beacons (by Mel)


#!/usr/bin/perl -w                                                                                                                                                                                                                
use strict;
use Ham::APRS::IS;
use Ham::APRS::FAP qw(parseaprs);
use Data::Dumper;
print "connecting to server\n";
my $is = new Ham::APRS::IS('', 'PerlEx', 'appid' => 'Perl Example App', 'filter'=>'r/+45.557/+5.976/201.4');
$is->connect('retryuntil' => 3) || die "Failed to connect: $is->{error}";
my $lastkeepalive = time();
while($is->connected()) {
    # make sure we send a keep alive every 240 seconds or so                                                                                                                                                                      
    my $now = time();
    if( $now - $lastkeepalive > 240 ) {
        $is->sendline('# example code');
        $lastkeepalive = $now;
    # read the line from the server                                                                                                                                                                                               
    my $line = $is->getline();
    next if (!defined $line);
    # parse the aprs packet                                                                                                                                                                                                       
    my %packetdata;
    my $retval = parseaprs($line, \%packetdata);
    # and display it on the screen                                                                                                                                                                                                
    if ($retval == 1) {
        print Dumper( \%packetdata );
$is->disconnect() || die "Failed to disconnect: $is->{error}";
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License