STM32WL55, Issue with propagating to the M4 that there are no more free channels while trying to Join LoRa
Dear All,
I am developing an application and I have reached a point where the device is trying to join LoRa.
For testing purposes, the gateway is closed, so the device ends up consuming all the available bandwidth on all channels and it can no longer try to send a join request.
What I want is to have this message somehow communicated to the CM4, in order to accommodate this issue there.
What I have found so far is that the
LORAMAC_STATUS_DUTYCYCLE_RESTRICTEDIs propagated until the
LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest)found in CM0PLUS/Middlewares/Third_Party/LoRaWAN/LoRaMac.c.
I think that what I need to do is to somehow forward this information to the
MlmeConfirm( MlmeConfirm_t *mlmeConfirm )I tried this:
LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest )
{
LoRaMacStatus_t status = LORAMAC_STATUS_SERVICE_UNKNOWN;
MlmeConfirmQueue_t queueElement;
uint8_t macCmdPayload[2] = { 0x00, 0x00 };
if( mlmeRequest == NULL )
{
return LORAMAC_STATUS_PARAMETER_INVALID;
}
if( LoRaMacIsBusy( ) == true )
{
return LORAMAC_STATUS_BUSY;
}
if( LoRaMacConfirmQueueIsFull( ) == true )
{
return LORAMAC_STATUS_BUSY;
}
if( LoRaMacConfirmQueueGetCnt( ) == 0 )
{
memset1( ( uint8_t* ) &MacCtx.MlmeConfirm, 0, sizeof( MacCtx.MlmeConfirm ) );
}
MacCtx.MlmeConfirm.Status = LORAMAC_EVENT_INFO_STATUS_ERROR;
MacCtx.MacFlags.Bits.MlmeReq = 1;
queueElement.Request = mlmeRequest->Type;
queueElement.Status = LORAMAC_EVENT_INFO_STATUS_ERROR;
queueElement.RestrictCommonReadyToHandle = false;
switch( mlmeRequest->Type )
{
case MLME_JOIN:
{
if( ( MacCtx.MacState & LORAMAC_TX_DELAYED ) == LORAMAC_TX_DELAYED )
{
return LORAMAC_STATUS_BUSY;
}
ResetMacParameters( );
Nvm.MacGroup1.ChannelsDatarate = RegionAlternateDr( Nvm.MacGroup2.Region, mlmeRequest->Req.Join.Datarate, ALTERNATE_DR );
queueElement.Status = LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL;
status = SendReJoinReq( JOIN_REQ );
if( status != LORAMAC_STATUS_OK )
{
LoRaMacConfirmQueueSetStatusCmn(LORAMAC_EVENT_INFO_STATUS_ERROR);
queueElement.Status = LORAMAC_EVENT_INFO_STATUS_ERROR;
// Revert back the previous datarate ( mainly used for US915 like regions )
Nvm.MacGroup1.ChannelsDatarate = RegionAlternateDr( Nvm.MacGroup2.Region, mlmeRequest->Req.Join.Datarate, ALTERNATE_DR_RESTORE );
}
break;
}
...
}At the moment in the MlmeConfirm( MlmeConfirm_t *mlmeConfirm), I am only receiving:
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUTAny ideas or assistance?
