• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 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 #include "types/raw_address.h"
38 
39 /*******************************************************************************
40  *  BTIF CORE API
41  ******************************************************************************/
42 
43 /*******************************************************************************
44  *
45  * Function         btif_init_bluetooth
46  *
47  * Description      Creates BTIF task and prepares BT scheduler for startup
48  *
49  * Returns          bt_status_t
50  *
51  ******************************************************************************/
52 bt_status_t btif_init_bluetooth(void);
53 
54 /*******************************************************************************
55  *
56  * Function         btif_enable_bluetooth
57  *
58  * Description      Performs chip power on and kickstarts OS scheduler
59  *
60  * Returns          bt_status_t
61  *
62  ******************************************************************************/
63 bt_status_t btif_enable_bluetooth(void);
64 
65 /*******************************************************************************
66  *
67  * Function         btif_cleanup_bluetooth
68  *
69  * Description      Cleanup BTIF state.
70  *
71  *
72  * Returns          void
73  *
74  ******************************************************************************/
75 bt_status_t btif_cleanup_bluetooth(void);
76 
77 /*******************************************************************************
78  *
79  * Function         is_restricted_mode
80  *
81  * Description      Checks if BT was enabled in restriced mode. In restricted
82  *                  mode, bonds that are created are marked as temporary.
83  *                  These bonds persist until we leave restricted mode, at
84  *                  which point they will be deleted from the config. Also
85  *                  while in restricted mode, the user can access devices
86  *                  that are already paired before entering restricted mode,
87  *                  but they cannot remove any of these devices.
88  *
89  * Returns          bool
90  *
91  ******************************************************************************/
92 bool is_restricted_mode(void);
93 
94 /*******************************************************************************
95  *
96  * Function         is_common_criteria_mode
97  *
98  * Description      Check if BT is enabled in common criteria mode. In this
99  *                  mode, will use the LTK from the keystore to authenticate.
100  *
101  * Returns          bool
102  *
103  ******************************************************************************/
104 bool is_common_criteria_mode(void);
105 
106 /*******************************************************************************
107  *
108  * Function         get_common_criteria_config_compare_result
109  *
110  * Description      Get the common criteria config compare result for confirming
111  *                  the config checksum compare result. When the common criteria
112  *                  mode doesn't enable, it should be all pass (0b11).
113  *                  Bit define:
114  *                    CONFIG_FILE_COMPARE_PASS = 0b01
115  *                    CONFIG_BACKUP_COMPARE_PASS = 0b10
116  *
117  * Returns          int
118  *
119  ******************************************************************************/
120 int get_common_criteria_config_compare_result(void);
121 
122 /*******************************************************************************
123  *
124  * Function         is_atv_device
125  *
126  * Description      Returns true if the local device is an Android TV
127  *                  device, false if it is not.
128  *
129  * Returns          bool
130  *
131  ******************************************************************************/
132 bool is_atv_device(void);
133 
134 /*******************************************************************************
135  *
136  * Function         btif_get_adapter_properties
137  *
138  * Description      Fetches all local adapter properties
139  *
140  ******************************************************************************/
141 void btif_get_adapter_properties(void);
142 
143 bt_property_t* property_deep_copy(const bt_property_t* prop);
144 
145 /*******************************************************************************
146  *
147  * Function         btif_get_adapter_property
148  *
149  * Description      Fetches property value from local cache
150  *
151  ******************************************************************************/
152 void btif_get_adapter_property(bt_property_type_t type);
153 
154 /*******************************************************************************
155  *
156  * Function         btif_set_adapter_property
157  *
158  * Description      Updates core stack with property value and stores it in
159  *                  local cache
160  *
161  ******************************************************************************/
162 void btif_set_adapter_property(bt_property_t* property);
163 
164 /*******************************************************************************
165  *
166  * Function         btif_get_remote_device_property
167  *
168  * Description      Fetches the remote device property from the NVRAM
169  *
170  ******************************************************************************/
171 void btif_get_remote_device_property(RawAddress remote_addr,
172                                      bt_property_type_t type);
173 
174 /*******************************************************************************
175  *
176  * Function         btif_get_remote_device_properties
177  *
178  * Description      Fetches all the remote device properties from NVRAM
179  *
180  ******************************************************************************/
181 void btif_get_remote_device_properties(RawAddress remote_addr);
182 
183 /*******************************************************************************
184  *
185  * Function         btif_set_remote_device_property
186  *
187  * Description      Writes the remote device property to NVRAM.
188  *                  Currently, BT_PROPERTY_REMOTE_FRIENDLY_NAME is the only
189  *                  remote device property that can be set
190  *
191  ******************************************************************************/
192 void btif_set_remote_device_property(RawAddress* remote_addr,
193                                      bt_property_t* property);
194 
195 /*******************************************************************************
196  *  BTIF DM API
197  ******************************************************************************/
198 
199 /*******************************************************************************
200  *
201  * Function         btif_dm_start_discovery
202  *
203  * Description      Start device discovery/inquiry
204  *
205  ******************************************************************************/
206 void btif_dm_start_discovery(void);
207 
208 /*******************************************************************************
209  *
210  * Function         btif_dm_cancel_discovery
211  *
212  * Description      Cancels search
213  *
214  ******************************************************************************/
215 void btif_dm_cancel_discovery(void);
216 
217 bool btif_dm_pairing_is_busy();
218 /*******************************************************************************
219  *
220  * Function         btif_dm_create_bond
221  *
222  * Description      Initiate bonding with the specified device
223  *
224  ******************************************************************************/
225 void btif_dm_create_bond(const RawAddress bd_addr, int transport);
226 
227 /*******************************************************************************
228  *
229  * Function         btif_dm_create_bond_le
230  *
231  * Description      Initiate bonding with the specified device over le transport
232  *
233  ******************************************************************************/
234 void btif_dm_create_bond_le(const RawAddress bd_addr, uint8_t addr_type);
235 
236 /*******************************************************************************
237  *
238  * Function         btif_dm_create_bond_out_of_band
239  *
240  * Description      Initiate bonding with the specified device using OOB data.
241  *
242  ******************************************************************************/
243 void btif_dm_create_bond_out_of_band(const RawAddress bd_addr,
244                                      tBT_TRANSPORT transport,
245                                      const bt_oob_data_t p192_data,
246                                      const bt_oob_data_t p256_data);
247 
248 /*******************************************************************************
249  *
250  * Function         btif_dm_cancel_bond
251  *
252  * Description      Initiate bonding with the specified device
253  *
254  ******************************************************************************/
255 void btif_dm_cancel_bond(const RawAddress bd_addr);
256 
257 /*******************************************************************************
258  *
259  * Function         btif_dm_remove_bond
260  *
261  * Description      Removes bonding with the specified device
262  *
263  ******************************************************************************/
264 void btif_dm_remove_bond(const RawAddress bd_addr);
265 
266 /*******************************************************************************
267  *
268  * Function         btif_dm_get_connection_state
269  *
270  * Description      Returns whether the remote device is currently connected
271  *
272  * Returns          0 if not connected
273  *
274  ******************************************************************************/
275 uint16_t btif_dm_get_connection_state(const RawAddress* bd_addr);
276 
277 /*******************************************************************************
278  *
279  * Function         btif_dm_pin_reply
280  *
281  * Description      BT legacy pairing - PIN code reply
282  *
283  ******************************************************************************/
284 void btif_dm_pin_reply(const RawAddress bd_addr, uint8_t accept,
285                        uint8_t pin_len, bt_pin_code_t pin_code);
286 
287 /*******************************************************************************
288  *
289  * Function         btif_dm_passkey_reply
290  *
291  * Description      BT SSP passkey reply
292  *
293  * Returns          bt_status_t
294  *
295  ******************************************************************************/
296 bt_status_t btif_dm_passkey_reply(const RawAddress* bd_addr, uint8_t accept,
297                                   uint32_t passkey);
298 
299 /*******************************************************************************
300  *
301  * Function         btif_dm_ssp_reply
302  *
303  * Description      BT SSP Reply - Just Works, Numeric Comparison & Passkey
304  *                  Entry
305  *
306  ******************************************************************************/
307 void btif_dm_ssp_reply(const RawAddress bd_addr, bt_ssp_variant_t variant,
308                        uint8_t accept);
309 
310 /*******************************************************************************
311  *
312  * Function         btif_dm_get_adapter_property
313  *
314  * Description      Queries the BTA for the adapter property
315  *
316  * Returns          bt_status_t
317  *
318  ******************************************************************************/
319 bt_status_t btif_dm_get_adapter_property(bt_property_t* prop);
320 
321 /*******************************************************************************
322  *
323  * Function         btif_dm_get_remote_services
324  *
325  * Description      Start SDP to get remote services
326  *
327  * Returns          bt_status_t
328  *
329  ******************************************************************************/
330 void btif_dm_get_remote_services(const RawAddress remote_addr, int transport);
331 
332 /*******************************************************************************
333  *
334  * Function         btif_dm_read_energy_info
335  *
336  * Description     Reads the energy info from controller
337  *
338  * Returns          void
339  *
340  ******************************************************************************/
341 void btif_dm_read_energy_info();
342 
343 /*******************************************************************************
344  *
345  * Function         btif_config_hci_snoop_log
346  *
347  * Description     enable or disable HCI snoop log
348  *
349  * Returns          BT_STATUS_SUCCESS on success
350  *
351  ******************************************************************************/
352 bt_status_t btif_config_hci_snoop_log(uint8_t enable);
353 
354 /*******************************************************************************
355  *
356  * Function         btif_debug_bond_event_dump
357  *
358  * Description     Dump bond event information
359  *
360  * Returns          void
361  *
362  ******************************************************************************/
363 void btif_debug_bond_event_dump(int fd);
364 
365 /*******************************************************************************
366  *
367  * Function         btif_set_dynamic_audio_buffer_size
368  *
369  * Description     Set dynamic audio buffer size
370  *
371  * Returns          BT_STATUS_SUCCESS on success
372  *
373  ******************************************************************************/
374 bt_status_t btif_set_dynamic_audio_buffer_size(int codec, int size);
375 
376 /*******************************************************************************
377  *
378  * Function         btif_debug_linkkey_type_dump
379  *
380  * Description     Dump exchanged linkkey types information
381  *
382  * Returns          void
383  *
384  ******************************************************************************/
385 void btif_debug_linkkey_type_dump(int fd);
386 
387 #endif /* BTIF_API_H */
388