Skip to content

Commit 832c78a

Browse files
Daniel Jaecklemluis1
authored andcommitted
Fixed an issue where the Join back off algorithm wasn't being applied when the duty-cycle enforcement was OFF.
1 parent 118771f commit 832c78a

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/mac/region/RegionCommon.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, Band_t* bands,
337337
// when the duty cycle is off, or the TimeCredits of the band
338338
// is higher than the credit costs for the transmission.
339339
if( ( bands[i].TimeCredits > creditCosts ) ||
340-
( dutyCycleEnabled == false ) )
340+
( ( dutyCycleEnabled == false ) && ( joined == true ) ) )
341341
{
342342
bands[i].ReadyForTransmission = true;
343343
// This band is a potential candidate for an
@@ -350,24 +350,22 @@ TimerTime_t RegionCommonUpdateBandTimeOff( bool joined, Band_t* bands,
350350
// for the next transmission.
351351
bands[i].ReadyForTransmission = false;
352352

353-
// Differentiate the calculation if the device is joined or not.
354-
if( joined == true )
353+
if( bands[i].MaxTimeCredits > creditCosts )
355354
{
356-
if( bands[i].MaxTimeCredits > creditCosts )
357-
{
358-
// The band can only be taken into account, if the maximum credits
359-
// of the band are higher than the credit costs.
360-
// We calculate the minTimeToWait among the bands which are not
361-
// ready for transmission and which are potentially available
362-
// for a transmission in the future.
363-
minTimeToWait = MIN( minTimeToWait, ( creditCosts - bands[i].TimeCredits ) );
364-
// This band is a potential candidate for an
365-
// upcoming transmission (even if its time credits are not enough
366-
// at the moment), so increase the counter.
367-
validBands++;
368-
}
355+
// The band can only be taken into account, if the maximum credits
356+
// of the band are higher than the credit costs.
357+
// We calculate the minTimeToWait among the bands which are not
358+
// ready for transmission and which are potentially available
359+
// for a transmission in the future.
360+
minTimeToWait = MIN( minTimeToWait, ( creditCosts - bands[i].TimeCredits ) );
361+
// This band is a potential candidate for an
362+
// upcoming transmission (even if its time credits are not enough
363+
// at the moment), so increase the counter.
364+
validBands++;
369365
}
370-
else
366+
367+
// Apply a special calculation if the device is not joined.
368+
if( joined == false )
371369
{
372370
SysTime_t backoffTimeRange = {
373371
.Seconds = 0,

0 commit comments

Comments
 (0)