RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
LoRaWANPackageTS003.h
1#if !defined(_RADIOLIB_LORAWAN_PACKAGE_TS003_H) && !RADIOLIB_EXCLUDE_LORAWAN
2#define _RADIOLIB_LORAWAN_PACKAGE_TS003_H
3
4#include "LoRaWANPacMan.h"
5
6// The major benefit of using this package compared to using the DeviceTimeReq MAC
7// command is that, most of the time, the Application Server is not required to answer the
8// AppTimeReq command from the end-device. A downlink is only required when the end
9// device clock is outside the accuracy requirement that is targeted by the application. In
10// contrast, every DeviceTimeReq MAC command sent by the end-device requires an answer
11// from the Network Server.
12
13#define RADIOLIB_LORAWAN_TS003_PACKAGE_VERSION (0x00)
14#define RADIOLIB_LORAWAN_TS003_APP_TIME (0x01)
15#define RADIOLIB_LORAWAN_TS003_APP_TIME_PERIODICITY (0x02)
16#define RADIOLIB_LORAWAN_TS003_FORCE_DEVICE_RESYNC (0x03)
17
23 public:
24
25 // copy constructor is removed to prevent users from creating copies of this class
26 LoRaWANPackageTS003(const LoRaWANPackageTS003& obj) = delete;
27
33 size_t processData(const uint8_t* dataDown, size_t lenDown, LoRaWANEvent_t* event) override;
34
39 int16_t requestAppTime(bool force = false);
40
46 void setSecondsCb(SetSecondsCb_t setSecondsCb);
47
52 LoRaWANTaskInfo hasTask() override;
53
57 void doAction() override;
58
59#if !RADIOLIB_GODMODE
60 protected:
61#endif
62
63 SetSecondsCb_t setSeconds; // callback to configure current GPS time in seconds since epoch
64 uint8_t tokenReq; // validation of AppTimeReq response
65 uint8_t transmissions; // maximum number of AppTimeReq (re)transmissions
66 uint32_t periodicity; // requested interval between AppTimeReq transmissions (s)
67 RadioLibTime_t nextAppReqTime; // next scheduled AppTimeReq transmission
68
69#if !RADIOLIB_GODMODE
70 private:
71#endif
72 // private constructor, to not allow the user to create additional instances of this package
79 LoRaWANPackageTS003(LoRaWANPackageManager* pacMan, LoRaWANNode* node, GetSecondsCb_t secondsCb);
80
81 // allow LoRaWANPackageManager to access the private constructor
83};
84
85#endif
LoRaWAN-compatible node (class A device).
Definition LoRaWAN.h:572
Common interface for all application packages.
Definition LoRaWANPacMan.h:54
Interface to manage multiple LoRaWAN application packages.
Definition LoRaWANPacMan.h:129
LoRaWAN Application package for TS003 Application Time.
Definition LoRaWANPackageTS003.h:22
void doAction() override
Perform an ACTION task (if any).
Definition LoRaWANPackageTS003.cpp:63
void(* SetSecondsCb_t)(RadioLibTime_t)
Set the setSeconds callback function.
Definition LoRaWANPackageTS003.h:45
int16_t requestAppTime(bool force=false)
Send an application time request.
Definition LoRaWANPackageTS003.cpp:162
size_t processData(const uint8_t *dataDown, size_t lenDown, LoRaWANEvent_t *event) override
Process downlink data for the TS003 application time package.
Definition LoRaWANPackageTS003.cpp:67
LoRaWANTaskInfo hasTask() override
Find out what the next task is and when it occurs.
Definition LoRaWANPackageTS003.cpp:15
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:679
Structure to save extra information about uplink/downlink event.
Definition LoRaWAN.h:529
Structure displaying pending LoRaWAN task information.
Definition LoRaWANPacMan.h:45