LmHandlerSetAppKey does not update the APPKey
Hi,
I've been playing around with STM32CubeWL using Nucleo-64 (STM32WL55). The default LoRaWan applications seem to work correctly against TTI stack, but when I tried to make my own using Projects/NUCLEO-WL55JC/Applications/LoRaWAN/LoRaWAN_End_Node/ as basis things didn't work as expected
The main issue I'm having is that if have the most basic initialization code :
static uint8_t app_eui[] = { ... };
static uint8_t dev_eui[] = { ... };
static uint8_t app_key[] = { ... };
void APP_Init ( void )
{
/* Register LmHandler task */
UTIL_SEQ_RegTask( (1 << CFG_SEQ_Task_LmHandlerProcess),
UTIL_SEQ_RFU,
LmHandlerProcess,
0);
/* Initialize LoRaMac */
LoraInfo_Init();
LmHandlerInit(&lmhandler_callbacks);
LmHandlerConfigure(&lmhandler_params);
/* Set credentials */
LmHandlerSetAppEUI(app_eui);
LmHandlerSetAppKey(app_key);
LmHandlerSetDevEUI(dev_eui);
/* Start Join Process */
LmHandlerJoin(lmhandler_activation_type);
}
And I provision the device with abovementioned keys in TTI I'm getting a MIC MISMATCH and no join will occur, but as soon as the line containing LmHandlerSetAppKey(app_key); is removed and APP KEY in backend is substituted with the one from LoRaWAN_End_Node/LoRaWAN/App/se-identity.h everything is fine.
So my question is :
Why define and implement LmHandlerSetAppKey() when this function simply is useless ?
ST Internal Reference: 121057
@asob
Try this:
/* Init Info table used by LmHandler */
LoraInfo_Init();
/* Init the Lora Stack*/
LmHandlerInit(&LmHandlerCallbacks);
LmHandlerConfigure(&LmHandlerParams);
MibRequestConfirm_t mibReq;
mibReq.Type = MIB_DEV_EUI;
mibReq.Param.DevEui = yourDevEui;
LoRaMacMibSetRequestConfirm(&mibReq);
mibReq.Type = MIB_JOIN_EUI;
mibReq.Param.JoinEui = yourJoinEui;
LoRaMacMibSetRequestConfirm(&mibReq);
mibReq.Type = MIB_NWK_KEY;
mibReq.Param.AppKey = yourAppKey;
LoRaMacMibSetRequestConfirm(&mibReq);
Hi @asob,
According to our development teams, you have to use the LmHandlerSetNwkKey() function with the value of the APP_KEY you register in TTI.
Please find below more details:
- The
APP_KEYdefine in TTI is the key you will need to join the network. This implementation differs from the Link Layer specifications. - In your case, when setting a custom
APP_KEY:- You get a mismatch because the
APP_KEYin TTI meansNWK_KEY. - In other words, it's not the same key you have registered in your device's configuration.
- You get a mismatch because the
- When you commented the call to the
LmHandlerSetAppKey()function and reconfigured the device in TTI to set theAPP_KEYto the original value, it worked because:- In the code, the same value is used for both the
APP_KEYand theNWK_KEY. - Hence, the
NWK_KEYvalue will be used (which is the same as theAPP_KEY).
- In the code, the same value is used for both the
The se-identity.h file shall be updated to clarify the key usage. The update will be part of version 1.3.0 of this firmware, already available on st.com and soon on GitHub.
We hope this helps.
With regards,