Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright 2009-2012 Broadcom Corporation
      4  *
      5  *  Licensed under the Apache License, Version 2.0 (the "License");
      6  *  you may not use this file except in compliance with the License.
      7  *  You may obtain a copy of the License at:
      8  *
      9  *  http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  ******************************************************************************/
     18 
     19 /******************************************************************************
     20  *
     21  *  This is the public interface file for the HeaLth device profile (HL)
     22  *  subsystem of BTA, Broadcom's Bluetooth application layer for mobile
     23  *  phones.
     24  *
     25  ******************************************************************************/
     26 #ifndef BTA_HL_API_H
     27 #define BTA_HL_API_H
     28 
     29 #include "bta_api.h"
     30 #include "btm_api.h"
     31 #include "mca_api.h"
     32 
     33 /*****************************************************************************
     34  *  Constants and data types
     35  ****************************************************************************/
     36 /* Extra Debug Code */
     37 #ifndef BTA_HL_DEBUG
     38 #define BTA_HL_DEBUG TRUE
     39 #endif
     40 
     41 #ifndef BTA_HL_NUM_APPS
     42 #define BTA_HL_NUM_APPS 12
     43 #endif
     44 
     45 #ifndef BTA_HL_NUM_MDEPS
     46 #define BTA_HL_NUM_MDEPS 13
     47 #endif
     48 
     49 #ifndef BTA_HL_NUM_MCLS
     50 #define BTA_HL_NUM_MCLS 7
     51 #endif
     52 
     53 #ifndef BTA_HL_NUM_MDLS_PER_MDEP
     54 #define BTA_HL_NUM_MDLS_PER_MDEP 4
     55 #endif
     56 
     57 #ifndef BTA_HL_NUM_MDLS_PER_MCL
     58 #define BTA_HL_NUM_MDLS_PER_MCL 10
     59 #endif
     60 
     61 #ifndef BTA_HL_NUM_DATA_TYPES
     62 #define BTA_HL_NUM_DATA_TYPES                        \
     63   5 /* maximum number of data types can be supported \
     64        per MDEP ID */
     65 #endif
     66 
     67 #define BTA_HL_MCAP_RSP_TOUT 2 /* 2 seconds */
     68 
     69 #ifndef BTA_HL_CCH_NUM_FILTER_ELEMS
     70 #define BTA_HL_CCH_NUM_FILTER_ELEMS 3
     71 #endif
     72 
     73 #ifndef BTA_HL_NUM_SDP_CBACKS
     74 #define BTA_HL_NUM_SDP_CBACKS 7
     75 #endif
     76 
     77 #ifndef BTA_HL_NUM_SDP_RECS
     78 #define BTA_HL_NUM_SDP_RECS 5
     79 #endif
     80 
     81 #ifndef BTA_HL_NUM_SDP_MDEPS
     82 #define BTA_HL_NUM_SDP_MDEPS 12
     83 #endif
     84 
     85 #ifndef BTA_HL_NUM_SVC_ELEMS
     86 #define BTA_HL_NUM_SVC_ELEMS 2
     87 #endif
     88 
     89 #ifndef BTA_HL_NUM_PROTO_ELEMS
     90 #define BTA_HL_NUM_PROTO_ELEMS 2
     91 #endif
     92 
     93 #define BTA_HL_VERSION 0x0101
     94 #define BTA_HL_NUM_ADD_PROTO_LISTS 1
     95 #define BTA_HL_NUM_ADD_PROTO_ELEMS 2
     96 #define BTA_HL_MDEP_SEQ_SIZE 20
     97 #define BTA_HL_VAL_ARRY_SIZE 320
     98 
     99 #ifndef BTA_HL_NUM_MDL_CFGS
    100 #define BTA_HL_NUM_MDL_CFGS \
    101   16 /* numer of MDL cfg saved in the persistent memory*/
    102 #endif
    103 
    104 #define BTA_HL_NUM_TIMERS 7
    105 
    106 #define BTA_HL_CCH_RSP_TOUT 2000
    107 #define BTA_HL_MAX_TIME 255
    108 #define BTA_HL_MIN_TIME 1
    109 #define BTA_HL_INVALID_APP_HANDLE 0xFF
    110 #define BTA_HL_INVALID_MCL_HANDLE 0xFF
    111 #define BTA_HL_INVALID_MDL_HANDLE 0xFFFF
    112 
    113 #define BTA_HL_STATUS_OK 0
    114 #define BTA_HL_STATUS_FAIL 1 /* Used to pass all other errors */
    115 #define BTA_HL_STATUS_ABORTED 2
    116 #define BTA_HL_STATUS_NO_RESOURCE 3
    117 #define BTA_HL_STATUS_LAST_ITEM 4
    118 #define BTA_HL_STATUS_DUPLICATE_APP_ID 5
    119 #define BTA_HL_STATUS_INVALID_APP_HANDLE 6
    120 #define BTA_HL_STATUS_INVALID_MCL_HANDLE 7
    121 #define BTA_HL_STATUS_MCAP_REG_FAIL 8
    122 #define BTA_HL_STATUS_MDEP_CO_FAIL 9
    123 #define BTA_HL_STATUS_ECHO_CO_FAIL 10
    124 #define BTA_HL_STATUS_MDL_CFG_CO_FAIL 11
    125 #define BTA_HL_STATUS_SDP_NO_RESOURCE 12
    126 #define BTA_HL_STATUS_SDP_FAIL 13
    127 #define BTA_HL_STATUS_NO_CCH 14
    128 #define BTA_HL_STATUS_NO_MCL 15
    129 
    130 #define BTA_HL_STATUS_NO_FIRST_RELIABLE 17
    131 #define BTA_HL_STATUS_INVALID_DCH_CFG 18
    132 #define BTA_HL_STATUS_INVALID_MDL_HANDLE 19
    133 #define BTA_HL_STATUS_INVALID_BD_ADDR 20
    134 #define BTA_HL_STATUS_INVALID_RECONNECT_CFG 21
    135 #define BTA_HL_STATUS_ECHO_TEST_BUSY 22
    136 #define BTA_HL_STATUS_INVALID_LOCAL_MDEP_ID 23
    137 #define BTA_HL_STATUS_INVALID_MDL_ID 24
    138 #define BTA_HL_STATUS_NO_MDL_ID_FOUND 25
    139 #define BTA_HL_STATUS_DCH_BUSY 26 /* DCH is congested*/
    140 #define BTA_HL_STATUS_INVALID_CTRL_PSM 27
    141 #define BTA_HL_STATUS_DUPLICATE_CCH_OPEN 28
    142 
    143 typedef uint8_t tBTA_HL_STATUS;
    144 typedef tMCA_HANDLE tBTA_HL_APP_HANDLE;
    145 typedef tMCA_CL tBTA_HL_MCL_HANDLE;
    146 typedef tMCA_DL tBTA_HL_MDL_HANDLE;
    147 enum {
    148   BTA_HL_DEVICE_TYPE_SINK,
    149   BTA_HL_DEVICE_TYPE_SOURCE,
    150   BTA_HL_DEVICE_TYPE_DUAL
    151 };
    152 
    153 typedef uint8_t tBTA_HL_DEVICE_TYPE;
    154 
    155 #define BTA_HL_SDP_IEEE_11073_20601 0x01
    156 
    157 #define BTA_HL_MCAP_SUP_RECONNECT_MASK_INIT 2   /* 0x02 */
    158 #define BTA_HL_MCAP_SUP_RECONNECT_MASK_ACCEPT 4 /* 0x04 */
    159 #define BTA_HL_MCAP_SUP_CSP_MASK_SYNC_SLAVE 0   /* 0x08 */
    160 #define BTA_HL_MCAP_SUP_CSP_MASK_SYNC_MASTER 0  /* 0x10 */
    161 
    162 #define BTA_HL_MCAP_SUP_PROC_MASK          \
    163   (BTA_HL_MCAP_SUP_RECONNECT_MASK_INIT |   \
    164    BTA_HL_MCAP_SUP_RECONNECT_MASK_ACCEPT | \
    165    BTA_HL_MCAP_SUP_CSP_MASK_SYNC_SLAVE | BTA_HL_MCAP_SUP_CSP_MASK_SYNC_MASTER)
    166 #define BTA_HL_MDEP_ROLE_SOURCE 0x00
    167 #define BTA_HL_MDEP_ROLE_SINK 0x01
    168 
    169 typedef uint8_t tBTA_HL_MDEP_ROLE;
    170 
    171 #define BTA_HL_MDEP_ROLE_MASK_SOURCE 0x01 /* bit mask */
    172 #define BTA_HL_MDEP_ROLE_MASK_SINK 0x02
    173 typedef uint8_t tBTA_HL_MDEP_ROLE_MASK;
    174 
    175 #define BTA_HL_ECHO_TEST_MDEP_ID 0
    176 #define BTA_HL_ECHO_TEST_MDEP_CFG_IDX 0
    177 
    178 #define BTA_HL_INVALID_MDEP_ID 0xFF
    179 typedef tMCA_DEP tBTA_HL_MDEP_ID; /* 0 is for echo test,
    180                                    0x01-0x7F availave for use,
    181                                    0x80-0xFF reserved*/
    182 
    183 #define BTA_HL_DELETE_ALL_MDL_IDS 0xFFFF
    184 #define BTA_HL_MAX_MDL_VAL 0xFEFF
    185 typedef uint16_t tBTA_HL_MDL_ID; /* 0x0000 reserved,
    186                                   0x0001-0xFEFF dynamic range,
    187                                   0xFF00-0xFFFE reserved,
    188                                   0xFFFF indicates all MDLs*/
    189 
    190 #define BTA_HL_MDEP_DESP_LEN 35
    191 
    192 #define BTA_HL_DCH_MODE_RELIABLE 0
    193 #define BTA_HL_DCH_MODE_STREAMING 1
    194 
    195 typedef uint8_t tBTA_HL_DCH_MODE;
    196 
    197 #define BTA_HL_DCH_CFG_NO_PREF 0
    198 #define BTA_HL_DCH_CFG_RELIABLE 1
    199 #define BTA_HL_DCH_CFG_STREAMING 2
    200 #define BTA_HL_DCH_CFG_UNKNOWN 0xFF
    201 
    202 typedef uint8_t tBTA_HL_DCH_CFG;
    203 
    204 /* The Default DCH CFG for the echo test when the device is a Source */
    205 #define BTA_HL_DEFAULT_ECHO_TEST_SRC_DCH_CFG BTA_HL_DCH_CFG_RELIABLE
    206 
    207 #define BTA_HL_DCH_CREATE_RSP_SUCCESS 0
    208 #define BTA_HL_DCH_CREATE_RSP_CFG_REJ 1
    209 
    210 typedef uint8_t tBTA_HL_DCH_CREATE_RSP;
    211 
    212 #define BTA_HL_MCAP_SUP_PROC_RECONNECT_INIT 0x02
    213 #define BTA_HL_MCAP_SUP_PROC_RECONNECT_APT 0x04
    214 #define BTA_HL_MCAP_SUP_PROC_CSP_SLAVE 0x08
    215 #define BTA_HL_MCAP_SUP_PROC_CSP_MASTER 0x10
    216 
    217 typedef uint8_t tBTA_HL_SUP_PROC_MASK;
    218 
    219 typedef struct {
    220   uint16_t max_rx_apdu_size; /* local rcv MTU */
    221   uint16_t max_tx_apdu_size; /* maximum TX APDU size*/
    222 } tBTA_HL_ECHO_CFG;
    223 
    224 typedef struct {
    225   uint16_t data_type;
    226   uint16_t max_rx_apdu_size; /* local rcv MTU */
    227   uint16_t max_tx_apdu_size; /* maximum TX APDU size*/
    228   char desp[BTA_HL_MDEP_DESP_LEN + 1];
    229 } tBTA_HL_MDEP_DATA_TYPE_CFG;
    230 
    231 typedef struct {
    232   tBTA_HL_MDEP_ROLE mdep_role;
    233   uint8_t num_of_mdep_data_types;
    234   tBTA_HL_MDEP_DATA_TYPE_CFG data_cfg[BTA_HL_NUM_DATA_TYPES];
    235 } tBTA_HL_MDEP_CFG;
    236 
    237 typedef struct {
    238   tBTA_HL_MDEP_ID mdep_id; /* MDEP ID 0x01-0x7F */
    239   tBTA_HL_MDEP_CFG mdep_cfg;
    240   uint8_t ori_app_id;
    241 } tBTA_HL_MDEP;
    242 
    243 typedef struct {
    244   tBTA_HL_MDEP mdep[BTA_HL_NUM_MDEPS];
    245   tBTA_HL_ECHO_CFG echo_cfg;
    246   tBTA_HL_MDEP_ROLE_MASK app_role_mask;
    247   bool advertize_source_sdp;
    248   uint8_t num_of_mdeps;
    249 } tBTA_HL_SUP_FEATURE;
    250 
    251 typedef struct {
    252   bool delete_req_pending;
    253   tBTA_HL_MDL_ID mdl_id;
    254   tBTA_HL_MCL_HANDLE mcl_handle;
    255 } tBTA_HL_DELETE_MDL;
    256 
    257 typedef struct {
    258   uint8_t time;
    259   uint16_t mtu;
    260   tBTA_HL_MDL_ID mdl_id;
    261   tBTA_HL_MDEP_ID local_mdep_id;
    262   tBTA_HL_MDEP_ROLE local_mdep_role;
    263   bool active; /* true if this item is in use */
    264   tBTA_HL_DCH_MODE dch_mode;
    265   uint8_t fcs;
    266   RawAddress peer_bd_addr;
    267 } tBTA_HL_MDL_CFG;
    268 
    269 /* Maximum number of supported feature list items (list_elem in
    270  * tSDP_SUP_FEATURE_ELEM) */
    271 #define BTA_HL_NUM_SUP_FEATURE_ELEMS 13
    272 #define BTA_HL_SUP_FEATURE_SDP_BUF_SIZE 512
    273 /* This structure is used to add supported feature lists and find supported
    274  * feature elements */
    275 typedef struct {
    276   uint8_t mdep_id;
    277   uint16_t data_type;
    278   tBTA_HL_MDEP_ROLE mdep_role;
    279   char* p_mdep_desp;
    280 } tBTA_HL_SUP_FEATURE_ELEM;
    281 
    282 typedef struct {
    283   uint16_t num_elems;
    284   tBTA_HL_SUP_FEATURE_ELEM list_elem[BTA_HL_NUM_SUP_FEATURE_ELEMS];
    285 } tBTA_HL_SUP_FEATURE_LIST_ELEM;
    286 
    287 typedef struct {
    288   tBTA_HL_DEVICE_TYPE dev_type; /* sink, source or dual roles */
    289   tBTA_SEC sec_mask;            /* security mask for accepting conenction*/
    290   const char*
    291       p_srv_name; /* service name to be used in the SDP; null terminated*/
    292   const char* p_srv_desp; /* service description to be used in the SDP; null
    293                              terminated */
    294   const char*
    295       p_provider_name; /* provide name to be used in the SDP; null terminated */
    296 } tBTA_HL_REG_PARAM;
    297 
    298 typedef struct {
    299   uint16_t ctrl_psm;
    300   RawAddress bd_addr; /* Address of peer device */
    301   tBTA_SEC sec_mask; /* security mask for initiating connection*/
    302 } tBTA_HL_CCH_OPEN_PARAM;
    303 
    304 typedef struct {
    305   uint16_t ctrl_psm;
    306   tBTA_HL_MDEP_ID local_mdep_id; /* local MDEP ID */
    307   tBTA_HL_MDEP_ID peer_mdep_id;  /* peer mdep id */
    308   tBTA_HL_DCH_CFG local_cfg;
    309   tBTA_SEC sec_mask; /* security mask for initiating connection*/
    310 } tBTA_HL_DCH_OPEN_PARAM;
    311 
    312 typedef struct {
    313   uint16_t ctrl_psm;
    314   tBTA_HL_MDL_ID mdl_id;
    315 } tBTA_HL_DCH_RECONNECT_PARAM;
    316 
    317 typedef struct {
    318   uint16_t ctrl_psm;
    319   uint16_t pkt_size;
    320   tBTA_HL_DCH_CFG local_cfg;
    321 } tBTA_HL_DCH_ECHO_TEST_PARAM;
    322 
    323 typedef struct {
    324   uint16_t buf_size;
    325   uint8_t p_buf; /* buffer pointer */
    326 } tBTA_HL_DCH_BUF_INFO;
    327 
    328 typedef struct {
    329   tBTA_HL_MDEP_ID local_mdep_id; /* local MDEP ID */
    330   tBTA_HL_MDL_ID mdl_id;
    331   tBTA_HL_DCH_CREATE_RSP rsp_code;
    332   tBTA_HL_DCH_CFG cfg_rsp;
    333 } tBTA_HL_DCH_CREATE_RSP_PARAM;
    334 
    335 typedef struct {
    336   uint16_t data_type;
    337   uint8_t mdep_id;
    338   tBTA_HL_MDEP_ROLE mdep_role;
    339   char mdep_desp[BTA_HL_MDEP_DESP_LEN + 1];
    340 } tBTA_HL_SDP_MDEP_CFG;
    341 
    342 typedef struct {
    343   uint16_t ctrl_psm;
    344   uint16_t data_psm;
    345   uint8_t mcap_sup_proc;
    346   uint8_t num_mdeps; /* number of mdep elements from SDP*/
    347   char srv_name[BTA_SERVICE_NAME_LEN + 1];
    348   char srv_desp[BTA_SERVICE_DESP_LEN + 1];
    349   char provider_name[BTA_PROVIDER_NAME_LEN + 1];
    350   tBTA_HL_SDP_MDEP_CFG mdep_cfg[BTA_HL_NUM_SDP_MDEPS];
    351 } tBTA_HL_SDP_REC;
    352 
    353 typedef struct {
    354   uint8_t num_recs;
    355   tBTA_HL_SDP_REC sdp_rec[BTA_HL_NUM_SDP_RECS];
    356 } tBTA_HL_SDP;
    357 
    358 /* HL control callback function events */
    359 enum { BTA_HL_CTRL_ENABLE_CFM_EVT = 0, BTA_HL_CTRL_DISABLE_CFM_EVT };
    360 typedef uint8_t tBTA_HL_CTRL_EVT;
    361 /* Structure associated with BTA_HL_ENABLE_EVT
    362    BTA_HL_DISABLE_EVT */
    363 
    364 typedef struct { tBTA_HL_STATUS status; } tBTA_HL_CTRL_ENABLE_DISABLE;
    365 
    366 typedef union {
    367   tBTA_HL_CTRL_ENABLE_DISABLE enable_cfm;
    368   tBTA_HL_CTRL_ENABLE_DISABLE disable_cfm;
    369 } tBTA_HL_CTRL;
    370 
    371 /* HL instance callback function events */
    372 enum {
    373   BTA_HL_REGISTER_CFM_EVT = 0,
    374   BTA_HL_DEREGISTER_CFM_EVT,
    375   BTA_HL_CCH_OPEN_IND_EVT,
    376   BTA_HL_CCH_OPEN_CFM_EVT,
    377   BTA_HL_CCH_CLOSE_IND_EVT,
    378   BTA_HL_CCH_CLOSE_CFM_EVT,
    379   BTA_HL_DCH_CREATE_IND_EVT,
    380   BTA_HL_DCH_OPEN_IND_EVT,
    381   BTA_HL_DCH_OPEN_CFM_EVT,
    382   BTA_HL_DCH_CLOSE_IND_EVT,
    383   BTA_HL_DCH_CLOSE_CFM_EVT,
    384   BTA_HL_DCH_RECONNECT_IND_EVT,
    385   BTA_HL_DCH_RECONNECT_CFM_EVT,
    386 
    387   BTA_HL_DCH_ABORT_IND_EVT,
    388   BTA_HL_DCH_ABORT_CFM_EVT,
    389   BTA_HL_DELETE_MDL_IND_EVT,
    390   BTA_HL_DELETE_MDL_CFM_EVT,
    391   BTA_HL_DCH_SEND_DATA_CFM_EVT,
    392   BTA_HL_DCH_RCV_DATA_IND_EVT,
    393   BTA_HL_CONG_CHG_IND_EVT,
    394   BTA_HL_DCH_ECHO_TEST_CFM_EVT,
    395   BTA_HL_SDP_QUERY_CFM_EVT,
    396   BTA_HL_SDP_INFO_IND_EVT
    397 };
    398 typedef uint8_t tBTA_HL_EVT;
    399 
    400 typedef struct {
    401   tBTA_HL_STATUS status; /* start status */
    402   uint8_t app_id;
    403   tBTA_HL_APP_HANDLE app_handle;
    404 } tBTA_HL_REGISTER_CFM;
    405 
    406 typedef struct {
    407   tBTA_HL_STATUS status; /* start status */
    408   uint8_t app_id;
    409   tBTA_HL_APP_HANDLE app_handle;
    410 } tBTA_HL_DEREGISTER_CFM;
    411 
    412 typedef struct {
    413   bool intentional;
    414   tBTA_HL_MCL_HANDLE mcl_handle;
    415   tBTA_HL_APP_HANDLE app_handle;
    416 } tBTA_HL_CCH_CLOSE_IND;
    417 
    418 typedef struct {
    419   tBTA_HL_MCL_HANDLE mcl_handle;
    420   tBTA_HL_APP_HANDLE app_handle;
    421 } tBTA_HL_MCL_IND;
    422 
    423 typedef struct {
    424   tBTA_HL_STATUS status; /* connection status */
    425   tBTA_HL_MCL_HANDLE mcl_handle;
    426   tBTA_HL_APP_HANDLE app_handle;
    427 } tBTA_HL_MCL_CFM;
    428 
    429 typedef struct {
    430   tBTA_HL_MCL_HANDLE mcl_handle;
    431   tBTA_HL_APP_HANDLE app_handle;
    432   RawAddress bd_addr; /* address of peer device */
    433 } tBTA_HL_CCH_OPEN_IND;
    434 
    435 typedef struct {
    436   tBTA_HL_STATUS status; /* connection status */
    437   uint8_t app_id;
    438   tBTA_HL_MCL_HANDLE mcl_handle;
    439   tBTA_HL_APP_HANDLE app_handle;
    440   RawAddress bd_addr; /* address of peer device */
    441 } tBTA_HL_CCH_OPEN_CFM;
    442 
    443 typedef struct {
    444   tBTA_HL_MCL_HANDLE mcl_handle;
    445   tBTA_HL_APP_HANDLE app_handle;
    446   tBTA_HL_MDEP_ID local_mdep_id;
    447   tBTA_HL_MDL_ID mdl_id; /* MCAP data link ID for this
    448                             data channel conenction    */
    449   tBTA_HL_DCH_CFG cfg;   /* dch cfg requested by the peer device */
    450   RawAddress bd_addr;    /* address of peer device */
    451 
    452 } tBTA_HL_DCH_CREATE_IND;
    453 
    454 typedef struct {
    455   tBTA_HL_MDL_HANDLE mdl_handle;
    456   tBTA_HL_MCL_HANDLE mcl_handle;
    457   tBTA_HL_APP_HANDLE app_handle;
    458   tBTA_HL_MDEP_ID local_mdep_id;
    459   tBTA_HL_MDL_ID mdl_id;     /* MCAP data link ID for this
    460                                 data channel conenction    */
    461   tBTA_HL_DCH_MODE dch_mode; /* data channel mode - reliable or streaming*/
    462 
    463   bool first_reliable; /* whether this is the first reliable data channel */
    464   uint16_t mtu;
    465 } tBTA_HL_DCH_OPEN_IND;
    466 
    467 typedef struct {
    468   tBTA_HL_STATUS status; /* connection status */
    469   tBTA_HL_MDL_HANDLE mdl_handle;
    470   tBTA_HL_MCL_HANDLE mcl_handle;
    471   tBTA_HL_APP_HANDLE app_handle;
    472   tBTA_HL_MDEP_ID local_mdep_id;
    473   tBTA_HL_MDL_ID mdl_id;     /* MCAP data link ID for this
    474                                 data channel conenction    */
    475   tBTA_HL_DCH_MODE dch_mode; /* data channel mode - reliable or streaming*/
    476   bool first_reliable; /* whether this is the first reliable data channel */
    477   uint16_t mtu;
    478 } tBTA_HL_DCH_OPEN_CFM;
    479 
    480 typedef struct {
    481   bool intentional;
    482   tBTA_HL_MDL_HANDLE mdl_handle;
    483   tBTA_HL_MCL_HANDLE mcl_handle;
    484   tBTA_HL_APP_HANDLE app_handle;
    485 } tBTA_HL_DCH_CLOSE_IND;
    486 
    487 typedef struct {
    488   tBTA_HL_MDL_HANDLE mdl_handle;
    489   tBTA_HL_MCL_HANDLE mcl_handle;
    490   tBTA_HL_APP_HANDLE app_handle;
    491 } tBTA_HL_MDL_IND;
    492 
    493 typedef struct {
    494   tBTA_HL_STATUS status;
    495   tBTA_HL_MDL_HANDLE mdl_handle;
    496   tBTA_HL_MCL_HANDLE mcl_handle;
    497   tBTA_HL_APP_HANDLE app_handle;
    498 } tBTA_HL_MDL_CFM;
    499 
    500 typedef struct {
    501   tBTA_HL_MCL_HANDLE mcl_handle;
    502   tBTA_HL_APP_HANDLE app_handle;
    503   tBTA_HL_MDL_ID mdl_id;
    504 } tBTA_HL_DELETE_MDL_IND;
    505 
    506 typedef struct {
    507   tBTA_HL_STATUS status;
    508   tBTA_HL_MCL_HANDLE mcl_handle;
    509   tBTA_HL_APP_HANDLE app_handle;
    510   tBTA_HL_MDL_ID mdl_id;
    511 } tBTA_HL_DELETE_MDL_CFM;
    512 
    513 typedef struct {
    514   tBTA_HL_MDL_HANDLE mdl_handle;
    515   tBTA_HL_MCL_HANDLE mcl_handle;
    516   tBTA_HL_APP_HANDLE app_handle;
    517   bool cong;
    518 } tBTA_HL_DCH_CONG_IND;
    519 
    520 typedef struct {
    521   tBTA_HL_APP_HANDLE app_handle;
    522   uint16_t ctrl_psm;
    523   uint16_t data_psm;
    524   uint8_t data_x_spec;
    525   uint8_t mcap_sup_procs;
    526 } tBTA_HL_SDP_INFO_IND;
    527 
    528 typedef struct {
    529   tBTA_HL_STATUS status;
    530   uint8_t app_id;
    531   tBTA_HL_APP_HANDLE app_handle;
    532   RawAddress bd_addr;
    533   tBTA_HL_SDP* p_sdp;
    534 } tBTA_HL_SDP_QUERY_CFM;
    535 
    536 typedef union {
    537   tBTA_HL_REGISTER_CFM reg_cfm;
    538   tBTA_HL_DEREGISTER_CFM dereg_cfm;
    539   tBTA_HL_CCH_OPEN_IND cch_open_ind;
    540   tBTA_HL_CCH_OPEN_CFM cch_open_cfm;
    541   tBTA_HL_CCH_CLOSE_IND cch_close_ind;
    542   tBTA_HL_MCL_CFM cch_close_cfm;
    543   tBTA_HL_DCH_CREATE_IND dch_create_ind;
    544   tBTA_HL_DCH_OPEN_IND dch_open_ind;
    545   tBTA_HL_DCH_OPEN_CFM dch_open_cfm;
    546   tBTA_HL_DCH_CLOSE_IND dch_close_ind;
    547   tBTA_HL_MDL_CFM dch_close_cfm;
    548   tBTA_HL_DCH_OPEN_IND dch_reconnect_ind;
    549   tBTA_HL_DCH_OPEN_CFM dch_reconnect_cfm;
    550   tBTA_HL_MCL_IND dch_abort_ind;
    551   tBTA_HL_MCL_CFM dch_abort_cfm;
    552   tBTA_HL_DELETE_MDL_IND delete_mdl_ind;
    553   tBTA_HL_DELETE_MDL_CFM delete_mdl_cfm;
    554   tBTA_HL_MDL_CFM dch_send_data_cfm;
    555   tBTA_HL_MDL_IND dch_rcv_data_ind;
    556   tBTA_HL_DCH_CONG_IND dch_cong_ind;
    557   tBTA_HL_MCL_CFM echo_test_cfm;
    558   tBTA_HL_SDP_QUERY_CFM sdp_query_cfm;
    559   tBTA_HL_SDP_INFO_IND sdp_info_ind;
    560 
    561 } tBTA_HL;
    562 
    563 /* HL callback functions */
    564 typedef void tBTA_HL_CTRL_CBACK(tBTA_HL_CTRL_EVT event, tBTA_HL_CTRL* p_data);
    565 typedef void tBTA_HL_CBACK(tBTA_HL_EVT event, tBTA_HL* p_data);
    566 
    567 /*****************************************************************************
    568  *  External Function Declarations
    569  ****************************************************************************/
    570 
    571 /**************************
    572  *  API Functions
    573  **************************/
    574 
    575 /*******************************************************************************
    576  *
    577  * Function         BTA_HlEnable
    578  *
    579  * Description      Enable the HL subsystems.  This function must be
    580  *                  called before any other functions in the HL API are called.
    581  *                  When the enable operation is completed the callback function
    582  *                  will be called with an BTA_HL_CTRL_ENABLE_CFM_EVT event.
    583  *
    584  * Parameters       p_cback - HL event call back function
    585  *
    586  * Returns          void
    587  *
    588  ******************************************************************************/
    589 extern void BTA_HlEnable(tBTA_HL_CTRL_CBACK* p_ctrl_cback);
    590 /*******************************************************************************
    591  *
    592  * Function         BTA_HlDisable
    593  *
    594  * Description     Disable the HL subsystem.
    595  *
    596  * Returns          void
    597  *
    598  ******************************************************************************/
    599 extern void BTA_HlDisable(void);
    600 
    601 /*******************************************************************************
    602  *
    603  * Function         BTA_HlUpdate
    604  *
    605  * Description      Register an HDP application
    606  *
    607  * Parameters       app_id        - Application ID
    608  *                  p_reg_param   - non-platform related parameters for the
    609  *                                  HDP application
    610  *                  p_cback       - HL event callback fucntion
    611  *
    612  * Returns          void
    613  *
    614  ******************************************************************************/
    615 extern void BTA_HlUpdate(uint8_t app_id, tBTA_HL_REG_PARAM* p_reg_param,
    616                          bool is_register, tBTA_HL_CBACK* p_cback);
    617 
    618 /*******************************************************************************
    619  *
    620  * Function         BTA_HlRegister
    621  *
    622  * Description      Register a HDP application
    623  *
    624  *
    625  * Parameters       app_id        - hdp application ID
    626  *                  p_reg_param   - non-platform related parameters for the
    627  *                                  HDP application
    628  *                  p_cback       - HL event callback fucntion
    629  *
    630  * Returns          void
    631  *
    632  ******************************************************************************/
    633 extern void BTA_HlRegister(uint8_t app_id, tBTA_HL_REG_PARAM* p_reg_param,
    634                            tBTA_HL_CBACK* p_cback);
    635 
    636 /*******************************************************************************
    637  *
    638  * Function         BTA_HlDeregister
    639  *
    640  * Description      Deregister an HDP application
    641  *
    642  * Parameters       app_handle - Application handle
    643  *
    644  * Returns         void
    645  *
    646  ******************************************************************************/
    647 extern void BTA_HlDeregister(uint8_t app_id, tBTA_HL_APP_HANDLE app_handle);
    648 
    649 /*******************************************************************************
    650  *
    651  * Function         BTA_HlCchOpen
    652  *
    653  * Description      Open a Control channel connection with the specified BD
    654  *                  address and the control PSM value is used to select which
    655  *                  HDP insatnce should be used in case the peer device support
    656  *                  multiple HDP instances.
    657  *
    658  *
    659  * Parameters       app_handle - Application Handle
    660  *                  p_open_param - parameters for opening a control channel
    661  *
    662  * Returns          void
    663  *
    664  *                  Note: If the control PSM value is zero then the first HDP
    665  *                        instance is used for the control channel setup
    666  ******************************************************************************/
    667 extern void BTA_HlCchOpen(uint8_t app_id, tBTA_HL_APP_HANDLE app_handle,
    668                           tBTA_HL_CCH_OPEN_PARAM* p_open_param);
    669 
    670 /*******************************************************************************
    671  *
    672  * Function         BTA_HlCchClose
    673  *
    674  * Description      Close a Control channel connection with the specified MCL
    675  *                  handle
    676  *
    677  * Parameters       mcl_handle - MCL handle
    678  *
    679  * Returns          void
    680  *
    681  ******************************************************************************/
    682 extern void BTA_HlCchClose(tBTA_HL_MCL_HANDLE mcl_handle);
    683 
    684 /*******************************************************************************
    685  *
    686  * Function         BTA_HlDchOpen
    687  *
    688  * Description      Open a data channel connection with the specified DCH
    689  *                  parameters
    690  *
    691  * Parameters       mcl_handle - MCL handle
    692  *                  p_open_param - parameters for opening a data channel
    693  *
    694  * Returns          void
    695  *
    696  ******************************************************************************/
    697 extern void BTA_HlDchOpen(tBTA_HL_MCL_HANDLE mcl_handle,
    698                           tBTA_HL_DCH_OPEN_PARAM* p_open_param);
    699 /*******************************************************************************
    700  *
    701  * Function         BTA_HlDchReconnect
    702  *
    703  * Description      Reconnect a data channel with the specified MDL_ID
    704  *
    705  * Parameters       mcl_handle      - MCL handle
    706 *8                  p_recon_param   - parameters for reconnecting a data channel
    707  *
    708  * Returns          void
    709  *
    710  ******************************************************************************/
    711 extern void BTA_HlDchReconnect(tBTA_HL_MCL_HANDLE mcl_handle,
    712                                tBTA_HL_DCH_RECONNECT_PARAM* p_recon_param);
    713 /*******************************************************************************
    714  *
    715  * Function         BTA_HlDchClose
    716  *
    717  * Description      Close a data channel with the specified MDL handle
    718  *
    719  * Parameters       mdl_handle  - MDL handle
    720  *
    721  * Returns          void
    722  *
    723  ******************************************************************************/
    724 extern void BTA_HlDchClose(tBTA_HL_MDL_HANDLE mdl_handle);
    725 
    726 /*******************************************************************************
    727  *
    728  * Function         BTA_HlDchAbort
    729  *
    730  * Description      Abort the current data channel setup with the specified MCL
    731  *                  handle
    732  *
    733  * Parameters       mcl_handle  - MCL handle
    734  *
    735  *
    736  * Returns          void
    737  *
    738  ******************************************************************************/
    739 extern void BTA_HlDchAbort(tBTA_HL_MCL_HANDLE mcl_handle);
    740 
    741 /*******************************************************************************
    742  *
    743  * Function         BTA_HlSendData
    744  *
    745  * Description      Send an APDU to the peer device
    746  *
    747  * Parameters       mdl_handle  - MDL handle
    748  *                  pkt_size    - size of the data packet to be sent
    749  *
    750  * Returns          void
    751  *
    752  ******************************************************************************/
    753 extern void BTA_HlSendData(tBTA_HL_MDL_HANDLE mdl_handle, uint16_t pkt_size);
    754 
    755 /*******************************************************************************
    756  *
    757  * Function         BTA_HlDeleteMdl
    758  *
    759  * Description      Delete the specified MDL_ID within the specified MCL handle
    760  *
    761  * Parameters       mcl_handle  - MCL handle
    762  *                  mdl_id      - MDL ID
    763  *
    764  * Returns          void
    765  *
    766  *                  note: If mdl_id = 0xFFFF then this means to delete all MDLs
    767  *                        and this value can only be used with DeleteMdl request
    768  *                        only not other requests
    769  *
    770  ******************************************************************************/
    771 extern void BTA_HlDeleteMdl(tBTA_HL_MCL_HANDLE mcl_handle,
    772                             tBTA_HL_MDL_ID mdl_id);
    773 
    774 /*******************************************************************************
    775  *
    776  * Function         BTA_HlDchEchoTest
    777  *
    778  * Description      Initiate an echo test with the specified MCL handle
    779  *
    780  * Parameters       mcl_handle           - MCL handle
    781 *8                  p_echo_test_param   -  parameters for echo testing
    782  *
    783  * Returns          void
    784  *
    785  ******************************************************************************/
    786 extern void BTA_HlDchEchoTest(tBTA_HL_MCL_HANDLE mcl_handle,
    787                               tBTA_HL_DCH_ECHO_TEST_PARAM* p_echo_test_param);
    788 
    789 /*******************************************************************************
    790  *
    791  * Function         BTA_HlSdpQuery
    792  *
    793  * Description      SDP query request for the specified BD address
    794  *
    795  * Parameters       app_id
    796                         app_handle      - application handle
    797  *                  bd_addr         - BD address
    798  *
    799  * Returns          void
    800  *
    801  ******************************************************************************/
    802 extern void BTA_HlSdpQuery(uint8_t app_id, tBTA_HL_APP_HANDLE app_handle,
    803                            const RawAddress& bd_addr);
    804 
    805 /*******************************************************************************
    806  *
    807  * Function         BTA_HlDchCreateMdlRsp
    808  *
    809  * Description      Set the Response and configuration values for the Create MDL
    810  *                  request
    811  *
    812  * Parameters       mcl_handle  - MCL handle
    813  *                  p_rsp_param - parameters specified whether the request
    814  *                                should be accepted or not and if it should be
    815  *                                accepted then it also specified the
    816  *                                configuration response value
    817  *
    818  * Returns          void
    819  *
    820  ******************************************************************************/
    821 extern void BTA_HlDchCreateRsp(tBTA_HL_MCL_HANDLE mcl_handle,
    822                                tBTA_HL_DCH_CREATE_RSP_PARAM* p_rsp_param);
    823 
    824 #endif /* BTA_HL_API_H */
    825