Skip to content

Commit f9bb6f9

Browse files
Daniel Jaecklemluis1
authored andcommitted
Issue #1048 - Added a function to reset the stack internal state machine.
1 parent b6f383c commit f9bb6f9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/mac/LoRaMac.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5700,3 +5700,21 @@ LoRaMacStatus_t LoRaMacDeInitialization( void )
57005700
return LORAMAC_STATUS_BUSY;
57015701
}
57025702
}
5703+
5704+
void LoRaMacReset( void )
5705+
{
5706+
// Reset state machine
5707+
MacCtx.MacState &= ~LORAMAC_TX_RUNNING;
5708+
MacCtx.MacFlags.Bits.MacDone = 1;
5709+
5710+
// Stop Timers
5711+
TimerStop( &MacCtx.TxDelayedTimer );
5712+
TimerStop( &MacCtx.RxWindowTimer1 );
5713+
TimerStop( &MacCtx.RxWindowTimer2 );
5714+
5715+
// Stop retransmissions
5716+
MacCtx.ChannelsNbTransCounter = Nvm.MacGroup2.MacParams.ChannelsNbTrans;
5717+
5718+
// Inform application layer
5719+
OnMacProcessNotify( );
5720+
}

src/mac/LoRaMac.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,6 +2921,13 @@ LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t* mcpsRequest );
29212921
*/
29222922
LoRaMacStatus_t LoRaMacDeInitialization( void );
29232923

2924+
/*!
2925+
* \brief Resets the internal state machine.
2926+
*
2927+
* \details Resets the internal state machine to force the MAC to finalize a procedure.
2928+
*/
2929+
void LoRaMacReset( void );
2930+
29242931
/*! \} defgroup LORAMAC */
29252932

29262933
#ifdef __cplusplus

0 commit comments

Comments
 (0)