OSDN Git Service

Implement OOB pairing for LE devices using TK.
[android-x86/system-bt.git] / btif / include / btif_api.h
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-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  *  Filename:      btif_api.h
22  *
23  *  Description:   Main API header file for all BTIF functions accessed
24  *                 from main bluetooth HAL. All HAL extensions will not
25  *                 require headerfiles as they would be accessed through
26  *                 callout/callins.
27  *
28  *******************************************************************************/
29
30 #ifndef BTIF_API_H
31 #define BTIF_API_H
32
33 #include "btif_common.h"
34 #include "btif_dm.h"
35
36 /*******************************************************************************
37 **  BTIF CORE API
38 ********************************************************************************/
39
40 /*******************************************************************************
41 **
42 ** Function         btif_init_bluetooth
43 **
44 ** Description      Creates BTIF task and prepares BT scheduler for startup
45 **
46 ** Returns          bt_status_t
47 **
48 *******************************************************************************/
49 bt_status_t btif_init_bluetooth(void);
50
51 /*******************************************************************************
52 **
53 ** Function         btif_enable_bluetooth
54 **
55 ** Description      Performs chip power on and kickstarts OS scheduler
56 **
57 ** Returns          bt_status_t
58 **
59 *******************************************************************************/
60 bt_status_t btif_enable_bluetooth(void);
61
62 /*******************************************************************************
63 **
64 ** Function         btif_disable_bluetooth
65 **
66 ** Description      Inititates shutdown of Bluetooth system.
67 **                  Any active links will be dropped and device entering
68 **                  non connectable/discoverable mode
69 **
70 ** Returns          void
71 **
72 *******************************************************************************/
73 bt_status_t btif_disable_bluetooth(void);
74
75 /*******************************************************************************
76 **
77 ** Function         btif_shutdown_bluetooth
78 **
79 ** Description      Finalizes BT scheduler shutdown and terminates BTIF
80 **                  task.
81 **
82 **
83 ** Returns          void
84 **
85 *******************************************************************************/
86 bt_status_t btif_shutdown_bluetooth(void);
87
88 /*******************************************************************************
89 **
90 ** Function         btif_get_adapter_properties
91 **
92 ** Description      Fetches all local adapter properties
93 **
94 ** Returns          bt_status_t
95 **
96 *******************************************************************************/
97 bt_status_t btif_get_adapter_properties(void);
98
99 /*******************************************************************************
100 **
101 ** Function         btif_get_adapter_property
102 **
103 ** Description      Fetches property value from local cache
104 **
105 ** Returns          bt_status_t
106 **
107 *******************************************************************************/
108 bt_status_t btif_get_adapter_property( bt_property_type_t type);
109
110 /*******************************************************************************
111 **
112 ** Function         btif_set_adapter_property
113 **
114 ** Description      Updates core stack with property value and stores it in
115 **                  local cache
116 **
117 ** Returns          bt_status_t
118 **
119 *******************************************************************************/
120 bt_status_t btif_set_adapter_property( const bt_property_t *property);
121
122 /*******************************************************************************
123 **
124 ** Function         btif_get_remote_device_property
125 **
126 ** Description      Fetches the remote device property from the NVRAM
127 **
128 ** Returns          bt_status_t
129 **
130 *******************************************************************************/
131 bt_status_t btif_get_remote_device_property( bt_bdaddr_t *remote_addr,
132                                              bt_property_type_t type);
133
134 /*******************************************************************************
135 **
136 ** Function         btif_get_remote_device_properties
137 **
138 ** Description      Fetches all the remote device properties from NVRAM
139 **
140 ** Returns          bt_status_t
141 **
142 *******************************************************************************/
143 bt_status_t btif_get_remote_device_properties( bt_bdaddr_t *remote_addr);
144
145 /*******************************************************************************
146 **
147 ** Function         btif_set_remote_device_property
148 **
149 ** Description      Writes the remote device property to NVRAM.
150 **                  Currently, BT_PROPERTY_REMOTE_FRIENDLY_NAME is the only
151 **                  remote device property that can be set
152 **
153 ** Returns          bt_status_t
154 **
155 *******************************************************************************/
156 bt_status_t btif_set_remote_device_property( bt_bdaddr_t *remote_addr,
157                                              const bt_property_t *property);
158
159 /*******************************************************************************
160 **
161 ** Function         btif_get_remote_service_record
162 **
163 ** Description      Looks up the service matching uuid on the remote device
164 **                  and fetches the SCN and service_name if the UUID is found
165 **
166 ** Returns          bt_status_t
167 **
168 *******************************************************************************/
169 bt_status_t btif_get_remote_service_record( bt_bdaddr_t *remote_addr,
170                                             bt_uuid_t *uuid);
171
172
173 /*******************************************************************************
174 **  BTIF DM API
175 ********************************************************************************/
176
177 /*******************************************************************************
178 **
179 ** Function         btif_dm_start_discovery
180 **
181 ** Description      Start device discovery/inquiry
182 **
183 **
184 ** Returns          bt_status_t
185 **
186 *******************************************************************************/
187 bt_status_t btif_dm_start_discovery(void);
188
189 /*******************************************************************************
190 **
191 ** Function         btif_dm_cancel_discovery
192 **
193 ** Description      Cancels search
194 **
195 ** Returns          bt_status_t
196 **
197 *******************************************************************************/
198 bt_status_t btif_dm_cancel_discovery(void);
199
200 /*******************************************************************************
201 **
202 ** Function         btif_dm_create_bond
203 **
204 ** Description      Initiate bonding with the specified device
205 **
206 ** Returns          bt_status_t
207 **
208 *******************************************************************************/
209 bt_status_t btif_dm_create_bond(const bt_bdaddr_t *bd_addr, int transport);
210
211 /*******************************************************************************
212 **
213 ** Function         btif_dm_create_bond_out_of_band
214 **
215 ** Description      Initiate bonding with the specified device using OOB data.
216 **
217 ** Returns          bt_status_t
218 **
219 *******************************************************************************/
220 bt_status_t btif_dm_create_bond_out_of_band(const bt_bdaddr_t *bd_addr, int transport,
221                                     const bt_out_of_band_data_t *oob_data);
222
223 /*******************************************************************************
224 **
225 ** Function         btif_dm_cancel_bond
226 **
227 ** Description      Initiate bonding with the specified device
228 **
229 ** Returns          bt_status_t
230 **
231 *******************************************************************************/
232 bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr);
233
234 /*******************************************************************************
235 **
236 ** Function         btif_dm_remove_bond
237 **
238 ** Description      Removes bonding with the specified device
239 **
240 ** Returns          bt_status_t
241 **
242 *******************************************************************************/
243 bt_status_t btif_dm_remove_bond(const bt_bdaddr_t *bd_addr);
244
245 /*******************************************************************************
246 **
247 ** Function         btif_dm_get_connection_state
248 **
249 ** Description      Returns whether the remote device is currently connected
250 **
251 ** Returns          0 if not connected
252 **
253 *******************************************************************************/
254 uint16_t btif_dm_get_connection_state(const bt_bdaddr_t *bd_addr);
255
256 /*******************************************************************************
257 **
258 ** Function         btif_dm_pin_reply
259 **
260 ** Description      BT legacy pairing - PIN code reply
261 **
262 ** Returns          bt_status_t
263 **
264 *******************************************************************************/
265 bt_status_t btif_dm_pin_reply( const bt_bdaddr_t *bd_addr, uint8_t accept,
266                                uint8_t pin_len, bt_pin_code_t *pin_code);
267
268 /*******************************************************************************
269 **
270 ** Function         btif_dm_passkey_reply
271 **
272 ** Description      BT SSP passkey reply
273 **
274 ** Returns          bt_status_t
275 **
276 *******************************************************************************/
277 bt_status_t btif_dm_passkey_reply( const bt_bdaddr_t *bd_addr,
278                                    uint8_t accept, uint32_t passkey);
279
280 /*******************************************************************************
281 **
282 ** Function         btif_dm_ssp_reply
283 **
284 ** Description      BT SSP Reply - Just Works, Numeric Comparison & Passkey Entry
285 **
286 ** Returns          bt_status_t
287 **
288 *******************************************************************************/
289 bt_status_t btif_dm_ssp_reply( const bt_bdaddr_t *bd_addr,
290                               bt_ssp_variant_t variant, uint8_t accept,
291                               uint32_t passkey);
292
293 /*******************************************************************************
294 **
295 ** Function         btif_dm_get_adapter_property
296 **
297 ** Description      Queries the BTA for the adapter property
298 **
299 ** Returns          bt_status_t
300 **
301 *******************************************************************************/
302 bt_status_t btif_dm_get_adapter_property(bt_property_t *prop);
303
304 /*******************************************************************************
305 **
306 ** Function         btif_dm_get_remote_services
307 **
308 ** Description      Start SDP to get remote services
309 **
310 ** Returns          bt_status_t
311 **
312 *******************************************************************************/
313 bt_status_t btif_dm_get_remote_service_record(bt_bdaddr_t *remote_addr,
314                                               bt_uuid_t *uuid);
315
316
317 /*******************************************************************************
318 **
319 ** Function         btif_dm_get_remote_services
320 **
321 ** Description      Start SDP to get remote services
322 **
323 ** Returns          bt_status_t
324 **
325 *******************************************************************************/
326 bt_status_t btif_dm_get_remote_services(bt_bdaddr_t *remote_addr);
327
328 /*******************************************************************************
329 **
330 ** Function         btif_dm_get_remote_services_by_transport
331 **
332 ** Description      Start SDP to get remote services by transport
333 **
334 ** Returns          bt_status_t
335 **
336 *******************************************************************************/
337 bt_status_t btif_dm_get_remote_services_by_transport(bt_bdaddr_t *remote_addr, int transport);
338
339 /*******************************************************************************
340 **
341 ** Function         btif_dut_mode_configure
342 **
343 ** Description      Configure Test Mode - 'enable' to 1 puts the device in test mode and 0 exits
344 **                       test mode
345 **
346 ** Returns          BT_STATUS_SUCCESS on success
347 **
348 *******************************************************************************/
349 bt_status_t btif_dut_mode_configure(uint8_t enable);
350
351 /*******************************************************************************
352 **
353 ** Function         btif_dut_mode_send
354 **
355 ** Description     Sends a HCI Vendor specific command to the controller
356 **
357 ** Returns          BT_STATUS_SUCCESS on success
358 **
359 *******************************************************************************/
360 bt_status_t btif_dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len);
361
362 /*******************************************************************************
363 **
364 ** Function         btif_le_test_mode
365 **
366 ** Description     Sends a HCI BLE Test command to the Controller
367 **
368 ** Returns          BT_STATUS_SUCCESS on success
369 **
370 *******************************************************************************/
371 bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len);
372
373 /*******************************************************************************
374 **
375 ** Function         btif_dm_read_energy_info
376 **
377 ** Description     Reads the energy info from controller
378 **
379 ** Returns          void
380 **
381 *******************************************************************************/
382 void btif_dm_read_energy_info();
383
384 /*******************************************************************************
385 **
386 ** Function         btif_config_hci_snoop_log
387 **
388 ** Description     enable or disable HCI snoop log
389 **
390 ** Returns          BT_STATUS_SUCCESS on success
391 **
392 *******************************************************************************/
393 bt_status_t btif_config_hci_snoop_log(uint8_t enable);
394 #endif /* BTIF_API_H */