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