From a7a49ee9a04e44f810804ca035b99dd24b8b3ed6 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 24 Mar 2019 22:02:19 +0100 Subject: [PATCH 1/2] paxcounter.conf: added time sync retry setting --- src/paxcounter.conf | 1 + src/timekeeper.cpp | 6 ++---- src/timesync.cpp | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 79c3c8e6..24da1a74 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -67,6 +67,7 @@ // settings for syncing time of node with external time source #define TIME_SYNC_INTERVAL 0 // sync time attempt each .. minutes from time source (GPS/LORA/RTC) [default = 60], 0 means off +#define TIME_SYNC_INTERVAL_RETRY 0 // retry time sync after lost sync each .. minutes [default = 10], 0 means off #define TIME_SYNC_COMPILEDATE 0 // set to 1 to use compile date to initialize RTC after power outage [default = 0] #define TIME_SYNC_LORAWAN 0 // set to 1 to use LORA network as time source, 0 means off [default = 0] #define TIME_SYNC_TIMESERVER 0 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0] diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 2eb8024d..8ba94b0b 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -43,7 +43,7 @@ time_t timeProvider(void) { t = get_rtctime(); if (t) { timeSource = _rtc; - timesyncer.attach(60, timeSync); // short retry + timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, timeSync); // short retry } #endif @@ -57,7 +57,7 @@ time_t timeProvider(void) { if (!t) { timeSource = _unsynced; - timesyncer.attach(60, timeSync); // short retry + timesyncer.attach(TIME_SYNC_INTERVAL_RETRY * 60, timeSync); // short retry } return t; @@ -138,7 +138,6 @@ void IRAM_ATTR CLOCKIRQ(void) { portYIELD_FROM_ISR(); } - // helper function to check plausibility of a time time_t timeIsValid(time_t const t) { // is it a time in the past? we use compile date to guess @@ -204,7 +203,6 @@ void clock_init(void) { assert(ClockTask); // has clock task started? } // clock_init - void clock_loop(void *taskparameter) { // ClockTask // caveat: don't use now() in this task, it will cause a race condition diff --git a/src/timesync.cpp b/src/timesync.cpp index f0a9b1a4..8ecea0cd 100644 --- a/src/timesync.cpp +++ b/src/timesync.cpp @@ -160,8 +160,7 @@ void process_timesync_req(void *taskparameter) { I2C_MUTEX_UNLOCK(); timeSource = _lora; - timesyncer.attach(TIME_SYNC_INTERVAL * 60, - timeSync); // set to regular repeat + timesyncer.attach(TIME_SYNC_INTERVAL * 60, timeSync); // regular repeat ESP_LOGI(TAG, "[%0.3f] Timesync finished, time was adjusted", millis() / 1000.0); } else From f7aede199dc9149f33fc5641759b6143e3f7f205 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 24 Mar 2019 22:25:36 +0100 Subject: [PATCH 2/2] platformio.ini: bugfix rtc lib --- platformio.ini | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/platformio.ini b/platformio.ini index a0a895e9..e4421de0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -31,7 +31,7 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" -release_version = 1.7.4 +release_version = 1.7.41 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose debug_level = 3 @@ -53,21 +53,19 @@ lib_deps_rgbled = SmartLeds@>=1.1.5 lib_deps_gps = TinyGPSPlus@>=1.0.2 -lib_deps_rtc = - RTC@^2.3.0 lib_deps_sensors = Adafruit Unified Sensor@^1.0.3 Adafruit BME280 Library@1.0.8 lib_deps_basic = ArduinoJson@^5.13.1 Timezone@^1.2.2 + RTC@^2.3.0 lib_deps_all = ${common.lib_deps_basic} ${common.lib_deps_lora} ${common.lib_deps_display} ${common.lib_deps_rgbled} ${common.lib_deps_gps} - ${common.lib_deps_rtc} build_flags_basic = -include "src/hal/${PIOENV}.h" -include "src/paxcounter.conf" @@ -237,7 +235,6 @@ lib_deps = ${common.lib_deps_basic} ${common.lib_deps_lora} ${common.lib_deps_display} - ${common.lib_deps_rtc} build_flags = ${common.build_flags_basic} upload_protocol = ${common.upload_protocol}