1#if !defined(_RADIOLIB_LORAWAN_PACMAN_H) && !RADIOLIB_EXCLUDE_LORAWAN
2#define _RADIOLIB_LORAWAN_PACMAN_H
7#define RADIOLIB_LORAWAN_NUM_PACKAGES (8)
10#define RADIOLIB_LORAWAN_PACKAGE_TS003 (1)
11#define RADIOLIB_LORAWAN_PACKAGE_TS004 (3)
12#define RADIOLIB_LORAWAN_PACKAGE_TS005 (2)
13#define RADIOLIB_LORAWAN_PACKAGE_TS006 (4)
14#define RADIOLIB_LORAWAN_PACKAGE_TS007 (0)
15#define RADIOLIB_LORAWAN_PACKAGE_TS009 (5)
16#define RADIOLIB_LORAWAN_PACKAGE_TS011 (6)
19#define RADIOLIB_LORAWAN_FPORT_TS003 (202)
20#define RADIOLIB_LORAWAN_FPORT_TS004 (201)
21#define RADIOLIB_LORAWAN_FPORT_TS005 (200)
22#define RADIOLIB_LORAWAN_FPORT_TS006 (203)
23#define RADIOLIB_LORAWAN_FPORT_TS007 (225)
24#define RADIOLIB_LORAWAN_FPORT_TS009 (224)
25#define RADIOLIB_LORAWAN_FPORT_TS011 (226)
35enum LoRaWANTaskType_t {
36 RADIOLIB_LORAWAN_TASK_NONE = 0,
37 RADIOLIB_LORAWAN_TASK_ACTION,
38 RADIOLIB_LORAWAN_TASK_UPLINK
46 LoRaWANTaskType_t type;
94 if(this->getSeconds_cb != NULL) {
95 return(this->getSeconds_cb());
112 uint8_t packageIdentifier;
113 uint8_t packageVersion;
119 GetSecondsCb_t getSeconds_cb;
135 typedef void (*UplinkIntervalCb_t)(
RadioLibTime_t intervalSeconds);
136 typedef void (*RebootCb_t)();
152 int16_t
enableTS003(uint8_t fPort, SetSecondsCb_t setSecondsFunc);
163 int16_t
enableTS009(
PhysicalLayer* radio, DelaySecondsCb_t delayCb, UplinkIntervalCb_t intervalCb, RebootCb_t rebootCb);
201 bool getUplinkData(uint8_t* dataOut,
size_t* lenOut, uint8_t* fPort);
219 bool isEnabledFPort(uint8_t fPort) {
220 for(uint8_t i = 0; i < RADIOLIB_LORAWAN_NUM_PACKAGES; i++) {
221 if(this->enabledPackages[i] && this->packagePorts[i] == fPort) {
234 uint8_t packagePorts[RADIOLIB_LORAWAN_NUM_PACKAGES];
235 bool enabledPackages[RADIOLIB_LORAWAN_NUM_PACKAGES];
238 GetSecondsCb_t getSecondsCb;
LoRaWAN-compatible node (class A device).
Definition LoRaWAN.h:572
Common interface for all application packages.
Definition LoRaWANPacMan.h:54
virtual void doAction()
Perform an ACTION task (if any). Default no-op.
Definition LoRaWANPacMan.cpp:46
void getUplinkData(uint8_t *dataOut, size_t *lenOut)
Get uplink data for UPLINK tasks. Returns internal buffer.
Definition LoRaWANPacMan.cpp:23
virtual size_t processData(const uint8_t *data, size_t len, LoRaWANEvent_t *event)
Process a sequence of package commands and return how many bytes were consumed.
Definition LoRaWANPacMan.cpp:15
virtual LoRaWANTaskInfo hasTask()
Query the next scheduled task for this package.
Definition LoRaWANPacMan.cpp:33
RadioLibTime_t getSeconds()
Get current time via the stored callback.
Definition LoRaWANPacMan.h:93
Interface to manage multiple LoRaWAN application packages.
Definition LoRaWANPacMan.h:129
size_t processPackageManagerData(uint8_t *dataDown, size_t lenDown, uint8_t *ansOut, size_t *ansLen)
Process TS007 package management commands at the manager level.
bool getUplinkData(uint8_t *dataOut, size_t *lenOut, uint8_t *fPort)
Fetch uplink data from the first package reporting an UPLINK task.
Definition LoRaWANPacMan.cpp:211
bool doAction()
Execute the first applicable ACTION task (calls package->doAction()).
Definition LoRaWANPacMan.cpp:239
int16_t enableTS003(uint8_t fPort, SetSecondsCb_t setSecondsFunc)
Enable TS003 Application Time Synchronization package.
Definition LoRaWANPacMan.cpp:64
int16_t enableTS009(PhysicalLayer *radio, DelaySecondsCb_t delayCb, UplinkIntervalCb_t intervalCb, RebootCb_t rebootCb)
Enable TS009 Certification Protocol package.
Definition LoRaWANPacMan.cpp:92
void requestAppTime()
Send an application time request.
Definition LoRaWANPacMan.cpp:124
LoRaWANTaskInfo hasTask()
Query the next scheduled task across all packages and return the first.
Definition LoRaWANPacMan.cpp:179
int16_t processDownlink(const uint8_t *data, size_t len, LoRaWANEvent_t *eventDown)
Process a multi-package downlink payload (TS007 section 3.1).
Definition LoRaWANPacMan.cpp:141
bool getConfirmed()
Check whether subsequent uplinks should be confirmed.
Definition LoRaWANPacMan.cpp:133
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:257
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