blob: 9870913685aa0b679b17711a9f8ca51ec6f69fd1 [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 Gupta7ed5a7f2014-04-18 12:18:16 +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"
Mike Lockwood7da4cb82014-06-02 16:20:51 -070053#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
Andre Eisenbach05f49542012-09-18 12:15:26 -070054
55/** Bluetooth Address */
56typedef struct {
57 uint8_t address[6];
58} __attribute__((packed))bt_bdaddr_t;
59
60/** Bluetooth Device Name */
61typedef struct {
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -080062 uint8_t name[249];
Andre Eisenbach05f49542012-09-18 12:15:26 -070063} __attribute__((packed))bt_bdname_t;
64
65/** Bluetooth Adapter Visibility Modes*/
66typedef enum {
67 BT_SCAN_MODE_NONE,
68 BT_SCAN_MODE_CONNECTABLE,
69 BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
70} bt_scan_mode_t;
71
72/** Bluetooth Adapter State */
73typedef enum {
74 BT_STATE_OFF,
75 BT_STATE_ON
76} bt_state_t;
77
78/** Bluetooth Error Status */
79/** We need to build on this */
80
81typedef enum {
82 BT_STATUS_SUCCESS,
83 BT_STATUS_FAIL,
84 BT_STATUS_NOT_READY,
85 BT_STATUS_NOMEM,
86 BT_STATUS_BUSY,
87 BT_STATUS_DONE, /* request already completed */
88 BT_STATUS_UNSUPPORTED,
89 BT_STATUS_PARM_INVALID,
90 BT_STATUS_UNHANDLED,
91 BT_STATUS_AUTH_FAILURE,
Hemant Gupta4d864552013-07-31 19:14:02 +053092 BT_STATUS_RMT_DEV_DOWN,
Andre Eisenbachf65d1252016-03-17 16:46:39 -070093 BT_STATUS_AUTH_REJECTED,
94 BT_STATUS_JNI_ENVIRONMENT_ERROR,
95 BT_STATUS_JNI_THREAD_ATTACH_ERROR,
96 BT_STATUS_WAKELOCK_ERROR
Andre Eisenbach05f49542012-09-18 12:15:26 -070097} bt_status_t;
98
99/** Bluetooth PinKey Code */
100typedef struct {
101 uint8_t pin[16];
102} __attribute__((packed))bt_pin_code_t;
103
Satya Callojibe7f0442014-07-03 10:59:16 -0700104typedef struct {
105 uint8_t status;
106 uint8_t ctrl_state; /* stack reported state */
107 uint64_t tx_time; /* in ms */
108 uint64_t rx_time; /* in ms */
109 uint64_t idle_time; /* in ms */
110 uint64_t energy_used; /* a product of mA, V and ms */
111} __attribute__((packed))bt_activity_energy_info;
112
Adam Lesinskie2d316d2015-12-03 11:40:47 -0800113typedef struct {
114 int32_t app_uid;
115 uint64_t tx_bytes;
116 uint64_t rx_bytes;
117} __attribute__((packed))bt_uid_traffic_t;
118
Andre Eisenbach05f49542012-09-18 12:15:26 -0700119/** Bluetooth Adapter Discovery state */
120typedef enum {
121 BT_DISCOVERY_STOPPED,
122 BT_DISCOVERY_STARTED
123} bt_discovery_state_t;
124
125/** Bluetooth ACL connection state */
126typedef enum {
127 BT_ACL_STATE_CONNECTED,
128 BT_ACL_STATE_DISCONNECTED
129} bt_acl_state_t;
130
131/** Bluetooth 128-bit UUID */
132typedef struct {
133 uint8_t uu[16];
134} bt_uuid_t;
135
136/** Bluetooth SDP service record */
137typedef struct
138{
139 bt_uuid_t uuid;
140 uint16_t channel;
141 char name[256]; // what's the maximum length
142} bt_service_record_t;
143
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800144
145/** Bluetooth Remote Version info */
146typedef struct
147{
148 int version;
149 int sub_ver;
150 int manufacturer;
151} bt_remote_version_t;
152
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700153typedef struct
154{
Satya Callojia8b49d32015-02-10 09:20:07 -0800155 uint16_t version_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700156 uint8_t local_privacy_enabled;
157 uint8_t max_adv_instance;
158 uint8_t rpa_offload_supported;
159 uint8_t max_irk_list_size;
160 uint8_t max_adv_filter_supported;
Satya Callojibe7f0442014-07-03 10:59:16 -0700161 uint8_t activity_energy_info_supported;
Satya Callojia8b49d32015-02-10 09:20:07 -0800162 uint16_t scan_result_storage_size;
163 uint16_t total_trackable_advertisers;
Satya Calloji51225022015-03-31 13:58:21 -0700164 bool extended_scan_support;
165 bool debug_logging_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700166}bt_local_le_features_t;
167
Andre Eisenbach05f49542012-09-18 12:15:26 -0700168/* Bluetooth Adapter and Remote Device property types */
169typedef enum {
170 /* Properties common to both adapter and remote device */
171 /**
172 * Description - Bluetooth Device Name
173 * Access mode - Adapter name can be GET/SET. Remote device can be GET
174 * Data type - bt_bdname_t
175 */
176 BT_PROPERTY_BDNAME = 0x1,
177 /**
178 * Description - Bluetooth Device Address
179 * Access mode - Only GET.
180 * Data type - bt_bdaddr_t
181 */
182 BT_PROPERTY_BDADDR,
183 /**
184 * Description - Bluetooth Service 128-bit UUIDs
185 * Access mode - Only GET.
186 * Data type - Array of bt_uuid_t (Array size inferred from property length).
187 */
188 BT_PROPERTY_UUIDS,
189 /**
190 * Description - Bluetooth Class of Device as found in Assigned Numbers
191 * Access mode - Only GET.
192 * Data type - uint32_t.
193 */
194 BT_PROPERTY_CLASS_OF_DEVICE,
195 /**
196 * Description - Device Type - BREDR, BLE or DUAL Mode
197 * Access mode - Only GET.
198 * Data type - bt_device_type_t
199 */
200 BT_PROPERTY_TYPE_OF_DEVICE,
201 /**
202 * Description - Bluetooth Service Record
203 * Access mode - Only GET.
204 * Data type - bt_service_record_t
205 */
206 BT_PROPERTY_SERVICE_RECORD,
207
208 /* Properties unique to adapter */
209 /**
210 * Description - Bluetooth Adapter scan mode
211 * Access mode - GET and SET
212 * Data type - bt_scan_mode_t.
213 */
214 BT_PROPERTY_ADAPTER_SCAN_MODE,
215 /**
216 * Description - List of bonded devices
217 * Access mode - Only GET.
218 * Data type - Array of bt_bdaddr_t of the bonded remote devices
219 * (Array size inferred from property length).
220 */
221 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
222 /**
223 * Description - Bluetooth Adapter Discovery timeout (in seconds)
224 * Access mode - GET and SET
225 * Data type - uint32_t
226 */
227 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
228
229 /* Properties unique to remote device */
230 /**
231 * Description - User defined friendly name of the remote device
232 * Access mode - GET and SET
233 * Data type - bt_bdname_t.
234 */
235 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
236 /**
237 * Description - RSSI value of the inquired remote device
238 * Access mode - Only GET.
239 * Data type - int32_t.
240 */
241 BT_PROPERTY_REMOTE_RSSI,
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800242 /**
243 * Description - Remote version info
244 * Access mode - SET/GET.
245 * Data type - bt_remote_version_t.
246 */
247
248 BT_PROPERTY_REMOTE_VERSION_INFO,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700249
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700250 /**
251 * Description - Local LE features
252 * Access mode - GET.
253 * Data type - bt_local_le_features_t.
254 */
255 BT_PROPERTY_LOCAL_LE_FEATURES,
256
Andre Eisenbach05f49542012-09-18 12:15:26 -0700257 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
258} bt_property_type_t;
259
260/** Bluetooth Adapter Property data structure */
261typedef struct
262{
263 bt_property_type_t type;
264 int len;
265 void *val;
266} bt_property_t;
267
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800268/** Bluetooth Out Of Band data for bonding */
269typedef struct
270{
Jakub Pawlowskid82fbad2016-11-09 16:44:30 -0800271 uint8_t le_bt_dev_addr[7]; /* LE Bluetooth Device Address */
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800272 uint8_t c192[16]; /* Simple Pairing Hash C-192 */
273 uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
274 uint8_t c256[16]; /* Simple Pairing Hash C-256 */
275 uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
276 uint8_t sm_tk[16]; /* Security Manager TK Value */
Jakub Pawlowski9caabe12016-07-29 01:37:59 -0700277 uint8_t le_sc_c[16]; /* LE Secure Connections Confirmation Value */
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800278 uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
279} bt_out_of_band_data_t;
280
281
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700282
Andre Eisenbach05f49542012-09-18 12:15:26 -0700283/** Bluetooth Device Type */
284typedef enum {
285 BT_DEVICE_DEVTYPE_BREDR = 0x1,
286 BT_DEVICE_DEVTYPE_BLE,
287 BT_DEVICE_DEVTYPE_DUAL
288} bt_device_type_t;
289/** Bluetooth Bond state */
290typedef enum {
291 BT_BOND_STATE_NONE,
292 BT_BOND_STATE_BONDING,
293 BT_BOND_STATE_BONDED
294} bt_bond_state_t;
295
296/** Bluetooth SSP Bonding Variant */
297typedef enum {
298 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
299 BT_SSP_VARIANT_PASSKEY_ENTRY,
300 BT_SSP_VARIANT_CONSENT,
301 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
302} bt_ssp_variant_t;
303
304#define BT_MAX_NUM_UUIDS 32
305
306/** Bluetooth Interface callbacks */
307
308/** Bluetooth Enable/Disable Callback. */
309typedef void (*adapter_state_changed_callback)(bt_state_t state);
310
311/** GET/SET Adapter Properties callback */
312/* TODO: For the GET/SET property APIs/callbacks, we may need a session
313 * identifier to associate the call with the callback. This would be needed
314 * whenever more than one simultaneous instance of the same adapter_type
315 * is get/set.
316 *
317 * If this is going to be handled in the Java framework, then we do not need
318 * to manage sessions here.
319 */
320typedef void (*adapter_properties_callback)(bt_status_t status,
321 int num_properties,
322 bt_property_t *properties);
323
324/** GET/SET Remote Device Properties callback */
325/** TODO: For remote device properties, do not see a need to get/set
326 * multiple properties - num_properties shall be 1
327 */
328typedef void (*remote_device_properties_callback)(bt_status_t status,
329 bt_bdaddr_t *bd_addr,
330 int num_properties,
331 bt_property_t *properties);
332
333/** New device discovered callback */
334/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
335 * respectively */
336typedef void (*device_found_callback)(int num_properties,
337 bt_property_t *properties);
338
339/** Discovery state changed callback */
340typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
341
342/** Bluetooth Legacy PinKey Request callback */
343typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
Casper Bonde5ccdc512015-05-08 14:33:58 +0200344 bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700345
346/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
347/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
348 * BT_SSP_PAIRING_PASSKEY_ENTRY */
349/* TODO: Passkey request callback shall not be needed for devices with display
350 * capability. We still need support this in the stack for completeness */
351typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
352 bt_bdname_t *bd_name,
353 uint32_t cod,
354 bt_ssp_variant_t pairing_variant,
355 uint32_t pass_key);
356
357/** Bluetooth Bond state changed callback */
358/* Invoked in response to create_bond, cancel_bond or remove_bond */
359typedef void (*bond_state_changed_callback)(bt_status_t status,
360 bt_bdaddr_t *remote_bd_addr,
361 bt_bond_state_t state);
362
363/** Bluetooth ACL connection state changed callback */
364typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
365 bt_acl_state_t state);
366
367typedef enum {
368 ASSOCIATE_JVM,
369 DISASSOCIATE_JVM
370} bt_cb_thread_evt;
371
372/** Thread Associate/Disassociate JVM Callback */
373/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
374 * the JVM */
375typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
376
377/** Bluetooth Test Mode Callback */
378/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
379typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
380
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800381/* LE Test mode callbacks
382* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
383* The num_packets is valid only for le_test_end command */
384typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
Satya Callojibe7f0442014-07-03 10:59:16 -0700385
386/** Callback invoked when energy details are obtained */
387/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
388 * If the ctrl_state value is 0, it means the API call failed
389 * Time values-In milliseconds as returned by the controller
390 * Energy used-Value as returned by the controller
Adam Lesinskie2d316d2015-12-03 11:40:47 -0800391 * Status-Provides the status of the read_energy_info API call
392 * uid_data provides an array of bt_uid_traffic_t, where the array is terminated by an element with
393 * app_uid set to -1.
394 */
395typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info,
396 bt_uid_traffic_t *uid_data);
Satya Callojibe7f0442014-07-03 10:59:16 -0700397
Andre Eisenbach05f49542012-09-18 12:15:26 -0700398/** TODO: Add callbacks for Link Up/Down and other generic
399 * notifications/callbacks */
400
401/** Bluetooth DM callback structure. */
402typedef struct {
403 /** set to sizeof(bt_callbacks_t) */
404 size_t size;
405 adapter_state_changed_callback adapter_state_changed_cb;
406 adapter_properties_callback adapter_properties_cb;
407 remote_device_properties_callback remote_device_properties_cb;
408 device_found_callback device_found_cb;
409 discovery_state_changed_callback discovery_state_changed_cb;
410 pin_request_callback pin_request_cb;
411 ssp_request_callback ssp_request_cb;
412 bond_state_changed_callback bond_state_changed_cb;
413 acl_state_changed_callback acl_state_changed_cb;
414 callback_thread_event thread_evt_cb;
415 dut_mode_recv_callback dut_mode_recv_cb;
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800416 le_test_mode_callback le_test_mode_cb;
Satya Callojibe7f0442014-07-03 10:59:16 -0700417 energy_info_callback energy_info_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700418} bt_callbacks_t;
419
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700420typedef void (*alarm_cb)(void *data);
421typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
422typedef int (*acquire_wake_lock_callout)(const char *lock_name);
423typedef int (*release_wake_lock_callout)(const char *lock_name);
424
425/** The set of functions required by bluedroid to set wake alarms and
426 * grab wake locks. This struct is passed into the stack through the
427 * |set_os_callouts| function on |bt_interface_t|.
428 */
429typedef struct {
430 /* set to sizeof(bt_os_callouts_t) */
431 size_t size;
432
433 set_wake_alarm_callout set_wake_alarm;
434 acquire_wake_lock_callout acquire_wake_lock;
435 release_wake_lock_callout release_wake_lock;
436} bt_os_callouts_t;
437
Andre Eisenbach05f49542012-09-18 12:15:26 -0700438/** NOTE: By default, no profiles are initialized at the time of init/enable.
439 * Whenever the application invokes the 'init' API of a profile, then one of
440 * the following shall occur:
441 *
442 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
443 * profile as enabled. Subsequently, when the application invokes the
444 * Bluetooth 'enable', as part of the enable sequence the profile that were
445 * marked shall be enabled by calling appropriate stack APIs. The
446 * 'adapter_properties_cb' shall return the list of UUIDs of the
447 * enabled profiles.
448 *
449 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
450 * profile API to initialize the profile and trigger a
451 * 'adapter_properties_cb' with the current list of UUIDs including the
452 * newly added profile's UUID.
453 *
454 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
455 */
456
457/** Represents the standard Bluetooth DM interface. */
458typedef struct {
459 /** set to sizeof(bt_interface_t) */
460 size_t size;
461 /**
462 * Opens the interface and provides the callback routines
463 * to the implemenation of this interface.
464 */
465 int (*init)(bt_callbacks_t* callbacks );
466
467 /** Enable Bluetooth. */
Ajay Panickerd51c01d2016-03-18 14:27:36 -0700468 int (*enable)(bool guest_mode);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700469
470 /** Disable Bluetooth. */
471 int (*disable)(void);
472
473 /** Closes the interface. */
474 void (*cleanup)(void);
475
476 /** Get all Bluetooth Adapter properties at init */
477 int (*get_adapter_properties)(void);
478
479 /** Get Bluetooth Adapter property of 'type' */
480 int (*get_adapter_property)(bt_property_type_t type);
481
482 /** Set Bluetooth Adapter property of 'type' */
483 /* Based on the type, val shall be one of
484 * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
485 */
486 int (*set_adapter_property)(const bt_property_t *property);
487
488 /** Get all Remote Device properties */
489 int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
490
491 /** Get Remote Device property of 'type' */
492 int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
493 bt_property_type_t type);
494
495 /** Set Remote Device property of 'type' */
496 int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
497 const bt_property_t *property);
498
499 /** Get Remote Device's service record for the given UUID */
500 int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
501 bt_uuid_t *uuid);
502
503 /** Start SDP to get remote services */
504 int (*get_remote_services)(bt_bdaddr_t *remote_addr);
505
506 /** Start Discovery */
507 int (*start_discovery)(void);
508
509 /** Cancel Discovery */
510 int (*cancel_discovery)(void);
511
512 /** Create Bluetooth Bonding */
Andre Eisenbach01206e52014-08-04 17:22:29 -0700513 int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700514
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800515 /** Create Bluetooth Bond using out of band data */
516 int (*create_bond_out_of_band)(const bt_bdaddr_t *bd_addr, int transport,
517 const bt_out_of_band_data_t *oob_data);
518
Andre Eisenbach05f49542012-09-18 12:15:26 -0700519 /** Remove Bond */
520 int (*remove_bond)(const bt_bdaddr_t *bd_addr);
521
522 /** Cancel Bond */
523 int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
524
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700525 /**
526 * Get the connection status for a given remote device.
527 * return value of 0 means the device is not connected,
528 * non-zero return status indicates an active connection.
529 */
530 int (*get_connection_state)(const bt_bdaddr_t *bd_addr);
531
Andre Eisenbach05f49542012-09-18 12:15:26 -0700532 /** BT Legacy PinKey Reply */
533 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
534 int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
535 uint8_t pin_len, bt_pin_code_t *pin_code);
536
537 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
538 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
539 * BT_SSP_VARIANT_CONSENT
540 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
541 * shall be zero */
542 int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
543 uint8_t accept, uint32_t passkey);
544
545 /** Get Bluetooth profile interface */
546 const void* (*get_profile_interface) (const char *profile_id);
547
548 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
549 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
550 int (*dut_mode_configure)(uint8_t enable);
551
552 /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
553 int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800554 /** BLE Test Mode APIs */
555 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
556 int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
557
Zhihai Xua17b75b2013-06-10 20:23:45 -0700558 /* enable or disable bluetooth HCI snoop log */
559 int (*config_hci_snoop_log)(uint8_t enable);
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700560
561 /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
562 * This should be called immediately after a successful |init|.
563 */
564 int (*set_os_callouts)(bt_os_callouts_t *callouts);
Satya Callojibe7f0442014-07-03 10:59:16 -0700565
566 /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
567 * Success indicates that the VSC command was sent to controller
568 */
569 int (*read_energy_info)();
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800570
571 /**
572 * Native support for dumpsys function
573 * Function is synchronous and |fd| is owned by caller.
Marie Janssen32d45dd2016-01-08 11:16:29 -0800574 * |arguments| are arguments which may affect the output, encoded as
575 * UTF-8 strings.
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800576 */
Marie Janssen32d45dd2016-01-08 11:16:29 -0800577 void (*dump)(int fd, const char **arguments);
Ajay Panickerb3759712015-07-28 16:53:53 -0700578
579 /**
580 * Clear /data/misc/bt_config.conf and erase all stored connections
581 */
582 int (*config_clear)(void);
583
Andre Eisenbache4109402016-01-14 02:03:36 -0800584 /**
585 * Clear (reset) the dynamic portion of the device interoperability database.
586 */
587 void (*interop_database_clear)(void);
588
589 /**
590 * Add a new device interoperability workaround for a remote device whose
591 * first |len| bytes of the its device address match |addr|.
592 * NOTE: |feature| has to match an item defined in interop_feature_t (interop.h).
593 */
594 void (*interop_database_add)(uint16_t feature, const bt_bdaddr_t *addr, size_t len);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700595} bt_interface_t;
596
597/** TODO: Need to add APIs for Service Discovery, Service authorization and
598 * connection management. Also need to add APIs for configuring
599 * properties of remote bonded devices such as name, UUID etc. */
600
601typedef struct {
602 struct hw_device_t common;
603 const bt_interface_t* (*get_bluetooth_interface)();
604} bluetooth_device_t;
605
606typedef bluetooth_device_t bluetooth_module_t;
kschulz9a92a7b2015-03-06 09:15:43 +0100607
608
Andre Eisenbach05f49542012-09-18 12:15:26 -0700609__END_DECLS
610
611#endif /* ANDROID_INCLUDE_BLUETOOTH_H */