From 412136845fa3f00ea2bee7db7e1c57d887ee2db5 Mon Sep 17 00:00:00 2001 From: StevenCellist Date: Mon, 28 Oct 2024 13:02:58 +0100 Subject: [PATCH] [LoRaWAN] Fix persistence of channel mask (fixes #1293) --- src/protocols/LoRaWAN/LoRaWAN.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index b38bf97c..f184c4b2 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -2917,10 +2917,9 @@ void LoRaWANNode::getChannelPlanMask(uint64_t* chMaskGrp0123, uint32_t* chMaskGr *chMaskGrp0123 = 0; *chMaskGrp45 = 0; - uint8_t numCh = this->getAvailableChannels(NULL); - // if there are any channels selected, create the mask from those channels - if(numCh > 0) { + // channels are always selected for dynamic bands and/or when a device is active + if(this->band->bandType == RADIOLIB_LORAWAN_BAND_DYNAMIC || this->isActivated()) { for(int i = 0; i < RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS; i++) { uint8_t idx = this->channelPlan[RADIOLIB_LORAWAN_UPLINK][i].idx; if(idx != RADIOLIB_LORAWAN_CHANNEL_INDEX_NONE) { @@ -2932,12 +2931,6 @@ void LoRaWANNode::getChannelPlanMask(uint64_t* chMaskGrp0123, uint32_t* chMaskGr } } return; - } - - // it should not happen that no channels are set for dynamic band - // but in that case, simply return - if(this->band->bandType == RADIOLIB_LORAWAN_BAND_DYNAMIC) { - return; } else { // bandType == RADIOLIB_LORAWAN_BAND_FIXED // if a subband is set, we can set the channel indices straight from subband