Skip to content

Commit f9cf42b

Browse files
committed
Better interpretation of bulletin identifiers.
1 parent 4008153 commit f9cf42b

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

src/decode_aprs.c

+49-4
Original file line numberDiff line numberDiff line change
@@ -1628,10 +1628,15 @@ static void aprs_mic_e (decode_aprs_t *A, packet_t pp, unsigned char *info, int
16281628
* It's a lot more complicated with different types of addressees
16291629
* and replies with acknowledgement or rejection.
16301630
*
1631-
* There is even a special case for telemetry metadata.
1631+
* Is it an elegant generalization to lump all of these special cases
1632+
* together or was it a big mistake that will cause confusion and incorrect
1633+
* implementations? The decision to put telemetry metadata here is baffling.
16321634
*
16331635
*
1634-
* Cases: :xxxxxxxxx:PARM. Telemetry metadata, parameter name
1636+
* Cases: :BLNxxxxxx: ... Bulletin.
1637+
* :NWSxxxxxx: ... National Weather Service Bulletin.
1638+
*
1639+
* :xxxxxxxxx:PARM. Telemetry metadata, parameter name
16351640
* :xxxxxxxxx:UNIT. Telemetry metadata, unit/label
16361641
* :xxxxxxxxx:EQNS. Telemetry metadata, Equation Coefficients
16371642
* :xxxxxxxxx:BITS. Telemetry metadata, Bit Sense/Project Name
@@ -1736,6 +1741,46 @@ static void aprs_message (decode_aprs_t *A, unsigned char *info, int ilen, int q
17361741

17371742
strlcpy (A->g_addressee, addressee, sizeof(A->g_addressee));
17381743

1744+
/*
1745+
* Addressee starting with BLN or NWS is a bulletin.
1746+
*/
1747+
if (strlen(addressee) >= 3 && strncmp(addressee,"BLN",3) == 0) {
1748+
1749+
// Interpret 3 cases of identifiers.
1750+
// BLN9 "general bulletin" has a single digit.
1751+
// BLNX "announcement" has a single uppercase letter.
1752+
// BLN9xxxxx "group bulletin" has single digit group id and group name up to 5 characters.
1753+
1754+
if (strlen(addressee) == 4 && isdigit(addressee[3])) {
1755+
snprintf (A->g_data_type_desc, sizeof(A->g_data_type_desc), "General Bulletin with identifier \"%s\"", addressee+3);
1756+
}
1757+
else if (strlen(addressee) == 4 && isupper(addressee[3])) {
1758+
snprintf (A->g_data_type_desc, sizeof(A->g_data_type_desc), "Announcement with identifier \"%s\"", addressee+3);
1759+
}
1760+
if (strlen(addressee) >=5 && isdigit(addressee[3])) {
1761+
snprintf (A->g_data_type_desc, sizeof(A->g_data_type_desc), "Group Bulletin with identifier \"%c\", group name \"%s\"", addressee[3], addressee+4);
1762+
}
1763+
else {
1764+
// Not one of the official formats.
1765+
snprintf (A->g_data_type_desc, sizeof(A->g_data_type_desc), "Bulletin with identifier \"%s\"", addressee+3);
1766+
}
1767+
A->g_message_subtype = message_subtype_bulletin;
1768+
strlcpy (A->g_comment, p->message, sizeof(A->g_comment));
1769+
}
1770+
1771+
else if (strlen(addressee) >= 3 && strncmp(addressee,"NWS",3) == 0) {
1772+
// NWS-xxxxx
1773+
1774+
if (strlen(addressee) >=4 && addressee[3] == '-') {
1775+
snprintf (A->g_data_type_desc, sizeof(A->g_data_type_desc), "NWS bulletin with identifier \"%s\"", addressee+4);
1776+
}
1777+
else {
1778+
snprintf (A->g_data_type_desc, sizeof(A->g_data_type_desc), "NWS bulletin with identifier \"%s\", missing - after NWS", addressee+3);
1779+
}
1780+
A->g_message_subtype = message_subtype_nws;
1781+
strlcpy (A->g_comment, p->message, sizeof(A->g_comment));
1782+
}
1783+
17391784

17401785
/*
17411786
* Special message formats contain telemetry metadata.
@@ -1748,7 +1793,7 @@ static void aprs_message (decode_aprs_t *A, unsigned char *info, int ilen, int q
17481793
* Why not use other characters after the "T" for metadata?
17491794
*/
17501795

1751-
if (strncmp(p->message,"PARM.",5) == 0) {
1796+
else if (strncmp(p->message,"PARM.",5) == 0) {
17521797
snprintf (A->g_data_type_desc, sizeof(A->g_data_type_desc), "Telemetry Parameter Name Message for \"%s\"", addressee);
17531798
A->g_message_subtype = message_subtype_telem_parm;
17541799
telemetry_name_message (addressee, p->message+5);
@@ -1847,7 +1892,7 @@ static void aprs_message (decode_aprs_t *A, unsigned char *info, int ilen, int q
18471892
// X>Y:}A>B::WA1XYX-15:Howdy y'all{toolong
18481893

18491894
else {
1850-
// Look for message number.
1895+
// Normal messaage case. Look for message number.
18511896
char *pno = strchr(p->message, '{');
18521897
if (pno != NULL) {
18531898
strlcpy (A->g_message_number, pno+1, sizeof(A->g_message_number));

src/decode_aprs.h

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ typedef struct decode_aprs_s {
7070
message_subtype_message,
7171
message_subtype_ack,
7272
message_subtype_rej,
73+
message_subtype_bulletin,
74+
message_subtype_nws,
7375
message_subtype_telem_parm,
7476
message_subtype_telem_unit,
7577
message_subtype_telem_eqns,

0 commit comments

Comments
 (0)