From a381f3124486290b85f05a82323ee13d009b56d8 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 18 Aug 2019 22:13:42 +0200 Subject: [PATCH] timekeeper.cpp: setmytime return if no timesrc --- src/timekeeper.cpp | 6 +++++- src/timesync.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 16236de0..85f62864 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -54,7 +54,7 @@ void calibrateTime(void) { } #endif -goto finish; + goto finish; finish: @@ -66,6 +66,10 @@ finish: void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec, timesource_t mytimesource) { + // called with invalid timesource? + if (mytimesource == _unsynced) + return; + // increment t_sec only if t_msec > 1000 time_t time_to_set = (time_t)(t_sec + t_msec / 1000); diff --git a/src/timesync.cpp b/src/timesync.cpp index b1814538..b44a955a 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -178,7 +178,7 @@ int recv_timesync_ans(uint8_t seq_no, uint8_t buf[], uint8_t buf_len) { // the 5th byte contains the fractional seconds in 2^-8 second steps // (= 1/250th sec), we convert this to ms uint16_t timestamp_msec = 4 * buf[4]; - // pointers to 4 bytes 4 bytes containing UTC seconds since unix epoch, msb + // pointers to 4 bytes containing UTC seconds since unix epoch, msb uint32_t timestamp_sec, *timestamp_ptr; // convert buffer to uint32_t, octet order is big endian