1 /******************************************************************************
2  *
3  *  Copyright (C) 2006-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 is the interface file for device mananger callout functions.
22  *
23  ******************************************************************************/
24 #ifndef BTA_DM_CO_H
25 #define BTA_DM_CO_H
26 
27 #include "bta/bta_sys.h"
28 #include "esp_err.h"
29 
30 /*****************************************************************************
31 **  Function Declarations
32 *****************************************************************************/
33 
34 /*******************************************************************************
35 **
36 ** Function         bta_dm_co_bt_set_io_cap
37 **
38 ** Description      This function is used to set IO capabilities
39 **
40 ** Parameters       bt_io_cap  - IO capabilities
41 **
42 ** @return          - ESP_BT_STATUS_SUCCESS : success
43 **                  - other  : failed
44 **
45 *******************************************************************************/
46 extern esp_err_t bta_dm_co_bt_set_io_cap(UINT8 bt_io_cap);
47 
48 /*******************************************************************************
49 **
50 ** Function         bta_dm_co_io_req
51 **
52 ** Description      This callout function is executed by DM to get IO capabilities
53 **                  of the local device for the Simple Pairing process
54 **
55 ** Parameters       bd_addr  - The peer device
56 **                  *p_io_cap - The local Input/Output capabilities
57 **                  *p_oob_data - TRUE, if OOB data is available for the peer device.
58 **                  *p_auth_req - TRUE, if MITM protection is required.
59 **
60 ** Returns          void.
61 **
62 *******************************************************************************/
63 extern void bta_dm_co_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
64                              tBTA_OOB_DATA *p_oob_data, tBTA_AUTH_REQ *p_auth_req,
65                              BOOLEAN is_orig);
66 
67 /*******************************************************************************
68 **
69 ** Function         bta_dm_co_io_rsp
70 **
71 ** Description      This callout function is executed by DM to report IO capabilities
72 **                  of the peer device for the Simple Pairing process
73 **
74 ** Parameters       bd_addr  - The peer device
75 **                  io_cap - The remote Input/Output capabilities
76 **                  oob_data - TRUE, if OOB data is available for the peer device.
77 **                  auth_req - TRUE, if MITM protection is required.
78 **
79 ** Returns          void.
80 **
81 *******************************************************************************/
82 extern void bta_dm_co_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
83                              tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req);
84 
85 /*******************************************************************************
86 **
87 ** Function         bta_dm_co_lk_upgrade
88 **
89 ** Description      This callout function is executed by DM to check if the
90 **                  platform wants allow link key upgrade
91 **
92 ** Parameters       bd_addr  - The peer device
93 **                  *p_upgrade - TRUE, if link key upgrade is desired.
94 **
95 ** Returns          void.
96 **
97 *******************************************************************************/
98 extern void  bta_dm_co_lk_upgrade(BD_ADDR bd_addr, BOOLEAN *p_upgrade );
99 
100 /*******************************************************************************
101 **
102 ** Function         bta_dm_co_loc_oob
103 **
104 ** Description      This callout function is executed by DM to report the OOB
105 **                  data of the local device for the Simple Pairing process
106 **
107 ** Parameters       valid - TRUE, if the local OOB data is retrieved from LM
108 **                  c     - Simple Pairing Hash C
109 **                  r     - Simple Pairing Randomnizer R
110 **
111 ** Returns          void.
112 **
113 *******************************************************************************/
114 extern void bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r);
115 
116 /*******************************************************************************
117 **
118 ** Function         bta_dm_co_rmt_oob
119 **
120 ** Description      This callout function is executed by DM to request the OOB
121 **                  data for the remote device for the Simple Pairing process
122 **
123 ** Parameters       bd_addr  - The peer device
124 **
125 ** Returns          void.
126 **
127 *******************************************************************************/
128 extern void bta_dm_co_rmt_oob(BD_ADDR bd_addr);
129 
130 
131 /*******************************************************************************
132 **
133 ** Function         bta_dm_co_ble_io_req
134 **
135 ** Description      This callout function is executed by DM to get BLE IO capabilities
136 **                  before SMP pairing gets going.
137 **
138 ** Parameters       bd_addr  - The peer device
139 **                  *p_io_cap - The local Input/Output capabilities
140 **                  *p_oob_data - TRUE, if OOB data is available for the peer device.
141 **                  *p_auth_req -  Auth request setting (Bonding and MITM required or not)
142 **                  *p_max_key_size - max key size local device supported.
143 **                  *p_init_key - initiator keys.
144 **                  *p_resp_key - responder keys.
145 **
146 ** Returns          void.
147 **
148 *******************************************************************************/
149 extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr,  tBTA_IO_CAP *p_io_cap,
150                                  tBTA_OOB_DATA *p_oob_data,
151                                  tBTA_LE_AUTH_REQ *p_auth_req,
152                                  UINT8 *p_max_key_size,
153                                  tBTA_LE_KEY_TYPE *p_init_key,
154                                  tBTA_LE_KEY_TYPE  *p_resp_key );
155 
156 
157 /*******************************************************************************
158 **
159 ** Function         bta_dm_co_ble_local_key_reload
160 **
161 ** Description      This callout function is to load the local BLE keys if available
162 **                  on the device.
163 **
164 ** Parameters       none
165 **
166 ** Returns          void.
167 **
168 *******************************************************************************/
169 extern void bta_dm_co_ble_load_local_keys (tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er,
170         tBTA_BLE_LOCAL_ID_KEYS *p_id_keys);
171 
172 // btla-specific ++
173 /*******************************************************************************
174 **
175 ** Function         bta_dm_co_ble_io_req
176 **
177 ** Description      This callout function is executed by DM to get BLE IO capabilities
178 **                  before SMP pairing gets going.
179 **
180 ** Parameters       bd_addr  - The peer device
181 **                  *p_io_cap - The local Input/Output capabilities
182 **                  *p_oob_data - TRUE, if OOB data is available for the peer device.
183 **                  *p_auth_req -  Auth request setting (Bonding and MITM required or not)
184 **                  *p_max_key_size - max key size local device supported.
185 **                  *p_init_key - initiator keys.
186 **                  *p_resp_key - responder keys.
187 **
188 ** Returns          void.
189 **
190 *******************************************************************************/
191 extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr,  tBTA_IO_CAP *p_io_cap,
192                                  tBTA_OOB_DATA *p_oob_data,
193                                  tBTA_LE_AUTH_REQ *p_auth_req,
194                                  UINT8 *p_max_key_size,
195                                  tBTA_LE_KEY_TYPE *p_init_key,
196                                  tBTA_LE_KEY_TYPE  *p_resp_key );
197 // btla-specific --
198 
199 extern void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap);
200 
201 extern void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req);
202 
203 extern void bta_dm_co_ble_set_init_key_req(UINT8 init_key);
204 
205 extern void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key);
206 
207 extern void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size);
208 
209 extern void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size);
210 
211 extern void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable);
212 
213 extern UINT8 bta_dm_co_ble_get_accept_auth_enable(void);
214 
215 extern UINT8 bta_dm_co_ble_get_auth_req(void);
216 
217 extern void bta_dm_co_ble_oob_support(UINT8 enable);
218 
219 extern void bta_dm_co_ble_set_appl_enc_key_size(UINT8 ble_key_size);
220 #endif
221