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 "bt_target.h" 28 #include "smp_api_types.h" 29 30 /***************************************************************************** 31 * External Function Declarations 32 ****************************************************************************/ 33 /* API of SMP */ 34 35 /******************************************************************************* 36 * 37 * Function SMP_Init 38 * 39 * Description This function initializes the SMP unit. 40 * 41 * Returns void 42 * 43 ******************************************************************************/ 44 extern void SMP_Init(void); 45 46 /******************************************************************************* 47 * 48 * Function SMP_SetTraceLevel 49 * 50 * Description This function sets the trace level for SMP. If called with 51 * a value of 0xFF, it simply returns the current trace level. 52 * 53 * Returns The new or current trace level 54 * 55 ******************************************************************************/ 56 extern uint8_t SMP_SetTraceLevel(uint8_t new_level); 57 58 /******************************************************************************* 59 * 60 * Function SMP_Register 61 * 62 * Description This function register for the SMP service callback. 63 * 64 * Returns void 65 * 66 ******************************************************************************/ 67 extern bool SMP_Register(tSMP_CALLBACK* p_cback); 68 69 /******************************************************************************* 70 * 71 * Function SMP_Pair 72 * 73 * Description This function is called to start a SMP pairing. 74 * 75 * Returns SMP_STARTED if bond started, else otherwise exception. 76 * 77 ******************************************************************************/ 78 extern tSMP_STATUS SMP_Pair(const RawAddress& bd_addr); 79 80 /******************************************************************************* 81 * 82 * Function SMP_BR_PairWith 83 * 84 * Description This function is called to start a SMP pairing over BR/EDR. 85 * 86 * Returns SMP_STARTED if pairing started, otherwise the reason for the 87 * failure. 88 * 89 ******************************************************************************/ 90 extern tSMP_STATUS SMP_BR_PairWith(const RawAddress& bd_addr); 91 92 /******************************************************************************* 93 * 94 * Function SMP_PairCancel 95 * 96 * Description This function is called to cancel a SMP pairing. 97 * 98 * Returns true - pairing cancelled 99 * 100 ******************************************************************************/ 101 extern bool SMP_PairCancel(const RawAddress& bd_addr); 102 103 /******************************************************************************* 104 * 105 * Function SMP_SecurityGrant 106 * 107 * Description This function is called to grant security process. 108 * 109 * Parameters bd_addr - peer device bd address. 110 * res - result of the operation SMP_SUCCESS if success. 111 * Otherwise, SMP_REPEATED_ATTEMPTS is too many 112 * attempts. 113 * 114 * Returns None 115 * 116 ******************************************************************************/ 117 extern void SMP_SecurityGrant(const RawAddress& bd_addr, uint8_t res); 118 119 /******************************************************************************* 120 * 121 * Function SMP_PasskeyReply 122 * 123 * Description This function is called after Security Manager submitted 124 * Passkey request to the application. 125 * 126 * Parameters: bd_addr - Address of the device for which PIN was requested 127 * res - result of the operation SMP_SUCCESS if success 128 * passkey - numeric value in the range of 129 * BTM_MIN_PASSKEY_VAL(0) - 130 * BTM_MAX_PASSKEY_VAL(999999(0xF423F)). 131 * 132 ******************************************************************************/ 133 extern void SMP_PasskeyReply(const RawAddress& bd_addr, uint8_t res, 134 uint32_t passkey); 135 136 /******************************************************************************* 137 * 138 * Function SMP_ConfirmReply 139 * 140 * Description This function is called after Security Manager submitted 141 * numeric comparison request to the application. 142 * 143 * Parameters: bd_addr - Address of the device with which numeric 144 * comparison was requested 145 * res - comparison result SMP_SUCCESS if success 146 * 147 ******************************************************************************/ 148 extern void SMP_ConfirmReply(const RawAddress& bd_addr, uint8_t res); 149 150 /******************************************************************************* 151 * 152 * Function SMP_OobDataReply 153 * 154 * Description This function is called to provide the OOB data for 155 * SMP in response to SMP_OOB_REQ_EVT 156 * 157 * Parameters: bd_addr - Address of the peer device 158 * res - result of the operation SMP_SUCCESS if success 159 * p_data - SM Randomizer C. 160 * 161 ******************************************************************************/ 162 extern void SMP_OobDataReply(const RawAddress& bd_addr, tSMP_STATUS res, 163 uint8_t len, uint8_t* p_data); 164 165 /******************************************************************************* 166 * 167 * Function SMP_SecureConnectionOobDataReply 168 * 169 * Description This function is called to provide the SC OOB data for 170 * SMP in response to SMP_SC_OOB_REQ_EVT 171 * 172 * Parameters: p_data - pointer to the data 173 * 174 ******************************************************************************/ 175 extern void SMP_SecureConnectionOobDataReply(uint8_t* p_data); 176 177 /******************************************************************************* 178 * 179 * Function SMP_KeypressNotification 180 * 181 * Description Notify SM about Keypress Notification. 182 * 183 * Parameters: bd_addr - Address of the device to send keypress 184 * notification to 185 * value - keypress notification parameter value 186 * 187 ******************************************************************************/ 188 extern void SMP_KeypressNotification(const RawAddress& bd_addr, uint8_t value); 189 190 /******************************************************************************* 191 * 192 * Function SMP_CreateLocalSecureConnectionsOobData 193 * 194 * Description This function is called to start creation of local SC OOB 195 * data set (tSMP_LOC_OOB_DATA). 196 * 197 * Parameters: bd_addr - Address of the device to send OOB data block 198 * to. 199 * 200 * Returns Boolean - true: creation of local SC OOB data set started. 201 ******************************************************************************/ 202 extern bool SMP_CreateLocalSecureConnectionsOobData( 203 tBLE_BD_ADDR* addr_to_send_to); 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 slave device. 209 // Proceed to send LTK, DIV and ER to master if bonding the devices. 210 extern void smp_link_encrypted(const RawAddress& bda, uint8_t encr_enable); 211 212 #endif /* SMP_API_H */ 213