make change according to the suggestions

This commit is contained in:
Determinant 2020-08-30 21:21:49 -04:00
parent 258e3f9d65
commit d25103361a
No known key found for this signature in database
GPG Key ID: 0FD4BAB8BE694DDE
2 changed files with 20 additions and 65 deletions

View File

@ -300,7 +300,7 @@ void showHelp(void) {
"--net-sbs-port <ports> TCP BaseStation output listen ports (default: 30003)\n"
"--net-bi-port <ports> TCP Beast input listen ports (default: 30004,30104)\n"
"--net-bo-port <ports> TCP Beast output listen ports (default: 30005)\n"
"--net-stratux-port <ports> TCP Stratux output listen ports (default: 30006)\n"
"--net-stratux-port <ports> TCP Stratux output listen ports (default: disabled)\n"
"--net-ro-size <size> TCP output minimum size (default: 0)\n"
"--net-ro-interval <rate> TCP output memory flush rate in seconds (default: 0)\n"
"--net-heartbeat <rate> TCP heartbeat rate in seconds (default: 60 sec; 0 to disable)\n"

View File

@ -791,21 +791,20 @@ static void modesSendStratuxOutput(struct modesMessage *mm, struct aircraft *a)
char *p;
struct timespec now;
struct tm stTime_receive, stTime_now;
int msgType;
// We require a tracked aircraft for SBS output
// We require a tracked aircraft for Stratux output
if (!a)
return;
// Don't ever forward 2-bit-corrected messages via SBS output.
// Don't ever forward 2-bit-corrected messages via Stratux output.
if (mm->correctedbits >= 2)
return;
// Don't ever forward mlat messages via SBS output.
// Don't ever forward mlat messages via Stratux output.
if (mm->source == SOURCE_MLAT)
return;
// Don't ever send unreliable messages via SBS output
// Don't ever send unreliable messages via Stratux output
if (!mm->reliable && !a->reliable)
return;
@ -817,42 +816,6 @@ static void modesSendStratuxOutput(struct modesMessage *mm, struct aircraft *a)
if (!p)
return;
// NOTE: not sure about message types, so keep the original code from
// stratux/dump1090 as-is.
//
// Decide on the basic SBS Message Type
if ((mm->msgtype == 4) || (mm->msgtype == 20)) {
msgType = 5;
} else if ((mm->msgtype == 5) || (mm->msgtype == 21)) {
msgType = 6;
} else if ((mm->msgtype == 0) || (mm->msgtype == 16)) {
msgType = 7;
} else if (mm->msgtype == 11) {
msgType = 8;
} else if ((mm->msgtype != 17) && (mm->msgtype != 18)) {
return;
} else if ((mm->metype >= 1) && (mm->metype <= 4)) {
msgType = 1;
} else if ((mm->metype >= 5) && (mm->metype <= 8)) {
if (mm->cpr_decoded)
{msgType = 2;}
else
{msgType = 7;}
} else if ((mm->metype >= 9) && (mm->metype <= 18)) {
if (mm->cpr_decoded)
{msgType = 3;}
else
{msgType = 7;}
} else if ((mm->metype == 29) || (mm->metype == 31)) {
msgType = 9; // new message type for target state and operational status messages
} else if (mm->metype != 19) {
return;
} else if ((mm->mesub == 1) || (mm->mesub == 2)) {
msgType = 4;
} else {
return;
}
// Begin populating the traffic.go fields.
// ICAO address, Mode S message types, and signal level
@ -868,13 +831,11 @@ static void modesSendStratuxOutput(struct modesMessage *mm, struct aircraft *a)
"\"DF\":%d,\"CA\":%d,"
"\"TypeCode\":%d,"
"\"SubtypeCode\":%d,"
"\"SBS_MsgType\":%d,"
"\"SignalLevel\":%f,",
mm->addr,
mm->msgtype, cacf,
mm->metype,
mm->mesub,
msgType,
mm->signalLevel); // what precision and range is needed for RSSI?
// Find current system time
@ -892,14 +853,17 @@ static void modesSendStratuxOutput(struct modesMessage *mm, struct aircraft *a)
p += sprintf(p, "\"Tail\":null,");
//// altitude & gnss
bool alt_is_geom = false;
if (Modes.use_gnss && mm->altitude_geom_valid) {
bool alt_is_geom;
if (mm->altitude_baro_valid) {
p += sprintf(p, "\"Alt\":%d,",mm->altitude_baro);
alt_is_geom = false;
} else if (mm->altitude_geom_valid) {
p += sprintf(p, "\"Alt\":%d,",mm->altitude_geom);
alt_is_geom = true;
} else if (mm->altitude_baro_valid)
p += sprintf(p, "\"Alt\":%d,",mm->altitude_baro);
else
} else {
p += sprintf(p, "\"Alt\":null,");
alt_is_geom = false;
}
// altitude source
if (alt_is_geom)
@ -933,22 +897,13 @@ static void modesSendStratuxOutput(struct modesMessage *mm, struct aircraft *a)
else
p += sprintf(p, "\"Lat\":null,\"Lng\":null,\"Position_valid\":false,");
//// vrate
if (Modes.use_gnss) {
if (mm->geom_rate_valid)
p += sprintf(p, "\"Vvel\":%d,", mm->geom_rate);
else if (mm->baro_rate_valid)
p += sprintf(p, "\"Vvel\":%d,", mm->baro_rate);
else
p += sprintf(p, "\"Vvel\":null,");
} else {
if (mm->baro_rate_valid)
p += sprintf(p, "\"Vvel\":%d,", mm->baro_rate);
else if (mm->geom_rate_valid)
p += sprintf(p, "\"Vvel\":%d,", mm->geom_rate);
else
p += sprintf(p, "\"Vvel\":null,");
}
//// vrate (use barometric if possible)
if (mm->baro_rate_valid)
p += sprintf(p, "\"Vvel\":%d,", mm->baro_rate);
else if (mm->geom_rate_valid)
p += sprintf(p, "\"Vvel\":%d,", mm->geom_rate);
else
p += sprintf(p, "\"Vvel\":null,");
//// squawk
if (mm->squawk_valid)