blob: 96edd9fc130a9808f2800aec4b1cdd598004c134 [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
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -070025#include <bluetooth/uuid.h>
Jakub Pawlowskibec70c62017-07-05 11:13:00 -070026#include <raw_address.h>
27
Andre Eisenbach05f49542012-09-18 12:15:26 -070028__BEGIN_DECLS
29
Soumil Shah6122e222017-12-21 19:21:22 -080030/**
31* The Bluetooth Hardware Module ID
32*/
33
Jakub Pawlowski5d5996a2017-10-16 20:10:09 -070034#define BLUETOOTH_INTERFACE_STRING "bluetoothInterface"
Soumil Shah6122e222017-12-21 19:21:22 -080035#define BT_HARDWARE_MODULE_ID "bluetooth"
36#define BT_STACK_MODULE_ID "bluetooth"
37#define BT_STACK_TEST_MODULE_ID "bluetooth_test"
38#define bluetooth_module_t "bluetooth_test"
39
Andre Eisenbach05f49542012-09-18 12:15:26 -070040
Jack He9213f5b2017-05-13 13:54:26 -070041/** Bluetooth profile interface IDs */
Andre Eisenbach05f49542012-09-18 12:15:26 -070042
43#define BT_PROFILE_HANDSFREE_ID "handsfree"
Hemant Guptae7737c82013-08-19 18:02:54 +053044#define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
Andre Eisenbach05f49542012-09-18 12:15:26 -070045#define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
Mike Lockwood21e50b12014-06-07 14:05:22 -070046#define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink"
Andre Eisenbach05f49542012-09-18 12:15:26 -070047#define BT_PROFILE_HEALTH_ID "health"
48#define BT_PROFILE_SOCKETS_ID "socket"
49#define BT_PROFILE_HIDHOST_ID "hidhost"
Hemant Gupta7ed5a7f2014-04-18 12:18:16 +053050#define BT_PROFILE_HIDDEV_ID "hiddev"
Andre Eisenbach05f49542012-09-18 12:15:26 -070051#define BT_PROFILE_PAN_ID "pan"
Hemant Gupta053cccf2014-04-18 12:25:24 +053052#define BT_PROFILE_MAP_CLIENT_ID "map_client"
kschulz9a92a7b2015-03-06 09:15:43 +010053#define BT_PROFILE_SDP_CLIENT_ID "sdp"
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -080054#define BT_PROFILE_GATT_ID "gatt"
Ravi Nagarajan482ba782013-02-26 10:34:41 -080055#define BT_PROFILE_AV_RC_ID "avrcp"
Mike Lockwood7da4cb82014-06-02 16:20:51 -070056#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
Andre Eisenbach05f49542012-09-18 12:15:26 -070057
Jack He9213f5b2017-05-13 13:54:26 -070058/** Bluetooth test interface IDs */
59#define BT_TEST_INTERFACE_MCAP_ID "mcap_test"
60
Andre Eisenbach05f49542012-09-18 12:15:26 -070061/** 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,
Andre Eisenbachf65d1252016-03-17 16:46:39 -070094 BT_STATUS_AUTH_REJECTED,
95 BT_STATUS_JNI_ENVIRONMENT_ERROR,
96 BT_STATUS_JNI_THREAD_ATTACH_ERROR,
97 BT_STATUS_WAKELOCK_ERROR
Andre Eisenbach05f49542012-09-18 12:15:26 -070098} bt_status_t;
99
100/** Bluetooth PinKey Code */
101typedef struct {
102 uint8_t pin[16];
103} __attribute__((packed))bt_pin_code_t;
104
Satya Callojibe7f0442014-07-03 10:59:16 -0700105typedef struct {
106 uint8_t status;
107 uint8_t ctrl_state; /* stack reported state */
108 uint64_t tx_time; /* in ms */
109 uint64_t rx_time; /* in ms */
110 uint64_t idle_time; /* in ms */
111 uint64_t energy_used; /* a product of mA, V and ms */
112} __attribute__((packed))bt_activity_energy_info;
113
Adam Lesinskie2d316d2015-12-03 11:40:47 -0800114typedef struct {
115 int32_t app_uid;
116 uint64_t tx_bytes;
117 uint64_t rx_bytes;
118} __attribute__((packed))bt_uid_traffic_t;
119
Andre Eisenbach05f49542012-09-18 12:15:26 -0700120/** Bluetooth Adapter Discovery state */
121typedef enum {
122 BT_DISCOVERY_STOPPED,
123 BT_DISCOVERY_STARTED
124} bt_discovery_state_t;
125
126/** Bluetooth ACL connection state */
127typedef enum {
128 BT_ACL_STATE_CONNECTED,
129 BT_ACL_STATE_DISCONNECTED
130} bt_acl_state_t;
131
Andre Eisenbach05f49542012-09-18 12:15:26 -0700132/** Bluetooth SDP service record */
133typedef struct
134{
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -0700135 bluetooth::Uuid uuid;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700136 uint16_t channel;
137 char name[256]; // what's the maximum length
138} bt_service_record_t;
139
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800140
141/** Bluetooth Remote Version info */
142typedef struct
143{
144 int version;
145 int sub_ver;
146 int manufacturer;
147} bt_remote_version_t;
148
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700149typedef struct
150{
Satya Callojia8b49d32015-02-10 09:20:07 -0800151 uint16_t version_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700152 uint8_t local_privacy_enabled;
153 uint8_t max_adv_instance;
154 uint8_t rpa_offload_supported;
155 uint8_t max_irk_list_size;
156 uint8_t max_adv_filter_supported;
Satya Callojibe7f0442014-07-03 10:59:16 -0700157 uint8_t activity_energy_info_supported;
Satya Callojia8b49d32015-02-10 09:20:07 -0800158 uint16_t scan_result_storage_size;
159 uint16_t total_trackable_advertisers;
Satya Calloji51225022015-03-31 13:58:21 -0700160 bool extended_scan_support;
161 bool debug_logging_supported;
Jakub Pawlowski0a660af2017-03-09 18:16:56 -0800162 bool le_2m_phy_supported;
163 bool le_coded_phy_supported;
164 bool le_extended_advertising_supported;
165 bool le_periodic_advertising_supported;
Jakub Pawlowski696f6992017-03-16 18:20:49 -0700166 uint16_t le_maximum_advertising_data_length;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700167}bt_local_le_features_t;
168
Andre Eisenbach05f49542012-09-18 12:15:26 -0700169/* Bluetooth Adapter and Remote Device property types */
170typedef enum {
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -0700171 /* Properties common to both adapter and remote device */
172 /**
173 * Description - Bluetooth Device Name
174 * Access mode - Adapter name can be GET/SET. Remote device can be GET
175 * Data type - bt_bdname_t
176 */
177 BT_PROPERTY_BDNAME = 0x1,
178 /**
179 * Description - Bluetooth Device Address
180 * Access mode - Only GET.
181 * Data type - RawAddress
182 */
183 BT_PROPERTY_BDADDR,
184 /**
185 * Description - Bluetooth Service 128-bit UUIDs
186 * Access mode - Only GET.
187 * Data type - Array of bluetooth::Uuid (Array size inferred from property
188 * length).
189 */
190 BT_PROPERTY_UUIDS,
191 /**
192 * Description - Bluetooth Class of Device as found in Assigned Numbers
193 * Access mode - Only GET.
194 * Data type - uint32_t.
195 */
196 BT_PROPERTY_CLASS_OF_DEVICE,
197 /**
198 * Description - Device Type - BREDR, BLE or DUAL Mode
199 * Access mode - Only GET.
200 * Data type - bt_device_type_t
201 */
202 BT_PROPERTY_TYPE_OF_DEVICE,
203 /**
204 * Description - Bluetooth Service Record
205 * Access mode - Only GET.
206 * Data type - bt_service_record_t
207 */
208 BT_PROPERTY_SERVICE_RECORD,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700209
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -0700210 /* Properties unique to adapter */
211 /**
212 * Description - Bluetooth Adapter scan mode
213 * Access mode - GET and SET
214 * Data type - bt_scan_mode_t.
215 */
216 BT_PROPERTY_ADAPTER_SCAN_MODE,
217 /**
218 * Description - List of bonded devices
219 * Access mode - Only GET.
220 * Data type - Array of RawAddress of the bonded remote devices
221 * (Array size inferred from property length).
222 */
223 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
224 /**
225 * Description - Bluetooth Adapter Discovery timeout (in seconds)
226 * Access mode - GET and SET
227 * Data type - uint32_t
228 */
229 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700230
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -0700231 /* Properties unique to remote device */
232 /**
233 * Description - User defined friendly name of the remote device
234 * Access mode - GET and SET
235 * Data type - bt_bdname_t.
236 */
237 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
238 /**
239 * Description - RSSI value of the inquired remote device
240 * Access mode - Only GET.
241 * Data type - int32_t.
242 */
243 BT_PROPERTY_REMOTE_RSSI,
244 /**
245 * Description - Remote version info
246 * Access mode - SET/GET.
247 * Data type - bt_remote_version_t.
248 */
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800249
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -0700250 BT_PROPERTY_REMOTE_VERSION_INFO,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700251
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -0700252 /**
253 * Description - Local LE features
254 * Access mode - GET.
255 * Data type - bt_local_le_features_t.
256 */
257 BT_PROPERTY_LOCAL_LE_FEATURES,
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700258
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -0700259 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700260} bt_property_type_t;
261
262/** Bluetooth Adapter Property data structure */
263typedef struct
264{
265 bt_property_type_t type;
266 int len;
267 void *val;
268} bt_property_t;
269
Martin Brabham63e4dc02021-03-11 12:28:27 -0800270/** Represents the actual Out of Band data itself */
271typedef struct {
272 // Both
273 uint8_t address[7]; /* Bluetooth Device Address (6) plus Address Type (1) */
274 uint8_t c[16]; /* Simple Pairing Hash C-192/256 (Classic or LE) */
275 uint8_t r[16]; /* Simple Pairing Randomizer R-192/256 (Classic or LE) */
276 uint8_t device_name[256]; /* Name of the device */
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800277
Martin Brabham63e4dc02021-03-11 12:28:27 -0800278 // Classic
279 uint8_t oob_data_length[2]; /* Classic only data Length. Value includes this
280 in length */
281 uint8_t class_of_device[2]; /* Class of Device (Classic or LE) */
282
283 // LE
284 uint8_t le_device_role; /* Supported and preferred role of device */
285 uint8_t sm_tk[16]; /* Security Manager TK Value (LE Only) */
286 uint8_t le_flags; /* LE Flags for discoverability and features */
287 uint8_t le_appearance[2]; /* For the appearance of the device */
288} bt_oob_data_t;
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800289
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700290
Andre Eisenbach05f49542012-09-18 12:15:26 -0700291/** Bluetooth Device Type */
292typedef enum {
293 BT_DEVICE_DEVTYPE_BREDR = 0x1,
294 BT_DEVICE_DEVTYPE_BLE,
295 BT_DEVICE_DEVTYPE_DUAL
296} bt_device_type_t;
297/** Bluetooth Bond state */
298typedef enum {
299 BT_BOND_STATE_NONE,
300 BT_BOND_STATE_BONDING,
301 BT_BOND_STATE_BONDED
302} bt_bond_state_t;
303
304/** Bluetooth SSP Bonding Variant */
305typedef enum {
306 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
307 BT_SSP_VARIANT_PASSKEY_ENTRY,
308 BT_SSP_VARIANT_CONSENT,
309 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
310} bt_ssp_variant_t;
311
312#define BT_MAX_NUM_UUIDS 32
313
314/** Bluetooth Interface callbacks */
315
316/** Bluetooth Enable/Disable Callback. */
317typedef void (*adapter_state_changed_callback)(bt_state_t state);
318
319/** GET/SET Adapter Properties callback */
320/* TODO: For the GET/SET property APIs/callbacks, we may need a session
321 * identifier to associate the call with the callback. This would be needed
322 * whenever more than one simultaneous instance of the same adapter_type
323 * is get/set.
324 *
325 * If this is going to be handled in the Java framework, then we do not need
326 * to manage sessions here.
327 */
328typedef void (*adapter_properties_callback)(bt_status_t status,
329 int num_properties,
330 bt_property_t *properties);
331
332/** GET/SET Remote Device Properties callback */
333/** TODO: For remote device properties, do not see a need to get/set
334 * multiple properties - num_properties shall be 1
335 */
336typedef void (*remote_device_properties_callback)(bt_status_t status,
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700337 RawAddress *bd_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700338 int num_properties,
339 bt_property_t *properties);
340
341/** New device discovered callback */
342/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
343 * respectively */
344typedef void (*device_found_callback)(int num_properties,
345 bt_property_t *properties);
346
347/** Discovery state changed callback */
348typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
349
350/** Bluetooth Legacy PinKey Request callback */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700351typedef void (*pin_request_callback)(RawAddress *remote_bd_addr,
Casper Bonde5ccdc512015-05-08 14:33:58 +0200352 bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700353
354/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
355/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
356 * BT_SSP_PAIRING_PASSKEY_ENTRY */
357/* TODO: Passkey request callback shall not be needed for devices with display
358 * capability. We still need support this in the stack for completeness */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700359typedef void (*ssp_request_callback)(RawAddress *remote_bd_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700360 bt_bdname_t *bd_name,
361 uint32_t cod,
362 bt_ssp_variant_t pairing_variant,
363 uint32_t pass_key);
364
365/** Bluetooth Bond state changed callback */
366/* Invoked in response to create_bond, cancel_bond or remove_bond */
367typedef void (*bond_state_changed_callback)(bt_status_t status,
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700368 RawAddress *remote_bd_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700369 bt_bond_state_t state);
370
371/** Bluetooth ACL connection state changed callback */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700372typedef void (*acl_state_changed_callback)(bt_status_t status, RawAddress *remote_bd_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700373 bt_acl_state_t state);
374
375typedef enum {
376 ASSOCIATE_JVM,
377 DISASSOCIATE_JVM
378} bt_cb_thread_evt;
379
380/** Thread Associate/Disassociate JVM Callback */
381/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
382 * the JVM */
383typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
384
385/** Bluetooth Test Mode Callback */
386/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
387typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
388
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800389/* LE Test mode callbacks
390* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
391* The num_packets is valid only for le_test_end command */
392typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
Satya Callojibe7f0442014-07-03 10:59:16 -0700393
394/** Callback invoked when energy details are obtained */
395/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
396 * If the ctrl_state value is 0, it means the API call failed
397 * Time values-In milliseconds as returned by the controller
398 * Energy used-Value as returned by the controller
Adam Lesinskie2d316d2015-12-03 11:40:47 -0800399 * Status-Provides the status of the read_energy_info API call
400 * uid_data provides an array of bt_uid_traffic_t, where the array is terminated by an element with
401 * app_uid set to -1.
402 */
403typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info,
404 bt_uid_traffic_t *uid_data);
Satya Callojibe7f0442014-07-03 10:59:16 -0700405
Andre Eisenbach05f49542012-09-18 12:15:26 -0700406/** TODO: Add callbacks for Link Up/Down and other generic
407 * notifications/callbacks */
408
409/** Bluetooth DM callback structure. */
410typedef struct {
411 /** set to sizeof(bt_callbacks_t) */
412 size_t size;
413 adapter_state_changed_callback adapter_state_changed_cb;
414 adapter_properties_callback adapter_properties_cb;
415 remote_device_properties_callback remote_device_properties_cb;
416 device_found_callback device_found_cb;
417 discovery_state_changed_callback discovery_state_changed_cb;
418 pin_request_callback pin_request_cb;
419 ssp_request_callback ssp_request_cb;
420 bond_state_changed_callback bond_state_changed_cb;
421 acl_state_changed_callback acl_state_changed_cb;
422 callback_thread_event thread_evt_cb;
423 dut_mode_recv_callback dut_mode_recv_cb;
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800424 le_test_mode_callback le_test_mode_cb;
Satya Callojibe7f0442014-07-03 10:59:16 -0700425 energy_info_callback energy_info_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700426} bt_callbacks_t;
427
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700428typedef void (*alarm_cb)(void *data);
429typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
430typedef int (*acquire_wake_lock_callout)(const char *lock_name);
431typedef int (*release_wake_lock_callout)(const char *lock_name);
432
433/** The set of functions required by bluedroid to set wake alarms and
434 * grab wake locks. This struct is passed into the stack through the
435 * |set_os_callouts| function on |bt_interface_t|.
436 */
437typedef struct {
438 /* set to sizeof(bt_os_callouts_t) */
439 size_t size;
440
441 set_wake_alarm_callout set_wake_alarm;
442 acquire_wake_lock_callout acquire_wake_lock;
443 release_wake_lock_callout release_wake_lock;
444} bt_os_callouts_t;
445
Andre Eisenbach05f49542012-09-18 12:15:26 -0700446/** NOTE: By default, no profiles are initialized at the time of init/enable.
447 * Whenever the application invokes the 'init' API of a profile, then one of
448 * the following shall occur:
449 *
450 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
451 * profile as enabled. Subsequently, when the application invokes the
452 * Bluetooth 'enable', as part of the enable sequence the profile that were
453 * marked shall be enabled by calling appropriate stack APIs. The
454 * 'adapter_properties_cb' shall return the list of UUIDs of the
455 * enabled profiles.
456 *
457 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
458 * profile API to initialize the profile and trigger a
459 * 'adapter_properties_cb' with the current list of UUIDs including the
460 * newly added profile's UUID.
461 *
462 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
463 */
464
465/** Represents the standard Bluetooth DM interface. */
466typedef struct {
467 /** set to sizeof(bt_interface_t) */
468 size_t size;
469 /**
470 * Opens the interface and provides the callback routines
471 * to the implemenation of this interface.
Rahul Sabnis247c6462020-08-04 14:17:15 -0700472 * The |is_atv| flag indicates whether the local device is an Android TV
Andre Eisenbach05f49542012-09-18 12:15:26 -0700473 */
Rahul Sabnis247c6462020-08-04 14:17:15 -0700474 int (*init)(bt_callbacks_t* callbacks, bool is_atv);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700475
476 /** Enable Bluetooth. */
Ajay Panickerd51c01d2016-03-18 14:27:36 -0700477 int (*enable)(bool guest_mode);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700478
479 /** Disable Bluetooth. */
480 int (*disable)(void);
481
482 /** Closes the interface. */
483 void (*cleanup)(void);
484
485 /** Get all Bluetooth Adapter properties at init */
486 int (*get_adapter_properties)(void);
487
488 /** Get Bluetooth Adapter property of 'type' */
489 int (*get_adapter_property)(bt_property_type_t type);
490
491 /** Set Bluetooth Adapter property of 'type' */
492 /* Based on the type, val shall be one of
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700493 * RawAddress or bt_bdname_t or bt_scanmode_t etc
Andre Eisenbach05f49542012-09-18 12:15:26 -0700494 */
495 int (*set_adapter_property)(const bt_property_t *property);
496
497 /** Get all Remote Device properties */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700498 int (*get_remote_device_properties)(RawAddress *remote_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700499
500 /** Get Remote Device property of 'type' */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700501 int (*get_remote_device_property)(RawAddress *remote_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700502 bt_property_type_t type);
503
504 /** Set Remote Device property of 'type' */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700505 int (*set_remote_device_property)(RawAddress *remote_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700506 const bt_property_t *property);
507
508 /** Get Remote Device's service record for the given UUID */
Jakub Pawlowskieab6b6e2017-07-11 09:25:44 -0700509 int (*get_remote_service_record)(const RawAddress& remote_addr,
510 const bluetooth::Uuid& uuid);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700511
512 /** Start SDP to get remote services */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700513 int (*get_remote_services)(RawAddress *remote_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700514
515 /** Start Discovery */
516 int (*start_discovery)(void);
517
518 /** Cancel Discovery */
519 int (*cancel_discovery)(void);
520
521 /** Create Bluetooth Bonding */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700522 int (*create_bond)(const RawAddress *bd_addr, int transport);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700523
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800524 /** Create Bluetooth Bond using out of band data */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700525 int (*create_bond_out_of_band)(const RawAddress *bd_addr, int transport,
Martin Brabham63e4dc02021-03-11 12:28:27 -0800526 const bt_oob_data_t *p192_data,
527 const bt_oob_data_t *p256_data);
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800528
Andre Eisenbach05f49542012-09-18 12:15:26 -0700529 /** Remove Bond */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700530 int (*remove_bond)(const RawAddress *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700531
532 /** Cancel Bond */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700533 int (*cancel_bond)(const RawAddress *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700534
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700535 /**
536 * Get the connection status for a given remote device.
537 * return value of 0 means the device is not connected,
538 * non-zero return status indicates an active connection.
539 */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700540 int (*get_connection_state)(const RawAddress *bd_addr);
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700541
Andre Eisenbach05f49542012-09-18 12:15:26 -0700542 /** BT Legacy PinKey Reply */
543 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700544 int (*pin_reply)(const RawAddress *bd_addr, uint8_t accept,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700545 uint8_t pin_len, bt_pin_code_t *pin_code);
546
547 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
548 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
549 * BT_SSP_VARIANT_CONSENT
550 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
551 * shall be zero */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700552 int (*ssp_reply)(const RawAddress *bd_addr, bt_ssp_variant_t variant,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700553 uint8_t accept, uint32_t passkey);
554
555 /** Get Bluetooth profile interface */
556 const void* (*get_profile_interface) (const char *profile_id);
557
558 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
559 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
560 int (*dut_mode_configure)(uint8_t enable);
561
562 /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
563 int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800564 /** BLE Test Mode APIs */
565 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
566 int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
567
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700568 /** 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 Janssen32d45dd2016-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 Janssen32d45dd2016-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 Eisenbache4109402016-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 */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700601 void (*interop_database_add)(uint16_t feature, const RawAddress *addr, size_t len);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700602} bt_interface_t;
603
Andre Eisenbach05f49542012-09-18 12:15:26 -0700604__END_DECLS
605
606#endif /* ANDROID_INCLUDE_BLUETOOTH_H */