Initial Bluetooth open source release

Change-Id: I27bb95db854806d7deedaf6c622b17cb09f62f16
This commit is contained in:
Andre Eisenbach 2012-09-18 12:15:26 -07:00 committed by Jean-Baptiste Queru
parent 97c262fc84
commit 05f49546a9
7 changed files with 1262 additions and 0 deletions

View file

@ -0,0 +1,441 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BLUETOOTH_H
#define ANDROID_INCLUDE_BLUETOOTH_H
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
__BEGIN_DECLS
/**
* The Bluetooth Hardware Module ID
*/
#define BT_HARDWARE_MODULE_ID "bluetooth"
#define BT_STACK_MODULE_ID "bluetooth"
#define BT_STACK_TEST_MODULE_ID "bluetooth_test"
/* Bluetooth profile interface IDs */
#define BT_PROFILE_HANDSFREE_ID "handsfree"
#define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp"
#define BT_PROFILE_HEALTH_ID "health"
#define BT_PROFILE_SOCKETS_ID "socket"
#define BT_PROFILE_HIDHOST_ID "hidhost"
#define BT_PROFILE_PAN_ID "pan"
/** Bluetooth Address */
typedef struct {
uint8_t address[6];
} __attribute__((packed))bt_bdaddr_t;
/** Bluetooth Device Name */
typedef struct {
uint8_t name[248];
} __attribute__((packed))bt_bdname_t;
/** Bluetooth Adapter Visibility Modes*/
typedef enum {
BT_SCAN_MODE_NONE,
BT_SCAN_MODE_CONNECTABLE,
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE
} bt_scan_mode_t;
/** Bluetooth Adapter State */
typedef enum {
BT_STATE_OFF,
BT_STATE_ON
} bt_state_t;
/** Bluetooth Error Status */
/** We need to build on this */
typedef enum {
BT_STATUS_SUCCESS,
BT_STATUS_FAIL,
BT_STATUS_NOT_READY,
BT_STATUS_NOMEM,
BT_STATUS_BUSY,
BT_STATUS_DONE, /* request already completed */
BT_STATUS_UNSUPPORTED,
BT_STATUS_PARM_INVALID,
BT_STATUS_UNHANDLED,
BT_STATUS_AUTH_FAILURE,
BT_STATUS_RMT_DEV_DOWN
} bt_status_t;
/** Bluetooth PinKey Code */
typedef struct {
uint8_t pin[16];
} __attribute__((packed))bt_pin_code_t;
/** Bluetooth Adapter Discovery state */
typedef enum {
BT_DISCOVERY_STOPPED,
BT_DISCOVERY_STARTED
} bt_discovery_state_t;
/** Bluetooth ACL connection state */
typedef enum {
BT_ACL_STATE_CONNECTED,
BT_ACL_STATE_DISCONNECTED
} bt_acl_state_t;
/** Bluetooth 128-bit UUID */
typedef struct {
uint8_t uu[16];
} bt_uuid_t;
/** Bluetooth SDP service record */
typedef struct
{
bt_uuid_t uuid;
uint16_t channel;
char name[256]; // what's the maximum length
} bt_service_record_t;
/* Bluetooth Adapter and Remote Device property types */
typedef enum {
/* Properties common to both adapter and remote device */
/**
* Description - Bluetooth Device Name
* Access mode - Adapter name can be GET/SET. Remote device can be GET
* Data type - bt_bdname_t
*/
BT_PROPERTY_BDNAME = 0x1,
/**
* Description - Bluetooth Device Address
* Access mode - Only GET.
* Data type - bt_bdaddr_t
*/
BT_PROPERTY_BDADDR,
/**
* Description - Bluetooth Service 128-bit UUIDs
* Access mode - Only GET.
* Data type - Array of bt_uuid_t (Array size inferred from property length).
*/
BT_PROPERTY_UUIDS,
/**
* Description - Bluetooth Class of Device as found in Assigned Numbers
* Access mode - Only GET.
* Data type - uint32_t.
*/
BT_PROPERTY_CLASS_OF_DEVICE,
/**
* Description - Device Type - BREDR, BLE or DUAL Mode
* Access mode - Only GET.
* Data type - bt_device_type_t
*/
BT_PROPERTY_TYPE_OF_DEVICE,
/**
* Description - Bluetooth Service Record
* Access mode - Only GET.
* Data type - bt_service_record_t
*/
BT_PROPERTY_SERVICE_RECORD,
/* Properties unique to adapter */
/**
* Description - Bluetooth Adapter scan mode
* Access mode - GET and SET
* Data type - bt_scan_mode_t.
*/
BT_PROPERTY_ADAPTER_SCAN_MODE,
/**
* Description - List of bonded devices
* Access mode - Only GET.
* Data type - Array of bt_bdaddr_t of the bonded remote devices
* (Array size inferred from property length).
*/
BT_PROPERTY_ADAPTER_BONDED_DEVICES,
/**
* Description - Bluetooth Adapter Discovery timeout (in seconds)
* Access mode - GET and SET
* Data type - uint32_t
*/
BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
/* Properties unique to remote device */
/**
* Description - User defined friendly name of the remote device
* Access mode - GET and SET
* Data type - bt_bdname_t.
*/
BT_PROPERTY_REMOTE_FRIENDLY_NAME,
/**
* Description - RSSI value of the inquired remote device
* Access mode - Only GET.
* Data type - int32_t.
*/
BT_PROPERTY_REMOTE_RSSI,
BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF,
} bt_property_type_t;
/** Bluetooth Adapter Property data structure */
typedef struct
{
bt_property_type_t type;
int len;
void *val;
} bt_property_t;
/** Bluetooth Device Type */
typedef enum {
BT_DEVICE_DEVTYPE_BREDR = 0x1,
BT_DEVICE_DEVTYPE_BLE,
BT_DEVICE_DEVTYPE_DUAL
} bt_device_type_t;
/** Bluetooth Bond state */
typedef enum {
BT_BOND_STATE_NONE,
BT_BOND_STATE_BONDING,
BT_BOND_STATE_BONDED
} bt_bond_state_t;
/** Bluetooth SSP Bonding Variant */
typedef enum {
BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
BT_SSP_VARIANT_PASSKEY_ENTRY,
BT_SSP_VARIANT_CONSENT,
BT_SSP_VARIANT_PASSKEY_NOTIFICATION
} bt_ssp_variant_t;
#define BT_MAX_NUM_UUIDS 32
/** Bluetooth Interface callbacks */
/** Bluetooth Enable/Disable Callback. */
typedef void (*adapter_state_changed_callback)(bt_state_t state);
/** GET/SET Adapter Properties callback */
/* TODO: For the GET/SET property APIs/callbacks, we may need a session
* identifier to associate the call with the callback. This would be needed
* whenever more than one simultaneous instance of the same adapter_type
* is get/set.
*
* If this is going to be handled in the Java framework, then we do not need
* to manage sessions here.
*/
typedef void (*adapter_properties_callback)(bt_status_t status,
int num_properties,
bt_property_t *properties);
/** GET/SET Remote Device Properties callback */
/** TODO: For remote device properties, do not see a need to get/set
* multiple properties - num_properties shall be 1
*/
typedef void (*remote_device_properties_callback)(bt_status_t status,
bt_bdaddr_t *bd_addr,
int num_properties,
bt_property_t *properties);
/** New device discovered callback */
/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1
* respectively */
typedef void (*device_found_callback)(int num_properties,
bt_property_t *properties);
/** Discovery state changed callback */
typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state);
/** Bluetooth Legacy PinKey Request callback */
typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr,
bt_bdname_t *bd_name, uint32_t cod);
/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/
/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT &
* BT_SSP_PAIRING_PASSKEY_ENTRY */
/* TODO: Passkey request callback shall not be needed for devices with display
* capability. We still need support this in the stack for completeness */
typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr,
bt_bdname_t *bd_name,
uint32_t cod,
bt_ssp_variant_t pairing_variant,
uint32_t pass_key);
/** Bluetooth Bond state changed callback */
/* Invoked in response to create_bond, cancel_bond or remove_bond */
typedef void (*bond_state_changed_callback)(bt_status_t status,
bt_bdaddr_t *remote_bd_addr,
bt_bond_state_t state);
/** Bluetooth ACL connection state changed callback */
typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
bt_acl_state_t state);
typedef enum {
ASSOCIATE_JVM,
DISASSOCIATE_JVM
} bt_cb_thread_evt;
/** Thread Associate/Disassociate JVM Callback */
/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from
* the JVM */
typedef void (*callback_thread_event)(bt_cb_thread_evt evt);
/** Bluetooth Test Mode Callback */
/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */
typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len);
/** TODO: Add callbacks for Link Up/Down and other generic
* notifications/callbacks */
/** Bluetooth DM callback structure. */
typedef struct {
/** set to sizeof(bt_callbacks_t) */
size_t size;
adapter_state_changed_callback adapter_state_changed_cb;
adapter_properties_callback adapter_properties_cb;
remote_device_properties_callback remote_device_properties_cb;
device_found_callback device_found_cb;
discovery_state_changed_callback discovery_state_changed_cb;
pin_request_callback pin_request_cb;
ssp_request_callback ssp_request_cb;
bond_state_changed_callback bond_state_changed_cb;
acl_state_changed_callback acl_state_changed_cb;
callback_thread_event thread_evt_cb;
dut_mode_recv_callback dut_mode_recv_cb;
} bt_callbacks_t;
/** NOTE: By default, no profiles are initialized at the time of init/enable.
* Whenever the application invokes the 'init' API of a profile, then one of
* the following shall occur:
*
* 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the
* profile as enabled. Subsequently, when the application invokes the
* Bluetooth 'enable', as part of the enable sequence the profile that were
* marked shall be enabled by calling appropriate stack APIs. The
* 'adapter_properties_cb' shall return the list of UUIDs of the
* enabled profiles.
*
* 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack
* profile API to initialize the profile and trigger a
* 'adapter_properties_cb' with the current list of UUIDs including the
* newly added profile's UUID.
*
* The reverse shall occur whenever the profile 'cleanup' APIs are invoked
*/
/** Represents the standard Bluetooth DM interface. */
typedef struct {
/** set to sizeof(bt_interface_t) */
size_t size;
/**
* Opens the interface and provides the callback routines
* to the implemenation of this interface.
*/
int (*init)(bt_callbacks_t* callbacks );
/** Enable Bluetooth. */
int (*enable)(void);
/** Disable Bluetooth. */
int (*disable)(void);
/** Closes the interface. */
void (*cleanup)(void);
/** Get all Bluetooth Adapter properties at init */
int (*get_adapter_properties)(void);
/** Get Bluetooth Adapter property of 'type' */
int (*get_adapter_property)(bt_property_type_t type);
/** Set Bluetooth Adapter property of 'type' */
/* Based on the type, val shall be one of
* bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc
*/
int (*set_adapter_property)(const bt_property_t *property);
/** Get all Remote Device properties */
int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr);
/** Get Remote Device property of 'type' */
int (*get_remote_device_property)(bt_bdaddr_t *remote_addr,
bt_property_type_t type);
/** Set Remote Device property of 'type' */
int (*set_remote_device_property)(bt_bdaddr_t *remote_addr,
const bt_property_t *property);
/** Get Remote Device's service record for the given UUID */
int (*get_remote_service_record)(bt_bdaddr_t *remote_addr,
bt_uuid_t *uuid);
/** Start SDP to get remote services */
int (*get_remote_services)(bt_bdaddr_t *remote_addr);
/** Start Discovery */
int (*start_discovery)(void);
/** Cancel Discovery */
int (*cancel_discovery)(void);
/** Create Bluetooth Bonding */
int (*create_bond)(const bt_bdaddr_t *bd_addr);
/** Remove Bond */
int (*remove_bond)(const bt_bdaddr_t *bd_addr);
/** Cancel Bond */
int (*cancel_bond)(const bt_bdaddr_t *bd_addr);
/** BT Legacy PinKey Reply */
/** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept,
uint8_t pin_len, bt_pin_code_t *pin_code);
/** BT SSP Reply - Just Works, Numeric Comparison and Passkey
* passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON &
* BT_SSP_VARIANT_CONSENT
* For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey
* shall be zero */
int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
uint8_t accept, uint32_t passkey);
/** Get Bluetooth profile interface */
const void* (*get_profile_interface) (const char *profile_id);
/** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */
/* Configure DUT Mode - Use this mode to enter/exit DUT mode */
int (*dut_mode_configure)(uint8_t enable);
/* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */
int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len);
} bt_interface_t;
/** TODO: Need to add APIs for Service Discovery, Service authorization and
* connection management. Also need to add APIs for configuring
* properties of remote bonded devices such as name, UUID etc. */
typedef struct {
struct hw_device_t common;
const bt_interface_t* (*get_bluetooth_interface)();
} bluetooth_device_t;
typedef bluetooth_device_t bluetooth_module_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BLUETOOTH_H */

90
include/hardware/bt_av.h Normal file
View file

@ -0,0 +1,90 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_AV_H
#define ANDROID_INCLUDE_BT_AV_H
__BEGIN_DECLS
/* Bluetooth AV connection states */
typedef enum {
BTAV_CONNECTION_STATE_DISCONNECTED = 0,
BTAV_CONNECTION_STATE_CONNECTING,
BTAV_CONNECTION_STATE_CONNECTED,
BTAV_CONNECTION_STATE_DISCONNECTING
} btav_connection_state_t;
/* Bluetooth AV datapath states */
typedef enum {
BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0,
BTAV_AUDIO_STATE_STOPPED,
BTAV_AUDIO_STATE_STARTED,
} btav_audio_state_t;
/** Callback for connection state change.
* state will have one of the values from btav_connection_state_t
*/
typedef void (* btav_connection_state_callback)(btav_connection_state_t state,
bt_bdaddr_t *bd_addr);
/** Callback for audiopath state change.
* state will have one of the values from btav_audio_state_t
*/
typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
bt_bdaddr_t *bd_addr);
/** BT-AV callback structure. */
typedef struct {
/** set to sizeof(btav_callbacks_t) */
size_t size;
btav_connection_state_callback connection_state_cb;
btav_audio_state_callback audio_state_cb;
} btav_callbacks_t;
/**
* NOTE:
*
* 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
* shall be handled internally via uinput
*
* 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
* android_audio_hw library and the Bluetooth stack.
*
*/
/** Represents the standard BT-AV interface. */
typedef struct {
/** set to sizeof(btav_interface_t) */
size_t size;
/**
* Register the BtAv callbacks
*/
bt_status_t (*init)( btav_callbacks_t* callbacks );
/** connect to headset */
bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
/** dis-connect from headset */
bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
/** Closes the interface. */
void (*cleanup)( void );
} btav_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_AV_H */

284
include/hardware/bt_hf.h Normal file
View file

@ -0,0 +1,284 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_HF_H
#define ANDROID_INCLUDE_BT_HF_H
__BEGIN_DECLS
/* AT response code - OK/Error */
typedef enum {
BTHF_AT_RESPONSE_ERROR = 0,
BTHF_AT_RESPONSE_OK
} bthf_at_response_t;
typedef enum {
BTHF_CONNECTION_STATE_DISCONNECTED = 0,
BTHF_CONNECTION_STATE_CONNECTING,
BTHF_CONNECTION_STATE_CONNECTED,
BTHF_CONNECTION_STATE_SLC_CONNECTED,
BTHF_CONNECTION_STATE_DISCONNECTING
} bthf_connection_state_t;
typedef enum {
BTHF_AUDIO_STATE_DISCONNECTED = 0,
BTHF_AUDIO_STATE_CONNECTING,
BTHF_AUDIO_STATE_CONNECTED,
BTHF_AUDIO_STATE_DISCONNECTING
} bthf_audio_state_t;
typedef enum {
BTHF_VR_STATE_STOPPED = 0,
BTHF_VR_STATE_STARTED
} bthf_vr_state_t;
typedef enum {
BTHF_VOLUME_TYPE_SPK = 0,
BTHF_VOLUME_TYPE_MIC
} bthf_volume_type_t;
/* Noise Reduction and Echo Cancellation */
typedef enum
{
BTHF_NREC_STOP,
BTHF_NREC_START
} bthf_nrec_t;
/* CHLD - Call held handling */
typedef enum
{
BTHF_CHLD_TYPE_RELEASEHELD, // Terminate all held or set UDUB("busy") to a waiting call
BTHF_CHLD_TYPE_RELEASEACTIVE_ACCEPTHELD, // Terminate all active calls and accepts a waiting/held call
BTHF_CHLD_TYPE_HOLDACTIVE_ACCEPTHELD, // Hold all active calls and accepts a waiting/held call
BTHF_CHLD_TYPE_ADDHELDTOCONF, // Add all held calls to a conference
} bthf_chld_type_t;
/** Callback for connection state change.
* state will have one of the values from BtHfConnectionState
*/
typedef void (* bthf_connection_state_callback)(bthf_connection_state_t state, bt_bdaddr_t *bd_addr);
/** Callback for audio connection state change.
* state will have one of the values from BtHfAudioState
*/
typedef void (* bthf_audio_state_callback)(bthf_audio_state_t state, bt_bdaddr_t *bd_addr);
/** Callback for VR connection state change.
* state will have one of the values from BtHfVRState
*/
typedef void (* bthf_vr_cmd_callback)(bthf_vr_state_t state);
/** Callback for answer incoming call (ATA)
*/
typedef void (* bthf_answer_call_cmd_callback)();
/** Callback for disconnect call (AT+CHUP)
*/
typedef void (* bthf_hangup_call_cmd_callback)();
/** Callback for disconnect call (AT+CHUP)
* type will denote Speaker/Mic gain (BtHfVolumeControl).
*/
typedef void (* bthf_volume_cmd_callback)(bthf_volume_type_t type, int volume);
/** Callback for dialing an outgoing call
* If number is NULL, redial
*/
typedef void (* bthf_dial_call_cmd_callback)(char *number);
/** Callback for sending DTMF tones
* tone contains the dtmf character to be sent
*/
typedef void (* bthf_dtmf_cmd_callback)(char tone);
/** Callback for enabling/disabling noise reduction/echo cancellation
* value will be 1 to enable, 0 to disable
*/
typedef void (* bthf_nrec_cmd_callback)(bthf_nrec_t nrec);
/** Callback for call hold handling (AT+CHLD)
* value will contain the call hold command (0, 1, 2, 3)
*/
typedef void (* bthf_chld_cmd_callback)(bthf_chld_type_t chld);
/** Callback for CNUM (subscriber number)
*/
typedef void (* bthf_cnum_cmd_callback)();
/** Callback for indicators (CIND)
*/
typedef void (* bthf_cind_cmd_callback)();
/** Callback for operator selection (COPS)
*/
typedef void (* bthf_cops_cmd_callback)();
/** Callback for call list (AT+CLCC)
*/
typedef void (* bthf_clcc_cmd_callback) ();
/** Callback for unknown AT command recd from HF
* at_string will contain the unparsed AT string
*/
typedef void (* bthf_unknown_at_cmd_callback)(char *at_string);
/** Callback for keypressed (HSP) event.
*/
typedef void (* bthf_key_pressed_cmd_callback)();
/** BT-HF callback structure. */
typedef struct {
/** set to sizeof(BtHfCallbacks) */
size_t size;
bthf_connection_state_callback connection_state_cb;
bthf_audio_state_callback audio_state_cb;
bthf_vr_cmd_callback vr_cmd_cb;
bthf_answer_call_cmd_callback answer_call_cmd_cb;
bthf_hangup_call_cmd_callback hangup_call_cmd_cb;
bthf_volume_cmd_callback volume_cmd_cb;
bthf_dial_call_cmd_callback dial_call_cmd_cb;
bthf_dtmf_cmd_callback dtmf_cmd_cb;
bthf_nrec_cmd_callback nrec_cmd_cb;
bthf_chld_cmd_callback chld_cmd_cb;
bthf_cnum_cmd_callback cnum_cmd_cb;
bthf_cind_cmd_callback cind_cmd_cb;
bthf_cops_cmd_callback cops_cmd_cb;
bthf_clcc_cmd_callback clcc_cmd_cb;
bthf_unknown_at_cmd_callback unknown_at_cmd_cb;
bthf_key_pressed_cmd_callback key_pressed_cmd_cb;
} bthf_callbacks_t;
/** Network Status */
typedef enum
{
BTHF_NETWORK_STATE_NOT_AVAILABLE = 0,
BTHF_NETWORK_STATE_AVAILABLE
} bthf_network_state_t;
/** Service type */
typedef enum
{
BTHF_SERVICE_TYPE_HOME = 0,
BTHF_SERVICE_TYPE_ROAMING
} bthf_service_type_t;
typedef enum {
BTHF_CALL_STATE_ACTIVE = 0,
BTHF_CALL_STATE_HELD,
BTHF_CALL_STATE_DIALING,
BTHF_CALL_STATE_ALERTING,
BTHF_CALL_STATE_INCOMING,
BTHF_CALL_STATE_WAITING,
BTHF_CALL_STATE_IDLE
} bthf_call_state_t;
typedef enum {
BTHF_CALL_DIRECTION_OUTGOING = 0,
BTHF_CALL_DIRECTION_INCOMING
} bthf_call_direction_t;
typedef enum {
BTHF_CALL_TYPE_VOICE = 0,
BTHF_CALL_TYPE_DATA,
BTHF_CALL_TYPE_FAX
} bthf_call_mode_t;
typedef enum {
BTHF_CALL_MPTY_TYPE_SINGLE = 0,
BTHF_CALL_MPTY_TYPE_MULTI
} bthf_call_mpty_type_t;
typedef enum {
BTHF_CALL_ADDRTYPE_UNKNOWN = 0x81,
BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91
} bthf_call_addrtype_t;
/** Represents the standard BT-HF interface. */
typedef struct {
/** set to sizeof(BtHfInterface) */
size_t size;
/**
* Register the BtHf callbacks
*/
bt_status_t (*init)( bthf_callbacks_t* callbacks );
/** connect to headset */
bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
/** dis-connect from headset */
bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
/** create an audio connection */
bt_status_t (*connect_audio)( bt_bdaddr_t *bd_addr );
/** close the audio connection */
bt_status_t (*disconnect_audio)( bt_bdaddr_t *bd_addr );
/** start voice recognition */
bt_status_t (*start_voice_recognition)();
/** stop voice recognition */
bt_status_t (*stop_voice_recognition)();
/** volume control */
bt_status_t (*volume_control) (bthf_volume_type_t type, int volume);
/** Combined device status change notification */
bt_status_t (*device_status_notification)(bthf_network_state_t ntk_state, bthf_service_type_t svc_type, int signal,
int batt_chg);
/** Response for COPS command */
bt_status_t (*cops_response)(const char *cops);
/** Response for CIND command */
bt_status_t (*cind_response)(int svc, int num_active, int num_held, bthf_call_state_t call_setup_state,
int signal, int roam, int batt_chg);
/** Pre-formatted AT response, typically in response to unknown AT cmd */
bt_status_t (*formatted_at_response)(const char *rsp);
/** ok/error response
* ERROR (0)
* OK (1)
*/
bt_status_t (*at_response) (bthf_at_response_t response_code, int error_code);
/** response for CLCC command
* Can be iteratively called for each call index
* Call index of 0 will be treated as NULL termination (Completes response)
*/
bt_status_t (*clcc_response) (int index, bthf_call_direction_t dir,
bthf_call_state_t state, bthf_call_mode_t mode,
bthf_call_mpty_type_t mpty, const char *number,
bthf_call_addrtype_t type);
/** notify of a call state change
* Each update notifies
* 1. Number of active/held/ringing calls
* 2. call_state: This denotes the state change that triggered this msg
* This will take one of the values from BtHfCallState
* 3. number & type: valid only for incoming & waiting call
*/
bt_status_t (*phone_state_change) (int num_active, int num_held, bthf_call_state_t call_setup_state,
const char *number, bthf_call_addrtype_t type);
/** Closes the interface. */
void (*cleanup)( void );
} bthf_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_HF_H */

179
include/hardware/bt_hh.h Normal file
View file

@ -0,0 +1,179 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_HH_H
#define ANDROID_INCLUDE_BT_HH_H
#include <stdint.h>
__BEGIN_DECLS
#define BTHH_MAX_DSC_LEN 884
/* HH connection states */
typedef enum
{
BTHH_CONN_STATE_CONNECTED = 0,
BTHH_CONN_STATE_CONNECTING,
BTHH_CONN_STATE_DISCONNECTED,
BTHH_CONN_STATE_DISCONNECTING,
BTHH_CONN_STATE_FAILED_MOUSE_FROM_HOST,
BTHH_CONN_STATE_FAILED_KBD_FROM_HOST,
BTHH_CONN_STATE_FAILED_TOO_MANY_DEVICES,
BTHH_CONN_STATE_FAILED_NO_BTHID_DRIVER,
BTHH_CONN_STATE_FAILED_GENERIC,
BTHH_CONN_STATE_UNKNOWN
} bthh_connection_state_t;
typedef enum
{
BTHH_OK = 0,
BTHH_HS_HID_NOT_READY, /* handshake error : device not ready */
BTHH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */
BTHH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */
BTHH_HS_INVALID_PARAM, /* handshake error : invalid paremter */
BTHH_HS_ERROR, /* handshake error : unspecified HS error */
BTHH_ERR, /* general BTA HH error */
BTHH_ERR_SDP, /* SDP error */
BTHH_ERR_PROTO, /* SET_Protocol error,
only used in BTA_HH_OPEN_EVT callback */
BTHH_ERR_DB_FULL, /* device database full error, used */
BTHH_ERR_TOD_UNSPT, /* type of device not supported */
BTHH_ERR_NO_RES, /* out of system resources */
BTHH_ERR_AUTH_FAILED, /* authentication fail */
BTHH_ERR_HDL
}bthh_status_t;
/* Protocol modes */
typedef enum {
BTHH_REPORT_MODE = 0x00,
BTHH_BOOT_MODE = 0x01,
BTHH_UNSUPPORTED_MODE = 0xff
}bthh_protocol_mode_t;
/* Report types */
typedef enum {
BTHH_INPUT_REPORT = 1,
BTHH_OUTPUT_REPORT,
BTHH_FEATURE_REPORT
}bthh_report_type_t;
typedef struct
{
int attr_mask;
uint8_t sub_class;
uint8_t app_id;
int vendor_id;
int product_id;
int version;
uint8_t ctry_code;
int dl_len;
uint8_t dsc_list[BTHH_MAX_DSC_LEN];
} bthh_hid_info_t;
/** Callback for connection state change.
* state will have one of the values from bthh_connection_state_t
*/
typedef void (* bthh_connection_state_callback)(bt_bdaddr_t *bd_addr, bthh_connection_state_t state);
/** Callback for vitual unplug api.
* the status of the vitual unplug
*/
typedef void (* bthh_virtual_unplug_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status);
/** Callback for get hid info
* hid_info will contain attr_mask, sub_class, app_id, vendor_id, product_id, version, ctry_code, len
*/
typedef void (* bthh_hid_info_callback)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info);
/** Callback for get/set protocal api.
* the protocol mode is one of the value from bthh_protocol_mode_t
*/
typedef void (* bthh_protocol_mode_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status,bthh_protocol_mode_t mode);
/** Callback for get/set_idle_time api.
*/
typedef void (* bthh_idle_time_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, int idle_rate);
/** Callback for get report api.
* if staus is ok rpt_data contains the report data
*/
typedef void (* bthh_get_report_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, uint8_t* rpt_data, int rpt_size);
/** BT-HH callback structure. */
typedef struct {
/** set to sizeof(BtHfCallbacks) */
size_t size;
bthh_connection_state_callback connection_state_cb;
bthh_hid_info_callback hid_info_cb;
bthh_protocol_mode_callback protocol_mode_cb;
bthh_idle_time_callback idle_time_cb;
bthh_get_report_callback get_report_cb;
bthh_virtual_unplug_callback virtual_unplug_cb;
} bthh_callbacks_t;
/** Represents the standard BT-HH interface. */
typedef struct {
/** set to sizeof(BtHhInterface) */
size_t size;
/**
* Register the BtHh callbacks
*/
bt_status_t (*init)( bthh_callbacks_t* callbacks );
/** connect to hid device */
bt_status_t (*connect)( bt_bdaddr_t *bd_addr);
/** dis-connect from hid device */
bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
/** Virtual UnPlug (VUP) the specified HID device */
bt_status_t (*virtual_unplug)(bt_bdaddr_t *bd_addr);
/** Set the HID device descriptor for the specified HID device. */
bt_status_t (*set_info)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info );
/** Get the HID proto mode. */
bt_status_t (*get_protocol) (bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode);
/** Set the HID proto mode. */
bt_status_t (*set_protocol)(bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode);
/** Send a GET_REPORT to HID device. */
bt_status_t (*get_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, uint8_t reportId, int bufferSize);
/** Send a SET_REPORT to HID device. */
bt_status_t (*set_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, char* report);
/** Send data to HID device. */
bt_status_t (*send_data)(bt_bdaddr_t *bd_addr, char* data);
/** Closes the interface. */
void (*cleanup)( void );
} bthh_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_HH_H */

123
include/hardware/bt_hl.h Normal file
View file

@ -0,0 +1,123 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_HL_H
#define ANDROID_INCLUDE_BT_HL_H
__BEGIN_DECLS
/* HL connection states */
typedef enum
{
BTHL_MDEP_ROLE_SOURCE,
BTHL_MDEP_ROLE_SINK
} bthl_mdep_role_t;
typedef enum {
BTHL_APP_REG_STATE_REG_SUCCESS,
BTHL_APP_REG_STATE_REG_FAILED,
BTHL_APP_REG_STATE_DEREG_SUCCESS,
BTHL_APP_REG_STATE_DEREG_FAILED
} bthl_app_reg_state_t;
typedef enum
{
BTHL_CHANNEL_TYPE_RELIABLE,
BTHL_CHANNEL_TYPE_STREAMING,
BTHL_CHANNEL_TYPE_ANY
} bthl_channel_type_t;
/* HL connection states */
typedef enum {
BTHL_CONN_STATE_CONNECTING,
BTHL_CONN_STATE_CONNECTED,
BTHL_CONN_STATE_DISCONNECTING,
BTHL_CONN_STATE_DISCONNECTED,
BTHL_CONN_STATE_DESTROYED
} bthl_channel_state_t;
typedef struct
{
bthl_mdep_role_t mdep_role;
int data_type;
bthl_channel_type_t channel_type;
const char *mdep_description; /* MDEP description to be used in the SDP (optional); null terminated */
} bthl_mdep_cfg_t;
typedef struct
{
const char *application_name;
const char *provider_name; /* provider name to be used in the SDP (optional); null terminated */
const char *srv_name; /* service name to be used in the SDP (optional); null terminated*/
const char *srv_desp; /* service description to be used in the SDP (optional); null terminated */
int number_of_mdeps;
bthl_mdep_cfg_t *mdep_cfg; /* Dynamic array */
} bthl_reg_param_t;
/** Callback for application registration status.
* state will have one of the values from bthl_app_reg_state_t
*/
typedef void (* bthl_app_reg_state_callback)(int app_id, bthl_app_reg_state_t state);
/** Callback for channel connection state change.
* state will have one of the values from
* bthl_connection_state_t and fd (file descriptor)
*/
typedef void (* bthl_channel_state_callback)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int channel_id, bthl_channel_state_t state, int fd);
/** BT-HL callback structure. */
typedef struct {
/** set to sizeof(bthl_callbacks_t) */
size_t size;
bthl_app_reg_state_callback app_reg_state_cb;
bthl_channel_state_callback channel_state_cb;
} bthl_callbacks_t;
/** Represents the standard BT-HL interface. */
typedef struct {
/** set to sizeof(bthl_interface_t) */
size_t size;
/**
* Register the Bthl callbacks
*/
bt_status_t (*init)( bthl_callbacks_t* callbacks );
/** Register HL application */
bt_status_t (*register_application) ( bthl_reg_param_t *p_reg_param, int *app_id);
/** Unregister HL application */
bt_status_t (*unregister_application) (int app_id);
/** connect channel */
bt_status_t (*connect_channel)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int *channel_id);
/** destroy channel */
bt_status_t (*destroy_channel)(int channel_id);
/** Close the Bthl callback **/
void (*cleanup)(void);
} bthl_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_HL_H */

87
include/hardware/bt_pan.h Normal file
View file

@ -0,0 +1,87 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_PAN_H
#define ANDROID_INCLUDE_BT_PAN_H
__BEGIN_DECLS
#define BTPAN_ROLE_NONE 0
#define BTPAN_ROLE_PANNAP 1
#define BTPAN_ROLE_PANU 2
typedef enum {
BTPAN_STATE_CONNECTED = 0,
BTPAN_STATE_CONNECTING = 1,
BTPAN_STATE_DISCONNECTED = 2,
BTPAN_STATE_DISCONNECTING = 3
} btpan_connection_state_t;
typedef enum {
BTPAN_STATE_ENABLED = 0,
BTPAN_STATE_DISABLED = 1
} btpan_control_state_t;
/**
* Callback for pan connection state
*/
typedef void (*btpan_connection_state_callback)(btpan_connection_state_t state, bt_status_t error,
const bt_bdaddr_t *bd_addr, int local_role, int remote_role);
typedef void (*btpan_control_state_callback)(btpan_control_state_t state, bt_status_t error,
int local_role, const char* ifname);
typedef struct {
size_t size;
btpan_control_state_callback control_state_cb;
btpan_connection_state_callback connection_state_cb;
} btpan_callbacks_t;
typedef struct {
/** set to size of this struct*/
size_t size;
/**
* Initialize the pan interface and register the btpan callbacks
*/
bt_status_t (*init)(const btpan_callbacks_t* callbacks);
/*
* enable the pan service by specified role. The result state of
* enabl will be returned by btpan_control_state_callback. when pan-nap is enabled,
* the state of connecting panu device will be notified by btpan_connection_state_callback
*/
bt_status_t (*enable)(int local_role);
/*
* get current pan local role
*/
int (*get_local_role)(void);
/**
* start bluetooth pan connection to the remote device by specified pan role. The result state will be
* returned by btpan_connection_state_callback
*/
bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, int local_role, int remote_role);
/**
* stop bluetooth pan connection. The result state will be returned by btpan_connection_state_callback
*/
bt_status_t (*disconnect)(const bt_bdaddr_t *bd_addr);
/**
* Cleanup the pan interface
*/
void (*cleanup)(void);
} btpan_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_PAN_H */

View file

@ -0,0 +1,58 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_INCLUDE_BT_SOCK_H
#define ANDROID_INCLUDE_BT_SOCK_H
__BEGIN_DECLS
#define BTSOCK_FLAG_ENCRYPT 1
#define BTSOCK_FLAG_AUTH (1 << 1)
typedef enum {
BTSOCK_RFCOMM = 1,
BTSOCK_SCO = 2,
BTSOCK_L2CAP = 3
} btsock_type_t;
/** Represents the standard BT SOCKET interface. */
typedef struct {
short size;
bt_bdaddr_t bd_addr;
int channel;
int status;
} __attribute__((packed)) sock_connect_signal_t;
typedef struct {
/** set to size of this struct*/
size_t size;
/**
* listen to a rfcomm uuid or channel. It returns the socket fd from which
* btsock_connect_signal can be read out when a remote device connected
*/
bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
/*
* connect to a rfcomm uuid channel of remote device, It returns the socket fd from which
* the btsock_connect_signal and a new socket fd to be accepted can be read out when connected
*/
bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid, int channel, int* sock_fd, int flags);
} btsock_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BT_SOCK_H */