2019-03-09 00:53:11 +01:00
|
|
|
#ifndef _TIME_SYNC_TIMESERVER_H
|
|
|
|
#define _TIME_SYNC_TIMESERVER_H
|
|
|
|
|
2019-03-12 23:50:02 +01:00
|
|
|
#include <chrono>
|
2019-03-09 00:53:11 +01:00
|
|
|
#include "globals.h"
|
|
|
|
#include "timesync.h"
|
|
|
|
#include "timekeeper.h"
|
|
|
|
|
2019-03-17 15:04:11 +01:00
|
|
|
#define TIME_SYNC_SAMPLES 2 // number of time requests for averaging
|
2019-03-17 19:24:50 +01:00
|
|
|
#define TIME_SYNC_CYCLE 20 // seconds between two time requests
|
2019-03-12 23:50:02 +01:00
|
|
|
#define TIME_SYNC_TIMEOUT 120 // timeout seconds waiting for timeserver answer
|
2019-03-14 19:52:10 +01:00
|
|
|
#define TIME_SYNC_TRIGGER 100 // time deviation in millisec triggering a sync
|
2019-03-09 22:08:57 +01:00
|
|
|
#define TIME_SYNC_FRAME_LENGTH 0x06 // timeserver answer frame length
|
2019-03-17 22:00:42 +01:00
|
|
|
#define TIME_SYNC_FIXUP 0 // calibration millisec to fixup processing time
|
2019-03-09 00:53:11 +01:00
|
|
|
|
2019-03-12 23:50:02 +01:00
|
|
|
void send_timesync_req(void);
|
2019-03-14 19:52:10 +01:00
|
|
|
int recv_timesync_ans(uint8_t buf[], uint8_t buf_len);
|
2019-03-12 23:50:02 +01:00
|
|
|
void process_timesync_req(void *taskparameter);
|
2019-03-16 21:01:43 +01:00
|
|
|
void store_time_sync_req(uint32_t t_millisec);
|
2019-03-09 00:53:11 +01:00
|
|
|
|
|
|
|
#endif
|