diff --git a/src/mac/LoRaMacCommands.c b/src/mac/LoRaMacCommands.c index efbe9f90c..a4697b10d 100644 --- a/src/mac/LoRaMacCommands.c +++ b/src/mac/LoRaMacCommands.c @@ -267,7 +267,7 @@ static bool LinkedListRemove( MacCommandsList_t* list, MacCommand_t* element ) /* * \brief Determines if a MAC command is sticky or not * - * \param[IN] cid - MAC command identifier + * \param[IN] cid - MAC command identifier * * \retval - Status of the operation */ @@ -289,6 +289,26 @@ static bool IsSticky( uint8_t cid ) } } +/* + * \brief Determines if a MAC command requires an explicit confirmation + * + * \param[IN] cid - MAC command identifier + * + * \retval - Status of the operation + */ +static bool IsConfirmationRequired( uint8_t cid ) +{ + switch( cid ) + { + case MOTE_MAC_RESET_IND: + case MOTE_MAC_REKEY_IND: + case MOTE_MAC_DEVICE_MODE_IND: + return true; + default: + return false; + } +} + LoRaMacCommandStatus_t LoRaMacCommandsInit( void ) { // Initialize with default @@ -326,6 +346,7 @@ LoRaMacCommandStatus_t LoRaMacCommandsAddCmd( uint8_t cid, uint8_t* payload, siz newCmd->PayloadSize = payloadSize; memcpy1( ( uint8_t* )newCmd->Payload, payload, payloadSize ); newCmd->IsSticky = IsSticky( cid ); + newCmd->IsConfirmationRequired = IsConfirmationRequired( cid ); CommandsCtx.SerializedCmdsSize += ( CID_FIELD_SIZE + payloadSize ); @@ -418,7 +439,8 @@ LoRaMacCommandStatus_t LoRaMacCommandsRemoveStickyAnsCmds( void ) while( curElement != NULL ) { nexElement = curElement->Next; - if( IsSticky( curElement->CID ) == true ) + if( ( IsSticky( curElement->CID ) == true ) && + ( IsConfirmationRequired( curElement->CID ) == false ) ) { LoRaMacCommandsRemoveCmd( curElement ); } diff --git a/src/mac/LoRaMacCommands.h b/src/mac/LoRaMacCommands.h index 10bb15083..144b1fd36 100644 --- a/src/mac/LoRaMacCommands.h +++ b/src/mac/LoRaMacCommands.h @@ -77,6 +77,10 @@ struct sMacCommand * Indicates if it's a sticky MAC command */ bool IsSticky; + /*! + * The command requires an explicit confirmation + */ + bool IsConfirmationRequired; }; /*!