2019-03-31 19:13:06 +02:00
|
|
|
#ifndef _TIMESYNC_H
|
|
|
|
#define _TIMESYNC_H
|
2019-03-09 00:53:11 +01:00
|
|
|
|
|
|
|
#include "globals.h"
|
2019-03-31 19:13:06 +02:00
|
|
|
#include "irqhandler.h"
|
2019-03-09 00:53:11 +01:00
|
|
|
#include "timekeeper.h"
|
|
|
|
|
2019-09-03 16:28:11 +02:00
|
|
|
#define TIME_SYNC_FRAME_LENGTH 0x07 // timeserver answer frame length [bytes]
|
2020-03-04 21:54:26 +01:00
|
|
|
#define TIME_SYNC_FIXUP 16 // compensation for processing time [milliseconds]
|
2020-03-03 16:38:29 +01:00
|
|
|
#define TIMEREQUEST_MAX_SEQNO 0xfe // threshold for wrap around seqno
|
|
|
|
#define TIMEREQUEST_FINISH \
|
|
|
|
(TIMEREQUEST_MAX_SEQNO + 1) // marker for end of timesync handshake
|
2020-03-04 21:54:26 +01:00
|
|
|
#define GPS_UTC_DIFF 315964800
|
2019-03-09 00:53:11 +01:00
|
|
|
|
2020-03-03 12:54:42 +01:00
|
|
|
enum timesync_t {
|
|
|
|
timesync_tx,
|
|
|
|
timesync_rx,
|
|
|
|
gwtime_sec,
|
|
|
|
gwtime_msec,
|
2020-03-04 21:54:26 +01:00
|
|
|
gwtime_tzsec,
|
2020-03-03 12:54:42 +01:00
|
|
|
no_of_timestamps
|
|
|
|
};
|
|
|
|
|
2019-04-07 16:13:04 +02:00
|
|
|
void timesync_init(void);
|
2019-03-12 23:50:02 +01:00
|
|
|
void send_timesync_req(void);
|
2019-10-04 15:31:31 +02:00
|
|
|
int recv_timesync_ans(const uint8_t buf[], uint8_t buf_len);
|
2020-03-03 12:54:42 +01:00
|
|
|
void store_timestamp(uint32_t timestamp, timesync_t timestamp_type);
|
2020-03-04 21:54:26 +01:00
|
|
|
void IRAM_ATTR process_timesync_req(void *taskparameter);
|
|
|
|
void IRAM_ATTR process_timesync_req(void *pVoidUserUTCTime, int flagSuccess);
|
2019-03-09 00:53:11 +01:00
|
|
|
|
2019-09-03 16:28:11 +02:00
|
|
|
#endif
|