Skip to content

Commit 5b4ac08

Browse files
committed
Update the function LoRaMacCommandsRemoveStickyAnsCmds to remove all occurrences of a sticky Mac command
#529
1 parent 173f513 commit 5b4ac08

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/mac/LoRaMacCommands.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,28 @@ LoRaMacCommandStatus_t LoRaMacCommandsRemoveNoneStickyCmds( void )
456456

457457
LoRaMacCommandStatus_t LoRaMacCommandsRemoveStickyAnsCmds( void )
458458
{
459-
MacCommand_t* macCmd;
459+
MacCommand_t* curElement;
460+
MacCommand_t* nexElement;
460461

461-
for( uint8_t i = 0; i < sizeof( CIDsStickyAnsCmds ); i++)
462+
// Start at the head of the list
463+
curElement = NvmCtx.MacCommandList.First;
464+
465+
// Loop through all elements
466+
while( curElement != NULL )
462467
{
463-
if( LoRaMacCommandsGetCmd( CIDsStickyAnsCmds[i], &macCmd ) == LORAMAC_COMMANDS_SUCCESS )
468+
nexElement = curElement->Next;
469+
if( curElement->IsSticky == true )
464470
{
465-
LoRaMacCommandsRemoveCmd( macCmd );
471+
for( uint8_t i = 0; i < sizeof( CIDsStickyAnsCmds ); i++)
472+
{
473+
if( curElement->CID == CIDsStickyAnsCmds[i] )
474+
{
475+
LoRaMacCommandsRemoveCmd( curElement );
476+
break;
477+
}
478+
}
466479
}
480+
curElement = nexElement;
467481
}
468482

469483
NvmCtxCallback( );

0 commit comments

Comments
 (0)