timesync (experimental)

This commit is contained in:
Verkehrsrot committed 2019-03-09 15:25:44 +01:00
1 parent 669d05a1b4
commit c64f087faa
10 files changed
+149 -73

No files matched your search

+7 -4
View File
@@ -16,11 +16,12 @@
#define LPP_MSG_CHANNEL 28
#define LPP_HUMIDITY_CHANNEL 29
#define LPP_BAROMETER_CHANNEL 30
#define LPP_AIR_CHANNEL 31
#define LPP_AIR_CHANNEL 31
#endif
// MyDevices CayenneLPP 2.0 types for Packed Sensor Payload, not using channels, but different FPorts
// MyDevices CayenneLPP 2.0 types for Packed Sensor Payload, not using channels,
// but different FPorts
#define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01m
#define LPP_TEMPERATURE 103 // 2 bytes, 0.1°C signed MSB
#define LPP_DIGITAL_INPUT 0 // 1 byte
@@ -40,11 +41,13 @@ public:
void reset(void);
uint8_t getSize(void);
uint8_t *getBuffer(void);
void addByte(uint8_t value);
void addWord(uint16_t value);
void addCount(uint16_t value, uint8_t sniffytpe);
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 add2Bytes(int8_t rssi, uint8_t message);
void addAlarm(int8_t rssi, uint8_t message);
void addVoltage(uint16_t value);
void addGPS(gpsStatus_t value);
void addBME(bmeStatus_t value);
@@ -72,7 +75,7 @@ private:
void writeFloat(float value);
void writeUFloat(float value);
void writePressure(float value);
void writeVersion(char * version);
void writeVersion(char *version);
void writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f, bool g,
bool h);
+15 -7
View File
@@ -7,19 +7,27 @@
#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
#define TIME_SYNC_TIMEOUT 180 // timeout seconds waiting for timeserver answer
#define TIME_SYNC_THRESHOLD \
1.0f // time deviation threshold triggering time sync
#define TIME_SYNC_START_OPCODE 0x90 // start time sync on node
#define TIME_SYNC_STOP_OPCODE 0x91 // stop time sync on node
#define TIME_SYNC_REQ_OPCODE 0x92 // node request at timeserver
#define TIME_SYNC_ANS_OPCODE 0x93 // timeserver answer to node
extern uint32_t time_sync_messages[], time_sync_answers[];
extern uint8_t volatile time_sync_seqNo;
typedef struct {
uint32_t seconds;
uint8_t fractions; // 1/250ths second = 4 milliseconds resolution
} time_sync_message_t;
extern time_sync_message_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[]);
void store_time_sync_req(time_t secs, uint32_t micros);
#endif