From 303dcc991575bfadf85e0e2858cc64b1c0271a5d Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Tue, 8 Sep 2020 23:35:17 +0800 Subject: [PATCH] Fix stratux output timestamps to really be UTC as they claim --- net_io.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/net_io.c b/net_io.c index 64436b7..f0754c4 100644 --- a/net_io.c +++ b/net_io.c @@ -794,8 +794,6 @@ static void send_sbs_heartbeat(struct net_service *service) #define STRATUX_MAX_PACKET_SIZE 1000 static void modesSendStratuxOutput(struct modesMessage *mm, struct aircraft *a) { char *p; - struct timespec now; - struct tm stTime_receive, stTime_now; // We require a tracked aircraft for Stratux output if (!a) @@ -841,14 +839,6 @@ static void modesSendStratuxOutput(struct modesMessage *mm, struct aircraft *a) mm->mesub, mm->signalLevel); // what precision and range is needed for RSSI? - // Find current system time - clock_gettime(CLOCK_REALTIME, &now); - gmtime_r(&now.tv_sec, &stTime_now); // we expect UTC - - // Find message reception time - time_t received = (time_t) (mm->sysTimestampMsg / 1000); - localtime_r(&received, &stTime_receive); - //// callsign if (mm->callsign_valid) p = safe_snprintf(p, end, "\"Tail\":\"%s\",", jsonEscapeString(mm->callsign)); @@ -962,6 +952,9 @@ static void modesSendStratuxOutput(struct modesMessage *mm, struct aircraft *a) p = safe_snprintf(p, end, "\"Emitter_category\":null,"); // Time message received (based on system clock). Format is 2016-02-20T06:35:43.155Z + struct tm stTime_receive; + time_t received = (time_t) (mm->sysTimestampMsg / 1000); + gmtime_r(&received, &stTime_receive); p = safe_snprintf(p, end, "\"Timestamp\":\"%04d-%02d-%02dT%02d:%02d:%02d.%03dZ\"", (stTime_receive.tm_year+1900),(stTime_receive.tm_mon+1), stTime_receive.tm_mday, stTime_receive.tm_hour,