2019-03-09 00:53:11 +01:00
|
|
|
#ifndef _TIME_SYNC_TIMESERVER_H
|
|
|
|
#define _TIME_SYNC_TIMESERVER_H
|
|
|
|
|
|
|
|
#include "globals.h"
|
|
|
|
#include "timesync.h"
|
|
|
|
#include "timekeeper.h"
|
|
|
|
|
2019-03-09 20:40:21 +01:00
|
|
|
#define TIME_SYNC_SAMPLES 1 // number of time requests for averaging
|
2019-03-09 22:08:57 +01:00
|
|
|
#define TIME_SYNC_CYCLE 30 // seconds between two time requests
|
2019-03-09 20:40:21 +01:00
|
|
|
#define TIME_SYNC_TIMEOUT 120 // timeout seconds waiting for timeserver answer
|
|
|
|
#define TIME_SYNC_TRIGGER 1.0f // time deviation threshold triggering time sync
|
2019-03-09 22:08:57 +01:00
|
|
|
#define TIME_SYNC_FRAME_LENGTH 0x06 // timeserver answer frame length
|
2019-03-09 00:53:11 +01:00
|
|
|
|
2019-03-09 15:25:44 +01:00
|
|
|
typedef struct {
|
|
|
|
uint32_t seconds;
|
|
|
|
uint8_t fractions; // 1/250ths second = 4 milliseconds resolution
|
|
|
|
} time_sync_message_t;
|
|
|
|
|
2019-03-09 00:53:11 +01:00
|
|
|
void send_Servertime_req(void);
|
2019-03-09 22:08:57 +01:00
|
|
|
void recv_Servertime_ans(uint8_t buf[], uint8_t buf_len);
|
2019-03-09 00:53:11 +01:00
|
|
|
void process_Servertime_sync_req(void *taskparameter);
|
2019-03-09 15:25:44 +01:00
|
|
|
void store_time_sync_req(time_t secs, uint32_t micros);
|
2019-03-09 00:53:11 +01:00
|
|
|
|
|
|
|
#endif
|