From 62276e070bcc4baac09236f2ecd7409eaf51728d Mon Sep 17 00:00:00 2001 From: StevenCellist Date: Sat, 9 Dec 2023 10:28:13 +0100 Subject: [PATCH] [LoRaWAN] Expose downlink framecounters --- keywords.txt | 3 +++ src/protocols/LoRaWAN/LoRaWAN.cpp | 8 ++++++++ src/protocols/LoRaWAN/LoRaWAN.h | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/keywords.txt b/keywords.txt index 24369e17..6394b32a 100644 --- a/keywords.txt +++ b/keywords.txt @@ -298,6 +298,9 @@ uplink KEYWORD2 downlink KEYWORD2 sendReceive KEYWORD2 setDeviceStatus KEYWORD2 +getFcntUp KEYWORD2 +getNFcntDown KEYWORD2 +getAFcntDown KEYWORD2 setDatarate KEYWORD2 setADR KEYWORD2 setTxPower KEYWORD2 diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index 99c93549..a9370da5 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -1335,6 +1335,14 @@ uint32_t LoRaWANNode::getFcntUp() { return(this->fcntUp); } +uint32_t LoRaWANNode::getNFcntDown() { + return(this->nFcntDown); +} + +uint32_t LoRaWANNode::getAFcntDown() { + return(this->aFcntDown); +} + uint32_t LoRaWANNode::generateMIC(uint8_t* msg, size_t len, uint8_t* key) { if((msg == NULL) || (len == 0)) { return(0); diff --git a/src/protocols/LoRaWAN/LoRaWAN.h b/src/protocols/LoRaWAN/LoRaWAN.h index 30ff2512..f8e1365f 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.h +++ b/src/protocols/LoRaWAN/LoRaWAN.h @@ -527,6 +527,12 @@ class LoRaWANNode { /*! \brief Returns the last uplink's frame counter */ uint32_t getFcntUp(); + /*! \brief Returns the last network downlink's frame counter */ + uint32_t getNFcntDown(); + + /*! \brief Returns the last application downlink's frame counter */ + uint32_t getAFcntDown(); + /*! \brief Set uplink datarate. This should not be used when ADR is enabled. \param dr Datarate to use for uplinks.