Skip to content

Commit 647d698

Browse files
committed
Add beacon position ambiguity option.
1 parent ed67bdf commit 647d698

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

beacon.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo)
839839
case BEACON_POSITION:
840840

841841
encode_position (bp->messaging, bp->compress,
842-
bp->lat, bp->lon, 0,
842+
bp->lat, bp->lon, bp->ambiguity,
843843
(int)roundf(DW_METERS_TO_FEET(bp->alt_m)),
844844
bp->symtab, bp->symbol,
845845
bp->power, bp->height, bp->gain, bp->dir,
@@ -852,7 +852,7 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo)
852852

853853
case BEACON_OBJECT:
854854

855-
encode_object (bp->objname, bp->compress, 0, bp->lat, bp->lon, 0,
855+
encode_object (bp->objname, bp->compress, 0, bp->lat, bp->lon, bp->ambiguity,
856856
bp->symtab, bp->symbol,
857857
bp->power, bp->height, bp->gain, bp->dir,
858858
G_UNKNOWN, G_UNKNOWN, /* course, speed */
@@ -883,7 +883,7 @@ static void beacon_send (int j, dwgps_info_t *gpsinfo)
883883
}
884884

885885
encode_position (bp->messaging, bp->compress,
886-
gpsinfo->dlat, gpsinfo->dlon, 0, my_alt_ft,
886+
gpsinfo->dlat, gpsinfo->dlon, bp->ambiguity, my_alt_ft,
887887
bp->symtab, bp->symbol,
888888
bp->power, bp->height, bp->gain, bp->dir,
889889
coarse, (int)roundf(gpsinfo->speed_knots),

config.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -4778,6 +4778,7 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
47784778
//b->every = 3600;
47794779
b->lat = G_UNKNOWN;
47804780
b->lon = G_UNKNOWN;
4781+
b->ambiguity = 0;
47814782
b->alt_m = G_UNKNOWN;
47824783
b->symtab = '/';
47834784
b->symbol = '-'; /* house */
@@ -4904,6 +4905,16 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
49044905
else if (strcasecmp(keyword, "LONG") == 0 || strcasecmp(keyword, "LON") == 0) {
49054906
b->lon = parse_ll (value, LON, line);
49064907
}
4908+
else if (strcasecmp(keyword, "AMBIGUITY") == 0 || strcasecmp(keyword, "AMBIG") == 0) {
4909+
int n = atoi(value);
4910+
if (n >= 0 && n <= 4) {
4911+
b->ambiguity = n;
4912+
}
4913+
else {
4914+
text_color_set(DW_COLOR_ERROR);
4915+
dw_printf ("Config file: Location ambiguity, on line %d, must be in range of 0 to 4.\n", line);
4916+
}
4917+
}
49074918
else if (strcasecmp(keyword, "ALT") == 0 || strcasecmp(keyword, "ALTITUDE") == 0) {
49084919
b->alt_m = atof(value);
49094920
}
@@ -4971,7 +4982,13 @@ static int beacon_options(char *cmd, struct beacon_s *b, int line, struct audio_
49714982

49724983
if (b->custom_info != NULL && b->custom_infocmd != NULL) {
49734984
text_color_set(DW_COLOR_ERROR);
4974-
dw_printf ("Config file, line %d: Can't use both INFO and INFOCMD at the same time..\n", line);
4985+
dw_printf ("Config file, line %d: Can't use both INFO and INFOCMD at the same time.\n", line);
4986+
}
4987+
4988+
if (b->compress && b->ambiguity != 0) {
4989+
text_color_set(DW_COLOR_ERROR);
4990+
dw_printf ("Config file, line %d: Position ambiguity can't be used with compressed location format.\n", line);
4991+
b->ambiguity = 0;
49754992
}
49764993

49774994
/*

config.h

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ struct misc_config_s {
164164

165165
double lat; /* Latitude and longitude. */
166166
double lon;
167+
int ambiguity; /* Number of lower digits to trim from location. 0 (default), 1, 2, 3, 4. */
167168
float alt_m; /* Altitude in meters. */
168169

169170
char symtab; /* Symbol table: / or \ or overlay character. */

0 commit comments

Comments
 (0)