From 2fd3b6725c186a7b9a1e430d7b6278606e2de227 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Tue, 29 Jan 2019 09:04:56 +0100 Subject: [PATCH] set RTC by GPS & LORA --- src/gpsread.cpp | 4 ++++ src/lorawan.cpp | 7 ++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gpsread.cpp b/src/gpsread.cpp index 2aff4947..07bfd9ee 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -73,6 +73,10 @@ time_t get_gpstime(void) { if (gps.time.age() < 1500) { t = tmConvert_t(gps.date.year(), gps.date.month(), gps.date.day(), gps.time.hour(), gps.time.minute(), gps.time.second()); +#ifdef HAS_RTC + if (!set_rtctime(t)) + ESP_LOGE(TAG, "RTC set time failure"); +#endif } else { ESP_LOGW(TAG, "GPS has no confident time"); } diff --git a/src/lorawan.cpp b/src/lorawan.cpp index fa53fdd7..d8350b5b 100644 --- a/src/lorawan.cpp +++ b/src/lorawan.cpp @@ -455,12 +455,9 @@ void user_request_network_time_callback(void *pVoidUserUTCTime, // Update system time with time read from the network setTime(*pUserUTCTime); + ESP_LOGI(TAG, "LoRaWAN network has set the system time"); #ifdef HAS_RTC if (!set_rtctime(*pUserUTCTime)) ESP_LOGE(TAG, "RTC set time failure"); #endif - time_t t = myTZ.toLocal(now()); - ESP_LOGI(TAG, - "LORA Network has set system time to %02d/%02d/%d %02d:%02d:%02d", - month(t), day(t), year(t), hour(t), minute(t), second(t)); -} +} \ No newline at end of file