Skip to content

Commit

Permalink
Issue #913 - Added an option for MAC commands to verify against an ex…
Browse files Browse the repository at this point in the history
…plicit confirmation.
  • Loading branch information
Daniel Jaeckle authored and mluis1 committed Oct 13, 2022
1 parent 2ca160b commit 55f83f9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/mac/LoRaMacCommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
}
Expand Down
4 changes: 4 additions & 0 deletions src/mac/LoRaMacCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ struct sMacCommand
* Indicates if it's a sticky MAC command
*/
bool IsSticky;
/*!
* The command requires an explicit confirmation
*/
bool IsConfirmationRequired;
};

/*!
Expand Down

0 comments on commit 55f83f9

Please sign in to comment.