blob: 2cba754016c22d12de5b8f9a280c13727e5b247f [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"
Hemant Guptae338c362013-11-11 11:53:48 +053047#define BT_PROFILE_HIDDEV_ID "hiddev"
Andre Eisenbach05f49542012-09-18 12:15:26 -070048#define BT_PROFILE_PAN_ID "pan"
Hemant Gupta053cccf2014-04-18 12:25:24 +053049#define BT_PROFILE_MAP_CLIENT_ID "map_client"
kschulz9a92a7b2015-03-06 09:15:43 +010050#define BT_PROFILE_SDP_CLIENT_ID "sdp"
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -080051#define BT_PROFILE_GATT_ID "gatt"
Ravi Nagarajan482ba782013-02-26 10:34:41 -080052#define BT_PROFILE_AV_RC_ID "avrcp"
Kiran Kelageridee0c782015-07-13 12:12:18 -070053#define WIPOWER_PROFILE_ID "wipower"
Mike Lockwood7da4cb82014-06-02 16:20:51 -070054#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
Andre Eisenbach05f49542012-09-18 12:15:26 -070055
56/** Bluetooth Address */
57typedef struct {
58 uint8_t address[6];
59} __attribute__((packed))bt_bdaddr_t;
60
61/** Bluetooth Device Name */
62typedef struct {
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -080063 uint8_t name[249];
Andre Eisenbach05f49542012-09-18 12:15:26 -070064} __attribute__((packed))bt_bdname_t;
65
66/** Bluetooth Adapter Visibility Modes*/
67typedef enum {
68 BT_SCAN_MODE_NONE,
69 BT_SCAN_MODE_CONNECTABLE,
70 BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
71} bt_scan_mode_t;
72
73/** Bluetooth Adapter State */
74typedef enum {
75 BT_STATE_OFF,
76 BT_STATE_ON
77} bt_state_t;
78
79/** Bluetooth Error Status */
80/** We need to build on this */
81
82typedef enum {
83 BT_STATUS_SUCCESS,
84 BT_STATUS_FAIL,
85 BT_STATUS_NOT_READY,
86 BT_STATUS_NOMEM,
87 BT_STATUS_BUSY,
88 BT_STATUS_DONE, /* request already completed */
89 BT_STATUS_UNSUPPORTED,
90 BT_STATUS_PARM_INVALID,
91 BT_STATUS_UNHANDLED,
92 BT_STATUS_AUTH_FAILURE,
Hemant Gupta4d864552013-07-31 19:14:02 +053093 BT_STATUS_RMT_DEV_DOWN,
94 BT_STATUS_AUTH_REJECTED
Andre Eisenbach05f49542012-09-18 12:15:26 -070095
96} bt_status_t;
97
98/** Bluetooth PinKey Code */
99typedef struct {
100 uint8_t pin[16];
101} __attribute__((packed))bt_pin_code_t;
102
Satya Callojibe7f0442014-07-03 10:59:16 -0700103typedef struct {
104 uint8_t status;
105 uint8_t ctrl_state; /* stack reported state */
106 uint64_t tx_time; /* in ms */
107 uint64_t rx_time; /* in ms */
108 uint64_t idle_time; /* in ms */
109 uint64_t energy_used; /* a product of mA, V and ms */
110} __attribute__((packed))bt_activity_energy_info;
111
Andre Eisenbach05f49542012-09-18 12:15:26 -0700112/** Bluetooth Adapter Discovery state */
113typedef enum {
114 BT_DISCOVERY_STOPPED,
115 BT_DISCOVERY_STARTED
116} bt_discovery_state_t;
117
118/** Bluetooth ACL connection state */
119typedef enum {
120 BT_ACL_STATE_CONNECTED,
121 BT_ACL_STATE_DISCONNECTED
122} bt_acl_state_t;
123
124/** Bluetooth 128-bit UUID */
125typedef struct {
126 uint8_t uu[16];
127} bt_uuid_t;
128
129/** Bluetooth SDP service record */
130typedef struct
131{
132 bt_uuid_t uuid;
133 uint16_t channel;
134 char name[256]; // what's the maximum length
135} bt_service_record_t;
136
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800137
138/** Bluetooth Remote Version info */
139typedef struct
140{
141 int version;
142 int sub_ver;
143 int manufacturer;
144} bt_remote_version_t;
145
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700146typedef struct
147{
Satya Callojia8b49d32015-02-10 09:20:07 -0800148 uint16_t version_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700149 uint8_t local_privacy_enabled;
150 uint8_t max_adv_instance;
151 uint8_t rpa_offload_supported;
152 uint8_t max_irk_list_size;
153 uint8_t max_adv_filter_supported;
Satya Callojibe7f0442014-07-03 10:59:16 -0700154 uint8_t activity_energy_info_supported;
Satya Callojia8b49d32015-02-10 09:20:07 -0800155 uint16_t scan_result_storage_size;
156 uint16_t total_trackable_advertisers;
Satya Calloji51225022015-03-31 13:58:21 -0700157 bool extended_scan_support;
158 bool debug_logging_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700159}bt_local_le_features_t;
160
Andre Eisenbach05f49542012-09-18 12:15:26 -0700161/* Bluetooth Adapter and Remote Device property types */
162typedef enum {
163 /* Properties common to both adapter and remote device */
164 /**
165 * Description - Bluetooth Device Name
166 * Access mode - Adapter name can be GET/SET. Remote device can be GET
167 * Data type - bt_bdname_t
168 */
169 BT_PROPERTY_BDNAME = 0x1,
170 /**
171 * Description - Bluetooth Device Address
172 * Access mode - Only GET.
173 * Data type - bt_bdaddr_t
174 */
175 BT_PROPERTY_BDADDR,
176 /**
177 * Description - Bluetooth Service 128-bit UUIDs
178 * Access mode - Only GET.
179 * Data type - Array of bt_uuid_t (Array size inferred from property length).
180 */
181 BT_PROPERTY_UUIDS,
182 /**
183 * Description - Bluetooth Class of Device as found in Assigned Numbers
184 * Access mode - Only GET.
185 * Data type - uint32_t.
186 */
187 BT_PROPERTY_CLASS_OF_DEVICE,
188 /**
189 * Description - Device Type - BREDR, BLE or DUAL Mode
190 * Access mode - Only GET.
191 * Data type - bt_device_type_t
192 */
193 BT_PROPERTY_TYPE_OF_DEVICE,
194 /**
195 * Description - Bluetooth Service Record
196 * Access mode - Only GET.
197 * Data type - bt_service_record_t
198 */
199 BT_PROPERTY_SERVICE_RECORD,
200
201 /* Properties unique to adapter */
202 /**
203 * Description - Bluetooth Adapter scan mode
204 * Access mode - GET and SET
205 * Data type - bt_scan_mode_t.
206 */
207 BT_PROPERTY_ADAPTER_SCAN_MODE,
208 /**
209 * Description - List of bonded devices
210 * Access mode - Only GET.
211 * Data type - Array of bt_bdaddr_t of the bonded remote devices
212 * (Array size inferred from property length).
213 */
214 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
215 /**
216 * Description - Bluetooth Adapter Discovery timeout (in seconds)
217 * Access mode - GET and SET
218 * Data type - uint32_t
219 */
220 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
221
222 /* Properties unique to remote device */
223 /**
224 * Description - User defined friendly name of the remote device
225 * Access mode - GET and SET
226 * Data type - bt_bdname_t.
227 */
228 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
229 /**
230 * Description - RSSI value of the inquired remote device
231 * Access mode - Only GET.
232 * Data type - int32_t.
233 */
234 BT_PROPERTY_REMOTE_RSSI,
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800235 /**
236 * Description - Remote version info
237 * Access mode - SET/GET.
238 * Data type - bt_remote_version_t.
239 */
240
241 BT_PROPERTY_REMOTE_VERSION_INFO,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700242
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700243 /**
244 * Description - Local LE features
245 * Access mode - GET.
246 * Data type - bt_local_le_features_t.
247 */
248 BT_PROPERTY_LOCAL_LE_FEATURES,
249
Andre Eisenbach05f49542012-09-18 12:15:26 -0700250 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
251} bt_property_type_t;
252
253/** Bluetooth Adapter Property data structure */
254typedef struct
255{
256 bt_property_type_t type;
257 int len;
258 void *val;
259} bt_property_t;
260
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700261
Andre Eisenbach05f49542012-09-18 12:15:26 -0700262/** Bluetooth Device Type */
263typedef enum {
264 BT_DEVICE_DEVTYPE_BREDR = 0x1,
265 BT_DEVICE_DEVTYPE_BLE,
266 BT_DEVICE_DEVTYPE_DUAL
267} bt_device_type_t;
268/** Bluetooth Bond state */
269typedef enum {
270 BT_BOND_STATE_NONE,
271 BT_BOND_STATE_BONDING,
272 BT_BOND_STATE_BONDED
273} bt_bond_state_t;
274
275/** Bluetooth SSP Bonding Variant */
276typedef enum {
277 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
278 BT_SSP_VARIANT_PASSKEY_ENTRY,
279 BT_SSP_VARIANT_CONSENT,
280 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
281} bt_ssp_variant_t;
282
283#define BT_MAX_NUM_UUIDS 32
284
285/** Bluetooth Interface callbacks */
286
287/** Bluetooth Enable/Disable Callback. */
288typedef void (*adapter_state_changed_callback)(bt_state_t state);
289
290/** GET/SET Adapter Properties callback */
291/* TODO: For the GET/SET property APIs/callbacks, we may need a session
292 * identifier to associate the call with the callback. This would be needed
293 * whenever more than one simultaneous instance of the same adapter_type
294 * is get/set.
295 *
296 * If this is going to be handled in the Java framework, then we do not need
297 * to manage sessions here.
298 */
299typedef void (*adapter_properties_callback)(bt_status_t status,
300 int num_properties,
301 bt_property_t *properties);
302
303/** GET/SET Remote Device Properties callback */
304/** TODO: For remote device properties, do not see a need to get/set
305 * multiple properties - num_properties shall be 1
306 */
307typedef void (*remote_device_properties_callback)(bt_status_t status,
308 bt_bdaddr_t *bd_addr,
309 int num_properties,
310 bt_property_t *properties);
311
312/** New device discovered callback */
313/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
314 * respectively */
315typedef void (*device_found_callback)(int num_properties,
316 bt_property_t *properties);
317
318/** Discovery state changed callback */
319typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
320
321/** Bluetooth Legacy PinKey Request callback */
322typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
Casper Bonde5ccdc512015-05-08 14:33:58 +0200323 bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700324
325/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
326/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
327 * BT_SSP_PAIRING_PASSKEY_ENTRY */
328/* TODO: Passkey request callback shall not be needed for devices with display
329 * capability. We still need support this in the stack for completeness */
330typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
331 bt_bdname_t *bd_name,
332 uint32_t cod,
333 bt_ssp_variant_t pairing_variant,
334 uint32_t pass_key);
335
336/** Bluetooth Bond state changed callback */
337/* Invoked in response to create_bond, cancel_bond or remove_bond */
338typedef void (*bond_state_changed_callback)(bt_status_t status,
339 bt_bdaddr_t *remote_bd_addr,
340 bt_bond_state_t state);
341
342/** Bluetooth ACL connection state changed callback */
343typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
344 bt_acl_state_t state);
345
346typedef enum {
347 ASSOCIATE_JVM,
348 DISASSOCIATE_JVM
349} bt_cb_thread_evt;
350
351/** Thread Associate/Disassociate JVM Callback */
352/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
353 * the JVM */
354typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
355
356/** Bluetooth Test Mode Callback */
357/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
358typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
359
Srinu Jellab1746482013-12-06 16:33:53 +0530360/** Bluetooth HCI event Callback */
361/* Receive any HCI event from controller for raw commands */
362typedef void (*hci_event_recv_callback)(uint8_t event_code, uint8_t *buf, uint8_t len);
363
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800364/* LE Test mode callbacks
365* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
366* The num_packets is valid only for le_test_end command */
367typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
Satya Callojibe7f0442014-07-03 10:59:16 -0700368
369/** Callback invoked when energy details are obtained */
370/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
371 * If the ctrl_state value is 0, it means the API call failed
372 * Time values-In milliseconds as returned by the controller
373 * Energy used-Value as returned by the controller
374 * Status-Provides the status of the read_energy_info API call */
375typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info);
376
Andre Eisenbach05f49542012-09-18 12:15:26 -0700377/** TODO: Add callbacks for Link Up/Down and other generic
378 * notifications/callbacks */
379
380/** Bluetooth DM callback structure. */
381typedef struct {
382 /** set to sizeof(bt_callbacks_t) */
383 size_t size;
384 adapter_state_changed_callback adapter_state_changed_cb;
385 adapter_properties_callback adapter_properties_cb;
386 remote_device_properties_callback remote_device_properties_cb;
387 device_found_callback device_found_cb;
388 discovery_state_changed_callback discovery_state_changed_cb;
389 pin_request_callback pin_request_cb;
390 ssp_request_callback ssp_request_cb;
391 bond_state_changed_callback bond_state_changed_cb;
392 acl_state_changed_callback acl_state_changed_cb;
393 callback_thread_event thread_evt_cb;
394 dut_mode_recv_callback dut_mode_recv_cb;
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800395 le_test_mode_callback le_test_mode_cb;
Satya Callojibe7f0442014-07-03 10:59:16 -0700396 energy_info_callback energy_info_cb;
Srinu Jellab1746482013-12-06 16:33:53 +0530397 hci_event_recv_callback hci_event_recv_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700398} bt_callbacks_t;
399
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700400typedef void (*alarm_cb)(void *data);
401typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
402typedef int (*acquire_wake_lock_callout)(const char *lock_name);
403typedef int (*release_wake_lock_callout)(const char *lock_name);
404
405/** The set of functions required by bluedroid to set wake alarms and
406 * grab wake locks. This struct is passed into the stack through the
407 * |set_os_callouts| function on |bt_interface_t|.
408 */
409typedef struct {
410 /* set to sizeof(bt_os_callouts_t) */
411 size_t size;
412
413 set_wake_alarm_callout set_wake_alarm;
414 acquire_wake_lock_callout acquire_wake_lock;
415 release_wake_lock_callout release_wake_lock;
416} bt_os_callouts_t;
417
Andre Eisenbach05f49542012-09-18 12:15:26 -0700418/** NOTE: By default, no profiles are initialized at the time of init/enable.
419 * Whenever the application invokes the 'init' API of a profile, then one of
420 * the following shall occur:
421 *
422 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
423 * profile as enabled. Subsequently, when the application invokes the
424 * Bluetooth 'enable', as part of the enable sequence the profile that were
425 * marked shall be enabled by calling appropriate stack APIs. The
426 * 'adapter_properties_cb' shall return the list of UUIDs of the
427 * enabled profiles.
428 *
429 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
430 * profile API to initialize the profile and trigger a
431 * 'adapter_properties_cb' with the current list of UUIDs including the
432 * newly added profile's UUID.
433 *
434 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
435 */
436
437/** Represents the standard Bluetooth DM interface. */
438typedef struct {
439 /** set to sizeof(bt_interface_t) */
440 size_t size;
441 /**
442 * Opens the interface and provides the callback routines
443 * to the implemenation of this interface.
444 */
445 int (*init)(bt_callbacks_t* callbacks );
446
447 /** Enable Bluetooth. */
Dirk Vogtf003f632017-01-05 14:18:29 +0000448 int (*enable)(void);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700449
450 /** Disable Bluetooth. */
451 int (*disable)(void);
452
453 /** Closes the interface. */
454 void (*cleanup)(void);
455
Kiran Kelageria3b7ebb2015-08-04 16:25:57 -0700456 /** SSR cleanup. */
457 void (*ssrcleanup)(void);
458
Andre Eisenbach05f49542012-09-18 12:15:26 -0700459 /** Get all Bluetooth Adapter properties at init */
460 int (*get_adapter_properties)(void);
461
462 /** Get Bluetooth Adapter property of 'type' */
463 int (*get_adapter_property)(bt_property_type_t type);
464
465 /** Set Bluetooth Adapter property of 'type' */
466 /* Based on the type, val shall be one of
467 * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
468 */
469 int (*set_adapter_property)(const bt_property_t *property);
470
471 /** Get all Remote Device properties */
472 int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
473
474 /** Get Remote Device property of 'type' */
475 int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
476 bt_property_type_t type);
477
478 /** Set Remote Device property of 'type' */
479 int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
480 const bt_property_t *property);
481
482 /** Get Remote Device's service record for the given UUID */
483 int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
484 bt_uuid_t *uuid);
485
486 /** Start SDP to get remote services */
487 int (*get_remote_services)(bt_bdaddr_t *remote_addr);
488
489 /** Start Discovery */
490 int (*start_discovery)(void);
491
492 /** Cancel Discovery */
493 int (*cancel_discovery)(void);
494
495 /** Create Bluetooth Bonding */
Andre Eisenbach01206e52014-08-04 17:22:29 -0700496 int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700497
498 /** Remove Bond */
499 int (*remove_bond)(const bt_bdaddr_t *bd_addr);
500
501 /** Cancel Bond */
502 int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
503
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700504 /**
505 * Get the connection status for a given remote device.
506 * return value of 0 means the device is not connected,
507 * non-zero return status indicates an active connection.
508 */
509 int (*get_connection_state)(const bt_bdaddr_t *bd_addr);
510
Andre Eisenbach05f49542012-09-18 12:15:26 -0700511 /** BT Legacy PinKey Reply */
512 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
513 int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
514 uint8_t pin_len, bt_pin_code_t *pin_code);
515
516 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
517 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
518 * BT_SSP_VARIANT_CONSENT
519 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
520 * shall be zero */
521 int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
522 uint8_t accept, uint32_t passkey);
523
524 /** Get Bluetooth profile interface */
525 const void* (*get_profile_interface) (const char *profile_id);
526
527 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
528 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
529 int (*dut_mode_configure)(uint8_t enable);
530
531 /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
532 int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
Srinu Jellab1746482013-12-06 16:33:53 +0530533
534 /* Send any test HCI command to the controller. */
535 int (*hci_cmd_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
536
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800537 /** BLE Test Mode APIs */
538 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
539 int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
540
Zhihai Xua17b75b2013-06-10 20:23:45 -0700541 /* enable or disable bluetooth HCI snoop log */
542 int (*config_hci_snoop_log)(uint8_t enable);
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700543
544 /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
545 * This should be called immediately after a successful |init|.
546 */
547 int (*set_os_callouts)(bt_os_callouts_t *callouts);
Satya Callojibe7f0442014-07-03 10:59:16 -0700548
549 /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
550 * Success indicates that the VSC command was sent to controller
551 */
552 int (*read_energy_info)();
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800553
554 /**
555 * Native support for dumpsys function
556 * Function is synchronous and |fd| is owned by caller.
557 */
558 void (*dump)(int fd);
Ajay Panickerb3759712015-07-28 16:53:53 -0700559
560 /**
561 * Clear /data/misc/bt_config.conf and erase all stored connections
562 */
563 int (*config_clear)(void);
564
Srinu Jella2bf78392015-04-08 17:09:09 +0530565 /** BT stack Test interface */
566 const void* (*get_testapp_interface)(int test_app_profile);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700567} bt_interface_t;
568
569/** TODO: Need to add APIs for Service Discovery, Service authorization and
570 * connection management. Also need to add APIs for configuring
571 * properties of remote bonded devices such as name, UUID etc. */
572
573typedef struct {
574 struct hw_device_t common;
575 const bt_interface_t* (*get_bluetooth_interface)();
576} bluetooth_device_t;
577
578typedef bluetooth_device_t bluetooth_module_t;
kschulz9a92a7b2015-03-06 09:15:43 +0100579
580
Andre Eisenbach05f49542012-09-18 12:15:26 -0700581__END_DECLS
582
583#endif /* ANDROID_INCLUDE_BLUETOOTH_H */