timesync TIME_SYNC_FIXUP
This commit is contained in:
parent
cd67cb2335
commit
5cb875bcfc
@ -11,6 +11,7 @@
|
||||
#define TIME_SYNC_TIMEOUT 120 // timeout seconds waiting for timeserver answer
|
||||
#define TIME_SYNC_TRIGGER 100 // time deviation in millisec triggering a sync
|
||||
#define TIME_SYNC_FRAME_LENGTH 0x06 // timeserver answer frame length
|
||||
#define TIME_SYNC_FIXUP 0 // calibration millisec to fixup processing time
|
||||
|
||||
void send_timesync_req(void);
|
||||
int recv_timesync_ans(uint8_t buf[], uint8_t buf_len);
|
||||
|
@ -124,6 +124,8 @@ void process_timesync_req(void *taskparameter) {
|
||||
// calculate absolute time offset with millisecond precision using time base
|
||||
// of LMIC os, since we use LMIC's ostime_t txEnd as tx timestamp
|
||||
time_offset += milliseconds(osticks2ms(os_getTime()));
|
||||
// apply calibration factor for processing time
|
||||
time_offset += milliseconds(TIME_SYNC_FIXUP);
|
||||
// convert to seconds
|
||||
time_to_set = static_cast<time_t>(myClock_secTick(time_offset).count());
|
||||
// calculate fraction milliseconds
|
||||
@ -138,9 +140,9 @@ void process_timesync_req(void *taskparameter) {
|
||||
TIME_SYNC_TRIGGER) { // milliseconds threshold
|
||||
|
||||
// wait until top of second
|
||||
ESP_LOGD(TAG, "[%0.3f] waiting %d ms", millis() / 1000.0,
|
||||
1000 - time_to_set_fraction_msec);
|
||||
vTaskDelay(pdMS_TO_TICKS(1000 - time_to_set_fraction_msec));
|
||||
uint16_t const wait_ms = 1000 - time_to_set_fraction_msec;
|
||||
ESP_LOGD(TAG, "[%0.3f] waiting %d ms", millis() / 1000.0, wait_ms);
|
||||
vTaskDelay(pdMS_TO_TICKS(wait_ms));
|
||||
|
||||
// sync timer pps to top of second
|
||||
if (ppsIRQ) {
|
||||
|
Loading…
Reference in New Issue
Block a user