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] | [common] | ||||||
| ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" | ; 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! | ; 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 | ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose | ||||||
| debug_level = 3 | debug_level = 3 | ||||||
|  | |||||||
| @ -139,6 +139,12 @@ void refreshtheDisplay() { | |||||||
| 
 | 
 | ||||||
|     uint8_t msgWaiting; |     uint8_t msgWaiting; | ||||||
|     char buff[16]; // 16 chars line buffer
 |     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)
 |     // update counter (lines 0-1)
 | ||||||
|     snprintf( |     snprintf( | ||||||
| @ -210,10 +216,15 @@ void refreshtheDisplay() { | |||||||
| #else | #else | ||||||
|     // update time/date display (line 6)
 |     // update time/date display (line 6)
 | ||||||
|     time_t t = myTZ.toLocal(now()); |     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), |     u8x8.printf("%02d:%02d:%02d%c %2d.%3s", hour(t), minute(t), second(t), | ||||||
|                 timeStatus() == timeSet ? '*' : '?', day(t), |                 timeState, day(t), printmonth[month(t)]); | ||||||
|                 printmonth[month(t)]); | #endif         // HAS_RTC
 | ||||||
| #endif |  | ||||||
| 
 | 
 | ||||||
|     // update LMiC event display (line 7)
 |     // update LMiC event display (line 7)
 | ||||||
|     u8x8.setCursor(0, 7); |     u8x8.setCursor(0, 7); | ||||||
|  | |||||||
| @ -25,11 +25,11 @@ | |||||||
| #define RTC_INT GPIO_NUM_34 // interrupt input from rtc
 | #define RTC_INT GPIO_NUM_34 // interrupt input from rtc
 | ||||||
| 
 | 
 | ||||||
| // Settings for IF482 interface
 | // 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
 | // Settings for external GPS chip
 | ||||||
| //#define HAS_GPS 1 // use on board GPS
 | #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 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
 | // Pins for LORA chip SPI interface, reset line and interrupt lines
 | ||||||
| #define LORA_SCK  (5)  | #define LORA_SCK  (5)  | ||||||
|  | |||||||
| @ -1,13 +1,14 @@ | |||||||
| #if defined HAS_IF482 && defined HAS_RTC | #if defined HAS_IF482 && defined RTC_INT | ||||||
| 
 | 
 | ||||||
| /* NOTE:
 | /* NOTE:
 | ||||||
| The IF482 Generator needs an high precise 1 Hz clock signal which cannot be | 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 | acquired in suitable precision on the ESP32 SoC itself. Additional clocking | ||||||
| hardware is required, ususally the clock signal is generated by external RTC or | 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 | GPS which can generate a precise time pulse signal (+/- 2ppm). | ||||||
| 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, | In this example code we use a Maxim DS3231 RTC chip, and configure the chips's | ||||||
| which controls the realtime output of IF482 telegram. This is why code in | 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. | 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) | IF482 Generator to control clocks with IF482 telegram input (e.g. BÜRK BU190) | ||||||
|     |     | ||||||
|  | 
 | ||||||
| Example IF482 telegram: "OAL160806F170400" | Example IF482 telegram: "OAL160806F170400" | ||||||
| 
 | 
 | ||||||
| IF482 Specification: | IF482 Specification: | ||||||
|  | |||||||
| @ -455,12 +455,9 @@ void user_request_network_time_callback(void *pVoidUserUTCTime, | |||||||
| 
 | 
 | ||||||
|   // Update system time with time read from the network
 |   // Update system time with time read from the network
 | ||||||
|   setTime(*pUserUTCTime); |   setTime(*pUserUTCTime); | ||||||
|  |   ESP_LOGI(TAG, "LoRaWAN network has set the system time"); | ||||||
| #ifdef HAS_RTC | #ifdef HAS_RTC | ||||||
|   if (!set_rtctime(*pUserUTCTime)) |   if (set_rtctime(*pUserUTCTime)) | ||||||
|     ESP_LOGE(TAG, "RTC set time failure"); |     ESP_LOGE(TAG, "RTC set time failure"); | ||||||
| #endif | #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"); |     ESP_LOGI(TAG, "Unable to sync system time with RTC"); | ||||||
|   else |   else | ||||||
|     ESP_LOGI(TAG, "RTC has set the system time"); |     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 | #ifdef HAS_IF482 | ||||||
|   strcat_P(features, " IF482"); |   strcat_P(features, " IF482"); | ||||||
| @ -212,8 +213,6 @@ void setup() { | |||||||
|                           0);          // CPU core
 |                           0);          // CPU core
 | ||||||
| #endif                                 // HAS_IF482
 | #endif                                 // HAS_IF482
 | ||||||
| 
 | 
 | ||||||
| #endif                                 // HAS_RTC
 |  | ||||||
| 
 |  | ||||||
| // initialize wifi antenna
 | // initialize wifi antenna
 | ||||||
| #ifdef HAS_ANTENNA_SWITCH | #ifdef HAS_ANTENNA_SWITCH | ||||||
|   strcat_P(features, " ANT"); |   strcat_P(features, " ANT"); | ||||||
| @ -427,13 +426,18 @@ void setup() { | |||||||
|   setSyncProvider(&get_gpstime); |   setSyncProvider(&get_gpstime); | ||||||
|   if (timeStatus() != timeSet) |   if (timeStatus() != timeSet) | ||||||
|     ESP_LOGI(TAG, "Unable to sync system time with GPS"); |     ESP_LOGI(TAG, "Unable to sync system time with GPS"); | ||||||
|   else |   else { | ||||||
|     ESP_LOGI(TAG, "GPS has set the system time"); |     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 | #endif | ||||||
| 
 | 
 | ||||||
| // start RTC interrupt
 | // 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
 |   // setup external interupt for active low RTC INT pin
 | ||||||
|   assert(IF482Task != NULL); // has if482loop task started?
 |   assert(IF482Task != NULL); // has if482loop task started?
 | ||||||
|   ESP_LOGI(TAG, "Starting IF482 output..."); |   ESP_LOGI(TAG, "Starting IF482 output..."); | ||||||
|  | |||||||
| @ -82,9 +82,9 @@ | |||||||
| #define RESPONSE_TIMEOUT_MS             60000   // firmware binary server connection timeout [milliseconds] | #define RESPONSE_TIMEOUT_MS             60000   // firmware binary server connection timeout [milliseconds] | ||||||
| 
 | 
 | ||||||
| // settings for syncing time of node and external time sources | // 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_GPS          60      // sync time each ... minutes with GPS [default = 60], 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_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 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 | #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 | // time zone, see https://github.com/JChristensen/Timezone/blob/master/examples/WorldClock/WorldClock.ino | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user