From 1ed22717d748db981c3c7d002c6fd9f9226137a2 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Aug 2023 21:48:31 +0200 Subject: [PATCH] [LoRaWAN] Added check to not uplink in Rx slots --- src/TypeDef.h | 5 +++++ src/protocols/LoRaWAN/LoRaWAN.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/TypeDef.h b/src/TypeDef.h index e24675b2..96058827 100644 --- a/src/TypeDef.h +++ b/src/TypeDef.h @@ -518,6 +518,11 @@ */ #define RADIOLIB_ERR_INVALID_CID (-1107) +/*! + \brief User requested to start uplink while still inside RX window. +*/ +#define RADIOLIB_ERR_UPLINK_UNAVAILABLE (-1108) + /*! \} */ diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index b31abbb2..c2cd77d7 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -342,9 +342,10 @@ int16_t LoRaWANNode::uplink(uint8_t* data, size_t len, uint8_t port) { // check if sufficient time has elapsed since the last uplink Module* mod = this->phyLayer->getMod(); - /*if(mod->hal->millis() - this->rxDelayStart < ) { - - }*/ + if(mod->hal->millis() - this->rxDelayStart < rxDelays[1]) { + // not enough time elapsed since the last uplink, we may still be in an RX window + return(RADIOLIB_ERR_UPLINK_UNAVAILABLE); + } // build the uplink message // the first 16 bytes are reserved for MIC calculation blocks