Skip to content

Commit 55f83f9

Browse files
Daniel Jaecklemluis1
authored andcommitted
Issue #913 - Added an option for MAC commands to verify against an explicit confirmation.
1 parent 2ca160b commit 55f83f9

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/mac/LoRaMacCommands.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static bool LinkedListRemove( MacCommandsList_t* list, MacCommand_t* element )
267267
/*
268268
* \brief Determines if a MAC command is sticky or not
269269
*
270-
* \param[IN] cid - MAC command identifier
270+
* \param[IN] cid - MAC command identifier
271271
*
272272
* \retval - Status of the operation
273273
*/
@@ -289,6 +289,26 @@ static bool IsSticky( uint8_t cid )
289289
}
290290
}
291291

292+
/*
293+
* \brief Determines if a MAC command requires an explicit confirmation
294+
*
295+
* \param[IN] cid - MAC command identifier
296+
*
297+
* \retval - Status of the operation
298+
*/
299+
static bool IsConfirmationRequired( uint8_t cid )
300+
{
301+
switch( cid )
302+
{
303+
case MOTE_MAC_RESET_IND:
304+
case MOTE_MAC_REKEY_IND:
305+
case MOTE_MAC_DEVICE_MODE_IND:
306+
return true;
307+
default:
308+
return false;
309+
}
310+
}
311+
292312
LoRaMacCommandStatus_t LoRaMacCommandsInit( void )
293313
{
294314
// Initialize with default
@@ -326,6 +346,7 @@ LoRaMacCommandStatus_t LoRaMacCommandsAddCmd( uint8_t cid, uint8_t* payload, siz
326346
newCmd->PayloadSize = payloadSize;
327347
memcpy1( ( uint8_t* )newCmd->Payload, payload, payloadSize );
328348
newCmd->IsSticky = IsSticky( cid );
349+
newCmd->IsConfirmationRequired = IsConfirmationRequired( cid );
329350

330351
CommandsCtx.SerializedCmdsSize += ( CID_FIELD_SIZE + payloadSize );
331352

@@ -418,7 +439,8 @@ LoRaMacCommandStatus_t LoRaMacCommandsRemoveStickyAnsCmds( void )
418439
while( curElement != NULL )
419440
{
420441
nexElement = curElement->Next;
421-
if( IsSticky( curElement->CID ) == true )
442+
if( ( IsSticky( curElement->CID ) == true ) &&
443+
( IsConfirmationRequired( curElement->CID ) == false ) )
422444
{
423445
LoRaMacCommandsRemoveCmd( curElement );
424446
}

src/mac/LoRaMacCommands.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ struct sMacCommand
7777
* Indicates if it's a sticky MAC command
7878
*/
7979
bool IsSticky;
80+
/*!
81+
* The command requires an explicit confirmation
82+
*/
83+
bool IsConfirmationRequired;
8084
};
8185

8286
/*!

0 commit comments

Comments
 (0)