blob: 9fd91cb281283a807bc04165f38fbd22c812672d [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
Jakub Pawlowskibec70c62017-07-05 11:13:00 -070027#include <raw_address.h>
28
Andre Eisenbach05f49542012-09-18 12:15:26 -070029__BEGIN_DECLS
30
31/**
32 * The Bluetooth Hardware Module ID
33 */
34
35#define BT_HARDWARE_MODULE_ID "bluetooth"
36#define BT_STACK_MODULE_ID "bluetooth"
37#define BT_STACK_TEST_MODULE_ID "bluetooth_test"
38
39
Jack He9213f5b2017-05-13 13:54:26 -070040/** Bluetooth profile interface IDs */
Andre Eisenbach05f49542012-09-18 12:15:26 -070041
42#define BT_PROFILE_HANDSFREE_ID "handsfree"
Hemant Guptae7737c82013-08-19 18:02:54 +053043#define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
Andre Eisenbach05f49542012-09-18 12:15:26 -070044#define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
Mike Lockwood21e50b12014-06-07 14:05:22 -070045#define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink"
Andre Eisenbach05f49542012-09-18 12:15:26 -070046#define BT_PROFILE_HEALTH_ID "health"
47#define BT_PROFILE_SOCKETS_ID "socket"
48#define BT_PROFILE_HIDHOST_ID "hidhost"
Hemant Gupta7ed5a7f2014-04-18 12:18:16 +053049#define BT_PROFILE_HIDDEV_ID "hiddev"
Andre Eisenbach05f49542012-09-18 12:15:26 -070050#define BT_PROFILE_PAN_ID "pan"
Hemant Gupta053cccf2014-04-18 12:25:24 +053051#define BT_PROFILE_MAP_CLIENT_ID "map_client"
kschulz9a92a7b2015-03-06 09:15:43 +010052#define BT_PROFILE_SDP_CLIENT_ID "sdp"
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -080053#define BT_PROFILE_GATT_ID "gatt"
Ravi Nagarajan482ba782013-02-26 10:34:41 -080054#define BT_PROFILE_AV_RC_ID "avrcp"
Mike Lockwood7da4cb82014-06-02 16:20:51 -070055#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
Andre Eisenbach05f49542012-09-18 12:15:26 -070056
Jack He9213f5b2017-05-13 13:54:26 -070057/** Bluetooth test interface IDs */
58#define BT_TEST_INTERFACE_MCAP_ID "mcap_test"
59
Andre Eisenbach05f49542012-09-18 12:15:26 -070060/** 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;
Jakub Pawlowski0a660af2017-03-09 18:16:56 -0800166 bool le_2m_phy_supported;
167 bool le_coded_phy_supported;
168 bool le_extended_advertising_supported;
169 bool le_periodic_advertising_supported;
Jakub Pawlowski696f6992017-03-16 18:20:49 -0700170 uint16_t le_maximum_advertising_data_length;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700171}bt_local_le_features_t;
172
Andre Eisenbach05f49542012-09-18 12:15:26 -0700173/* Bluetooth Adapter and Remote Device property types */
174typedef enum {
175 /* Properties common to both adapter and remote device */
176 /**
177 * Description - Bluetooth Device Name
178 * Access mode - Adapter name can be GET/SET. Remote device can be GET
179 * Data type - bt_bdname_t
180 */
181 BT_PROPERTY_BDNAME = 0x1,
182 /**
183 * Description - Bluetooth Device Address
184 * Access mode - Only GET.
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700185 * Data type - RawAddress
Andre Eisenbach05f49542012-09-18 12:15:26 -0700186 */
187 BT_PROPERTY_BDADDR,
188 /**
189 * Description - Bluetooth Service 128-bit UUIDs
190 * Access mode - Only GET.
191 * Data type - Array of bt_uuid_t (Array size inferred from property length).
192 */
193 BT_PROPERTY_UUIDS,
194 /**
195 * Description - Bluetooth Class of Device as found in Assigned Numbers
196 * Access mode - Only GET.
197 * Data type - uint32_t.
198 */
199 BT_PROPERTY_CLASS_OF_DEVICE,
200 /**
201 * Description - Device Type - BREDR, BLE or DUAL Mode
202 * Access mode - Only GET.
203 * Data type - bt_device_type_t
204 */
205 BT_PROPERTY_TYPE_OF_DEVICE,
206 /**
207 * Description - Bluetooth Service Record
208 * Access mode - Only GET.
209 * Data type - bt_service_record_t
210 */
211 BT_PROPERTY_SERVICE_RECORD,
212
213 /* Properties unique to adapter */
214 /**
215 * Description - Bluetooth Adapter scan mode
216 * Access mode - GET and SET
217 * Data type - bt_scan_mode_t.
218 */
219 BT_PROPERTY_ADAPTER_SCAN_MODE,
220 /**
221 * Description - List of bonded devices
222 * Access mode - Only GET.
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700223 * Data type - Array of RawAddress of the bonded remote devices
Andre Eisenbach05f49542012-09-18 12:15:26 -0700224 * (Array size inferred from property length).
225 */
226 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
227 /**
228 * Description - Bluetooth Adapter Discovery timeout (in seconds)
229 * Access mode - GET and SET
230 * Data type - uint32_t
231 */
232 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
233
234 /* Properties unique to remote device */
235 /**
236 * Description - User defined friendly name of the remote device
237 * Access mode - GET and SET
238 * Data type - bt_bdname_t.
239 */
240 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
241 /**
242 * Description - RSSI value of the inquired remote device
243 * Access mode - Only GET.
244 * Data type - int32_t.
245 */
246 BT_PROPERTY_REMOTE_RSSI,
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800247 /**
248 * Description - Remote version info
249 * Access mode - SET/GET.
250 * Data type - bt_remote_version_t.
251 */
252
253 BT_PROPERTY_REMOTE_VERSION_INFO,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700254
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700255 /**
256 * Description - Local LE features
257 * Access mode - GET.
258 * Data type - bt_local_le_features_t.
259 */
260 BT_PROPERTY_LOCAL_LE_FEATURES,
261
Andre Eisenbach05f49542012-09-18 12:15:26 -0700262 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
263} bt_property_type_t;
264
265/** Bluetooth Adapter Property data structure */
266typedef struct
267{
268 bt_property_type_t type;
269 int len;
270 void *val;
271} bt_property_t;
272
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800273/** Bluetooth Out Of Band data for bonding */
274typedef struct
275{
Jakub Pawlowskid82fbad2016-11-09 16:44:30 -0800276 uint8_t le_bt_dev_addr[7]; /* LE Bluetooth Device Address */
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800277 uint8_t c192[16]; /* Simple Pairing Hash C-192 */
278 uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
279 uint8_t c256[16]; /* Simple Pairing Hash C-256 */
280 uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
281 uint8_t sm_tk[16]; /* Security Manager TK Value */
Jakub Pawlowski9caabe12016-07-29 01:37:59 -0700282 uint8_t le_sc_c[16]; /* LE Secure Connections Confirmation Value */
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800283 uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
284} bt_out_of_band_data_t;
285
286
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700287
Andre Eisenbach05f49542012-09-18 12:15:26 -0700288/** Bluetooth Device Type */
289typedef enum {
290 BT_DEVICE_DEVTYPE_BREDR = 0x1,
291 BT_DEVICE_DEVTYPE_BLE,
292 BT_DEVICE_DEVTYPE_DUAL
293} bt_device_type_t;
294/** Bluetooth Bond state */
295typedef enum {
296 BT_BOND_STATE_NONE,
297 BT_BOND_STATE_BONDING,
298 BT_BOND_STATE_BONDED
299} bt_bond_state_t;
300
301/** Bluetooth SSP Bonding Variant */
302typedef enum {
303 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
304 BT_SSP_VARIANT_PASSKEY_ENTRY,
305 BT_SSP_VARIANT_CONSENT,
306 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
307} bt_ssp_variant_t;
308
309#define BT_MAX_NUM_UUIDS 32
310
311/** Bluetooth Interface callbacks */
312
313/** Bluetooth Enable/Disable Callback. */
314typedef void (*adapter_state_changed_callback)(bt_state_t state);
315
316/** GET/SET Adapter Properties callback */
317/* TODO: For the GET/SET property APIs/callbacks, we may need a session
318 * identifier to associate the call with the callback. This would be needed
319 * whenever more than one simultaneous instance of the same adapter_type
320 * is get/set.
321 *
322 * If this is going to be handled in the Java framework, then we do not need
323 * to manage sessions here.
324 */
325typedef void (*adapter_properties_callback)(bt_status_t status,
326 int num_properties,
327 bt_property_t *properties);
328
329/** GET/SET Remote Device Properties callback */
330/** TODO: For remote device properties, do not see a need to get/set
331 * multiple properties - num_properties shall be 1
332 */
333typedef void (*remote_device_properties_callback)(bt_status_t status,
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700334 RawAddress *bd_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700335 int num_properties,
336 bt_property_t *properties);
337
338/** New device discovered callback */
339/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
340 * respectively */
341typedef void (*device_found_callback)(int num_properties,
342 bt_property_t *properties);
343
344/** Discovery state changed callback */
345typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
346
347/** Bluetooth Legacy PinKey Request callback */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700348typedef void (*pin_request_callback)(RawAddress *remote_bd_addr,
Casper Bonde5ccdc512015-05-08 14:33:58 +0200349 bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700350
351/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
352/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
353 * BT_SSP_PAIRING_PASSKEY_ENTRY */
354/* TODO: Passkey request callback shall not be needed for devices with display
355 * capability. We still need support this in the stack for completeness */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700356typedef void (*ssp_request_callback)(RawAddress *remote_bd_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700357 bt_bdname_t *bd_name,
358 uint32_t cod,
359 bt_ssp_variant_t pairing_variant,
360 uint32_t pass_key);
361
362/** Bluetooth Bond state changed callback */
363/* Invoked in response to create_bond, cancel_bond or remove_bond */
364typedef void (*bond_state_changed_callback)(bt_status_t status,
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700365 RawAddress *remote_bd_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700366 bt_bond_state_t state);
367
368/** Bluetooth ACL connection state changed callback */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700369typedef void (*acl_state_changed_callback)(bt_status_t status, RawAddress *remote_bd_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700370 bt_acl_state_t state);
371
372typedef enum {
373 ASSOCIATE_JVM,
374 DISASSOCIATE_JVM
375} bt_cb_thread_evt;
376
377/** Thread Associate/Disassociate JVM Callback */
378/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
379 * the JVM */
380typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
381
382/** Bluetooth Test Mode Callback */
383/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
384typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
385
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800386/* LE Test mode callbacks
387* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
388* The num_packets is valid only for le_test_end command */
389typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
Satya Callojibe7f0442014-07-03 10:59:16 -0700390
391/** Callback invoked when energy details are obtained */
392/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
393 * If the ctrl_state value is 0, it means the API call failed
394 * Time values-In milliseconds as returned by the controller
395 * Energy used-Value as returned by the controller
Adam Lesinskie2d316d2015-12-03 11:40:47 -0800396 * Status-Provides the status of the read_energy_info API call
397 * uid_data provides an array of bt_uid_traffic_t, where the array is terminated by an element with
398 * app_uid set to -1.
399 */
400typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info,
401 bt_uid_traffic_t *uid_data);
Satya Callojibe7f0442014-07-03 10:59:16 -0700402
Andre Eisenbach05f49542012-09-18 12:15:26 -0700403/** TODO: Add callbacks for Link Up/Down and other generic
404 * notifications/callbacks */
405
406/** Bluetooth DM callback structure. */
407typedef struct {
408 /** set to sizeof(bt_callbacks_t) */
409 size_t size;
410 adapter_state_changed_callback adapter_state_changed_cb;
411 adapter_properties_callback adapter_properties_cb;
412 remote_device_properties_callback remote_device_properties_cb;
413 device_found_callback device_found_cb;
414 discovery_state_changed_callback discovery_state_changed_cb;
415 pin_request_callback pin_request_cb;
416 ssp_request_callback ssp_request_cb;
417 bond_state_changed_callback bond_state_changed_cb;
418 acl_state_changed_callback acl_state_changed_cb;
419 callback_thread_event thread_evt_cb;
420 dut_mode_recv_callback dut_mode_recv_cb;
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800421 le_test_mode_callback le_test_mode_cb;
Satya Callojibe7f0442014-07-03 10:59:16 -0700422 energy_info_callback energy_info_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700423} bt_callbacks_t;
424
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700425typedef void (*alarm_cb)(void *data);
426typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
427typedef int (*acquire_wake_lock_callout)(const char *lock_name);
428typedef int (*release_wake_lock_callout)(const char *lock_name);
429
430/** The set of functions required by bluedroid to set wake alarms and
431 * grab wake locks. This struct is passed into the stack through the
432 * |set_os_callouts| function on |bt_interface_t|.
433 */
434typedef struct {
435 /* set to sizeof(bt_os_callouts_t) */
436 size_t size;
437
438 set_wake_alarm_callout set_wake_alarm;
439 acquire_wake_lock_callout acquire_wake_lock;
440 release_wake_lock_callout release_wake_lock;
441} bt_os_callouts_t;
442
Andre Eisenbach05f49542012-09-18 12:15:26 -0700443/** NOTE: By default, no profiles are initialized at the time of init/enable.
444 * Whenever the application invokes the 'init' API of a profile, then one of
445 * the following shall occur:
446 *
447 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
448 * profile as enabled. Subsequently, when the application invokes the
449 * Bluetooth 'enable', as part of the enable sequence the profile that were
450 * marked shall be enabled by calling appropriate stack APIs. The
451 * 'adapter_properties_cb' shall return the list of UUIDs of the
452 * enabled profiles.
453 *
454 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
455 * profile API to initialize the profile and trigger a
456 * 'adapter_properties_cb' with the current list of UUIDs including the
457 * newly added profile's UUID.
458 *
459 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
460 */
461
462/** Represents the standard Bluetooth DM interface. */
463typedef struct {
464 /** set to sizeof(bt_interface_t) */
465 size_t size;
466 /**
467 * Opens the interface and provides the callback routines
468 * to the implemenation of this interface.
469 */
470 int (*init)(bt_callbacks_t* callbacks );
471
472 /** Enable Bluetooth. */
Ajay Panickerd51c01d2016-03-18 14:27:36 -0700473 int (*enable)(bool guest_mode);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700474
475 /** Disable Bluetooth. */
476 int (*disable)(void);
477
478 /** Closes the interface. */
479 void (*cleanup)(void);
480
481 /** Get all Bluetooth Adapter properties at init */
482 int (*get_adapter_properties)(void);
483
484 /** Get Bluetooth Adapter property of 'type' */
485 int (*get_adapter_property)(bt_property_type_t type);
486
487 /** Set Bluetooth Adapter property of 'type' */
488 /* Based on the type, val shall be one of
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700489 * RawAddress or bt_bdname_t or bt_scanmode_t etc
Andre Eisenbach05f49542012-09-18 12:15:26 -0700490 */
491 int (*set_adapter_property)(const bt_property_t *property);
492
493 /** Get all Remote Device properties */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700494 int (*get_remote_device_properties)(RawAddress *remote_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700495
496 /** Get Remote Device property of 'type' */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700497 int (*get_remote_device_property)(RawAddress *remote_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700498 bt_property_type_t type);
499
500 /** Set Remote Device property of 'type' */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700501 int (*set_remote_device_property)(RawAddress *remote_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700502 const bt_property_t *property);
503
504 /** Get Remote Device's service record for the given UUID */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700505 int (*get_remote_service_record)(RawAddress *remote_addr,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700506 bt_uuid_t *uuid);
507
508 /** Start SDP to get remote services */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700509 int (*get_remote_services)(RawAddress *remote_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700510
511 /** Start Discovery */
512 int (*start_discovery)(void);
513
514 /** Cancel Discovery */
515 int (*cancel_discovery)(void);
516
517 /** Create Bluetooth Bonding */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700518 int (*create_bond)(const RawAddress *bd_addr, int transport);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700519
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800520 /** Create Bluetooth Bond using out of band data */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700521 int (*create_bond_out_of_band)(const RawAddress *bd_addr, int transport,
Jakub Pawlowski00202ff2015-12-01 12:06:23 -0800522 const bt_out_of_band_data_t *oob_data);
523
Andre Eisenbach05f49542012-09-18 12:15:26 -0700524 /** Remove Bond */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700525 int (*remove_bond)(const RawAddress *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700526
527 /** Cancel Bond */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700528 int (*cancel_bond)(const RawAddress *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700529
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700530 /**
531 * Get the connection status for a given remote device.
532 * return value of 0 means the device is not connected,
533 * non-zero return status indicates an active connection.
534 */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700535 int (*get_connection_state)(const RawAddress *bd_addr);
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700536
Andre Eisenbach05f49542012-09-18 12:15:26 -0700537 /** BT Legacy PinKey Reply */
538 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700539 int (*pin_reply)(const RawAddress *bd_addr, uint8_t accept,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700540 uint8_t pin_len, bt_pin_code_t *pin_code);
541
542 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
543 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
544 * BT_SSP_VARIANT_CONSENT
545 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
546 * shall be zero */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700547 int (*ssp_reply)(const RawAddress *bd_addr, bt_ssp_variant_t variant,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700548 uint8_t accept, uint32_t passkey);
549
550 /** Get Bluetooth profile interface */
551 const void* (*get_profile_interface) (const char *profile_id);
552
553 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
554 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
555 int (*dut_mode_configure)(uint8_t enable);
556
557 /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
558 int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800559 /** BLE Test Mode APIs */
560 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
561 int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
562
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700563 /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
564 * This should be called immediately after a successful |init|.
565 */
566 int (*set_os_callouts)(bt_os_callouts_t *callouts);
Satya Callojibe7f0442014-07-03 10:59:16 -0700567
568 /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
569 * Success indicates that the VSC command was sent to controller
570 */
571 int (*read_energy_info)();
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800572
573 /**
574 * Native support for dumpsys function
575 * Function is synchronous and |fd| is owned by caller.
Marie Janssen32d45dd2016-01-08 11:16:29 -0800576 * |arguments| are arguments which may affect the output, encoded as
577 * UTF-8 strings.
Andre Eisenbach34ab95a2014-12-05 09:35:57 -0800578 */
Marie Janssen32d45dd2016-01-08 11:16:29 -0800579 void (*dump)(int fd, const char **arguments);
Ajay Panickerb3759712015-07-28 16:53:53 -0700580
581 /**
582 * Clear /data/misc/bt_config.conf and erase all stored connections
583 */
584 int (*config_clear)(void);
585
Andre Eisenbache4109402016-01-14 02:03:36 -0800586 /**
587 * Clear (reset) the dynamic portion of the device interoperability database.
588 */
589 void (*interop_database_clear)(void);
590
591 /**
592 * Add a new device interoperability workaround for a remote device whose
593 * first |len| bytes of the its device address match |addr|.
594 * NOTE: |feature| has to match an item defined in interop_feature_t (interop.h).
595 */
Jakub Pawlowski5a852002017-06-24 17:33:20 -0700596 void (*interop_database_add)(uint16_t feature, const RawAddress *addr, size_t len);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700597} bt_interface_t;
598
599/** TODO: Need to add APIs for Service Discovery, Service authorization and
600 * connection management. Also need to add APIs for configuring
601 * properties of remote bonded devices such as name, UUID etc. */
602
603typedef struct {
604 struct hw_device_t common;
605 const bt_interface_t* (*get_bluetooth_interface)();
606} bluetooth_device_t;
607
608typedef bluetooth_device_t bluetooth_module_t;
kschulz9a92a7b2015-03-06 09:15:43 +0100609
610
Andre Eisenbach05f49542012-09-18 12:15:26 -0700611__END_DECLS
612
613#endif /* ANDROID_INCLUDE_BLUETOOTH_H */