Skip to content
Merged
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
12 changes: 9 additions & 3 deletions src/hk_param_sniffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ void hk_set_epoch(time_t epoch, uint16_t node, bool auto_sync) {
char current_time_str[32];
strftime(current_time_str, sizeof(current_time_str), "%Y-%m-%d %H:%M:%S", gmtime(&current_epoch));

/* 1577833200: Jan 1st 2020 */
if (epoch > current_epoch || epoch < 1577833200) {
/* 1577836800: Jan 1st 2020 */
if (epoch > current_epoch || epoch < 1577836800) {
char current_epoch_str[32];
strftime(current_epoch_str, sizeof(current_epoch_str), "%Y-%m-%d %H:%M:%S", gmtime(&epoch));
printf("At %s: Illegal EPOCH %lu (%s) received\n", current_time_str, current_epoch, current_epoch_str);
Expand Down Expand Up @@ -238,6 +238,9 @@ bool hk_param_sniffer(csp_packet_t * packet) {
if (timesync_nodes.node[i] == node && timesync_nodes.paramid[i] == param->id) {
mpack_tag_t tag = mpack_peek_tag(&reader);
local_epoch = tag.v.i - timestamp.tv_sec;
if (local_epoch == 0) {
local_epoch = tag.v.i;
}
hk_set_epoch(local_epoch, packet->id.src, true);
break;
}
Expand All @@ -251,7 +254,10 @@ bool hk_param_sniffer(csp_packet_t * packet) {
continue;
}

param->timestamp->tv_sec += local_epoch;
/* Only update if not receiving a UTC timestamp. 1577836800: Jan 1st 2020 */
if (param->timestamp->tv_sec < 1577836800) {
param->timestamp->tv_sec += local_epoch;
}
param_sniffer_log(NULL, &queue, param, offset, &reader, param->timestamp);
} else {
printf("HK: Found unknown param node %d id %d\n", node, id);
Expand Down