Blame android/hardware/bluetooth.h

Packit 34410b
/*
Packit 34410b
 * Copyright (C) 2012 The Android Open Source Project
Packit 34410b
 *
Packit 34410b
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 34410b
 * you may not use this file except in compliance with the License.
Packit 34410b
 * You may obtain a copy of the License at
Packit 34410b
 *
Packit 34410b
 *      http://www.apache.org/licenses/LICENSE-2.0
Packit 34410b
 *
Packit 34410b
 * Unless required by applicable law or agreed to in writing, software
Packit 34410b
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 34410b
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 34410b
 * See the License for the specific language governing permissions and
Packit 34410b
 * limitations under the License.
Packit 34410b
 */
Packit 34410b
Packit 34410b
#ifndef ANDROID_INCLUDE_BLUETOOTH_H
Packit 34410b
#define ANDROID_INCLUDE_BLUETOOTH_H
Packit 34410b
Packit 34410b
#include <stdbool.h>
Packit 34410b
#include <stdint.h>
Packit 34410b
#include <sys/cdefs.h>
Packit 34410b
#include <sys/types.h>
Packit 34410b
Packit 34410b
#include <hardware/hardware.h>
Packit 34410b
Packit 34410b
__BEGIN_DECLS
Packit 34410b
Packit 34410b
/**
Packit 34410b
 * The Bluetooth Hardware Module ID
Packit 34410b
 */
Packit 34410b
Packit 34410b
#define BT_HARDWARE_MODULE_ID "bluetooth"
Packit 34410b
#define BT_STACK_MODULE_ID "bluetooth"
Packit 34410b
#define BT_STACK_TEST_MODULE_ID "bluetooth_test"
Packit 34410b
Packit 34410b
Packit 34410b
/* Bluetooth profile interface IDs */
Packit 34410b
Packit 34410b
#define BT_PROFILE_HANDSFREE_ID "handsfree"
Packit 34410b
#define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client"
Packit 34410b
#define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
Packit 34410b
#define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink"
Packit 34410b
#define BT_PROFILE_HEALTH_ID "health"
Packit 34410b
#define BT_PROFILE_SOCKETS_ID "socket"
Packit 34410b
#define BT_PROFILE_HIDHOST_ID "hidhost"
Packit 34410b
#define BT_PROFILE_PAN_ID "pan"
Packit 34410b
#define BT_PROFILE_MAP_CLIENT_ID "map_client"
Packit 34410b
Packit 34410b
#define BT_PROFILE_GATT_ID "gatt"
Packit 34410b
#define BT_PROFILE_AV_RC_ID "avrcp"
Packit 34410b
#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
Packit 34410b
Packit 34410b
/** Bluetooth Address */
Packit 34410b
typedef struct {
Packit 34410b
    uint8_t address[6];
Packit 34410b
} __attribute__((packed))bt_bdaddr_t;
Packit 34410b
Packit 34410b
/** Bluetooth Device Name */
Packit 34410b
typedef struct {
Packit 34410b
    uint8_t name[249];
Packit 34410b
} __attribute__((packed))bt_bdname_t;
Packit 34410b
Packit 34410b
/** Bluetooth Adapter Visibility Modes*/
Packit 34410b
typedef enum {
Packit 34410b
    BT_SCAN_MODE_NONE,
Packit 34410b
    BT_SCAN_MODE_CONNECTABLE,
Packit 34410b
    BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
Packit 34410b
} bt_scan_mode_t;
Packit 34410b
Packit 34410b
/** Bluetooth Adapter State */
Packit 34410b
typedef enum {
Packit 34410b
    BT_STATE_OFF,
Packit 34410b
    BT_STATE_ON
Packit 34410b
}   bt_state_t;
Packit 34410b
Packit 34410b
/** Bluetooth Error Status */
Packit 34410b
/** We need to build on this */
Packit 34410b
Packit 34410b
typedef enum {
Packit 34410b
    BT_STATUS_SUCCESS,
Packit 34410b
    BT_STATUS_FAIL,
Packit 34410b
    BT_STATUS_NOT_READY,
Packit 34410b
    BT_STATUS_NOMEM,
Packit 34410b
    BT_STATUS_BUSY,
Packit 34410b
    BT_STATUS_DONE,        /* request already completed */
Packit 34410b
    BT_STATUS_UNSUPPORTED,
Packit 34410b
    BT_STATUS_PARM_INVALID,
Packit 34410b
    BT_STATUS_UNHANDLED,
Packit 34410b
    BT_STATUS_AUTH_FAILURE,
Packit 34410b
    BT_STATUS_RMT_DEV_DOWN,
Packit 34410b
    BT_STATUS_AUTH_REJECTED
Packit 34410b
Packit 34410b
} bt_status_t;
Packit 34410b
Packit 34410b
/** Bluetooth PinKey Code */
Packit 34410b
typedef struct {
Packit 34410b
    uint8_t pin[16];
Packit 34410b
} __attribute__((packed))bt_pin_code_t;
Packit 34410b
Packit 34410b
typedef struct {
Packit 34410b
    uint8_t status;
Packit 34410b
    uint8_t ctrl_state;     /* stack reported state */
Packit 34410b
    uint64_t tx_time;       /* in ms */
Packit 34410b
    uint64_t rx_time;       /* in ms */
Packit 34410b
    uint64_t idle_time;     /* in ms */
Packit 34410b
    uint64_t energy_used;   /* a product of mA, V and ms */
Packit 34410b
} __attribute__((packed))bt_activity_energy_info;
Packit 34410b
Packit 34410b
/** Bluetooth Adapter Discovery state */
Packit 34410b
typedef enum {
Packit 34410b
    BT_DISCOVERY_STOPPED,
Packit 34410b
    BT_DISCOVERY_STARTED
Packit 34410b
} bt_discovery_state_t;
Packit 34410b
Packit 34410b
/** Bluetooth ACL connection state */
Packit 34410b
typedef enum {
Packit 34410b
    BT_ACL_STATE_CONNECTED,
Packit 34410b
    BT_ACL_STATE_DISCONNECTED
Packit 34410b
} bt_acl_state_t;
Packit 34410b
Packit 34410b
/** Bluetooth 128-bit UUID */
Packit 34410b
typedef struct {
Packit 34410b
   uint8_t uu[16];
Packit 34410b
} bt_uuid_t;
Packit 34410b
Packit 34410b
/** Bluetooth SDP service record */
Packit 34410b
typedef struct
Packit 34410b
{
Packit 34410b
   bt_uuid_t uuid;
Packit 34410b
   uint16_t channel;
Packit 34410b
   char name[256]; // what's the maximum length
Packit 34410b
} bt_service_record_t;
Packit 34410b
Packit 34410b
Packit 34410b
/** Bluetooth Remote Version info */
Packit 34410b
typedef struct
Packit 34410b
{
Packit 34410b
   int version;
Packit 34410b
   int sub_ver;
Packit 34410b
   int manufacturer;
Packit 34410b
} bt_remote_version_t;
Packit 34410b
Packit 34410b
typedef struct
Packit 34410b
{
Packit 34410b
    uint8_t local_privacy_enabled;
Packit 34410b
    uint8_t max_adv_instance;
Packit 34410b
    uint8_t rpa_offload_supported;
Packit 34410b
    uint8_t max_irk_list_size;
Packit 34410b
    uint8_t max_adv_filter_supported;
Packit 34410b
    uint8_t scan_result_storage_size_lobyte;
Packit 34410b
    uint8_t scan_result_storage_size_hibyte;
Packit 34410b
    uint8_t activity_energy_info_supported;
Packit 34410b
}bt_local_le_features_t;
Packit 34410b
Packit 34410b
/* Bluetooth Adapter and Remote Device property types */
Packit 34410b
typedef enum {
Packit 34410b
    /* Properties common to both adapter and remote device */
Packit 34410b
    /**
Packit 34410b
     * Description - Bluetooth Device Name
Packit 34410b
     * Access mode - Adapter name can be GET/SET. Remote device can be GET
Packit 34410b
     * Data type   - bt_bdname_t
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_BDNAME = 0x1,
Packit 34410b
    /**
Packit 34410b
     * Description - Bluetooth Device Address
Packit 34410b
     * Access mode - Only GET.
Packit 34410b
     * Data type   - bt_bdaddr_t
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_BDADDR,
Packit 34410b
    /**
Packit 34410b
     * Description - Bluetooth Service 128-bit UUIDs
Packit 34410b
     * Access mode - Only GET.
Packit 34410b
     * Data type   - Array of bt_uuid_t (Array size inferred from property length).
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_UUIDS,
Packit 34410b
    /**
Packit 34410b
     * Description - Bluetooth Class of Device as found in Assigned Numbers
Packit 34410b
     * Access mode - Only GET.
Packit 34410b
     * Data type   - uint32_t.
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_CLASS_OF_DEVICE,
Packit 34410b
    /**
Packit 34410b
     * Description - Device Type - BREDR, BLE or DUAL Mode
Packit 34410b
     * Access mode - Only GET.
Packit 34410b
     * Data type   - bt_device_type_t
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_TYPE_OF_DEVICE,
Packit 34410b
    /**
Packit 34410b
     * Description - Bluetooth Service Record
Packit 34410b
     * Access mode - Only GET.
Packit 34410b
     * Data type   - bt_service_record_t
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_SERVICE_RECORD,
Packit 34410b
Packit 34410b
    /* Properties unique to adapter */
Packit 34410b
    /**
Packit 34410b
     * Description - Bluetooth Adapter scan mode
Packit 34410b
     * Access mode - GET and SET
Packit 34410b
     * Data type   - bt_scan_mode_t.
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_ADAPTER_SCAN_MODE,
Packit 34410b
    /**
Packit 34410b
     * Description - List of bonded devices
Packit 34410b
     * Access mode - Only GET.
Packit 34410b
     * Data type   - Array of bt_bdaddr_t of the bonded remote devices
Packit 34410b
     *               (Array size inferred from property length).
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_ADAPTER_BONDED_DEVICES,
Packit 34410b
    /**
Packit 34410b
     * Description - Bluetooth Adapter Discovery timeout (in seconds)
Packit 34410b
     * Access mode - GET and SET
Packit 34410b
     * Data type   - uint32_t
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
Packit 34410b
Packit 34410b
    /* Properties unique to remote device */
Packit 34410b
    /**
Packit 34410b
     * Description - User defined friendly name of the remote device
Packit 34410b
     * Access mode - GET and SET
Packit 34410b
     * Data type   - bt_bdname_t.
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_REMOTE_FRIENDLY_NAME,
Packit 34410b
    /**
Packit 34410b
     * Description - RSSI value of the inquired remote device
Packit 34410b
     * Access mode - Only GET.
Packit 34410b
     * Data type   - int32_t.
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_REMOTE_RSSI,
Packit 34410b
    /**
Packit 34410b
     * Description - Remote version info
Packit 34410b
     * Access mode - SET/GET.
Packit 34410b
     * Data type   - bt_remote_version_t.
Packit 34410b
     */
Packit 34410b
Packit 34410b
    BT_PROPERTY_REMOTE_VERSION_INFO,
Packit 34410b
Packit 34410b
    /**
Packit 34410b
     * Description - Local LE features
Packit 34410b
     * Access mode - GET.
Packit 34410b
     * Data type   - bt_local_le_features_t.
Packit 34410b
     */
Packit 34410b
    BT_PROPERTY_LOCAL_LE_FEATURES,
Packit 34410b
Packit 34410b
    BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
Packit 34410b
} bt_property_type_t;
Packit 34410b
Packit 34410b
/** Bluetooth Adapter Property data structure */
Packit 34410b
typedef struct
Packit 34410b
{
Packit 34410b
    bt_property_type_t type;
Packit 34410b
    int len;
Packit 34410b
    void *val;
Packit 34410b
} bt_property_t;
Packit 34410b
Packit 34410b
Packit 34410b
/** Bluetooth Device Type */
Packit 34410b
typedef enum {
Packit 34410b
    BT_DEVICE_DEVTYPE_BREDR = 0x1,
Packit 34410b
    BT_DEVICE_DEVTYPE_BLE,
Packit 34410b
    BT_DEVICE_DEVTYPE_DUAL
Packit 34410b
} bt_device_type_t;
Packit 34410b
/** Bluetooth Bond state */
Packit 34410b
typedef enum {
Packit 34410b
    BT_BOND_STATE_NONE,
Packit 34410b
    BT_BOND_STATE_BONDING,
Packit 34410b
    BT_BOND_STATE_BONDED
Packit 34410b
} bt_bond_state_t;
Packit 34410b
Packit 34410b
/** Bluetooth SSP Bonding Variant */
Packit 34410b
typedef enum {
Packit 34410b
    BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
Packit 34410b
    BT_SSP_VARIANT_PASSKEY_ENTRY,
Packit 34410b
    BT_SSP_VARIANT_CONSENT,
Packit 34410b
    BT_SSP_VARIANT_PASSKEY_NOTIFICATION
Packit 34410b
} bt_ssp_variant_t;
Packit 34410b
Packit 34410b
#define BT_MAX_NUM_UUIDS 32
Packit 34410b
Packit 34410b
/** Bluetooth Interface callbacks */
Packit 34410b
Packit 34410b
/** Bluetooth Enable/Disable Callback. */
Packit 34410b
typedef void (*adapter_state_changed_callback)(bt_state_t state);
Packit 34410b
Packit 34410b
/** GET/SET Adapter Properties callback */
Packit 34410b
/* TODO: For the GET/SET property APIs/callbacks, we may need a session
Packit 34410b
 * identifier to associate the call with the callback. This would be needed
Packit 34410b
 * whenever more than one simultaneous instance of the same adapter_type
Packit 34410b
 * is get/set.
Packit 34410b
 *
Packit 34410b
 * If this is going to be handled in the Java framework, then we do not need
Packit 34410b
 * to manage sessions here.
Packit 34410b
 */
Packit 34410b
typedef void (*adapter_properties_callback)(bt_status_t status,
Packit 34410b
                                               int num_properties,
Packit 34410b
                                               bt_property_t *properties);
Packit 34410b
Packit 34410b
/** GET/SET Remote Device Properties callback */
Packit 34410b
/** TODO: For remote device properties, do not see a need to get/set
Packit 34410b
 * multiple properties - num_properties shall be 1
Packit 34410b
 */
Packit 34410b
typedef void (*remote_device_properties_callback)(bt_status_t status,
Packit 34410b
                                                       bt_bdaddr_t *bd_addr,
Packit 34410b
                                                       int num_properties,
Packit 34410b
                                                       bt_property_t *properties);
Packit 34410b
Packit 34410b
/** New device discovered callback */
Packit 34410b
/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
Packit 34410b
 * respectively */
Packit 34410b
typedef void (*device_found_callback)(int num_properties,
Packit 34410b
                                         bt_property_t *properties);
Packit 34410b
Packit 34410b
/** Discovery state changed callback */
Packit 34410b
typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
Packit 34410b
Packit 34410b
/** Bluetooth Legacy PinKey Request callback */
Packit 34410b
typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
Packit 34410b
                                        bt_bdname_t *bd_name, uint32_t cod);
Packit 34410b
Packit 34410b
/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
Packit 34410b
/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
Packit 34410b
 *  BT_SSP_PAIRING_PASSKEY_ENTRY */
Packit 34410b
/* TODO: Passkey request callback shall not be needed for devices with display
Packit 34410b
 * capability. We still need support this in the stack for completeness */
Packit 34410b
typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
Packit 34410b
                                        bt_bdname_t *bd_name,
Packit 34410b
                                        uint32_t cod,
Packit 34410b
                                        bt_ssp_variant_t pairing_variant,
Packit 34410b
                                     uint32_t pass_key);
Packit 34410b
Packit 34410b
/** Bluetooth Bond state changed callback */
Packit 34410b
/* Invoked in response to create_bond, cancel_bond or remove_bond */
Packit 34410b
typedef void (*bond_state_changed_callback)(bt_status_t status,
Packit 34410b
                                               bt_bdaddr_t *remote_bd_addr,
Packit 34410b
                                               bt_bond_state_t state);
Packit 34410b
Packit 34410b
/** Bluetooth ACL connection state changed callback */
Packit 34410b
typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
Packit 34410b
                                            bt_acl_state_t state);
Packit 34410b
Packit 34410b
typedef enum {
Packit 34410b
    ASSOCIATE_JVM,
Packit 34410b
    DISASSOCIATE_JVM
Packit 34410b
} bt_cb_thread_evt;
Packit 34410b
Packit 34410b
/** Thread Associate/Disassociate JVM Callback */
Packit 34410b
/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
Packit 34410b
 * the JVM */
Packit 34410b
typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
Packit 34410b
Packit 34410b
/** Bluetooth Test Mode Callback */
Packit 34410b
/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
Packit 34410b
typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
Packit 34410b
Packit 34410b
/* LE Test mode callbacks
Packit 34410b
* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked
Packit 34410b
* The num_packets is valid only for le_test_end command */
Packit 34410b
typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
Packit 34410b
Packit 34410b
/** Callback invoked when energy details are obtained */
Packit 34410b
/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec.
Packit 34410b
 * If the ctrl_state value is 0, it means the API call failed
Packit 34410b
 * Time values-In milliseconds as returned by the controller
Packit 34410b
 * Energy used-Value as returned by the controller
Packit 34410b
 * Status-Provides the status of the read_energy_info API call */
Packit 34410b
typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info);
Packit 34410b
Packit 34410b
/** TODO: Add callbacks for Link Up/Down and other generic
Packit 34410b
  *  notifications/callbacks */
Packit 34410b
Packit 34410b
/** Bluetooth DM callback structure. */
Packit 34410b
typedef struct {
Packit 34410b
    /** set to sizeof(bt_callbacks_t) */
Packit 34410b
    size_t size;
Packit 34410b
    adapter_state_changed_callback adapter_state_changed_cb;
Packit 34410b
    adapter_properties_callback adapter_properties_cb;
Packit 34410b
    remote_device_properties_callback remote_device_properties_cb;
Packit 34410b
    device_found_callback device_found_cb;
Packit 34410b
    discovery_state_changed_callback discovery_state_changed_cb;
Packit 34410b
    pin_request_callback pin_request_cb;
Packit 34410b
    ssp_request_callback ssp_request_cb;
Packit 34410b
    bond_state_changed_callback bond_state_changed_cb;
Packit 34410b
    acl_state_changed_callback acl_state_changed_cb;
Packit 34410b
    callback_thread_event thread_evt_cb;
Packit 34410b
    dut_mode_recv_callback dut_mode_recv_cb;
Packit 34410b
    le_test_mode_callback le_test_mode_cb;
Packit 34410b
    energy_info_callback energy_info_cb;
Packit 34410b
} bt_callbacks_t;
Packit 34410b
Packit 34410b
typedef void (*alarm_cb)(void *data);
Packit 34410b
typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data);
Packit 34410b
typedef int (*acquire_wake_lock_callout)(const char *lock_name);
Packit 34410b
typedef int (*release_wake_lock_callout)(const char *lock_name);
Packit 34410b
Packit 34410b
/** The set of functions required by bluedroid to set wake alarms and
Packit 34410b
  * grab wake locks. This struct is passed into the stack through the
Packit 34410b
  * |set_os_callouts| function on |bt_interface_t|.
Packit 34410b
  */
Packit 34410b
typedef struct {
Packit 34410b
  /* set to sizeof(bt_os_callouts_t) */
Packit 34410b
  size_t size;
Packit 34410b
Packit 34410b
  set_wake_alarm_callout set_wake_alarm;
Packit 34410b
  acquire_wake_lock_callout acquire_wake_lock;
Packit 34410b
  release_wake_lock_callout release_wake_lock;
Packit 34410b
} bt_os_callouts_t;
Packit 34410b
Packit 34410b
/** NOTE: By default, no profiles are initialized at the time of init/enable.
Packit 34410b
 *  Whenever the application invokes the 'init' API of a profile, then one of
Packit 34410b
 *  the following shall occur:
Packit 34410b
 *
Packit 34410b
 *    1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
Packit 34410b
 *        profile as enabled. Subsequently, when the application invokes the
Packit 34410b
 *        Bluetooth 'enable', as part of the enable sequence the profile that were
Packit 34410b
 *        marked shall be enabled by calling appropriate stack APIs. The
Packit 34410b
 *        'adapter_properties_cb' shall return the list of UUIDs of the
Packit 34410b
 *        enabled profiles.
Packit 34410b
 *
Packit 34410b
 *    2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
Packit 34410b
 *        profile API to initialize the profile and trigger a
Packit 34410b
 *        'adapter_properties_cb' with the current list of UUIDs including the
Packit 34410b
 *        newly added profile's UUID.
Packit 34410b
 *
Packit 34410b
 *   The reverse shall occur whenever the profile 'cleanup' APIs are invoked
Packit 34410b
 */
Packit 34410b
Packit 34410b
/** Represents the standard Bluetooth DM interface. */
Packit 34410b
typedef struct {
Packit 34410b
    /** set to sizeof(bt_interface_t) */
Packit 34410b
    size_t size;
Packit 34410b
    /**
Packit 34410b
     * Opens the interface and provides the callback routines
Packit 34410b
     * to the implemenation of this interface.
Packit 34410b
     */
Packit 34410b
    int (*init)(bt_callbacks_t* callbacks );
Packit 34410b
Packit 34410b
    /** Enable Bluetooth. */
Packit 34410b
    int (*enable)(void);
Packit 34410b
Packit 34410b
    /** Disable Bluetooth. */
Packit 34410b
    int (*disable)(void);
Packit 34410b
Packit 34410b
    /** Closes the interface. */
Packit 34410b
    void (*cleanup)(void);
Packit 34410b
Packit 34410b
    /** Get all Bluetooth Adapter properties at init */
Packit 34410b
    int (*get_adapter_properties)(void);
Packit 34410b
Packit 34410b
    /** Get Bluetooth Adapter property of 'type' */
Packit 34410b
    int (*get_adapter_property)(bt_property_type_t type);
Packit 34410b
Packit 34410b
    /** Set Bluetooth Adapter property of 'type' */
Packit 34410b
    /* Based on the type, val shall be one of
Packit 34410b
     * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
Packit 34410b
     */
Packit 34410b
    int (*set_adapter_property)(const bt_property_t *property);
Packit 34410b
Packit 34410b
    /** Get all Remote Device properties */
Packit 34410b
    int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
Packit 34410b
Packit 34410b
    /** Get Remote Device property of 'type' */
Packit 34410b
    int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
Packit 34410b
                                      bt_property_type_t type);
Packit 34410b
Packit 34410b
    /** Set Remote Device property of 'type' */
Packit 34410b
    int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
Packit 34410b
                                      const bt_property_t *property);
Packit 34410b
Packit 34410b
    /** Get Remote Device's service record  for the given UUID */
Packit 34410b
    int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
Packit 34410b
                                     bt_uuid_t *uuid);
Packit 34410b
Packit 34410b
    /** Start SDP to get remote services */
Packit 34410b
    int (*get_remote_services)(bt_bdaddr_t *remote_addr);
Packit 34410b
Packit 34410b
    /** Start Discovery */
Packit 34410b
    int (*start_discovery)(void);
Packit 34410b
Packit 34410b
    /** Cancel Discovery */
Packit 34410b
    int (*cancel_discovery)(void);
Packit 34410b
Packit 34410b
    /** Create Bluetooth Bonding */
Packit 34410b
    int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport);
Packit 34410b
Packit 34410b
    /** Remove Bond */
Packit 34410b
    int (*remove_bond)(const bt_bdaddr_t *bd_addr);
Packit 34410b
Packit 34410b
    /** Cancel Bond */
Packit 34410b
    int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
Packit 34410b
Packit 34410b
    /**
Packit 34410b
     * Get the connection status for a given remote device.
Packit 34410b
     * return value of 0 means the device is not connected,
Packit 34410b
     * non-zero return status indicates an active connection.
Packit 34410b
     */
Packit 34410b
    int (*get_connection_state)(const bt_bdaddr_t *bd_addr);
Packit 34410b
Packit 34410b
    /** BT Legacy PinKey Reply */
Packit 34410b
    /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
Packit 34410b
    int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
Packit 34410b
                     uint8_t pin_len, bt_pin_code_t *pin_code);
Packit 34410b
Packit 34410b
    /** BT SSP Reply - Just Works, Numeric Comparison and Passkey
Packit 34410b
     * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
Packit 34410b
     * BT_SSP_VARIANT_CONSENT
Packit 34410b
     * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
Packit 34410b
     * shall be zero */
Packit 34410b
    int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
Packit 34410b
                     uint8_t accept, uint32_t passkey);
Packit 34410b
Packit 34410b
    /** Get Bluetooth profile interface */
Packit 34410b
    const void* (*get_profile_interface) (const char *profile_id);
Packit 34410b
Packit 34410b
    /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
Packit 34410b
    /* Configure DUT Mode - Use this mode to enter/exit DUT mode */
Packit 34410b
    int (*dut_mode_configure)(uint8_t enable);
Packit 34410b
Packit 34410b
    /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
Packit 34410b
    int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
Packit 34410b
    /** BLE Test Mode APIs */
Packit 34410b
    /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
Packit 34410b
    int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
Packit 34410b
Packit 34410b
    /* enable or disable bluetooth HCI snoop log */
Packit 34410b
    int (*config_hci_snoop_log)(uint8_t enable);
Packit 34410b
Packit 34410b
    /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks.
Packit 34410b
      * This should be called immediately after a successful |init|.
Packit 34410b
      */
Packit 34410b
    int (*set_os_callouts)(bt_os_callouts_t *callouts);
Packit 34410b
Packit 34410b
    /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY
Packit 34410b
      * Success indicates that the VSC command was sent to controller
Packit 34410b
      */
Packit 34410b
    int (*read_energy_info)();
Packit 34410b
} bt_interface_t;
Packit 34410b
Packit 34410b
/** TODO: Need to add APIs for Service Discovery, Service authorization and
Packit 34410b
  *       connection management. Also need to add APIs for configuring
Packit 34410b
  *       properties of remote bonded devices such as name, UUID etc. */
Packit 34410b
Packit 34410b
typedef struct {
Packit 34410b
    struct hw_device_t common;
Packit 34410b
    const bt_interface_t* (*get_bluetooth_interface)();
Packit 34410b
} bluetooth_device_t;
Packit 34410b
Packit 34410b
typedef bluetooth_device_t bluetooth_module_t;
Packit 34410b
__END_DECLS
Packit 34410b
Packit 34410b
#endif /* ANDROID_INCLUDE_BLUETOOTH_H */