From ffbd453cd83e8d7620dd7c20be47d29a911a3053 Mon Sep 17 00:00:00 2001 From: Miguel Luis Date: Fri, 14 Jun 2019 09:31:23 +0200 Subject: [PATCH] Do not allow a MLME_PING_SLOT_INFO request, if the MAC is not in class A. The function returns a SERVICE_UNKNOWN state in this case. --- src/mac/LoRaMac.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/mac/LoRaMac.c b/src/mac/LoRaMac.c index 1555a5b1f..537e7602c 100644 --- a/src/mac/LoRaMac.c +++ b/src/mac/LoRaMac.c @@ -4488,15 +4488,18 @@ LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest ) } case MLME_PING_SLOT_INFO: { - uint8_t value = mlmeRequest->Req.PingSlotInfo.PingSlot.Value; - - // LoRaMac will send this command piggy-pack - LoRaMacClassBSetPingSlotInfo( mlmeRequest->Req.PingSlotInfo.PingSlot.Fields.Periodicity ); - macCmdPayload[0] = value; - status = LORAMAC_STATUS_OK; - if( LoRaMacCommandsAddCmd( MOTE_MAC_PING_SLOT_INFO_REQ, macCmdPayload, 1 ) != LORAMAC_COMMANDS_SUCCESS ) + if( MacCtx.NvmCtx->DeviceClass == CLASS_A ) { - status = LORAMAC_STATUS_MAC_COMMAD_ERROR; + uint8_t value = mlmeRequest->Req.PingSlotInfo.PingSlot.Value; + + // LoRaMac will send this command piggy-pack + LoRaMacClassBSetPingSlotInfo( mlmeRequest->Req.PingSlotInfo.PingSlot.Fields.Periodicity ); + macCmdPayload[0] = value; + status = LORAMAC_STATUS_OK; + if( LoRaMacCommandsAddCmd( MOTE_MAC_PING_SLOT_INFO_REQ, macCmdPayload, 1 ) != LORAMAC_COMMANDS_SUCCESS ) + { + status = LORAMAC_STATUS_MAC_COMMAD_ERROR; + } } break; }