blob: 5a03cf8b6be063e18da98ffbd293952c9ce93e5f [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,
Andre Eisenbachcbe2d3a2016-03-17 16:46:39 -070092 BT_STATUS_AUTH_REJECTED,
93 BT_STATUS_JNI_ENVIRONMENT_ERROR,
94 BT_STATUS_JNI_THREAD_ATTACH_ERROR,
95 BT_STATUS_WAKELOCK_ERROR
Andre Eisenbach05f49542012-09-18 12:15:26 -070096} 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
Adam Lesinskiaf8db062015-12-03 11:40:47 -0800112typedef struct {
113 int32_t app_uid;
114 uint64_t tx_bytes;
115 uint64_t rx_bytes;
116} __attribute__((packed))bt_uid_traffic_t;
117
Andre Eisenbach05f49542012-09-18 12:15:26 -0700118/** Bluetooth Adapter Discovery state */
119typedef enum {
120 BT_DISCOVERY_STOPPED,
121 BT_DISCOVERY_STARTED
122} bt_discovery_state_t;
123
124/** Bluetooth ACL connection state */
125typedef enum {
126 BT_ACL_STATE_CONNECTED,
127 BT_ACL_STATE_DISCONNECTED
128} bt_acl_state_t;
129
130/** Bluetooth 128-bit UUID */
131typedef struct {
132 uint8_t uu[16];
133} bt_uuid_t;
134
135/** Bluetooth SDP service record */
136typedef struct
137{
138 bt_uuid_t uuid;
139 uint16_t channel;
140 char name[256]; // what's the maximum length
141} bt_service_record_t;
142
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800143
144/** Bluetooth Remote Version info */
145typedef struct
146{
147 int version;
148 int sub_ver;
149 int manufacturer;
150} bt_remote_version_t;
151
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700152typedef struct
153{
Satya Callojia8b49d32015-02-10 09:20:07 -0800154 uint16_t version_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700155 uint8_t local_privacy_enabled;
156 uint8_t max_adv_instance;
157 uint8_t rpa_offload_supported;
158 uint8_t max_irk_list_size;
159 uint8_t max_adv_filter_supported;
Satya Callojibe7f0442014-07-03 10:59:16 -0700160 uint8_t activity_energy_info_supported;
Satya Callojia8b49d32015-02-10 09:20:07 -0800161 uint16_t scan_result_storage_size;
162 uint16_t total_trackable_advertisers;
Satya Calloji51225022015-03-31 13:58:21 -0700163 bool extended_scan_support;
164 bool debug_logging_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700165}bt_local_le_features_t;
166
Andre Eisenbach05f49542012-09-18 12:15:26 -0700167/* Bluetooth Adapter and Remote Device property types */
168typedef enum {
169 /* Properties common to both adapter and remote device */
170 /**
171 * Description - Bluetooth Device Name
172 * Access mode - Adapter name can be GET/SET. Remote device can be GET
173 * Data type - bt_bdname_t
174 */
175 BT_PROPERTY_BDNAME = 0x1,
176 /**
177 * Description - Bluetooth Device Address
178 * Access mode - Only GET.
179 * Data type - bt_bdaddr_t
180 */
181 BT_PROPERTY_BDADDR,
182 /**
183 * Description - Bluetooth Service 128-bit UUIDs
184 * Access mode - Only GET.
185 * Data type - Array of bt_uuid_t (Array size inferred from property length).
186 */
187 BT_PROPERTY_UUIDS,
188 /**
189 * Description - Bluetooth Class of Device as found in Assigned Numbers
190 * Access mode - Only GET.
191 * Data type - uint32_t.
192 */
193 BT_PROPERTY_CLASS_OF_DEVICE,
194 /**
195 * Description - Device Type - BREDR, BLE or DUAL Mode
196 * Access mode - Only GET.
197 * Data type - bt_device_type_t
198 */
199 BT_PROPERTY_TYPE_OF_DEVICE,
200 /**
201 * Description - Bluetooth Service Record
202 * Access mode - Only GET.
203 * Data type - bt_service_record_t
204 */
205 BT_PROPERTY_SERVICE_RECORD,
206
207 /* Properties unique to adapter */
208 /**
209 * Description - Bluetooth Adapter scan mode
210 * Access mode - GET and SET
211 * Data type - bt_scan_mode_t.
212 */
213 BT_PROPERTY_ADAPTER_SCAN_MODE,
214 /**
215 * Description - List of bonded devices
216 * Access mode - Only GET.
217 * Data type - Array of bt_bdaddr_t of the bonded remote devices
218 * (Array size inferred from property length).
219 */
220 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
221 /**
222 * Description - Bluetooth Adapter Discovery timeout (in seconds)
223 * Access mode - GET and SET
224 * Data type - uint32_t
225 */
226 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
227
228 /* Properties unique to remote device */
229 /**
230 * Description - User defined friendly name of the remote device
231 * Access mode - GET and SET
232 * Data type - bt_bdname_t.
233 */
234 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
235 /**
236 * Description - RSSI value of the inquired remote device
237 * Access mode - Only GET.
238 * Data type - int32_t.
239 */
240 BT_PROPERTY_REMOTE_RSSI,
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800241 /**
242 * Description - Remote version info
243 * Access mode - SET/GET.
244 * Data type - bt_remote_version_t.
245 */
246
247 BT_PROPERTY_REMOTE_VERSION_INFO,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700248
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700249 /**
250 * Description - Local LE features
251 * Access mode - GET.
252 * Data type - bt_local_le_features_t.
253 */
254 BT_PROPERTY_LOCAL_LE_FEATURES,
255
Andre Eisenbach05f49542012-09-18 12:15:26 -0700256 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
257} bt_property_type_t;
258
259/** Bluetooth Adapter Property data structure */
260typedef struct
261{
262 bt_property_type_t type;
263 int len;
264 void *val;
265} bt_property_t;
266
Jakub Pawlowski85d3e792015-12-01 12:06:23 -0800267/** Bluetooth Out Of Band data for bonding */
268typedef struct
269{
270 uint8_t c192[16]; /* Simple Pairing Hash C-192 */
271 uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
272 uint8_t c256[16]; /* Simple Pairing Hash C-256 */
273 uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
274 uint8_t sm_tk[16]; /* Security Manager TK Value */
275 uint8_t le_sc_c[16]; /* LE Secure Connections Random Value */
276 uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
277} bt_out_of_band_data_t;
278
279
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700280
Andre Eisenbach05f49542012-09-18 12:15:26 -0700281/** Bluetooth Device Type */
282typedef enum {
283 BT_DEVICE_DEVTYPE_BREDR = 0x1,
284 BT_DEVICE_DEVTYPE_BLE,
285 BT_DEVICE_DEVTYPE_DUAL
286} bt_device_type_t;
287/** Bluetooth Bond state */
288typedef enum {
289 BT_BOND_STATE_NONE,
290 BT_BOND_STATE_BONDING,
291 BT_BOND_STATE_BONDED
292} bt_bond_state_t;
293
294/** Bluetooth SSP Bonding Variant */
295typedef enum {
296 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
297 BT_SSP_VARIANT_PASSKEY_ENTRY,
298 BT_SSP_VARIANT_CONSENT,
299 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
300} bt_ssp_variant_t;
301
302#define BT_MAX_NUM_UUIDS 32
303
304/** Bluetooth Interface callbacks */
305
306/** Bluetooth Enable/Disable Callback. */
307typedef void (*adapter_state_changed_callback)(bt_state_t state);
308
309/** GET/SET Adapter Properties callback */
310/* TODO: For the GET/SET property APIs/callbacks, we may need a session
311 * identifier to associate the call with the callback. This would be needed
312 * whenever more than one simultaneous instance of the same adapter_type
313 * is get/set.
314 *
315 * If this is going to be handled in the Java framework, then we do not need
316 * to manage sessions here.
317 */
318typedef void (*adapter_properties_callback)(bt_status_t status,
319 int num_properties,
320 bt_property_t *properties);
321
322/** GET/SET Remote Device Properties callback */
323/** TODO: For remote device properties, do not see a need to get/set
324 * multiple properties - num_properties shall be 1
325 */
326typedef void (*remote_device_properties_callback)(bt_status_t status,
327 bt_bdaddr_t *bd_addr,
328 int num_properties,
329 bt_property_t *properties);
330
331/** New device discovered callback */
332/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
333 * respectively */
334typedef void (*device_found_callback)(int num_properties,
335 bt_property_t *properties);
336
337/** Discovery state changed callback */
338typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
339
340/** Bluetooth Legacy PinKey Request callback */
341typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
Casper Bonde5ccdc512015-05-08 14:33:58 +0200342 bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700343
344/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
345/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
346 * BT_SSP_PAIRING_PASSKEY_ENTRY */
347/* TODO: Passkey request callback shall not be needed for devices with display
348 * capability. We still need support this in the stack for completeness */
349typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
350 bt_bdname_t *bd_name,
351 uint32_t cod,
352 bt_ssp_variant_t pairing_variant,
353 uint32_t pass_key);
354
355/** Bluetooth Bond state changed callback */
356/* Invoked in response to create_bond, cancel_bond or remove_bond */
357typedef void (*bond_state_changed_callback)(bt_status_t status,
358 bt_bdaddr_t *remote_bd_addr,
359 bt_bond_state_t state);
360
361/** Bluetooth ACL connection state changed callback */
362typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
363 bt_acl_state_t state);
364
365typedef enum {
366 ASSOCIATE_JVM,
367 DISASSOCIATE_JVM
368} bt_cb_thread_evt;
369
370/** Thread Associate/Disassociate JVM Callback */
371/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
372 * the JVM */
373typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
374
375/** Bluetooth Test Mode Callback */
376/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
377typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
378
Srinu Jellad3898222013-12-06 16:33:53 +0530379/** Bluetooth HCI event Callback */
380/* Receive any HCI event from controller for raw commands */
381typedef void (*hci_event_recv_callback)(uint8_t event_code, uint8_t *buf, uint8_t len);
382
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800383/* LE Test mode callbacks
384* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
385* The num_packets is valid only for le_test_end command */
386typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
Satya Callojibe7f0442014-07-03 10:59:16 -0700387
388/** Callback invoked when energy details are obtained */
389/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
390 * If the ctrl_state value is 0, it means the API call failed
391 * Time values-In milliseconds as returned by the controller
392 * Energy used-Value as returned by the controller
Adam Lesinskiaf8db062015-12-03 11:40:47 -0800393 * Status-Provides the status of the read_energy_info API call
394 * uid_data provides an array of bt_uid_traffic_t, where the array is terminated by an element with
395 * app_uid set to -1.
396 */
397typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info,
398 bt_uid_traffic_t *uid_data);
Satya Callojibe7f0442014-07-03 10:59:16 -0700399
Andre Eisenbach05f49542012-09-18 12:15:26 -0700400/** TODO: Add callbacks for Link Up/Down and other generic
401 * notifications/callbacks */
402
403/** Bluetooth DM callback structure. */
404typedef struct {
405 /** set to sizeof(bt_callbacks_t) */
406 size_t size;
407 adapter_state_changed_callback adapter_state_changed_cb;
408 adapter_properties_callback adapter_properties_cb;
409 remote_device_properties_callback remote_device_properties_cb;
410 device_found_callback device_found_cb;
411 discovery_state_changed_callback discovery_state_changed_cb;
412 pin_request_callback pin_request_cb;
413 ssp_request_callback ssp_request_cb;
414 bond_state_changed_callback bond_state_changed_cb;
415 acl_state_changed_callback acl_state_changed_cb;
416 callback_thread_event thread_evt_cb;
417 dut_mode_recv_callback dut_mode_recv_cb;
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800418 le_test_mode_callback le_test_mode_cb;
Satya Callojibe7f0442014-07-03 10:59:16 -0700419 energy_info_callback energy_info_cb;
Srinu Jellad3898222013-12-06 16:33:53 +0530420 hci_event_recv_callback hci_event_recv_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700421} bt_callbacks_t;
422
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700423typedef void (*alarm_cb)(void *data);
424typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
425typedef int (*acquire_wake_lock_callout)(const char *lock_name);
426typedef int (*release_wake_lock_callout)(const char *lock_name);
427
428/** The set of functions required by bluedroid to set wake alarms and
429 * grab wake locks. This struct is passed into the stack through the
430 * |set_os_callouts| function on |bt_interface_t|.
431 */
432typedef struct {
433 /* set to sizeof(bt_os_callouts_t) */
434 size_t size;
435
436 set_wake_alarm_callout set_wake_alarm;
437 acquire_wake_lock_callout acquire_wake_lock;
438 release_wake_lock_callout release_wake_lock;
439} bt_os_callouts_t;
440
Andre Eisenbach05f49542012-09-18 12:15:26 -0700441/** NOTE: By default, no profiles are initialized at the time of init/enable.
442 * Whenever the application invokes the 'init' API of a profile, then one of
443 * the following shall occur:
444 *
445 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
446 * profile as enabled. Subsequently, when the application invokes the
447 * Bluetooth 'enable', as part of the enable sequence the profile that were
448 * marked shall be enabled by calling appropriate stack APIs. The
449 * 'adapter_properties_cb' shall return the list of UUIDs of the
450 * enabled profiles.
451 *
452 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
453 * profile API to initialize the profile and trigger a
454 * 'adapter_properties_cb' with the current list of UUIDs including the
455 * newly added profile's UUID.
456 *
457 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
458 */
459
460/** Represents the standard Bluetooth DM interface. */
461typedef struct {
462 /** set to sizeof(bt_interface_t) */
463 size_t size;
464 /**
465 * Opens the interface and provides the callback routines
466 * to the implemenation of this interface.
467 */
468 int (*init)(bt_callbacks_t* callbacks );
469
470 /** Enable Bluetooth. */
Ajay Panicker6366e232016-03-18 14:27:36 -0700471 int (*enable)(bool guest_mode);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700472
473 /** Disable Bluetooth. */
474 int (*disable)(void);
475
476 /** Closes the interface. */
477 void (*cleanup)(void);
478
479 /** Get all Bluetooth Adapter properties at init */
480 int (*get_adapter_properties)(void);
481
482 /** Get Bluetooth Adapter property of 'type' */
483 int (*get_adapter_property)(bt_property_type_t type);
484
485 /** Set Bluetooth Adapter property of 'type' */
486 /* Based on the type, val shall be one of
487 * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
488 */
489 int (*set_adapter_property)(const bt_property_t *property);
490
491 /** Get all Remote Device properties */
492 int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
493
494 /** Get Remote Device property of 'type' */
495 int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
496 bt_property_type_t type);
497
498 /** Set Remote Device property of 'type' */
499 int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
500 const bt_property_t *property);
501
502 /** Get Remote Device's service record for the given UUID */
503 int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
504 bt_uuid_t *uuid);
505
506 /** Start SDP to get remote services */
507 int (*get_remote_services)(bt_bdaddr_t *remote_addr);
508
509 /** Start Discovery */
510 int (*start_discovery)(void);
511
512 /** Cancel Discovery */
513 int (*cancel_discovery)(void);
514
515 /** Create Bluetooth Bonding */
Andre Eisenbach01206e52014-08-04 17:22:29 -0700516 int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700517
Jakub Pawlowski85d3e792015-12-01 12:06:23 -0800518 /** Create Bluetooth Bond using out of band data */
519 int (*create_bond_out_of_band)(const bt_bdaddr_t *bd_addr, int transport,
520 const bt_out_of_band_data_t *oob_data);
521
Andre Eisenbach05f49542012-09-18 12:15:26 -0700522 /** Remove Bond */
523 int (*remove_bond)(const bt_bdaddr_t *bd_addr);
524
525 /** Cancel Bond */
526 int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
527
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700528 /**
529 * Get the connection status for a given remote device.
530 * return value of 0 means the device is not connected,
531 * non-zero return status indicates an active connection.
532 */
533 int (*get_connection_state)(const bt_bdaddr_t *bd_addr);
534
Andre Eisenbach05f49542012-09-18 12:15:26 -0700535 /** BT Legacy PinKey Reply */
536 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
537 int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
538 uint8_t pin_len, bt_pin_code_t *pin_code);
539
540 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
541 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
542 * BT_SSP_VARIANT_CONSENT
543 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
544 * shall be zero */
545 int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
546 uint8_t accept, uint32_t passkey);
547
548 /** Get Bluetooth profile interface */
549 const void* (*get_profile_interface) (const char *profile_id);
550
551 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
552 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
553 int (*dut_mode_configure)(uint8_t enable);
554
555 /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
556 int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
Srinu Jellad3898222013-12-06 16:33:53 +0530557
558 /* Send any test HCI command to the controller. */
559 int (*hci_cmd_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
560
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800561 /** BLE Test Mode APIs */
562 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
563 int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
564
Zhihai Xua17b75b2013-06-10 20:23:45 -0700565 /* enable or disable bluetooth HCI snoop log */
566 int (*config_hci_snoop_log)(uint8_t enable);
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700567
568 /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
569 * This should be called immediately after a successful |init|.
570 */
571 int (*set_os_callouts)(bt_os_callouts_t *callouts);
Satya Callojibe7f0442014-07-03 10:59:16 -0700572
573 /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
574 * Success indicates that the VSC command was sent to controller
575 */
576 int (*read_energy_info)();
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800577
578 /**
579 * Native support for dumpsys function
580 * Function is synchronous and |fd| is owned by caller.
Marie Janssenaddd3132016-01-08 11:16:29 -0800581 * |arguments| are arguments which may affect the output, encoded as
582 * UTF-8 strings.
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800583 */
Marie Janssenaddd3132016-01-08 11:16:29 -0800584 void (*dump)(int fd, const char **arguments);
Ajay Panickerb3759712015-07-28 16:53:53 -0700585
586 /**
587 * Clear /data/misc/bt_config.conf and erase all stored connections
588 */
589 int (*config_clear)(void);
590
Andre Eisenbachb245a822016-01-14 02:03:36 -0800591 /**
592 * Clear (reset) the dynamic portion of the device interoperability database.
593 */
594 void (*interop_database_clear)(void);
595
596 /**
597 * Add a new device interoperability workaround for a remote device whose
598 * first |len| bytes of the its device address match |addr|.
599 * NOTE: |feature| has to match an item defined in interop_feature_t (interop.h).
600 */
601 void (*interop_database_add)(uint16_t feature, const bt_bdaddr_t *addr, size_t len);
Matadeen Mishrad5fe6382016-05-11 21:21:17 -0700602 /** BT stack Test interface */
603 const void* (*get_testapp_interface)(int test_app_profile);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700604} bt_interface_t;
605
606/** TODO: Need to add APIs for Service Discovery, Service authorization and
607 * connection management. Also need to add APIs for configuring
608 * properties of remote bonded devices such as name, UUID etc. */
609
610typedef struct {
611 struct hw_device_t common;
612 const bt_interface_t* (*get_bluetooth_interface)();
613} bluetooth_device_t;
614
615typedef bluetooth_device_t bluetooth_module_t;
kschulz9a92a7b2015-03-06 09:15:43 +0100616
617
Andre Eisenbach05f49542012-09-18 12:15:26 -0700618__END_DECLS
619
620#endif /* ANDROID_INCLUDE_BLUETOOTH_H */