blob: 93aa8e52918d6b1426fc99cf6a4def37eb7b812a [file] [log] [blame]
Andre Eisenbach05f49542012-09-18 12:15:26 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_BLUETOOTH_H
18#define ANDROID_INCLUDE_BLUETOOTH_H
19
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -070020#include <stdbool.h>
Andre Eisenbach05f49542012-09-18 12:15:26 -070021#include <stdint.h>
22#include <sys/cdefs.h>
23#include <sys/types.h>
24
25#include <hardware/hardware.h>
26
27__BEGIN_DECLS
28
29/**
30 * The Bluetooth Hardware Module ID
31 */
32
33#define BT_HARDWARE_MODULE_ID "bluetooth"
34#define BT_STACK_MODULE_ID "bluetooth"
35#define BT_STACK_TEST_MODULE_ID "bluetooth_test"
36
37
38/* Bluetooth profile interface IDs */
39
40#define BT_PROFILE_HANDSFREE_ID "handsfree"
Hemant Guptae7737c82013-08-19 18:02:54 +053041#define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
Andre Eisenbach05f49542012-09-18 12:15:26 -070042#define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
Mike Lockwood21e50b12014-06-07 14:05:22 -070043#define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink"
Andre Eisenbach05f49542012-09-18 12:15:26 -070044#define BT_PROFILE_HEALTH_ID "health"
45#define BT_PROFILE_SOCKETS_ID "socket"
46#define BT_PROFILE_HIDHOST_ID "hidhost"
47#define BT_PROFILE_PAN_ID "pan"
Hemant Gupta053cccf2014-04-18 12:25:24 +053048#define BT_PROFILE_MAP_CLIENT_ID "map_client"
kschulz9a92a7b2015-03-06 09:15:43 +010049#define BT_PROFILE_SDP_CLIENT_ID "sdp"
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -080050#define BT_PROFILE_GATT_ID "gatt"
Ravi Nagarajan482ba782013-02-26 10:34:41 -080051#define BT_PROFILE_AV_RC_ID "avrcp"
Mike Lockwood7da4cb82014-06-02 16:20:51 -070052#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
Andre Eisenbach05f49542012-09-18 12:15:26 -070053
54/** Bluetooth Address */
55typedef struct {
56 uint8_t address[6];
57} __attribute__((packed))bt_bdaddr_t;
58
59/** Bluetooth Device Name */
60typedef struct {
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -080061 uint8_t name[249];
Andre Eisenbach05f49542012-09-18 12:15:26 -070062} __attribute__((packed))bt_bdname_t;
63
64/** Bluetooth Adapter Visibility Modes*/
65typedef enum {
66 BT_SCAN_MODE_NONE,
67 BT_SCAN_MODE_CONNECTABLE,
68 BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
69} bt_scan_mode_t;
70
71/** Bluetooth Adapter State */
72typedef enum {
73 BT_STATE_OFF,
74 BT_STATE_ON
75} bt_state_t;
76
77/** Bluetooth Error Status */
78/** We need to build on this */
79
80typedef enum {
81 BT_STATUS_SUCCESS,
82 BT_STATUS_FAIL,
83 BT_STATUS_NOT_READY,
84 BT_STATUS_NOMEM,
85 BT_STATUS_BUSY,
86 BT_STATUS_DONE, /* request already completed */
87 BT_STATUS_UNSUPPORTED,
88 BT_STATUS_PARM_INVALID,
89 BT_STATUS_UNHANDLED,
90 BT_STATUS_AUTH_FAILURE,
Hemant Gupta4d864552013-07-31 19:14:02 +053091 BT_STATUS_RMT_DEV_DOWN,
92 BT_STATUS_AUTH_REJECTED
Andre Eisenbach05f49542012-09-18 12:15:26 -070093
94} bt_status_t;
95
96/** Bluetooth PinKey Code */
97typedef struct {
98 uint8_t pin[16];
99} __attribute__((packed))bt_pin_code_t;
100
Satya Callojibe7f0442014-07-03 10:59:16 -0700101typedef struct {
102 uint8_t status;
103 uint8_t ctrl_state; /* stack reported state */
104 uint64_t tx_time; /* in ms */
105 uint64_t rx_time; /* in ms */
106 uint64_t idle_time; /* in ms */
107 uint64_t energy_used; /* a product of mA, V and ms */
108} __attribute__((packed))bt_activity_energy_info;
109
Adam Lesinskie2d316d2015-12-03 11:40:47 -0800110typedef struct {
111 int32_t app_uid;
112 uint64_t tx_bytes;
113 uint64_t rx_bytes;
114} __attribute__((packed))bt_uid_traffic_t;
115
Andre Eisenbach05f49542012-09-18 12:15:26 -0700116/** Bluetooth Adapter Discovery state */
117typedef enum {
118 BT_DISCOVERY_STOPPED,
119 BT_DISCOVERY_STARTED
120} bt_discovery_state_t;
121
122/** Bluetooth ACL connection state */
123typedef enum {
124 BT_ACL_STATE_CONNECTED,
125 BT_ACL_STATE_DISCONNECTED
126} bt_acl_state_t;
127
128/** Bluetooth 128-bit UUID */
129typedef struct {
130 uint8_t uu[16];
131} bt_uuid_t;
132
133/** Bluetooth SDP service record */
134typedef struct
135{
136 bt_uuid_t uuid;
137 uint16_t channel;
138 char name[256]; // what's the maximum length
139} bt_service_record_t;
140
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800141
142/** Bluetooth Remote Version info */
143typedef struct
144{
145 int version;
146 int sub_ver;
147 int manufacturer;
148} bt_remote_version_t;
149
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700150typedef struct
151{
Satya Callojia8b49d32015-02-10 09:20:07 -0800152 uint16_t version_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700153 uint8_t local_privacy_enabled;
154 uint8_t max_adv_instance;
155 uint8_t rpa_offload_supported;
156 uint8_t max_irk_list_size;
157 uint8_t max_adv_filter_supported;
Satya Callojibe7f0442014-07-03 10:59:16 -0700158 uint8_t activity_energy_info_supported;
Satya Callojia8b49d32015-02-10 09:20:07 -0800159 uint16_t scan_result_storage_size;
160 uint16_t total_trackable_advertisers;
Satya Calloji51225022015-03-31 13:58:21 -0700161 bool extended_scan_support;
162 bool debug_logging_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700163}bt_local_le_features_t;
164
Andre Eisenbach05f49542012-09-18 12:15:26 -0700165/* Bluetooth Adapter and Remote Device property types */
166typedef enum {
167 /* Properties common to both adapter and remote device */
168 /**
169 * Description - Bluetooth Device Name
170 * Access mode - Adapter name can be GET/SET. Remote device can be GET
171 * Data type - bt_bdname_t
172 */
173 BT_PROPERTY_BDNAME = 0x1,
174 /**
175 * Description - Bluetooth Device Address
176 * Access mode - Only GET.
177 * Data type - bt_bdaddr_t
178 */
179 BT_PROPERTY_BDADDR,
180 /**
181 * Description - Bluetooth Service 128-bit UUIDs
182 * Access mode - Only GET.
183 * Data type - Array of bt_uuid_t (Array size inferred from property length).
184 */
185 BT_PROPERTY_UUIDS,
186 /**
187 * Description - Bluetooth Class of Device as found in Assigned Numbers
188 * Access mode - Only GET.
189 * Data type - uint32_t.
190 */
191 BT_PROPERTY_CLASS_OF_DEVICE,
192 /**
193 * Description - Device Type - BREDR, BLE or DUAL Mode
194 * Access mode - Only GET.
195 * Data type - bt_device_type_t
196 */
197 BT_PROPERTY_TYPE_OF_DEVICE,
198 /**
199 * Description - Bluetooth Service Record
200 * Access mode - Only GET.
201 * Data type - bt_service_record_t
202 */
203 BT_PROPERTY_SERVICE_RECORD,
204
205 /* Properties unique to adapter */
206 /**
207 * Description - Bluetooth Adapter scan mode
208 * Access mode - GET and SET
209 * Data type - bt_scan_mode_t.
210 */
211 BT_PROPERTY_ADAPTER_SCAN_MODE,
212 /**
213 * Description - List of bonded devices
214 * Access mode - Only GET.
215 * Data type - Array of bt_bdaddr_t of the bonded remote devices
216 * (Array size inferred from property length).
217 */
218 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
219 /**
220 * Description - Bluetooth Adapter Discovery timeout (in seconds)
221 * Access mode - GET and SET
222 * Data type - uint32_t
223 */
224 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
225
226 /* Properties unique to remote device */
227 /**
228 * Description - User defined friendly name of the remote device
229 * Access mode - GET and SET
230 * Data type - bt_bdname_t.
231 */
232 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
233 /**
234 * Description - RSSI value of the inquired remote device
235 * Access mode - Only GET.
236 * Data type - int32_t.
237 */
238 BT_PROPERTY_REMOTE_RSSI,
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800239 /**
240 * Description - Remote version info
241 * Access mode - SET/GET.
242 * Data type - bt_remote_version_t.
243 */
244
245 BT_PROPERTY_REMOTE_VERSION_INFO,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700246
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700247 /**
248 * Description - Local LE features
249 * Access mode - GET.
250 * Data type - bt_local_le_features_t.
251 */
252 BT_PROPERTY_LOCAL_LE_FEATURES,
253
Andre Eisenbach05f49542012-09-18 12:15:26 -0700254 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
255} bt_property_type_t;
256
257/** Bluetooth Adapter Property data structure */
258typedef struct
259{
260 bt_property_type_t type;
261 int len;
262 void *val;
263} bt_property_t;
264
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800265/** Bluetooth Out Of Band data for bonding */
266typedef struct
267{
268 uint8_t c192[16]; /* Simple Pairing Hash C-192 */
269 uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
270 uint8_t c256[16]; /* Simple Pairing Hash C-256 */
271 uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
272 uint8_t sm_tk[16]; /* Security Manager TK Value */
273 uint8_t le_sc_c[16]; /* LE Secure Connections Random Value */
274 uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
275} bt_out_of_band_data_t;
276
277
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700278
Andre Eisenbach05f49542012-09-18 12:15:26 -0700279/** Bluetooth Device Type */
280typedef enum {
281 BT_DEVICE_DEVTYPE_BREDR = 0x1,
282 BT_DEVICE_DEVTYPE_BLE,
283 BT_DEVICE_DEVTYPE_DUAL
284} bt_device_type_t;
285/** Bluetooth Bond state */
286typedef enum {
287 BT_BOND_STATE_NONE,
288 BT_BOND_STATE_BONDING,
289 BT_BOND_STATE_BONDED
290} bt_bond_state_t;
291
292/** Bluetooth SSP Bonding Variant */
293typedef enum {
294 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
295 BT_SSP_VARIANT_PASSKEY_ENTRY,
296 BT_SSP_VARIANT_CONSENT,
297 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
298} bt_ssp_variant_t;
299
300#define BT_MAX_NUM_UUIDS 32
301
302/** Bluetooth Interface callbacks */
303
304/** Bluetooth Enable/Disable Callback. */
305typedef void (*adapter_state_changed_callback)(bt_state_t state);
306
307/** GET/SET Adapter Properties callback */
308/* TODO: For the GET/SET property APIs/callbacks, we may need a session
309 * identifier to associate the call with the callback. This would be needed
310 * whenever more than one simultaneous instance of the same adapter_type
311 * is get/set.
312 *
313 * If this is going to be handled in the Java framework, then we do not need
314 * to manage sessions here.
315 */
316typedef void (*adapter_properties_callback)(bt_status_t status,
317 int num_properties,
318 bt_property_t *properties);
319
320/** GET/SET Remote Device Properties callback */
321/** TODO: For remote device properties, do not see a need to get/set
322 * multiple properties - num_properties shall be 1
323 */
324typedef void (*remote_device_properties_callback)(bt_status_t status,
325 bt_bdaddr_t *bd_addr,
326 int num_properties,
327 bt_property_t *properties);
328
329/** New device discovered callback */
330/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
331 * respectively */
332typedef void (*device_found_callback)(int num_properties,
333 bt_property_t *properties);
334
335/** Discovery state changed callback */
336typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
337
338/** Bluetooth Legacy PinKey Request callback */
339typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
Casper Bonde5ccdc512015-05-08 14:33:58 +0200340 bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700341
342/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
343/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
344 * BT_SSP_PAIRING_PASSKEY_ENTRY */
345/* TODO: Passkey request callback shall not be needed for devices with display
346 * capability. We still need support this in the stack for completeness */
347typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
348 bt_bdname_t *bd_name,
349 uint32_t cod,
350 bt_ssp_variant_t pairing_variant,
351 uint32_t pass_key);
352
353/** Bluetooth Bond state changed callback */
354/* Invoked in response to create_bond, cancel_bond or remove_bond */
355typedef void (*bond_state_changed_callback)(bt_status_t status,
356 bt_bdaddr_t *remote_bd_addr,
357 bt_bond_state_t state);
358
359/** Bluetooth ACL connection state changed callback */
360typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
361 bt_acl_state_t state);
362
363typedef enum {
364 ASSOCIATE_JVM,
365 DISASSOCIATE_JVM
366} bt_cb_thread_evt;
367
368/** Thread Associate/Disassociate JVM Callback */
369/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
370 * the JVM */
371typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
372
373/** Bluetooth Test Mode Callback */
374/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
375typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
376
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800377/* LE Test mode callbacks
378* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
379* The num_packets is valid only for le_test_end command */
380typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
Satya Callojibe7f0442014-07-03 10:59:16 -0700381
382/** Callback invoked when energy details are obtained */
383/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
384 * If the ctrl_state value is 0, it means the API call failed
385 * Time values-In milliseconds as returned by the controller
386 * Energy used-Value as returned by the controller
Adam Lesinskie2d316d2015-12-03 11:40:47 -0800387 * Status-Provides the status of the read_energy_info API call
388 * uid_data provides an array of bt_uid_traffic_t, where the array is terminated by an element with
389 * app_uid set to -1.
390 */
391typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info,
392 bt_uid_traffic_t *uid_data);
Satya Callojibe7f0442014-07-03 10:59:16 -0700393
Andre Eisenbach05f49542012-09-18 12:15:26 -0700394/** TODO: Add callbacks for Link Up/Down and other generic
395 * notifications/callbacks */
396
397/** Bluetooth DM callback structure. */
398typedef struct {
399 /** set to sizeof(bt_callbacks_t) */
400 size_t size;
401 adapter_state_changed_callback adapter_state_changed_cb;
402 adapter_properties_callback adapter_properties_cb;
403 remote_device_properties_callback remote_device_properties_cb;
404 device_found_callback device_found_cb;
405 discovery_state_changed_callback discovery_state_changed_cb;
406 pin_request_callback pin_request_cb;
407 ssp_request_callback ssp_request_cb;
408 bond_state_changed_callback bond_state_changed_cb;
409 acl_state_changed_callback acl_state_changed_cb;
410 callback_thread_event thread_evt_cb;
411 dut_mode_recv_callback dut_mode_recv_cb;
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800412 le_test_mode_callback le_test_mode_cb;
Satya Callojibe7f0442014-07-03 10:59:16 -0700413 energy_info_callback energy_info_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700414} bt_callbacks_t;
415
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700416typedef void (*alarm_cb)(void *data);
417typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
418typedef int (*acquire_wake_lock_callout)(const char *lock_name);
419typedef int (*release_wake_lock_callout)(const char *lock_name);
420
421/** The set of functions required by bluedroid to set wake alarms and
422 * grab wake locks. This struct is passed into the stack through the
423 * |set_os_callouts| function on |bt_interface_t|.
424 */
425typedef struct {
426 /* set to sizeof(bt_os_callouts_t) */
427 size_t size;
428
429 set_wake_alarm_callout set_wake_alarm;
430 acquire_wake_lock_callout acquire_wake_lock;
431 release_wake_lock_callout release_wake_lock;
432} bt_os_callouts_t;
433
Andre Eisenbach05f49542012-09-18 12:15:26 -0700434/** NOTE: By default, no profiles are initialized at the time of init/enable.
435 * Whenever the application invokes the 'init' API of a profile, then one of
436 * the following shall occur:
437 *
438 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
439 * profile as enabled. Subsequently, when the application invokes the
440 * Bluetooth 'enable', as part of the enable sequence the profile that were
441 * marked shall be enabled by calling appropriate stack APIs. The
442 * 'adapter_properties_cb' shall return the list of UUIDs of the
443 * enabled profiles.
444 *
445 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
446 * profile API to initialize the profile and trigger a
447 * 'adapter_properties_cb' with the current list of UUIDs including the
448 * newly added profile's UUID.
449 *
450 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
451 */
452
453/** Represents the standard Bluetooth DM interface. */
454typedef struct {
455 /** set to sizeof(bt_interface_t) */
456 size_t size;
457 /**
458 * Opens the interface and provides the callback routines
459 * to the implemenation of this interface.
460 */
461 int (*init)(bt_callbacks_t* callbacks );
462
463 /** Enable Bluetooth. */
464 int (*enable)(void);
465
466 /** Disable Bluetooth. */
467 int (*disable)(void);
468
469 /** Closes the interface. */
470 void (*cleanup)(void);
471
472 /** Get all Bluetooth Adapter properties at init */
473 int (*get_adapter_properties)(void);
474
475 /** Get Bluetooth Adapter property of 'type' */
476 int (*get_adapter_property)(bt_property_type_t type);
477
478 /** Set Bluetooth Adapter property of 'type' */
479 /* Based on the type, val shall be one of
480 * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
481 */
482 int (*set_adapter_property)(const bt_property_t *property);
483
484 /** Get all Remote Device properties */
485 int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
486
487 /** Get Remote Device property of 'type' */
488 int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
489 bt_property_type_t type);
490
491 /** Set Remote Device property of 'type' */
492 int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
493 const bt_property_t *property);
494
495 /** Get Remote Device's service record for the given UUID */
496 int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
497 bt_uuid_t *uuid);
498
499 /** Start SDP to get remote services */
500 int (*get_remote_services)(bt_bdaddr_t *remote_addr);
501
502 /** Start Discovery */
503 int (*start_discovery)(void);
504
505 /** Cancel Discovery */
506 int (*cancel_discovery)(void);
507
508 /** Create Bluetooth Bonding */
Andre Eisenbach01206e52014-08-04 17:22:29 -0700509 int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700510
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800511 /** Create Bluetooth Bond using out of band data */
512 int (*create_bond_out_of_band)(const bt_bdaddr_t *bd_addr, int transport,
513 const bt_out_of_band_data_t *oob_data);
514
Andre Eisenbach05f49542012-09-18 12:15:26 -0700515 /** Remove Bond */
516 int (*remove_bond)(const bt_bdaddr_t *bd_addr);
517
518 /** Cancel Bond */
519 int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
520
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700521 /**
522 * Get the connection status for a given remote device.
523 * return value of 0 means the device is not connected,
524 * non-zero return status indicates an active connection.
525 */
526 int (*get_connection_state)(const bt_bdaddr_t *bd_addr);
527
Andre Eisenbach05f49542012-09-18 12:15:26 -0700528 /** BT Legacy PinKey Reply */
529 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
530 int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
531 uint8_t pin_len, bt_pin_code_t *pin_code);
532
533 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
534 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
535 * BT_SSP_VARIANT_CONSENT
536 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
537 * shall be zero */
538 int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
539 uint8_t accept, uint32_t passkey);
540
541 /** Get Bluetooth profile interface */
542 const void* (*get_profile_interface) (const char *profile_id);
543
544 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
545 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
546 int (*dut_mode_configure)(uint8_t enable);
547
548 /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
549 int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800550 /** BLE Test Mode APIs */
551 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
552 int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
553
Zhihai Xua17b75b2013-06-10 20:23:45 -0700554 /* enable or disable bluetooth HCI snoop log */
555 int (*config_hci_snoop_log)(uint8_t enable);
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700556
557 /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
558 * This should be called immediately after a successful |init|.
559 */
560 int (*set_os_callouts)(bt_os_callouts_t *callouts);
Satya Callojibe7f0442014-07-03 10:59:16 -0700561
562 /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
563 * Success indicates that the VSC command was sent to controller
564 */
565 int (*read_energy_info)();
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800566
567 /**
568 * Native support for dumpsys function
569 * Function is synchronous and |fd| is owned by caller.
Marie Janssen32d45dd2016-01-08 11:16:29 -0800570 * |arguments| are arguments which may affect the output, encoded as
571 * UTF-8 strings.
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800572 */
Marie Janssen32d45dd2016-01-08 11:16:29 -0800573 void (*dump)(int fd, const char **arguments);
Ajay Panickerb3759712015-07-28 16:53:53 -0700574
575 /**
576 * Clear /data/misc/bt_config.conf and erase all stored connections
577 */
578 int (*config_clear)(void);
579
Andre Eisenbach05f49542012-09-18 12:15:26 -0700580} bt_interface_t;
581
582/** TODO: Need to add APIs for Service Discovery, Service authorization and
583 * connection management. Also need to add APIs for configuring
584 * properties of remote bonded devices such as name, UUID etc. */
585
586typedef struct {
587 struct hw_device_t common;
588 const bt_interface_t* (*get_bluetooth_interface)();
589} bluetooth_device_t;
590
591typedef bluetooth_device_t bluetooth_module_t;
kschulz9a92a7b2015-03-06 09:15:43 +0100592
593
Andre Eisenbach05f49542012-09-18 12:15:26 -0700594__END_DECLS
595
596#endif /* ANDROID_INCLUDE_BLUETOOTH_H */