From a0fe9c693b376711b88316f84dafd1da34d82644 Mon Sep 17 00:00:00 2001 From: Marek NOVAK Date: Wed, 9 Mar 2022 21:44:58 +0100 Subject: [PATCH] Fixed class B multicast handling in LoRaMacClassBProcessMulticastSlot() --- src/mac/LoRaMacClassB.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/mac/LoRaMacClassB.c b/src/mac/LoRaMacClassB.c index 28e11868e..b31b36176 100644 --- a/src/mac/LoRaMacClassB.c +++ b/src/mac/LoRaMacClassB.c @@ -1133,12 +1133,15 @@ static void LoRaMacClassBProcessMulticastSlot( void ) case PINGSLOT_STATE_CALC_PING_OFFSET: { // Compute all offsets for every multicast slots - for( uint8_t i = 0; i < 4; i++ ) + for( uint8_t i = 0; i < LORAMAC_MAX_MC_CTX; i++ ) { - ComputePingOffset( Ctx.BeaconCtx.BeaconTime.Seconds, - cur->ChannelParams.Address, - cur->PingPeriod, - &( cur->PingOffset ) ); + if( cur->ChannelParams.IsEnabled ) + { + ComputePingOffset( Ctx.BeaconCtx.BeaconTime.Seconds, + cur->ChannelParams.Address, + cur->PingPeriod, + &( cur->PingOffset ) ); + } cur++; } Ctx.MulticastSlotState = PINGSLOT_STATE_SET_TIMER; @@ -1151,14 +1154,17 @@ static void LoRaMacClassBProcessMulticastSlot( void ) for( uint8_t i = 0; i < LORAMAC_MAX_MC_CTX; i++ ) { - // Calculate the next slot time for every multicast slot - if( CalcNextSlotTime( cur->PingOffset, cur->PingPeriod, cur->PingNb, &slotTime ) == true ) + if( cur->ChannelParams.IsEnabled ) { - if( ( multicastSlotTime == 0 ) || ( multicastSlotTime > slotTime ) ) + // Calculate the next slot time for every multicast slot + if( CalcNextSlotTime( cur->PingOffset, cur->PingPeriod, cur->PingNb, &slotTime ) == true ) { - // Update the slot time and the next multicast channel - multicastSlotTime = slotTime; - Ctx.PingSlotCtx.NextMulticastChannel = cur; + if( ( multicastSlotTime == 0 ) || ( multicastSlotTime > slotTime ) ) + { + // Update the slot time and the next multicast channel + multicastSlotTime = slotTime; + Ctx.PingSlotCtx.NextMulticastChannel = cur; + } } } cur++;