Skip to content

Commit

Permalink
implement APRS display mode for iGates
Browse files Browse the repository at this point in the history
run with "multimonNG -A" to get APRS format output.

Example output:

	APRS: DO1GL-5>APDR12,DO1GL*,WIDE2-2:=5111.11N/01111.11E$ http://aprsdroid.org/
  • Loading branch information
ge0rg committed Apr 9, 2013
1 parent 71bf692 commit 36182d2
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
62 changes: 62 additions & 0 deletions hdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,64 @@ static inline int check_crc_ccitt(const unsigned char *buf, int cnt)

/* ---------------------------------------------------------------------- */

int aprs_mode = 0;

static void aprs_print_ax25call(unsigned char *call, int is_repeater)
{
int i;
for (i = 0; i < 6; i++)
if ((call[i] &0xfe) != 0x40)
verbprintf(0, "%c",call[i] >> 1);
int ssid = (call[6] >> 1) & 0xf;
if (ssid)
verbprintf(0, "-%u",ssid);
// hack: only display "*" on the last repeater, as opposed to all that already repeated
if (is_repeater && (call[6] & 0x80))
verbprintf(0, "*");
}
static void aprs_disp_packet(unsigned char *bp, unsigned int len)
{
unsigned char *hdr = bp + 14;
unsigned int hlen = len - 14;
// skip address fields
while ((!(hdr[-1] & 1)) && (hlen >= 7)) {
hdr += 7;
hlen -= 7;
}
if (*hdr++ != 0x03) // Ctrl 0x03 = UI frame
return;
if (*hdr++ != 0xf0) // PID 0xf0 = no layer 3 protocol
return;

verbprintf(0, "APRS: ");
// source call
aprs_print_ax25call(&bp[7], 0);
verbprintf(0, ">");
// tocall
aprs_print_ax25call(&bp[0], 0);
bp += 14;
len -= 14;
// via callsigns
while ((!(bp[-1] & 1)) && (len >= 7)) {
if ((!(bp[-1] & 1)) && (len >= 7))
verbprintf(0, ",");
aprs_print_ax25call(&bp[0], 1);
bp += 7;
len -= 7;
}
verbprintf(0, ":");
// end of header
bp += 2;
len -= 2;
if(!len)
return;
while (len) {
verbprintf(0, "%c",*bp++);
len--;
}
verbprintf(0, "\n");
}

static void ax25_disp_packet(struct demod_state *s, unsigned char *bp, unsigned int len)
{
unsigned char v1=1,cmd=0;
Expand Down Expand Up @@ -125,6 +183,10 @@ static void ax25_disp_packet(struct demod_state *s, unsigned char *bp, unsigned
*/
if (len < 15)
return;
if (aprs_mode) {
aprs_disp_packet(bp, len);
return;
}
if ((bp[6] & 0x80) != (bp[13] & 0x80)) {
v1 = 0;
cmd = (bp[6] & 0x80);
Expand Down
15 changes: 14 additions & 1 deletion unixinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static unsigned int dem_mask[(NUMDEMOD+31)/32];

static int verbose_level = 0;
extern int pocsag_mode;
extern int aprs_mode;
void quit(void);

/* ---------------------------------------------------------------------- */
Expand Down Expand Up @@ -489,6 +490,7 @@ static const char usage_str[] = "multimonNG\n"
" -v <level> : level of verbosity (for example '-v 10')\n"
" -f <mode> : forces POCSAG data decoding as <mode> (<mode> can be 'numeric', 'alpha' and 'skyper')\n"
" -h : this help\n"
" -A : APRS mode (TNC2 text output)\n"
" Raw input requires one channel, 16 bit, signed integer (platform-native)\n"
" samples at the demodulator's input sampling rate, which is\n"
" usually 22050 kHz. Raw input is assumed and required if piped input is used.\n";
Expand All @@ -511,7 +513,7 @@ int main(int argc, char *argv[])
for (i = 0; i < NUMDEMOD; i++)
fprintf(stderr, " %s", dem[i]->name);
fprintf(stderr, "\n");
while ((c = getopt(argc, argv, "t:a:s:v:f:cqh")) != EOF) {
while ((c = getopt(argc, argv, "t:a:s:v:f:cqhA")) != EOF) {
switch (c) {
case 'h':
case '?':
Expand All @@ -522,6 +524,17 @@ int main(int argc, char *argv[])
quietflg++;
break;

case 'A':
aprs_mode = 1;
memset(dem_mask, 0, sizeof(dem_mask));
mask_first = 0;
for (i = 0; i < NUMDEMOD; i++)
if (!strcasecmp("AFSK1200", dem[i]->name)) {
MASK_SET(i);
break;
}
break;

case 'v':
verbose_level = strtoul(optarg, 0, 0);
break;
Expand Down

0 comments on commit 36182d2

Please sign in to comment.