This commit is contained in:
Verkehrsrot 2019-03-31 15:56:56 +02:00
parent edfd8b1fac
commit 6aba3c128b
8 changed files with 14 additions and 14 deletions

View File

@ -4,7 +4,7 @@
#include "globals.h" #include "globals.h"
#include "rcommand.h" #include "rcommand.h"
#include "timekeeper.h" #include "timekeeper.h"
#if(TIME_SYNC_TIMESERVER) #if(TIME_SYNC_LORASERVER)
#include "timesync.h" #include "timesync.h"
#endif #endif

View File

@ -11,7 +11,7 @@
#include <rom/rtc.h> #include <rom/rtc.h>
#include "cyclic.h" #include "cyclic.h"
#include "timekeeper.h" #include "timekeeper.h"
#if(TIME_SYNC_TIMESERVER) #if(TIME_SYNC_LORASERVER)
#include "timesync.h" #include "timesync.h"
#endif #endif

View File

@ -1,5 +1,5 @@
#ifndef _TIME_SYNC_TIMESERVER_H #ifndef _TIME_SYNC_LORASERVER_H
#define _TIME_SYNC_TIMESERVER_H #define _TIME_SYNC_LORASERVER_H
#include <chrono> #include <chrono>
#include "globals.h" #include "globals.h"

View File

@ -239,7 +239,7 @@ void onEvent(ev_t ev) {
case EV_TXCOMPLETE: case EV_TXCOMPLETE:
#if (TIME_SYNC_TIMESERVER) #if (TIME_SYNC_LORASERVER)
// if last packet sent was a timesync request, store TX timestamp // if last packet sent was a timesync request, store TX timestamp
if (LMIC.pendTxPort == TIMEPORT) { if (LMIC.pendTxPort == TIMEPORT) {
store_time_sync_req(osticks2ms(LMIC.txend)); // milliseconds store_time_sync_req(osticks2ms(LMIC.txend)); // milliseconds
@ -257,7 +257,7 @@ void onEvent(ev_t ev) {
if (LMIC.txrxFlags & TXRX_PORT) { // FPort -> use to switch if (LMIC.txrxFlags & TXRX_PORT) { // FPort -> use to switch
switch (LMIC.frame[LMIC.dataBeg - 1]) { switch (LMIC.frame[LMIC.dataBeg - 1]) {
#if (TIME_SYNC_TIMESERVER) #if (TIME_SYNC_LORASERVER)
case TIMEPORT: // timesync answer -> call timesync processor case TIMEPORT: // timesync answer -> call timesync processor
recv_timesync_ans(LMIC.frame + LMIC.dataBeg, LMIC.dataLen); recv_timesync_ans(LMIC.frame + LMIC.dataBeg, LMIC.dataLen);
break; break;

View File

@ -411,7 +411,7 @@ 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) && \ #if (!defined(TIME_SYNC_LORAWAN) && !defined(TIME_SYNC_LORASERVER) && \
!defined HAS_GPS && !defined HAS_RTC) !defined HAS_GPS && !defined HAS_RTC)
#warning you did not specify a time source, time will not be synched #warning you did not specify a time source, time will not be synched
#endif #endif

View File

@ -70,7 +70,7 @@
#define TIME_SYNC_INTERVAL_RETRY 0 // retry time sync after lost sync each .. minutes [default = 10], 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_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_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] #define TIME_SYNC_LORASERVER 0 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0]
// settings for syncing time with timeserver applications // settings for syncing time with timeserver applications
#define TIME_SYNC_SAMPLES 1 // number of time requests for averaging #define TIME_SYNC_SAMPLES 1 // number of time requests for averaging

View File

@ -1,8 +1,8 @@
#include "timekeeper.h" #include "timekeeper.h"
#ifndef HAS_LORA #if !(HAS_LORA)
#if (TIME_SYNC_TIMESERVER) #if (TIME_SYNC_LORASERVER)
#error TIME_SYNC_TIMESERVER defined, but device has no LORA configured #error TIME_SYNC_LORASERVER defined, but device has no LORA configured
#elif (TIME_SYNC_LORAWAN) #elif (TIME_SYNC_LORAWAN)
#error TIME_SYNC_LORAWAN defined, but device has no LORA configured #error TIME_SYNC_LORAWAN defined, but device has no LORA configured
#endif #endif
@ -48,10 +48,10 @@ time_t timeProvider(void) {
#endif #endif
// kick off asychronous Lora timeserver timesync if we have // kick off asychronous Lora timeserver timesync if we have
#if (TIME_SYNC_TIMESERVER) #if (HAS_LORA) && (TIME_SYNC_LORASERVER)
send_timesync_req(); send_timesync_req();
// kick off asychronous lora network sync if we have // kick off asychronous lora network sync if we have
#elif (TIME_SYNC_LORAWAN) #elif (HAS_LORA) && (TIME_SYNC_LORAWAN)
LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime); LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime);
#endif #endif

View File

@ -9,7 +9,7 @@ algorithm in applications without granted license by the patent holder.
*/ */
#if(TIME_SYNC_TIMESERVER) #if(TIME_SYNC_LORASERVER)
#include "timesync.h" #include "timesync.h"