issue #331
This commit is contained in:
parent
edfd8b1fac
commit
6aba3c128b
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -239,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
|
||||
@ -257,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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user