timekeeper.cpp: setmytime return if no timesrc
This commit is contained in:
parent
0a970f3dcf
commit
a381f31244
@ -54,7 +54,7 @@ void calibrateTime(void) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
|
|
||||||
@ -66,6 +66,10 @@ finish:
|
|||||||
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec,
|
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec,
|
||||||
timesource_t mytimesource) {
|
timesource_t mytimesource) {
|
||||||
|
|
||||||
|
// called with invalid timesource?
|
||||||
|
if (mytimesource == _unsynced)
|
||||||
|
return;
|
||||||
|
|
||||||
// increment t_sec only if t_msec > 1000
|
// increment t_sec only if t_msec > 1000
|
||||||
time_t time_to_set = (time_t)(t_sec + t_msec / 1000);
|
time_t time_to_set = (time_t)(t_sec + t_msec / 1000);
|
||||||
|
|
||||||
|
@ -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
|
// the 5th byte contains the fractional seconds in 2^-8 second steps
|
||||||
// (= 1/250th sec), we convert this to ms
|
// (= 1/250th sec), we convert this to ms
|
||||||
uint16_t timestamp_msec = 4 * buf[4];
|
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;
|
uint32_t timestamp_sec, *timestamp_ptr;
|
||||||
|
|
||||||
// convert buffer to uint32_t, octet order is big endian
|
// convert buffer to uint32_t, octet order is big endian
|
||||||
|
Loading…
Reference in New Issue
Block a user