Skip to content

Commit ab4a779

Browse files
committed
Corrected BACKOFF duty-cycle reference time to be the MAC initialization time.
1 parent be24a23 commit ab4a779

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/mac/LoRaMac.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,13 @@ static bool DutyCycleOn;
496496
*/
497497
static uint8_t Channel;
498498

499+
/*!
500+
* Stores the time at LoRaMac initialization.
501+
*
502+
* \remark Used for the BACKOFF_DC computation.
503+
*/
504+
static TimerTime_t LoRaMacInitializationTime = 0;
505+
499506
/*!
500507
* LoRaMac internal states
501508
*/
@@ -2920,7 +2927,7 @@ static LoRaMacStatus_t ScheduleTx( )
29202927
static uint16_t JoinDutyCycle( void )
29212928
{
29222929
uint16_t dutyCycle = 0;
2923-
TimerTime_t timeElapsed = TimerGetCurrentTime( );
2930+
TimerTime_t timeElapsed = TimerGetElapsedTime( LoRaMacInitializationTime );
29242931

29252932
if( timeElapsed < 3600e3 )
29262933
{
@@ -3073,6 +3080,9 @@ static void ResetMacParameters( void )
30733080

30743081
// Initialize channel index.
30753082
Channel = LORA_MAX_NB_CHANNELS;
3083+
3084+
// Store the current initialization time
3085+
LoRaMacInitializationTime = TimerGetCurrentTime( );
30763086
}
30773087

30783088
LoRaMacStatus_t PrepareFrame( LoRaMacHeader_t *macHdr, LoRaMacFrameCtrl_t *fCtrl, uint8_t fPort, void *fBuffer, uint16_t fBufferSize )

0 commit comments

Comments
 (0)