Caching the advertising data and the scan response.
Fork of MaximBLE by
exactLE/stack/include/smp_api.h@1:4e764337d5c5, 2016-03-22 (annotated)
- Committer:
- kgills
- Date:
- Tue Mar 22 18:16:10 2016 +0000
- Revision:
- 1:4e764337d5c5
- Parent:
- 0:b562096246b3
Caching the advertising data and scan response.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
enginerd | 0:b562096246b3 | 1 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 2 | /*! |
enginerd | 0:b562096246b3 | 3 | * \file smp_api.h |
enginerd | 0:b562096246b3 | 4 | * |
enginerd | 0:b562096246b3 | 5 | * \brief SMP subsystem API. |
enginerd | 0:b562096246b3 | 6 | * |
enginerd | 0:b562096246b3 | 7 | * $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $ |
enginerd | 0:b562096246b3 | 8 | * $Revision: 191 $ |
enginerd | 0:b562096246b3 | 9 | * |
enginerd | 0:b562096246b3 | 10 | * Copyright (c) 2010-2016 ARM Limited. All rights reserved. |
enginerd | 0:b562096246b3 | 11 | * |
enginerd | 0:b562096246b3 | 12 | * SPDX-License-Identifier: LicenseRef-PBL |
enginerd | 0:b562096246b3 | 13 | * |
enginerd | 0:b562096246b3 | 14 | * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use |
enginerd | 0:b562096246b3 | 15 | * this file except in compliance with the License. You may obtain a copy of the License at |
enginerd | 0:b562096246b3 | 16 | * |
enginerd | 0:b562096246b3 | 17 | * https://www.mbed.com/licenses/PBL-1.0 |
enginerd | 0:b562096246b3 | 18 | * |
enginerd | 0:b562096246b3 | 19 | * See the License for the specific language governing permissions and limitations under the License. |
enginerd | 0:b562096246b3 | 20 | */ |
enginerd | 0:b562096246b3 | 21 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 22 | #ifndef SMP_API_H |
enginerd | 0:b562096246b3 | 23 | #define SMP_API_H |
enginerd | 0:b562096246b3 | 24 | |
enginerd | 0:b562096246b3 | 25 | #include "wsf_os.h" |
enginerd | 0:b562096246b3 | 26 | #include "smp_defs.h" |
enginerd | 0:b562096246b3 | 27 | #include "dm_api.h" |
enginerd | 0:b562096246b3 | 28 | |
enginerd | 0:b562096246b3 | 29 | #ifdef __cplusplus |
enginerd | 0:b562096246b3 | 30 | extern "C" { |
enginerd | 0:b562096246b3 | 31 | #endif |
enginerd | 0:b562096246b3 | 32 | |
enginerd | 0:b562096246b3 | 33 | /************************************************************************************************** |
enginerd | 0:b562096246b3 | 34 | Macros |
enginerd | 0:b562096246b3 | 35 | **************************************************************************************************/ |
enginerd | 0:b562096246b3 | 36 | |
enginerd | 0:b562096246b3 | 37 | /*! Event handler messages for SMP state machines */ |
enginerd | 0:b562096246b3 | 38 | enum |
enginerd | 0:b562096246b3 | 39 | { |
enginerd | 0:b562096246b3 | 40 | SMP_MSG_API_PAIR_REQ = 1, /*! API pairing request */ |
enginerd | 0:b562096246b3 | 41 | SMP_MSG_API_PAIR_RSP, /*! API pairing response */ |
enginerd | 0:b562096246b3 | 42 | SMP_MSG_API_CANCEL_REQ, /*! API cancel request */ |
enginerd | 0:b562096246b3 | 43 | SMP_MSG_API_AUTH_RSP, /*! API pin response */ |
enginerd | 0:b562096246b3 | 44 | SMP_MSG_API_SECURITY_REQ, /*! API security request */ |
enginerd | 0:b562096246b3 | 45 | SMP_MSG_CMD_PKT, /*! SMP command packet received */ |
enginerd | 0:b562096246b3 | 46 | SMP_MSG_CMD_PAIRING_FAILED, /*! SMP pairing failed packet received */ |
enginerd | 0:b562096246b3 | 47 | SMP_MSG_DM_ENCRYPT_CMPL, /*! Link encrypted */ |
enginerd | 0:b562096246b3 | 48 | SMP_MSG_DM_ENCRYPT_FAILED, /*! Link encryption failed */ |
enginerd | 0:b562096246b3 | 49 | SMP_MSG_DM_CONN_CLOSE, /*! Connection closed */ |
enginerd | 0:b562096246b3 | 50 | SMP_MSG_WSF_AES_CMPL, /*! AES calculation complete */ |
enginerd | 0:b562096246b3 | 51 | SMP_MSG_INT_SEND_NEXT_KEY, /*! Send next key to be distributed */ |
enginerd | 0:b562096246b3 | 52 | SMP_MSG_INT_MAX_ATTEMPTS, /*! Maximum pairing attempts reached */ |
enginerd | 0:b562096246b3 | 53 | SMP_MSG_INT_PAIRING_CMPL, /*! Pairing complete */ |
enginerd | 0:b562096246b3 | 54 | SMP_MSG_INT_TIMEOUT, /*! Pairing protocol timeout */ |
enginerd | 0:b562096246b3 | 55 | SMP_NUM_MSGS |
enginerd | 0:b562096246b3 | 56 | }; |
enginerd | 0:b562096246b3 | 57 | |
enginerd | 0:b562096246b3 | 58 | /************************************************************************************************** |
enginerd | 0:b562096246b3 | 59 | Data Types |
enginerd | 0:b562096246b3 | 60 | **************************************************************************************************/ |
enginerd | 0:b562096246b3 | 61 | |
enginerd | 0:b562096246b3 | 62 | /*! Configurable parameters */ |
enginerd | 0:b562096246b3 | 63 | typedef struct |
enginerd | 0:b562096246b3 | 64 | { |
enginerd | 0:b562096246b3 | 65 | uint16_t attemptTimeout; /*! 'Repeated attempts' timeout in msec */ |
enginerd | 0:b562096246b3 | 66 | uint8_t ioCap; /*! I/O Capability */ |
enginerd | 0:b562096246b3 | 67 | uint8_t minKeyLen; /*! Minimum encryption key length */ |
enginerd | 0:b562096246b3 | 68 | uint8_t maxKeyLen; /*! Maximum encryption key length */ |
enginerd | 0:b562096246b3 | 69 | uint8_t maxAttempts; /*! Attempts to trigger 'repeated attempts' timeout */ |
enginerd | 0:b562096246b3 | 70 | uint8_t auth; /*! Device authentication requirements */ |
enginerd | 0:b562096246b3 | 71 | } smpCfg_t; |
enginerd | 0:b562096246b3 | 72 | |
enginerd | 0:b562096246b3 | 73 | /*! Data type for SMP_MSG_API_PAIR_REQ and SMP_MSG_API_PAIR_RSP */ |
enginerd | 0:b562096246b3 | 74 | typedef struct |
enginerd | 0:b562096246b3 | 75 | { |
enginerd | 0:b562096246b3 | 76 | wsfMsgHdr_t hdr; |
enginerd | 0:b562096246b3 | 77 | uint8_t oob; |
enginerd | 0:b562096246b3 | 78 | uint8_t auth; |
enginerd | 0:b562096246b3 | 79 | uint8_t iKeyDist; |
enginerd | 0:b562096246b3 | 80 | uint8_t rKeyDist; |
enginerd | 0:b562096246b3 | 81 | } smpDmPair_t; |
enginerd | 0:b562096246b3 | 82 | |
enginerd | 0:b562096246b3 | 83 | /*! Data type for SMP_MSG_API_AUTH_RSP */ |
enginerd | 0:b562096246b3 | 84 | typedef struct |
enginerd | 0:b562096246b3 | 85 | { |
enginerd | 0:b562096246b3 | 86 | wsfMsgHdr_t hdr; |
enginerd | 0:b562096246b3 | 87 | uint8_t authData[SMP_OOB_LEN]; |
enginerd | 0:b562096246b3 | 88 | uint8_t authDataLen; |
enginerd | 0:b562096246b3 | 89 | } smpDmAuthRsp_t; |
enginerd | 0:b562096246b3 | 90 | |
enginerd | 0:b562096246b3 | 91 | /*! Data type for SMP_MSG_API_SECURITY_REQ */ |
enginerd | 0:b562096246b3 | 92 | typedef struct |
enginerd | 0:b562096246b3 | 93 | { |
enginerd | 0:b562096246b3 | 94 | wsfMsgHdr_t hdr; |
enginerd | 0:b562096246b3 | 95 | uint8_t auth; |
enginerd | 0:b562096246b3 | 96 | } smpDmSecurityReq_t; |
enginerd | 0:b562096246b3 | 97 | |
enginerd | 0:b562096246b3 | 98 | /*! Union SMP DM message data types */ |
enginerd | 0:b562096246b3 | 99 | typedef union |
enginerd | 0:b562096246b3 | 100 | { |
enginerd | 0:b562096246b3 | 101 | wsfMsgHdr_t hdr; |
enginerd | 0:b562096246b3 | 102 | smpDmPair_t pair; |
enginerd | 0:b562096246b3 | 103 | smpDmAuthRsp_t authRsp; |
enginerd | 0:b562096246b3 | 104 | smpDmSecurityReq_t securityReq; |
enginerd | 0:b562096246b3 | 105 | } smpDmMsg_t; |
enginerd | 0:b562096246b3 | 106 | |
enginerd | 0:b562096246b3 | 107 | /************************************************************************************************** |
enginerd | 0:b562096246b3 | 108 | Global Variables; |
enginerd | 0:b562096246b3 | 109 | **************************************************************************************************/ |
enginerd | 0:b562096246b3 | 110 | |
enginerd | 0:b562096246b3 | 111 | /*! Configuration pointer */ |
enginerd | 0:b562096246b3 | 112 | extern smpCfg_t *pSmpCfg; |
enginerd | 0:b562096246b3 | 113 | |
enginerd | 0:b562096246b3 | 114 | /************************************************************************************************** |
enginerd | 0:b562096246b3 | 115 | Function Declarations |
enginerd | 0:b562096246b3 | 116 | **************************************************************************************************/ |
enginerd | 0:b562096246b3 | 117 | |
enginerd | 0:b562096246b3 | 118 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 119 | /*! |
enginerd | 0:b562096246b3 | 120 | * \fn SmpiInit |
enginerd | 0:b562096246b3 | 121 | * |
enginerd | 0:b562096246b3 | 122 | * \brief Initialize SMP initiator role. |
enginerd | 0:b562096246b3 | 123 | * |
enginerd | 0:b562096246b3 | 124 | * \return None. |
enginerd | 0:b562096246b3 | 125 | */ |
enginerd | 0:b562096246b3 | 126 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 127 | void SmpiInit(void); |
enginerd | 0:b562096246b3 | 128 | |
enginerd | 0:b562096246b3 | 129 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 130 | /*! |
enginerd | 0:b562096246b3 | 131 | * \fn SmprInit |
enginerd | 0:b562096246b3 | 132 | * |
enginerd | 0:b562096246b3 | 133 | * \brief Initialize SMP responder role. |
enginerd | 0:b562096246b3 | 134 | * |
enginerd | 0:b562096246b3 | 135 | * \return None. |
enginerd | 0:b562096246b3 | 136 | */ |
enginerd | 0:b562096246b3 | 137 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 138 | void SmprInit(void); |
enginerd | 0:b562096246b3 | 139 | |
enginerd | 0:b562096246b3 | 140 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 141 | /*! |
enginerd | 0:b562096246b3 | 142 | * \fn SmpNonInit |
enginerd | 0:b562096246b3 | 143 | * |
enginerd | 0:b562096246b3 | 144 | * \brief Use this SMP init function when SMP is not supported. |
enginerd | 0:b562096246b3 | 145 | * |
enginerd | 0:b562096246b3 | 146 | * \return None. |
enginerd | 0:b562096246b3 | 147 | */ |
enginerd | 0:b562096246b3 | 148 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 149 | void SmpNonInit(void); |
enginerd | 0:b562096246b3 | 150 | |
enginerd | 0:b562096246b3 | 151 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 152 | /*! |
enginerd | 0:b562096246b3 | 153 | * \fn SmpDmMsgSend |
enginerd | 0:b562096246b3 | 154 | * |
enginerd | 0:b562096246b3 | 155 | * \brief This function is called by DM to send a message to SMP. |
enginerd | 0:b562096246b3 | 156 | * |
enginerd | 0:b562096246b3 | 157 | * \param pMsg Pointer to message structure. |
enginerd | 0:b562096246b3 | 158 | * |
enginerd | 0:b562096246b3 | 159 | * \return None. |
enginerd | 0:b562096246b3 | 160 | */ |
enginerd | 0:b562096246b3 | 161 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 162 | void SmpDmMsgSend(smpDmMsg_t *pMsg); |
enginerd | 0:b562096246b3 | 163 | |
enginerd | 0:b562096246b3 | 164 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 165 | /*! |
enginerd | 0:b562096246b3 | 166 | * \fn SmpDmEncryptInd |
enginerd | 0:b562096246b3 | 167 | * |
enginerd | 0:b562096246b3 | 168 | * \brief This function is called by DM to notify SMP of encrypted link status. |
enginerd | 0:b562096246b3 | 169 | * |
enginerd | 0:b562096246b3 | 170 | * \param pMsg Pointer to HCI message structure. |
enginerd | 0:b562096246b3 | 171 | * |
enginerd | 0:b562096246b3 | 172 | * \return None. |
enginerd | 0:b562096246b3 | 173 | */ |
enginerd | 0:b562096246b3 | 174 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 175 | void SmpDmEncryptInd(wsfMsgHdr_t *pMsg); |
enginerd | 0:b562096246b3 | 176 | |
enginerd | 0:b562096246b3 | 177 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 178 | /*! |
enginerd | 0:b562096246b3 | 179 | * \fn SmpDmGetStk |
enginerd | 0:b562096246b3 | 180 | * |
enginerd | 0:b562096246b3 | 181 | * \brief Return the STK for the given connection. |
enginerd | 0:b562096246b3 | 182 | * |
enginerd | 0:b562096246b3 | 183 | * \param connId Connection identifier. |
enginerd | 0:b562096246b3 | 184 | * \param pSecLevel Returns the security level of pairing when STK was created. |
enginerd | 0:b562096246b3 | 185 | * |
enginerd | 0:b562096246b3 | 186 | * \return Pointer to STK or NULL if not available. |
enginerd | 0:b562096246b3 | 187 | */ |
enginerd | 0:b562096246b3 | 188 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 189 | uint8_t *SmpDmGetStk(dmConnId_t connId, uint8_t *pSecLevel); |
enginerd | 0:b562096246b3 | 190 | |
enginerd | 0:b562096246b3 | 191 | #ifdef __cplusplus |
enginerd | 0:b562096246b3 | 192 | }; |
enginerd | 0:b562096246b3 | 193 | #endif |
enginerd | 0:b562096246b3 | 194 | |
enginerd | 0:b562096246b3 | 195 | #endif /* SMP_API_H */ |