From 4fe2b724fe2f18acb55b72e178467c01193073bd Mon Sep 17 00:00:00 2001 From: Daniel Jaeckle Date: Mon, 8 Jul 2019 13:31:59 +0200 Subject: [PATCH] Add the DevEui and the JoinEui to the MIB --- src/mac/LoRaMac.c | 26 ++++++++++++++++++ src/mac/LoRaMac.h | 67 ++++++++++++++++++++++------------------------- 2 files changed, 58 insertions(+), 35 deletions(-) diff --git a/src/mac/LoRaMac.c b/src/mac/LoRaMac.c index 4cbef9dcd..ccfa59188 100644 --- a/src/mac/LoRaMac.c +++ b/src/mac/LoRaMac.c @@ -3422,6 +3422,16 @@ LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t* mibGet ) mibGet->Param.NetworkActivation = MacCtx.NvmCtx->NetworkActivation; break; } + case MIB_DEV_EUI: + { + mibGet->Param.DevEui = SecureElementGetDevEui( ); + break; + } + case MIB_JOIN_EUI: + { + mibGet->Param.JoinEui = SecureElementGetJoinEui( ); + break; + } case MIB_ADR: { mibGet->Param.AdrEnable = MacCtx.NvmCtx->AdrCtrlOn; @@ -3609,6 +3619,22 @@ LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t* mibSet ) } break; } + case MIB_DEV_EUI: + { + if( SecureElementSetDevEui( mibSet->Param.DevEui ) != SECURE_ELEMENT_SUCCESS ) + { + status = LORAMAC_STATUS_PARAMETER_INVALID; + } + break; + } + case MIB_JOIN_EUI: + { + if( SecureElementSetJoinEui( mibSet->Param.JoinEui ) != SECURE_ELEMENT_SUCCESS ) + { + status = LORAMAC_STATUS_PARAMETER_INVALID; + } + break; + } case MIB_ADR: { MacCtx.NvmCtx->AdrCtrlOn = mibSet->Param.AdrEnable; diff --git a/src/mac/LoRaMac.h b/src/mac/LoRaMac.h index e197a4317..bf5b85db6 100644 --- a/src/mac/LoRaMac.h +++ b/src/mac/LoRaMac.h @@ -985,18 +985,6 @@ typedef enum eMlme */ typedef struct sMlmeReqJoin { - /*! - * Globally unique end-device identifier - * - * LoRaWAN Specification V1.1.0, chapter 6.1.1.2 - */ - uint8_t* DevEui; - /*! - * Join Sever identifier - * - * LoRaWAN Specification V1.1.0, chapter 6.1.1.1 - */ - uint8_t* JoinEui; /*! * Datarate used for join request. */ @@ -1168,6 +1156,8 @@ typedef struct sMlmeIndication * ----------------------------------------------| :-: | :-: * \ref MIB_DEVICE_CLASS | YES | YES * \ref MIB_NETWORK_ACTIVATION | YES | YES + * \ref MIB_DEV_EUI | YES | YES + * \ref MIB_JOIN_EUI | YES | YES * \ref MIB_ADR | YES | YES * \ref MIB_NET_ID | YES | YES * \ref MIB_DEV_ADDR | YES | YES @@ -1253,6 +1243,18 @@ typedef enum eMib * LoRaWAN Specification V1.0.2 */ MIB_NETWORK_ACTIVATION, + /*! + * LoRaWAN device EUI + * + * LoRaWAN Specification V1.0.2 + */ + MIB_DEV_EUI, + /*! + * LoRaWAN join EUI + * + * LoRaWAN Specification V1.0.2 + */ + MIB_JOIN_EUI, /*! * Adaptive data rate * @@ -1549,7 +1551,7 @@ typedef enum eMib * The antenna gain is used to calculate the TX power of the node. * The formula is: * radioTxPower = ( int8_t )floor( maxEirp - antennaGain ) - * + * * \remark The antenna gain value is referenced to the isotropic antenna. * The value is in dBi. * MIB_ANTENNA_GAIN[dBi] = measuredAntennaGain[dBd] + 2.15 @@ -1560,7 +1562,7 @@ typedef enum eMib * The antenna gain is used to calculate the TX power of the node. * The formula is: * radioTxPower = ( int8_t )floor( maxEirp - antennaGain ) - * + * * \remark The antenna gain value is referenced to the isotropic antenna. * The value is in dBi. * MIB_DEFAULT_ANTENNA_GAIN[dBi] = measuredAntennaGain[dBd] + 2.15 @@ -1651,6 +1653,18 @@ typedef union uMibParam * Related MIB type: \ref MIB_NETWORK_ACTIVATION */ ActivationType_t NetworkActivation; + /*! + * LoRaWAN device class + * + * Related MIB type: \ref MIB_DEV_EUI + */ + uint8_t* DevEui; + /*! + * LoRaWAN device class + * + * Related MIB type: \ref MIB_JOIN_EUI + */ + uint8_t* JoinEui; /*! * Activation state of ADR * @@ -2567,32 +2581,15 @@ LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t* mibSet ); * * \details The Mac layer management entity handles management services. The * following code-snippet shows how to use the API to perform a - * network join request. + * network join request. Please note that for a join request, the + * DevEUI and the JoinEUI must be set previously via the MIB. Please + * also refer to the sample implementations. * * \code - * static uint8_t DevEui[] = - * { - * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - * }; - * static uint8_t JoinEui[] = - * { - * 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - * }; - * static uint8_t NwkKey[] = - * { - * 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, - * 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C - * }; - * static uint8_t AppKey[] = - * { - * 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, - * 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C - * }; * * MlmeReq_t mlmeReq; * mlmeReq.Type = MLME_JOIN; - * mlmeReq.Req.Join.DevEui = DevEui; - * mlmeReq.Req.Join.JoinEui = JoinEui; + * mlmeReq.Req.Join.Datarate = LORAWAN_DEFAULT_DATARATE; * * if( LoRaMacMlmeRequest( &mlmeReq ) == LORAMAC_STATUS_OK ) * {