faup1090: upload unknown-format Comm-B messages on demand

This commit is contained in:
Oliver Jowett 2021-07-29 19:04:53 +08:00
parent fab8081322
commit 95ab1c0faa
3 changed files with 20 additions and 1 deletions

View File

@ -385,6 +385,7 @@ struct _Modes { // Internal state
uint64_t json_stats_interval; // Interval between rewriting the json stats file, in milliseconds
int json_location_accuracy; // Accuracy of location metadata: 0=none, 1=approx, 2=exact
double faup_rate_multiplier; // Multiplier to adjust rate of faup1090 messages emitted
bool faup_upload_unknown_commb; // faup1090: should we upload Comm-B messages that weren't in a recognized format?
int json_aircraft_history_next;
struct {

View File

@ -1126,7 +1126,7 @@ static int handleFaupCommand(struct client *c, char *p) {
// Traverse through message for commands
while (msg_field != NULL) {
if (strcmp(msg_field, "upload_rate_multiplier") == 0) {
if (!strcmp(msg_field, "upload_rate_multiplier")) {
msg_field = strtok (NULL, "\t");
multiplier = atof(msg_field);
@ -1140,6 +1140,14 @@ static int handleFaupCommand(struct client *c, char *p) {
Modes.faup_rate_multiplier = multiplier;
break;
}
if (!strcmp(msg_field, "upload_unknown_commb")) {
msg_field = strtok (NULL, "\t");
unsigned enable = atoi(msg_field);
fprintf(stderr, "handleFaupCommand(): %s upload of unknown Comm-B messages\n", enable ? "Enabling" : "Disabling");
Modes.faup_upload_unknown_commb = enable;
break;
}
msg_field = strtok (NULL, "\t");
}
@ -2360,6 +2368,15 @@ static void writeFATSVEvent(struct modesMessage *mm, struct aircraft *a)
}
break;
case COMMB_UNKNOWN:
// If enabled, upload raw unrecognized Comm-B messages
// for server-side analysis
if (Modes.faup_upload_unknown_commb && memcmp(mm->MB, a->fatsv_emitted_unknown_commb, 7) != 0) {
memcpy(a->fatsv_emitted_unknown_commb, mm->MB, 7);
writeFATSVEventMessage(mm, "unknown_commb", mm->MB, 7);
}
break;
default:
// nothing
break;

View File

@ -252,6 +252,7 @@ struct aircraft {
unsigned char fatsv_emitted_bds_10[7]; // -"- BDS 1,0 message
unsigned char fatsv_emitted_bds_17[7]; // -"- BDS 1,7 message
unsigned char fatsv_emitted_bds_30[7]; // -"- BDS 3,0 message
unsigned char fatsv_emitted_unknown_commb[7]; // -"- unrecognized Comm-B message
unsigned char fatsv_emitted_es_status[7]; // -"- ES operational status message
unsigned char fatsv_emitted_es_acas_ra[7]; // -"- ES ACAS RA report message
char fatsv_emitted_callsign[9]; // -"- callsign