15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Copyright (C) 2003-2012 Broadcom Corporation
45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Licensed under the Apache License, Version 2.0 (the "License");
65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  you may not use this file except in compliance with the License.
75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  You may obtain a copy of the License at:
85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  http://www.apache.org/licenses/LICENSE-2.0
105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  Unless required by applicable law or agreed to in writing, software
125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  distributed under the License is distributed on an "AS IS" BASIS,
135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  See the License for the specific language governing permissions and
155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  limitations under the License.
165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/
185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  This file contains the HeaLth device profile (HL) action functions for
225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *  the state machine.
235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *
245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/
255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <string.h>
275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bt_target.h"
295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if defined(HL_INCLUDED) && (HL_INCLUDED == TRUE)
305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "gki.h"
325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "sdp_api.h"
335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_sys.h"
345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "port_api.h"
355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "sdp_api.h"
365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_hl_api.h"
375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_hl_int.h"
385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "utl.h"
395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "mca_defs.h"
405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "mca_api.h"
415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*****************************************************************************
435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**  Local Function prototypes
445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/
455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE && BT_TRACE_VERBOSE == TRUE)
465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic char *bta_hl_mcap_evt_code(UINT8 evt_code);
475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic char *bta_hl_dch_oper_code(tBTA_HL_DCH_OPER oper_code);
485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic char *bta_hl_cback_evt_code(UINT8 evt_code);
495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback(UINT8 sdp_op, UINT8 app_idx, UINT8 mcl_idx,
515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             UINT8 mdl_idx, UINT16 status);
525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback0(UINT16 status);
535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback1(UINT16 status);
545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback2(UINT16 status);
555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback3(UINT16 status);
565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback4(UINT16 status);
575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback5(UINT16 status);
585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback6(UINT16 status);
595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
61ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic tSDP_DISC_CMPL_CB * const bta_hl_sdp_cback_arr[] =
62ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{
635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback0,
645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback1,
655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback2,
665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback3,
675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback4,
685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback5,
695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback6
705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project};
715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_cong_change
775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing congestion change notification
795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_cong_change(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                tBTA_HL_DATA *p_data)
855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_CONG_CHG       *p_cong_chg = &p_data->mca_evt.mca_data.cong_chg;
905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
93e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_cong_change mdl_id=%d cong=%d",
945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      p_cong_chg->mdl_id,
955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      p_cong_chg->cong);
965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    evt_data.dch_cong_ind.cong          =
985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->cong                         = p_cong_chg->cong;
995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    evt_data.dch_cong_ind.mdl_handle    = p_dcb->mdl_handle;
1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    evt_data.dch_cong_ind.mcl_handle    = p_mcb->mcl_handle;
1015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    evt_data.dch_cong_ind.app_handle    = p_acb->app_handle;
1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_acb->p_cback(BTA_HL_CONG_CHG_IND_EVT ,(tBTA_HL *) &evt_data );
1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_echo_test
1115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing echo test request
1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_echo_test(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                          tBTA_HL_DATA *p_data)
1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1235cd8bff2dd0337cb52bf48f312e3d2d55a8882fbMike J. Chen    UNUSED(p_data);
1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
126e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_echo_test");
1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->echo_oper = BTA_HL_ECHO_OP_CI_GET_ECHO_DATA;
1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->cout_oper |= BTA_HL_CO_GET_ECHO_DATA_MASK;
1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_co_get_echo_data(p_acb->app_id, p_mcb->mcl_handle,
1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            p_dcb->p_echo_tx_pkt->len,
1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            BTA_HL_GET_BUF_PTR(p_dcb->p_echo_tx_pkt),
1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            BTA_HL_CI_GET_ECHO_DATA_EVT);
1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_sdp_init
1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing DCH SDP initiation
1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
1475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_sdp_init(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                         tBTA_HL_DATA *p_data)
1495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
154e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_sdp_init");
1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if ( p_mcb->sdp_oper == BTA_HL_SDP_OP_NONE)
1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_mcb->sdp_mdl_idx = mdl_idx;
1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_OPEN )
1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_mcb->sdp_oper = BTA_HL_SDP_OP_DCH_OPEN_INIT;
1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_mcb->sdp_oper = BTA_HL_SDP_OP_DCH_RECONNECT_INIT;
1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (bta_hl_init_sdp(p_mcb->sdp_oper, app_idx, mcl_idx, mdl_idx) != BTA_HL_STATUS_OK)
1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
171e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_ERROR("SDP INIT failed");
1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_mcb->sdp_oper = BTA_HL_SDP_OP_NONE;
1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_SDP_FAIL_EVT, p_data);
1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
178e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati        APPL_TRACE_ERROR("SDP in use");
1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_SDP_FAIL_EVT, p_data);
1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_close_echo_test
1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the closing of echo test
1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_close_echo_test(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                tBTA_HL_DATA *p_data)
1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB          *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
199e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_close_echo_test");
2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (p_dcb->echo_oper)
2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_ECHO_OP_DCH_CLOSE_CFM:
2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_ECHO_OP_OPEN_IND:
2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_ECHO_OP_ECHO_PKT:
2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST;
2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_ECHO_OP_MDL_CREATE_CFM:
2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_ECHO_OP_DCH_OPEN_CFM:
2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_ECHO_OP_LOOP_BACK:
2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (MCA_CloseReq((tMCA_DL) p_dcb->mdl_handle)!= MCA_SUCCESS)
2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_rcv_data
2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the received data
2285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_rcv_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             tBTA_HL_DATA *p_data)
2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
2355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
2365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
2385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
240e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_rcv_data");
2415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
2425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID)
2445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        switch ( p_dcb->echo_oper)
2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
2475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            case  BTA_HL_ECHO_OP_ECHO_PKT:
2485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (MCA_WriteReq((tMCA_DL) p_dcb->mdl_handle, p_data->mca_rcv_data_evt.p_pkt) != MCA_SUCCESS)
2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
2515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    utl_freebuf((void **) &p_data->mca_rcv_data_evt.p_pkt);
2525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_ECHO_TEST_EVT, p_data);
2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
2545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
2555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            case BTA_HL_ECHO_OP_LOOP_BACK:
2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->p_echo_rx_pkt = p_data->mca_rcv_data_evt.p_pkt;
2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->echo_oper = BTA_HL_ECHO_OP_CI_PUT_ECHO_DATA;
2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->cout_oper |= BTA_HL_CO_PUT_ECHO_DATA_MASK;
2605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->ci_put_echo_data_status = BTA_HL_STATUS_FAIL;
2615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_co_put_echo_data(p_acb->app_id, p_mcb->mcl_handle,
2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                        p_dcb->p_echo_rx_pkt->len,
2645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                        BTA_HL_GET_BUF_PTR(p_dcb->p_echo_rx_pkt),
2655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                        BTA_HL_CI_PUT_ECHO_DATA_EVT);
2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
2675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            default:
268e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                APPL_TRACE_ERROR("Unknonw echo_oper=%d",p_dcb->echo_oper);
2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
2705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
2715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
2735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->cout_oper |= BTA_HL_CO_PUT_RX_DATA_MASK;
2765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->p_rx_pkt = p_data->mca_rcv_data_evt.p_pkt;
2775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_co_put_rx_data(p_acb->app_id, p_dcb->mdl_handle,
2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_dcb->p_rx_pkt->len,
2805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              BTA_HL_GET_BUF_PTR(p_dcb->p_rx_pkt),
2815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              BTA_HL_CI_PUT_RX_DATA_EVT);
2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
2895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_ci_put_echo_data
2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the call-in of the
2935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  put echo data event
2945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
2965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
2985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_ci_put_echo_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
2995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 tBTA_HL_DATA *p_data)
3005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
3015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
3025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
304e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_ci_put_echo_data");
3055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->cout_oper &= ~BTA_HL_CO_PUT_ECHO_DATA_MASK;
3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    utl_freebuf((void **) &p_dcb->p_echo_rx_pkt);
3095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->ci_put_echo_data_status = p_data->ci_get_put_echo_data.status;
3105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->echo_oper = BTA_HL_ECHO_OP_DCH_CLOSE_CFM;
3125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_ECHO_TEST_EVT, p_data);
3135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
3145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
3195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_ci_get_echo_data
3205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
3215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the call-in of the
3225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  get echo data event
3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
3245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
3255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
3265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
3275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_ci_get_echo_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
3285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 tBTA_HL_DATA *p_data)
3295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
3305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
3315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_STATUS      status;
3325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
334e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_ci_get_echo_data");
3355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
3365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->cout_oper &= ~BTA_HL_CO_GET_ECHO_DATA_MASK;
3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (!p_dcb->abort_oper)
3405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
3415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        status = p_data->ci_get_put_echo_data.status;
3425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (status == BTA_HL_STATUS_OK)
3435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->echo_oper = BTA_HL_ECHO_OP_MDL_CREATE_CFM;
3455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_OPEN_EVT, p_data);
3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
3475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
3495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
3505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
3515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
3525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
3545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
3555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
3565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
3585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
3605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
3615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_ci_put_rx_data
3625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
3635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the call-in of the
3645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  put rx data event
3655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
3665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
3675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
3685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
3695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_ci_put_rx_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
3705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               tBTA_HL_DATA *p_data)
3715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
3725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
3735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
3745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
3755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
3765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
378e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_ci_put_rx_data");
3795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
3805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->cout_oper &= ~BTA_HL_CO_PUT_RX_DATA_MASK;
3825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    utl_freebuf((void **) &p_dcb->p_rx_pkt);
3835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_build_rcv_data_ind(&evt_data,
3845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_acb->app_handle,
3855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_mcb->mcl_handle,
3865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_dcb->mdl_handle);
3875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_acb->p_cback(BTA_HL_DCH_RCV_DATA_IND_EVT,(tBTA_HL *) &evt_data );
3885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_dcb->close_pending)
3895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
3905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (!p_dcb->cout_oper)
3915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_EVT, p_data);
3935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
3945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
3975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
4015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
4025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_ci_get_tx_data
4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
4045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the call-in of the
4055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  get tx data event
4065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
4075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
4095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
4105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_ci_get_tx_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
4115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               tBTA_HL_DATA *p_data)
4125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
4135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
4145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
4155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
4165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_RESULT         result;
4175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_STATUS      status = BTA_HL_STATUS_OK;
4185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             free_buf = FALSE;
4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             close_dch = FALSE;
4205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
4215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
424e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_ci_get_tx_data");
4255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
4265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->cout_oper &= ~BTA_HL_CO_GET_TX_DATA_MASK;
4285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_dcb->close_pending)
4305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
4315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        status = BTA_HL_STATUS_FAIL;
4325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        free_buf = TRUE;
4335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (!p_dcb->cout_oper)
4355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
4365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            close_dch = TRUE;
4375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
4385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
4395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
4405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
4415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ((result = MCA_WriteReq((tMCA_DL) p_dcb->mdl_handle, p_dcb->p_tx_pkt)) != MCA_SUCCESS)
4425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
4435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (result == MCA_BUSY)
4445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
4455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                status = BTA_HL_STATUS_DCH_BUSY;
4465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
4475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
4485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
4495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                status = BTA_HL_STATUS_FAIL;
4505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
4515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            free_buf = TRUE;
4525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
4535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
4545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
4555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->p_tx_pkt = NULL;
4565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
4575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
4585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (free_buf)
4605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
4615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        utl_freebuf((void **) &p_dcb->p_tx_pkt);
4625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
4635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_build_send_data_cfm(&evt_data,
4655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               p_acb->app_handle,
4665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               p_mcb->mcl_handle,
4675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               p_dcb->mdl_handle,
4685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               status);
4695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_acb->p_cback(BTA_HL_DCH_SEND_DATA_CFM_EVT,(tBTA_HL *) &evt_data );
4705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (close_dch)
4725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
4735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_EVT, p_data);
4745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
4755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
4765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
4795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
4805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_send_data
4815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
4825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing api send data request
4835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
4845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
4855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
4865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
4875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_send_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
4885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                          tBTA_HL_DATA *p_data)
4895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
4905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
4915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
4925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
4935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
4945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             success = TRUE;
4955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
4965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
497e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_send_data");
4985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
4995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
5005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (!(p_dcb->cout_oper & BTA_HL_CO_GET_TX_DATA_MASK))
5015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
5025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ((p_dcb->p_tx_pkt = bta_hl_get_buf(p_data->api_send_data.pkt_size)) != NULL)
5035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
5045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_co_get_tx_data( p_acb->app_id,
5055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                   p_dcb->mdl_handle,
5065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                   p_data->api_send_data.pkt_size,
5075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                   BTA_HL_GET_BUF_PTR(p_dcb->p_tx_pkt),
5085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                   BTA_HL_CI_GET_TX_DATA_EVT);
5095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->cout_oper |= BTA_HL_CO_GET_TX_DATA_MASK;
5105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
5115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
5125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
5135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            success = FALSE;
5145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
5155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
5165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
5175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
5185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        success = FALSE;
5195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
5205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
5215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (!success)
5225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
5235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_build_send_data_cfm(&evt_data,
5245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                   p_acb->app_handle,
5255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                   p_mcb->mcl_handle,
5265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                   p_dcb->mdl_handle,
5275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                   BTA_HL_STATUS_FAIL);
5285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_acb->p_cback(BTA_HL_DCH_SEND_DATA_CFM_EVT,(tBTA_HL *) &evt_data );
5295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
5305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
5315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
5325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
5335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
5345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_close_cmpl
5355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
5365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the close complete event
5375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
5385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
5395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
5405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
5415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_close_cmpl(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
5425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                           tBTA_HL_DATA *p_data)
5435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
5445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
5455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
5465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
5475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
548ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    tBTA_HL_EVT         event = 0;
5495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             send_evt=TRUE;
5505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_STATUS      status;
5515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
5525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
5535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
554e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_close_cmpl dch oper=%s", bta_hl_dch_oper_code(p_dcb->dch_oper));
5555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else
556e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_close_cmpl dch oper=%d", p_dcb->dch_oper);
5575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
5585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
5595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
5605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (p_dcb->dch_oper)
5615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
5625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_OPEN:
5635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_RECONNECT:
5645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
5655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (p_dcb->abort_oper & BTA_HL_ABORT_LOCAL_MASK)
5665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
5675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_build_abort_cfm(&evt_data,
5685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
5695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
5705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       BTA_HL_STATUS_OK);
5715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event = BTA_HL_DCH_ABORT_CFM_EVT;
5725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
5735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else if (p_dcb->abort_oper & BTA_HL_ABORT_REMOTE_MASK )
5745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
5755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_build_abort_ind(&evt_data,
5765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
5775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle);
5785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event = BTA_HL_DCH_ABORT_IND_EVT;
5795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
5805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
5815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
5825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_build_dch_open_cfm(&evt_data,
5835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                          p_acb->app_handle,
5845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                          p_mcb->mcl_handle,
5855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                          BTA_HL_INVALID_MDL_HANDLE,
5865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                          0,0,0,0,0, BTA_HL_STATUS_FAIL);
5875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event = BTA_HL_DCH_OPEN_CFM_EVT;
5885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_RECONNECT)
5895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
5905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    event = BTA_HL_DCH_RECONNECT_CFM_EVT;
5915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
5925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
5935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
5945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
5955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE:
5965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_DELETE:
5975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT:
5985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_NONE:
5995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_build_dch_close_cfm(&evt_data,
6015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
6025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
6035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_dcb->mdl_handle,
6045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       BTA_HL_STATUS_OK);
6055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            event = BTA_HL_DCH_CLOSE_CFM_EVT;
6065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
6075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_CLOSE:
6095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_build_dch_close_ind(&evt_data,
6105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
6115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
6125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_dcb->mdl_handle,
6135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_dcb->intentional_close);
6145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            event = BTA_HL_DCH_CLOSE_IND_EVT;
6155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
6165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_OPEN:
6185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (p_dcb->abort_oper & BTA_HL_ABORT_LOCAL_MASK)
6205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
6215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_build_abort_cfm(&evt_data,
6225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
6235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
6245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       BTA_HL_STATUS_OK);
6255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event = BTA_HL_DCH_ABORT_CFM_EVT;
6265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
6275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else if (p_dcb->abort_oper & BTA_HL_ABORT_REMOTE_MASK )
6285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
6295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_build_abort_ind(&evt_data,
6305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
6315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle);
6325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event = BTA_HL_DCH_ABORT_IND_EVT;
6335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
6345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
6355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
6365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_build_dch_close_ind(&evt_data,
6375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                           p_acb->app_handle,
6385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                           p_mcb->mcl_handle,
6395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                           p_dcb->mdl_handle,
6405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                           p_dcb->intentional_close);
6415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event = BTA_HL_DCH_CLOSE_IND_EVT;
6425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
6435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
6445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST:
6465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            /* this is normal echo test close */
6475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_CREATE:
6485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_RECONNECT:
6495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            send_evt=FALSE;
6505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
6515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
6535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
6545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
655e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_ERROR("DCH operation not found oper=%s", bta_hl_dch_oper_code(p_dcb->dch_oper));
6565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else
657e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_ERROR("DCH operation not found oper=%d", p_dcb->dch_oper);
6585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
6595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
6605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            send_evt=FALSE;
6615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
6625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
6635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if ( p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID )
6655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
6665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_mcb->echo_test = FALSE;
6675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        send_evt=FALSE;
6685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ( p_dcb->dch_oper != BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST)
6705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
6715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            switch (p_dcb->echo_oper)
6725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
6735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                case BTA_HL_ECHO_OP_CI_GET_ECHO_DATA:
6745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                case BTA_HL_ECHO_OP_SDP_INIT:
6755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                case BTA_HL_ECHO_OP_MDL_CREATE_CFM:
6765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                case BTA_HL_ECHO_OP_DCH_OPEN_CFM:
6775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                case BTA_HL_ECHO_OP_LOOP_BACK:
6785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    status = BTA_HL_STATUS_FAIL;
6805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    send_evt = TRUE;
6815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    break;
6825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                case BTA_HL_ECHO_OP_OPEN_IND:
6835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                case BTA_HL_ECHO_OP_ECHO_PKT:
6845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    break;
6855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                default:
686e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                    APPL_TRACE_ERROR("Invalid echo_oper=%d", p_dcb->echo_oper);
6875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    break;
6885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
6895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
6905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
6915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
6925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            status = p_dcb->ci_put_echo_data_status;
6935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            send_evt = TRUE;
6945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
6955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
6965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (send_evt)
6975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
6985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_build_echo_test_cfm(&evt_data,
6995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
7005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
7015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       status);
7025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            event = BTA_HL_DCH_ECHO_TEST_CFM_EVT;
7035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
7045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
7055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_clean_mdl_cb(app_idx, mcl_idx, mdl_idx);
7075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (send_evt)
7095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
7105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (p_acb->p_cback)
7115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
7125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
7135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
714e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_DEBUG("Send Event: %s",  bta_hl_cback_evt_code(event));
7155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else
716e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_DEBUG("Send Event: 0x%02x", event);
7175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
7185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
7195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_acb->p_cback(event,(tBTA_HL *) &evt_data );
7205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
7215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
7225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    /* check cch close is in progress or not */
7235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_check_cch_close(app_idx, mcl_idx, p_data, FALSE);
7245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
7255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
7265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_close_ind
7285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the close indication
7305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
7325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
7345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_close_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
7355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              tBTA_HL_DATA *p_data)
7365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
7375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
7385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
7405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
741e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_close_ind dch oper=%s", bta_hl_dch_oper_code(p_dcb->dch_oper));
7425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else
743e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_close_ind dch oper=%d", p_dcb->dch_oper);
7445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
7455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
7465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->intentional_close = FALSE;
7485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_data->mca_evt.mca_data.close_ind.reason == L2CAP_DISC_OK)
7495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
7505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->intentional_close = TRUE;
7515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
7525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (!p_dcb->cout_oper)
7545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
7555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ((p_dcb->dch_oper != BTA_HL_DCH_OP_REMOTE_OPEN) &&
7565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            (p_dcb->dch_oper != BTA_HL_DCH_OP_REMOTE_RECONNECT))
7575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
7585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->dch_oper = BTA_HL_DCH_OP_REMOTE_CLOSE;
7595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
7605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
7615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
7625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
7635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
7645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->close_pending = TRUE;
7655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
7665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
7675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
7695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_close_cfm
7715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the close confirmation
7735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
7755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
7765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
7775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_close_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
7785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              tBTA_HL_DATA *p_data)
7795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
7805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
7815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
7845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
785e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_close_cfm dch_oper=%s", bta_hl_dch_oper_code(p_dcb->dch_oper) );
7865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else
787e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_close_cfm dch_oper=%d", p_dcb->dch_oper);
7885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
7895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
7905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
7915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (p_dcb->dch_oper)
7925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
7935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE:
7945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_OPEN:
7955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_RECONNECT:
7965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST:
7975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_DELETE:
7985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT:
7995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_NONE:
8005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
8015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
8025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
8035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
8045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
805e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_ERROR("Invalid dch_oper=%s for close cfm", bta_hl_dch_oper_code(p_dcb->dch_oper) );
8065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else
807e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_ERROR("Invalid dch_oper=%d for close cfm", p_dcb->dch_oper);
8085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
8095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
8105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
8115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
8125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
8145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
8165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
8175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_close
8185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
8195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the DCH close request
8205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
8215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
8225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
8235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
8245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_close(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
8255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                          tBTA_HL_DATA *p_data)
8265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
8275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB          *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
8285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB          *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
8295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB          *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
8305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_STATUS          status = BTA_HL_STATUS_OK;
8315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL                 evt_data;
8325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
834e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_close");
8355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
8365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (!p_dcb->cout_oper)
8375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
8385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->close_pending = FALSE;
8395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (MCA_CloseReq((tMCA_DL)p_dcb->mdl_handle)== MCA_SUCCESS)
8405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
8415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_CLOSE;
8425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
8435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
8445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
8455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            status = BTA_HL_STATUS_FAIL;
8465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
8475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ((status != BTA_HL_STATUS_OK) &&
8495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            (p_mcb->cch_close_dch_oper != BTA_HL_CCH_CLOSE_OP_DCH_CLOSE))
8505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
8515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_build_dch_close_cfm(&evt_data,
8525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
8535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
8545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_data->api_dch_close.mdl_handle,
8555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       status);
8565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_acb->p_cback(BTA_HL_DCH_CLOSE_CFM_EVT,(tBTA_HL *) &evt_data );
8575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
8585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
8595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
8605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
8615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->close_pending = TRUE;
8625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
8635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
8645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
8675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
8685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_open_ind
8695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
8705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the open indication
8715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
8725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
8735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
8745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
8755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_open_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
8765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             tBTA_HL_DATA *p_data)
8775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
8785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
8795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
8805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
8815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_DL_OPEN        *p_open_ind = &p_data->mca_evt.mca_data.open_ind;
8825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
8835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_EVT         event;
884ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    UINT8               old_dch_oper = BTA_HL_DCH_OP_NONE;
8855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             send_event = FALSE;
8865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
889e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_open_ind");
8905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
8915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if ((p_dcb->dch_oper == BTA_HL_DCH_OP_REMOTE_OPEN) ||
8925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        (p_dcb->dch_oper == BTA_HL_DCH_OP_REMOTE_RECONNECT)    )
8935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
8945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->mdl_handle = (tBTA_HL_MDL_HANDLE) p_open_ind->mdl;
8955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->mtu        = p_open_ind->mtu;
8965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
8975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_open_ind.mdl_handle = p_dcb->mdl_handle;
8985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_open_ind.mcl_handle = p_mcb->mcl_handle;
8995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_open_ind.app_handle = p_acb->app_handle;
9005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_open_ind.local_mdep_id = p_dcb->local_mdep_id;
9025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_open_ind.mdl_id = p_dcb->mdl_id;
9035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_open_ind.mtu = p_dcb->mtu;
9045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ( p_dcb->chnl_cfg.fcr_opt.mode == L2CAP_FCR_ERTM_MODE )
9065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
9075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            evt_data.dch_open_ind.dch_mode = BTA_HL_DCH_MODE_RELIABLE;
9085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (!bta_hl_is_the_first_reliable_existed(app_idx, mcl_idx))
9095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
9105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->is_the_first_reliable = TRUE;
9115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
9125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
9135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
9145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
9155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            evt_data.dch_open_ind.dch_mode = BTA_HL_DCH_MODE_STREAMING;
9165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
9175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_open_ind.first_reliable = p_dcb->is_the_first_reliable ;
9185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        old_dch_oper = p_dcb->dch_oper;
9205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->dch_oper = BTA_HL_DCH_OP_NONE;
9215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
9245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (old_dch_oper)
9265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
9275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_OPEN:
9285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->dch_mode = evt_data.dch_open_ind.dch_mode;
9305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (p_dcb->local_mdep_id != BTA_HL_ECHO_TEST_MDEP_ID)
9315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
9325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_save_mdl_cfg(app_idx, mcl_idx,mdl_idx);
9335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event= BTA_HL_DCH_OPEN_IND_EVT;
9345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                send_event= TRUE;
9355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
9365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
9375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
9385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->echo_oper = BTA_HL_ECHO_OP_ECHO_PKT;
9395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
9405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
9425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_RECONNECT:
9445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (bta_hl_validate_chan_cfg(app_idx, mcl_idx, mdl_idx))
9465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
9475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_save_mdl_cfg(app_idx, mcl_idx,mdl_idx);
9485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event= BTA_HL_DCH_RECONNECT_IND_EVT;
9495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                send_event= TRUE;
9505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
9515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
9525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
9535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (MCA_CloseReq((tMCA_DL) p_dcb->mdl_handle) == MCA_SUCCESS)
9545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
9555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT;
9565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
9575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
9585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
959e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                    APPL_TRACE_ERROR("Unabel to close DCH for reconnect cfg mismatch");
9605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
9615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
9625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
9635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
9645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
9655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
9665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (send_event)
9685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
9695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_acb->p_cback(event ,(tBTA_HL *) &evt_data );
9705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
9715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
9725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
9745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
9755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_open_cfm
9765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
9775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the open confirmation
9785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
9795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
9805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
9815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
9825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_open_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
9835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             tBTA_HL_DATA *p_data)
9845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
9855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
9865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
9875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
9885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_DL_OPEN        *p_open_cfm = &p_data->mca_evt.mca_data.open_cfm;
9895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
9905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_EVT         event;
991ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    UINT8               old_dch_oper = BTA_HL_DCH_OP_NONE;
992ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    tBTA_HL_DCH_MODE    dch_mode = BTA_HL_DCH_MODE_STREAMING;
9935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             send_event = FALSE;
9945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
9965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
997e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_open_cfm");
9985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
9995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if ((p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_OPEN) ||
10005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_RECONNECT))
10015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
10025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->mdl_handle = (tBTA_HL_MDL_HANDLE) p_open_cfm->mdl;
10035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->mtu        = p_open_cfm->mtu;
10045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        /*todo verify dch_mode, mtu and fcs for reconnect */
10065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ( p_dcb->chnl_cfg.fcr_opt.mode == L2CAP_FCR_ERTM_MODE )
10075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
10085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            dch_mode = BTA_HL_DCH_MODE_RELIABLE;
10095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
10105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (p_dcb->local_mdep_id != BTA_HL_ECHO_TEST_MDEP_ID)
10125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
10135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (dch_mode == BTA_HL_DCH_MODE_RELIABLE )
10145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
10155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (!bta_hl_is_the_first_reliable_existed(app_idx, mcl_idx))
10165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
10175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    p_dcb->is_the_first_reliable = TRUE;
10185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
10195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
10205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
10215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_build_dch_open_cfm(&evt_data, p_acb->app_handle,
10235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_mcb->mcl_handle,
10245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_dcb->mdl_handle,
10255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_dcb->local_mdep_id,
10265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_dcb->mdl_id, dch_mode,
10275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_dcb->is_the_first_reliable,
10285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_dcb->mtu,
10295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  BTA_HL_STATUS_OK);
10305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        old_dch_oper = p_dcb->dch_oper;
10325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->dch_oper = BTA_HL_DCH_OP_NONE;
10335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
1034ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    else
1035ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    {
1036e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati        APPL_TRACE_ERROR("Error dch oper =%d",  p_dcb->dch_oper);
1037ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta        return;
1038ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    }
10395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (old_dch_oper)
10415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
10425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_OPEN:
10435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->dch_mode = dch_mode;
10455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (p_dcb->local_mdep_id != BTA_HL_ECHO_TEST_MDEP_ID)
10465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
10475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_save_mdl_cfg(app_idx, mcl_idx, mdl_idx);
10485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event= BTA_HL_DCH_OPEN_CFM_EVT;
10495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                send_event= TRUE;
10505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
10515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
10525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
10535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->echo_oper = BTA_HL_ECHO_OP_LOOP_BACK;
10545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (MCA_WriteReq((tMCA_DL) p_dcb->mdl_handle, p_dcb->p_echo_tx_pkt)!= MCA_SUCCESS)
10555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
10565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_ECHO_TEST_EVT, p_data);
10575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
10585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
10595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
10605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    p_dcb->p_echo_tx_pkt = NULL;
10615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
10625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
10635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
10645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_RECONNECT:
10665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (bta_hl_validate_chan_cfg(app_idx, mcl_idx, mdl_idx))
10685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
10695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_save_mdl_cfg(app_idx, mcl_idx,mdl_idx);
10705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                event= BTA_HL_DCH_RECONNECT_CFM_EVT;
10715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                send_event= TRUE;
10725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
10735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
10745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
10755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (MCA_CloseReq((tMCA_DL) p_dcb->mdl_handle) == MCA_SUCCESS)
10765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
10775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT;
10785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
10795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
10805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
1081e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                    APPL_TRACE_ERROR("Unabel to close DCH for reconnect cfg mismatch");
10825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
10835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
10845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
10855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
10865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
10875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
10885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (send_event)
10905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_acb->p_cback(event ,(tBTA_HL *) &evt_data );
10915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
10925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
10945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
10955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
10965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_abort_ind
10975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
10985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the abort indication
10995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
11015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
11035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_abort_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
11045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              tBTA_HL_DATA *p_data)
11055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
11065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
11075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1110e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_abort_ind");
11115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
11125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->abort_oper |= BTA_HL_ABORT_REMOTE_MASK;
11145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
11155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
11165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
11185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_abort_cfm
11205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the abort confirmation
11225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
11245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
11265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_abort_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
11275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              tBTA_HL_DATA *p_data)
11285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
11295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
11305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
11315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
11325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
11335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1135e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_abort_cfm");
11365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
11375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_dcb->abort_oper)
11395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
11405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (p_data->mca_evt.mca_data.abort_cfm.rsp_code != MCA_RSP_SUCCESS )
11415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
11425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (p_dcb->abort_oper & BTA_HL_ABORT_LOCAL_MASK)
11435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
11445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_build_abort_cfm(&evt_data,
11455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
11465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
11475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       BTA_HL_STATUS_FAIL);
11485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_acb->p_cback(BTA_HL_DCH_ABORT_CFM_EVT ,(tBTA_HL *) &evt_data );
11495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
11505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
11515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
11525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
11535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
11545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
11555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
11565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
11575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
1158e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati        APPL_TRACE_ERROR("Not expecting Abort CFM ");
11595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
11605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
11615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
11635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_abort
11655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the abort request
11675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
11695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
11705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
11715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_abort(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
11725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                          tBTA_HL_DATA *p_data)
11735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
11745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB          *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
11755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB          *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
11765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB          *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
11775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_RESULT             mca_result;
11785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL                 evt_data;
11795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (((p_mcb->sdp_oper == BTA_HL_SDP_OP_DCH_OPEN_INIT) ||
11815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project         (p_mcb->sdp_oper == BTA_HL_SDP_OP_DCH_RECONNECT_INIT)) &&
11825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        (p_mcb->sdp_mdl_idx == mdl_idx) )
11835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
11845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->abort_oper |= BTA_HL_ABORT_PENDING_MASK;
11855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        return;
11865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
11875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else if (p_dcb->echo_oper == BTA_HL_ECHO_OP_CI_GET_ECHO_DATA)
11885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
11895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->abort_oper |= BTA_HL_ABORT_PENDING_MASK;
11905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        return;
11915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
11925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_dcb->abort_oper &= ~BTA_HL_ABORT_PENDING_MASK;
11945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
11955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if ((mca_result = MCA_Abort((tMCA_CL) p_mcb->mcl_handle))!= MCA_SUCCESS)
11965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
11975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (mca_result == MCA_NO_RESOURCES)
11985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
11995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->abort_oper |= BTA_HL_ABORT_PENDING_MASK;
12005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
12015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
12025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
12035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (p_dcb->abort_oper & BTA_HL_ABORT_LOCAL_MASK)
12045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
12055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_build_abort_cfm(&evt_data,
12065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
12075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
12085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       BTA_HL_STATUS_FAIL);
12095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_acb->p_cback(BTA_HL_DCH_ABORT_CFM_EVT ,(tBTA_HL *) &evt_data );
12105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
12115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_check_cch_close(app_idx, mcl_idx, p_data, FALSE);
12125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
12135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
12165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1218e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_abort abort_oper=0x%x", p_dcb->abort_oper);
12195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
12205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
12225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
12245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
12255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_reconnect_ind
12265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
12275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the reconnect indication
12285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
12295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
12305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
12315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
12325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_reconnect_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
12335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  tBTA_HL_DATA *p_data)
12345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
12355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
12365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
12375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CFG     *p_mdl_cfg;
12385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_EVT_HDR        *p_reconnect_ind = &p_data->mca_evt.mca_data.reconnect_ind;
12395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               mdl_cfg_idx, in_use_mdl_idx, mdep_cfg_idx;
12405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               rsp_code = MCA_RSP_SUCCESS;
12415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1244e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_reconnect_ind mdl_id=%d", p_reconnect_ind->mdl_id);
12455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
12465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (bta_hl_find_mdl_cfg_idx(app_idx, mcl_idx, p_reconnect_ind->mdl_id, &mdl_cfg_idx))
12485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
12495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (!bta_hl_find_mdl_idx(app_idx,mcl_idx,p_reconnect_ind->mdl_id, &in_use_mdl_idx) )
12505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
12515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_mdl_cfg =  BTA_HL_GET_MDL_CFG_PTR(app_idx, mdl_cfg_idx);
12525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (bta_hl_find_mdep_cfg_idx(app_idx, p_mdl_cfg->local_mdep_id, &mdep_cfg_idx))
12545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
12555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->in_use               = TRUE;
12565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->dch_oper             = BTA_HL_DCH_OP_REMOTE_RECONNECT;
12575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->sec_mask             = (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
12585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->peer_mdep_id             = 0xFF;
12595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->local_mdep_id        = p_mdl_cfg->local_mdep_id  ;
12605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->local_mdep_cfg_idx   = mdep_cfg_idx;
12615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->local_cfg            = BTA_HL_DCH_CFG_UNKNOWN;
12625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->mdl_id               = p_reconnect_ind->mdl_id;
12635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->mdl_cfg_idx_included = TRUE;
12645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->mdl_cfg_idx          = mdl_cfg_idx;
12655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->dch_mode             = p_mdl_cfg->dch_mode;
12665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_find_rxtx_apdu_size(app_idx, mdep_cfg_idx,
12675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                           &p_dcb->max_rx_apdu_size,
12685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                           &p_dcb->max_tx_apdu_size);
12695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
12705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
12715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
12725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
12735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                rsp_code = MCA_RSP_BAD_MDL;
12745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
12755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
12765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
12775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
12785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            rsp_code = MCA_RSP_BAD_MDL;
12795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
12805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
12815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
12825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
12835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        rsp_code = MCA_RSP_BAD_MDL;
12845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
12855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (MCA_ReconnectMdlRsp((tMCA_CL) p_mcb->mcl_handle,
12875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            p_dcb->local_mdep_id,
12885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            p_dcb->mdl_id,
12895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            rsp_code,
12905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            &p_dcb->chnl_cfg)!= MCA_SUCCESS)
12915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
12925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        MCA_Abort((tMCA_CL) p_mcb->mcl_handle);
12935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
12945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
12955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
12965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
12975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
12985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
12995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_reconnect_cfm
13005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the reconenct confirmation
13025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
13045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
13065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_reconnect_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
13075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  tBTA_HL_DATA *p_data)
13085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
13095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
13105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
13115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_RSP_EVT        *p_reconnect_cfm = &p_data->mca_evt.mca_data.reconnect_cfm;
13125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1315e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_reconnect_cfm");
13165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
13175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_dcb->abort_oper & BTA_HL_ABORT_PENDING_MASK)
13185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
13195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->abort_oper &= ~BTA_HL_ABORT_PENDING_MASK;
13205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_ABORT_EVT, p_data);
13215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        return;
13225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
13235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_RECONNECT)
13265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
13275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (p_reconnect_cfm->rsp_code == MCA_RSP_SUCCESS)
13285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
13295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
13315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (MCA_DataChnlCfg((tMCA_CL) p_mcb->mcl_handle, &p_dcb->chnl_cfg)!= MCA_SUCCESS)
13335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
13345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                /* should be able to abort so no checking of the return code */
13355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                MCA_Abort((tMCA_CL) p_mcb->mcl_handle);
13365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
13375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
13385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
13395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
13405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
13415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
13425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
13435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
13445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
13455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
13475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_reconnect
13495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the reconnect request
13515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
13535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
13555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_reconnect(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
13565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              tBTA_HL_DATA *p_data)
13575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
13585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
13595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
13605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_CHNL_CFG       *p_chnl_cfg=NULL;
13615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               sdp_idx;
13625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1364e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_reconnect");
13655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
13665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (bta_hl_find_sdp_idx_using_ctrl_psm(&p_mcb->sdp, p_mcb->ctrl_psm, &sdp_idx))
13675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
13685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_mcb->data_psm = p_mcb->sdp.sdp_rec[sdp_idx].data_psm;
13695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ( MCA_ReconnectMdl((tMCA_CL) p_mcb->mcl_handle,
13705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_dcb->local_mdep_id,
13715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_mcb->data_psm,
13725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_dcb->mdl_id,
13735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_chnl_cfg ) != MCA_SUCCESS)
13745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
13755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
13765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
13775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
13785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
13795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
13805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
13815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
13825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
13835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
13855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
13865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_create_rsp
13885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing BTA_HL_API_DCH_CREATE_RSP_EVT
13905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
13925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
13935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
13945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_create_rsp(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
13955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                           tBTA_HL_DATA *p_data)
13965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
13975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB              *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
13985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB              *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
13995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_API_DCH_CREATE_RSP  *p_create_rsp = &p_data->api_dch_create_rsp;
14005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8                       mca_rsp_code = MCA_RSP_SUCCESS;
14015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1403e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_create_rsp");
14045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
14055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_create_rsp->rsp_code == BTA_HL_DCH_CREATE_RSP_SUCCESS)
14065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
14075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->dch_oper             = BTA_HL_DCH_OP_REMOTE_OPEN;
14085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->local_cfg            = p_create_rsp->cfg_rsp;
14095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
14135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
14145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
14155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
14165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        mca_rsp_code = MCA_RSP_CFG_REJ;
14175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
14185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (MCA_CreateMdlRsp((tMCA_CL) p_mcb->mcl_handle,
14205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                         p_dcb->local_mdep_id,
14215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                         p_dcb->mdl_id,
14225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                         p_dcb->local_cfg,
14235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                         mca_rsp_code,
14245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                         &p_dcb->chnl_cfg)!= MCA_SUCCESS)
14255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
14265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
14275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
14285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
14295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
14315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
14325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_create_ind
14335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
14345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing
14355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
14365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
14375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
14385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
14395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_create_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
14405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               tBTA_HL_DATA *p_data)
14415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
14425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
14435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
14445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
14455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_CREATE_IND     *p_create_ind = &p_data->mca_evt.mca_data.create_ind;
14465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               mdep_cfg_idx;
14475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               cfg_rsp;
14485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               rsp_code = MCA_RSP_SUCCESS;
14495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             send_create_ind_evt = FALSE;
14505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
14515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_ECHO_CFG    *p_echo_cfg;
14525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1454e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_create_ind");
14555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
14565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (bta_hl_find_mdep_cfg_idx(app_idx, p_create_ind->dep_id, &mdep_cfg_idx))
14585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
14595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (p_create_ind->dep_id == BTA_HL_ECHO_TEST_MDEP_ID )
14605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
14615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (bta_hl_find_echo_cfg_rsp(app_idx, mcl_idx, mdep_cfg_idx,p_create_ind->cfg, &cfg_rsp ))
14625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
14635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->in_use               = TRUE;
14645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->dch_oper             = BTA_HL_DCH_OP_REMOTE_OPEN;
14655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->local_mdep_id        = p_create_ind->dep_id  ;
14665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->local_mdep_cfg_idx   = mdep_cfg_idx;
14675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->local_cfg            = cfg_rsp;
14685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->remote_cfg           = p_create_ind->cfg ;
14695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->mdl_id               = p_create_ind->mdl_id;
14705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->mdl_cfg_idx_included = FALSE;
14715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_echo_cfg                      = BTA_HL_GET_ECHO_CFG_PTR(app_idx);
14725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->max_rx_apdu_size         = p_echo_cfg->max_rx_apdu_size;
14735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->max_tx_apdu_size         = p_echo_cfg->max_tx_apdu_size;
14745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
14765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
14775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
14785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
14795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                rsp_code = MCA_RSP_CFG_REJ;
14805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
14815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
14825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
14835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
14845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
14855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->in_use               = TRUE;
14865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->dch_oper             = BTA_HL_DCH_OP_REMOTE_CREATE;
14875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->local_mdep_id        = p_create_ind->dep_id  ;
14885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->local_mdep_cfg_idx   = mdep_cfg_idx;
14895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->local_cfg            = BTA_HL_DCH_CFG_UNKNOWN;
14905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->remote_cfg           = p_create_ind->cfg;
14915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->mdl_id               = p_create_ind->mdl_id;
14925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_dcb->mdl_cfg_idx_included = FALSE;
14935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_find_rxtx_apdu_size(app_idx, mdep_cfg_idx,
14945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       &p_dcb->max_rx_apdu_size,
14955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       &p_dcb->max_tx_apdu_size);
14965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            send_create_ind_evt = TRUE;
14975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
14985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
14995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
15005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
15015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        rsp_code = MCA_RSP_BAD_MDEP;
15025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
15035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
15045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (send_create_ind_evt)
15055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
15065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_create_ind.mcl_handle =  p_mcb->mcl_handle;
15075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_create_ind.app_handle =  p_acb->app_handle;
15085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_create_ind.local_mdep_id = p_dcb->local_mdep_id;
15095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_create_ind.mdl_id = p_dcb->mdl_id;
15105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        evt_data.dch_create_ind.cfg = p_dcb->remote_cfg;
1511f8f30c2cecf221b2c3983b72d5a849d799c39dd7Priti Aghera        bdcpy(evt_data.dch_create_ind.bd_addr, p_mcb->bd_addr);
15125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_acb->p_cback(BTA_HL_DCH_CREATE_IND_EVT,(tBTA_HL *) &evt_data );
15135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
15145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
15155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
15165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (MCA_CreateMdlRsp((tMCA_CL) p_mcb->mcl_handle,
15175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             p_dcb->local_mdep_id,
15185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             p_dcb->mdl_id,
15195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             p_dcb->local_cfg,
15205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             rsp_code,
15215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             &p_dcb->chnl_cfg)!= MCA_SUCCESS)
15225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
15235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
15245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
15255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
15265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
15275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID)
15285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
15295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_mcb->echo_test = TRUE;
15305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb->echo_oper = BTA_HL_ECHO_OP_OPEN_IND;
15315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
15325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
15335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
15345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
15355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
15365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
15375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
15385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_create_cfm
15395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
15405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing
15415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
15425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
15435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
15445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
15455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_create_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
15465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               tBTA_HL_DATA *p_data)
15475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
15485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
15495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
15505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_CREATE_CFM     *p_create_cfm = &p_data->mca_evt.mca_data.create_cfm;
15515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
15525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1553e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_create_cfm");
15545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
15555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
15565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_dcb->abort_oper & BTA_HL_ABORT_PENDING_MASK)
15575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
15585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb->abort_oper &= ~BTA_HL_ABORT_PENDING_MASK;
15595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_ABORT_EVT, p_data);
15605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        return;
15615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
15625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
15635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_OPEN)
15645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
15655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (p_create_cfm->rsp_code == MCA_RSP_SUCCESS)
15665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
15675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (bta_hl_validate_cfg(app_idx, mcl_idx, mdl_idx, p_create_cfm->cfg ))
15685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
15695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
15705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
15715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (MCA_DataChnlCfg((tMCA_CL) p_mcb->mcl_handle, &p_dcb->chnl_cfg)!= MCA_SUCCESS)
15725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
15735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    /* this should not happen */
1574e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                    APPL_TRACE_ERROR("Unable to create data channel");
15755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    MCA_Abort((tMCA_CL) p_mcb->mcl_handle);
15765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
15775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
15785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
15795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
15805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    if (p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID)
15815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    {
15825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        p_dcb->echo_oper = BTA_HL_ECHO_OP_DCH_OPEN_CFM;
15835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    }
15845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
15855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
15865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
15875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
15885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                MCA_Abort((tMCA_CL) p_mcb->mcl_handle);
15895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
15905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
15915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
15925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else
15935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
1594e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_ERROR("MCA Create- failed");
15955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
15965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
15975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
15985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
15995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
16005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
16015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_mca_create
16035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the MDL create request
16055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
16075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
16095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_mca_create(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
16105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                           tBTA_HL_DATA *p_data)
16115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
16125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
16135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb  = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
16145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tMCA_RESULT         result;
16155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               sdp_idx;
16165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
16175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
1618e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_mca_create");
16195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
16205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
16215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (bta_hl_find_sdp_idx_using_ctrl_psm(&p_mcb->sdp, p_mcb->ctrl_psm, &sdp_idx) &&
16225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_validate_peer_cfg(app_idx, mcl_idx, mdl_idx,
16235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 p_dcb->peer_mdep_id,
16245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 p_dcb->peer_mdep_role,
16255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                 sdp_idx))
16265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
16275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
16285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_mcb->data_psm = p_mcb->sdp.sdp_rec[sdp_idx].data_psm;
16295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ( (result = MCA_CreateMdl((tMCA_CL) p_mcb->mcl_handle,
16305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     p_dcb->local_mdep_id,
16315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     p_mcb->data_psm,
16325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     p_dcb->mdl_id,
16335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     p_dcb->peer_mdep_id,
16345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     p_dcb->local_cfg,
16355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                     NULL )) != MCA_SUCCESS)
16365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
1637e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_ERROR("MCA_CreateMdl FAIL mca_result=%d", result);
16385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
16395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
16405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
16415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
16425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
1643e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati        APPL_TRACE_ERROR("MCA Create- SDP idx or peer MDEP cfg not found");
16445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
16455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
16465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
16475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
16485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
16495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_sdp_fail
16515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the SDP failed event
16535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
16555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
16575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_dch_sdp_fail(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
16585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                         tBTA_HL_DATA *p_data)
16595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
16605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
16615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
1662e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_dch_sdp_fail");
16635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
16645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
16655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
16665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
16675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
16685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_sdp_cback
16705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This is the SDP callback function used by HL.
16725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  This function will be executed by SDP when the service
16735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  search is completed.  If the search is successful, it
16745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  finds the first record in the database that matches the
16755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  UUID of the search.  Then retrieves the scn from the
16765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                  record.
16775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void.
16795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
16805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/
16815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback(UINT8 sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
16825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             UINT8 mdl_idx, UINT16 status)
16835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
16845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB                  *p_cb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
16855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_SDP_REC                 *p_hdp_rec;
16865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_CCH_SDP                 *p_cch_buf;
16875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_DCH_SDP                 *p_dch_buf;
16885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tSDP_DISC_REC                   *p_rec = NULL;
16895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tSDP_PROTOCOL_ELEM              pe;
16905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tSDP_DISC_ATTR                  *p_attr;
16915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8                           i, rec_cnt;
16925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_SUP_FEATURE_LIST_ELEM   sup_feature;
16935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN                         sdp_parsing_ok =FALSE, result=FALSE;
16945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT16                          event;
16955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB                  *p_dcb;
16965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT16                          service_uuid;
16975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT16                          name_len;
16985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
16995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
1700e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_sdp_cback status:%d sdp_oper=%d app_idx=%d, mcl_idx=%d,   mdl_idx=%d",
17015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      status, sdp_oper, app_idx, mcl_idx, mdl_idx);
17025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
17035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    rec_cnt = 0;
17055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    service_uuid = bta_hl_get_service_uuids(sdp_oper, app_idx, mcl_idx, mdl_idx);
17065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (status == SDP_SUCCESS || status == SDP_DB_FULL)
17085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
17095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        memset(&p_cb->sdp,0, sizeof(tBTA_HL_SDP));
17105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        do
17115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
17125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (bta_hl_find_service_in_db(app_idx, mcl_idx, service_uuid, &p_rec))
17135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_hdp_rec = &p_cb->sdp.sdp_rec[rec_cnt];
17155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_cb->sdp.num_recs = rec_cnt+1;
17165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
17185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
17205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_L2CAP, &pe))
17235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_hdp_rec->ctrl_psm  = (UINT16) pe.params[0];
17255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
17275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
1728e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                APPL_TRACE_WARNING("Control PSM not found");
17295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
17305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (SDP_FindAddProtoListsElemInRec(p_rec, UUID_PROTOCOL_L2CAP, &pe))
17325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_hdp_rec->data_psm = (UINT16) pe.params[0];
17345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
17365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
1737e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                APPL_TRACE_WARNING("Data PSM not found");
17385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
17395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_hdp_rec->srv_name[0]= '\0';
17425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
17435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) < BT_MAX_SERVICE_NAME_LEN)
17455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    name_len = (UINT16)SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
17465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
17475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    name_len = BT_MAX_SERVICE_NAME_LEN;
17485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                memcpy(p_hdp_rec->srv_name, p_attr->attr_value.v.array, name_len);
17495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_hdp_rec->srv_desp[0]= '\0';
17525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_DESCRIPTION)) != NULL)
17535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) < BT_MAX_SERVICE_NAME_LEN)
17555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    name_len = (UINT16)SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
17565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
17575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    name_len = BT_MAX_SERVICE_NAME_LEN;
17585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                memcpy(p_hdp_rec->srv_desp, p_attr->attr_value.v.array, name_len);
17595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_hdp_rec->provider_name[0]= '\0';
17635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_PROVIDER_NAME)) != NULL)
17645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) < BT_MAX_SERVICE_NAME_LEN)
17665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    name_len = (UINT16)SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
17675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
17685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    name_len = BT_MAX_SERVICE_NAME_LEN;
17695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                memcpy(p_hdp_rec->provider_name, p_attr->attr_value.v.array, name_len);
17705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_HDP_MCAP_SUP_PROC))!=NULL)
17735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_hdp_rec->mcap_sup_proc = p_attr->attr_value.v.u8;
17755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
17775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
1778e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                APPL_TRACE_WARNING("MCAP SUP PROC not found");
17795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
17805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
17815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
17825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_HDP_SUP_FEAT_LIST ))!=NULL)
17835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
17845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (bta_hl_fill_sup_feature_list (p_attr, &sup_feature))
17855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
17865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    p_hdp_rec->num_mdeps = (UINT8) sup_feature.num_elems;
1787e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                    APPL_TRACE_WARNING("bta_hl_sdp_cback num_mdeps %d",sup_feature.num_elems);
17885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    for (i=0; i<sup_feature.num_elems; i++)
17895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    {
17905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        p_hdp_rec->mdep_cfg[i].data_type = sup_feature.list_elem[i].data_type;
17915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        p_hdp_rec->mdep_cfg[i].mdep_id = sup_feature.list_elem[i].mdep_id;
17925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        p_hdp_rec->mdep_cfg[i].mdep_role = sup_feature.list_elem[i].mdep_role;
17935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        /* Check MDEP Description pointer to prevent crash due to null pointer */
17945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        if (sup_feature.list_elem[i].p_mdep_desp != NULL)
17955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        {
17965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            BCM_STRNCPY_S(p_hdp_rec->mdep_cfg[i].mdep_desp,
17975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                    sizeof(p_hdp_rec->mdep_cfg[i].mdep_desp),
17985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                    sup_feature.list_elem[i].p_mdep_desp,
17995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                    BTA_HL_MDEP_DESP_LEN);
18005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        }
18015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        else
18025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        {
1803e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                            APPL_TRACE_ERROR("bta_hl_sdp_cback Incorrect Mdep[%d] Description (Null ptr)", i);
18045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        }
18055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    }
18065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    sdp_parsing_ok = TRUE;
18085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
18095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
18105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
1811e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                    APPL_TRACE_WARNING("HDP supported feature list fill failed");
18125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    break;
18135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
18145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
18155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
18165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
1817e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                APPL_TRACE_WARNING("HDP supported feature list not found");
18185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
18195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
18205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
1821e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_DEBUG("record=%d ctrl_psm=%0x data_psm=%x",
18225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              rec_cnt+1,
18235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_hdp_rec->ctrl_psm,
18245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_hdp_rec->data_psm );
1825e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_DEBUG("srv_name=[%s]",(p_hdp_rec->srv_name[0] != '\0')? p_hdp_rec->srv_name:"NULL");
1826e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_DEBUG("srv_desp=[%s]",(p_hdp_rec->srv_desp[0] != '\0')? p_hdp_rec->srv_desp:"NULL");
18275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            for (i=0; i<sup_feature.num_elems; i++)
18285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
1829e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                APPL_TRACE_DEBUG("index=0x%02x mdep_id=0x%04x data type=0x%04x mdep role=%s(0x%02x)",
18305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  (i+1),
18315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_hdp_rec->mdep_cfg[i].mdep_id,
18325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_hdp_rec->mdep_cfg[i].data_type,
18335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  (p_hdp_rec->mdep_cfg[i].mdep_role == BTA_HL_MDEP_ROLE_SOURCE)?"Src":"Snk",
18345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                  p_hdp_rec->mdep_cfg[i].mdep_role);
18355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
1836e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_DEBUG("provider_name=[%s]",(p_hdp_rec->provider_name[0] != '\0')? p_hdp_rec->provider_name:"NULL");
1837e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_DEBUG("found MCAP sup procedure=%d",
18385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                              p_cb->sdp.sdp_rec[rec_cnt].mcap_sup_proc );
18395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
18405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            rec_cnt++;
18415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (rec_cnt >= BTA_HL_NUM_SDP_RECS)
18425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
1843e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati                APPL_TRACE_WARNING("No more spaces for SDP recs max_rec_cnt=%d", BTA_HL_NUM_SDP_RECS);
18445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                break;
18455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
18465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        } while (TRUE);
18495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
18505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    utl_freebuf((void **)&p_cb->p_db);
18535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if ( (status == SDP_SUCCESS || status == SDP_DB_FULL) &&
18555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project         p_cb->sdp.num_recs  &&
18565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project         sdp_parsing_ok)
18575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
18585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        result = TRUE;
18595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
18605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
18615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
1862e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati        APPL_TRACE_WARNING("SDP Failed sdp_status=%d num_recs=%d sdp_parsing_ok=%d ",
18635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            status, p_cb->sdp.num_recs,sdp_parsing_ok );
18645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
18655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_cb->sdp_oper = BTA_HL_SDP_OP_NONE;
18685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (sdp_oper )
18705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
18715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_SDP_OP_CCH_INIT:
18725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_SDP_OP_SDP_QUERY_NEW:
18735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_SDP_OP_SDP_QUERY_CURRENT:
18745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
18755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            /* send result in event back to BTA */
18765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if ((p_cch_buf = (tBTA_HL_CCH_SDP *) GKI_getbuf(sizeof(tBTA_HL_CCH_SDP))) != NULL)
18775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
18785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (result)
18795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
18805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    if (sdp_oper == BTA_HL_SDP_OP_CCH_INIT)
18815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    {
18825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        event = BTA_HL_CCH_SDP_OK_EVT;
18835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        if (p_cb->close_pending)
18845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        {
18855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            event = BTA_HL_CCH_SDP_FAIL_EVT;
18865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        }
18875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    }
18885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    else
18895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    {
18905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        event = BTA_HL_SDP_QUERY_OK_EVT;
18915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    }
18925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
18935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                else
18945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
18955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    if (sdp_oper == BTA_HL_SDP_OP_CCH_INIT)
18965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    {
18975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        event = BTA_HL_CCH_SDP_FAIL_EVT;
18985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    }
18995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    else
19005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    {
19015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        event = BTA_HL_SDP_QUERY_FAIL_EVT;
19025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    }
19035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
19045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_cch_buf->hdr.event = event;
19055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
19065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_cch_buf->app_idx = app_idx;
19075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_cch_buf->mcl_idx = mcl_idx;
19085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_cch_buf->release_mcl_cb = FALSE;
19095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (sdp_oper == BTA_HL_SDP_OP_SDP_QUERY_NEW)
19105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
19115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    p_cch_buf->release_mcl_cb = TRUE;
19125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
19135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
19145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_sys_sendmsg(p_cch_buf);
19155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
19165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
19175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_SDP_OP_DCH_OPEN_INIT:
19185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_SDP_OP_DCH_RECONNECT_INIT:
19195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if ((p_dch_buf = (tBTA_HL_DCH_SDP *) GKI_getbuf(sizeof(tBTA_HL_DCH_SDP))) != NULL)
19205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
19215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dch_buf->hdr.event = BTA_HL_DCH_SDP_FAIL_EVT;
19225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dch_buf->app_idx = app_idx;
19235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dch_buf->mcl_idx = mcl_idx;
19245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dch_buf->mdl_idx = mdl_idx;
19255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
19265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (p_dcb->abort_oper & BTA_HL_ABORT_PENDING_MASK)
19275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
19285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    p_dcb->abort_oper &= ~BTA_HL_ABORT_PENDING_MASK;
19295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    result = FALSE;
19305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
19315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                if (result)
19325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                {
19335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    if (sdp_oper == BTA_HL_SDP_OP_DCH_OPEN_INIT)
19345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    {
19355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        if (p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID )
19365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        {
19375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            p_dch_buf->hdr.event = BTA_HL_DCH_ECHO_TEST_EVT;
19385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        }
19395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        else
19405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        {
19415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            p_dch_buf->hdr.event = BTA_HL_DCH_OPEN_EVT;
19425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        }
19435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    }
19445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    else
19455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    {
19465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                        p_dch_buf->hdr.event = BTA_HL_DCH_RECONNECT_EVT;
19475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                    }
19485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                }
19495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_sys_sendmsg(p_dch_buf);
19505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
19515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
19525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
19535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
19545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
19555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
19565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
19575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
19585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
19595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_sdp_cback0
19615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This is the SDP callback function used by index = 0
19635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void.
19655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/
19675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback0(UINT16 status)
19685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
19695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback(bta_hl_cb.scb[0].sdp_oper,
19705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[0].app_idx,
19715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[0].mcl_idx,
19725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[0].mdl_idx,
19735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     status);
19745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_deallocate_spd_cback(0);
19755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
19765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
19775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
19785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_sdp_cback1
19805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This is the SDP callback function used by index = 1
19825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters       status  - status of the SDP callabck
19845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void.
19865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
19875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/
19885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback1(UINT16 status)
19895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
19905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback(bta_hl_cb.scb[1].sdp_oper,
19915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[1].app_idx,
19925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[1].mcl_idx,
19935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[1].mdl_idx,
19945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     status);
19955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_deallocate_spd_cback(1);
19965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
19975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
19985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
19995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_sdp_cback2
20015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This is the SDP callback function used by index = 2
20035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void.
20055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/
20075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback2(UINT16 status)
20085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
20095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback(bta_hl_cb.scb[2].sdp_oper,
20105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[2].app_idx,
20115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[2].mcl_idx,
20125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[2].mdl_idx,
20135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     status);
20145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_deallocate_spd_cback(2);
20155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
20165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
20175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
20185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_sdp_cback3
20205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This is the SDP callback function used by index = 3
20225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void.
20245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/
20265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback3(UINT16 status)
20275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
20285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback(bta_hl_cb.scb[3].sdp_oper,
20295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[3].app_idx,
20305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[3].mcl_idx,
20315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[3].mdl_idx,
20325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     status);
20335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_deallocate_spd_cback(3);
20345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
20355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
20365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
20375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_sdp_cback4
20395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This is the SDP callback function used by index = 4
20415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters       status  - status of the SDP callabck
20435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void.
20455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/
20475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback4(UINT16 status)
20485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
20495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback(bta_hl_cb.scb[4].sdp_oper,
20505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[4].app_idx,
20515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[4].mcl_idx,
20525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[4].mdl_idx,
20535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     status);
20545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_deallocate_spd_cback(4);
20555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
20565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
20575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
20585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_sdp_cback5
20605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This is the SDP callback function used by index = 5
20625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters       status  - status of the SDP callabck
20645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void.
20665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/
20685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback5(UINT16 status)
20695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
20705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback(bta_hl_cb.scb[5].sdp_oper,
20715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[5].app_idx,
20725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[5].mcl_idx,
20735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[5].mdl_idx,
20745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     status);
20755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_deallocate_spd_cback(5);
20765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
20775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
20785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************
20795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_sdp_cback6
20815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      This is the SDP callback function used by index = 6
20835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void.
20855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
20865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project******************************************************************************/
20875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_hl_sdp_cback6(UINT16 status)
20885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
20895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_sdp_cback(bta_hl_cb.scb[6].sdp_oper,
20905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[6].app_idx,
20915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[6].mcl_idx,
20925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     bta_hl_cb.scb[6].mdl_idx,
20935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                     status);
20945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_deallocate_spd_cback(6);
20955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
20965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
20975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
20985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
20995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function      bta_hl_deallocate_spd_cback
21015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description   Deallocate a SDP control block
21035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns      BOOLEAN - TRUE found
21055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                        FALSE not found
21065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
21085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_deallocate_spd_cback(UINT8 sdp_cback_idx)
21095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
21105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_SDP_CB *p_spd_cb = &bta_hl_cb.scb[sdp_cback_idx];
21115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    memset(p_spd_cb, 0, sizeof(tBTA_HL_SDP_CB));
21135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2115e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_deallocate_spd_cback index=%d", sdp_cback_idx);
21165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
21175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
21205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
21225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function      bta_hl_allocate_spd_cback
21245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description   Finds a not in used SDP control block index
21265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns      BOOLEAN - TRUE found
21295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**                        FALSE not found
21305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
21325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttSDP_DISC_CMPL_CB *bta_hl_allocate_spd_cback(tBTA_HL_SDP_OPER sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
21335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                             UINT8 mdl_idx,
21345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                             UINT8 *p_sdp_cback_idx)
21355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
21365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8 i;
21375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tSDP_DISC_CMPL_CB *p_cbcak=NULL;
21385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    for (i=0; i < BTA_HL_NUM_SDP_CBACKS ; i ++)
21415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
21425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (!bta_hl_cb.scb[i].in_use)
21435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
21445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_cbcak = bta_hl_sdp_cback_arr[i];
21455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_cb.scb[i].in_use = TRUE;
21465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_cb.scb[i].sdp_oper = sdp_oper;
21475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_cb.scb[i].app_idx = app_idx;
21485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_cb.scb[i].mcl_idx = mcl_idx;
21495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_cb.scb[i].mdl_idx = mdl_idx;
21505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            *p_sdp_cback_idx = i;
21515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
21525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
21535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
21545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (i == BTA_HL_NUM_SDP_CBACKS)
21565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
2157e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati        APPL_TRACE_WARNING("No scb is available to allocate")
21585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
21595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
21605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
21615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2162e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_allocate_spd_cback cback_idx=%d ",i );
2163e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("sdp_oper=%d, app_idx=%d, mcl_idx=%d,  mdl_idx=%d",
21645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      bta_hl_cb.scb[i].sdp_oper,
21655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      bta_hl_cb.scb[i].app_idx,
21665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      bta_hl_cb.scb[i].mcl_idx,
21675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      bta_hl_cb.scb[i].mdl_idx );
21685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
21695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
21705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    return p_cbcak;
21715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
21725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
21745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
21755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_init_sdp
21775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the SDP initiattion request
21795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
21815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
21825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
21835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttBTA_HL_STATUS bta_hl_init_sdp(tBTA_HL_SDP_OPER sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
21845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                               UINT8 mdl_idx)
21855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
21865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_cb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
21875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tSDP_UUID           uuid_list;
21885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT16              attr_list[BTA_HL_NUM_SRCH_ATTR];
21895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT16              num_attrs = BTA_HL_NUM_SRCH_ATTR;
21905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_STATUS      status;
21915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               sdp_cback_idx;
21925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2193e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_init_sdp sdp_oper=%d app_idx=%d mcl_idx=%d, mdl_idx=%d",
21945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                      sdp_oper, app_idx, mcl_idx, mdl_idx);
21955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
21965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if ((p_cb->sdp_cback = bta_hl_allocate_spd_cback(sdp_oper, app_idx, mcl_idx, mdl_idx, &sdp_cback_idx)) != NULL)
21975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
21985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ( p_cb->p_db ||
21995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project             (!p_cb->p_db &&
22005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project              (p_cb->p_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_HL_DISC_SIZE)) != NULL))
22015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
22025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
22035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
22045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
22055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[3] = ATTR_ID_ADDITION_PROTO_DESC_LISTS;
22065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[4] = ATTR_ID_SERVICE_NAME;
22075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[5] = ATTR_ID_SERVICE_DESCRIPTION;
22085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[6] = ATTR_ID_PROVIDER_NAME;
22095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[7] = ATTR_ID_HDP_SUP_FEAT_LIST;
22105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[8] = ATTR_ID_HDP_DATA_EXCH_SPEC;
22115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            attr_list[9] = ATTR_ID_HDP_MCAP_SUP_PROC;
22125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            uuid_list.len = LEN_UUID_16;
22155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            uuid_list.uu.uuid16 = UUID_SERVCLASS_HDP_PROFILE;
22165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            SDP_InitDiscoveryDb(p_cb->p_db, BTA_HL_DISC_SIZE, 1, &uuid_list, num_attrs, attr_list);
22175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (!SDP_ServiceSearchAttributeRequest(p_cb->bd_addr, p_cb->p_db, p_cb->sdp_cback))
22195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
22205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                status = BTA_HL_STATUS_FAIL;
22215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
22225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
22235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
22245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                status = BTA_HL_STATUS_OK;
22255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
22265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
22275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        else    /* No services available */
22285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
22295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            status = BTA_HL_STATUS_NO_RESOURCE;
22305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
22315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
22325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
22335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
22345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        status = BTA_HL_STATUS_SDP_NO_RESOURCE;
22355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
22365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (status != BTA_HL_STATUS_OK)
22385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
22395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        utl_freebuf((void **)&p_cb->p_db);
22405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (status != BTA_HL_STATUS_SDP_NO_RESOURCE )
22415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
22425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_deallocate_spd_cback(sdp_cback_idx);
22435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
22445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
22455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    return status;
22475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
22485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
22505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
22515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_cch_sdp_init
22525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
22535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the CCH SDP init event
22545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
22555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
22565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
22575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
22585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_cch_sdp_init(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data)
22595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
22605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_cb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
22615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2262e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_cch_init_sdp");
22635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
22645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if ( p_cb->sdp_oper == BTA_HL_SDP_OP_NONE)
22655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
2266f8f30c2cecf221b2c3983b72d5a849d799c39dd7Priti Aghera        p_cb->app_id = p_data->api_cch_open.app_id;
22675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_cb->sdp_oper = BTA_HL_SDP_OP_CCH_INIT;
22685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (bta_hl_init_sdp( p_cb->sdp_oper, app_idx, mcl_idx, 0xFF) != BTA_HL_STATUS_OK)
22705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
22715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_cb->sdp_oper = BTA_HL_SDP_OP_NONE;
22725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_SDP_FAIL_EVT, p_data);
22735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
22745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
22755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
22765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
2277e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati        APPL_TRACE_ERROR("SDP in use");
22785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_SDP_FAIL_EVT, p_data);
22795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
22805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
22815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
22835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
22845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_cch_mca_open
22855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
22865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the CCH open request
22875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
22885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
22895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
22905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
22915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_cch_mca_open(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data)
22925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
22935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
22945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
22955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8               sdp_idx;
22965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
22975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2298e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_cch_mca_open");
22995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
23005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
23015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (bta_hl_find_sdp_idx_using_ctrl_psm(&p_mcb->sdp, p_mcb->req_ctrl_psm, &sdp_idx))
23025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
23035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_mcb->ctrl_psm = p_mcb->sdp.sdp_rec[sdp_idx].ctrl_psm;
23045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_mcb->data_psm = p_mcb->sdp.sdp_rec[sdp_idx].data_psm;
23055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ( MCA_ConnectReq((tMCA_HANDLE) p_acb->app_handle,
23065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            p_mcb->bd_addr,
23075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            p_mcb->ctrl_psm ,
23085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                            p_mcb->sec_mask) != MCA_SUCCESS)
23095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
23105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
23115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_CLOSE_CMPL_EVT, p_data);
23125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
23135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
23145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
23155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
23165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_CLOSE_CMPL_EVT, p_data);
23175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
23185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
23195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
23205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
23215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
23225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_cch_mca_close
23235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
23245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the CCH close request
23255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
23265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
23275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
23285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
23295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_cch_mca_close(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data)
23305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
23315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
23325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
23335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2334e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_cch_mca_close mcl_handle=%d", p_mcb->mcl_handle);
23355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
23365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_mcb->sdp_oper != BTA_HL_SDP_OP_CCH_INIT)
23375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
2338ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta        if(p_mcb->mcl_handle)
23395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
2340ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta            if ( MCA_DisconnectReq((tMCA_HANDLE) p_mcb->mcl_handle) != MCA_SUCCESS)
2341ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta            {
2342ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta                bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_CLOSE_CMPL_EVT, p_data);
2343ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta            }
2344ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta        }
2345ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta        else
2346ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta        {
2347ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta            p_mcb->close_pending = TRUE;
2348e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati            APPL_TRACE_DEBUG("No valid mcl_handle to stop the CCH setup now so wait until CCH is up then close it" );
23495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
23505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
23515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    else
23525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
23535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_mcb->close_pending = TRUE;
2354e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati        APPL_TRACE_DEBUG("can not stop the CCH setup becasue SDP is in progress so wait until it is done" );
23555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
23565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
23575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
23585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
23595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
23605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_cch_close_cmpl
23615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
23625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the CCH close complete event
23635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
23645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
23655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
23665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
23675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_cch_close_cmpl(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data)
23685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
23695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
23705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
23715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
23725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
23735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_EVT         event;
23745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             send_evt=TRUE;
23755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2376e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_cch_close_cmpl");
23775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
23785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_sys_conn_close(BTA_ID_HL, p_acb->app_id, p_mcb->bd_addr);
23795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2380ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    if (p_mcb->cch_oper == BTA_HL_CCH_OP_LOCAL_CLOSE && p_mcb->force_close_local_cch_opening)
2381ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    {
2382ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta       p_mcb->cch_oper = BTA_HL_CCH_OP_LOCAL_OPEN;
2383e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati       APPL_TRACE_DEBUG("change cch_oper from BTA_HL_CCH_OP_LOCAL_CLOSE to BTA_HL_CCH_OP_LOCAL_OPEN");
2384ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    }
2385ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta
23865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (p_mcb->cch_oper)
23875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
23885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CCH_OP_LOCAL_OPEN:
2389f8f30c2cecf221b2c3983b72d5a849d799c39dd7Priti Aghera            bta_hl_build_cch_open_cfm(&evt_data,p_mcb->app_id,p_acb->app_handle,
23905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                      p_mcb->mcl_handle,
23915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                      p_mcb->bd_addr,
23925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                      BTA_HL_STATUS_FAIL);
23935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            event = BTA_HL_CCH_OPEN_CFM_EVT;
23945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
23955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CCH_OP_LOCAL_CLOSE:
23965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_build_cch_close_cfm(&evt_data,  p_acb->app_handle,
23975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
23985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       BTA_HL_STATUS_OK);
23995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            event = BTA_HL_CCH_CLOSE_CFM_EVT;
24005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
24015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CCH_OP_REMOTE_CLOSE:
24025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_build_cch_close_ind(&evt_data,
24035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_acb->app_handle,
24045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->mcl_handle,
24055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                       p_mcb->intentional_close);
24065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            event = BTA_HL_CCH_CLOSE_IND_EVT;
24075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
24085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
24095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            send_evt=FALSE;
24105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
24115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
24125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    memset(p_mcb, 0 ,sizeof(tBTA_HL_MCL_CB));
24155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (send_evt)p_acb->p_cback(event,(tBTA_HL *) &evt_data );
24175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_check_deregistration(app_idx, p_data);
24195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
24205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
24225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
24235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_cch_mca_disconnect
24245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
24255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the CCH disconnect indication
24265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
24275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
24285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
24295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
24305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_cch_mca_disconnect(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data)
24315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
24325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
24345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MDL_CB      *p_dcb;
24355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8              i;
24365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2437e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_cch_mca_disconnect");
24385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
24395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_mcb->intentional_close = FALSE;
24415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (p_data->mca_evt.mca_data.disconnect_ind.reason == L2CAP_DISC_OK)
24425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
24435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_mcb->intentional_close = TRUE;
24445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
24455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    for (i=0; i< BTA_HL_NUM_MDLS_PER_MCL; i++)
24475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
24485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_dcb= BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, i);
24495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if (p_dcb->in_use && (p_dcb->dch_state != BTA_HL_DCH_IDLE_ST))
24505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
24515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            if (p_mcb->cch_oper == BTA_HL_CCH_OP_LOCAL_CLOSE )
24525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
24535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_dch_sm_execute(app_idx, mcl_idx, i, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
24545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
24555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            else
24565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            {
24575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                bta_hl_dch_sm_execute(app_idx, mcl_idx, i, BTA_HL_MCA_CLOSE_IND_EVT, p_data);
24585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            }
24595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
24605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
24615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_CLOSE_CMPL_EVT, p_data);
24625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
24635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
24655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
2466ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Function         bta_hl_cch_mca_disc_open
2467ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta**
2468ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Description      Action routine for disconnect the just opened Control channel
2469ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta**
2470ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Returns          void
2471ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta**
2472ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta*******************************************************************************/
2473ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battavoid bta_hl_cch_mca_disc_open(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data)
2474ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta{
2475ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2476ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta
2477ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if BTA_HL_DEBUG == TRUE
2478e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_cch_mca_disc_open mcl_handle=0x%x close_pending=%d", p_data->mca_evt.mcl_handle, p_mcb->close_pending );
2479ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#endif
2480ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta
2481ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    p_mcb->close_pending = FALSE;
2482ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    p_mcb->mcl_handle = p_data->mca_evt.mcl_handle;
2483ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    bta_hl_cch_mca_close(app_idx, mcl_idx, p_data);
2484ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta}
2485ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta
2486ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta/*******************************************************************************
2487ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta**
24885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_cch_mca_rsp_tout
24895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
24905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the MCAP response timeout
24915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
24925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
24935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
24945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
24955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_cch_mca_rsp_tout(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data)
24965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
24975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
24985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
24995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2500e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_cch_mca_rsp_tout");
25015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
25025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_mcb->rsp_tout = TRUE;
25045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_hl_check_cch_close(app_idx,mcl_idx,p_data,TRUE);
25065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
2507ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta
25085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
25095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
25105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_cch_mca_connect
25115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
25125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Action routine for processing the CCH connect indication
25135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
25145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
25155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
25165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
25175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_cch_mca_connect(UINT8 app_idx, UINT8 mcl_idx,  tBTA_HL_DATA *p_data)
25185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
25195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_APP_CB      *p_acb  = BTA_HL_GET_APP_CB_PTR(app_idx);
25205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCL_CB      *p_mcb  = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
25215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL             evt_data;
25225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_EVT         event;
25235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN             send_event=TRUE;
25245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if BTA_HL_DEBUG == TRUE
2526e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_DEBUG("bta_hl_cch_mca_connect mcl_handle=%d ", p_data->mca_evt.mcl_handle);
25275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
25285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_mcb->mcl_handle = p_data->mca_evt.mcl_handle;
25305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bdcpy(p_mcb->bd_addr, p_data->mca_evt.mca_data.connect_ind.bd_addr);
25315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_mcb->cch_mtu = p_data->mca_evt.mca_data.connect_ind.mtu;
25325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    bta_sys_conn_open(BTA_ID_HL, p_acb->app_id, p_mcb->bd_addr);
25345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (p_mcb->cch_oper)
25355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
25365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CCH_OP_LOCAL_OPEN:
2537f8f30c2cecf221b2c3983b72d5a849d799c39dd7Priti Aghera            bta_hl_build_cch_open_cfm(&evt_data, p_mcb->app_id,p_acb->app_handle,
25385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                      p_mcb->mcl_handle,
25395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                      p_mcb->bd_addr,
25405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                      BTA_HL_STATUS_OK);
25415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            event = BTA_HL_CCH_OPEN_CFM_EVT;
25425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
25435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CCH_OP_REMOTE_OPEN:
25445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_hl_build_cch_open_ind(&evt_data, p_acb->app_handle,
25455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                      p_mcb->mcl_handle,
25465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                                      p_mcb->bd_addr);
25475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            event = BTA_HL_CCH_OPEN_IND_EVT;
25485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
25495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
25505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            send_event = FALSE;
25515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
25525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
25535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    p_mcb->cch_oper = BTA_HL_CCH_OP_NONE;
25555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (send_event) p_acb->p_cback(event,(tBTA_HL *) &evt_data );
25565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
25575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
25595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
25605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_mcap_ctrl_cback
25615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
25625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      MCAP control callback function for HL.
25635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
25645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
25655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
25665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
25675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_mcap_ctrl_cback (tMCA_HANDLE handle, tMCA_CL mcl, UINT8 event,
25685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project                             tMCA_CTRL *p_data)
25695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
25705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCA_EVT * p_msg;
25715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    BOOLEAN send_event=TRUE;
25725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT16 mca_event;
25735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE)
25755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BT_TRACE_VERBOSE == TRUE)
2576e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_EVENT("bta_hl_mcap_ctrl_cback event[%s]",bta_hl_mcap_evt_code(event));
25775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else
2578e8c3d75b75493911ebf0f99c83676359657178f7Sharvil Nanavati    APPL_TRACE_EVENT("bta_hl_mcap_ctrl_cback event[0x%02x]", event);
25795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
25805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif
25815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (event)
25835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
25845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
25855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CREATE_IND_EVT:
25865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_CREATE_IND_EVT;
25875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
25885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CREATE_CFM_EVT:
25895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_CREATE_CFM_EVT;
25905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
25915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_RECONNECT_IND_EVT:
25925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_RECONNECT_IND_EVT;
25935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
25945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_RECONNECT_CFM_EVT:
25955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_RECONNECT_CFM_EVT;
25965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
25975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_ABORT_IND_EVT:
25985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_ABORT_IND_EVT;
25995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_ABORT_CFM_EVT:
26015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_ABORT_CFM_EVT;
26025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_DELETE_IND_EVT:
26045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_DELETE_IND_EVT;
26055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_DELETE_CFM_EVT:
26075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_DELETE_CFM_EVT;
26085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CONNECT_IND_EVT:
26105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_CONNECT_IND_EVT;
26115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_DISCONNECT_IND_EVT:
26135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_DISCONNECT_IND_EVT;
26145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_OPEN_IND_EVT:
26165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_OPEN_IND_EVT;
26175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_OPEN_CFM_EVT:
26195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_OPEN_CFM_EVT;
26205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CLOSE_IND_EVT:
26225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_CLOSE_IND_EVT;
26235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CLOSE_CFM_EVT:
26255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_CLOSE_CFM_EVT;
26265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CONG_CHG_EVT:
26285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_CONG_CHG_EVT;
26295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_RSP_TOUT_IND_EVT:
26315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            mca_event = (UINT16) BTA_HL_MCA_RSP_TOUT_IND_EVT;
26325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_ERROR_RSP_EVT:
26345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
26355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
26365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            send_event=FALSE;
26375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            break;
26385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
26395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
2640ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta    if (send_event && ((p_msg = (tBTA_HL_MCA_EVT *)GKI_getbuf(sizeof(tBTA_HL_MCA_EVT))) != NULL))
26415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
26425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_msg->hdr.event = mca_event;
26435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_msg->app_handle = (tBTA_HL_APP_HANDLE) handle;
26445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        p_msg->mcl_handle = (tBTA_HL_MCL_HANDLE) mcl;
26455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        memcpy (&p_msg->mca_data, p_data, sizeof(tMCA_CTRL));
26465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        bta_sys_sendmsg(p_msg);
26475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
26485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
26495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
26505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
26515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
26525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_mcap_data_cback
26535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
26545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      MCAP data callback function for HL.
26555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
26565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          void
26575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
26585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
26595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_hl_mcap_data_cback (tMCA_DL mdl, BT_HDR *p_pkt)
26605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
26615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    tBTA_HL_MCA_RCV_DATA_EVT *p_msg;
26625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
26635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    UINT8 app_idx, mcl_idx, mdl_idx;
26645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    if (bta_hl_find_mdl_idx_using_handle ((tBTA_HL_MDL_HANDLE)mdl, &app_idx, &mcl_idx, &mdl_idx))
26655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
26665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        if ((p_msg = (tBTA_HL_MCA_RCV_DATA_EVT *)GKI_getbuf(sizeof(tBTA_HL_MCA_RCV_DATA_EVT))) != NULL)
26675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        {
26685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_msg->hdr.event = BTA_HL_MCA_RCV_DATA_EVT;
26695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_msg->app_idx = app_idx;
26705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_msg->mcl_idx = mcl_idx;
26715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_msg->mdl_idx = mdl_idx;
26725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            p_msg->p_pkt = p_pkt;
26735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            bta_sys_sendmsg(p_msg);
26745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        }
26755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
26765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
26775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*****************************************************************************
26785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**  Debug Functions
26795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/
26805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HL_DEBUG == TRUE && BT_TRACE_VERBOSE == TRUE)
26815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
26825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
26835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
26845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_mcap_evt_code
26855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
26865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      get the MCAP event string pointer
26875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
26885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          char * - event string pointer
26895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
26905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
26915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic char *bta_hl_mcap_evt_code(UINT8 evt_code)
26925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
26935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
26945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (evt_code)
26955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
26965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
26975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_ERROR_RSP_EVT:
26985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_ERROR_RSP_EVT";
26995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CREATE_IND_EVT:
27005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_CREATE_IND_EVT";
27015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CREATE_CFM_EVT:
27025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_CREATE_CFM_EVT";
27035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_RECONNECT_IND_EVT:
27045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_RECONNECT_IND_EVT";
27055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_RECONNECT_CFM_EVT:
27065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_RECONNECT_CFM_EVT";
27075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_ABORT_IND_EVT:
27085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_ABORT_IND_EVT";
27095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_ABORT_CFM_EVT:
27105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_ABORT_CFM_EVT";
27115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_DELETE_IND_EVT:
27125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_DELETE_IND_EVT";
27135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_DELETE_CFM_EVT:
27145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_DELETE_CFM_EVT";
27155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
27165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CONNECT_IND_EVT:
27175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_CONNECT_IND_EVT";
27185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_DISCONNECT_IND_EVT:
27195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_DISCONNECT_IND_EVT";
27205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_OPEN_IND_EVT:
27215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_OPEN_IND_EVT";
27225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_OPEN_CFM_EVT:
27235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_OPEN_CFM_EVT";
27245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CLOSE_IND_EVT:
27255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_CLOSE_IND_EVT";
27265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CLOSE_CFM_EVT:
27275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_CLOSE_CFM_EVT";
27285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_CONG_CHG_EVT:
27295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_CONG_CHG_EVT";
27305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case MCA_RSP_TOUT_IND_EVT:
27315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "MCA_RSP_TOUT_IND_EVT";
27325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
27335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "Unknown MCAP event code";
27345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
27355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
27365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
27375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
27385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
27395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
27405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_cback_evt_code
27415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
27425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      get the HDP event string pointer
27435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
27445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          char * - event string pointer
27455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
27465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
27475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic char *bta_hl_cback_evt_code(UINT8 evt_code)
27485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
27495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
27505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (evt_code)
27515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
27525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
27535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CCH_OPEN_IND_EVT:
27545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_CCH_OPEN_IND_EVT";
27555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CCH_OPEN_CFM_EVT:
27565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_CCH_OPEN_CFM_EVT";
27575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CCH_CLOSE_IND_EVT:
27585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_CCH_CLOSE_IND_EVT";
27595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case     BTA_HL_CCH_CLOSE_CFM_EVT:
27605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_CCH_CLOSE_CFM_EVT";
27615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OPEN_IND_EVT:
27625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OPEN_IND_EVT";
27635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OPEN_CFM_EVT:
27645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OPEN_CFM_EVT";
27655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_CLOSE_IND_EVT:
27665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_CLOSE_IND_EVT";
27675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_CLOSE_CFM_EVT:
27685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_CLOSE_CFM_EVT";
27695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_RCV_DATA_IND_EVT:
27705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_RCV_DATA_IND_EVT";
27715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_REGISTER_CFM_EVT:
27725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_REGISTER_CFM_EVT";
27735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DEREGISTER_CFM_EVT:
27745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DEREGISTER_CFM_EVT";
27755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_RECONNECT_CFM_EVT:
27765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_RECONNECT_CFM_EVT";
27775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_RECONNECT_IND_EVT:
27785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_RECONNECT_IND_EVT";
27795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_ECHO_TEST_CFM_EVT:
27805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_ECHO_TEST_CFM_EVT";
27815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_SDP_QUERY_CFM_EVT:
27825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_SDP_QUERY_CFM_EVT";
27835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_CONG_CHG_IND_EVT:
27845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_CONG_CHG_IND_EVT";
27855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_CREATE_IND_EVT:
27865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_CREATE_IND_EVT";
27875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DELETE_MDL_IND_EVT:
27885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DELETE_MDL_IND_EVT";
27895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DELETE_MDL_CFM_EVT:
27905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DELETE_MDL_CFM_EVT";
27915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_ABORT_IND_EVT:
27925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_ABORT_IND_EVT";
27935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_ABORT_CFM_EVT:
27945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_ABORT_CFM_EVT";
27955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
27965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "Unknown HDP event code";
27975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
27985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
27995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
28005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
28015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
28025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/*******************************************************************************
28035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
28045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function         bta_hl_dch_oper_code
28055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
28065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description      Get the DCH operation string
28075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
28085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns          char * - DCH operation string pointer
28095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project**
28105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/
28115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic char *bta_hl_dch_oper_code(tBTA_HL_DCH_OPER oper_code)
28125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{
28135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
28145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    switch (oper_code)
28155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    {
28165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_NONE:
28175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_NONE";
28185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_CREATE:
28195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_REMOTE_CREATE";
28205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_OPEN:
28215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_LOCAL_OPEN";
28225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_OPEN:
28235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_REMOTE_OPEN";
28245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE:
28255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_LOCAL_CLOSE";
28265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_CLOSE:
28275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_REMOTE_CLOSE";
28285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_DELETE:
28295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_LOCAL_DELETE";
28305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_DELETE:
28315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_REMOTE_DELETE";
28325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_RECONNECT:
28335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_LOCAL_RECONNECT";
28345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_REMOTE_RECONNECT:
28355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_REMOTE_RECONNECT";
28365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST:
28375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST";
28385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        case BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT:
28395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT";
28405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project        default:
28415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project            return "Unknown DCH oper code";
28425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project    }
28435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project}
28445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
28455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project
28465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif  /* Debug Functions */
28475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif /* HL_INCLUDED */
2848