commit
27f484f01f
@ -36,6 +36,9 @@ void lora_send(osjob_t *job);
|
|||||||
void lora_enqueuedata(MessageBuffer_t *message, sendprio_t prio);
|
void lora_enqueuedata(MessageBuffer_t *message, sendprio_t prio);
|
||||||
void lora_queuereset(void);
|
void lora_queuereset(void);
|
||||||
void lora_housekeeping(void);
|
void lora_housekeeping(void);
|
||||||
|
#if (TIME_SYNC_LORAWAN)
|
||||||
void user_request_network_time_callback(void *pVoidUserUTCTime,
|
void user_request_network_time_callback(void *pVoidUserUTCTime,
|
||||||
int flagSuccess);
|
int flagSuccess);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -14,6 +14,6 @@ void send_timesync_req(void);
|
|||||||
int recv_timesync_ans(uint8_t buf[], uint8_t buf_len);
|
int recv_timesync_ans(uint8_t buf[], uint8_t buf_len);
|
||||||
void process_timesync_req(void *taskparameter);
|
void process_timesync_req(void *taskparameter);
|
||||||
void store_time_sync_req(uint32_t t_millisec);
|
void store_time_sync_req(uint32_t t_millisec);
|
||||||
int adjustTime(uint32_t t_sec, uint16_t t_msec);
|
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -31,7 +31,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.41
|
release_version = 1.7.422
|
||||||
; 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
|
||||||
|
@ -62,8 +62,8 @@
|
|||||||
//#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 DCF77 interface
|
// Settings for DCF77 interface
|
||||||
#define HAS_DCF77 GPIO_NUM_1
|
//#define HAS_DCF77 GPIO_NUM_1
|
||||||
#define DCF77_ACTIVE_LOW 1
|
//#define DCF77_ACTIVE_LOW 1
|
||||||
|
|
||||||
// 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)
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
//#define LMIC_USE_INTERRUPTS 1
|
//#define LMIC_USE_INTERRUPTS 1
|
||||||
|
|
||||||
//time sync via LoRaWAN network, is not yet supported by TTN (LoRaWAN spec v1.0.3)
|
//time sync via LoRaWAN network, is not yet supported by TTN (LoRaWAN spec v1.0.3)
|
||||||
#define LMIC_ENABLE_DeviceTimeReq 1
|
//#define LMIC_ENABLE_DeviceTimeReq 1
|
||||||
|
|
||||||
// 16 μs per tick
|
// 16 μs per tick
|
||||||
// LMIC requires ticks to be 15.5μs - 100 μs long
|
// LMIC requires ticks to be 15.5μs - 100 μs long
|
||||||
|
@ -462,6 +462,7 @@ void lora_housekeeping(void) {
|
|||||||
// uxTaskGetStackHighWaterMark(LoraTask));
|
// uxTaskGetStackHighWaterMark(LoraTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (TIME_SYNC_LORAWAN)
|
||||||
void IRAM_ATTR user_request_network_time_callback(void *pVoidUserUTCTime,
|
void IRAM_ATTR user_request_network_time_callback(void *pVoidUserUTCTime,
|
||||||
int flagSuccess) {
|
int flagSuccess) {
|
||||||
// Explicit conversion from void* to uint32_t* to avoid compiler errors
|
// Explicit conversion from void* to uint32_t* to avoid compiler errors
|
||||||
@ -504,11 +505,12 @@ void IRAM_ATTR user_request_network_time_callback(void *pVoidUserUTCTime,
|
|||||||
time_t requestDelaySec = osticks2ms(ticksNow - ticksRequestSent) / 1000;
|
time_t requestDelaySec = osticks2ms(ticksNow - ticksRequestSent) / 1000;
|
||||||
|
|
||||||
// Update system time with time read from the network
|
// Update system time with time read from the network
|
||||||
adjustTime(*pUserUTCTime + requestDelaySec, 0);
|
setMyTime(*pUserUTCTime + requestDelaySec, 0);
|
||||||
|
|
||||||
// end of time critical section: release I2C bus
|
// end of time critical section: release I2C bus
|
||||||
I2C_MUTEX_UNLOCK();
|
I2C_MUTEX_UNLOCK();
|
||||||
|
|
||||||
} // user_request_network_time_callback
|
} // user_request_network_time_callback
|
||||||
|
#endif // TIME_SYNC_LORAWAN
|
||||||
|
|
||||||
#endif // HAS_LORA
|
#endif // HAS_LORA
|
||||||
|
@ -411,6 +411,11 @@ void setup() {
|
|||||||
#endif // HAS_BUTTON
|
#endif // HAS_BUTTON
|
||||||
|
|
||||||
#if (TIME_SYNC_INTERVAL)
|
#if (TIME_SYNC_INTERVAL)
|
||||||
|
#if (!defined(TIME_SYNC_LORAWAN) && !defined(TIME_SYNC_TIMESERVER) && \
|
||||||
|
!defined HAS_GPS && !defined HAS_RTC)
|
||||||
|
#warning you did not specify a time source, time will not be synched
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
// start pps timepulse
|
// start pps timepulse
|
||||||
ESP_LOGI(TAG, "Starting Timekeeper...");
|
ESP_LOGI(TAG, "Starting Timekeeper...");
|
||||||
assert(timepulse_init()); // setup timepulse
|
assert(timepulse_init()); // setup timepulse
|
||||||
|
@ -130,7 +130,7 @@ void process_timesync_req(void *taskparameter) {
|
|||||||
// calculate fraction milliseconds
|
// calculate fraction milliseconds
|
||||||
time_to_set_fraction_msec = (uint16_t)(time_offset_ms.count() % 1000);
|
time_to_set_fraction_msec = (uint16_t)(time_offset_ms.count() % 1000);
|
||||||
|
|
||||||
adjustTime(time_to_set, time_to_set_fraction_msec);
|
setMyTime(time_to_set, time_to_set_fraction_msec);
|
||||||
|
|
||||||
// end of time critical section: release I2C bus
|
// end of time critical section: release I2C bus
|
||||||
I2C_MUTEX_UNLOCK();
|
I2C_MUTEX_UNLOCK();
|
||||||
@ -213,7 +213,7 @@ int recv_timesync_ans(uint8_t buf[], uint8_t buf_len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// adjust system time, calibrate RTC and RTC_INT pps
|
// adjust system time, calibrate RTC and RTC_INT pps
|
||||||
int IRAM_ATTR adjustTime(uint32_t t_sec, uint16_t t_msec) {
|
void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec) {
|
||||||
|
|
||||||
time_t time_to_set = (time_t)t_sec;
|
time_t time_to_set = (time_t)t_sec;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user