Skip to content

Commit

Permalink
[LoRaWAN] Fix dwelltime & JR-dr for AU915, add JR dwelltime check
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenCellist committed Jun 5, 2024
1 parent aebbdd4 commit e42cd7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/protocols/LoRaWAN/LoRaWAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/protocols/LoRaWAN/LoRaWANBands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -247,7 +247,7 @@ const LoRaWANBand_t AU915 = {
.freqStep = 0.200,
.drMin = 0,
.drMax = 5,
.joinRequestDataRate = 0
.joinRequestDataRate = 2
},
{
.numChannels = 8,
Expand Down

0 comments on commit e42cd7e

Please sign in to comment.