1 /****************************************************************************** 2 * 3 * Copyright 1999-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This file contains the SMP API function external definitions. 22 * 23 ******************************************************************************/ 24 #ifndef SMP_API_H 25 #define SMP_API_H 26 27 #include <cstdint> 28 29 #include "bt_target.h" 30 #include "smp_api_types.h" 31 #include "types/bt_transport.h" 32 #include "types/raw_address.h" 33 34 /***************************************************************************** 35 * External Function Declarations 36 ****************************************************************************/ 37 /* API of SMP */ 38 39 /******************************************************************************* 40 * 41 * Function SMP_Init 42 * 43 * Description This function initializes the SMP unit. 44 * 45 * Returns void 46 * 47 ******************************************************************************/ 48 extern void SMP_Init(void); 49 50 /******************************************************************************* 51 * 52 * Function SMP_SetTraceLevel 53 * 54 * Description This function sets the trace level for SMP. If called with 55 * a value of 0xFF, it simply returns the current trace level. 56 * 57 * Returns The new or current trace level 58 * 59 ******************************************************************************/ 60 extern uint8_t SMP_SetTraceLevel(uint8_t new_level); 61 62 /******************************************************************************* 63 * 64 * Function SMP_Register 65 * 66 * Description This function register for the SMP service callback. 67 * 68 * Returns void 69 * 70 ******************************************************************************/ 71 extern bool SMP_Register(tSMP_CALLBACK* p_cback); 72 73 /******************************************************************************* 74 * 75 * Function SMP_Pair 76 * 77 * Description This function is called to start a SMP pairing. 78 * 79 * Returns SMP_STARTED if bond started, else otherwise exception. 80 * 81 ******************************************************************************/ 82 extern tSMP_STATUS SMP_Pair(const RawAddress& bd_addr); 83 extern tSMP_STATUS SMP_Pair(const RawAddress& bd_addr, 84 tBLE_ADDR_TYPE addr_type); 85 86 /******************************************************************************* 87 * 88 * Function SMP_BR_PairWith 89 * 90 * Description This function is called to start a SMP pairing over BR/EDR. 91 * 92 * Returns SMP_STARTED if pairing started, otherwise the reason for the 93 * failure. 94 * 95 ******************************************************************************/ 96 extern tSMP_STATUS SMP_BR_PairWith(const RawAddress& bd_addr); 97 98 /******************************************************************************* 99 * 100 * Function SMP_PairCancel 101 * 102 * Description This function is called to cancel a SMP pairing. 103 * 104 * Returns true - pairing cancelled 105 * 106 ******************************************************************************/ 107 extern bool SMP_PairCancel(const RawAddress& bd_addr); 108 109 /******************************************************************************* 110 * 111 * Function SMP_SecurityGrant 112 * 113 * Description This function is called to grant security process. 114 * 115 * Parameters bd_addr - peer device bd address. 116 * res - result of the operation SMP_SUCCESS if success. 117 * Otherwise, SMP_REPEATED_ATTEMPTS is too many 118 * attempts. 119 * 120 * Returns None 121 * 122 ******************************************************************************/ 123 extern void SMP_SecurityGrant(const RawAddress& bd_addr, tSMP_STATUS res); 124 125 /******************************************************************************* 126 * 127 * Function SMP_PasskeyReply 128 * 129 * Description This function is called after Security Manager submitted 130 * Passkey request to the application. 131 * 132 * Parameters: bd_addr - Address of the device for which PIN was requested 133 * res - result of the operation SMP_SUCCESS if success 134 * passkey - numeric value in the range of 135 * BTM_MIN_PASSKEY_VAL(0) - 136 * BTM_MAX_PASSKEY_VAL(999999(0xF423F)). 137 * 138 ******************************************************************************/ 139 extern void SMP_PasskeyReply(const RawAddress& bd_addr, uint8_t res, 140 uint32_t passkey); 141 142 /******************************************************************************* 143 * 144 * Function SMP_ConfirmReply 145 * 146 * Description This function is called after Security Manager submitted 147 * numeric comparison request to the application. 148 * 149 * Parameters: bd_addr - Address of the device with which numeric 150 * comparison was requested 151 * res - comparison result SMP_SUCCESS if success 152 * 153 ******************************************************************************/ 154 extern void SMP_ConfirmReply(const RawAddress& bd_addr, uint8_t res); 155 156 /******************************************************************************* 157 * 158 * Function SMP_OobDataReply 159 * 160 * Description This function is called to provide the OOB data for 161 * SMP in response to SMP_OOB_REQ_EVT 162 * 163 * Parameters: bd_addr - Address of the peer device 164 * res - result of the operation SMP_SUCCESS if success 165 * p_data - SM Randomizer C. 166 * 167 ******************************************************************************/ 168 extern void SMP_OobDataReply(const RawAddress& bd_addr, tSMP_STATUS res, 169 uint8_t len, uint8_t* p_data); 170 171 /******************************************************************************* 172 * 173 * Function SMP_SecureConnectionOobDataReply 174 * 175 * Description This function is called to provide the SC OOB data for 176 * SMP in response to SMP_SC_OOB_REQ_EVT 177 * 178 * Parameters: p_data - pointer to the data 179 * 180 ******************************************************************************/ 181 extern void SMP_SecureConnectionOobDataReply(uint8_t* p_data); 182 183 /******************************************************************************* 184 * 185 * Function SMP_CrLocScOobData 186 * 187 * Description This function is called to generate a public key to be 188 * passed to a remote device via an Out of Band transport 189 * 190 * Returns true if the request is successfully sent and executed by the 191 * state machine, false otherwise 192 * 193 ******************************************************************************/ 194 extern bool SMP_CrLocScOobData(); 195 196 /******************************************************************************* 197 * 198 * Function SMP_ClearLocScOobData 199 * 200 * Description This function is called to clear out the OOB stored locally. 201 * 202 ******************************************************************************/ 203 extern void SMP_ClearLocScOobData(); 204 205 // Called when LTK request is received from controller. 206 extern bool smp_proc_ltk_request(const RawAddress& bda); 207 208 // Called when link is encrypted and notified to peripheral device. 209 // Proceed to send LTK, DIV and ER to central if bonding the devices. 210 extern void smp_link_encrypted(const RawAddress& bda, uint8_t encr_enable); 211 212 #endif /* SMP_API_H */ 213