diff --git a/src/mac/region/RegionAS923.c b/src/mac/region/RegionAS923.c index 8775a7a63..5f9606ea4 100644 --- a/src/mac/region/RegionAS923.c +++ b/src/mac/region/RegionAS923.c @@ -917,7 +917,8 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_ NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ); } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -933,7 +934,7 @@ LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionAU915.c b/src/mac/region/RegionAU915.c index b9396c49b..25f29bf7a 100644 --- a/src/mac/region/RegionAU915.c +++ b/src/mac/region/RegionAU915.c @@ -917,7 +917,8 @@ LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_ } } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -933,7 +934,7 @@ LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionCN470.c b/src/mac/region/RegionCN470.c index a367aa65d..51abc2533 100644 --- a/src/mac/region/RegionCN470.c +++ b/src/mac/region/RegionCN470.c @@ -734,7 +734,8 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_ NvmCtx.ChannelsMask[5] = 0xFFFF; } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -750,7 +751,7 @@ LoRaMacStatus_t RegionCN470NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionCN779.c b/src/mac/region/RegionCN779.c index cd193ceca..42ef9cd75 100644 --- a/src/mac/region/RegionCN779.c +++ b/src/mac/region/RegionCN779.c @@ -860,7 +860,8 @@ LoRaMacStatus_t RegionCN779NextChannel( NextChanParams_t* nextChanParams, uint8_ NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 ); } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -876,7 +877,7 @@ LoRaMacStatus_t RegionCN779NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionCommon.c b/src/mac/region/RegionCommon.c index 641323fe5..ebcac5cfb 100644 --- a/src/mac/region/RegionCommon.c +++ b/src/mac/region/RegionCommon.c @@ -185,14 +185,14 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, bool dutyCycle, Band_t* { if( dutyCycle == true ) { - if( bands[i].TimeOff <= TimerGetElapsedTime( bands[i].LastTxDoneTime ) ) + TimerTime_t elapsed = TimerGetElapsedTime( bands[i].LastTxDoneTime ); + if( bands[i].TimeOff <= elapsed ) { bands[i].TimeOff = 0; } if( bands[i].TimeOff != 0 ) { - nextTxDelay = MIN( bands[i].TimeOff - TimerGetElapsedTime( bands[i].LastTxDoneTime ), - nextTxDelay ); + nextTxDelay = MIN( bands[i].TimeOff - elapsed, nextTxDelay ); } } else diff --git a/src/mac/region/RegionEU433.c b/src/mac/region/RegionEU433.c index e73fb5882..877011b16 100644 --- a/src/mac/region/RegionEU433.c +++ b/src/mac/region/RegionEU433.c @@ -860,7 +860,8 @@ LoRaMacStatus_t RegionEU433NextChannel( NextChanParams_t* nextChanParams, uint8_ NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 ); } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -876,7 +877,7 @@ LoRaMacStatus_t RegionEU433NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionEU868.c b/src/mac/region/RegionEU868.c index 562fc3d16..eb4c45633 100644 --- a/src/mac/region/RegionEU868.c +++ b/src/mac/region/RegionEU868.c @@ -892,7 +892,8 @@ LoRaMacStatus_t RegionEU868NextChannel( NextChanParams_t* nextChanParams, uint8_ NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 ); } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -908,7 +909,7 @@ LoRaMacStatus_t RegionEU868NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionIN865.c b/src/mac/region/RegionIN865.c index e0d84768d..d39f1586c 100644 --- a/src/mac/region/RegionIN865.c +++ b/src/mac/region/RegionIN865.c @@ -885,7 +885,8 @@ LoRaMacStatus_t RegionIN865NextChannel( NextChanParams_t* nextChanParams, uint8_ NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 ); } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -901,7 +902,7 @@ LoRaMacStatus_t RegionIN865NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionKR920.c b/src/mac/region/RegionKR920.c index 80a970e13..1c2b70fd5 100644 --- a/src/mac/region/RegionKR920.c +++ b/src/mac/region/RegionKR920.c @@ -854,7 +854,8 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_ NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 ); } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -870,7 +871,7 @@ LoRaMacStatus_t RegionKR920NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionRU864.c b/src/mac/region/RegionRU864.c index 13d49361e..76a55f6fb 100644 --- a/src/mac/region/RegionRU864.c +++ b/src/mac/region/RegionRU864.c @@ -851,7 +851,8 @@ LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_ NvmCtx.ChannelsMask[0] |= LC( 1 ) + LC( 2 ); } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -867,7 +868,7 @@ LoRaMacStatus_t RegionRU864NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 ) diff --git a/src/mac/region/RegionUS915.c b/src/mac/region/RegionUS915.c index 7c3d6f350..f3c9f802b 100644 --- a/src/mac/region/RegionUS915.c +++ b/src/mac/region/RegionUS915.c @@ -1009,7 +1009,8 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_ } } - if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) ) + TimerTime_t elapsed = TimerGetElapsedTime( nextChanParams->LastAggrTx ); + if( nextChanParams->AggrTimeOff <= elapsed ) { // Reset Aggregated time off *aggregatedTimeOff = 0; @@ -1025,7 +1026,7 @@ LoRaMacStatus_t RegionUS915NextChannel( NextChanParams_t* nextChanParams, uint8_ else { delayTx++; - nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx ); + nextTxDelay = nextChanParams->AggrTimeOff - elapsed; } if( nbEnabledChannels > 0 )