Merge pull request #260 from cyberman54/development
once more some bugfixes in realtime handling
This commit is contained in:
commit
171500581b
@ -30,7 +30,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.141
|
||||
release_version = 1.7.143
|
||||
; 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
|
||||
|
@ -139,6 +139,12 @@ void refreshtheDisplay() {
|
||||
|
||||
uint8_t msgWaiting;
|
||||
char buff[16]; // 16 chars line buffer
|
||||
const char timeNosyncSymbol = '?';
|
||||
#ifdef HAS_IF482
|
||||
const char timesyncSymbol = '+';
|
||||
#else
|
||||
const char timesyncSymbol = '*';
|
||||
#endif
|
||||
|
||||
// update counter (lines 0-1)
|
||||
snprintf(
|
||||
@ -210,10 +216,15 @@ void refreshtheDisplay() {
|
||||
#else
|
||||
// update time/date display (line 6)
|
||||
time_t t = myTZ.toLocal(now());
|
||||
char timeState =
|
||||
timeStatus() == timeSet ? timesyncSymbol : timeNosyncSymbol;
|
||||
#ifdef RTC_INT // make timestatus symbol blinking
|
||||
if (second(t) % 2)
|
||||
timeState = ' ';
|
||||
#endif // RTC_INT
|
||||
u8x8.printf("%02d:%02d:%02d%c %2d.%3s", hour(t), minute(t), second(t),
|
||||
timeStatus() == timeSet ? '*' : '?', day(t),
|
||||
printmonth[month(t)]);
|
||||
#endif
|
||||
timeState, day(t), printmonth[month(t)]);
|
||||
#endif // HAS_RTC
|
||||
|
||||
// update LMiC event display (line 7)
|
||||
u8x8.setCursor(0, 7);
|
||||
|
@ -25,11 +25,11 @@
|
||||
#define RTC_INT GPIO_NUM_34 // interrupt input from rtc
|
||||
|
||||
// Settings for IF482 interface
|
||||
//#define HAS_IF482 9600, SERIAL_7E1, GPIO_NUM_12, GPIO_NUM_14 // IF482 serial port parameters
|
||||
#define HAS_IF482 9600, SERIAL_7E1, GPIO_NUM_12, GPIO_NUM_14 // IF482 serial port parameters
|
||||
|
||||
// Settings for external GPS chip
|
||||
//#define HAS_GPS 1 // use on board GPS
|
||||
//#define GPS_SERIAL 9600, SERIAL_8N1, GPIO_NUM_17, GPIO_NUM_16 // UBlox NEO 6M or 7M with default configuration
|
||||
#define HAS_GPS 1 // use on board GPS
|
||||
#define GPS_SERIAL 9600, SERIAL_8N1, GPIO_NUM_17, GPIO_NUM_16 // UBlox NEO 6M or 7M with default configuration
|
||||
|
||||
// Pins for LORA chip SPI interface, reset line and interrupt lines
|
||||
#define LORA_SCK (5)
|
||||
|
@ -1,13 +1,14 @@
|
||||
#if defined HAS_IF482 && defined HAS_RTC
|
||||
#if defined HAS_IF482 && defined RTC_INT
|
||||
|
||||
/* NOTE:
|
||||
The IF482 Generator needs an high precise 1 Hz clock signal which cannot be
|
||||
acquired in suitable precision on the ESP32 SoC itself. Additional clocking
|
||||
hardware is required, ususally the clock signal is generated by external RTC or
|
||||
GPS chip or a GPS chip which can generate a precise clock signal (+/- 2ppm). In
|
||||
this example code we use a Maxim DS3231 RTC chip, and configure it's interrupt
|
||||
output as clock output. The clock signal triggers an interrupt on the ESP32,
|
||||
which controls the realtime output of IF482 telegram. This is why code in
|
||||
GPS which can generate a precise time pulse signal (+/- 2ppm).
|
||||
|
||||
In this example code we use a Maxim DS3231 RTC chip, and configure the chips's
|
||||
interrupt output pin as clock. The clock signal triggers an interrupt on the
|
||||
ESP32, which controls the realtime output of IF482 telegram. This is why code in
|
||||
IF482.cpp depends on code in RTCTIME.cpp.
|
||||
*/
|
||||
|
||||
@ -16,6 +17,7 @@ IF482.cpp depends on code in RTCTIME.cpp.
|
||||
/*
|
||||
IF482 Generator to control clocks with IF482 telegram input (e.g. BÜRK BU190)
|
||||
|
||||
|
||||
Example IF482 telegram: "OAL160806F170400"
|
||||
|
||||
IF482 Specification:
|
||||
|
@ -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))
|
||||
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));
|
||||
}
|
||||
}
|
16
src/main.cpp
16
src/main.cpp
@ -197,7 +197,8 @@ void setup() {
|
||||
ESP_LOGI(TAG, "Unable to sync system time with RTC");
|
||||
else
|
||||
ESP_LOGI(TAG, "RTC has set the system time");
|
||||
setSyncInterval(TIME_SYNC_INTERVAL_RTC);
|
||||
setSyncInterval(TIME_SYNC_INTERVAL_RTC * 60);
|
||||
#endif // HAS_RTC
|
||||
|
||||
#ifdef HAS_IF482
|
||||
strcat_P(features, " IF482");
|
||||
@ -212,8 +213,6 @@ void setup() {
|
||||
0); // CPU core
|
||||
#endif // HAS_IF482
|
||||
|
||||
#endif // HAS_RTC
|
||||
|
||||
// initialize wifi antenna
|
||||
#ifdef HAS_ANTENNA_SWITCH
|
||||
strcat_P(features, " ANT");
|
||||
@ -427,13 +426,18 @@ void setup() {
|
||||
setSyncProvider(&get_gpstime);
|
||||
if (timeStatus() != timeSet)
|
||||
ESP_LOGI(TAG, "Unable to sync system time with GPS");
|
||||
else
|
||||
else {
|
||||
ESP_LOGI(TAG, "GPS has set the system time");
|
||||
setSyncInterval(TIME_SYNC_INTERVAL_GPS);
|
||||
#ifdef HAS_RTC
|
||||
if (set_rtctime(now()))
|
||||
ESP_LOGE(TAG, "RTC set time failure");
|
||||
#endif
|
||||
}
|
||||
setSyncInterval(TIME_SYNC_INTERVAL_GPS * 60);
|
||||
#endif
|
||||
|
||||
// start RTC interrupt
|
||||
#if defined HAS_IF482 && defined HAS_RTC
|
||||
#if defined HAS_IF482 && defined RTC_INT
|
||||
// setup external interupt for active low RTC INT pin
|
||||
assert(IF482Task != NULL); // has if482loop task started?
|
||||
ESP_LOGI(TAG, "Starting IF482 output...");
|
||||
|
@ -82,9 +82,9 @@
|
||||
#define RESPONSE_TIMEOUT_MS 60000 // firmware binary server connection timeout [milliseconds]
|
||||
|
||||
// settings for syncing time of node and external time sources
|
||||
#define TIME_SYNC_INTERVAL_GPS 5 // sync time each ... minutes with GPS [default = 5], comment out means off
|
||||
#define TIME_SYNC_INTERVAL_RTC 5 // sync time each ... minutes with RTC [default = 5], comment out means off
|
||||
//#define TIME_SYNC_INTERVAL_LORA 60 // sync time each ... minutes with LORA network [default = 60], comment out means off
|
||||
#define TIME_SYNC_INTERVAL_GPS 60 // sync time each ... minutes with GPS [default = 60], comment out means off
|
||||
#define TIME_SYNC_INTERVAL_RTC 60 // sync time each ... minutes with RTC [default = 60], comment out means off
|
||||
//#define TIME_SYNC_INTERVAL_LORA 60 // sync time each ... minutes with LORA network [default = 60], comment out means off
|
||||
#define IF482_OFFSET 984 // 1sec minus IF482 serial transmit time [ms]: e.g. 9 bits * 17 bytes * 1/9600 bps = 16ms
|
||||
|
||||
// time zone, see https://github.com/JChristensen/Timezone/blob/master/examples/WorldClock/WorldClock.ino
|
||||
|
Loading…
Reference in New Issue
Block a user