diff --git a/examples/LoRaWAN/LoRaWAN_Reference/LoRaWAN_Reference.ino b/examples/LoRaWAN/LoRaWAN_Reference/LoRaWAN_Reference.ino index 98a3e312..87d7f1eb 100644 --- a/examples/LoRaWAN/LoRaWAN_Reference/LoRaWAN_Reference.ino +++ b/examples/LoRaWAN/LoRaWAN_Reference/LoRaWAN_Reference.ino @@ -69,7 +69,7 @@ void setup() { node.setDutyCycle(true, 1250); // Update dwell time limits - 400ms is the limit for the US - node.setDwellTime(400); + node.setDwellTime(true, 400); Serial.println(F("Ready!\n")); } diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index d6b938f3..53fd2a57 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -2696,8 +2696,15 @@ void LoRaWANNode::setDutyCycle(bool enable, RadioLibTime_t msPerHour) { } } -void LoRaWANNode::setDwellTime(RadioLibTime_t msPerUplink) { - this->dwellTimeUp = msPerUplink; +void LoRaWANNode::setDwellTime(bool enable, RadioLibTime_t msPerUplink) { + if(!enable) { + this->dwellTimeUp = 0; + + } else if(msPerUplink > 0) { + this->dwellTimeUp = msPerUplink; + } else { //msPerUplink == 0 + this->dwellTimeUp = this->band->dwellTimeUp; + } } // A user may enable CSMA to provide frames an additional layer of protection from interference. diff --git a/src/protocols/LoRaWAN/LoRaWAN.h b/src/protocols/LoRaWAN/LoRaWAN.h index eb8839c5..90a51ab8 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.h +++ b/src/protocols/LoRaWAN/LoRaWAN.h @@ -744,10 +744,11 @@ class LoRaWANNode { /*! \brief Set or disable uplink dwell time limitation; enabled by default if mandatory. + \param enable Whether to adhere to dwellTime limits or not (default true). \param msPerUplink The maximum allowed Time-on-Air per uplink in milliseconds - (0 = no dwell time limitation, make sure you follow regulations/law!). + (default 0 = band default value); make sure you follow regulations/law! */ - void setDwellTime(RadioLibTime_t msPerUplink); + void setDwellTime(bool enable, RadioLibTime_t msPerUplink = 0); /*! \brief Configures CSMA for LoRaWAN as per TR013, LoRa Alliance.