Merge pull request #561 from cyberman54/development

timesync.cpp: adjust lora time calibration
This commit is contained in:
Verkehrsrot 2020-03-02 00:13:56 +01:00 committed by GitHub
commit 3fe7299ff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,14 +117,19 @@ void process_timesync_req(void *taskparameter) {
// average time offset over all collected diffs // average time offset over all collected diffs
time_offset_ms /= TIME_SYNC_SAMPLES; time_offset_ms /= TIME_SYNC_SAMPLES;
// --------- do we need this? ---------
// calculate time offset with millisecond precision using LMIC's time base, // calculate time offset with millisecond precision using LMIC's time base,
// since we use LMIC's ostime_t txEnd as tx timestamp. // 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())) - // time_offset_ms += milliseconds(osticks2ms(os_getTime())) -
milliseconds(millis()) + milliseconds(TIME_SYNC_FIXUP); // milliseconds(millis());
// --------- not sure -----------------
// calculate absolute time in UTC epoch: convert to whole seconds, round to // Apply calibration const to compensate processing time.
// ceil, and calculate fraction milliseconds 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; time_to_set = (uint32_t)(time_offset_ms.count() / 1000) + 1;
// calculate fraction milliseconds // calculate fraction milliseconds
time_to_set_fraction_msec = (uint16_t)(time_offset_ms.count() % 1000); time_to_set_fraction_msec = (uint16_t)(time_offset_ms.count() % 1000);