avoid clock churn

This commit is contained in:
J. Nick Koston
2026-01-15 13:14:22 -10:00
parent 357542960d
commit 8861abea73
@@ -31,6 +31,14 @@ void RealTimeClock::dump_config() {
void RealTimeClock::synchronize_epoch_(uint32_t epoch) {
ESP_LOGVV(TAG, "Got epoch %" PRIu32, epoch);
// Skip if time is already synchronized to avoid unnecessary writes and log spam
auto current = this->utcnow();
if (current.is_valid()) {
int32_t diff = static_cast<int32_t>(epoch) - static_cast<int32_t>(current.timestamp);
if (diff >= -1 && diff <= 1) {
return;
}
}
// Update UTC epoch time.
#ifdef USE_ZEPHYR
struct timespec ts;