Skip to content

Commit b27aa87

Browse files
committed
Fixed potential continuous addition of DeviceTimeReq MAC command while Class B activation is pending
1 parent 7518bb5 commit b27aa87

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/apps/LoRaMac/common/LmHandler/LmHandler.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,19 @@ LmHandlerErrorStatus_t LmHandlerRequestClass( DeviceClass_t newClass )
660660
break;
661661
case CLASS_B:
662662
{
663-
if( currentClass != CLASS_A )
663+
if( IsClassBSwitchPending == false )
664664
{
665-
errorStatus = LORAMAC_HANDLER_ERROR;
665+
if( currentClass != CLASS_A )
666+
{
667+
errorStatus = LORAMAC_HANDLER_ERROR;
668+
}
669+
// Beacon must first be acquired
670+
errorStatus = LmHandlerDeviceTimeReq( );
671+
if( errorStatus == LORAMAC_HANDLER_SUCCESS)
672+
{
673+
IsClassBSwitchPending = true;
674+
}
666675
}
667-
// Beacon must first be acquired
668-
errorStatus = LmHandlerDeviceTimeReq( );
669-
IsClassBSwitchPending = true;
670676
}
671677
break;
672678
case CLASS_C:

0 commit comments

Comments
 (0)