commit
478f60a17d
@ -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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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"
|
||||||
|
@ -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
|
#warning CLOCK_ERROR_PROCENTAGE value in lmic_config.h is too high; values > 7 will cause side effects
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (TIME_SYNC_LORAWAN)
|
||||||
|
#ifndef LMIC_ENABLE_DeviceTimeReq
|
||||||
|
#define LMIC_ENABLE_DeviceTimeReq 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
osjob_t sendjob;
|
osjob_t sendjob;
|
||||||
QueueHandle_t LoraSendQueue;
|
QueueHandle_t LoraSendQueue;
|
||||||
|
|
||||||
@ -233,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
|
||||||
@ -251,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;
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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"
|
#include "timesync.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user