@@ -1231,10 +1231,11 @@ LoRaMacCryptoStatus_t LoRaMacCryptoHandleJoinAccept( JoinReqIdentifier_t joinReq
12311231
12321232 LoRaMacCryptoStatus_t retval = LORAMAC_CRYPTO_ERROR ;
12331233 uint8_t decJoinAccept [33 ] = { 0 };
1234+ uint8_t versionMinor = 0 ;
12341235
12351236 if ( SecureElementProcessJoinAccept ( joinReqType , joinEUI , CryptoCtx .NvmCtx -> DevNonce , macMsg -> Buffer ,
12361237 macMsg -> BufSize , decJoinAccept ,
1237- & CryptoCtx . NvmCtx -> LrWanVersion . Fields . Minor ) != SECURE_ELEMENT_SUCCESS )
1238+ & versionMinor ) != SECURE_ELEMENT_SUCCESS )
12381239 {
12391240 return LORAMAC_CRYPTO_ERROR_SECURE_ELEMENT_FUNC ;
12401241 }
@@ -1290,7 +1291,7 @@ LoRaMacCryptoStatus_t LoRaMacCryptoHandleJoinAccept( JoinReqIdentifier_t joinReq
12901291 }
12911292 }
12921293
1293- if ( CryptoCtx . NvmCtx -> LrWanVersion . Fields . Minor == 1 )
1294+ if ( versionMinor == 1 )
12941295 {
12951296 // Operating in LoRaWAN 1.1.x mode
12961297 // Derive lifetime keys
@@ -1371,14 +1372,19 @@ LoRaMacCryptoStatus_t LoRaMacCryptoHandleJoinAccept( JoinReqIdentifier_t joinReq
13711372 }
13721373 }
13731374
1374- // Join-Accept is successfully processed, reset frame counters
1375+ // Join-Accept is successfully processed
1376+ // Save LoRaWAN specification version
1377+ CryptoCtx .NvmCtx -> LrWanVersion .Fields .Minor = versionMinor ;
1378+
1379+ // Reset frame counters
13751380#if ( USE_LRWAN_1_1_X_CRYPTO == 1 )
13761381 CryptoCtx .RJcount0 = 0 ;
13771382#endif
13781383 CryptoCtx .NvmCtx -> FCntList .FCntUp = 0 ;
13791384 CryptoCtx .NvmCtx -> FCntList .FCntDown = FCNT_DOWN_INITAL_VALUE ;
13801385 CryptoCtx .NvmCtx -> FCntList .NFCntDown = FCNT_DOWN_INITAL_VALUE ;
13811386 CryptoCtx .NvmCtx -> FCntList .AFCntDown = FCNT_DOWN_INITAL_VALUE ;
1387+
13821388 CryptoCtx .EventCryptoNvmCtxChanged ( );
13831389
13841390 return LORAMAC_CRYPTO_SUCCESS ;
0 commit comments