Home | History | Annotate | Download | only in hardware
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      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
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     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.
     15  */
     16 
     17 #ifndef ANDROID_INCLUDE_BT_HL_H
     18 #define ANDROID_INCLUDE_BT_HL_H
     19 
     20 __BEGIN_DECLS
     21 
     22 /* HL connection states */
     23 
     24 typedef enum { BTHL_MDEP_ROLE_SOURCE, BTHL_MDEP_ROLE_SINK } bthl_mdep_role_t;
     25 
     26 typedef enum {
     27   BTHL_APP_REG_STATE_REG_SUCCESS,
     28   BTHL_APP_REG_STATE_REG_FAILED,
     29   BTHL_APP_REG_STATE_DEREG_SUCCESS,
     30   BTHL_APP_REG_STATE_DEREG_FAILED
     31 } bthl_app_reg_state_t;
     32 
     33 typedef enum {
     34   BTHL_CHANNEL_TYPE_RELIABLE,
     35   BTHL_CHANNEL_TYPE_STREAMING,
     36   BTHL_CHANNEL_TYPE_ANY
     37 } bthl_channel_type_t;
     38 
     39 /* HL connection states */
     40 typedef enum {
     41   BTHL_CONN_STATE_CONNECTING,
     42   BTHL_CONN_STATE_CONNECTED,
     43   BTHL_CONN_STATE_DISCONNECTING,
     44   BTHL_CONN_STATE_DISCONNECTED,
     45   BTHL_CONN_STATE_DESTROYED
     46 } bthl_channel_state_t;
     47 
     48 typedef struct {
     49   bthl_mdep_role_t mdep_role;
     50   int data_type;
     51   bthl_channel_type_t channel_type;
     52   const char* mdep_description; /* MDEP description to be used in the SDP
     53                                    (optional); null terminated */
     54 } bthl_mdep_cfg_t;
     55 
     56 typedef struct {
     57   const char* application_name;
     58   const char*
     59       provider_name;    /* provider name to be used in the SDP (optional); null
     60                            terminated */
     61   const char* srv_name; /* service name to be used in the SDP (optional); null
     62                            terminated*/
     63   const char*
     64       srv_desp; /* service description to be used in the SDP (optional); null
     65                    terminated */
     66   int number_of_mdeps;
     67   bthl_mdep_cfg_t* mdep_cfg; /* Dynamic array */
     68 } bthl_reg_param_t;
     69 
     70 /** Callback for application registration status.
     71  *  state will have one of the values from  bthl_app_reg_state_t
     72  */
     73 typedef void (*bthl_app_reg_state_callback)(int app_id,
     74                                             bthl_app_reg_state_t state);
     75 
     76 /** Callback for channel connection state change.
     77  *  state will have one of the values from
     78  *  bthl_connection_state_t and fd (file descriptor)
     79  */
     80 typedef void (*bthl_channel_state_callback)(int app_id, RawAddress* bd_addr,
     81                                             int mdep_cfg_index, int channel_id,
     82                                             bthl_channel_state_t state, int fd);
     83 
     84 /** BT-HL callback structure. */
     85 typedef struct {
     86   /** set to sizeof(bthl_callbacks_t) */
     87   size_t size;
     88   bthl_app_reg_state_callback app_reg_state_cb;
     89   bthl_channel_state_callback channel_state_cb;
     90 } bthl_callbacks_t;
     91 
     92 /** Represents the standard BT-HL interface. */
     93 typedef struct {
     94   /** set to sizeof(bthl_interface_t)  */
     95   size_t size;
     96 
     97   /**
     98    * Register the Bthl callbacks
     99    */
    100   bt_status_t (*init)(bthl_callbacks_t* callbacks);
    101 
    102   /** Register HL application */
    103   bt_status_t (*register_application)(bthl_reg_param_t* p_reg_param,
    104                                       int* app_id);
    105 
    106   /** Unregister HL application */
    107   bt_status_t (*unregister_application)(int app_id);
    108 
    109   /** connect channel */
    110   bt_status_t (*connect_channel)(int app_id, RawAddress* bd_addr,
    111                                  int mdep_cfg_index, int* channel_id);
    112 
    113   /** destroy channel */
    114   bt_status_t (*destroy_channel)(int channel_id);
    115 
    116   /** Close the  Bthl callback **/
    117   void (*cleanup)(void);
    118 
    119 } bthl_interface_t;
    120 __END_DECLS
    121 
    122 #endif /* ANDROID_INCLUDE_BT_HL_H */
    123