Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dump1090.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,13 @@ struct _Modes { // Internal state

struct net_service *beast_verbatim_service; // Beast-format output service, verbatim mode
struct net_service *beast_verbatim_local_service; // Beast-format output service, verbatim+local mode
struct net_service *beast_sys_time_service; // Beast-format output service, "cooked" mode, system timestamp
struct net_service *beast_cooked_service; // Beast-format output service, "cooked" mode

struct net_writer raw_out; // AVR-format output
struct net_writer beast_verbatim_out; // Beast-format output, verbatim mode
struct net_writer beast_verbatim_local_out; // Beast-format output, verbatim+local mode
struct net_writer beast_sys_time_out; // Beast-format output, "cooked" mode, system timestamp
struct net_writer beast_cooked_out; // Beast-format output, "cooked" mode
struct net_writer sbs_out; // SBS-format output
struct net_writer stratux_out; // Stratux-format output
Expand Down
29 changes: 29 additions & 0 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ void modesInitNet(void) {
// we maintain three output services for the different option setting combinations we support
// and switch clients between them if they request a change in mode
Modes.beast_cooked_service = serviceInit("Beast TCP output (cooked mode)", &Modes.beast_cooked_out, send_beast_heartbeat, READ_MODE_BEAST_COMMAND, NULL, handleBeastCommand);
Modes.beast_sys_time_service = serviceInit("Beast TCP output (cooked mode, system timestamp)", &Modes.beast_sys_time_out, send_beast_heartbeat, READ_MODE_BEAST_COMMAND, NULL, handleBeastCommand);
Modes.beast_verbatim_service = serviceInit("Beast TCP output (verbatim mode)", &Modes.beast_verbatim_out, send_beast_heartbeat, READ_MODE_BEAST_COMMAND, NULL, handleBeastCommand);
Modes.beast_verbatim_local_service = serviceInit("Beast TCP output (verbatim+local mode)", &Modes.beast_verbatim_local_out, send_beast_heartbeat, READ_MODE_BEAST_COMMAND, NULL, handleBeastCommand);

Expand Down Expand Up @@ -420,6 +421,23 @@ static void modesSendBeastVerbatimLocalOutput(struct modesMessage *mm) {
writeBeastMessage(&Modes.beast_verbatim_local_out, mm->timestampMsg, mm->signalLevel, mm->verbatim, mm->msgbits / 8);
}

static void modesSendBeastSysTimeOutput(struct modesMessage *mm, struct aircraft *a) {
// Don't forward mlat messages, unless --forward-mlat is set
if (mm->source == SOURCE_MLAT && !Modes.forward_mlat)
return;

// Filter some messages from cooked output
// Don't forward 2-bit-corrected messages
if (mm->correctedbits >= 2)
return;

// Don't forward unreliable messages
if ((a && !a->reliable) && !mm->reliable)
return;

writeBeastMessage(&Modes.beast_sys_time_out, mm->sysTimestampMsg, mm->signalLevel, mm->msg, mm->msgbits / 8);
}

static void modesSendBeastCookedOutput(struct modesMessage *mm, struct aircraft *a) {
// Don't forward mlat messages, unless --forward-mlat is set
if (mm->source == SOURCE_MLAT && !Modes.forward_mlat)
Expand Down Expand Up @@ -1019,6 +1037,7 @@ void modesQueueOutput(struct modesMessage *mm, struct aircraft *a) {
modesSendRawOutput(mm, a);
modesSendBeastVerbatimOutput(mm);
modesSendBeastVerbatimLocalOutput(mm);
modesSendBeastSysTimeOutput(mm, a);
modesSendBeastCookedOutput(mm, a);
writeFATSVEvent(mm, a);
}
Expand Down Expand Up @@ -1181,6 +1200,8 @@ static void handleOptionsChange(struct client *c) {
moveNetClient(c, Modes.beast_verbatim_local_service);
else if (c->verbatim_requested)
moveNetClient(c, Modes.beast_verbatim_service);
else if (c->sys_time_requested)
moveNetClient(c, Modes.beast_sys_time_service);
else
moveNetClient(c, Modes.beast_cooked_service);
}
Expand Down Expand Up @@ -1220,6 +1241,14 @@ static int handleBeastCommand(struct client *c, char *p) {
c->local_requested = 1;
handleOptionsChange(c);
break;
case 't':
c->sys_time_requested = 0;
handleOptionsChange(c);
break;
case 'T':
c->sys_time_requested = 1;
handleOptionsChange(c);
break;
}

return 0;
Expand Down
2 changes: 2 additions & 0 deletions net_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ struct client {
int modeac_requested; // 1 if this Beast output connection has asked for A/C
int verbatim_requested; // 1 if this Beast output connection has asked for verbatim mode
int local_requested; // 1 if this Beast output connection has asked for local-only mode
int sys_time_requested; // 1 if this Beast output connection has asked for message timestamps
// to be from the system clock in milliseconds since epoch
};

// Common writer state for all output sockets of one type
Expand Down