Lora-net / LoRaMac-node

Reference implementation and documentation of a LoRa network node.
Other
1.88k stars 1.09k forks source link

Sync Node RTC to network server[Question] #300

Closed rraks closed 6 years ago

rraks commented 7 years ago

I was wondering what the right way to sync the RTC calendar to the network server time is. Is there a best practice you would recommend? I couldn't find documentation about this on the LoRaWAN specs doc for Class C and Class A.

djaeckle commented 7 years ago

Hi RakshitAdmar,

the LoRaWAN Specification defines with Class B a beacon synchronization. The beacon frame contains a time reference. So with Class B you could synchronize your end device time with this time reference.

rraks commented 7 years ago

My question is, can this be done with Class A and Class C ? Otherwise, I will have to add the timestamp as payload on the downlink. The downlink is subject to being queued so for class A this method will not work.

Are you suggesting that I configure my device as a Class B device and then change classes once synchronization is done?

nestorayuso commented 7 years ago

I think LoRaWAN release 1.1 will have a MAC command DeviceTimeReq for that

GuntherSchulz commented 7 years ago

Your Gateway / Network provider should have an API giving the exact network time stamp of when a packet was received. What I do is send an upstream frame containing the time as my end device has it. The backend then compares that time in the payload to the network timestamp of reception at the gateway. Now queue a downstream packet containing the SIGNED DIFFERENCE between the two times, and adjust the node's time accordingly. This way, queing of packets has no bearing on SIGNED TIME DIFFERENCES during previous upstream packet, and time can be adjusted accurately to within the larger resolution of [Network TimeStamp, EndDevice TimeStamp] -> 1 second in my case. Should be more than good enough!

mluis1 commented 6 years ago

Can we close this issue?

GuntherSchulz commented 6 years ago

I dont mind, but @rraks asked the original question.

mluis1 commented 6 years ago

As said by @nestorayuso the LoRaWAN 1.0.3 and 1.1 have a new MAC command named DeviceTimeReq which can be used for this.

avbentem commented 5 years ago

Just for future reference, for 1.0.x the LoRa Alliance released LoRaWAN Application Layer Clock Synchronization Specification v1.0.0 in September 2018:

This document proposes an application layer messaging package running over LoRaWAN to synchronize the real-time clock of an end-device to the network’s GPS clock with second accuracy.

Note:

An end-device using LoRaWAN 1.1 or above SHOULD use DeviceTimeReq MAC command instead of this package. [...] End-devices with an accurate external clock source (e.g.: GPS) SHOULD use that clock source instead.

GuntherSchulz commented 5 years ago

Great to see my idea formalized :)