blob: 1280767ac9875aaf4633acd92fdc9ca7cd6fa0f0 [file] [log] [blame]
Andre Eisenbach05f49542012-09-18 12:15:26 -07001/*
Hemant Gupta2d7d33b2013-11-11 11:53:48 +05302 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 * Not a Contribution
4 *
Andre Eisenbach05f49542012-09-18 12:15:26 -07005 * Copyright (C) 2012 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#ifndef ANDROID_INCLUDE_BLUETOOTH_H
21#define ANDROID_INCLUDE_BLUETOOTH_H
22
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -070023#include <stdbool.h>
Andre Eisenbach05f49542012-09-18 12:15:26 -070024#include <stdint.h>
25#include <sys/cdefs.h>
26#include <sys/types.h>
27
28#include <hardware/hardware.h>
29
30__BEGIN_DECLS
31
32/**
33 * The Bluetooth Hardware Module ID
34 */
35
36#define BT_HARDWARE_MODULE_ID "bluetooth"
37#define BT_STACK_MODULE_ID "bluetooth"
38#define BT_STACK_TEST_MODULE_ID "bluetooth_test"
39
40
41/* Bluetooth profile interface IDs */
42
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 Gupta2d7d33b2013-11-11 11:53:48 +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"
Andre Eisenbach05f49542012-09-18 12:15:26 -070053
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"
Kiran Kelageri1c60b652014-07-16 18:33:55 -070056#define WIPOWER_PROFILE_ID "wipower"
57
Mike Lockwood7da4cb82014-06-02 16:20:51 -070058#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
Andre Eisenbach05f49542012-09-18 12:15:26 -070059
60/** Bluetooth Address */
61typedef struct {
62 uint8_t address[6];
63} __attribute__((packed))bt_bdaddr_t;
64
65/** Bluetooth Device Name */
66typedef struct {
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -080067 uint8_t name[249];
Andre Eisenbach05f49542012-09-18 12:15:26 -070068} __attribute__((packed))bt_bdname_t;
69
70/** Bluetooth Adapter Visibility Modes*/
71typedef enum {
72 BT_SCAN_MODE_NONE,
73 BT_SCAN_MODE_CONNECTABLE,
74 BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
75} bt_scan_mode_t;
76
77/** Bluetooth Adapter State */
78typedef enum {
79 BT_STATE_OFF,
80 BT_STATE_ON
81} bt_state_t;
82
83/** Bluetooth Error Status */
84/** We need to build on this */
85
86typedef enum {
87 BT_STATUS_SUCCESS,
88 BT_STATUS_FAIL,
89 BT_STATUS_NOT_READY,
90 BT_STATUS_NOMEM,
91 BT_STATUS_BUSY,
92 BT_STATUS_DONE, /* request already completed */
93 BT_STATUS_UNSUPPORTED,
94 BT_STATUS_PARM_INVALID,
95 BT_STATUS_UNHANDLED,
96 BT_STATUS_AUTH_FAILURE,
Hemant Gupta4d864552013-07-31 19:14:02 +053097 BT_STATUS_RMT_DEV_DOWN,
98 BT_STATUS_AUTH_REJECTED
Andre Eisenbach05f49542012-09-18 12:15:26 -070099
100} bt_status_t;
101
102/** Bluetooth PinKey Code */
103typedef struct {
104 uint8_t pin[16];
105} __attribute__((packed))bt_pin_code_t;
106
Satya Callojibe7f0442014-07-03 10:59:16 -0700107typedef struct {
108 uint8_t status;
109 uint8_t ctrl_state; /* stack reported state */
110 uint64_t tx_time; /* in ms */
111 uint64_t rx_time; /* in ms */
112 uint64_t idle_time; /* in ms */
113 uint64_t energy_used; /* a product of mA, V and ms */
114} __attribute__((packed))bt_activity_energy_info;
115
Andre Eisenbach05f49542012-09-18 12:15:26 -0700116/** Bluetooth Adapter Discovery state */
117typedef enum {
118 BT_DISCOVERY_STOPPED,
119 BT_DISCOVERY_STARTED
120} bt_discovery_state_t;
121
122/** Bluetooth ACL connection state */
123typedef enum {
124 BT_ACL_STATE_CONNECTED,
125 BT_ACL_STATE_DISCONNECTED
126} bt_acl_state_t;
127
128/** Bluetooth 128-bit UUID */
129typedef struct {
130 uint8_t uu[16];
131} bt_uuid_t;
132
133/** Bluetooth SDP service record */
134typedef struct
135{
136 bt_uuid_t uuid;
137 uint16_t channel;
138 char name[256]; // what's the maximum length
139} bt_service_record_t;
140
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800141/** 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{
151 uint8_t local_privacy_enabled;
152 uint8_t max_adv_instance;
153 uint8_t rpa_offload_supported;
154 uint8_t max_irk_list_size;
155 uint8_t max_adv_filter_supported;
Prerepa Viswanadham378de1a2014-07-30 15:10:39 -0700156 uint8_t scan_result_storage_size_lobyte;
157 uint8_t scan_result_storage_size_hibyte;
Satya Callojibe7f0442014-07-03 10:59:16 -0700158 uint8_t activity_energy_info_supported;
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700159}bt_local_le_features_t;
160
Nitin Shivpure59aa62a2014-05-20 18:06:38 +0530161/* Bluetooth Remote DI record */
162typedef struct
163{
164 int vendor;
165 int vendor_id_source;
166 int product;
167 int version;
168 int spec_id;
169} bt_remote_di_record_t;
170
Andre Eisenbach05f49542012-09-18 12:15:26 -0700171/* Bluetooth Adapter and Remote Device property types */
172typedef enum {
173 /* Properties common to both adapter and remote device */
174 /**
175 * Description - Bluetooth Device Name
176 * Access mode - Adapter name can be GET/SET. Remote device can be GET
177 * Data type - bt_bdname_t
178 */
179 BT_PROPERTY_BDNAME = 0x1,
180 /**
181 * Description - Bluetooth Device Address
182 * Access mode - Only GET.
183 * Data type - bt_bdaddr_t
184 */
185 BT_PROPERTY_BDADDR,
186 /**
187 * Description - Bluetooth Service 128-bit UUIDs
188 * Access mode - Only GET.
189 * Data type - Array of bt_uuid_t (Array size inferred from property length).
190 */
191 BT_PROPERTY_UUIDS,
192 /**
193 * Description - Bluetooth Class of Device as found in Assigned Numbers
194 * Access mode - Only GET.
195 * Data type - uint32_t.
196 */
197 BT_PROPERTY_CLASS_OF_DEVICE,
198 /**
199 * Description - Device Type - BREDR, BLE or DUAL Mode
200 * Access mode - Only GET.
201 * Data type - bt_device_type_t
202 */
203 BT_PROPERTY_TYPE_OF_DEVICE,
204 /**
205 * Description - Bluetooth Service Record
206 * Access mode - Only GET.
207 * Data type - bt_service_record_t
208 */
209 BT_PROPERTY_SERVICE_RECORD,
210
211 /* Properties unique to adapter */
212 /**
213 * Description - Bluetooth Adapter scan mode
214 * Access mode - GET and SET
215 * Data type - bt_scan_mode_t.
216 */
217 BT_PROPERTY_ADAPTER_SCAN_MODE,
218 /**
219 * Description - List of bonded devices
220 * Access mode - Only GET.
221 * Data type - Array of bt_bdaddr_t of the bonded remote devices
222 * (Array size inferred from property length).
223 */
224 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
225 /**
226 * Description - Bluetooth Adapter Discovery timeout (in seconds)
227 * Access mode - GET and SET
228 * Data type - uint32_t
229 */
230 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
231
232 /* Properties unique to remote device */
233 /**
234 * Description - User defined friendly name of the remote device
235 * Access mode - GET and SET
236 * Data type - bt_bdname_t.
237 */
238 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
239 /**
240 * Description - RSSI value of the inquired remote device
241 * Access mode - Only GET.
242 * Data type - int32_t.
243 */
244 BT_PROPERTY_REMOTE_RSSI,
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800245 /**
246 * Description - Remote version info
247 * Access mode - SET/GET.
248 * Data type - bt_remote_version_t.
249 */
250
251 BT_PROPERTY_REMOTE_VERSION_INFO,
Andre Eisenbach05f49542012-09-18 12:15:26 -0700252
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700253 /**
254 * Description - Local LE features
255 * Access mode - GET.
256 * Data type - bt_local_le_features_t.
257 */
258 BT_PROPERTY_LOCAL_LE_FEATURES,
259
Pradeep Panigrahi949280f2013-08-14 16:29:22 +0530260 /**
261 * Description - Trust value of the remote device
262 * Access mode - GET and SET
263 * Data type - boolean.
264 */
265 BT_PROPERTY_REMOTE_TRUST_VALUE = 0xFD,
266
Nitin Shivpure59aa62a2014-05-20 18:06:38 +0530267 /* Properties unique to remote device */
268 /**
269 * Description - DI Record of the remote device
270 * Access mode - GET
271 * Data type - bt_remote_di_record_t.
272 */
273 BT_PROPERTY_REMOTE_DI_RECORD = 0xFE,
274
Andre Eisenbach05f49542012-09-18 12:15:26 -0700275 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
276} bt_property_type_t;
277
278/** Bluetooth Adapter Property data structure */
279typedef struct
280{
281 bt_property_type_t type;
282 int len;
283 void *val;
284} bt_property_t;
285
Ganesh Ganapathi Batta460343a2014-05-27 16:03:11 -0700286
Andre Eisenbach05f49542012-09-18 12:15:26 -0700287/** Bluetooth Device Type */
288typedef enum {
289 BT_DEVICE_DEVTYPE_BREDR = 0x1,
290 BT_DEVICE_DEVTYPE_BLE,
291 BT_DEVICE_DEVTYPE_DUAL
292} bt_device_type_t;
293/** Bluetooth Bond state */
294typedef enum {
295 BT_BOND_STATE_NONE,
296 BT_BOND_STATE_BONDING,
297 BT_BOND_STATE_BONDED
298} bt_bond_state_t;
299
300/** Bluetooth SSP Bonding Variant */
301typedef enum {
302 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
303 BT_SSP_VARIANT_PASSKEY_ENTRY,
304 BT_SSP_VARIANT_CONSENT,
305 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
306} bt_ssp_variant_t;
307
308#define BT_MAX_NUM_UUIDS 32
309
310/** Bluetooth Interface callbacks */
311
312/** Bluetooth Enable/Disable Callback. */
313typedef void (*adapter_state_changed_callback)(bt_state_t state);
314
315/** GET/SET Adapter Properties callback */
316/* TODO: For the GET/SET property APIs/callbacks, we may need a session
317 * identifier to associate the call with the callback. This would be needed
318 * whenever more than one simultaneous instance of the same adapter_type
319 * is get/set.
320 *
321 * If this is going to be handled in the Java framework, then we do not need
322 * to manage sessions here.
323 */
324typedef void (*adapter_properties_callback)(bt_status_t status,
325 int num_properties,
326 bt_property_t *properties);
327
328/** GET/SET Remote Device Properties callback */
329/** TODO: For remote device properties, do not see a need to get/set
330 * multiple properties - num_properties shall be 1
331 */
332typedef void (*remote_device_properties_callback)(bt_status_t status,
333 bt_bdaddr_t *bd_addr,
334 int num_properties,
335 bt_property_t *properties);
336
337/** New device discovered callback */
338/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
339 * respectively */
340typedef void (*device_found_callback)(int num_properties,
341 bt_property_t *properties);
342
343/** Discovery state changed callback */
344typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
345
346/** Bluetooth Legacy PinKey Request callback */
347typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
Srinu Jella091164c2013-06-04 20:20:27 +0530348 bt_bdname_t *bd_name, uint32_t cod, uint8_t secure);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700349
350/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
351/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
352 * BT_SSP_PAIRING_PASSKEY_ENTRY */
353/* TODO: Passkey request callback shall not be needed for devices with display
354 * capability. We still need support this in the stack for completeness */
355typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
356 bt_bdname_t *bd_name,
357 uint32_t cod,
358 bt_ssp_variant_t pairing_variant,
359 uint32_t pass_key);
360
361/** Bluetooth Bond state changed callback */
362/* Invoked in response to create_bond, cancel_bond or remove_bond */
363typedef void (*bond_state_changed_callback)(bt_status_t status,
364 bt_bdaddr_t *remote_bd_addr,
365 bt_bond_state_t state);
366
367/** Bluetooth ACL connection state changed callback */
368typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
369 bt_acl_state_t state);
Nitin Arora61dbc682013-11-20 16:57:47 -0800370/** Callback invoked when write rssi threshold command complete */
371typedef void (*le_lpp_write_rssi_thresh_callback) (bt_bdaddr_t *bda, int status);
372
373/** Callback invoked when read rssi threshold command complete */
374typedef void (*le_lpp_read_rssi_thresh_callback)(bt_bdaddr_t *bda, int low, int upper,
375 int alert, int status);
376
377/** Callback invoked when enable or disable rssi monitor command complete */
378typedef void (*le_lpp_enable_rssi_monitor_callback)(bt_bdaddr_t *bda,
379 int enable, int status);
380
381/** Callback triggered when rssi threshold event reported */
382typedef void (*le_lpp_rssi_threshold_evt_callback)(bt_bdaddr_t *bda,
383 int evt_type, int rssi);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700384
385typedef enum {
386 ASSOCIATE_JVM,
387 DISASSOCIATE_JVM
388} bt_cb_thread_evt;
389
390/** Thread Associate/Disassociate JVM Callback */
391/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
392 * the JVM */
393typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
394
395/** Bluetooth Test Mode Callback */
396/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
397typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
398
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800399/* LE Test mode callbacks
400* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
401* The num_packets is valid only for le_test_end command */
402typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
Satya Callojibe7f0442014-07-03 10:59:16 -0700403
404/** Callback invoked when energy details are obtained */
405/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
406 * If the ctrl_state value is 0, it means the API call failed
407 * Time values-In milliseconds as returned by the controller
408 * Energy used-Value as returned by the controller
409 * Status-Provides the status of the read_energy_info API call */
410typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info);
411
Andre Eisenbach05f49542012-09-18 12:15:26 -0700412/** TODO: Add callbacks for Link Up/Down and other generic
413 * notifications/callbacks */
414
415/** Bluetooth DM callback structure. */
416typedef struct {
417 /** set to sizeof(bt_callbacks_t) */
418 size_t size;
419 adapter_state_changed_callback adapter_state_changed_cb;
420 adapter_properties_callback adapter_properties_cb;
421 remote_device_properties_callback remote_device_properties_cb;
422 device_found_callback device_found_cb;
423 discovery_state_changed_callback discovery_state_changed_cb;
424 pin_request_callback pin_request_cb;
425 ssp_request_callback ssp_request_cb;
426 bond_state_changed_callback bond_state_changed_cb;
427 acl_state_changed_callback acl_state_changed_cb;
428 callback_thread_event thread_evt_cb;
429 dut_mode_recv_callback dut_mode_recv_cb;
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800430 le_test_mode_callback le_test_mode_cb;
Satya Callojibe7f0442014-07-03 10:59:16 -0700431 energy_info_callback energy_info_cb;
Nitin Arora61dbc682013-11-20 16:57:47 -0800432 le_lpp_write_rssi_thresh_callback le_lpp_write_rssi_thresh_cb;
433 le_lpp_read_rssi_thresh_callback le_lpp_read_rssi_thresh_cb;
434 le_lpp_enable_rssi_monitor_callback le_lpp_enable_rssi_monitor_cb;
435 le_lpp_rssi_threshold_evt_callback le_lpp_rssi_threshold_evt_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -0700436} bt_callbacks_t;
437
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700438typedef void (*alarm_cb)(void *data);
439typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
440typedef int (*acquire_wake_lock_callout)(const char *lock_name);
441typedef int (*release_wake_lock_callout)(const char *lock_name);
442
443/** The set of functions required by bluedroid to set wake alarms and
444 * grab wake locks. This struct is passed into the stack through the
445 * |set_os_callouts| function on |bt_interface_t|.
446 */
447typedef struct {
448 /* set to sizeof(bt_os_callouts_t) */
449 size_t size;
450
451 set_wake_alarm_callout set_wake_alarm;
452 acquire_wake_lock_callout acquire_wake_lock;
453 release_wake_lock_callout release_wake_lock;
454} bt_os_callouts_t;
455
Andre Eisenbach05f49542012-09-18 12:15:26 -0700456/** NOTE: By default, no profiles are initialized at the time of init/enable.
457 * Whenever the application invokes the 'init' API of a profile, then one of
458 * the following shall occur:
459 *
460 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
461 * profile as enabled. Subsequently, when the application invokes the
462 * Bluetooth 'enable', as part of the enable sequence the profile that were
463 * marked shall be enabled by calling appropriate stack APIs. The
464 * 'adapter_properties_cb' shall return the list of UUIDs of the
465 * enabled profiles.
466 *
467 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
468 * profile API to initialize the profile and trigger a
469 * 'adapter_properties_cb' with the current list of UUIDs including the
470 * newly added profile's UUID.
471 *
472 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
473 */
474
475/** Represents the standard Bluetooth DM interface. */
476typedef struct {
477 /** set to sizeof(bt_interface_t) */
478 size_t size;
479 /**
480 * Opens the interface and provides the callback routines
481 * to the implemenation of this interface.
482 */
483 int (*init)(bt_callbacks_t* callbacks );
484
Nitin Arora61dbc682013-11-20 16:57:47 -0800485 /*adds callbacks for QC related calls to the btif env*/
486 int (*initq)(bt_callbacks_t* callbacks);
487
Andre Eisenbach05f49542012-09-18 12:15:26 -0700488 /** Enable Bluetooth. */
489 int (*enable)(void);
490
491 /** Disable Bluetooth. */
492 int (*disable)(void);
493
494 /** Closes the interface. */
495 void (*cleanup)(void);
496
pramod kotreshappa408d9e12014-03-03 13:16:32 -0800497 /** SSR cleanup. */
498 void (*ssrcleanup)(void);
499
Andre Eisenbach05f49542012-09-18 12:15:26 -0700500 /** Get all Bluetooth Adapter properties at init */
501 int (*get_adapter_properties)(void);
502
503 /** Get Bluetooth Adapter property of 'type' */
504 int (*get_adapter_property)(bt_property_type_t type);
505
506 /** Set Bluetooth Adapter property of 'type' */
507 /* Based on the type, val shall be one of
508 * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
509 */
510 int (*set_adapter_property)(const bt_property_t *property);
511
512 /** Get all Remote Device properties */
513 int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
514
515 /** Get Remote Device property of 'type' */
516 int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
517 bt_property_type_t type);
518
519 /** Set Remote Device property of 'type' */
520 int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
521 const bt_property_t *property);
522
523 /** Get Remote Device's service record for the given UUID */
524 int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
525 bt_uuid_t *uuid);
526
527 /** Start SDP to get remote services */
528 int (*get_remote_services)(bt_bdaddr_t *remote_addr);
529
530 /** Start Discovery */
531 int (*start_discovery)(void);
532
533 /** Cancel Discovery */
534 int (*cancel_discovery)(void);
535
536 /** Create Bluetooth Bonding */
Andre Eisenbach01206e52014-08-04 17:22:29 -0700537 int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700538
539 /** Remove Bond */
540 int (*remove_bond)(const bt_bdaddr_t *bd_addr);
541
542 /** Cancel Bond */
543 int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
544
Andre Eisenbach0d553bc2014-06-18 12:18:34 -0700545 /**
546 * Get the connection status for a given remote device.
547 * return value of 0 means the device is not connected,
548 * non-zero return status indicates an active connection.
549 */
550 int (*get_connection_state)(const bt_bdaddr_t *bd_addr);
551
Andre Eisenbach05f49542012-09-18 12:15:26 -0700552 /** BT Legacy PinKey Reply */
553 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
554 int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
555 uint8_t pin_len, bt_pin_code_t *pin_code);
556
557 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
558 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
559 * BT_SSP_VARIANT_CONSENT
560 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
561 * shall be zero */
562 int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
563 uint8_t accept, uint32_t passkey);
564
565 /** Get Bluetooth profile interface */
566 const void* (*get_profile_interface) (const char *profile_id);
567
568 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
569 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
570 int (*dut_mode_configure)(uint8_t enable);
571
572 /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
573 int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
Ganesh Ganapathi Battafefb3342013-02-05 15:23:45 -0800574 /** BLE Test Mode APIs */
575 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
576 int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
577
Zhihai Xua17b75b2013-06-10 20:23:45 -0700578 /* enable or disable bluetooth HCI snoop log */
579 int (*config_hci_snoop_log)(uint8_t enable);
Sharvil Nanavati3bd8cba2014-05-30 16:43:38 -0700580
581 /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
582 * This should be called immediately after a successful |init|.
583 */
584 int (*set_os_callouts)(bt_os_callouts_t *callouts);
Satya Callojibe7f0442014-07-03 10:59:16 -0700585
586 /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
587 * Success indicates that the VSC command was sent to controller
588 */
589 int (*read_energy_info)();
Pramod Sivaramanca854b32013-09-24 19:13:26 +0530590 /** BT stack Test interface */
591 const void* (*get_testapp_interface)(int test_app_profile);
Nitin Arora61dbc682013-11-20 16:57:47 -0800592 /** rssi monitoring */
593 bt_status_t (*le_lpp_write_rssi_threshold)(const bt_bdaddr_t *remote_bda, char min, char max);
594 bt_status_t (*le_lpp_enable_rssi_monitor)(const bt_bdaddr_t *remote_bda, int enable);
595 bt_status_t (*le_lpp_read_rssi_threshold)(const bt_bdaddr_t *remote_bda);
596
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;
609__END_DECLS
610
611#endif /* ANDROID_INCLUDE_BLUETOOTH_H */