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