OSDN Git Service

android: Copy the KitKat Bluetooth hardware headers
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 1 Nov 2013 13:24:55 +0000 (06:24 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 1 Nov 2013 13:24:55 +0000 (06:24 -0700)
android/hardware/bluetooth.h
android/hardware/bt_gatt_client.h
android/hardware/bt_gatt_types.h
android/hardware/bt_rc.h

index 2741332..c00a8f7 100644 (file)
@@ -451,6 +451,8 @@ typedef struct {
     /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */
     int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len);
 
+    /* enable or disable bluetooth HCI snoop log */
+    int (*config_hci_snoop_log)(uint8_t enable);
 } bt_interface_t;
 
 /** TODO: Need to add APIs for Service Discovery, Service authorization and
index 8b49f59..d6b0cb4 100644 (file)
@@ -40,8 +40,8 @@ typedef struct
 typedef struct
 {
     btgatt_srvc_id_t    srvc_id;
-    btgatt_char_id_t    char_id;
-    bt_uuid_t           descr_id;
+    btgatt_gatt_id_t    char_id;
+    btgatt_gatt_id_t    descr_id;
     btgatt_unformatted_value_t value;
     uint16_t            value_type;
     uint8_t             status;
@@ -51,8 +51,8 @@ typedef struct
 typedef struct
 {
     btgatt_srvc_id_t    srvc_id;
-    btgatt_char_id_t    char_id;
-    bt_uuid_t           descr_id;
+    btgatt_gatt_id_t    char_id;
+    btgatt_gatt_id_t    descr_id;
     uint8_t             status;
 } btgatt_write_params_t;
 
@@ -62,7 +62,7 @@ typedef struct
     uint8_t             value[BTGATT_MAX_ATTR_LEN];
     bt_bdaddr_t         bda;
     btgatt_srvc_id_t    srvc_id;
-    btgatt_char_id_t    char_id;
+    btgatt_gatt_id_t    char_id;
     uint16_t            len;
     uint8_t             is_notify;
 } btgatt_notify_params_t;
@@ -105,13 +105,13 @@ typedef void (*search_result_callback)( int conn_id, btgatt_srvc_id_t *srvc_id);
 
 /** GATT characteristic enumeration result callback */
 typedef void (*get_characteristic_callback)(int conn_id, int status,
-                btgatt_srvc_id_t *srvc_id, btgatt_char_id_t *char_id,
+                btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id,
                 int char_prop);
 
 /** GATT descriptor enumeration result callback */
 typedef void (*get_descriptor_callback)(int conn_id, int status,
-                btgatt_srvc_id_t *srvc_id, btgatt_char_id_t *char_id,
-                bt_uuid_t *descr_id);
+                btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id,
+                btgatt_gatt_id_t *descr_id);
 
 /** GATT included service enumeration result callback */
 typedef void (*get_included_service_callback)(int conn_id, int status,
@@ -120,7 +120,7 @@ typedef void (*get_included_service_callback)(int conn_id, int status,
 /** Callback invoked in response to [de]register_for_notification */
 typedef void (*register_for_notification_callback)(int conn_id,
                 int registered, int status, btgatt_srvc_id_t *srvc_id,
-                btgatt_char_id_t *char_id);
+                btgatt_gatt_id_t *char_id);
 
 /**
  * Remote device notification callback, invoked when a remote device sends
@@ -151,6 +151,11 @@ typedef void (*write_descriptor_callback)(int conn_id, int status,
 typedef void (*read_remote_rssi_callback)(int client_if, bt_bdaddr_t* bda,
                                           int rssi, int status);
 
+/**
+ * Callback indicationg the status of a listen() operation
+ */
+typedef void (*listen_callback)(int status, int server_if);
+
 typedef struct {
     register_client_callback            register_client_cb;
     scan_result_callback                scan_result_cb;
@@ -169,6 +174,7 @@ typedef struct {
     write_descriptor_callback           write_descriptor_cb;
     execute_write_callback              execute_write_cb;
     read_remote_rssi_callback           read_remote_rssi_cb;
+    listen_callback                     listen_cb;
 } btgatt_client_callbacks_t;
 
 /** Represents the standard BT-GATT client interface. */
@@ -191,6 +197,9 @@ typedef struct {
     bt_status_t (*disconnect)( int client_if, const bt_bdaddr_t *bd_addr,
                     int conn_id);
 
+    /** Start or stop advertisements to listen for incoming connections */
+    bt_status_t (*listen)(int client_if, bool start);
+
     /** Clear the attribute cache for a given device */
     bt_status_t (*refresh)( int client_if, const bt_bdaddr_t *bd_addr );
 
@@ -212,36 +221,36 @@ typedef struct {
      * Set start_char_id to NULL to get the first characteristic.
      */
     bt_status_t (*get_characteristic)( int conn_id,
-                    btgatt_srvc_id_t *srvc_id, btgatt_char_id_t *start_char_id);
+                    btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *start_char_id);
 
     /**
      * Enumerate descriptors for a given characteristic.
      * Set start_descr_id to NULL to get the first descriptor.
      */
     bt_status_t (*get_descriptor)( int conn_id,
-                    btgatt_srvc_id_t *srvc_id, btgatt_char_id_t *char_id,
-                    bt_uuid_t *start_descr_id);
+                    btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id,
+                    btgatt_gatt_id_t *start_descr_id);
 
     /** Read a characteristic on a remote device */
     bt_status_t (*read_characteristic)( int conn_id,
-                    btgatt_srvc_id_t *srvc_id, btgatt_char_id_t *char_id,
+                    btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id,
                     int auth_req );
 
     /** Write a remote characteristic */
     bt_status_t (*write_characteristic)(int conn_id,
-                    btgatt_srvc_id_t *srvc_id, btgatt_char_id_t *char_id,
+                    btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id,
                     int write_type, int len, int auth_req,
                     char* p_value);
 
     /** Read the descriptor for a given characteristic */
     bt_status_t (*read_descriptor)(int conn_id,
-                    btgatt_srvc_id_t *srvc_id, btgatt_char_id_t *char_id,
-                    bt_uuid_t *descr_id, int auth_req);
+                    btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id,
+                    btgatt_gatt_id_t *descr_id, int auth_req);
 
     /** Write a remote descriptor for a given characteristic */
     bt_status_t (*write_descriptor)( int conn_id,
-                    btgatt_srvc_id_t *srvc_id, btgatt_char_id_t *char_id,
-                    bt_uuid_t *descr_id, int write_type, int len,
+                    btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id,
+                    btgatt_gatt_id_t *descr_id, int write_type, int len,
                     int auth_req, char* p_value);
 
     /** Execute a prepared write operation */
@@ -253,12 +262,12 @@ typedef struct {
      */
     bt_status_t (*register_for_notification)( int client_if,
                     const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
-                    btgatt_char_id_t *char_id);
+                    btgatt_gatt_id_t *char_id);
 
     /** Deregister a previous request for notifications/indications */
     bt_status_t (*deregister_for_notification)( int client_if,
                     const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id,
-                    btgatt_char_id_t *char_id);
+                    btgatt_gatt_id_t *char_id);
 
     /** Request RSSI for a given remote device */
     bt_status_t (*read_remote_rssi)( int client_if, const bt_bdaddr_t *bd_addr);
@@ -266,6 +275,11 @@ typedef struct {
     /** Determine the type of the remote device (LE, BR/EDR, Dual-mode) */
     int (*get_device_type)( const bt_bdaddr_t *bd_addr );
 
+    /** Set the advertising data or scan response data */
+    bt_status_t (*set_adv_data)(int server_if, bool set_scan_rsp, bool include_name,
+                    bool include_txpower, int min_interval, int max_interval, int appearance,
+                    uint16_t manufacturer_len, char* manufacturer_data);
+
     /** Test mode interface */
     bt_status_t (*test_command)( int command, btgatt_test_params_t* params);
 } btgatt_client_interface_t;
index fee9bb5..0ac217e 100644 (file)
@@ -29,17 +29,17 @@ __BEGIN_DECLS
 #define BTGATT_SERVICE_TYPE_PRIMARY 0
 #define BTGATT_SERVICE_TYPE_SECONDARY 1
 
-/** GATT Characteristic ID adding instance id tracking to the UUID */
+/** GATT ID adding instance id tracking to the UUID */
 typedef struct
 {
     bt_uuid_t           uuid;
     uint8_t             inst_id;
-} btgatt_char_id_t;
+} btgatt_gatt_id_t;
 
 /** GATT Service ID also identifies the service type (primary/secondary) */
 typedef struct
 {
-    btgatt_char_id_t    id;
+    btgatt_gatt_id_t    id;
     uint8_t             is_primary;
 } btgatt_srvc_id_t;
 
index 952652e..d455543 100644 (file)
@@ -30,6 +30,13 @@ __BEGIN_DECLS
 typedef uint8_t btrc_uid_t[BTRC_UID_SIZE];
 
 typedef enum {
+    BTRC_FEAT_NONE = 0x00,    /* AVRCP 1.0 */
+    BTRC_FEAT_METADATA = 0x01,    /* AVRCP 1.3 */
+    BTRC_FEAT_ABSOLUTE_VOLUME = 0x02,    /* Supports TG role and volume sync */
+    BTRC_FEAT_BROWSE = 0x04,    /* AVRCP 1.4 and up, with Browsing support */
+} btrc_remote_features_t;
+
+typedef enum {
     BTRC_PLAYSTATE_STOPPED = 0x00,    /* Stopped */
     BTRC_PLAYSTATE_PLAYING = 0x01,    /* Playing */
     BTRC_PLAYSTATE_PAUSED = 0x02,    /* Paused  */
@@ -114,6 +121,10 @@ typedef struct {
     uint8_t text[BTRC_MAX_ATTR_STR_LEN];
 } btrc_element_attr_val_t;
 
+/** Callback for the controller's supported feautres */
+typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr,
+                                                      btrc_remote_features_t features);
+
 /** Callback for play status request */
 typedef void (* btrc_get_play_status_callback)();
 
@@ -151,10 +162,20 @@ typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_at
 */
 typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
 
+/* AVRCP 1.4 Enhancements */
+/** Callback for volume change on CT
+**  volume: Current volume setting on the CT (0-127)
+*/
+typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype);
+
+/** Callback for passthrough commands */
+typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
+
 /** BT-RC callback structure. */
 typedef struct {
     /** set to sizeof(BtRcCallbacks) */
     size_t      size;
+    btrc_remote_features_callback               remote_features_cb;
     btrc_get_play_status_callback               get_play_status_cb;
     btrc_list_player_app_attr_callback          list_player_app_attr_cb;
     btrc_list_player_app_values_callback        list_player_app_values_cb;
@@ -164,6 +185,8 @@ typedef struct {
     btrc_set_player_app_value_callback          set_player_app_value_cb;
     btrc_get_element_attr_callback              get_element_attr_cb;
     btrc_register_notification_callback         register_notification_cb;
+    btrc_volume_change_callback                 volume_change_cb;
+    btrc_passthrough_cmd_callback               passthrough_cmd_cb;
 } btrc_callbacks_t;
 
 /** Represents the standard BT-RC interface. */
@@ -225,6 +248,15 @@ typedef struct {
                                              btrc_notification_type_t type,
                                              btrc_register_notification_t *p_param);
 
+    /* AVRCP 1.4 enhancements */
+
+    /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume
+    ** This can be enhanced to support Relative Volume (AVRCP 1.0).
+    ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
+    ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
+    */
+    bt_status_t (*set_volume)(uint8_t volume);
+
     /** Closes the interface. */
     void  (*cleanup)( void );
 } btrc_interface_t;