Skip to content

Commit 76a2acc

Browse files
Daniel Jaecklemluis1
authored andcommitted
Fixed Class B & C confirmed downlink acknowledge management when CLASS_B_C_RESP_TIMEOUT expires
1 parent 0d80d26 commit 76a2acc

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

src/mac/LoRaMac.c

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,21 @@ static void LoRaMacHandleIndicationEvents( void );
649649
*/
650650
static void LoRaMacHandleNvm( LoRaMacNvmData_t* nvmData );
651651

652+
/*!
653+
* \brief This function verifies if the response timeout has been elapsed. If
654+
* this is the case, the status of Nvm.MacGroup1.SrvAckRequested will be
655+
* reset.
656+
*
657+
* \param [IN] timeoutInMs Timeout [ms] to be compared.
658+
*
659+
* \param [IN] startTimeInMs Start time [ms] used as a base. If set to 0,
660+
* no comparison will be done.
661+
*
662+
* \retval true: Response timeout has been elapsed, false: Response timeout
663+
* has not been elapsed or startTimeInMs is 0.
664+
*/
665+
static bool LoRaMacHandleResponseTimeout( TimerTime_t timeoutInMs, TimerTime_t startTimeInMs );
666+
652667
/*!
653668
* Structure used to store the radio Tx event data
654669
*/
@@ -1634,6 +1649,19 @@ static void LoRaMacHandleNvm( LoRaMacNvmData_t* nvmData )
16341649
CallNvmDataChangeCallback( notifyFlags );
16351650
}
16361651

1652+
static bool LoRaMacHandleResponseTimeout( TimerTime_t timeoutInMs, TimerTime_t startTimeInMs )
1653+
{
1654+
if( startTimeInMs != 0 )
1655+
{
1656+
TimerTime_t elapsedTime = TimerGetElapsedTime( startTimeInMs );
1657+
if( elapsedTime > timeoutInMs )
1658+
{
1659+
Nvm.MacGroup1.SrvAckRequested = false;
1660+
return true;
1661+
}
1662+
}
1663+
return false;
1664+
}
16371665

16381666
void LoRaMacProcess( void )
16391667
{
@@ -1676,14 +1704,11 @@ static void OnTxDelayedTimerEvent( void* context )
16761704
TimerStop( &MacCtx.TxDelayedTimer );
16771705
MacCtx.MacState &= ~LORAMAC_TX_DELAYED;
16781706

1679-
if( MacCtx.ResponseTimeoutStartTime != 0 )
1707+
if( LoRaMacHandleResponseTimeout( REGION_COMMON_CLASS_B_C_RESP_TIMEOUT,
1708+
MacCtx.ResponseTimeoutStartTime ) == true )
16801709
{
1681-
TimerTime_t elapsedTime = TimerGetElapsedTime( MacCtx.ResponseTimeoutStartTime );
1682-
if( elapsedTime > REGION_COMMON_CLASS_B_C_RESP_TIMEOUT )
1683-
{
1684-
// Skip retransmission
1685-
return;
1686-
}
1710+
// Skip retransmission
1711+
return;
16871712
}
16881713

16891714
// Schedule frame, allow delayed frame transmissions
@@ -2698,6 +2723,7 @@ static void ResetMacParameters( void )
26982723

26992724
MacCtx.ChannelsNbTransCounter = 0;
27002725
MacCtx.RetransmitTimeoutRetry = false;
2726+
MacCtx.ResponseTimeoutStartTime = 0;
27012727

27022728
Nvm.MacGroup2.MaxDCycle = 0;
27032729
Nvm.MacGroup2.AggregatedDCycle = 1;
@@ -4819,6 +4845,10 @@ LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t* mcpsRequest )
48194845
}
48204846
}
48214847

4848+
// Verification of response timeout for class b and class c
4849+
LoRaMacHandleResponseTimeout( REGION_COMMON_CLASS_B_C_RESP_TIMEOUT,
4850+
MacCtx.ResponseTimeoutStartTime );
4851+
48224852
status = Send( &macHdr, fPort, fBuffer, fBufferSize );
48234853
if( status == LORAMAC_STATUS_OK )
48244854
{

0 commit comments

Comments
 (0)