From 647d698656163aeb284c213d06eaf3d6b67e0770 Mon Sep 17 00:00:00 2001 From: WB2OSZ Date: Wed, 14 Jun 2017 21:57:34 -0400 Subject: [PATCH] Add beacon position ambiguity option. --- beacon.c | 6 +++--- config.c | 19 ++++++++++++++++++- config.h | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/beacon.c b/beacon.c index b0f51f6..952bc8a 100644 --- a/beacon.c +++ b/beacon.c @@ -839,7 +839,7 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo) case BEACON_POSITION: encode_position (bp->messaging, bp->compress, - bp->lat, bp->lon, 0, + bp->lat, bp->lon, bp->ambiguity, (int)roundf(DW_METERS_TO_FEET(bp->alt_m)), bp->symtab, bp->symbol, bp->power, bp->height, bp->gain, bp->dir, @@ -852,7 +852,7 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo) case BEACON_OBJECT: - encode_object (bp->objname, bp->compress, 0, bp->lat, bp->lon, 0, + encode_object (bp->objname, bp->compress, 0, bp->lat, bp->lon, bp->ambiguity, bp->symtab, bp->symbol, bp->power, bp->height, bp->gain, bp->dir, G_UNKNOWN, G_UNKNOWN, /* course, speed */ @@ -883,7 +883,7 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo) } encode_position (bp->messaging, bp->compress, - gpsinfo->dlat, gpsinfo->dlon, 0, my_alt_ft, + gpsinfo->dlat, gpsinfo->dlon, bp->ambiguity, my_alt_ft, bp->symtab, bp->symbol, bp->power, bp->height, bp->gain, bp->dir, coarse, (int)roundf(gpsinfo->speed_knots), diff --git a/config.c b/config.c index e8ad499..a076d62 100644 --- a/config.c +++ b/config.c @@ -4778,6 +4778,7 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_ //b->every = 3600; b->lat = G_UNKNOWN; b->lon = G_UNKNOWN; + b->ambiguity = 0; b->alt_m = G_UNKNOWN; b->symtab = '/'; b->symbol = '-'; /* house */ @@ -4904,6 +4905,16 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_ else if (strcasecmp(keyword, "LONG") == 0 || strcasecmp(keyword, "LON") == 0) { b->lon = parse_ll (value, LON, line); } + else if (strcasecmp(keyword, "AMBIGUITY") == 0 || strcasecmp(keyword, "AMBIG") == 0) { + int n = atoi(value); + if (n >= 0 && n <= 4) { + b->ambiguity = n; + } + else { + text_color_set(DW_COLOR_ERROR); + dw_printf ("Config file: Location ambiguity, on line %d, must be in range of 0 to 4.\n", line); + } + } else if (strcasecmp(keyword, "ALT") == 0 || strcasecmp(keyword, "ALTITUDE") == 0) { b->alt_m = atof(value); } @@ -4971,7 +4982,13 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_ if (b->custom_info != NULL && b->custom_infocmd != NULL) { text_color_set(DW_COLOR_ERROR); - dw_printf ("Config file, line %d: Can't use both INFO and INFOCMD at the same time..\n", line); + dw_printf ("Config file, line %d: Can't use both INFO and INFOCMD at the same time.\n", line); + } + + if (b->compress && b->ambiguity != 0) { + text_color_set(DW_COLOR_ERROR); + dw_printf ("Config file, line %d: Position ambiguity can't be used with compressed location format.\n", line); + b->ambiguity = 0; } /* diff --git a/config.h b/config.h index d369600..71f8d14 100644 --- a/config.h +++ b/config.h @@ -164,6 +164,7 @@ struct misc_config_s { double lat; /* Latitude and longitude. */ double lon; + int ambiguity; /* Number of lower digits to trim from location. 0 (default), 1, 2, 3, 4. */ float alt_m; /* Altitude in meters. */ char symtab; /* Symbol table: / or \ or overlay character. */