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)
28#define RADIOLIB_LORAWAN_TS007_CID_PKG_VERSION (0x00)
29#define RADIOLIB_LORAWAN_TS007_CID_DEV_PACKAGE (0x01)
30#define RADIOLIB_LORAWAN_TS007_CID_MULTI_PACK_BUFFER (0x02)
31#define RADIOLIB_LORAWAN_TS007_PACKAGE_VERSION_NUM (1)
32#define RADIOLIB_LORAWAN_TS007_ERROR (0xFF)
35#define RADIOLIB_LORAWAN_TS007_PACKAGE_ID_FLAG (0x80)
38#define RADIOLIB_LORAWAN_TS007_ANS_BUFFER_SIZE (128)
53 LoRaWANPackage(
const LoRaWANPackage& obj) =
delete;
90 if(this->getSeconds_cb != NULL) {
91 return(this->getSeconds_cb());
109 uint8_t packageIdentifier;
110 uint8_t packageVersion;
115 GetSecondsCb_t getSeconds_cb;
131 typedef void (*UplinkIntervalCb_t)(
RadioLibTime_t intervalSeconds);
132 typedef void (*ConfirmedCb_t)(
bool confirmed);
133 typedef void (*RebootCb_t)();
150 int16_t
enableTS003(uint8_t fPort, SetSecondsCb_t setSecondsFunc);
167 int16_t
enableTS009(
PhysicalLayer* radio, DelaySecondsCb_t delayCb, UplinkIntervalCb_t intervalCb, ConfirmedCb_t confirmedCb, RebootCb_t rebootCb);
202 bool getUplinkData(uint8_t* dataOut,
size_t* lenOut, uint8_t* fPort);
204 bool isEnabledFPort(uint8_t fPort) {
205 for(uint8_t i = 0; i < RADIOLIB_LORAWAN_NUM_PACKAGES; i++) {
206 if(this->enabledPackages[i] && this->packagePorts[i] == fPort) {
219 void handleMultiPackBufferReq(uint8_t startByte, uint8_t stopByte);
223 size_t processPackageManagerData(
const uint8_t* dataDown,
size_t lenDown, uint8_t* ansOut,
size_t* ansLen);
228 uint8_t packagePorts[RADIOLIB_LORAWAN_NUM_PACKAGES];
229 bool enabledPackages[RADIOLIB_LORAWAN_NUM_PACKAGES];
232 GetSecondsCb_t getSecondsCb;
237 uint8_t ansBuffer[255] = { 0 };
238 size_t ansBufferLen = 0;
239 uint8_t ansFPort = 0;
244 uint8_t ts007Buffer[RADIOLIB_LORAWAN_TS007_ANS_BUFFER_SIZE] = { 0 };
245 size_t ts007BufferLen = 0;
246 uint8_t commandToken = 0;
250 bool pendingUplink =
false;
251 uint8_t pendingPackage = 0;
254 bool sendFragmented =
false;
255 bool indexError =
false;
LoRaWAN-compatible node (class A device).
Definition LoRaWAN.h:557
Common interface for all application packages.
Definition LoRaWANPacMan.h:47
virtual size_t processData(const uint8_t *dataIn, size_t lenIn, uint8_t *dataOut, size_t *lenOut, LoRaWANEvent_t *event)
Process a single package command, writing any answer into the buffer provided by the package manager.
Definition LoRaWANPacMan.cpp:14
virtual size_t buildUplink(uint8_t *dataOut)
Build the uplink that handleTask() reported as due, at the moment of transmission,...
Definition LoRaWANPacMan.cpp:32
virtual bool handleTask(RadioLibTime_t *tNext, bool *uplinkDue)
Execute any scheduled task that is due now and report when this package next needs servicing....
Definition LoRaWANPacMan.cpp:25
RadioLibTime_t getSeconds()
Get current time via the stored callback.
Definition LoRaWANPacMan.h:89
Interface to manage multiple LoRaWAN application packages.
Definition LoRaWANPacMan.h:125
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:396
int16_t enableTS003(uint8_t fPort, SetSecondsCb_t setSecondsFunc)
Enable TS003 Application Time Synchronization package.
Definition LoRaWANPacMan.cpp:54
int16_t enableTS009(PhysicalLayer *radio, DelaySecondsCb_t delayCb, UplinkIntervalCb_t intervalCb, ConfirmedCb_t confirmedCb, RebootCb_t rebootCb)
Enable TS009 Certification Protocol package.
Definition LoRaWANPacMan.cpp:97
void requestAppTime()
Send an application time request.
Definition LoRaWANPacMan.cpp:130
int16_t enableTS007()
Enable TS007 Multi-package Access Control package.
Definition LoRaWANPacMan.cpp:81
LoRaWANPackageManager(RadioLibHal *hal, LoRaWANNode *node, GetSecondsCb_t secondsCb)
Create a package manager.
Definition LoRaWANPacMan.cpp:40
bool handleTask(RadioLibTime_t *tNext)
Execute any due tasks across all packages and report when the manager next needs servicing.
Definition LoRaWANPacMan.cpp:333
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:139
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:402
Hardware abstraction library base interface.
Definition Hal.h:18
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:783
Structure to save extra information about uplink/downlink event.
Definition LoRaWAN.h:514