1 /******************************************************************************
3 * Copyright (C) 2003-2012 Broadcom Corporation
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 ******************************************************************************/
19 /******************************************************************************
21 * This file contains the HeaLth device profile (HL) action functions for
24 ******************************************************************************/
28 #include "bt_target.h"
29 #if defined(HL_INCLUDED) && (HL_INCLUDED == TRUE)
31 #include "bt_common.h"
36 #include "bta_hl_api.h"
37 #include "bta_hl_int.h"
42 /*****************************************************************************
43 ** Local Function prototypes
44 *****************************************************************************/
45 #if (BTA_HL_DEBUG == TRUE && BT_TRACE_VERBOSE == TRUE)
46 static char *bta_hl_mcap_evt_code(UINT8 evt_code);
47 static char *bta_hl_dch_oper_code(tBTA_HL_DCH_OPER oper_code);
48 static char *bta_hl_cback_evt_code(UINT8 evt_code);
50 static void bta_hl_sdp_cback(UINT8 sdp_op, UINT8 app_idx, UINT8 mcl_idx,
51 UINT8 mdl_idx, UINT16 status);
52 static void bta_hl_sdp_cback0(UINT16 status);
53 static void bta_hl_sdp_cback1(UINT16 status);
54 static void bta_hl_sdp_cback2(UINT16 status);
55 static void bta_hl_sdp_cback3(UINT16 status);
56 static void bta_hl_sdp_cback4(UINT16 status);
57 static void bta_hl_sdp_cback5(UINT16 status);
58 static void bta_hl_sdp_cback6(UINT16 status);
61 static tSDP_DISC_CMPL_CB * const bta_hl_sdp_cback_arr[] =
74 /*******************************************************************************
76 ** Function bta_hl_dch_mca_cong_change
78 ** Description Action routine for processing congestion change notification
82 *******************************************************************************/
83 void bta_hl_dch_mca_cong_change(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
86 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
87 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
88 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
89 tMCA_CONG_CHG *p_cong_chg = &p_data->mca_evt.mca_data.cong_chg;
92 #if (BTA_HL_DEBUG == TRUE)
93 APPL_TRACE_DEBUG("bta_hl_dch_mca_cong_change mdl_id=%d cong=%d",
97 evt_data.dch_cong_ind.cong =
98 p_dcb->cong = p_cong_chg->cong;
99 evt_data.dch_cong_ind.mdl_handle = p_dcb->mdl_handle;
100 evt_data.dch_cong_ind.mcl_handle = p_mcb->mcl_handle;
101 evt_data.dch_cong_ind.app_handle = p_acb->app_handle;
103 p_acb->p_cback(BTA_HL_CONG_CHG_IND_EVT ,(tBTA_HL *) &evt_data );
108 /*******************************************************************************
110 ** Function bta_hl_dch_echo_test
112 ** Description Action routine for processing echo test request
116 *******************************************************************************/
117 void bta_hl_dch_echo_test(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
118 tBTA_HL_DATA *p_data)
120 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
121 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
122 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
125 #if (BTA_HL_DEBUG == TRUE)
126 APPL_TRACE_DEBUG("bta_hl_dch_echo_test");
129 p_dcb->echo_oper = BTA_HL_ECHO_OP_CI_GET_ECHO_DATA;
130 p_dcb->cout_oper |= BTA_HL_CO_GET_ECHO_DATA_MASK;
132 bta_hl_co_get_echo_data(p_acb->app_id, p_mcb->mcl_handle,
133 p_dcb->p_echo_tx_pkt->len,
134 BTA_HL_GET_BUF_PTR(p_dcb->p_echo_tx_pkt),
135 BTA_HL_CI_GET_ECHO_DATA_EVT);
138 /*******************************************************************************
140 ** Function bta_hl_dch_sdp_init
142 ** Description Action routine for processing DCH SDP initiation
146 *******************************************************************************/
147 void bta_hl_dch_sdp_init(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
148 tBTA_HL_DATA *p_data)
150 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
151 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
153 #if (BTA_HL_DEBUG == TRUE)
154 APPL_TRACE_DEBUG("bta_hl_dch_sdp_init");
156 if ( p_mcb->sdp_oper == BTA_HL_SDP_OP_NONE)
158 p_mcb->sdp_mdl_idx = mdl_idx;
159 if (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_OPEN )
161 p_mcb->sdp_oper = BTA_HL_SDP_OP_DCH_OPEN_INIT;
166 p_mcb->sdp_oper = BTA_HL_SDP_OP_DCH_RECONNECT_INIT;
169 if (bta_hl_init_sdp(p_mcb->sdp_oper, app_idx, mcl_idx, mdl_idx) != BTA_HL_STATUS_OK)
171 APPL_TRACE_ERROR("SDP INIT failed");
172 p_mcb->sdp_oper = BTA_HL_SDP_OP_NONE;
173 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_SDP_FAIL_EVT, p_data);
178 APPL_TRACE_ERROR("SDP in use");
179 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_SDP_FAIL_EVT, p_data);
184 /*******************************************************************************
186 ** Function bta_hl_dch_close_echo_test
188 ** Description Action routine for processing the closing of echo test
192 *******************************************************************************/
193 void bta_hl_dch_close_echo_test(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
194 tBTA_HL_DATA *p_data)
196 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
198 #if (BTA_HL_DEBUG == TRUE)
199 APPL_TRACE_DEBUG("bta_hl_dch_close_echo_test");
202 switch (p_dcb->echo_oper)
204 case BTA_HL_ECHO_OP_DCH_CLOSE_CFM:
205 case BTA_HL_ECHO_OP_OPEN_IND:
206 case BTA_HL_ECHO_OP_ECHO_PKT:
207 p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST;
209 case BTA_HL_ECHO_OP_MDL_CREATE_CFM:
210 case BTA_HL_ECHO_OP_DCH_OPEN_CFM:
211 case BTA_HL_ECHO_OP_LOOP_BACK:
216 if (MCA_CloseReq((tMCA_DL) p_dcb->mdl_handle)!= MCA_SUCCESS)
218 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
223 /*******************************************************************************
225 ** Function bta_hl_dch_mca_rcv_data
227 ** Description Action routine for processing the received data
231 *******************************************************************************/
232 void bta_hl_dch_mca_rcv_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
233 tBTA_HL_DATA *p_data)
235 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
236 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
237 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
239 #if (BTA_HL_DEBUG == TRUE)
240 APPL_TRACE_DEBUG("bta_hl_dch_mca_rcv_data");
243 if (p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID)
245 switch ( p_dcb->echo_oper)
247 case BTA_HL_ECHO_OP_ECHO_PKT:
249 if (MCA_WriteReq((tMCA_DL) p_dcb->mdl_handle, p_data->mca_rcv_data_evt.p_pkt) != MCA_SUCCESS)
251 osi_free_and_reset((void **)&p_data->mca_rcv_data_evt.p_pkt);
252 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_ECHO_TEST_EVT, p_data);
255 case BTA_HL_ECHO_OP_LOOP_BACK:
257 p_dcb->p_echo_rx_pkt = p_data->mca_rcv_data_evt.p_pkt;
258 p_dcb->echo_oper = BTA_HL_ECHO_OP_CI_PUT_ECHO_DATA;
259 p_dcb->cout_oper |= BTA_HL_CO_PUT_ECHO_DATA_MASK;
260 p_dcb->ci_put_echo_data_status = BTA_HL_STATUS_FAIL;
262 bta_hl_co_put_echo_data(p_acb->app_id, p_mcb->mcl_handle,
263 p_dcb->p_echo_rx_pkt->len,
264 BTA_HL_GET_BUF_PTR(p_dcb->p_echo_rx_pkt),
265 BTA_HL_CI_PUT_ECHO_DATA_EVT);
268 APPL_TRACE_ERROR("Unknonw echo_oper=%d",p_dcb->echo_oper);
275 p_dcb->cout_oper |= BTA_HL_CO_PUT_RX_DATA_MASK;
276 p_dcb->p_rx_pkt = p_data->mca_rcv_data_evt.p_pkt;
278 bta_hl_co_put_rx_data(p_acb->app_id, p_dcb->mdl_handle,
279 p_dcb->p_rx_pkt->len,
280 BTA_HL_GET_BUF_PTR(p_dcb->p_rx_pkt),
281 BTA_HL_CI_PUT_RX_DATA_EVT);
288 /*******************************************************************************
290 ** Function bta_hl_dch_ci_put_echo_data
292 ** Description Action routine for processing the call-in of the
293 ** put echo data event
297 *******************************************************************************/
298 void bta_hl_dch_ci_put_echo_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
299 tBTA_HL_DATA *p_data)
301 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
303 #if (BTA_HL_DEBUG == TRUE)
304 APPL_TRACE_DEBUG("bta_hl_dch_ci_put_echo_data");
307 p_dcb->cout_oper &= ~BTA_HL_CO_PUT_ECHO_DATA_MASK;
308 osi_free_and_reset((void **)&p_dcb->p_echo_rx_pkt);
309 p_dcb->ci_put_echo_data_status = p_data->ci_get_put_echo_data.status;
311 p_dcb->echo_oper = BTA_HL_ECHO_OP_DCH_CLOSE_CFM;
312 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_ECHO_TEST_EVT, p_data);
317 /*******************************************************************************
319 ** Function bta_hl_dch_ci_get_echo_data
321 ** Description Action routine for processing the call-in of the
322 ** get echo data event
326 *******************************************************************************/
327 void bta_hl_dch_ci_get_echo_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
328 tBTA_HL_DATA *p_data)
330 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
331 tBTA_HL_STATUS status;
333 #if (BTA_HL_DEBUG == TRUE)
334 APPL_TRACE_DEBUG("bta_hl_dch_ci_get_echo_data");
337 p_dcb->cout_oper &= ~BTA_HL_CO_GET_ECHO_DATA_MASK;
339 if (!p_dcb->abort_oper)
341 status = p_data->ci_get_put_echo_data.status;
342 if (status == BTA_HL_STATUS_OK)
344 p_dcb->echo_oper = BTA_HL_ECHO_OP_MDL_CREATE_CFM;
345 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_OPEN_EVT, p_data);
349 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
354 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
359 /*******************************************************************************
361 ** Function bta_hl_dch_ci_put_rx_data
363 ** Description Action routine for processing the call-in of the
368 *******************************************************************************/
369 void bta_hl_dch_ci_put_rx_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
370 tBTA_HL_DATA *p_data)
372 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
373 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
374 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
377 #if (BTA_HL_DEBUG == TRUE)
378 APPL_TRACE_DEBUG("bta_hl_dch_ci_put_rx_data");
381 p_dcb->cout_oper &= ~BTA_HL_CO_PUT_RX_DATA_MASK;
382 osi_free_and_reset((void **)&p_dcb->p_rx_pkt);
383 bta_hl_build_rcv_data_ind(&evt_data,
387 p_acb->p_cback(BTA_HL_DCH_RCV_DATA_IND_EVT,(tBTA_HL *) &evt_data );
388 if (p_dcb->close_pending)
390 if (!p_dcb->cout_oper)
392 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_EVT, p_data);
400 /*******************************************************************************
402 ** Function bta_hl_dch_ci_get_tx_data
404 ** Description Action routine for processing the call-in of the
409 *******************************************************************************/
410 void bta_hl_dch_ci_get_tx_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
411 tBTA_HL_DATA *p_data)
413 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
414 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
415 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
417 tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
418 BOOLEAN free_buf = FALSE;
419 BOOLEAN close_dch = FALSE;
423 #if (BTA_HL_DEBUG == TRUE)
424 APPL_TRACE_DEBUG("bta_hl_dch_ci_get_tx_data");
427 p_dcb->cout_oper &= ~BTA_HL_CO_GET_TX_DATA_MASK;
429 if (p_dcb->close_pending)
431 status = BTA_HL_STATUS_FAIL;
434 if (!p_dcb->cout_oper)
441 if ((result = MCA_WriteReq((tMCA_DL) p_dcb->mdl_handle, p_dcb->p_tx_pkt)) != MCA_SUCCESS)
443 if (result == MCA_BUSY)
445 status = BTA_HL_STATUS_DCH_BUSY;
449 status = BTA_HL_STATUS_FAIL;
455 p_dcb->p_tx_pkt = NULL;
460 osi_free_and_reset((void **)&p_dcb->p_tx_pkt);
462 bta_hl_build_send_data_cfm(&evt_data,
467 p_acb->p_cback(BTA_HL_DCH_SEND_DATA_CFM_EVT,(tBTA_HL *) &evt_data );
471 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_EVT, p_data);
476 /*******************************************************************************
478 ** Function bta_hl_dch_send_data
480 ** Description Action routine for processing api send data request
484 *******************************************************************************/
485 void bta_hl_dch_send_data(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
486 tBTA_HL_DATA *p_data)
488 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
489 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
490 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
492 BOOLEAN success = TRUE;
494 #if (BTA_HL_DEBUG == TRUE)
495 APPL_TRACE_DEBUG("bta_hl_dch_send_data");
498 if (!(p_dcb->cout_oper & BTA_HL_CO_GET_TX_DATA_MASK))
500 // p_dcb->chnl_cfg.fcs may be BTA_HL_MCA_USE_FCS (0x11) or BTA_HL_MCA_NO_FCS (0x10) or BTA_HL_DEFAULT_SOURCE_FCS (1)
501 BOOLEAN fcs_use = (BOOLEAN) (p_dcb->chnl_cfg.fcs & BTA_HL_MCA_FCS_USE_MASK);
502 if ((p_dcb->p_tx_pkt = bta_hl_get_buf(p_data->api_send_data.pkt_size, fcs_use)) != NULL)
504 bta_hl_co_get_tx_data( p_acb->app_id,
506 p_data->api_send_data.pkt_size,
507 BTA_HL_GET_BUF_PTR(p_dcb->p_tx_pkt),
508 BTA_HL_CI_GET_TX_DATA_EVT);
509 p_dcb->cout_oper |= BTA_HL_CO_GET_TX_DATA_MASK;
523 bta_hl_build_send_data_cfm(&evt_data,
528 p_acb->p_cback(BTA_HL_DCH_SEND_DATA_CFM_EVT,(tBTA_HL *) &evt_data );
532 /*******************************************************************************
534 ** Function bta_hl_dch_close_cmpl
536 ** Description Action routine for processing the close complete event
540 *******************************************************************************/
541 void bta_hl_dch_close_cmpl(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
542 tBTA_HL_DATA *p_data)
544 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
545 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
546 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
548 tBTA_HL_EVT event = 0;
549 BOOLEAN send_evt=TRUE;
550 tBTA_HL_STATUS status;
552 #if (BTA_HL_DEBUG == TRUE)
553 #if (BT_TRACE_VERBOSE == TRUE)
554 APPL_TRACE_DEBUG("bta_hl_dch_close_cmpl dch oper=%s", bta_hl_dch_oper_code(p_dcb->dch_oper));
556 APPL_TRACE_DEBUG("bta_hl_dch_close_cmpl dch oper=%d", p_dcb->dch_oper);
560 switch (p_dcb->dch_oper)
562 case BTA_HL_DCH_OP_LOCAL_OPEN:
563 case BTA_HL_DCH_OP_LOCAL_RECONNECT:
565 if (p_dcb->abort_oper & BTA_HL_ABORT_LOCAL_MASK)
567 bta_hl_build_abort_cfm(&evt_data,
571 event = BTA_HL_DCH_ABORT_CFM_EVT;
573 else if (p_dcb->abort_oper & BTA_HL_ABORT_REMOTE_MASK )
575 bta_hl_build_abort_ind(&evt_data,
578 event = BTA_HL_DCH_ABORT_IND_EVT;
582 bta_hl_build_dch_open_cfm(&evt_data,
585 BTA_HL_INVALID_MDL_HANDLE,
586 0,0,0,0,0, BTA_HL_STATUS_FAIL);
587 event = BTA_HL_DCH_OPEN_CFM_EVT;
588 if (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_RECONNECT)
590 event = BTA_HL_DCH_RECONNECT_CFM_EVT;
595 case BTA_HL_DCH_OP_LOCAL_CLOSE:
596 case BTA_HL_DCH_OP_REMOTE_DELETE:
597 case BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT:
598 case BTA_HL_DCH_OP_NONE:
600 bta_hl_build_dch_close_cfm(&evt_data,
605 event = BTA_HL_DCH_CLOSE_CFM_EVT;
608 case BTA_HL_DCH_OP_REMOTE_CLOSE:
609 bta_hl_build_dch_close_ind(&evt_data,
613 p_dcb->intentional_close);
614 event = BTA_HL_DCH_CLOSE_IND_EVT;
617 case BTA_HL_DCH_OP_REMOTE_OPEN:
619 if (p_dcb->abort_oper & BTA_HL_ABORT_LOCAL_MASK)
621 bta_hl_build_abort_cfm(&evt_data,
625 event = BTA_HL_DCH_ABORT_CFM_EVT;
627 else if (p_dcb->abort_oper & BTA_HL_ABORT_REMOTE_MASK )
629 bta_hl_build_abort_ind(&evt_data,
632 event = BTA_HL_DCH_ABORT_IND_EVT;
636 bta_hl_build_dch_close_ind(&evt_data,
640 p_dcb->intentional_close);
641 event = BTA_HL_DCH_CLOSE_IND_EVT;
645 case BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST:
646 /* this is normal echo test close */
647 case BTA_HL_DCH_OP_REMOTE_CREATE:
648 case BTA_HL_DCH_OP_REMOTE_RECONNECT:
653 #if (BTA_HL_DEBUG == TRUE)
654 #if (BT_TRACE_VERBOSE == TRUE)
655 APPL_TRACE_ERROR("DCH operation not found oper=%s", bta_hl_dch_oper_code(p_dcb->dch_oper));
657 APPL_TRACE_ERROR("DCH operation not found oper=%d", p_dcb->dch_oper);
664 if ( p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID )
666 p_mcb->echo_test = FALSE;
669 if ( p_dcb->dch_oper != BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST)
671 switch (p_dcb->echo_oper)
673 case BTA_HL_ECHO_OP_CI_GET_ECHO_DATA:
674 case BTA_HL_ECHO_OP_SDP_INIT:
675 case BTA_HL_ECHO_OP_MDL_CREATE_CFM:
676 case BTA_HL_ECHO_OP_DCH_OPEN_CFM:
677 case BTA_HL_ECHO_OP_LOOP_BACK:
679 status = BTA_HL_STATUS_FAIL;
682 case BTA_HL_ECHO_OP_OPEN_IND:
683 case BTA_HL_ECHO_OP_ECHO_PKT:
686 APPL_TRACE_ERROR("Invalid echo_oper=%d", p_dcb->echo_oper);
692 status = p_dcb->ci_put_echo_data_status;
698 bta_hl_build_echo_test_cfm(&evt_data,
702 event = BTA_HL_DCH_ECHO_TEST_CFM_EVT;
706 bta_hl_clean_mdl_cb(app_idx, mcl_idx, mdl_idx);
712 #if (BTA_HL_DEBUG == TRUE)
713 #if (BT_TRACE_VERBOSE == TRUE)
714 APPL_TRACE_DEBUG("Send Event: %s", bta_hl_cback_evt_code(event));
716 APPL_TRACE_DEBUG("Send Event: 0x%02x", event);
719 p_acb->p_cback(event,(tBTA_HL *) &evt_data );
722 /* check cch close is in progress or not */
723 bta_hl_check_cch_close(app_idx, mcl_idx, p_data, FALSE);
725 /*******************************************************************************
727 ** Function bta_hl_dch_mca_close_ind
729 ** Description Action routine for processing the close indication
733 *******************************************************************************/
734 void bta_hl_dch_mca_close_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
735 tBTA_HL_DATA *p_data)
737 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
739 #if (BTA_HL_DEBUG == TRUE)
740 #if (BT_TRACE_VERBOSE == TRUE)
741 APPL_TRACE_DEBUG("bta_hl_dch_mca_close_ind dch oper=%s", bta_hl_dch_oper_code(p_dcb->dch_oper));
743 APPL_TRACE_DEBUG("bta_hl_dch_mca_close_ind dch oper=%d", p_dcb->dch_oper);
747 p_dcb->intentional_close = FALSE;
748 if (p_data->mca_evt.mca_data.close_ind.reason == L2CAP_DISC_OK)
750 p_dcb->intentional_close = TRUE;
753 if (!p_dcb->cout_oper)
755 if ((p_dcb->dch_oper != BTA_HL_DCH_OP_REMOTE_OPEN) &&
756 (p_dcb->dch_oper != BTA_HL_DCH_OP_REMOTE_RECONNECT))
758 p_dcb->dch_oper = BTA_HL_DCH_OP_REMOTE_CLOSE;
760 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
764 p_dcb->close_pending = TRUE;
768 /*******************************************************************************
770 ** Function bta_hl_dch_mca_close_cfm
772 ** Description Action routine for processing the close confirmation
776 *******************************************************************************/
777 void bta_hl_dch_mca_close_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
778 tBTA_HL_DATA *p_data)
780 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
783 #if (BTA_HL_DEBUG == TRUE)
784 #if (BT_TRACE_VERBOSE == TRUE)
785 APPL_TRACE_DEBUG("bta_hl_dch_mca_close_cfm dch_oper=%s", bta_hl_dch_oper_code(p_dcb->dch_oper) );
787 APPL_TRACE_DEBUG("bta_hl_dch_mca_close_cfm dch_oper=%d", p_dcb->dch_oper);
791 switch (p_dcb->dch_oper)
793 case BTA_HL_DCH_OP_LOCAL_CLOSE:
794 case BTA_HL_DCH_OP_LOCAL_OPEN:
795 case BTA_HL_DCH_OP_LOCAL_RECONNECT:
796 case BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST:
797 case BTA_HL_DCH_OP_REMOTE_DELETE:
798 case BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT:
799 case BTA_HL_DCH_OP_NONE:
800 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
803 #if (BTA_HL_DEBUG == TRUE)
804 #if (BT_TRACE_VERBOSE == TRUE)
805 APPL_TRACE_ERROR("Invalid dch_oper=%s for close cfm", bta_hl_dch_oper_code(p_dcb->dch_oper) );
807 APPL_TRACE_ERROR("Invalid dch_oper=%d for close cfm", p_dcb->dch_oper);
815 /*******************************************************************************
817 ** Function bta_hl_dch_mca_close
819 ** Description Action routine for processing the DCH close request
823 *******************************************************************************/
824 void bta_hl_dch_mca_close(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
825 tBTA_HL_DATA *p_data)
827 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
828 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
829 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
830 tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
833 #if (BTA_HL_DEBUG == TRUE)
834 APPL_TRACE_DEBUG("bta_hl_dch_mca_close");
836 if (!p_dcb->cout_oper)
838 p_dcb->close_pending = FALSE;
839 if (MCA_CloseReq((tMCA_DL)p_dcb->mdl_handle)== MCA_SUCCESS)
841 p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_CLOSE;
845 status = BTA_HL_STATUS_FAIL;
848 if ((status != BTA_HL_STATUS_OK) &&
849 (p_mcb->cch_close_dch_oper != BTA_HL_CCH_CLOSE_OP_DCH_CLOSE))
851 bta_hl_build_dch_close_cfm(&evt_data,
854 p_data->api_dch_close.mdl_handle,
856 p_acb->p_cback(BTA_HL_DCH_CLOSE_CFM_EVT,(tBTA_HL *) &evt_data );
861 p_dcb->close_pending = TRUE;
866 /*******************************************************************************
868 ** Function bta_hl_dch_mca_open_ind
870 ** Description Action routine for processing the open indication
874 *******************************************************************************/
875 void bta_hl_dch_mca_open_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
876 tBTA_HL_DATA *p_data)
878 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
879 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
880 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
881 tMCA_DL_OPEN *p_open_ind = &p_data->mca_evt.mca_data.open_ind;
884 UINT8 old_dch_oper = BTA_HL_DCH_OP_NONE;
885 BOOLEAN send_event = FALSE;
888 #if (BTA_HL_DEBUG == TRUE)
889 APPL_TRACE_DEBUG("bta_hl_dch_mca_open_ind");
891 if ((p_dcb->dch_oper == BTA_HL_DCH_OP_REMOTE_OPEN) ||
892 (p_dcb->dch_oper == BTA_HL_DCH_OP_REMOTE_RECONNECT) )
894 p_dcb->mdl_handle = (tBTA_HL_MDL_HANDLE) p_open_ind->mdl;
895 p_dcb->mtu = p_open_ind->mtu;
897 evt_data.dch_open_ind.mdl_handle = p_dcb->mdl_handle;
898 evt_data.dch_open_ind.mcl_handle = p_mcb->mcl_handle;
899 evt_data.dch_open_ind.app_handle = p_acb->app_handle;
901 evt_data.dch_open_ind.local_mdep_id = p_dcb->local_mdep_id;
902 evt_data.dch_open_ind.mdl_id = p_dcb->mdl_id;
903 evt_data.dch_open_ind.mtu = p_dcb->mtu;
905 if ( p_dcb->chnl_cfg.fcr_opt.mode == L2CAP_FCR_ERTM_MODE )
907 evt_data.dch_open_ind.dch_mode = BTA_HL_DCH_MODE_RELIABLE;
908 if (!bta_hl_is_the_first_reliable_existed(app_idx, mcl_idx))
910 p_dcb->is_the_first_reliable = TRUE;
915 evt_data.dch_open_ind.dch_mode = BTA_HL_DCH_MODE_STREAMING;
917 evt_data.dch_open_ind.first_reliable = p_dcb->is_the_first_reliable ;
919 old_dch_oper = p_dcb->dch_oper;
920 p_dcb->dch_oper = BTA_HL_DCH_OP_NONE;
925 switch (old_dch_oper)
927 case BTA_HL_DCH_OP_REMOTE_OPEN:
929 p_dcb->dch_mode = evt_data.dch_open_ind.dch_mode;
930 if (p_dcb->local_mdep_id != BTA_HL_ECHO_TEST_MDEP_ID)
932 bta_hl_save_mdl_cfg(app_idx, mcl_idx,mdl_idx);
933 event= BTA_HL_DCH_OPEN_IND_EVT;
938 p_dcb->echo_oper = BTA_HL_ECHO_OP_ECHO_PKT;
943 case BTA_HL_DCH_OP_REMOTE_RECONNECT:
945 if (bta_hl_validate_chan_cfg(app_idx, mcl_idx, mdl_idx))
947 bta_hl_save_mdl_cfg(app_idx, mcl_idx,mdl_idx);
948 event= BTA_HL_DCH_RECONNECT_IND_EVT;
953 if (MCA_CloseReq((tMCA_DL) p_dcb->mdl_handle) == MCA_SUCCESS)
955 p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT;
959 APPL_TRACE_ERROR("Unabel to close DCH for reconnect cfg mismatch");
969 p_acb->p_cback(event ,(tBTA_HL *) &evt_data );
973 /*******************************************************************************
975 ** Function bta_hl_dch_mca_open_cfm
977 ** Description Action routine for processing the open confirmation
981 *******************************************************************************/
982 void bta_hl_dch_mca_open_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
983 tBTA_HL_DATA *p_data)
985 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
986 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
987 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
988 tMCA_DL_OPEN *p_open_cfm = &p_data->mca_evt.mca_data.open_cfm;
991 UINT8 old_dch_oper = BTA_HL_DCH_OP_NONE;
992 tBTA_HL_DCH_MODE dch_mode = BTA_HL_DCH_MODE_STREAMING;
993 BOOLEAN send_event = FALSE;
996 #if (BTA_HL_DEBUG == TRUE)
997 APPL_TRACE_DEBUG("bta_hl_dch_mca_open_cfm");
999 if ((p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_OPEN) ||
1000 (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_RECONNECT))
1002 p_dcb->mdl_handle = (tBTA_HL_MDL_HANDLE) p_open_cfm->mdl;
1003 p_dcb->mtu = p_open_cfm->mtu;
1005 /*todo verify dch_mode, mtu and fcs for reconnect */
1006 if ( p_dcb->chnl_cfg.fcr_opt.mode == L2CAP_FCR_ERTM_MODE )
1008 dch_mode = BTA_HL_DCH_MODE_RELIABLE;
1011 if (p_dcb->local_mdep_id != BTA_HL_ECHO_TEST_MDEP_ID)
1013 if (dch_mode == BTA_HL_DCH_MODE_RELIABLE )
1015 if (!bta_hl_is_the_first_reliable_existed(app_idx, mcl_idx))
1017 p_dcb->is_the_first_reliable = TRUE;
1022 bta_hl_build_dch_open_cfm(&evt_data, p_acb->app_handle,
1025 p_dcb->local_mdep_id,
1026 p_dcb->mdl_id, dch_mode,
1027 p_dcb->is_the_first_reliable,
1031 old_dch_oper = p_dcb->dch_oper;
1032 p_dcb->dch_oper = BTA_HL_DCH_OP_NONE;
1036 APPL_TRACE_ERROR("Error dch oper =%d", p_dcb->dch_oper);
1040 switch (old_dch_oper)
1042 case BTA_HL_DCH_OP_LOCAL_OPEN:
1044 p_dcb->dch_mode = dch_mode;
1045 if (p_dcb->local_mdep_id != BTA_HL_ECHO_TEST_MDEP_ID)
1047 bta_hl_save_mdl_cfg(app_idx, mcl_idx, mdl_idx);
1048 event= BTA_HL_DCH_OPEN_CFM_EVT;
1053 p_dcb->echo_oper = BTA_HL_ECHO_OP_LOOP_BACK;
1054 if (MCA_WriteReq((tMCA_DL) p_dcb->mdl_handle, p_dcb->p_echo_tx_pkt)!= MCA_SUCCESS)
1056 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_ECHO_TEST_EVT, p_data);
1060 p_dcb->p_echo_tx_pkt = NULL;
1065 case BTA_HL_DCH_OP_LOCAL_RECONNECT:
1067 if (bta_hl_validate_chan_cfg(app_idx, mcl_idx, mdl_idx))
1069 bta_hl_save_mdl_cfg(app_idx, mcl_idx,mdl_idx);
1070 event= BTA_HL_DCH_RECONNECT_CFM_EVT;
1075 if (MCA_CloseReq((tMCA_DL) p_dcb->mdl_handle) == MCA_SUCCESS)
1077 p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT;
1081 APPL_TRACE_ERROR("Unabel to close DCH for reconnect cfg mismatch");
1090 p_acb->p_cback(event ,(tBTA_HL *) &evt_data );
1094 /*******************************************************************************
1096 ** Function bta_hl_dch_mca_abort_ind
1098 ** Description Action routine for processing the abort indication
1102 *******************************************************************************/
1103 void bta_hl_dch_mca_abort_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1104 tBTA_HL_DATA *p_data)
1106 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1109 #if (BTA_HL_DEBUG == TRUE)
1110 APPL_TRACE_DEBUG("bta_hl_dch_mca_abort_ind");
1113 p_dcb->abort_oper |= BTA_HL_ABORT_REMOTE_MASK;
1114 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1117 /*******************************************************************************
1119 ** Function bta_hl_dch_mca_abort_cfm
1121 ** Description Action routine for processing the abort confirmation
1125 *******************************************************************************/
1126 void bta_hl_dch_mca_abort_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1127 tBTA_HL_DATA *p_data)
1129 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
1130 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1131 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1134 #if (BTA_HL_DEBUG == TRUE)
1135 APPL_TRACE_DEBUG("bta_hl_dch_mca_abort_cfm");
1138 if (p_dcb->abort_oper)
1140 if (p_data->mca_evt.mca_data.abort_cfm.rsp_code != MCA_RSP_SUCCESS )
1142 if (p_dcb->abort_oper & BTA_HL_ABORT_LOCAL_MASK)
1144 bta_hl_build_abort_cfm(&evt_data,
1147 BTA_HL_STATUS_FAIL);
1148 p_acb->p_cback(BTA_HL_DCH_ABORT_CFM_EVT ,(tBTA_HL *) &evt_data );
1153 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1158 APPL_TRACE_ERROR("Not expecting Abort CFM ");
1162 /*******************************************************************************
1164 ** Function bta_hl_dch_mca_abort
1166 ** Description Action routine for processing the abort request
1170 *******************************************************************************/
1171 void bta_hl_dch_mca_abort(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1172 tBTA_HL_DATA *p_data)
1174 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
1175 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1176 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1177 tMCA_RESULT mca_result;
1180 if (((p_mcb->sdp_oper == BTA_HL_SDP_OP_DCH_OPEN_INIT) ||
1181 (p_mcb->sdp_oper == BTA_HL_SDP_OP_DCH_RECONNECT_INIT)) &&
1182 (p_mcb->sdp_mdl_idx == mdl_idx) )
1184 p_dcb->abort_oper |= BTA_HL_ABORT_PENDING_MASK;
1187 else if (p_dcb->echo_oper == BTA_HL_ECHO_OP_CI_GET_ECHO_DATA)
1189 p_dcb->abort_oper |= BTA_HL_ABORT_PENDING_MASK;
1193 p_dcb->abort_oper &= ~BTA_HL_ABORT_PENDING_MASK;
1195 if ((mca_result = MCA_Abort((tMCA_CL) p_mcb->mcl_handle))!= MCA_SUCCESS)
1197 if (mca_result == MCA_NO_RESOURCES)
1199 p_dcb->abort_oper |= BTA_HL_ABORT_PENDING_MASK;
1203 if (p_dcb->abort_oper & BTA_HL_ABORT_LOCAL_MASK)
1205 bta_hl_build_abort_cfm(&evt_data,
1208 BTA_HL_STATUS_FAIL);
1209 p_acb->p_cback(BTA_HL_DCH_ABORT_CFM_EVT ,(tBTA_HL *) &evt_data );
1211 bta_hl_check_cch_close(app_idx, mcl_idx, p_data, FALSE);
1217 #if (BTA_HL_DEBUG == TRUE)
1218 APPL_TRACE_DEBUG("bta_hl_dch_mca_abort abort_oper=0x%x", p_dcb->abort_oper);
1223 /*******************************************************************************
1225 ** Function bta_hl_dch_mca_reconnect_ind
1227 ** Description Action routine for processing the reconnect indication
1231 *******************************************************************************/
1232 void bta_hl_dch_mca_reconnect_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1233 tBTA_HL_DATA *p_data)
1235 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1236 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1237 tBTA_HL_MDL_CFG *p_mdl_cfg;
1238 tMCA_EVT_HDR *p_reconnect_ind = &p_data->mca_evt.mca_data.reconnect_ind;
1239 UINT8 mdl_cfg_idx, in_use_mdl_idx, mdep_cfg_idx;
1240 UINT8 rsp_code = MCA_RSP_SUCCESS;
1243 #if (BTA_HL_DEBUG == TRUE)
1244 APPL_TRACE_DEBUG("bta_hl_dch_mca_reconnect_ind mdl_id=%d", p_reconnect_ind->mdl_id);
1247 if (bta_hl_find_mdl_cfg_idx(app_idx, mcl_idx, p_reconnect_ind->mdl_id, &mdl_cfg_idx))
1249 if (!bta_hl_find_mdl_idx(app_idx,mcl_idx,p_reconnect_ind->mdl_id, &in_use_mdl_idx) )
1251 p_mdl_cfg = BTA_HL_GET_MDL_CFG_PTR(app_idx, mdl_cfg_idx);
1253 if (bta_hl_find_mdep_cfg_idx(app_idx, p_mdl_cfg->local_mdep_id, &mdep_cfg_idx))
1255 p_dcb->in_use = TRUE;
1256 p_dcb->dch_oper = BTA_HL_DCH_OP_REMOTE_RECONNECT;
1257 p_dcb->sec_mask = (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
1258 p_dcb->peer_mdep_id = 0xFF;
1259 p_dcb->local_mdep_id = p_mdl_cfg->local_mdep_id ;
1260 p_dcb->local_mdep_cfg_idx = mdep_cfg_idx;
1261 p_dcb->local_cfg = BTA_HL_DCH_CFG_UNKNOWN;
1262 p_dcb->mdl_id = p_reconnect_ind->mdl_id;
1263 p_dcb->mdl_cfg_idx_included = TRUE;
1264 p_dcb->mdl_cfg_idx = mdl_cfg_idx;
1265 p_dcb->dch_mode = p_mdl_cfg->dch_mode;
1266 bta_hl_find_rxtx_apdu_size(app_idx, mdep_cfg_idx,
1267 &p_dcb->max_rx_apdu_size,
1268 &p_dcb->max_tx_apdu_size);
1269 bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
1273 rsp_code = MCA_RSP_BAD_MDL;
1278 rsp_code = MCA_RSP_BAD_MDL;
1283 rsp_code = MCA_RSP_BAD_MDL;
1286 if (MCA_ReconnectMdlRsp((tMCA_CL) p_mcb->mcl_handle,
1287 p_dcb->local_mdep_id,
1290 &p_dcb->chnl_cfg)!= MCA_SUCCESS)
1292 MCA_Abort((tMCA_CL) p_mcb->mcl_handle);
1293 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1297 /*******************************************************************************
1299 ** Function bta_hl_dch_mca_reconnect_cfm
1301 ** Description Action routine for processing the reconenct confirmation
1305 *******************************************************************************/
1306 void bta_hl_dch_mca_reconnect_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1307 tBTA_HL_DATA *p_data)
1309 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1310 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1311 tMCA_RSP_EVT *p_reconnect_cfm = &p_data->mca_evt.mca_data.reconnect_cfm;
1314 #if (BTA_HL_DEBUG == TRUE)
1315 APPL_TRACE_DEBUG("bta_hl_dch_mca_reconnect_cfm");
1317 if (p_dcb->abort_oper & BTA_HL_ABORT_PENDING_MASK)
1319 p_dcb->abort_oper &= ~BTA_HL_ABORT_PENDING_MASK;
1320 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_ABORT_EVT, p_data);
1325 if (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_RECONNECT)
1327 if (p_reconnect_cfm->rsp_code == MCA_RSP_SUCCESS)
1330 bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
1332 if (MCA_DataChnlCfg((tMCA_CL) p_mcb->mcl_handle, &p_dcb->chnl_cfg)!= MCA_SUCCESS)
1334 /* should be able to abort so no checking of the return code */
1335 MCA_Abort((tMCA_CL) p_mcb->mcl_handle);
1336 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1341 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1346 /*******************************************************************************
1348 ** Function bta_hl_dch_mca_reconnect
1350 ** Description Action routine for processing the reconnect request
1354 *******************************************************************************/
1355 void bta_hl_dch_mca_reconnect(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1356 tBTA_HL_DATA *p_data)
1358 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1359 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1360 tMCA_CHNL_CFG *p_chnl_cfg=NULL;
1363 #if (BTA_HL_DEBUG == TRUE)
1364 APPL_TRACE_DEBUG("bta_hl_dch_mca_reconnect");
1366 if (bta_hl_find_sdp_idx_using_ctrl_psm(&p_mcb->sdp, p_mcb->ctrl_psm, &sdp_idx))
1368 p_mcb->data_psm = p_mcb->sdp.sdp_rec[sdp_idx].data_psm;
1369 if ( MCA_ReconnectMdl((tMCA_CL) p_mcb->mcl_handle,
1370 p_dcb->local_mdep_id,
1373 p_chnl_cfg ) != MCA_SUCCESS)
1375 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1380 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1385 /*******************************************************************************
1387 ** Function bta_hl_dch_create_rsp
1389 ** Description Action routine for processing BTA_HL_API_DCH_CREATE_RSP_EVT
1393 *******************************************************************************/
1394 void bta_hl_dch_create_rsp(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1395 tBTA_HL_DATA *p_data)
1397 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1398 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1399 tBTA_HL_API_DCH_CREATE_RSP *p_create_rsp = &p_data->api_dch_create_rsp;
1400 UINT8 mca_rsp_code = MCA_RSP_SUCCESS;
1402 #if (BTA_HL_DEBUG == TRUE)
1403 APPL_TRACE_DEBUG("bta_hl_dch_create_rsp");
1405 if (p_create_rsp->rsp_code == BTA_HL_DCH_CREATE_RSP_SUCCESS)
1407 p_dcb->dch_oper = BTA_HL_DCH_OP_REMOTE_OPEN;
1408 p_dcb->local_cfg = p_create_rsp->cfg_rsp;
1412 bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
1416 mca_rsp_code = MCA_RSP_CFG_REJ;
1419 if (MCA_CreateMdlRsp((tMCA_CL) p_mcb->mcl_handle,
1420 p_dcb->local_mdep_id,
1424 &p_dcb->chnl_cfg)!= MCA_SUCCESS)
1426 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1430 /*******************************************************************************
1432 ** Function bta_hl_dch_mca_create_ind
1434 ** Description Action routine for processing
1438 *******************************************************************************/
1439 void bta_hl_dch_mca_create_ind(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1440 tBTA_HL_DATA *p_data)
1442 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
1443 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1444 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1445 tMCA_CREATE_IND *p_create_ind = &p_data->mca_evt.mca_data.create_ind;
1448 UINT8 rsp_code = MCA_RSP_SUCCESS;
1449 BOOLEAN send_create_ind_evt = FALSE;
1451 tBTA_HL_ECHO_CFG *p_echo_cfg;
1453 #if (BTA_HL_DEBUG == TRUE)
1454 APPL_TRACE_DEBUG("bta_hl_dch_mca_create_ind");
1457 if (bta_hl_find_mdep_cfg_idx(app_idx, p_create_ind->dep_id, &mdep_cfg_idx))
1459 if (p_create_ind->dep_id == BTA_HL_ECHO_TEST_MDEP_ID )
1461 if (bta_hl_find_echo_cfg_rsp(app_idx, mcl_idx, mdep_cfg_idx,p_create_ind->cfg, &cfg_rsp ))
1463 p_dcb->in_use = TRUE;
1464 p_dcb->dch_oper = BTA_HL_DCH_OP_REMOTE_OPEN;
1465 p_dcb->local_mdep_id = p_create_ind->dep_id ;
1466 p_dcb->local_mdep_cfg_idx = mdep_cfg_idx;
1467 p_dcb->local_cfg = cfg_rsp;
1468 p_dcb->remote_cfg = p_create_ind->cfg ;
1469 p_dcb->mdl_id = p_create_ind->mdl_id;
1470 p_dcb->mdl_cfg_idx_included = FALSE;
1471 p_echo_cfg = BTA_HL_GET_ECHO_CFG_PTR(app_idx);
1472 p_dcb->max_rx_apdu_size = p_echo_cfg->max_rx_apdu_size;
1473 p_dcb->max_tx_apdu_size = p_echo_cfg->max_tx_apdu_size;
1475 bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
1479 rsp_code = MCA_RSP_CFG_REJ;
1485 p_dcb->in_use = TRUE;
1486 p_dcb->dch_oper = BTA_HL_DCH_OP_REMOTE_CREATE;
1487 p_dcb->local_mdep_id = p_create_ind->dep_id ;
1488 p_dcb->local_mdep_cfg_idx = mdep_cfg_idx;
1489 p_dcb->local_cfg = BTA_HL_DCH_CFG_UNKNOWN;
1490 p_dcb->remote_cfg = p_create_ind->cfg;
1491 p_dcb->mdl_id = p_create_ind->mdl_id;
1492 p_dcb->mdl_cfg_idx_included = FALSE;
1493 bta_hl_find_rxtx_apdu_size(app_idx, mdep_cfg_idx,
1494 &p_dcb->max_rx_apdu_size,
1495 &p_dcb->max_tx_apdu_size);
1496 send_create_ind_evt = TRUE;
1501 rsp_code = MCA_RSP_BAD_MDEP;
1504 if (send_create_ind_evt)
1506 evt_data.dch_create_ind.mcl_handle = p_mcb->mcl_handle;
1507 evt_data.dch_create_ind.app_handle = p_acb->app_handle;
1508 evt_data.dch_create_ind.local_mdep_id = p_dcb->local_mdep_id;
1509 evt_data.dch_create_ind.mdl_id = p_dcb->mdl_id;
1510 evt_data.dch_create_ind.cfg = p_dcb->remote_cfg;
1511 bdcpy(evt_data.dch_create_ind.bd_addr, p_mcb->bd_addr);
1512 p_acb->p_cback(BTA_HL_DCH_CREATE_IND_EVT,(tBTA_HL *) &evt_data );
1516 if (MCA_CreateMdlRsp((tMCA_CL) p_mcb->mcl_handle,
1517 p_dcb->local_mdep_id,
1521 &p_dcb->chnl_cfg)!= MCA_SUCCESS)
1523 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1527 if (p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID)
1529 p_mcb->echo_test = TRUE;
1530 p_dcb->echo_oper = BTA_HL_ECHO_OP_OPEN_IND;
1536 /*******************************************************************************
1538 ** Function bta_hl_dch_mca_create_cfm
1540 ** Description Action routine for processing
1544 *******************************************************************************/
1545 void bta_hl_dch_mca_create_cfm(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1546 tBTA_HL_DATA *p_data)
1548 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1549 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1550 tMCA_CREATE_CFM *p_create_cfm = &p_data->mca_evt.mca_data.create_cfm;
1552 #if (BTA_HL_DEBUG == TRUE)
1553 APPL_TRACE_DEBUG("bta_hl_dch_mca_create_cfm");
1556 if (p_dcb->abort_oper & BTA_HL_ABORT_PENDING_MASK)
1558 p_dcb->abort_oper &= ~BTA_HL_ABORT_PENDING_MASK;
1559 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_ABORT_EVT, p_data);
1563 if (p_dcb->dch_oper == BTA_HL_DCH_OP_LOCAL_OPEN)
1565 if (p_create_cfm->rsp_code == MCA_RSP_SUCCESS)
1567 if (bta_hl_validate_cfg(app_idx, mcl_idx, mdl_idx, p_create_cfm->cfg ))
1569 bta_hl_set_dch_chan_cfg(app_idx, mcl_idx, mdl_idx, p_data);
1571 if (MCA_DataChnlCfg((tMCA_CL) p_mcb->mcl_handle, &p_dcb->chnl_cfg)!= MCA_SUCCESS)
1573 /* this should not happen */
1574 APPL_TRACE_ERROR("Unable to create data channel");
1575 MCA_Abort((tMCA_CL) p_mcb->mcl_handle);
1576 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1580 if (p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID)
1582 p_dcb->echo_oper = BTA_HL_ECHO_OP_DCH_OPEN_CFM;
1588 MCA_Abort((tMCA_CL) p_mcb->mcl_handle);
1589 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1594 APPL_TRACE_ERROR("MCA Create- failed");
1595 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1600 /*******************************************************************************
1602 ** Function bta_hl_dch_mca_create
1604 ** Description Action routine for processing the MDL create request
1608 *******************************************************************************/
1609 void bta_hl_dch_mca_create(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1610 tBTA_HL_DATA *p_data)
1612 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1613 tBTA_HL_MDL_CB *p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1617 #if BTA_HL_DEBUG == TRUE
1618 APPL_TRACE_DEBUG("bta_hl_dch_mca_create");
1621 if (bta_hl_find_sdp_idx_using_ctrl_psm(&p_mcb->sdp, p_mcb->ctrl_psm, &sdp_idx) &&
1622 bta_hl_validate_peer_cfg(app_idx, mcl_idx, mdl_idx,
1623 p_dcb->peer_mdep_id,
1624 p_dcb->peer_mdep_role,
1628 p_mcb->data_psm = p_mcb->sdp.sdp_rec[sdp_idx].data_psm;
1629 if ( (result = MCA_CreateMdl((tMCA_CL) p_mcb->mcl_handle,
1630 p_dcb->local_mdep_id,
1633 p_dcb->peer_mdep_id,
1635 NULL )) != MCA_SUCCESS)
1637 APPL_TRACE_ERROR("MCA_CreateMdl FAIL mca_result=%d", result);
1638 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1643 APPL_TRACE_ERROR("MCA Create- SDP idx or peer MDEP cfg not found");
1644 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1648 /*******************************************************************************
1650 ** Function bta_hl_dch_sdp_fail
1652 ** Description Action routine for processing the SDP failed event
1656 *******************************************************************************/
1657 void bta_hl_dch_sdp_fail(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,
1658 tBTA_HL_DATA *p_data)
1661 #if (BTA_HL_DEBUG == TRUE)
1662 APPL_TRACE_DEBUG("bta_hl_dch_sdp_fail");
1664 bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
1667 /******************************************************************************
1669 ** Function bta_hl_sdp_cback
1671 ** Description This is the SDP callback function used by HL.
1672 ** This function will be executed by SDP when the service
1673 ** search is completed. If the search is successful, it
1674 ** finds the first record in the database that matches the
1675 ** UUID of the search. Then retrieves the scn from the
1680 ******************************************************************************/
1681 static void bta_hl_sdp_cback(UINT8 sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
1682 UINT8 mdl_idx, UINT16 status)
1684 tBTA_HL_MCL_CB *p_cb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
1685 tBTA_HL_SDP_REC *p_hdp_rec;
1686 tBTA_HL_CCH_SDP *p_cch_buf;
1687 tBTA_HL_DCH_SDP *p_dch_buf;
1688 tSDP_DISC_REC *p_rec = NULL;
1689 tSDP_PROTOCOL_ELEM pe;
1690 tSDP_DISC_ATTR *p_attr;
1692 tBTA_HL_SUP_FEATURE_LIST_ELEM sup_feature;
1693 BOOLEAN sdp_parsing_ok =FALSE, result=FALSE;
1695 tBTA_HL_MDL_CB *p_dcb;
1696 UINT16 service_uuid;
1699 #if BTA_HL_DEBUG == TRUE
1700 APPL_TRACE_DEBUG("bta_hl_sdp_cback status:%d sdp_oper=%d app_idx=%d, mcl_idx=%d, mdl_idx=%d",
1701 status, sdp_oper, app_idx, mcl_idx, mdl_idx);
1705 service_uuid = bta_hl_get_service_uuids(sdp_oper, app_idx, mcl_idx, mdl_idx);
1707 if (status == SDP_SUCCESS || status == SDP_DB_FULL)
1709 memset(&p_cb->sdp,0, sizeof(tBTA_HL_SDP));
1712 if (bta_hl_find_service_in_db(app_idx, mcl_idx, service_uuid, &p_rec))
1714 p_hdp_rec = &p_cb->sdp.sdp_rec[rec_cnt];
1715 p_cb->sdp.num_recs = rec_cnt+1;
1722 if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_L2CAP, &pe))
1724 p_hdp_rec->ctrl_psm = (UINT16) pe.params[0];
1728 APPL_TRACE_WARNING("Control PSM not found");
1731 if (SDP_FindAddProtoListsElemInRec(p_rec, UUID_PROTOCOL_L2CAP, &pe))
1733 p_hdp_rec->data_psm = (UINT16) pe.params[0];
1737 APPL_TRACE_WARNING("Data PSM not found");
1741 p_hdp_rec->srv_name[0]= '\0';
1742 if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
1744 if (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) < BT_MAX_SERVICE_NAME_LEN)
1745 name_len = (UINT16)SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
1747 name_len = BT_MAX_SERVICE_NAME_LEN;
1748 memcpy(p_hdp_rec->srv_name, p_attr->attr_value.v.array, name_len);
1751 p_hdp_rec->srv_desp[0]= '\0';
1752 if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_DESCRIPTION)) != NULL)
1754 if (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) < BT_MAX_SERVICE_NAME_LEN)
1755 name_len = (UINT16)SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
1757 name_len = BT_MAX_SERVICE_NAME_LEN;
1758 memcpy(p_hdp_rec->srv_desp, p_attr->attr_value.v.array, name_len);
1762 p_hdp_rec->provider_name[0]= '\0';
1763 if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_PROVIDER_NAME)) != NULL)
1765 if (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) < BT_MAX_SERVICE_NAME_LEN)
1766 name_len = (UINT16)SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
1768 name_len = BT_MAX_SERVICE_NAME_LEN;
1769 memcpy(p_hdp_rec->provider_name, p_attr->attr_value.v.array, name_len);
1772 if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_HDP_MCAP_SUP_PROC))!=NULL)
1774 p_hdp_rec->mcap_sup_proc = p_attr->attr_value.v.u8;
1778 APPL_TRACE_WARNING("MCAP SUP PROC not found");
1782 if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_HDP_SUP_FEAT_LIST ))!=NULL)
1784 if (bta_hl_fill_sup_feature_list (p_attr, &sup_feature))
1786 p_hdp_rec->num_mdeps = (UINT8) sup_feature.num_elems;
1787 APPL_TRACE_WARNING("bta_hl_sdp_cback num_mdeps %d",sup_feature.num_elems);
1788 for (i=0; i<sup_feature.num_elems; i++)
1790 p_hdp_rec->mdep_cfg[i].data_type = sup_feature.list_elem[i].data_type;
1791 p_hdp_rec->mdep_cfg[i].mdep_id = sup_feature.list_elem[i].mdep_id;
1792 p_hdp_rec->mdep_cfg[i].mdep_role = sup_feature.list_elem[i].mdep_role;
1793 /* Check MDEP Description pointer to prevent crash due to null pointer */
1794 if (sup_feature.list_elem[i].p_mdep_desp != NULL)
1796 strlcpy(p_hdp_rec->mdep_cfg[i].mdep_desp,
1797 sup_feature.list_elem[i].p_mdep_desp,
1798 BTA_HL_MDEP_DESP_LEN);
1802 APPL_TRACE_ERROR("bta_hl_sdp_cback Incorrect Mdep[%d] Description (Null ptr)", i);
1806 sdp_parsing_ok = TRUE;
1810 APPL_TRACE_WARNING("HDP supported feature list fill failed");
1816 APPL_TRACE_WARNING("HDP supported feature list not found");
1819 #if BTA_HL_DEBUG == TRUE
1820 APPL_TRACE_DEBUG("record=%d ctrl_psm=%0x data_psm=%x",
1822 p_hdp_rec->ctrl_psm,
1823 p_hdp_rec->data_psm );
1824 APPL_TRACE_DEBUG("srv_name=[%s]",(p_hdp_rec->srv_name[0] != '\0')? p_hdp_rec->srv_name:"NULL");
1825 APPL_TRACE_DEBUG("srv_desp=[%s]",(p_hdp_rec->srv_desp[0] != '\0')? p_hdp_rec->srv_desp:"NULL");
1826 for (i=0; i<sup_feature.num_elems; i++)
1828 APPL_TRACE_DEBUG("index=0x%02x mdep_id=0x%04x data type=0x%04x mdep role=%s(0x%02x)",
1830 p_hdp_rec->mdep_cfg[i].mdep_id,
1831 p_hdp_rec->mdep_cfg[i].data_type,
1832 (p_hdp_rec->mdep_cfg[i].mdep_role == BTA_HL_MDEP_ROLE_SOURCE)?"Src":"Snk",
1833 p_hdp_rec->mdep_cfg[i].mdep_role);
1835 APPL_TRACE_DEBUG("provider_name=[%s]",(p_hdp_rec->provider_name[0] != '\0')? p_hdp_rec->provider_name:"NULL");
1836 APPL_TRACE_DEBUG("found MCAP sup procedure=%d",
1837 p_cb->sdp.sdp_rec[rec_cnt].mcap_sup_proc );
1840 if (rec_cnt >= BTA_HL_NUM_SDP_RECS)
1842 APPL_TRACE_WARNING("No more spaces for SDP recs max_rec_cnt=%d", BTA_HL_NUM_SDP_RECS);
1850 osi_free_and_reset((void **)&p_cb->p_db);
1852 if ( (status == SDP_SUCCESS || status == SDP_DB_FULL) &&
1853 p_cb->sdp.num_recs &&
1860 APPL_TRACE_WARNING("SDP Failed sdp_status=%d num_recs=%d sdp_parsing_ok=%d ",
1861 status, p_cb->sdp.num_recs,sdp_parsing_ok );
1865 p_cb->sdp_oper = BTA_HL_SDP_OP_NONE;
1869 case BTA_HL_SDP_OP_CCH_INIT:
1870 case BTA_HL_SDP_OP_SDP_QUERY_NEW:
1871 case BTA_HL_SDP_OP_SDP_QUERY_CURRENT:
1873 /* send result in event back to BTA */
1874 p_cch_buf = (tBTA_HL_CCH_SDP *)osi_malloc(sizeof(tBTA_HL_CCH_SDP));
1876 if (sdp_oper == BTA_HL_SDP_OP_CCH_INIT) {
1877 event = BTA_HL_CCH_SDP_OK_EVT;
1878 if (p_cb->close_pending)
1879 event = BTA_HL_CCH_SDP_FAIL_EVT;
1881 event = BTA_HL_SDP_QUERY_OK_EVT;
1884 if (sdp_oper == BTA_HL_SDP_OP_CCH_INIT)
1885 event = BTA_HL_CCH_SDP_FAIL_EVT;
1887 event = BTA_HL_SDP_QUERY_FAIL_EVT;
1889 p_cch_buf->hdr.event = event;
1891 p_cch_buf->app_idx = app_idx;
1892 p_cch_buf->mcl_idx = mcl_idx;
1893 p_cch_buf->release_mcl_cb = FALSE;
1894 if (sdp_oper == BTA_HL_SDP_OP_SDP_QUERY_NEW)
1895 p_cch_buf->release_mcl_cb = TRUE;
1897 bta_sys_sendmsg(p_cch_buf);
1899 case BTA_HL_SDP_OP_DCH_OPEN_INIT:
1900 case BTA_HL_SDP_OP_DCH_RECONNECT_INIT:
1901 p_dch_buf = (tBTA_HL_DCH_SDP *)osi_malloc(sizeof(tBTA_HL_DCH_SDP));
1902 p_dch_buf->hdr.event = BTA_HL_DCH_SDP_FAIL_EVT;
1903 p_dch_buf->app_idx = app_idx;
1904 p_dch_buf->mcl_idx = mcl_idx;
1905 p_dch_buf->mdl_idx = mdl_idx;
1906 p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
1907 if (p_dcb->abort_oper & BTA_HL_ABORT_PENDING_MASK) {
1908 p_dcb->abort_oper &= ~BTA_HL_ABORT_PENDING_MASK;
1912 if (sdp_oper == BTA_HL_SDP_OP_DCH_OPEN_INIT) {
1913 if (p_dcb->local_mdep_id == BTA_HL_ECHO_TEST_MDEP_ID) {
1914 p_dch_buf->hdr.event = BTA_HL_DCH_ECHO_TEST_EVT;
1916 p_dch_buf->hdr.event = BTA_HL_DCH_OPEN_EVT;
1919 p_dch_buf->hdr.event = BTA_HL_DCH_RECONNECT_EVT;
1922 bta_sys_sendmsg(p_dch_buf);
1930 /******************************************************************************
1932 ** Function bta_hl_sdp_cback0
1934 ** Description This is the SDP callback function used by index = 0
1938 ******************************************************************************/
1939 static void bta_hl_sdp_cback0(UINT16 status)
1941 bta_hl_sdp_cback(bta_hl_cb.scb[0].sdp_oper,
1942 bta_hl_cb.scb[0].app_idx,
1943 bta_hl_cb.scb[0].mcl_idx,
1944 bta_hl_cb.scb[0].mdl_idx,
1946 bta_hl_deallocate_spd_cback(0);
1949 /******************************************************************************
1951 ** Function bta_hl_sdp_cback1
1953 ** Description This is the SDP callback function used by index = 1
1955 ** Parameters status - status of the SDP callabck
1959 ******************************************************************************/
1960 static void bta_hl_sdp_cback1(UINT16 status)
1962 bta_hl_sdp_cback(bta_hl_cb.scb[1].sdp_oper,
1963 bta_hl_cb.scb[1].app_idx,
1964 bta_hl_cb.scb[1].mcl_idx,
1965 bta_hl_cb.scb[1].mdl_idx,
1967 bta_hl_deallocate_spd_cback(1);
1970 /******************************************************************************
1972 ** Function bta_hl_sdp_cback2
1974 ** Description This is the SDP callback function used by index = 2
1978 ******************************************************************************/
1979 static void bta_hl_sdp_cback2(UINT16 status)
1981 bta_hl_sdp_cback(bta_hl_cb.scb[2].sdp_oper,
1982 bta_hl_cb.scb[2].app_idx,
1983 bta_hl_cb.scb[2].mcl_idx,
1984 bta_hl_cb.scb[2].mdl_idx,
1986 bta_hl_deallocate_spd_cback(2);
1989 /******************************************************************************
1991 ** Function bta_hl_sdp_cback3
1993 ** Description This is the SDP callback function used by index = 3
1997 ******************************************************************************/
1998 static void bta_hl_sdp_cback3(UINT16 status)
2000 bta_hl_sdp_cback(bta_hl_cb.scb[3].sdp_oper,
2001 bta_hl_cb.scb[3].app_idx,
2002 bta_hl_cb.scb[3].mcl_idx,
2003 bta_hl_cb.scb[3].mdl_idx,
2005 bta_hl_deallocate_spd_cback(3);
2008 /******************************************************************************
2010 ** Function bta_hl_sdp_cback4
2012 ** Description This is the SDP callback function used by index = 4
2014 ** Parameters status - status of the SDP callabck
2018 ******************************************************************************/
2019 static void bta_hl_sdp_cback4(UINT16 status)
2021 bta_hl_sdp_cback(bta_hl_cb.scb[4].sdp_oper,
2022 bta_hl_cb.scb[4].app_idx,
2023 bta_hl_cb.scb[4].mcl_idx,
2024 bta_hl_cb.scb[4].mdl_idx,
2026 bta_hl_deallocate_spd_cback(4);
2029 /******************************************************************************
2031 ** Function bta_hl_sdp_cback5
2033 ** Description This is the SDP callback function used by index = 5
2035 ** Parameters status - status of the SDP callabck
2039 ******************************************************************************/
2040 static void bta_hl_sdp_cback5(UINT16 status)
2042 bta_hl_sdp_cback(bta_hl_cb.scb[5].sdp_oper,
2043 bta_hl_cb.scb[5].app_idx,
2044 bta_hl_cb.scb[5].mcl_idx,
2045 bta_hl_cb.scb[5].mdl_idx,
2047 bta_hl_deallocate_spd_cback(5);
2050 /******************************************************************************
2052 ** Function bta_hl_sdp_cback6
2054 ** Description This is the SDP callback function used by index = 6
2058 ******************************************************************************/
2059 static void bta_hl_sdp_cback6(UINT16 status)
2061 bta_hl_sdp_cback(bta_hl_cb.scb[6].sdp_oper,
2062 bta_hl_cb.scb[6].app_idx,
2063 bta_hl_cb.scb[6].mcl_idx,
2064 bta_hl_cb.scb[6].mdl_idx,
2066 bta_hl_deallocate_spd_cback(6);
2070 /*******************************************************************************
2072 ** Function bta_hl_deallocate_spd_cback
2074 ** Description Deallocate a SDP control block
2076 ** Returns BOOLEAN - TRUE found
2079 *******************************************************************************/
2080 void bta_hl_deallocate_spd_cback(UINT8 sdp_cback_idx)
2082 tBTA_HL_SDP_CB *p_spd_cb = &bta_hl_cb.scb[sdp_cback_idx];
2084 memset(p_spd_cb, 0, sizeof(tBTA_HL_SDP_CB));
2086 #if BTA_HL_DEBUG == TRUE
2087 APPL_TRACE_DEBUG("bta_hl_deallocate_spd_cback index=%d", sdp_cback_idx);
2093 /*******************************************************************************
2095 ** Function bta_hl_allocate_spd_cback
2097 ** Description Finds a not in used SDP control block index
2100 ** Returns BOOLEAN - TRUE found
2103 *******************************************************************************/
2104 tSDP_DISC_CMPL_CB *bta_hl_allocate_spd_cback(tBTA_HL_SDP_OPER sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
2106 UINT8 *p_sdp_cback_idx)
2109 tSDP_DISC_CMPL_CB *p_cbcak=NULL;
2112 for (i=0; i < BTA_HL_NUM_SDP_CBACKS ; i ++)
2114 if (!bta_hl_cb.scb[i].in_use)
2116 p_cbcak = bta_hl_sdp_cback_arr[i];
2117 bta_hl_cb.scb[i].in_use = TRUE;
2118 bta_hl_cb.scb[i].sdp_oper = sdp_oper;
2119 bta_hl_cb.scb[i].app_idx = app_idx;
2120 bta_hl_cb.scb[i].mcl_idx = mcl_idx;
2121 bta_hl_cb.scb[i].mdl_idx = mdl_idx;
2122 *p_sdp_cback_idx = i;
2127 if (i == BTA_HL_NUM_SDP_CBACKS)
2129 APPL_TRACE_WARNING("No scb is available to allocate")
2133 #if BTA_HL_DEBUG == TRUE
2134 APPL_TRACE_DEBUG("bta_hl_allocate_spd_cback cback_idx=%d ",i );
2135 APPL_TRACE_DEBUG("sdp_oper=%d, app_idx=%d, mcl_idx=%d, mdl_idx=%d",
2136 bta_hl_cb.scb[i].sdp_oper,
2137 bta_hl_cb.scb[i].app_idx,
2138 bta_hl_cb.scb[i].mcl_idx,
2139 bta_hl_cb.scb[i].mdl_idx );
2146 /*******************************************************************************
2148 ** Function bta_hl_init_sdp
2150 ** Description Action routine for processing the SDP initiattion request
2154 *******************************************************************************/
2155 tBTA_HL_STATUS bta_hl_init_sdp(tBTA_HL_SDP_OPER sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
2158 tBTA_HL_MCL_CB *p_cb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2159 tSDP_UUID uuid_list;
2160 UINT16 attr_list[BTA_HL_NUM_SRCH_ATTR];
2161 UINT16 num_attrs = BTA_HL_NUM_SRCH_ATTR;
2162 tBTA_HL_STATUS status;
2163 UINT8 sdp_cback_idx;
2164 #if BTA_HL_DEBUG == TRUE
2165 APPL_TRACE_DEBUG("bta_hl_init_sdp sdp_oper=%d app_idx=%d mcl_idx=%d, mdl_idx=%d",
2166 sdp_oper, app_idx, mcl_idx, mdl_idx);
2168 if ((p_cb->sdp_cback = bta_hl_allocate_spd_cback(sdp_oper, app_idx, mcl_idx, mdl_idx, &sdp_cback_idx)) != NULL)
2170 if (p_cb->p_db == NULL)
2171 (p_cb->p_db = (tSDP_DISCOVERY_DB *)osi_malloc(BTA_HL_DISC_SIZE));
2172 attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
2173 attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
2174 attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
2175 attr_list[3] = ATTR_ID_ADDITION_PROTO_DESC_LISTS;
2176 attr_list[4] = ATTR_ID_SERVICE_NAME;
2177 attr_list[5] = ATTR_ID_SERVICE_DESCRIPTION;
2178 attr_list[6] = ATTR_ID_PROVIDER_NAME;
2179 attr_list[7] = ATTR_ID_HDP_SUP_FEAT_LIST;
2180 attr_list[8] = ATTR_ID_HDP_DATA_EXCH_SPEC;
2181 attr_list[9] = ATTR_ID_HDP_MCAP_SUP_PROC;
2183 uuid_list.len = LEN_UUID_16;
2184 uuid_list.uu.uuid16 = UUID_SERVCLASS_HDP_PROFILE;
2185 SDP_InitDiscoveryDb(p_cb->p_db, BTA_HL_DISC_SIZE, 1, &uuid_list, num_attrs, attr_list);
2187 if (!SDP_ServiceSearchAttributeRequest(p_cb->bd_addr, p_cb->p_db, p_cb->sdp_cback))
2189 status = BTA_HL_STATUS_FAIL;
2191 status = BTA_HL_STATUS_OK;
2194 status = BTA_HL_STATUS_SDP_NO_RESOURCE;
2197 if (status != BTA_HL_STATUS_OK) {
2198 osi_free_and_reset((void **)&p_cb->p_db);
2199 if (status != BTA_HL_STATUS_SDP_NO_RESOURCE)
2200 bta_hl_deallocate_spd_cback(sdp_cback_idx);
2206 /*******************************************************************************
2208 ** Function bta_hl_cch_sdp_init
2210 ** Description Action routine for processing the CCH SDP init event
2214 *******************************************************************************/
2215 void bta_hl_cch_sdp_init(UINT8 app_idx, UINT8 mcl_idx, tBTA_HL_DATA *p_data)
2217 tBTA_HL_MCL_CB *p_cb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2218 #if BTA_HL_DEBUG == TRUE
2219 APPL_TRACE_DEBUG("bta_hl_cch_init_sdp");
2221 if ( p_cb->sdp_oper == BTA_HL_SDP_OP_NONE)
2223 p_cb->app_id = p_data->api_cch_open.app_id;
2224 p_cb->sdp_oper = BTA_HL_SDP_OP_CCH_INIT;
2226 if (bta_hl_init_sdp( p_cb->sdp_oper, app_idx, mcl_idx, 0xFF) != BTA_HL_STATUS_OK)
2228 p_cb->sdp_oper = BTA_HL_SDP_OP_NONE;
2229 bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_SDP_FAIL_EVT, p_data);
2234 APPL_TRACE_ERROR("SDP in use");
2235 bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_SDP_FAIL_EVT, p_data);
2239 /*******************************************************************************
2241 ** Function bta_hl_cch_mca_open
2243 ** Description Action routine for processing the CCH open request
2247 *******************************************************************************/
2248 void bta_hl_cch_mca_open(UINT8 app_idx, UINT8 mcl_idx, tBTA_HL_DATA *p_data)
2250 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
2251 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2254 #if BTA_HL_DEBUG == TRUE
2255 APPL_TRACE_DEBUG("bta_hl_cch_mca_open");
2258 if (bta_hl_find_sdp_idx_using_ctrl_psm(&p_mcb->sdp, p_mcb->req_ctrl_psm, &sdp_idx))
2260 p_mcb->ctrl_psm = p_mcb->sdp.sdp_rec[sdp_idx].ctrl_psm;
2261 p_mcb->data_psm = p_mcb->sdp.sdp_rec[sdp_idx].data_psm;
2262 if ( MCA_ConnectReq((tMCA_HANDLE) p_acb->app_handle,
2265 p_mcb->sec_mask) != MCA_SUCCESS)
2268 bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_CLOSE_CMPL_EVT, p_data);
2273 bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_CLOSE_CMPL_EVT, p_data);
2277 /*******************************************************************************
2279 ** Function bta_hl_cch_mca_close
2281 ** Description Action routine for processing the CCH close request
2285 *******************************************************************************/
2286 void bta_hl_cch_mca_close(UINT8 app_idx, UINT8 mcl_idx, tBTA_HL_DATA *p_data)
2288 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2290 #if BTA_HL_DEBUG == TRUE
2291 APPL_TRACE_DEBUG("bta_hl_cch_mca_close mcl_handle=%d", p_mcb->mcl_handle);
2293 if (p_mcb->sdp_oper != BTA_HL_SDP_OP_CCH_INIT)
2295 if(p_mcb->mcl_handle)
2297 if ( MCA_DisconnectReq((tMCA_HANDLE) p_mcb->mcl_handle) != MCA_SUCCESS)
2299 bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_CLOSE_CMPL_EVT, p_data);
2304 p_mcb->close_pending = TRUE;
2305 APPL_TRACE_DEBUG("No valid mcl_handle to stop the CCH setup now so wait until CCH is up then close it" );
2310 p_mcb->close_pending = TRUE;
2311 APPL_TRACE_DEBUG("can not stop the CCH setup becasue SDP is in progress so wait until it is done" );
2315 /*******************************************************************************
2317 ** Function bta_hl_cch_close_cmpl
2319 ** Description Action routine for processing the CCH close complete event
2323 *******************************************************************************/
2324 void bta_hl_cch_close_cmpl(UINT8 app_idx, UINT8 mcl_idx, tBTA_HL_DATA *p_data)
2326 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
2327 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2331 BOOLEAN send_evt=TRUE;
2332 #if BTA_HL_DEBUG == TRUE
2333 APPL_TRACE_DEBUG("bta_hl_cch_close_cmpl");
2335 bta_sys_conn_close(BTA_ID_HL, p_acb->app_id, p_mcb->bd_addr);
2337 if (p_mcb->cch_oper == BTA_HL_CCH_OP_LOCAL_CLOSE && p_mcb->force_close_local_cch_opening)
2339 p_mcb->cch_oper = BTA_HL_CCH_OP_LOCAL_OPEN;
2340 APPL_TRACE_DEBUG("change cch_oper from BTA_HL_CCH_OP_LOCAL_CLOSE to BTA_HL_CCH_OP_LOCAL_OPEN");
2343 switch (p_mcb->cch_oper)
2345 case BTA_HL_CCH_OP_LOCAL_OPEN:
2346 bta_hl_build_cch_open_cfm(&evt_data,p_mcb->app_id,p_acb->app_handle,
2349 BTA_HL_STATUS_FAIL);
2350 event = BTA_HL_CCH_OPEN_CFM_EVT;
2352 case BTA_HL_CCH_OP_LOCAL_CLOSE:
2353 bta_hl_build_cch_close_cfm(&evt_data, p_acb->app_handle,
2356 event = BTA_HL_CCH_CLOSE_CFM_EVT;
2358 case BTA_HL_CCH_OP_REMOTE_CLOSE:
2359 bta_hl_build_cch_close_ind(&evt_data,
2362 p_mcb->intentional_close);
2363 event = BTA_HL_CCH_CLOSE_IND_EVT;
2371 memset(p_mcb, 0 ,sizeof(tBTA_HL_MCL_CB));
2373 if (send_evt)p_acb->p_cback(event,(tBTA_HL *) &evt_data );
2375 bta_hl_check_deregistration(app_idx, p_data);
2378 /*******************************************************************************
2380 ** Function bta_hl_cch_mca_disconnect
2382 ** Description Action routine for processing the CCH disconnect indication
2386 *******************************************************************************/
2387 void bta_hl_cch_mca_disconnect(UINT8 app_idx, UINT8 mcl_idx, tBTA_HL_DATA *p_data)
2390 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2391 tBTA_HL_MDL_CB *p_dcb;
2393 #if BTA_HL_DEBUG == TRUE
2394 APPL_TRACE_DEBUG("bta_hl_cch_mca_disconnect");
2397 p_mcb->intentional_close = FALSE;
2398 if (p_data->mca_evt.mca_data.disconnect_ind.reason == L2CAP_DISC_OK)
2400 p_mcb->intentional_close = TRUE;
2403 for (i=0; i< BTA_HL_NUM_MDLS_PER_MCL; i++)
2405 p_dcb= BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, i);
2406 if (p_dcb->in_use && (p_dcb->dch_state != BTA_HL_DCH_IDLE_ST))
2408 if (p_mcb->cch_oper == BTA_HL_CCH_OP_LOCAL_CLOSE )
2410 bta_hl_dch_sm_execute(app_idx, mcl_idx, i, BTA_HL_DCH_CLOSE_CMPL_EVT, p_data);
2414 bta_hl_dch_sm_execute(app_idx, mcl_idx, i, BTA_HL_MCA_CLOSE_IND_EVT, p_data);
2418 bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_CLOSE_CMPL_EVT, p_data);
2421 /*******************************************************************************
2423 ** Function bta_hl_cch_mca_disc_open
2425 ** Description Action routine for disconnect the just opened Control channel
2429 *******************************************************************************/
2430 void bta_hl_cch_mca_disc_open(UINT8 app_idx, UINT8 mcl_idx, tBTA_HL_DATA *p_data)
2432 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2434 #if BTA_HL_DEBUG == TRUE
2435 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 );
2438 p_mcb->close_pending = FALSE;
2439 p_mcb->mcl_handle = p_data->mca_evt.mcl_handle;
2440 bta_hl_cch_mca_close(app_idx, mcl_idx, p_data);
2443 /*******************************************************************************
2445 ** Function bta_hl_cch_mca_rsp_tout
2447 ** Description Action routine for processing the MCAP response timeout
2451 *******************************************************************************/
2452 void bta_hl_cch_mca_rsp_tout(UINT8 app_idx, UINT8 mcl_idx, tBTA_HL_DATA *p_data)
2455 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2456 #if BTA_HL_DEBUG == TRUE
2457 APPL_TRACE_DEBUG("bta_hl_cch_mca_rsp_tout");
2460 p_mcb->rsp_tout = TRUE;
2462 bta_hl_check_cch_close(app_idx,mcl_idx,p_data,TRUE);
2465 /*******************************************************************************
2467 ** Function bta_hl_cch_mca_connect
2469 ** Description Action routine for processing the CCH connect indication
2473 *******************************************************************************/
2474 void bta_hl_cch_mca_connect(UINT8 app_idx, UINT8 mcl_idx, tBTA_HL_DATA *p_data)
2476 tBTA_HL_APP_CB *p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
2477 tBTA_HL_MCL_CB *p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
2480 BOOLEAN send_event=TRUE;
2482 #if BTA_HL_DEBUG == TRUE
2483 APPL_TRACE_DEBUG("bta_hl_cch_mca_connect mcl_handle=%d ", p_data->mca_evt.mcl_handle);
2486 p_mcb->mcl_handle = p_data->mca_evt.mcl_handle;
2487 bdcpy(p_mcb->bd_addr, p_data->mca_evt.mca_data.connect_ind.bd_addr);
2488 p_mcb->cch_mtu = p_data->mca_evt.mca_data.connect_ind.mtu;
2490 bta_sys_conn_open(BTA_ID_HL, p_acb->app_id, p_mcb->bd_addr);
2491 switch (p_mcb->cch_oper)
2493 case BTA_HL_CCH_OP_LOCAL_OPEN:
2494 bta_hl_build_cch_open_cfm(&evt_data, p_mcb->app_id,p_acb->app_handle,
2498 event = BTA_HL_CCH_OPEN_CFM_EVT;
2500 case BTA_HL_CCH_OP_REMOTE_OPEN:
2501 bta_hl_build_cch_open_ind(&evt_data, p_acb->app_handle,
2504 event = BTA_HL_CCH_OPEN_IND_EVT;
2511 p_mcb->cch_oper = BTA_HL_CCH_OP_NONE;
2512 if (send_event) p_acb->p_cback(event,(tBTA_HL *) &evt_data );
2515 /*******************************************************************************
2517 ** Function bta_hl_mcap_ctrl_cback
2519 ** Description MCAP control callback function for HL.
2523 *******************************************************************************/
2524 void bta_hl_mcap_ctrl_cback (tMCA_HANDLE handle, tMCA_CL mcl, UINT8 event,
2527 BOOLEAN send_event=TRUE;
2530 #if (BTA_HL_DEBUG == TRUE)
2531 #if (BT_TRACE_VERBOSE == TRUE)
2532 APPL_TRACE_EVENT("bta_hl_mcap_ctrl_cback event[%s]",bta_hl_mcap_evt_code(event));
2534 APPL_TRACE_EVENT("bta_hl_mcap_ctrl_cback event[0x%02x]", event);
2541 case MCA_CREATE_IND_EVT:
2542 mca_event = (UINT16) BTA_HL_MCA_CREATE_IND_EVT;
2544 case MCA_CREATE_CFM_EVT:
2545 mca_event = (UINT16) BTA_HL_MCA_CREATE_CFM_EVT;
2547 case MCA_RECONNECT_IND_EVT:
2548 mca_event = (UINT16) BTA_HL_MCA_RECONNECT_IND_EVT;
2550 case MCA_RECONNECT_CFM_EVT:
2551 mca_event = (UINT16) BTA_HL_MCA_RECONNECT_CFM_EVT;
2553 case MCA_ABORT_IND_EVT:
2554 mca_event = (UINT16) BTA_HL_MCA_ABORT_IND_EVT;
2556 case MCA_ABORT_CFM_EVT:
2557 mca_event = (UINT16) BTA_HL_MCA_ABORT_CFM_EVT;
2559 case MCA_DELETE_IND_EVT:
2560 mca_event = (UINT16) BTA_HL_MCA_DELETE_IND_EVT;
2562 case MCA_DELETE_CFM_EVT:
2563 mca_event = (UINT16) BTA_HL_MCA_DELETE_CFM_EVT;
2565 case MCA_CONNECT_IND_EVT:
2566 mca_event = (UINT16) BTA_HL_MCA_CONNECT_IND_EVT;
2568 case MCA_DISCONNECT_IND_EVT:
2569 mca_event = (UINT16) BTA_HL_MCA_DISCONNECT_IND_EVT;
2571 case MCA_OPEN_IND_EVT:
2572 mca_event = (UINT16) BTA_HL_MCA_OPEN_IND_EVT;
2574 case MCA_OPEN_CFM_EVT:
2575 mca_event = (UINT16) BTA_HL_MCA_OPEN_CFM_EVT;
2577 case MCA_CLOSE_IND_EVT:
2578 mca_event = (UINT16) BTA_HL_MCA_CLOSE_IND_EVT;
2580 case MCA_CLOSE_CFM_EVT:
2581 mca_event = (UINT16) BTA_HL_MCA_CLOSE_CFM_EVT;
2583 case MCA_CONG_CHG_EVT:
2584 mca_event = (UINT16) BTA_HL_MCA_CONG_CHG_EVT;
2586 case MCA_RSP_TOUT_IND_EVT:
2587 mca_event = (UINT16) BTA_HL_MCA_RSP_TOUT_IND_EVT;
2589 case MCA_ERROR_RSP_EVT:
2597 tBTA_HL_MCA_EVT * p_msg =
2598 (tBTA_HL_MCA_EVT *)osi_malloc(sizeof(tBTA_HL_MCA_EVT));
2599 p_msg->hdr.event = mca_event;
2600 p_msg->app_handle = (tBTA_HL_APP_HANDLE) handle;
2601 p_msg->mcl_handle = (tBTA_HL_MCL_HANDLE) mcl;
2602 memcpy(&p_msg->mca_data, p_data, sizeof(tMCA_CTRL));
2603 bta_sys_sendmsg(p_msg);
2607 /*******************************************************************************
2609 ** Function bta_hl_mcap_data_cback
2611 ** Description MCAP data callback function for HL.
2615 *******************************************************************************/
2616 void bta_hl_mcap_data_cback (tMCA_DL mdl, BT_HDR *p_pkt)
2618 UINT8 app_idx, mcl_idx, mdl_idx;
2619 if (bta_hl_find_mdl_idx_using_handle ((tBTA_HL_MDL_HANDLE)mdl, &app_idx, &mcl_idx, &mdl_idx))
2621 tBTA_HL_MCA_RCV_DATA_EVT *p_msg =
2622 (tBTA_HL_MCA_RCV_DATA_EVT *)osi_malloc(sizeof(tBTA_HL_MCA_RCV_DATA_EVT));
2623 p_msg->hdr.event = BTA_HL_MCA_RCV_DATA_EVT;
2624 p_msg->app_idx = app_idx;
2625 p_msg->mcl_idx = mcl_idx;
2626 p_msg->mdl_idx = mdl_idx;
2627 p_msg->p_pkt = p_pkt;
2628 bta_sys_sendmsg(p_msg);
2632 /*****************************************************************************
2634 *****************************************************************************/
2635 #if (BTA_HL_DEBUG == TRUE && BT_TRACE_VERBOSE == TRUE)
2637 /*******************************************************************************
2639 ** Function bta_hl_mcap_evt_code
2641 ** Description get the MCAP event string pointer
2643 ** Returns char * - event string pointer
2645 *******************************************************************************/
2646 static char *bta_hl_mcap_evt_code(UINT8 evt_code)
2652 case MCA_ERROR_RSP_EVT:
2653 return "MCA_ERROR_RSP_EVT";
2654 case MCA_CREATE_IND_EVT:
2655 return "MCA_CREATE_IND_EVT";
2656 case MCA_CREATE_CFM_EVT:
2657 return "MCA_CREATE_CFM_EVT";
2658 case MCA_RECONNECT_IND_EVT:
2659 return "MCA_RECONNECT_IND_EVT";
2660 case MCA_RECONNECT_CFM_EVT:
2661 return "MCA_RECONNECT_CFM_EVT";
2662 case MCA_ABORT_IND_EVT:
2663 return "MCA_ABORT_IND_EVT";
2664 case MCA_ABORT_CFM_EVT:
2665 return "MCA_ABORT_CFM_EVT";
2666 case MCA_DELETE_IND_EVT:
2667 return "MCA_DELETE_IND_EVT";
2668 case MCA_DELETE_CFM_EVT:
2669 return "MCA_DELETE_CFM_EVT";
2671 case MCA_CONNECT_IND_EVT:
2672 return "MCA_CONNECT_IND_EVT";
2673 case MCA_DISCONNECT_IND_EVT:
2674 return "MCA_DISCONNECT_IND_EVT";
2675 case MCA_OPEN_IND_EVT:
2676 return "MCA_OPEN_IND_EVT";
2677 case MCA_OPEN_CFM_EVT:
2678 return "MCA_OPEN_CFM_EVT";
2679 case MCA_CLOSE_IND_EVT:
2680 return "MCA_CLOSE_IND_EVT";
2681 case MCA_CLOSE_CFM_EVT:
2682 return "MCA_CLOSE_CFM_EVT";
2683 case MCA_CONG_CHG_EVT:
2684 return "MCA_CONG_CHG_EVT";
2685 case MCA_RSP_TOUT_IND_EVT:
2686 return "MCA_RSP_TOUT_IND_EVT";
2688 return "Unknown MCAP event code";
2693 /*******************************************************************************
2695 ** Function bta_hl_cback_evt_code
2697 ** Description get the HDP event string pointer
2699 ** Returns char * - event string pointer
2701 *******************************************************************************/
2702 static char *bta_hl_cback_evt_code(UINT8 evt_code)
2708 case BTA_HL_CCH_OPEN_IND_EVT:
2709 return "BTA_HL_CCH_OPEN_IND_EVT";
2710 case BTA_HL_CCH_OPEN_CFM_EVT:
2711 return "BTA_HL_CCH_OPEN_CFM_EVT";
2712 case BTA_HL_CCH_CLOSE_IND_EVT:
2713 return "BTA_HL_CCH_CLOSE_IND_EVT";
2714 case BTA_HL_CCH_CLOSE_CFM_EVT:
2715 return "BTA_HL_CCH_CLOSE_CFM_EVT";
2716 case BTA_HL_DCH_OPEN_IND_EVT:
2717 return "BTA_HL_DCH_OPEN_IND_EVT";
2718 case BTA_HL_DCH_OPEN_CFM_EVT:
2719 return "BTA_HL_DCH_OPEN_CFM_EVT";
2720 case BTA_HL_DCH_CLOSE_IND_EVT:
2721 return "BTA_HL_DCH_CLOSE_IND_EVT";
2722 case BTA_HL_DCH_CLOSE_CFM_EVT:
2723 return "BTA_HL_DCH_CLOSE_CFM_EVT";
2724 case BTA_HL_DCH_RCV_DATA_IND_EVT:
2725 return "BTA_HL_DCH_RCV_DATA_IND_EVT";
2726 case BTA_HL_REGISTER_CFM_EVT:
2727 return "BTA_HL_REGISTER_CFM_EVT";
2728 case BTA_HL_DEREGISTER_CFM_EVT:
2729 return "BTA_HL_DEREGISTER_CFM_EVT";
2730 case BTA_HL_DCH_RECONNECT_CFM_EVT:
2731 return "BTA_HL_DCH_RECONNECT_CFM_EVT";
2732 case BTA_HL_DCH_RECONNECT_IND_EVT:
2733 return "BTA_HL_DCH_RECONNECT_IND_EVT";
2734 case BTA_HL_DCH_ECHO_TEST_CFM_EVT:
2735 return "BTA_HL_DCH_ECHO_TEST_CFM_EVT";
2736 case BTA_HL_SDP_QUERY_CFM_EVT:
2737 return "BTA_HL_SDP_QUERY_CFM_EVT";
2738 case BTA_HL_CONG_CHG_IND_EVT:
2739 return "BTA_HL_CONG_CHG_IND_EVT";
2740 case BTA_HL_DCH_CREATE_IND_EVT:
2741 return "BTA_HL_DCH_CREATE_IND_EVT";
2742 case BTA_HL_DELETE_MDL_IND_EVT:
2743 return "BTA_HL_DELETE_MDL_IND_EVT";
2744 case BTA_HL_DELETE_MDL_CFM_EVT:
2745 return "BTA_HL_DELETE_MDL_CFM_EVT";
2746 case BTA_HL_DCH_ABORT_IND_EVT:
2747 return "BTA_HL_DCH_ABORT_IND_EVT";
2748 case BTA_HL_DCH_ABORT_CFM_EVT:
2749 return "BTA_HL_DCH_ABORT_CFM_EVT";
2751 return "Unknown HDP event code";
2757 /*******************************************************************************
2759 ** Function bta_hl_dch_oper_code
2761 ** Description Get the DCH operation string
2763 ** Returns char * - DCH operation string pointer
2765 *******************************************************************************/
2766 static char *bta_hl_dch_oper_code(tBTA_HL_DCH_OPER oper_code)
2771 case BTA_HL_DCH_OP_NONE:
2772 return "BTA_HL_DCH_OP_NONE";
2773 case BTA_HL_DCH_OP_REMOTE_CREATE:
2774 return "BTA_HL_DCH_OP_REMOTE_CREATE";
2775 case BTA_HL_DCH_OP_LOCAL_OPEN:
2776 return "BTA_HL_DCH_OP_LOCAL_OPEN";
2777 case BTA_HL_DCH_OP_REMOTE_OPEN:
2778 return "BTA_HL_DCH_OP_REMOTE_OPEN";
2779 case BTA_HL_DCH_OP_LOCAL_CLOSE:
2780 return "BTA_HL_DCH_OP_LOCAL_CLOSE";
2781 case BTA_HL_DCH_OP_REMOTE_CLOSE:
2782 return "BTA_HL_DCH_OP_REMOTE_CLOSE";
2783 case BTA_HL_DCH_OP_LOCAL_DELETE:
2784 return "BTA_HL_DCH_OP_LOCAL_DELETE";
2785 case BTA_HL_DCH_OP_REMOTE_DELETE:
2786 return "BTA_HL_DCH_OP_REMOTE_DELETE";
2787 case BTA_HL_DCH_OP_LOCAL_RECONNECT:
2788 return "BTA_HL_DCH_OP_LOCAL_RECONNECT";
2789 case BTA_HL_DCH_OP_REMOTE_RECONNECT:
2790 return "BTA_HL_DCH_OP_REMOTE_RECONNECT";
2791 case BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST:
2792 return "BTA_HL_DCH_OP_LOCAL_CLOSE_ECHO_TEST";
2793 case BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT:
2794 return "BTA_HL_DCH_OP_LOCAL_CLOSE_RECONNECT";
2796 return "Unknown DCH oper code";
2801 #endif /* Debug Functions */
2802 #endif /* HL_INCLUDED */