From edff6ce161773e888687a9cd352ce2e2234e6b0d Mon Sep 17 00:00:00 2001 From: Daniel Jaeckle Date: Tue, 14 Dec 2021 09:46:42 +0100 Subject: [PATCH] Issue #1144 - Refactored stack FramePending variable handling and renamed FramePending to IsUplinkTxPending. --- src/apps/LoRaMac/common/LmHandler/LmHandler.c | 3 +-- src/mac/LoRaMac.c | 10 ++++++++-- src/mac/LoRaMac.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/apps/LoRaMac/common/LmHandler/LmHandler.c b/src/apps/LoRaMac/common/LmHandler/LmHandler.c index 0073fb993..3ebdcd540 100644 --- a/src/apps/LoRaMac/common/LmHandler/LmHandler.c +++ b/src/apps/LoRaMac/common/LmHandler/LmHandler.c @@ -745,8 +745,7 @@ static void McpsIndication( McpsIndication_t *mcpsIndication ) // Call packages RxProcess function LmHandlerPackagesNotify( PACKAGE_MCPS_INDICATION, mcpsIndication ); - if( ( ( mcpsIndication->FramePending != 0 ) && ( LmHandlerGetCurrentClass( ) == CLASS_A ) ) || - ( mcpsIndication->ResponseTimeout > 0 ) ) + if( mcpsIndication->IsUplinkTxPending != 0 ) { // The server signals that it has pending data to be sent. // We schedule an uplink as soon as possible to flush the server. diff --git a/src/mac/LoRaMac.c b/src/mac/LoRaMac.c index 5f063e03a..12c0ff451 100644 --- a/src/mac/LoRaMac.c +++ b/src/mac/LoRaMac.c @@ -914,7 +914,7 @@ static void ProcessRadioRxDone( void ) MacCtx.McpsIndication.RxSlot = MacCtx.RxSlot; MacCtx.McpsIndication.Port = 0; MacCtx.McpsIndication.Multicast = 0; - MacCtx.McpsIndication.FramePending = 0; + MacCtx.McpsIndication.IsUplinkTxPending = 0; MacCtx.McpsIndication.Buffer = NULL; MacCtx.McpsIndication.BufferSize = 0; MacCtx.McpsIndication.RxData = false; @@ -1203,7 +1203,6 @@ static void ProcessRadioRxDone( void ) MacCtx.McpsIndication.Status = LORAMAC_EVENT_INFO_STATUS_OK; MacCtx.McpsIndication.Multicast = multicast; - MacCtx.McpsIndication.FramePending = macMsgData.FHDR.FCtrl.Bits.FPending; MacCtx.McpsIndication.Buffer = NULL; MacCtx.McpsIndication.BufferSize = 0; MacCtx.McpsIndication.DownLinkCounter = downLinkCounter; @@ -1252,6 +1251,13 @@ static void ProcessRadioRxDone( void ) } } + // Set the pending status + if( ( ( ( Nvm.MacGroup1.SrvAckRequested == true ) || ( macMsgData.FHDR.FCtrl.Bits.FPending > 0 ) ) && ( Nvm.MacGroup2.DeviceClass == CLASS_A ) ) || + ( MacCtx.McpsIndication.ResponseTimeout > 0 ) ) + { + MacCtx.McpsIndication.IsUplinkTxPending = 1; + } + RemoveMacCommands( MacCtx.McpsIndication.RxSlot, macMsgData.FHDR.FCtrl, MacCtx.McpsConfirm.McpsRequest ); switch( fType ) diff --git a/src/mac/LoRaMac.h b/src/mac/LoRaMac.h index 1a62dd221..229c8818f 100644 --- a/src/mac/LoRaMac.h +++ b/src/mac/LoRaMac.h @@ -1003,7 +1003,7 @@ typedef struct sMcpsIndication /*! * Frame pending status */ - uint8_t FramePending; + uint8_t IsUplinkTxPending; /*! * Pointer to the received data stream */