@@ -716,7 +716,7 @@ static void LoRaMacClassBProcessBeacon( void )
716716 bool activateTimer = false;
717717 TimerTime_t beaconEventTime = 1 ;
718718 RxConfigParams_t beaconRxConfig ;
719- TimerTime_t currentTime = Ctx .BeaconCtx .TimeStamp ;
719+ TimerTime_t beaconTimestamp = Ctx .BeaconCtx .TimeStamp ;
720720
721721 // Beacon state machine
722722 switch ( Ctx .BeaconState )
@@ -742,10 +742,11 @@ static void LoRaMacClassBProcessBeacon( void )
742742
743743 if ( Ctx .BeaconCtx .BeaconTimingDelay > 0 )
744744 {
745- if ( SysTimeToMs ( Ctx .BeaconCtx .NextBeaconRx ) > currentTime )
745+ uint32_t now = TimerGetCurrentTime ( );
746+ if ( SysTimeToMs ( Ctx .BeaconCtx .NextBeaconRx ) > now )
746747 {
747748 // Calculate the time when we expect the next beacon
748- beaconEventTime = TimerTempCompensation ( SysTimeToMs ( Ctx .BeaconCtx .NextBeaconRx ) - currentTime , Ctx .BeaconCtx .Temperature );
749+ beaconEventTime = TimerTempCompensation ( SysTimeToMs ( Ctx .BeaconCtx .NextBeaconRx ) - now , Ctx .BeaconCtx .Temperature );
749750
750751 if ( ( int32_t ) beaconEventTime > beaconRxConfig .WindowOffset )
751752 {
@@ -837,15 +838,15 @@ static void LoRaMacClassBProcessBeacon( void )
837838 Ctx .BeaconCtx .Ctrl .BeaconAcquired = 0 ;
838839
839840 // Verify if the maximum beacon less period has been elapsed
840- if ( ( currentTime - SysTimeToMs ( Ctx .BeaconCtx .LastBeaconRx ) ) > CLASSB_MAX_BEACON_LESS_PERIOD )
841+ if ( ( beaconTimestamp - SysTimeToMs ( Ctx .BeaconCtx .LastBeaconRx ) ) > CLASSB_MAX_BEACON_LESS_PERIOD )
841842 {
842843 Ctx .BeaconState = BEACON_STATE_LOST ;
843844 }
844845 else
845846 {
846847 // Handle beacon miss
847848 beaconEventTime = UpdateBeaconState ( LORAMAC_EVENT_INFO_STATUS_BEACON_LOST ,
848- Ctx .BeaconCtx .BeaconWindowMovement , currentTime );
849+ Ctx .BeaconCtx .BeaconWindowMovement , beaconTimestamp );
849850
850851 // Setup next state
851852 Ctx .BeaconState = BEACON_STATE_IDLE ;
@@ -861,7 +862,7 @@ static void LoRaMacClassBProcessBeacon( void )
861862
862863 // Handle beacon reception
863864 beaconEventTime = UpdateBeaconState ( LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED ,
864- 0 , currentTime );
865+ 0 , beaconTimestamp );
865866
866867 // Setup the MLME confirm for the MLME_BEACON_ACQUISITION
867868 if ( Ctx .LoRaMacClassBParams .LoRaMacFlags -> Bits .MlmeReq == 1 )
@@ -882,15 +883,15 @@ static void LoRaMacClassBProcessBeacon( void )
882883 activateTimer = true;
883884 GetTemperatureLevel ( & Ctx .LoRaMacClassBCallbacks , & Ctx .BeaconCtx );
884885 beaconEventTime = Ctx .BeaconCtx .NextBeaconRxAdjusted - Radio .GetWakeupTime ( );
885- currentTime = TimerGetCurrentTime ( );
886+ uint32_t now = TimerGetCurrentTime ( );
886887
887888 // The goal is to calculate beaconRxConfig.WindowTimeout and beaconRxConfig.WindowOffset
888889 CalculateBeaconRxWindowConfig ( & beaconRxConfig , Ctx .BeaconCtx .SymbolTimeout );
889890
890- if ( beaconEventTime > currentTime )
891+ if ( beaconEventTime > now )
891892 {
892893 Ctx .BeaconState = BEACON_STATE_GUARD ;
893- beaconEventTime -= currentTime ;
894+ beaconEventTime -= now ;
894895 beaconEventTime = TimerTempCompensation ( beaconEventTime , Ctx .BeaconCtx .Temperature );
895896
896897 if ( ( int32_t ) beaconEventTime > beaconRxConfig .WindowOffset )
0 commit comments