timeserver (experimental)

This commit is contained in:
Verkehrsrot committed 2019-03-09 00:53:11 +01:00
1 parent 8980a3d8ff
commit 1051d841b6
16 files changed
+211 -200

No files matched your search

+2 -2
View File
@@ -4,8 +4,8 @@
#include "globals.h"
#include "rcommand.h"
#include "timekeeper.h"
#if(ServertimeSYNC)
#include "Servertimesync.h"
#if(TIME_SYNC_TIMESERVER)
#include "timesync.h"
#endif
// LMIC-Arduino LoRaWAN Stack
+1 -1
View File
@@ -44,7 +44,7 @@ public:
void addConfig(configData_t value);
void addStatus(uint16_t voltage, uint64_t uptime, float cputemp, uint32_t mem,
uint8_t reset1, uint8_t reset2);
void addAlarm(int8_t rssi, uint8_t message);
void add2Bytes(int8_t rssi, uint8_t message);
void addVoltage(uint16_t value);
void addGPS(gpsStatus_t value);
void addBME(bmeStatus_t value);
+2 -2
View File
@@ -9,8 +9,8 @@
#include <rom/rtc.h>
#include "cyclic.h"
#include "timekeeper.h"
#if(ServertimeSYNC)
#include "Servertimesync.h"
#if(TIME_SYNC_TIMESERVER)
#include "timesync.h"
#endif
// table of remote commands and assigned functions
-27
View File
@@ -1,27 +0,0 @@
#ifndef _ServertimeSYNC_H
#define _ServertimeSYNC_H
#include "globals.h"
#include "Servertimesync.h"
#include "timekeeper.h"
#define SYNC_SAMPLES 3
//#define SYNC_CYCLE 600 // seconds between two time sync requests
#define SYNC_CYCLE 20 // seconds between two time sync requests
#define SYNC_TIMEOUT \
(SYNC_SAMPLES * (SYNC_CYCLE + 60)) // timeout waiting for time sync answer
#define SYNC_THRESHOLD 0.01f // time deviation threshold triggering time sync
#define TIME_SYNC_OPCODE 0x90
#define TIME_REQ_OPCODE 0x92
#define TIME_ANS_OPCODE 0x93
extern uint32_t time_sync_messages[], time_sync_answers[];
extern uint8_t time_sync_seqNo;
void send_Servertime_req(void);
void recv_Servertime_ans(uint8_t val[]);
void process_Servertime_sync_req(void *taskparameter);
void process_Servertime_sync_ans(void *taskparameter);
void force_Servertime_sync(uint8_t val[]);
#endif
+25
View File
@@ -0,0 +1,25 @@
#ifndef _TIME_SYNC_TIMESERVER_H
#define _TIME_SYNC_TIMESERVER_H
#include "globals.h"
#include "timesync.h"
#include "timekeeper.h"
#define TIME_SYNC_SAMPLES 3 // number of time requests for averaging
#define TIME_SYNC_CYCLE 20 // seconds between two time requests
#define TIME_SYNC_TIMEOUT 30 // timeout seconds waiting for timeserver answer
#define TIME_SYNC_THRESHOLD 1 // time deviation threshold triggering time sync
#define TIME_SYNC_START_OPCODE 0x90 // force time sync on node
#define TIME_SYNC_REQ_OPCODE 0x92 // node requests time at server
#define TIME_SYNC_ANS_OPCODE 0x93 // server answers time to node
extern uint32_t time_sync_messages[], time_sync_answers[];
extern uint8_t volatile time_sync_seqNo;
void send_Servertime_req(void);
void recv_Servertime_ans(uint8_t val[]);
void process_Servertime_sync_req(void *taskparameter);
void process_Servertime_sync_ans(void *taskparameter);
void force_Servertime_sync(uint8_t val[]);
#endif