From 36f0a6255a2ad89432b1d7091a4a9c539ce70d7c Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Mon, 2 Mar 2020 00:12:57 +0100 Subject: [PATCH] timesync.cpp: adjust lora time calibration --- src/timesync.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/timesync.cpp b/src/timesync.cpp index d7a64461..43093bb4 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -117,14 +117,19 @@ void process_timesync_req(void *taskparameter) { // average time offset over all collected diffs time_offset_ms /= TIME_SYNC_SAMPLES; + // --------- do we need this? --------- // calculate time offset with millisecond precision using LMIC's time base, // since we use LMIC's ostime_t txEnd as tx timestamp. - // Also apply calibration const to compensate processing time. - time_offset_ms += milliseconds(osticks2ms(os_getTime())) - - milliseconds(millis()) + milliseconds(TIME_SYNC_FIXUP); + // + // time_offset_ms += milliseconds(osticks2ms(os_getTime())) - + // milliseconds(millis()); + // --------- not sure ----------------- - // calculate absolute time in UTC epoch: convert to whole seconds, round to - // ceil, and calculate fraction milliseconds + // Apply calibration const to compensate processing time. + time_offset_ms += milliseconds(TIME_SYNC_FIXUP); + + // calculate absolute time in UTC epoch: convert to whole seconds, round + // to ceil, and calculate fraction milliseconds time_to_set = (uint32_t)(time_offset_ms.count() / 1000) + 1; // calculate fraction milliseconds time_to_set_fraction_msec = (uint16_t)(time_offset_ms.count() % 1000);