Merge pull request #334 from cyberman54/development

Fix issue #331
This commit is contained in:
Verkehrsrot 2019-03-31 15:58:42 +02:00 committed by GitHub
commit 478f60a17d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 14 deletions

View File

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

View File

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

View File

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

View File

@ -12,6 +12,12 @@ static const char TAG[] = "lora";
#warning CLOCK_ERROR_PROCENTAGE value in lmic_config.h is too high; values > 7 will cause side effects
#endif
#if (TIME_SYNC_LORAWAN)
#ifndef LMIC_ENABLE_DeviceTimeReq
#define LMIC_ENABLE_DeviceTimeReq 1
#endif
#endif
osjob_t sendjob;
QueueHandle_t LoraSendQueue;
@ -233,7 +239,7 @@ void onEvent(ev_t ev) {
case EV_TXCOMPLETE:
#if (TIME_SYNC_TIMESERVER)
#if (TIME_SYNC_LORASERVER)
// if last packet sent was a timesync request, store TX timestamp
if (LMIC.pendTxPort == TIMEPORT) {
store_time_sync_req(osticks2ms(LMIC.txend)); // milliseconds
@ -251,7 +257,7 @@ void onEvent(ev_t ev) {
if (LMIC.txrxFlags & TXRX_PORT) { // FPort -> use to switch
switch (LMIC.frame[LMIC.dataBeg - 1]) {
#if (TIME_SYNC_TIMESERVER)
#if (TIME_SYNC_LORASERVER)
case TIMEPORT: // timesync answer -> call timesync processor
recv_timesync_ans(LMIC.frame + LMIC.dataBeg, LMIC.dataLen);
break;

View File

@ -411,7 +411,7 @@ void setup() {
#endif // HAS_BUTTON
#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)
#warning you did not specify a time source, time will not be synched
#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_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]
#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
#define TIME_SYNC_SAMPLES 1 // number of time requests for averaging

View File

@ -1,8 +1,8 @@
#include "timekeeper.h"
#ifndef HAS_LORA
#if (TIME_SYNC_TIMESERVER)
#error TIME_SYNC_TIMESERVER defined, but device has no LORA configured
#if !(HAS_LORA)
#if (TIME_SYNC_LORASERVER)
#error TIME_SYNC_LORASERVER defined, but device has no LORA configured
#elif (TIME_SYNC_LORAWAN)
#error TIME_SYNC_LORAWAN defined, but device has no LORA configured
#endif
@ -48,10 +48,10 @@ time_t timeProvider(void) {
#endif
// kick off asychronous Lora timeserver timesync if we have
#if (TIME_SYNC_TIMESERVER)
#if (HAS_LORA) && (TIME_SYNC_LORASERVER)
send_timesync_req();
// 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);
#endif

View File

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