1
1
/* Copyright (c) 2009-2019 Arm Limited
2
+ * Copyright (c) 2019-2020 Packetcraft, Inc.
2
3
* SPDX-License-Identifier: Apache-2.0
3
4
*
4
5
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -233,6 +234,7 @@ static void smpDmConnCback(dmEvt_t *pDmEvt)
233
234
pCcb -> attempts = SmpDbGetFailureCount ((dmConnId_t ) pDmEvt -> hdr .param );
234
235
pCcb -> lastSentKey = 0 ;
235
236
pCcb -> state = 0 ;
237
+ pCcb -> keyReady = FALSE;
236
238
237
239
/* Resume the attempts state if necessary */
238
240
smpResumeAttemptsState ((dmConnId_t ) pDmEvt -> hdr .param );
@@ -693,6 +695,27 @@ uint8_t smpGetScSecLevel(smpCcb_t *pCcb)
693
695
return secLevel ;
694
696
}
695
697
698
+ /*************************************************************************************************/
699
+ /*!
700
+ * \brief Check if LE Secure Connections is enabled on the connection.
701
+ *
702
+ * \param connId Connection identifier.
703
+ *
704
+ * \return TRUE is Secure Connections is enabled, else FALSE
705
+ */
706
+ /*************************************************************************************************/
707
+ bool_t SmpDmLescEnabled (dmConnId_t connId )
708
+ {
709
+ smpCcb_t * pCcb = smpCcbByConnId (connId );
710
+
711
+ if (pCcb == NULL || pCcb -> pScCcb == NULL )
712
+ {
713
+ return FALSE;
714
+ }
715
+
716
+ return pCcb -> pScCcb -> lescEnabled ;
717
+ }
718
+
696
719
/*************************************************************************************************/
697
720
/*!
698
721
* \brief Return the STK for the given connection.
@@ -710,6 +733,11 @@ uint8_t *SmpDmGetStk(dmConnId_t connId, uint8_t *pSecLevel)
710
733
/* get connection control block */
711
734
pCcb = smpCcbByConnId (connId );
712
735
736
+ if ((pCcb == NULL ) || (pCcb -> keyReady == FALSE))
737
+ {
738
+ return NULL ;
739
+ }
740
+
713
741
if (smpCb .lescSupported && pCcb -> pScCcb -> lescEnabled && (pCcb -> pScCcb -> pLtk != NULL ))
714
742
{
715
743
/* set security level */
0 commit comments