From 7d401697f6b0a0f3bc635697bc10d91e8cc580ec Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Wed, 31 Mar 2021 09:44:23 +0200 Subject: [PATCH] issue #774 --- include/globals.h | 2 +- src/gpsread.cpp | 5 +++-- src/rcommand.cpp | 2 +- src/timekeeper.cpp | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/globals.h b/include/globals.h index cf8e0869..5a055123 100644 --- a/include/globals.h +++ b/include/globals.h @@ -50,7 +50,7 @@ #define _seconds() millis() / 1000.0 -enum timesource_t { _gps, _rtc, _lora, _unsynced }; +enum timesource_t { _gps, _rtc, _lora, _set, _unsynced }; enum snifftype_t { MAC_SNIFF_WIFI, MAC_SNIFF_BLE, MAC_SNIFF_BLE_ENS }; enum runmode_t { RUNMODE_POWERCYCLE, diff --git a/src/gpsread.cpp b/src/gpsread.cpp index d253bcb2..7801a4ce 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -120,7 +120,7 @@ time_t get_gpstime(uint16_t *msec) { t = makeTime(tm); ESP_LOGD(TAG, "GPS time/date = %02d:%02d:%02d / %02d.%02d.%2d", tm.Hour, - tm.Minute, tm.Second, tm.Day, tm.Month, tm.Year + 1970); + tm.Minute, tm.Second, tm.Day, tm.Month, tm.Year + 1970); // add protocol delay with millisecond precision t += delay_ms / 1000 - 1; // whole seconds @@ -163,7 +163,8 @@ void gps_loop(void *pvParameters) { // (only) while device time is not set or unsynched, and we have a valid // GPS time, we trigger a device time update to poll time from GPS - if (timeSource == _unsynced && gpstime.isUpdated()) { + if ((timeSource == _unsynced || timeSource == _set) && + gpstime.isUpdated()) { now(); calibrateTime(); } diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 31838de5..4b0801d3 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -357,7 +357,7 @@ void set_time(uint8_t val[]) { // swap byte order from msb to lsb, note: this is a platform dependent hack uint32_t t = __builtin_bswap32(*(uint32_t *)(val)); ESP_LOGI(TAG, "Remote command: set time to %d", t); - setMyTime(t, 0, _unsynced); + setMyTime(t, 0, _set); }; void set_flush(uint8_t val[]) { diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index f49adc7c..d1da7744 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -12,7 +12,7 @@ static const char TAG[] = __FILE__; // symbol to display current time source -const char timeSetSymbols[] = {'G', 'R', 'L', '?'}; +const char timeSetSymbols[] = {'G', 'R', 'L', 'S', '?'}; #ifdef HAS_IF482 #if (HAS_SDS011)