From e42cd7e2a5e7d6e7b8f40842921dbf6049ba9b26 Mon Sep 17 00:00:00 2001 From: StevenCellist Date: Wed, 5 Jun 2024 21:27:19 +0200 Subject: [PATCH] [LoRaWAN] Fix dwelltime & JR-dr for AU915, add JR dwelltime check --- src/protocols/LoRaWAN/LoRaWAN.cpp | 9 +++++++++ src/protocols/LoRaWAN/LoRaWANBands.cpp | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index ad33ceae..4cac3fdb 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -36,6 +36,8 @@ LoRaWANNode::LoRaWANNode(PhysicalLayer* phy, const LoRaWANBand_t* band, uint8_t this->difsSlots = 2; this->backoffMax = 6; this->enableCSMA = false; + this->dwellTimeEnabledUp = this->dwellTimeUp != 0; + this->dwellTimeEnabledDn = this->dwellTimeDn != 0; memset(this->availableChannels, 0, sizeof(this->availableChannels)); } @@ -507,6 +509,13 @@ int16_t LoRaWANNode::activateOTAA(uint8_t joinDr, LoRaWANJoinEvent_t *joinEvent) state = this->setPhyProperties(RADIOLIB_LORAWAN_CHANNEL_DIR_UPLINK); RADIOLIB_ASSERT(state); + if(this->dwellTimeEnabledUp) { + RadioLibTime_t toa = this->phyLayer->getTimeOnAir(RADIOLIB_LORAWAN_JOIN_REQUEST_LEN); + if(toa > this->dwellTimeUp) { + return(RADIOLIB_ERR_DWELL_TIME_EXCEEDED); + } + } + // copy devNonce currently in use uint16_t devNonceUsed = this->devNonce; diff --git a/src/protocols/LoRaWAN/LoRaWANBands.cpp b/src/protocols/LoRaWAN/LoRaWANBands.cpp index dcafbd72..d81ce7d0 100644 --- a/src/protocols/LoRaWAN/LoRaWANBands.cpp +++ b/src/protocols/LoRaWAN/LoRaWANBands.cpp @@ -227,7 +227,7 @@ const LoRaWANBand_t AU915 = { .powerMax = 30, .powerNumSteps = 10, .dutyCycle = 0, - .dwellTimeUp = 0, + .dwellTimeUp = RADIOLIB_LORAWAN_DWELL_TIME, .dwellTimeDn = 0, .txFreqs = { RADIOLIB_LORAWAN_CHANNEL_NONE, @@ -247,7 +247,7 @@ const LoRaWANBand_t AU915 = { .freqStep = 0.200, .drMin = 0, .drMax = 5, - .joinRequestDataRate = 0 + .joinRequestDataRate = 2 }, { .numChannels = 8,