2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_INCLUDE_BLUETOOTH_H
18 #define ANDROID_INCLUDE_BLUETOOTH_H
22 #include <sys/cdefs.h>
23 #include <sys/types.h>
25 #include <hardware/hardware.h>
30 * The Bluetooth Hardware Module ID
33 #define BT_HARDWARE_MODULE_ID "bluetooth"
34 #define BT_STACK_MODULE_ID "bluetooth"
35 #define BT_STACK_TEST_MODULE_ID "bluetooth_test"
38 /* Bluetooth profile interface IDs */
40 #define BT_PROFILE_HANDSFREE_ID "handsfree"
41 #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
42 #define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
43 #define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink"
44 #define BT_PROFILE_HEALTH_ID "health"
45 #define BT_PROFILE_SOCKETS_ID "socket"
46 #define BT_PROFILE_HIDHOST_ID "hidhost"
47 #define BT_PROFILE_HIDDEVICE_ID "hiddevice"
48 #define BT_PROFILE_PAN_ID "pan"
49 #define BT_PROFILE_MAP_CLIENT_ID "map_client"
51 #define BT_PROFILE_GATT_ID "gatt"
52 #define BT_PROFILE_AV_RC_ID "avrcp"
53 #define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
54 #define BT_MANUFACTURER_DATA_LENGTH_MAX 31 /**< This specifies the Maximum manufacturer data Length>*/
56 /** Bluetooth Address */
59 } __attribute__((packed))bt_bdaddr_t;
61 /** Bluetooth Device Name */
64 } __attribute__((packed))bt_bdname_t;
66 /** Bluetooth Adapter Visibility Modes*/
69 BT_SCAN_MODE_CONNECTABLE,
70 BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
73 /** Bluetooth Adapter State */
79 /** Bluetooth Error Status */
80 /** We need to build on this */
88 BT_STATUS_DONE, /* request already completed */
89 BT_STATUS_UNSUPPORTED,
90 BT_STATUS_PARM_INVALID,
92 BT_STATUS_AUTH_FAILURE,
93 BT_STATUS_RMT_DEV_DOWN,
96 BT_STATUS_CONN_TOUT /* disconnection due to supervision timeout */
98 BT_STATUS_CONN_TOUT, /* disconnection due to supervision timeout */
99 BT_STATUS_AUTH_REJECTED,
100 BT_STATUS_CONN_TERM_LOCAL_HOST,
101 BT_STATUS_CONN_TERM_RMT_HOST
106 BT_SCAN_FILTER_FEATURE_DEVICE_ADDRESS = 0x01, /**< device address */
107 BT_SCAN_FILTER_FEATURE_SERVICE_DATA_CHANGED = 0x02, /**< service data changed */
108 BT_SCAN_FILTER_FEATURE_SERVICE_UUID = 0x04, /**< service uuid */
109 BT_SCAN_FILTER_FEATURE_SERVICE_SOLICITATION_UUID = 0x08, /**< service solicitation uuid */
110 BT_SCAN_FILTER_FEATURE_DEVICE_NAME = 0x10, /**< device name */
111 BT_SCAN_FILTER_FEATURE_MANUFACTURER_DATA = 0x20, /**< manufacturer data */
112 BT_SCAN_FILTER_FEATURE_SERVICE_DATA = 0x40, /**< service data */
113 } bt_scan_filter_feature_t;
116 /** Bluetooth PinKey Code */
119 } __attribute__((packed))bt_pin_code_t;
122 int data_len; /**< manafacturer specific data length */
123 char data[BT_MANUFACTURER_DATA_LENGTH_MAX];
124 } bt_manufacturer_data_t;
128 uint8_t ctrl_state; /* stack reported state */
129 uint64_t tx_time; /* in ms */
130 uint64_t rx_time; /* in ms */
131 uint64_t idle_time; /* in ms */
132 uint64_t energy_used; /* a product of mA, V and ms */
133 } __attribute__((packed))bt_activity_energy_info;
135 /** Bluetooth Adapter Discovery state */
137 BT_DISCOVERY_STOPPED,
139 } bt_discovery_state_t;
141 /** Bluetooth ACL connection state */
143 BT_ACL_STATE_CONNECTED,
144 BT_ACL_STATE_DISCONNECTED
147 /** Remote Device Trusted state */
150 BT_DEVICE_NOT_TRUSTED
151 } bt_device_trust_state_t;
153 /** Bluetooth 128-bit UUID */
158 /** Bluetooth SDP service record */
162 char name[256]; // what's the maximum length
163 } bt_service_record_t;
166 /** Bluetooth Remote Version info */
171 } bt_remote_version_t;
175 uint16_t version_supported;
176 uint8_t local_privacy_enabled;
177 uint8_t max_adv_instance;
178 uint8_t rpa_offload_supported;
179 uint8_t max_irk_list_size;
180 uint8_t max_adv_filter_supported;
181 uint8_t activity_energy_info_supported;
182 uint16_t scan_result_storage_size;
183 uint16_t total_trackable_advertisers;
184 bool extended_scan_support;
185 bool debug_logging_supported;
186 bool le_2m_phy_supported;
187 bool le_coded_phy_supported;
188 bool le_extended_advertising_supported;
189 bool le_periodic_advertising_supported;
190 uint16_t le_maximum_advertising_data_length;
191 } bt_local_le_features_t;
195 uint8_t local_privacy_enabled;
196 uint8_t max_adv_instance;
197 uint8_t rpa_offload_supported;
198 uint8_t max_irk_list_size;
199 uint8_t max_adv_filter_supported;
200 uint8_t scan_result_storage_size_lobyte;
201 uint8_t scan_result_storage_size_hibyte;
202 uint8_t activity_energy_info_supported;
203 } bt_local_le_features_t;*/
205 /* Bluetooth Adapter and Remote Device property types */
207 /* Properties common to both adapter and remote device */
209 * Description - Bluetooth Device Name
210 * Access mode - Adapter name can be GET/SET. Remote device can be GET
211 * Data type - bt_bdname_t
213 BT_PROPERTY_BDNAME = 0x1,
215 * Description - Bluetooth Device Address
216 * Access mode - Only GET.
217 * Data type - bt_bdaddr_t
221 * Description - Bluetooth Service 128-bit UUIDs
222 * Access mode - Only GET.
223 * Data type - Array of bt_uuid_t (Array size inferred from property length).
227 * Description - Bluetooth Class of Device as found in Assigned Numbers
228 * Access mode - Only GET.
229 * Data type - uint32_t.
231 BT_PROPERTY_CLASS_OF_DEVICE,
233 * Description - Device Type - BREDR, BLE or DUAL Mode
234 * Access mode - Only GET.
235 * Data type - bt_device_type_t
237 BT_PROPERTY_TYPE_OF_DEVICE,
239 * Description - Bluetooth Service Record
240 * Access mode - Only GET.
241 * Data type - bt_service_record_t
243 BT_PROPERTY_SERVICE_RECORD,
245 /* Properties unique to adapter */
247 * Description - Bluetooth Adapter scan mode
248 * Access mode - GET and SET
249 * Data type - bt_scan_mode_t.
251 BT_PROPERTY_ADAPTER_SCAN_MODE,
253 * Description - List of bonded devices
254 * Access mode - Only GET.
255 * Data type - Array of bt_bdaddr_t of the bonded remote devices
256 * (Array size inferred from property length).
258 BT_PROPERTY_ADAPTER_BONDED_DEVICES,
260 * Description - Bluetooth Adapter Discovery timeout (in seconds)
261 * Access mode - GET and SET
262 * Data type - uint32_t
264 BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
266 /* Properties unique to remote device */
268 * Description - User defined friendly name of the remote device
269 * Access mode - GET and SET
270 * Data type - bt_bdname_t.
272 BT_PROPERTY_REMOTE_FRIENDLY_NAME,
274 * Description - RSSI value of the inquired remote device
275 * Access mode - Only GET.
276 * Data type - int32_t.
278 BT_PROPERTY_REMOTE_RSSI,
280 * Description - Remote version info
281 * Access mode - SET/GET.
282 * Data type - bt_remote_version_t.
285 BT_PROPERTY_REMOTE_VERSION_INFO,
287 /* Tizen Specific Adapter and Remote Device properties */
289 * Description - Remote Device paired Info
291 * Data type - uint8_t.
293 BT_PROPERTY_REMOTE_PAIRED,
296 * Description - Remote Device connected Info
298 * Data type - unsigned int.
300 BT_PROPERTY_REMOTE_CONNECTED,
303 * Description - Remote Device Trusted info
305 * Data type - uint8_t.
307 BT_PROPERTY_REMOTE_TRUST,
310 * Description - Adapter Pairable info
311 * Access mode - GET\SET.
312 * Data type - uint8_t
314 BT_PROPERTY_PAIRABLE,
317 * Description - Adapter pairable Timeout value
319 * Data type - uint32_t
321 BT_PROPERTY_PAIRABLE_TIMEOUT,
324 * Description - Adapter version
326 * Data type - Array of character string
331 * Description - Adapter IPSP initialized state info
333 * Data type - uint8_t
335 BT_PROPERTY_IPSP_INITIALIZED,
338 * Description - Adapter Modalias info
340 * Data type - Array of character string
342 BT_PROPERTY_MODALIAS,
345 * Description - BLE Device manufacturer data length
347 * Data type - uint32_t
349 BT_PROPERTY_REMOTE_DEVICE_MANUFACTURER_DATA_LEN,
352 * Description - BLE Device manufacturer data
354 * Data type - Array of character string
356 BT_PROPERTY_REMOTE_DEVICE_MANUFACTURER_DATA,
359 * Description - Remote BLE advertising data
360 * Access mode - Only received during device found callback.
361 * Data type - Array of uint8_t of remote BLE adv data.
362 * (Array size inferred from property length).
364 BT_PROPERTY_REMOTE_BLE_ADV_DATA,
367 * Description - Local LE features
369 * Data type - bt_local_le_features_t.
371 BT_PROPERTY_LOCAL_LE_FEATURES,
374 * Description - Remote device friendly name set?
376 * Data type - uint8_t
378 BT_PROPERTY_REMOTE_IS_ALIAS_SET,
381 * Description - Bluetooth Adapter LE Discovery started
383 BT_PROPERTY_ADAPTER_LE_DISCOVERY_STARTED,
386 * Description - Bluetooth Adapter LE Discovery stopped
388 BT_PROPERTY_ADAPTER_LE_DISCOVERY_STOPPED,
391 * Description - A2DP role of media endpoint
392 * Access mode - Only GET.
393 * Data type - uint32_t.
395 BT_PROPERTY_A2DP_ROLE = 0x1c,
397 BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
398 } bt_property_type_t;
400 /** Bluetooth Adapter Property data structure */
402 bt_property_type_t type;
408 /** Bluetooth Device Type */
410 BT_DEVICE_DEVTYPE_BREDR = 0x1,
411 BT_DEVICE_DEVTYPE_BLE,
412 BT_DEVICE_DEVTYPE_DUAL
414 /** Bluetooth Bond state */
417 BT_BOND_STATE_BONDING,
421 /** Bluetooth SSP Bonding Variant */
423 BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
424 BT_SSP_VARIANT_PASSKEY_ENTRY,
425 BT_SSP_VARIANT_CONSENT,
426 BT_SSP_VARIANT_PASSKEY_NOTIFICATION
429 /** Bluetooth Profile Service IDs */
431 BT_RES_SERVICE_ID, /* Reserved */
432 BT_SPP_SERVICE_ID, /* Serial port profile. */
433 BT_DUN_SERVICE_ID, /* Dial-up networking profile. */
434 BT_A2DP_SRC_SERVICE_ID, /* A2DP Source profile. */
435 BT_LAP_SERVICE_ID, /* LAN access profile. */
436 BT_HSP_SERVICE_ID, /* Headset profile. */
437 BT_HFP_SERVICE_ID, /* Hands-free profile. */
438 BT_OPP_SERVICE_ID, /* Object push */
439 BT_FTP_SERVICE_ID, /* File transfer */
440 BT_AVRCP_CT_SERVICE_ID, /* AVRC Controller Terminal */
441 BT_ICP_SERVICE_ID, /* Intercom Terminal */
442 BT_SYNC_SERVICE_ID, /* Synchronization */
443 BT_BPP_SERVICE_ID, /* Basic printing profile */
444 BT_BIP_SERVICE_ID, /* Basic Imaging profile */
445 BT_PANU_SERVICE_ID, /* PAN User */
446 BT_NAP_SERVICE_ID, /* PAN Network access point */
447 BT_GN_SERVICE_ID, /* PAN Group Ad-hoc networks */
448 BT_SAP_SERVICE_ID, /* SIM Access profile */
449 BT_A2DP_SERVICE_ID, /* A2DP Sink */
450 BT_AVRCP_SERVICE_ID, /* A/V remote control */
451 BT_HID_SERVICE_ID, /* HID */
452 BT_VDP_SERVICE_ID, /* Video distribution */
453 BT_PBAP_SERVICE_ID, /* PhoneBook Access Server*/
454 BT_HSP_HS_SERVICE_ID, /* HFP HS role */
455 BT_HFP_HS_SERVICE_ID, /* HSP HS role */
456 BT_MAP_SERVICE_ID, /* Message Access Profile */
457 BT_MN_SERVICE_ID, /* Message Notification Service */
458 BT_HDP_SERVICE_ID, /* Health Device Profile */
459 BT_PCE_SERVICE_ID, /* PhoneBook Access Client*/
461 BT_IOTIVITY_SERVICE_ID, /* Custom IOTIVITY UUID */
465 #define BT_MAX_NUM_UUIDS 32
468 #define BT_OSP_SERVER_OBEX 0x00
469 #define BT_OSP_SERVER_RFCOMM 0x01
470 #define BT_OSP_SERVER_MAX 0xFF
472 /* Tizen BT discovery Types */
474 BT_DISC_ROLE_BREDR = 0x01,
477 } bt_disc_role_type_t;
480 * This is Bluetooth device address type
483 BLUETOOTH_HAL_DEVICE_PUBLIC_ADDRESS = 0x00,
484 BLUETOOTH_HAL_DEVICE_RANDOM_ADDRESS
485 } bt_dev_addr_type_t;
487 /** Bluetooth Trusted Profiles */
489 BT_TRUSTED_PROFILE_PBAP = 1,
490 BT_TRUSTED_PROFILE_MAP,
491 BT_TRUSTED_PROFILE_SAP,
492 BT_TRUSTED_PROFILE_HFP_HF,
493 BT_TRUSTED_PROFILE_A2DP,
494 BT_TRUSTED_PROFILE_ALL = 0xFFFFFFFF,
495 } bt_trusted_profile_t;
497 /** Bluetooth Bonding Authentication Notifications */
499 BT_PASSKEY_CONFIRMATION = 1,
503 } bt_gap_auth_variant_t;
507 /** Bluetooth Interface callbacks */
509 /** Bluetooth Enable/Disable Callback. */
510 typedef void (*adapter_state_changed_callback)(bt_state_t state);
513 /** BLE Enable/Disable Callback. */
514 typedef void (*le_state_changed_callback)(bt_state_t state);
517 /** GET/SET Adapter Properties callback */
518 /* TODO: For the GET/SET property APIs/callbacks, we may need a session
519 * identifier to associate the call with the callback. This would be needed
520 * whenever more than one simultaneous instance of the same adapter_type
523 * If this is going to be handled in the Java framework, then we do not need
524 * to manage sessions here.
526 typedef void (*adapter_properties_callback)(bt_status_t status,
528 bt_property_t *properties);
530 /** GET/SET Remote Device Properties callback */
531 /** TODO: For remote device properties, do not see a need to get/set
532 * multiple properties - num_properties shall be 1
534 typedef void (*remote_device_properties_callback)(bt_status_t status,
535 bt_bdaddr_t *bd_addr,
537 bt_property_t *properties);
539 /** New device discovered callback */
540 /** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
542 typedef void (*device_found_callback)(int num_properties,
543 bt_property_t *properties);
545 /** Discovery state changed callback */
546 typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
548 /** Bluetooth Legacy PinKey Request callback */
549 typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
550 bt_bdname_t *bd_name, uint32_t cod);
552 /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
553 /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
554 * BT_SSP_PAIRING_PASSKEY_ENTRY */
555 /* TODO: Passkey request callback shall not be needed for devices with display
556 * capability. We still need support this in the stack for completeness */
557 typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
558 bt_bdname_t *bd_name,
560 bt_ssp_variant_t pairing_variant,
563 /** Bluetooth Bond state changed callback */
564 /* Invoked in response to create_bond, cancel_bond or remove_bond */
565 typedef void (*bond_state_changed_callback)(bt_status_t status,
566 bt_bdaddr_t *remote_bd_addr,
567 bt_bond_state_t state);
569 /** Bluetooth ACL connection state changed callback */
570 typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
571 bt_acl_state_t state);
578 /** Thread Associate/Disassociate JVM Callback */
579 /* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
581 typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
583 /** Bluetooth Test Mode Callback */
584 /* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
585 typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
587 /* LE Test mode callbacks
588 * This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
589 * The num_packets is valid only for le_test_end command */
590 typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
592 /** Callback invoked when energy details are obtained */
593 /* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
594 * If the ctrl_state value is 0, it means the API call failed
595 * Time values-In milliseconds as returned by the controller
596 * Energy used-Value as returned by the controller
597 * Status-Provides the status of the read_energy_info API call */
598 typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info);
600 /* Service level Authorization request callback */
601 typedef void (*authorize_request_callback) (bt_bdaddr_t *remote_bd_addr, bt_service_id_t service_d);
604 /* Service level Authorization request callback */
605 typedef void (*sock_authorize_request_callback) (bt_bdaddr_t *remote_bd_addr, bt_uuid_t *uuid, uint8_t *name, uint8_t *path, uint32_t fd);
607 /** Bluetooth ACL connection state */
609 BT_LE_CONN_STATE_CONNECTED,
610 BT_LE_CONN_STATE_DISCONNECTED
611 } bt_le_conn_state_t;
613 /** Bluetooth ACL connection state changed callback */
614 typedef void (*le_conn_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
615 bt_le_conn_state_t state);
617 /** Remote device trusted profiles changed callback */
618 typedef void (*device_trusted_profiles_changed_callback)(bt_bdaddr_t *bd_addr, uint32_t trust_val);
620 /** Remote device RSSI monitoring state changed callback */
621 typedef void (*rssi_monitor_state_changed_callback)(bt_bdaddr_t *bd_addr, int32_t link_type, uint8_t state);
623 /** Remote device RSSI alert callback */
624 typedef void (*rssi_alert_callback)(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t alert_type, int32_t rssi);
626 /** Remote device Raw RSSI received callback */
627 typedef void (*raw_rssi_received_callback)(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t rssi);
629 /** DBFW plus info received callback */
630 typedef void (*dbfw_plus_info_received_callback)(unsigned char *data, uint32_t length, uint8_t event_code);
632 typedef void (*controller_error_received_callback)(uint8_t code);
635 /** TODO: Add callbacks for Link Up/Down and other generic
636 * notifications/callbacks */
638 /** Remote Device Trust state changed callback */
639 typedef void (*device_trust_state_changed_callback)(bt_bdaddr_t *remote_bd_addr,
640 bt_device_trust_state_t trust);
642 /** Bluetooth DM callback structure. */
644 /** set to sizeof(bt_callbacks_t) */
646 adapter_state_changed_callback adapter_state_changed_cb;
647 adapter_properties_callback adapter_properties_cb;
648 remote_device_properties_callback remote_device_properties_cb;
649 device_found_callback device_found_cb;
650 discovery_state_changed_callback discovery_state_changed_cb;
651 pin_request_callback pin_request_cb;
652 ssp_request_callback ssp_request_cb;
653 bond_state_changed_callback bond_state_changed_cb;
654 acl_state_changed_callback acl_state_changed_cb;
655 callback_thread_event thread_evt_cb;
656 dut_mode_recv_callback dut_mode_recv_cb;
657 le_test_mode_callback le_test_mode_cb;
658 energy_info_callback energy_info_cb;
659 authorize_request_callback authorize_request_cb;
660 device_trust_state_changed_callback device_trust_state_changed_cb;
662 sock_authorize_request_callback socket_authorize_request_cb;
663 le_state_changed_callback le_state_changed_cb;
664 le_conn_state_changed_callback le_conn_state_changed_cb;
665 device_trusted_profiles_changed_callback device_trusted_profiles_changed_cb;
666 rssi_monitor_state_changed_callback rssi_monitor_state_changed_cb;
667 rssi_alert_callback rssi_alert_cb;
668 raw_rssi_received_callback raw_rssi_received_cb;
669 dbfw_plus_info_received_callback dbfw_plus_info_received_cb;
670 controller_error_received_callback controller_error_received_cb;
674 typedef void (*alarm_cb)(void *data);
675 typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
676 typedef int (*acquire_wake_lock_callout)(const char *lock_name);
677 typedef int (*release_wake_lock_callout)(const char *lock_name);
679 /** The set of functions required by bluedroid to set wake alarms and
680 * grab wake locks. This struct is passed into the stack through the
681 * |set_os_callouts| function on |bt_interface_t|.
684 /* set to sizeof(bt_os_callouts_t) */
687 set_wake_alarm_callout set_wake_alarm;
688 acquire_wake_lock_callout acquire_wake_lock;
689 release_wake_lock_callout release_wake_lock;
692 /** NOTE: By default, no profiles are initialized at the time of init/enable.
693 * Whenever the application invokes the 'init' API of a profile, then one of
694 * the following shall occur:
696 * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
697 * profile as enabled. Subsequently, when the application invokes the
698 * Bluetooth 'enable', as part of the enable sequence the profile that were
699 * marked shall be enabled by calling appropriate stack APIs. The
700 * 'adapter_properties_cb' shall return the list of UUIDs of the
703 * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
704 * profile API to initialize the profile and trigger a
705 * 'adapter_properties_cb' with the current list of UUIDs including the
706 * newly added profile's UUID.
708 * The reverse shall occur whenever the profile 'cleanup' APIs are invoked
711 /** Represents the standard Bluetooth DM interface. */
713 /** set to sizeof(bt_interface_t) */
716 * Opens the interface and provides the callback routines
717 * to the implemenation of this interface.
719 int (*init)(bt_callbacks_t*callbacks);
721 /** Enable Bluetooth. */
724 /** Disable Bluetooth. */
725 int (*disable)(void);
728 /** Recovers Adapter. */
729 int (*recover)(void);
733 /** Reset Bluetooth. */
738 /** Enable LE Bluetooth. */
739 int (*le_enable)(void);
741 /** Disable LE Bluetooth. */
742 int (*le_disable)(void);
744 int (*le_init)(void);
746 void (*le_deinit)(void);
748 int (*is_advertising) (void);
751 /** Closes the interface. */
752 void (*cleanup)(void);
755 /** Get Bluetooth Adapter Powered status */
756 int (*get_adapter_powered_status)(uint8_t *status);
758 /** Get Bluetooth Adapter Energy Information */
759 int (*get_adapter_energy_info)(uint32_t *tx_time, uint32_t *rx_time,
760 uint32_t *idle_time, uint32_t *energy_used);
763 /** Get all Bluetooth Adapter properties at init */
764 int (*get_adapter_properties)(void);
766 /** Get Bluetooth Adapter property of 'type' */
767 int (*get_adapter_property)(bt_property_type_t type);
769 /** Set Bluetooth Adapter property of 'type' */
770 /* Based on the type, val shall be one of
771 * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
773 int (*set_adapter_property)(const bt_property_t *property);
775 /** Get all Remote Device properties */
776 int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
778 /** Get Remote Device property of 'type' */
779 int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
780 bt_property_type_t type);
782 /** Set Remote Device property of 'type' */
783 int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
784 const bt_property_t *property);
786 /** Get Remote Device's service record for the given UUID */
787 int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
790 /** Start SDP to get remote services */
791 int (*get_remote_services)(bt_bdaddr_t *remote_addr);
793 /** Start Discovery */
794 int (*start_discovery)(void);
797 int (*start_custom_discovery)(bt_disc_role_type_t disc_type);
800 /** Cancel Discovery */
801 int (*cancel_discovery)(void);
803 /** Create Bluetooth Bonding */
804 int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
807 int (*remove_bond)(const bt_bdaddr_t *bd_addr);
810 int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
813 * Get the connection status for a given remote device.
814 * return value of 0 means the device is not connected,
815 * non-zero return status indicates an active connection.
817 int (*get_connection_state)(const bt_bdaddr_t *bd_addr);
819 /** BT Legacy PinKey Reply */
820 /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
821 int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
822 uint8_t pin_len, bt_pin_code_t *pin_code);
824 /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
825 * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
826 * BT_SSP_VARIANT_CONSENT
827 * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
829 int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
830 uint8_t accept, uint32_t passkey);
832 /** Get Bluetooth profile interface */
833 const void* (*get_profile_interface) (const char *profile_id);
835 /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
836 /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
837 int (*dut_mode_configure)(uint8_t enable);
839 /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
840 int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
841 /** BLE Test Mode APIs */
842 /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
843 int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
845 /* enable or disable bluetooth HCI snoop log */
846 int (*config_hci_snoop_log)(uint8_t enable);
848 /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
849 * This should be called immediately after a successful |init|.
851 int (*set_os_callouts)(bt_os_callouts_t *callouts);
853 /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
854 * Success indicates that the VSC command was sent to controller
856 int (*read_energy_info)();
858 /* Tizen Specific: Send service level Authorization response */
859 int (*authorize_response)(const bt_bdaddr_t *bd_addr, bt_service_id_t service_id,
860 uint8_t authorize, uint8_t save_settings);
862 /** Set auto authorization for peer device. Should be a paired device */
863 int (*set_authorization)(bt_bdaddr_t *bd_addr, uint8_t auth);
866 * get the service connection status for a given remote device.
867 * return value of 0 means the device is not connected,
868 * non-zero return status indicates an active connection.
870 int (*get_service_connection_state)(const bt_bdaddr_t *bd_addr, bt_service_id_t rem_svc_id);
873 * Register osp server in gap agent.
875 int (*register_agent_osp_server)(uint32_t type, char *uuid, char *path, int fd);
878 * Unregister osp server in gap agent.
880 int (*unregister_agent_osp_server)(uint32_t type, char *uuid);
883 * Set profile as trusted for remote device
885 int (*set_trusted_profile)(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint8_t trust);
888 * Get profile trusted status for remote device
890 int (*get_trusted_profile)(bt_bdaddr_t *bd_addr, bt_trusted_profile_t profile, uint32_t *trusted);
893 * Gets the identity address of the remote device
895 int (*get_device_ida)(bt_bdaddr_t *bd_addr, bt_bdaddr_t *id_addr);
898 * Get raw RSSI strength of remote device for connected link type
899 * conn_link_type: (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
901 int (*get_connected_link_rssi_strength)(bt_bdaddr_t *bd_addr, uint32_t conn_link_type);
904 * Enable RSSI monitoring of remote device for connected link type
905 * conn_link_type: (0 = BR/EDR link, 1 = LE link, 0xFF = Any (Default))
906 * Threshold : (low_threshold, in_range_threshold, high_threshold)
908 int (*enable_rssi_monitoring)(bt_bdaddr_t *bd_addr, uint32_t conn_link_type,
909 int low_threshold, int in_range_threshold, int high_threshold);
911 * Enable/Disable GAP authentication notification to application
912 * enable == 0/1 -> Enable/Disable notification sending
913 * type == value from bt_gap_auth_variant_t
915 int (*enable_gap_auth_notifications)(uint32_t type, uint8_t enable);
917 int (*set_le_static_random_address)(uint8_t enable);
920 * Sets is_activating variable in HAL to TRUE. It is required for the
921 * adapter switched on event to propagate to upper layers from HAL.
923 int (*set_hal_adapter_request_state)(int enable);
926 * Sets is_activating variable in HAL to TRUE. It is required for the
927 * le adapter switched on event to propagate to upper layers from HAL.
929 int (*set_hal_le_request_state)(int enable);
932 * adds/removes the remote device address to/from the white list
934 int (*adapter_le_set_white_list)(bt_bdaddr_t *device_address, bt_dev_addr_type_t address_type, bool is_add);
937 * Sets the privacy functionality of the adapter
939 int (*adapter_le_set_privacy)(uint8_t set_privacy);
942 * disconnect the device
944 int (*device_disconnect)(const bt_bdaddr_t *bd_addr);
947 * sets the specified manufacturer data of the adapter
949 int (*adapter_le_set_manufacturer_data)(bt_manufacturer_data_t *m_data);
953 /** TODO: Need to add APIs for Service Discovery, Service authorization and
954 * connection management. Also need to add APIs for configuring
955 * properties of remote bonded devices such as name, UUID etc. */
958 struct hw_device_t common;
959 const bt_interface_t* (*get_bluetooth_interface)();
960 } bluetooth_device_t;
962 typedef bluetooth_device_t bluetooth_module_t;
965 #endif /* ANDROID_INCLUDE_BLUETOOTH_H */