blob: dd7b8e1195902f84474661d52be128747226f7a5 [file] [log] [blame]
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -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
20#include <stdbool.h>
21#include <stdint.h>
22#include <sys/cdefs.h>
23#include <sys/types.h>
24
25#include <bluetooth/uuid.h>
26#include <raw_address.h>
27
28/**
29 * The Bluetooth Hardware Module ID
30 */
31
32#define BT_HARDWARE_MODULE_ID "bluetooth"
33#define BT_STACK_MODULE_ID "bluetooth"
34
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -070035/** Bluetooth profile interface IDs */
36
37#define BT_PROFILE_HANDSFREE_ID "handsfree"
38#define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
39#define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
40#define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink"
41#define BT_PROFILE_HEALTH_ID "health"
42#define BT_PROFILE_SOCKETS_ID "socket"
43#define BT_PROFILE_HIDHOST_ID "hidhost"
44#define BT_PROFILE_HIDDEV_ID "hiddev"
45#define BT_PROFILE_PAN_ID "pan"
46#define BT_PROFILE_MAP_CLIENT_ID "map_client"
47#define BT_PROFILE_SDP_CLIENT_ID "sdp"
48#define BT_PROFILE_GATT_ID "gatt"
49#define BT_PROFILE_AV_RC_ID "avrcp"
50#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
51
52/** Bluetooth test interface IDs */
53#define BT_TEST_INTERFACE_MCAP_ID "mcap_test"
54
55/** Bluetooth Device Name */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -070056typedef struct { uint8_t name[249]; } __attribute__((packed)) bt_bdname_t;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -070057
58/** Bluetooth Adapter Visibility Modes*/
59typedef enum {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -070060 BT_SCAN_MODE_NONE,
61 BT_SCAN_MODE_CONNECTABLE,
62 BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -070063} bt_scan_mode_t;
64
65/** Bluetooth Adapter State */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -070066typedef enum { BT_STATE_OFF, BT_STATE_ON } bt_state_t;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -070067
68/** Bluetooth Error Status */
69/** We need to build on this */
70
71typedef enum {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -070072 BT_STATUS_SUCCESS,
73 BT_STATUS_FAIL,
74 BT_STATUS_NOT_READY,
75 BT_STATUS_NOMEM,
76 BT_STATUS_BUSY,
77 BT_STATUS_DONE, /* request already completed */
78 BT_STATUS_UNSUPPORTED,
79 BT_STATUS_PARM_INVALID,
80 BT_STATUS_UNHANDLED,
81 BT_STATUS_AUTH_FAILURE,
82 BT_STATUS_RMT_DEV_DOWN,
83 BT_STATUS_AUTH_REJECTED,
84 BT_STATUS_JNI_ENVIRONMENT_ERROR,
85 BT_STATUS_JNI_THREAD_ATTACH_ERROR,
86 BT_STATUS_WAKELOCK_ERROR
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -070087} bt_status_t;
88
89/** Bluetooth PinKey Code */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -070090typedef struct { uint8_t pin[16]; } __attribute__((packed)) bt_pin_code_t;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -070091
92typedef struct {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -070093 uint8_t status;
94 uint8_t ctrl_state; /* stack reported state */
95 uint64_t tx_time; /* in ms */
96 uint64_t rx_time; /* in ms */
97 uint64_t idle_time; /* in ms */
98 uint64_t energy_used; /* a product of mA, V and ms */
99} __attribute__((packed)) bt_activity_energy_info;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700100
101typedef struct {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700102 int32_t app_uid;
103 uint64_t tx_bytes;
104 uint64_t rx_bytes;
105} __attribute__((packed)) bt_uid_traffic_t;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700106
107/** Bluetooth Adapter Discovery state */
108typedef enum {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700109 BT_DISCOVERY_STOPPED,
110 BT_DISCOVERY_STARTED
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700111} bt_discovery_state_t;
112
113/** Bluetooth ACL connection state */
114typedef enum {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700115 BT_ACL_STATE_CONNECTED,
116 BT_ACL_STATE_DISCONNECTED
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700117} bt_acl_state_t;
118
119/** Bluetooth SDP service record */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700120typedef struct {
121 bluetooth::Uuid uuid;
122 uint16_t channel;
123 char name[256]; // what's the maximum length
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700124} bt_service_record_t;
125
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700126/** Bluetooth Remote Version info */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700127typedef struct {
128 int version;
129 int sub_ver;
130 int manufacturer;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700131} bt_remote_version_t;
132
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700133typedef struct {
134 uint16_t version_supported;
135 uint8_t local_privacy_enabled;
136 uint8_t max_adv_instance;
137 uint8_t rpa_offload_supported;
138 uint8_t max_irk_list_size;
139 uint8_t max_adv_filter_supported;
140 uint8_t activity_energy_info_supported;
141 uint16_t scan_result_storage_size;
142 uint16_t total_trackable_advertisers;
143 bool extended_scan_support;
144 bool debug_logging_supported;
145 bool le_2m_phy_supported;
146 bool le_coded_phy_supported;
147 bool le_extended_advertising_supported;
148 bool le_periodic_advertising_supported;
149 uint16_t le_maximum_advertising_data_length;
150} bt_local_le_features_t;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700151
152/* Bluetooth Adapter and Remote Device property types */
153typedef enum {
154 /* Properties common to both adapter and remote device */
155 /**
156 * Description - Bluetooth Device Name
157 * Access mode - Adapter name can be GET/SET. Remote device can be GET
158 * Data type - bt_bdname_t
159 */
160 BT_PROPERTY_BDNAME = 0x1,
161 /**
162 * Description - Bluetooth Device Address
163 * Access mode - Only GET.
164 * Data type - RawAddress
165 */
166 BT_PROPERTY_BDADDR,
167 /**
168 * Description - Bluetooth Service 128-bit UUIDs
169 * Access mode - Only GET.
170 * Data type - Array of bluetooth::Uuid (Array size inferred from property
171 * length).
172 */
173 BT_PROPERTY_UUIDS,
174 /**
175 * Description - Bluetooth Class of Device as found in Assigned Numbers
176 * Access mode - Only GET.
177 * Data type - uint32_t.
178 */
179 BT_PROPERTY_CLASS_OF_DEVICE,
180 /**
181 * Description - Device Type - BREDR, BLE or DUAL Mode
182 * Access mode - Only GET.
183 * Data type - bt_device_type_t
184 */
185 BT_PROPERTY_TYPE_OF_DEVICE,
186 /**
187 * Description - Bluetooth Service Record
188 * Access mode - Only GET.
189 * Data type - bt_service_record_t
190 */
191 BT_PROPERTY_SERVICE_RECORD,
192
193 /* Properties unique to adapter */
194 /**
195 * Description - Bluetooth Adapter scan mode
196 * Access mode - GET and SET
197 * Data type - bt_scan_mode_t.
198 */
199 BT_PROPERTY_ADAPTER_SCAN_MODE,
200 /**
201 * Description - List of bonded devices
202 * Access mode - Only GET.
203 * Data type - Array of RawAddress of the bonded remote devices
204 * (Array size inferred from property length).
205 */
206 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
207 /**
208 * Description - Bluetooth Adapter Discovery timeout (in seconds)
209 * Access mode - GET and SET
210 * Data type - uint32_t
211 */
212 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
213
214 /* Properties unique to remote device */
215 /**
216 * Description - User defined friendly name of the remote device
217 * Access mode - GET and SET
218 * Data type - bt_bdname_t.
219 */
220 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
221 /**
222 * Description - RSSI value of the inquired remote device
223 * Access mode - Only GET.
Tiansong Cui1dee3a52017-10-27 14:24:15 -0700224 * Data type - int8_t.
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700225 */
226 BT_PROPERTY_REMOTE_RSSI,
227 /**
228 * Description - Remote version info
229 * Access mode - SET/GET.
230 * Data type - bt_remote_version_t.
231 */
232
233 BT_PROPERTY_REMOTE_VERSION_INFO,
234
235 /**
236 * Description - Local LE features
237 * Access mode - GET.
238 * Data type - bt_local_le_features_t.
239 */
240 BT_PROPERTY_LOCAL_LE_FEATURES,
241
242 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
243} bt_property_type_t;
244
245/** Bluetooth Adapter Property data structure */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700246typedef struct {
247 bt_property_type_t type;
248 int len;
249 void* val;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700250} bt_property_t;
251
252/** Bluetooth Out Of Band data for bonding */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700253typedef struct {
254 uint8_t le_bt_dev_addr[7]; /* LE Bluetooth Device Address */
255 uint8_t c192[16]; /* Simple Pairing Hash C-192 */
256 uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */
257 uint8_t c256[16]; /* Simple Pairing Hash C-256 */
258 uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */
259 uint8_t sm_tk[16]; /* Security Manager TK Value */
260 uint8_t le_sc_c[16]; /* LE Secure Connections Confirmation Value */
261 uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700262} bt_out_of_band_data_t;
263
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700264/** Bluetooth Device Type */
265typedef enum {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700266 BT_DEVICE_DEVTYPE_BREDR = 0x1,
267 BT_DEVICE_DEVTYPE_BLE,
268 BT_DEVICE_DEVTYPE_DUAL
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700269} bt_device_type_t;
270/** Bluetooth Bond state */
271typedef enum {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700272 BT_BOND_STATE_NONE,
273 BT_BOND_STATE_BONDING,
274 BT_BOND_STATE_BONDED
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700275} bt_bond_state_t;
276
277/** Bluetooth SSP Bonding Variant */
278typedef enum {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700279 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
280 BT_SSP_VARIANT_PASSKEY_ENTRY,
281 BT_SSP_VARIANT_CONSENT,
282 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700283} bt_ssp_variant_t;
284
285#define BT_MAX_NUM_UUIDS 32
286
287/** Bluetooth Interface callbacks */
288
289/** Bluetooth Enable/Disable Callback. */
290typedef void (*adapter_state_changed_callback)(bt_state_t state);
291
292/** GET/SET Adapter Properties callback */
293/* TODO: For the GET/SET property APIs/callbacks, we may need a session
294 * identifier to associate the call with the callback. This would be needed
295 * whenever more than one simultaneous instance of the same adapter_type
296 * is get/set.
297 *
298 * If this is going to be handled in the Java framework, then we do not need
299 * to manage sessions here.
300 */
301typedef void (*adapter_properties_callback)(bt_status_t status,
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700302 int num_properties,
303 bt_property_t* properties);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700304
305/** GET/SET Remote Device Properties callback */
306/** TODO: For remote device properties, do not see a need to get/set
307 * multiple properties - num_properties shall be 1
308 */
309typedef void (*remote_device_properties_callback)(bt_status_t status,
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700310 RawAddress* bd_addr,
311 int num_properties,
312 bt_property_t* properties);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700313
314/** New device discovered callback */
315/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
316 * respectively */
317typedef void (*device_found_callback)(int num_properties,
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700318 bt_property_t* properties);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700319
320/** Discovery state changed callback */
321typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
322
323/** Bluetooth Legacy PinKey Request callback */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700324typedef void (*pin_request_callback)(RawAddress* remote_bd_addr,
325 bt_bdname_t* bd_name, uint32_t cod,
326 bool min_16_digit);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700327
328/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
329/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
330 * BT_SSP_PAIRING_PASSKEY_ENTRY */
331/* TODO: Passkey request callback shall not be needed for devices with display
332 * capability. We still need support this in the stack for completeness */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700333typedef void (*ssp_request_callback)(RawAddress* remote_bd_addr,
334 bt_bdname_t* bd_name, uint32_t cod,
335 bt_ssp_variant_t pairing_variant,
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700336 uint32_t pass_key);
337
338/** Bluetooth Bond state changed callback */
339/* Invoked in response to create_bond, cancel_bond or remove_bond */
340typedef void (*bond_state_changed_callback)(bt_status_t status,
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700341 RawAddress* remote_bd_addr,
342 bt_bond_state_t state);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700343
344/** Bluetooth ACL connection state changed callback */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700345typedef void (*acl_state_changed_callback)(bt_status_t status,
346 RawAddress* remote_bd_addr,
347 bt_acl_state_t state);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700348
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700349typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM } bt_cb_thread_evt;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700350
351/** Thread Associate/Disassociate JVM Callback */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700352/* Callback that is invoked by the callback thread to allow upper layer to
353 * attach/detach to/from the JVM */
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700354typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
355
356/** Bluetooth Test Mode Callback */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700357/* Receive any HCI event from controller. Must be in DUT Mode for this callback
358 * to be received */
359typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t* buf,
360 uint8_t len);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700361
362/* LE Test mode callbacks
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700363 * This callback shall be invoked whenever the le_tx_test, le_rx_test or
364 * le_test_end is invoked The num_packets is valid only for le_test_end command
365 */
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700366typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
367
368/** Callback invoked when energy details are obtained */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700369/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as
370 * defined by HCI spec. If the ctrl_state value is 0, it means the API call
371 * failed Time values-In milliseconds as returned by the controller Energy
372 * used-Value as returned by the controller Status-Provides the status of the
373 * read_energy_info API call uid_data provides an array of bt_uid_traffic_t,
374 * where the array is terminated by an element with app_uid set to -1.
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700375 */
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700376typedef void (*energy_info_callback)(bt_activity_energy_info* energy_info,
377 bt_uid_traffic_t* uid_data);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700378
379/** TODO: Add callbacks for Link Up/Down and other generic
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700380 * notifications/callbacks */
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700381
382/** Bluetooth DM callback structure. */
383typedef struct {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700384 /** set to sizeof(bt_callbacks_t) */
385 size_t size;
386 adapter_state_changed_callback adapter_state_changed_cb;
387 adapter_properties_callback adapter_properties_cb;
388 remote_device_properties_callback remote_device_properties_cb;
389 device_found_callback device_found_cb;
390 discovery_state_changed_callback discovery_state_changed_cb;
391 pin_request_callback pin_request_cb;
392 ssp_request_callback ssp_request_cb;
393 bond_state_changed_callback bond_state_changed_cb;
394 acl_state_changed_callback acl_state_changed_cb;
395 callback_thread_event thread_evt_cb;
396 dut_mode_recv_callback dut_mode_recv_cb;
397 le_test_mode_callback le_test_mode_cb;
398 energy_info_callback energy_info_cb;
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700399} bt_callbacks_t;
400
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700401typedef void (*alarm_cb)(void* data);
402typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake,
403 alarm_cb cb, void* data);
404typedef int (*acquire_wake_lock_callout)(const char* lock_name);
405typedef int (*release_wake_lock_callout)(const char* lock_name);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700406
407/** The set of functions required by bluedroid to set wake alarms and
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700408 * grab wake locks. This struct is passed into the stack through the
409 * |set_os_callouts| function on |bt_interface_t|.
410 */
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700411typedef struct {
412 /* set to sizeof(bt_os_callouts_t) */
413 size_t size;
414
415 set_wake_alarm_callout set_wake_alarm;
416 acquire_wake_lock_callout acquire_wake_lock;
417 release_wake_lock_callout release_wake_lock;
418} bt_os_callouts_t;
419
420/** NOTE: By default, no profiles are initialized at the time of init/enable.
421 * Whenever the application invokes the 'init' API of a profile, then one of
422 * the following shall occur:
423 *
424 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
425 * profile as enabled. Subsequently, when the application invokes the
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700426 * Bluetooth 'enable', as part of the enable sequence the profile that
427 * were marked shall be enabled by calling appropriate stack APIs. The
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700428 * 'adapter_properties_cb' shall return the list of UUIDs of the
429 * enabled profiles.
430 *
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700431 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the
432 * stack profile API to initialize the profile and trigger a
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700433 * 'adapter_properties_cb' with the current list of UUIDs including the
434 * newly added profile's UUID.
435 *
436 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
437 */
438
439/** Represents the standard Bluetooth DM interface. */
440typedef struct {
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700441 /** set to sizeof(bt_interface_t) */
442 size_t size;
443 /**
444 * Opens the interface and provides the callback routines
445 * to the implemenation of this interface.
446 */
447 int (*init)(bt_callbacks_t* callbacks);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700448
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700449 /** Enable Bluetooth. */
450 int (*enable)(bool guest_mode);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700451
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700452 /** Disable Bluetooth. */
453 int (*disable)(void);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700454
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700455 /** Closes the interface. */
456 void (*cleanup)(void);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700457
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700458 /** Get all Bluetooth Adapter properties at init */
459 int (*get_adapter_properties)(void);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700460
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700461 /** Get Bluetooth Adapter property of 'type' */
462 int (*get_adapter_property)(bt_property_type_t type);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700463
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700464 /** Set Bluetooth Adapter property of 'type' */
465 /* Based on the type, val shall be one of
466 * RawAddress or bt_bdname_t or bt_scanmode_t etc
467 */
468 int (*set_adapter_property)(const bt_property_t* property);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700469
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700470 /** Get all Remote Device properties */
471 int (*get_remote_device_properties)(RawAddress* remote_addr);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700472
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700473 /** Get Remote Device property of 'type' */
474 int (*get_remote_device_property)(RawAddress* remote_addr,
475 bt_property_type_t type);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700476
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700477 /** Set Remote Device property of 'type' */
478 int (*set_remote_device_property)(RawAddress* remote_addr,
479 const bt_property_t* property);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700480
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700481 /** Get Remote Device's service record for the given UUID */
482 int (*get_remote_service_record)(const RawAddress& remote_addr,
483 const bluetooth::Uuid& uuid);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700484
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700485 /** Start SDP to get remote services */
486 int (*get_remote_services)(RawAddress* remote_addr);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700487
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700488 /** Start Discovery */
489 int (*start_discovery)(void);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700490
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700491 /** Cancel Discovery */
492 int (*cancel_discovery)(void);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700493
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700494 /** Create Bluetooth Bonding */
495 int (*create_bond)(const RawAddress* bd_addr, int transport);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700496
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700497 /** Create Bluetooth Bond using out of band data */
498 int (*create_bond_out_of_band)(const RawAddress* bd_addr, int transport,
499 const bt_out_of_band_data_t* oob_data);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700500
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700501 /** Remove Bond */
502 int (*remove_bond)(const RawAddress* bd_addr);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700503
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700504 /** Cancel Bond */
505 int (*cancel_bond)(const RawAddress* bd_addr);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700506
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700507 /**
508 * Get the connection status for a given remote device.
509 * return value of 0 means the device is not connected,
510 * non-zero return status indicates an active connection.
511 */
512 int (*get_connection_state)(const RawAddress* bd_addr);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700513
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700514 /** BT Legacy PinKey Reply */
515 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
516 int (*pin_reply)(const RawAddress* bd_addr, uint8_t accept, uint8_t pin_len,
517 bt_pin_code_t* pin_code);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700518
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700519 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
520 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
521 * BT_SSP_VARIANT_CONSENT
522 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
523 * shall be zero */
524 int (*ssp_reply)(const RawAddress* bd_addr, bt_ssp_variant_t variant,
525 uint8_t accept, uint32_t passkey);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700526
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700527 /** Get Bluetooth profile interface */
528 const void* (*get_profile_interface)(const char* profile_id);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700529
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700530 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
531 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
532 int (*dut_mode_configure)(uint8_t enable);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700533
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700534 /* Send any test HCI (vendor-specific) command to the controller. Must be in
535 * DUT Mode */
536 int (*dut_mode_send)(uint16_t opcode, uint8_t* buf, uint8_t len);
537 /** BLE Test Mode APIs */
538 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End
539 */
540 int (*le_test_mode)(uint16_t opcode, uint8_t* buf, uint8_t len);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700541
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700542 /** Sets the OS call-out functions that bluedroid needs for alarms and wake
543 * locks. This should be called immediately after a successful |init|.
544 */
545 int (*set_os_callouts)(bt_os_callouts_t* callouts);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700546
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700547 /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or
548 * BT_STATUS_NOT_READY Success indicates that the VSC command was sent to
549 * controller
550 */
551 int (*read_energy_info)();
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700552
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700553 /**
554 * Native support for dumpsys function
555 * Function is synchronous and |fd| is owned by caller.
556 * |arguments| are arguments which may affect the output, encoded as
557 * UTF-8 strings.
558 */
559 void (*dump)(int fd, const char** arguments);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700560
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700561 /**
Jack He9af00782018-01-31 16:51:26 -0800562 * Native support for metrics protobuf dumping. The dumping format will be
563 * raw byte array
564 *
565 * @param output an externally allocated string to dump serialized protobuf
566 */
567 void (*dumpMetrics)(std::string* output);
568
569 /**
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700570 * Clear /data/misc/bt_config.conf and erase all stored connections
571 */
572 int (*config_clear)(void);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700573
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700574 /**
575 * Clear (reset) the dynamic portion of the device interoperability database.
576 */
577 void (*interop_database_clear)(void);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700578
Jakub Pawlowski3a3b82c2017-10-18 20:49:54 -0700579 /**
580 * Add a new device interoperability workaround for a remote device whose
581 * first |len| bytes of the its device address match |addr|.
582 * NOTE: |feature| has to match an item defined in interop_feature_t
583 * (interop.h).
584 */
585 void (*interop_database_add)(uint16_t feature, const RawAddress* addr,
586 size_t len);
Jakub Pawlowskif2f207a2017-09-23 14:47:20 -0700587} bt_interface_t;
588
589#define BLUETOOTH_INTERFACE_STRING "bluetoothInterface"
590
591#endif /* ANDROID_INCLUDE_BLUETOOTH_H */