Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing return status for LmHandlerJoin #67

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Middlewares/Third_Party/LoRaWAN/LmHandler/LmHandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,10 @@ TimerTime_t LmHandlerGetDutyCycleWaitTime( void )
return DutyCycleWaitTime;
}

void LmHandlerJoin( ActivationType_t mode, bool forceRejoin )
LmHandlerErrorStatus_t LmHandlerJoin( ActivationType_t mode, bool forceRejoin )
{
LmHandlerErrorStatus_t lmhStatus = LORAMAC_HANDLER_ERROR;
LoRaMacStatus_t status;
MlmeReq_t mlmeReq;

mlmeReq.Type = MLME_JOIN;
Expand All @@ -605,7 +607,12 @@ void LmHandlerJoin( ActivationType_t mode, bool forceRejoin )
LoRaMacStart();
#if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000300 ))
/* Starts the OTAA join procedure */
LoRaMacMlmeRequest( &mlmeReq );
status = LoRaMacMlmeRequest( &mlmeReq );

if( status == LORAMAC_STATUS_OK )
{
lmhStatus = LORAMAC_STATUS_OK;
}
#endif /* LORAMAC_VERSION */
}
else
Expand Down Expand Up @@ -655,18 +662,25 @@ void LmHandlerJoin( ActivationType_t mode, bool forceRejoin )
{
LmHandlerCallbacks->OnJoinRequest( &JoinParams );
}
LmHandlerRequestClass( LmHandlerParams.DefaultClass );
lmhStatus = LmHandlerRequestClass( LmHandlerParams.DefaultClass );
#endif /* LORAMAC_VERSION */
}

#if (defined( LORAMAC_VERSION ) && (( LORAMAC_VERSION == 0x01000400 ) || ( LORAMAC_VERSION == 0x01010100 )))
if( ( CtxRestoreDone == false ) || ( forceRejoin == true ) )
{
/* Starts the join procedure */
LoRaMacMlmeRequest( &mlmeReq );
status = LoRaMacMlmeRequest( &mlmeReq );

if( status == LORAMAC_STATUS_OK )
{
lmhStatus = LORAMAC_STATUS_OK;
}
}
DutyCycleWaitTime = mlmeReq.ReqReturn.DutyCycleWaitTime;
#endif /* LORAMAC_VERSION */

return lmhStatus;
}

LmHandlerFlagStatus_t LmHandlerJoinStatus( void )
Expand Down
8 changes: 6 additions & 2 deletions Middlewares/Third_Party/LoRaWAN/LmHandler/LmHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,12 @@ TimerTime_t LmHandlerGetDutyCycleWaitTime( void );
*
* \param [in] mode Activation mode (OTAA or ABP)
* \param [in] forceRejoin Flag to force the rejoin even if LoRaWAN context can be restored
*
* \retval status Returns \ref LORAMAC_HANDLER_SUCCESS if request has been
* processed else if device not yet joined a network \ref LORAMAC_HANDLER_NO_NETWORK_JOINED
* else \ref LORAMAC_HANDLER_ERROR
*/
void LmHandlerJoin( ActivationType_t mode, bool forceRejoin );
LmHandlerErrorStatus_t LmHandlerJoin( ActivationType_t mode, bool forceRejoin );

/*!
* Check whether the Device is joined to the network
Expand Down Expand Up @@ -394,7 +398,7 @@ LmHandlerErrorStatus_t LmHandlerPingSlotReq( uint8_t periodicity );
*
* \retval status Returns \ref LORAMAC_HANDLER_SUCCESS if request has been
* processed else if device not yet joined a network \ref LORAMAC_HANDLER_NO_NETWORK_JOINED
else \ref LORAMAC_HANDLER_ERROR
* else \ref LORAMAC_HANDLER_ERROR
*/
LmHandlerErrorStatus_t LmHandlerRequestClass( DeviceClass_t newClass );

Expand Down