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 "smp_api_types.h" 30 #include "types/ble_address_with_type.h" 31 #include "types/raw_address.h" 32 33 /***************************************************************************** 34 * External Function Declarations 35 ****************************************************************************/ 36 /* API of SMP */ 37 38 /******************************************************************************* 39 * 40 * Function SMP_Init 41 * 42 * Description This function initializes the SMP unit. 43 * 44 * Returns void 45 * 46 ******************************************************************************/ 47 void SMP_Init(uint8_t init_security_mode); 48 49 /******************************************************************************* 50 * 51 * Function SMP_Register 52 * 53 * Description This function register for the SMP service callback. 54 * 55 * Returns void 56 * 57 ******************************************************************************/ 58 bool SMP_Register(tSMP_CALLBACK* p_cback); 59 60 /******************************************************************************* 61 * 62 * Function SMP_Pair 63 * 64 * Description This function is called to start a SMP pairing. 65 * 66 * Returns SMP_STARTED if bond started, else otherwise exception. 67 * 68 ******************************************************************************/ 69 tSMP_STATUS SMP_Pair(const RawAddress& bd_addr); 70 tSMP_STATUS SMP_Pair(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type); 71 72 /******************************************************************************* 73 * 74 * Function SMP_BR_PairWith 75 * 76 * Description This function is called to start a SMP pairing over BR/EDR. 77 * 78 * Returns SMP_STARTED if pairing started, otherwise the reason for the 79 * failure. 80 * 81 ******************************************************************************/ 82 tSMP_STATUS SMP_BR_PairWith(const RawAddress& bd_addr); 83 84 /******************************************************************************* 85 * 86 * Function SMP_PairCancel 87 * 88 * Description This function is called to cancel a SMP pairing. 89 * 90 * Returns true - pairing cancelled 91 * 92 ******************************************************************************/ 93 bool SMP_PairCancel(const RawAddress& bd_addr); 94 95 /******************************************************************************* 96 * 97 * Function SMP_SecurityGrant 98 * 99 * Description This function is called to grant security process. 100 * 101 * Parameters bd_addr - peer device bd address. 102 * res - result of the operation SMP_SUCCESS if success. 103 * Otherwise, SMP_REPEATED_ATTEMPTS is too many 104 * attempts. 105 * 106 * Returns None 107 * 108 ******************************************************************************/ 109 void SMP_SecurityGrant(const RawAddress& bd_addr, tSMP_STATUS res); 110 111 /******************************************************************************* 112 * 113 * Function SMP_PasskeyReply 114 * 115 * Description This function is called after Security Manager submitted 116 * Passkey request to the application. 117 * 118 * Parameters: bd_addr - Address of the device for which PIN was requested 119 * res - result of the operation SMP_SUCCESS if success 120 * passkey - numeric value in the range of 121 * BTM_MIN_PASSKEY_VAL(0) - 122 * BTM_MAX_PASSKEY_VAL(999999(0xF423F)). 123 * 124 ******************************************************************************/ 125 void SMP_PasskeyReply(const RawAddress& bd_addr, uint8_t res, uint32_t passkey); 126 127 /******************************************************************************* 128 * 129 * Function SMP_ConfirmReply 130 * 131 * Description This function is called after Security Manager submitted 132 * numeric comparison request to the application. 133 * 134 * Parameters: bd_addr - Address of the device with which numeric 135 * comparison was requested 136 * res - comparison result SMP_SUCCESS if success 137 * 138 ******************************************************************************/ 139 void SMP_ConfirmReply(const RawAddress& bd_addr, uint8_t res); 140 141 /******************************************************************************* 142 * 143 * Function SMP_OobDataReply 144 * 145 * Description This function is called to provide the OOB data for 146 * SMP in response to SMP_OOB_REQ_EVT 147 * 148 * Parameters: bd_addr - Address of the peer device 149 * res - result of the operation SMP_SUCCESS if success 150 * p_data - SM Randomizer C. 151 * 152 ******************************************************************************/ 153 void SMP_OobDataReply(const RawAddress& bd_addr, tSMP_STATUS res, uint8_t len, 154 uint8_t* p_data); 155 156 /******************************************************************************* 157 * 158 * Function SMP_SecureConnectionOobDataReply 159 * 160 * Description This function is called to provide the SC OOB data for 161 * SMP in response to SMP_SC_OOB_REQ_EVT 162 * 163 * Parameters: p_data - pointer to the data 164 * 165 ******************************************************************************/ 166 void SMP_SecureConnectionOobDataReply(uint8_t* p_data); 167 168 /******************************************************************************* 169 * 170 * Function SMP_CrLocScOobData 171 * 172 * Description This function is called to generate a public key to be 173 * passed to a remote device via an Out of Band transport 174 * 175 * Returns true if the request is successfully sent and executed by the 176 * state machine, false otherwise 177 * 178 ******************************************************************************/ 179 bool SMP_CrLocScOobData(); 180 181 /******************************************************************************* 182 * 183 * Function SMP_ClearLocScOobData 184 * 185 * Description This function is called to clear out the OOB stored locally. 186 * 187 ******************************************************************************/ 188 void SMP_ClearLocScOobData(); 189 190 /******************************************************************************* 191 * 192 * Function SMP_SirkConfirmDeviceReply 193 * 194 * Description This function is called after Security Manager submitted 195 * verification of device with CSIP. 196 * 197 * Parameters: bd_addr - Address of the device with which verification 198 * was requested 199 * res - comparison result SMP_SUCCESS if success 200 * 201 ******************************************************************************/ 202 void SMP_SirkConfirmDeviceReply(const RawAddress& bd_addr, uint8_t res); 203 204 // Called when LTK request is received from controller. 205 bool smp_proc_ltk_request(const RawAddress& bda); 206 207 // Called when link is encrypted and notified to peripheral device. 208 // Proceed to send LTK, DIV and ER to central if bonding the devices. 209 void smp_link_encrypted(const RawAddress& bda, uint8_t encr_enable); 210 211 #endif /* SMP_API_H */ 212