123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869 |
- /******************************************************************************
- *
- * Copyright 1998-2012 Broadcom Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************/
- /******************************************************************************
- *
- * This file contains the HeaLth device profile main functions and state
- * machine.
- *
- ******************************************************************************/
- #include <string.h>
- #include "bt_target.h"
- #if (HL_INCLUDED == TRUE)
- #include "bt_common.h"
- #include "bta_hl_api.h"
- #include "bta_hl_int.h"
- #include "l2c_api.h"
- #include "mca_defs.h"
- #include "osi/include/osi.h"
- #include "utl.h"
- #if (BTA_HL_DEBUG == TRUE)
- static const char* bta_hl_cch_state_code(tBTA_HL_CCH_STATE state_code);
- static const char* bta_hl_dch_state_code(tBTA_HL_DCH_STATE state_code);
- #endif
- extern uint16_t L2CA_AllocateRandomPsm(void);
- extern uint16_t L2CA_AllocatePsm(void);
- /*****************************************************************************
- * DCH State Table
- ****************************************************************************/
- /*****************************************************************************
- * Constants and types
- ****************************************************************************/
- /* state machine action enumeration list for DCH */
- /* The order of this enumeration must be the same as bta_hl_dch_act_tbl[] */
- enum {
- BTA_HL_DCH_MCA_CREATE,
- BTA_HL_DCH_MCA_CREATE_CFM,
- BTA_HL_DCH_MCA_CREATE_IND,
- BTA_HL_DCH_MCA_OPEN_CFM,
- BTA_HL_DCH_MCA_OPEN_IND,
- BTA_HL_DCH_MCA_CLOSE,
- BTA_HL_DCH_MCA_CLOSE_CFM,
- BTA_HL_DCH_MCA_CLOSE_IND,
- BTA_HL_DCH_CLOSE_CMPL,
- BTA_HL_DCH_MCA_RCV_DATA,
- BTA_HL_DCH_SDP_INIT,
- BTA_HL_DCH_MCA_RECONNECT,
- BTA_HL_DCH_MCA_RECONNECT_IND,
- BTA_HL_DCH_MCA_RECONNECT_CFM,
- BTA_HL_DCH_CLOSE_ECHO_TEST,
- BTA_HL_DCH_CREATE_RSP,
- BTA_HL_DCH_MCA_ABORT,
- BTA_HL_DCH_MCA_ABORT_IND,
- BTA_HL_DCH_MCA_ABORT_CFM,
- BTA_HL_DCH_MCA_CONG_CHANGE,
- BTA_HL_DCH_SDP_FAIL,
- BTA_HL_DCH_SEND_DATA,
- BTA_HL_DCH_CI_GET_TX_DATA,
- BTA_HL_DCH_CI_PUT_RX_DATA,
- BTA_HL_DCH_CI_GET_ECHO_DATA,
- BTA_HL_DCH_ECHO_TEST,
- BTA_HL_DCH_CI_PUT_ECHO_DATA,
- BTA_HL_DCH_IGNORE
- };
- typedef void (*tBTA_HL_DCH_ACTION)(uint8_t app_idx, uint8_t mcl_idx,
- uint8_t mdl_idx, tBTA_HL_DATA* p_data);
- static const tBTA_HL_DCH_ACTION bta_hl_dch_action[] = {
- bta_hl_dch_mca_create, bta_hl_dch_mca_create_cfm,
- bta_hl_dch_mca_create_ind, bta_hl_dch_mca_open_cfm,
- bta_hl_dch_mca_open_ind, bta_hl_dch_mca_close,
- bta_hl_dch_mca_close_cfm, bta_hl_dch_mca_close_ind,
- bta_hl_dch_close_cmpl, bta_hl_dch_mca_rcv_data,
- bta_hl_dch_sdp_init, bta_hl_dch_mca_reconnect,
- bta_hl_dch_mca_reconnect_ind, bta_hl_dch_mca_reconnect_cfm,
- bta_hl_dch_close_echo_test, bta_hl_dch_create_rsp,
- bta_hl_dch_mca_abort, bta_hl_dch_mca_abort_ind,
- bta_hl_dch_mca_abort_cfm, bta_hl_dch_mca_cong_change,
- bta_hl_dch_sdp_fail, bta_hl_dch_send_data,
- bta_hl_dch_ci_get_tx_data, bta_hl_dch_ci_put_rx_data,
- bta_hl_dch_ci_get_echo_data, bta_hl_dch_echo_test,
- bta_hl_dch_ci_put_echo_data,
- };
- /* state table information */
- #define BTA_HL_DCH_ACTIONS 1 /* number of actions */
- #define BTA_HL_DCH_ACTION_COL 0 /* position of action */
- #define BTA_HL_DCH_NEXT_STATE 1 /* position of next state */
- #define BTA_HL_DCH_NUM_COLS 2 /* number of columns in state tables */
- /* state table for idle state */
- static const uint8_t bta_hl_dch_st_idle[][BTA_HL_DCH_NUM_COLS] = {
- /* Event Action 1 Next
- state */
- /* BTA_HL_DCH_SDP_INIT_EVT */ {BTA_HL_DCH_SDP_INIT,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_DCH_OPEN_EVT */ {BTA_HL_DCH_MCA_CREATE,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_CREATE_IND_EVT */ {BTA_HL_DCH_MCA_CREATE_IND,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_CREATE_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_OPEN_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_OPEN_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_CLOSE_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_CLOSE_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_CLOSE_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_API_SEND_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_RCV_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_CLOSE_CMPL_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_RECONNECT_EVT */ {BTA_HL_DCH_MCA_RECONNECT,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_DCH_SDP_FAIL_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_RECONNECT_IND_EVT*/ {BTA_HL_DCH_MCA_RECONNECT_IND,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_RECONNECT_CFM_EVT*/ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_CLOSE_ECHO_TEST_EVT*/ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_API_DCH_CREATE_RSP_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_ABORT_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_ABORT_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_ABORT_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_CONG_CHG_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_CI_GET_TX_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_CI_PUT_RX_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_CI_GET_ECHO_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_ECHO_TEST_EVT */ {BTA_HL_DCH_ECHO_TEST,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_CI_PUT_ECHO_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST}};
- /* state table for opening state */
- static const uint8_t bta_hl_dch_st_opening[][BTA_HL_DCH_NUM_COLS] = {
- /* Event Action 1 Next
- state */
- /* BTA_HL_DCH_SDP_INIT_EVT */ {BTA_HL_DCH_SDP_INIT,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_DCH_OPEN_EVT */ {BTA_HL_DCH_MCA_CREATE,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_CREATE_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_CREATE_CFM_EVT */ {BTA_HL_DCH_MCA_CREATE_CFM,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_OPEN_IND_EVT */ {BTA_HL_DCH_MCA_OPEN_IND,
- BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_OPEN_CFM_EVT */ {BTA_HL_DCH_MCA_OPEN_CFM,
- BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_CLOSE_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_CLOSE_IND_EVT */ {BTA_HL_DCH_MCA_CLOSE_IND,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_CLOSE_CFM_EVT */ {BTA_HL_DCH_MCA_CLOSE_CFM,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_API_SEND_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_RCV_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_CLOSE_CMPL_EVT */ {BTA_HL_DCH_CLOSE_CMPL, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_RECONNECT_EVT */ {BTA_HL_DCH_MCA_RECONNECT,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_DCH_SDP_FAIL_EVT */ {BTA_HL_DCH_SDP_FAIL,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_RECONNECT_IND_EVT*/ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_MCA_RECONNECT_CFM_EVT*/ {BTA_HL_DCH_MCA_RECONNECT_CFM,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_DCH_CLOSE_ECHO_TEST_EVT*/ {BTA_HL_DCH_IGNORE,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_API_DCH_CREATE_RSP_EVT */ {BTA_HL_DCH_CREATE_RSP,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_DCH_ABORT_EVT */ {BTA_HL_DCH_MCA_ABORT, BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_ABORT_IND_EVT */ {BTA_HL_DCH_MCA_ABORT_IND,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_ABORT_CFM_EVT */ {BTA_HL_DCH_MCA_ABORT_CFM,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_MCA_CONG_CHG_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_CI_GET_TX_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_CI_PUT_RX_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_CI_GET_ECHO_DATA_EVT */ {BTA_HL_DCH_CI_GET_ECHO_DATA,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_DCH_ECHO_TEST_EVT */ {BTA_HL_DCH_ECHO_TEST,
- BTA_HL_DCH_OPENING_ST},
- /* BTA_HL_CI_PUT_ECHO_DATA_EVT */ {BTA_HL_DCH_IGNORE,
- BTA_HL_DCH_OPENING_ST}};
- /* state table for open state */
- static const uint8_t bta_hl_dch_st_open[][BTA_HL_DCH_NUM_COLS] = {
- /* Event Action 1 Next
- state */
- /* BTA_HL_DCH_SDP_INIT_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_OPEN_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_CREATE_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_CREATE_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_OPEN_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_OPEN_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_CLOSE_EVT */ {BTA_HL_DCH_MCA_CLOSE,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_CLOSE_IND_EVT */ {BTA_HL_DCH_MCA_CLOSE_IND,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_CLOSE_CFM_EVT */ {BTA_HL_DCH_MCA_CLOSE_CFM,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_API_SEND_DATA_EVT */ {BTA_HL_DCH_SEND_DATA, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_RCV_DATA_EVT */ {BTA_HL_DCH_MCA_RCV_DATA,
- BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_CLOSE_CMPL_EVT */ {BTA_HL_DCH_CLOSE_CMPL, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_RECONNECT_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_SDP_FAIL_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_RECONNECT_IND_EVT*/ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_RECONNECT_CFM_EVT*/ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_CLOSE_ECHO_TEST_EVT*/ {BTA_HL_DCH_CLOSE_ECHO_TEST,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_API_DCH_CREATE_RSP_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_ABORT_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_ABORT_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_ABORT_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_MCA_CONG_CHG_EVT */ {BTA_HL_DCH_MCA_CONG_CHANGE,
- BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_CI_GET_TX_DATA_EVT */ {BTA_HL_DCH_CI_GET_TX_DATA,
- BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_CI_PUT_RX_DATA_EVT */ {BTA_HL_DCH_CI_PUT_RX_DATA,
- BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_CI_GET_ECHO_DATA_EVT */ {BTA_HL_DCH_CI_GET_ECHO_DATA,
- BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_DCH_ECHO_TEST_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_OPEN_ST},
- /* BTA_HL_CI_PUT_ECHO_DATA_EVT */ {BTA_HL_DCH_CI_PUT_ECHO_DATA,
- BTA_HL_DCH_OPEN_ST}};
- /* state table for closing state */
- static const uint8_t bta_hl_dch_st_closing[][BTA_HL_DCH_NUM_COLS] = {
- /* Event Action 1 Next state */
- /* BTA_HL_DCH_SDP_INIT_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_DCH_OPEN_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_CREATE_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_CREATE_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_OPEN_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_OPEN_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_DCH_CLOSE_EVT */ {BTA_HL_DCH_MCA_CLOSE,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_CLOSE_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_CLOSE_CFM_EVT */ {BTA_HL_DCH_MCA_CLOSE_CFM,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_API_SEND_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_RCV_DATA_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_DCH_CLOSE_CMPL_EVT */ {BTA_HL_DCH_CLOSE_CMPL, BTA_HL_DCH_IDLE_ST},
- /* BTA_HL_DCH_RECONNECT_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_DCH_SDP_FAIL_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_RECONNECT_IND_EVT*/ {BTA_HL_DCH_IGNORE,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_RECONNECT_CFM_EVT*/ {BTA_HL_DCH_IGNORE,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_DCH_CLOSE_ECHO_TEST_EVT*/ {BTA_HL_DCH_IGNORE,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_API_DCH_CREATE_RSP_EVT */ {BTA_HL_DCH_IGNORE,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_DCH_ABORT_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_ABORT_IND_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_DCH_ABORT_CFM_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_MCA_CONG_CHG_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_CI_GET_TX_DATA_EVT */ {BTA_HL_DCH_CI_GET_TX_DATA,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_CI_PUT_RX_DATA_EVT */ {BTA_HL_DCH_CI_PUT_RX_DATA,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_CI_GET_ECHO_DATA_EVT */ {BTA_HL_DCH_CI_GET_ECHO_DATA,
- BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_DCH_ECHO_TEST_EVT */ {BTA_HL_DCH_IGNORE, BTA_HL_DCH_CLOSING_ST},
- /* BTA_HL_CI_PUT_ECHO_DATA_EVT */ {BTA_HL_DCH_CI_PUT_ECHO_DATA,
- BTA_HL_DCH_CLOSING_ST}};
- /* type for state table */
- typedef const uint8_t (*tBTA_HL_DCH_ST_TBL)[BTA_HL_DCH_NUM_COLS];
- /* state table */
- const tBTA_HL_DCH_ST_TBL bta_hl_dch_st_tbl[] = {
- bta_hl_dch_st_idle, bta_hl_dch_st_opening, bta_hl_dch_st_open,
- bta_hl_dch_st_closing};
- /*****************************************************************************
- * CCH State Table
- ****************************************************************************/
- /*****************************************************************************
- * Constants and types
- ****************************************************************************/
- /* state machine action enumeration list for CCH */
- enum {
- BTA_HL_CCH_SDP_INIT,
- BTA_HL_CCH_MCA_OPEN,
- BTA_HL_CCH_MCA_CLOSE,
- BTA_HL_CCH_CLOSE_CMPL,
- BTA_HL_CCH_MCA_CONNECT,
- BTA_HL_CCH_MCA_DISCONNECT,
- BTA_HL_CCH_MCA_RSP_TOUT,
- BTA_HL_CCH_MCA_DISC_OPEN,
- BTA_HL_CCH_IGNORE
- };
- /* type for action functions */
- typedef void (*tBTA_HL_CCH_ACTION)(uint8_t app_idx, uint8_t mcl_idx,
- tBTA_HL_DATA* p_data);
- /* action function list for MAS */
- const tBTA_HL_CCH_ACTION bta_hl_cch_action[] = {
- bta_hl_cch_sdp_init, bta_hl_cch_mca_open, bta_hl_cch_mca_close,
- bta_hl_cch_close_cmpl, bta_hl_cch_mca_connect, bta_hl_cch_mca_disconnect,
- bta_hl_cch_mca_rsp_tout, bta_hl_cch_mca_disc_open};
- /* state table information */
- #define BTA_HL_CCH_ACTIONS 1 /* number of actions */
- #define BTA_HL_CCH_NEXT_STATE 1 /* position of next state */
- #define BTA_HL_CCH_NUM_COLS 2 /* number of columns in state tables */
- /* state table for MAS idle state */
- static const uint8_t bta_hl_cch_st_idle[][BTA_HL_CCH_NUM_COLS] = {
- /* Event Action 1 Next state */
- /* BTA_HL_CCH_OPEN_EVT */ {BTA_HL_CCH_SDP_INIT,
- BTA_HL_CCH_OPENING_ST},
- /* BTA_HL_CCH_SDP_OK_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_CCH_SDP_FAIL_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_MCA_CONNECT_IND_EVT */ {BTA_HL_CCH_MCA_CONNECT,
- BTA_HL_CCH_OPEN_ST},
- /* BTA_HL_MCA_DISCONNECT_IND_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_CCH_CLOSE_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_CCH_CLOSE_CMPL_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_CCH_CLOSE_CMPL_EVT */ {BTA_HL_CCH_IGNORE,
- BTA_HL_CCH_IDLE_ST}};
- /* state table for obex/rfcomm connection state */
- static const uint8_t bta_hl_cch_st_opening[][BTA_HL_CCH_NUM_COLS] = {
- /* Event Action 1 Next state */
- /* BTA_HL_CCH_OPEN_EVT */ {BTA_HL_CCH_IGNORE,
- BTA_HL_CCH_OPENING_ST},
- /* BTA_HL_CCH_SDP_OK_EVT */ {BTA_HL_CCH_MCA_OPEN,
- BTA_HL_CCH_OPENING_ST},
- /* BTA_HL_CCH_SDP_FAIL_EVT */ {BTA_HL_CCH_CLOSE_CMPL,
- BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_MCA_CONNECT_IND_EVT */ {BTA_HL_CCH_MCA_CONNECT,
- BTA_HL_CCH_OPEN_ST},
- /* BTA_HL_MCA_DISCONNECT_IND_EVT */ {BTA_HL_CCH_MCA_DISCONNECT,
- BTA_HL_CCH_CLOSING_ST},
- /* BTA_HL_CCH_CLOSE_EVT */ {BTA_HL_CCH_MCA_CLOSE,
- BTA_HL_CCH_CLOSING_ST},
- /* BTA_HL_CCH_CLOSE_CMPL_EVT */ {BTA_HL_CCH_CLOSE_CMPL,
- BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_MCA_RSP_TOUT_IND_EVT */ {BTA_HL_CCH_MCA_RSP_TOUT,
- BTA_HL_CCH_CLOSING_ST}};
- /* state table for open state */
- static const uint8_t bta_hl_cch_st_open[][BTA_HL_CCH_NUM_COLS] = {
- /* Event Action 1 Next state */
- /* BTA_HL_CCH_OPEN_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_OPEN_ST},
- /* BTA_HL_CCH_SDP_OK_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_OPEN_ST},
- /* BTA_HL_CCH_SDP_FAIL_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_OPEN_ST},
- /* BTA_HL_MCA_CONNECT_IND_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_OPEN_ST},
- /* BTA_HL_MCA_DISCONNECT_IND_EVT */ {BTA_HL_CCH_MCA_DISCONNECT,
- BTA_HL_CCH_CLOSING_ST},
- /* BTA_HL_CCH_CLOSE_EVT */ {BTA_HL_CCH_MCA_CLOSE,
- BTA_HL_CCH_CLOSING_ST},
- /* BTA_HL_CCH_CLOSE_CMPL_EVT */ {BTA_HL_CCH_IGNORE, BTA_HL_CCH_OPEN_ST},
- /* BTA_HL_MCA_RSP_TOUT_IND_EVT */ {BTA_HL_CCH_MCA_RSP_TOUT,
- BTA_HL_CCH_CLOSING_ST}};
- /* state table for closing state */
- static const uint8_t bta_hl_cch_st_closing[][BTA_HL_CCH_NUM_COLS] = {
- /* Event Action 1 Next state */
- /* BTA_HL_CCH_OPEN_EVT */ {BTA_HL_CCH_IGNORE,
- BTA_HL_CCH_CLOSING_ST},
- /* BTA_HL_CCH_SDP_OK_EVT */ {BTA_HL_CCH_CLOSE_CMPL,
- BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_CCH_SDP_FAIL_EVT */ {BTA_HL_CCH_CLOSE_CMPL,
- BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_MCA_CONNECT_IND_EVT */ {BTA_HL_CCH_MCA_DISC_OPEN,
- BTA_HL_CCH_CLOSING_ST},
- /* BTA_HL_MCA_DISCONNECT_IND_EVT */ {BTA_HL_CCH_MCA_DISCONNECT,
- BTA_HL_CCH_CLOSING_ST},
- /* BTA_HL_CCH_CLOSE_EVT */ {BTA_HL_CCH_MCA_CLOSE,
- BTA_HL_CCH_CLOSING_ST},
- /* BTA_HL_CCH_CLOSE_CMPL_EVT */ {BTA_HL_CCH_CLOSE_CMPL,
- BTA_HL_CCH_IDLE_ST},
- /* BTA_HL_MCA_RSP_TOUT_IND_EVT */ {BTA_HL_CCH_IGNORE,
- BTA_HL_CCH_CLOSING_ST}};
- /* type for state table CCH */
- typedef const uint8_t (*tBTA_HL_CCH_ST_TBL)[BTA_HL_CCH_NUM_COLS];
- /* MAS state table */
- const tBTA_HL_CCH_ST_TBL bta_hl_cch_st_tbl[] = {
- bta_hl_cch_st_idle, bta_hl_cch_st_opening, bta_hl_cch_st_open,
- bta_hl_cch_st_closing};
- /*****************************************************************************
- * Global data
- ****************************************************************************/
- /* HL control block */
- tBTA_HL_CB bta_hl_cb;
- /*******************************************************************************
- *
- * Function bta_hl_cch_sm_execute
- *
- * Description State machine event handling function for CCH
- *
- * Returns void
- *
- ******************************************************************************/
- void bta_hl_cch_sm_execute(uint8_t app_idx, uint8_t mcl_idx, uint16_t event,
- tBTA_HL_DATA* p_data) {
- tBTA_HL_CCH_ST_TBL state_table;
- uint8_t action;
- int i;
- tBTA_HL_MCL_CB* p_cb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- #if (BTA_HL_DEBUG == TRUE)
- tBTA_HL_CCH_STATE in_state = p_cb->cch_state;
- uint16_t cur_evt = event;
- APPL_TRACE_DEBUG("HDP CCH Event Handler: State 0x%02x [%s], Event [%s]",
- in_state, bta_hl_cch_state_code(in_state),
- bta_hl_evt_code(cur_evt));
- #endif
- /* look up the state table for the current state */
- state_table = bta_hl_cch_st_tbl[p_cb->cch_state];
- event &= 0x00FF;
- /* set next state */
- p_cb->cch_state = state_table[event][BTA_HL_CCH_NEXT_STATE];
- for (i = 0; i < BTA_HL_CCH_ACTIONS; i++) {
- action = state_table[event][i];
- if (action != BTA_HL_CCH_IGNORE) {
- (*bta_hl_cch_action[action])(app_idx, mcl_idx, p_data);
- } else {
- /* discard HDP data */
- bta_hl_discard_data(p_data->hdr.event, p_data);
- break;
- }
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (in_state != p_cb->cch_state) {
- APPL_TRACE_DEBUG("HL CCH State Change: [%s] -> [%s] after [%s]",
- bta_hl_cch_state_code(in_state),
- bta_hl_cch_state_code(p_cb->cch_state),
- bta_hl_evt_code(cur_evt));
- }
- #endif
- }
- /*******************************************************************************
- *
- * Function bta_hl_dch_sm_execute
- *
- * Description State machine event handling function for DCH
- *
- * Returns void
- *
- ******************************************************************************/
- void bta_hl_dch_sm_execute(uint8_t app_idx, uint8_t mcl_idx, uint8_t mdl_idx,
- uint16_t event, tBTA_HL_DATA* p_data) {
- tBTA_HL_DCH_ST_TBL state_table;
- uint8_t action;
- int i;
- tBTA_HL_MDL_CB* p_cb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
- #if (BTA_HL_DEBUG == TRUE)
- tBTA_HL_DCH_STATE in_state = p_cb->dch_state;
- uint16_t cur_evt = event;
- APPL_TRACE_DEBUG("HDP DCH Event Handler: State 0x%02x [%s], Event [%s]",
- in_state, bta_hl_dch_state_code(in_state),
- bta_hl_evt_code(cur_evt));
- #endif
- /* look up the state table for the current state */
- state_table = bta_hl_dch_st_tbl[p_cb->dch_state];
- event -= BTA_HL_DCH_EVT_MIN;
- /* set next state */
- p_cb->dch_state = state_table[event][BTA_HL_DCH_NEXT_STATE];
- for (i = 0; i < BTA_HL_DCH_ACTIONS; i++) {
- action = state_table[event][i];
- if (action != BTA_HL_DCH_IGNORE) {
- (*bta_hl_dch_action[action])(app_idx, mcl_idx, mdl_idx, p_data);
- } else {
- /* discard mas data */
- bta_hl_discard_data(p_data->hdr.event, p_data);
- break;
- }
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (in_state != p_cb->dch_state) {
- APPL_TRACE_DEBUG("HL DCH State Change: [%s] -> [%s] after [%s]",
- bta_hl_dch_state_code(in_state),
- bta_hl_dch_state_code(p_cb->dch_state),
- bta_hl_evt_code(cur_evt));
- }
- #endif
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_enable
- *
- * Description Process the API enable request to enable the HL subsystem
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_enable(tBTA_HL_CB* p_cb, tBTA_HL_DATA* p_data) {
- tBTA_HL_CTRL evt_data;
- /* If already enabled then reject this request */
- if (p_cb->enable) {
- APPL_TRACE_ERROR("HL is already enabled");
- evt_data.enable_cfm.status = BTA_HL_STATUS_FAIL;
- if (p_data->api_enable.p_cback)
- p_data->api_enable.p_cback(BTA_HL_CTRL_ENABLE_CFM_EVT,
- (tBTA_HL_CTRL*)&evt_data);
- return;
- }
- /* Done with checking. now perform the enable oepration*/
- /* initialize control block */
- memset(p_cb, 0, sizeof(tBTA_HL_CB));
- p_cb->enable = true;
- p_cb->p_ctrl_cback = p_data->api_enable.p_cback;
- evt_data.enable_cfm.status = BTA_HL_STATUS_OK;
- if (p_data->api_enable.p_cback)
- p_data->api_enable.p_cback(BTA_HL_CTRL_ENABLE_CFM_EVT,
- (tBTA_HL_CTRL*)&evt_data);
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_disable
- *
- * Description Process the API disable request to disable the HL subsystem
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_disable(tBTA_HL_CB* p_cb, tBTA_HL_DATA* p_data) {
- tBTA_HL_CTRL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- if (p_cb->enable) {
- p_cb->disabling = true;
- bta_hl_check_disable(p_data);
- } else {
- status = BTA_HL_STATUS_FAIL;
- evt_data.disable_cfm.status = status;
- if (p_cb->p_ctrl_cback)
- p_cb->p_ctrl_cback(BTA_HL_CTRL_DISABLE_CFM_EVT, (tBTA_HL_CTRL*)&evt_data);
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_disable status =%s",
- bta_hl_status_code(status));
- }
- #endif
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_update
- *
- * Description Process the API registration request to register an HDP
- * application
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_update(tBTA_HL_CB* p_cb, tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_APP_CB* p_acb = BTA_HL_GET_APP_CB_PTR(0);
- tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
- APPL_TRACE_DEBUG("bta_hl_api_update");
- if (p_cb->enable) {
- status = bta_hl_app_update(p_data->api_update.app_id,
- p_data->api_update.is_register);
- if (!p_data->api_update.is_register) {
- APPL_TRACE_DEBUG("Deregister");
- memset(&evt_data, 0, sizeof(tBTA_HL));
- evt_data.dereg_cfm.status = status;
- evt_data.dereg_cfm.app_id = p_data->api_update.app_id;
- if (status == BTA_HL_STATUS_OK)
- evt_data.dereg_cfm.app_handle = p_acb->app_handle;
- if (p_acb->p_cback) {
- p_acb->p_cback(BTA_HL_DEREGISTER_CFM_EVT, (tBTA_HL*)&evt_data);
- }
- return;
- }
- }
- if (status != BTA_HL_STATUS_OK) {
- if ((status != BTA_HL_STATUS_DUPLICATE_APP_ID) &&
- (status != BTA_HL_STATUS_NO_RESOURCE)) {
- if (p_acb) memset(p_acb, 0, sizeof(tBTA_HL_APP_CB));
- }
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_register status =%s",
- bta_hl_status_code(status));
- }
- #endif
- memset(&evt_data, 0, sizeof(tBTA_HL));
- evt_data.reg_cfm.status = status;
- evt_data.reg_cfm.app_id = p_data->api_update.app_id;
- if (status == BTA_HL_STATUS_OK)
- evt_data.reg_cfm.app_handle = p_acb->app_handle;
- if (p_data->api_reg.p_cback) {
- p_data->api_reg.p_cback(BTA_HL_REGISTER_CFM_EVT, (tBTA_HL*)&evt_data);
- }
- if (status == BTA_HL_STATUS_OK) {
- evt_data.sdp_info_ind.app_handle = p_acb->app_handle;
- evt_data.sdp_info_ind.ctrl_psm = p_acb->ctrl_psm;
- evt_data.sdp_info_ind.data_psm = p_acb->data_psm;
- evt_data.sdp_info_ind.data_x_spec = BTA_HL_SDP_IEEE_11073_20601;
- evt_data.sdp_info_ind.mcap_sup_procs = BTA_HL_MCAP_SUP_PROC_MASK;
- if (p_data->api_reg.p_cback) {
- p_data->api_reg.p_cback(BTA_HL_SDP_INFO_IND_EVT, (tBTA_HL*)&evt_data);
- }
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_register
- *
- * Description Process the API registration request to register an HDP
- * application
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_register(tBTA_HL_CB* p_cb, tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- uint8_t app_idx;
- tBTA_HL_APP_CB* p_acb = NULL;
- tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
- if (p_cb->enable) {
- if (!bta_hl_is_a_duplicate_id(p_data->api_reg.app_id)) {
- if (bta_hl_find_avail_app_idx(&app_idx)) {
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- p_acb->in_use = true;
- p_acb->app_id = p_data->api_reg.app_id;
- p_acb->p_cback = p_data->api_reg.p_cback;
- p_acb->sec_mask = p_data->api_reg.sec_mask;
- p_acb->dev_type = p_data->api_reg.dev_type;
- strlcpy(p_acb->srv_name, p_data->api_reg.srv_name,
- sizeof(p_acb->srv_name));
- strlcpy(p_acb->srv_desp, p_data->api_reg.srv_desp,
- sizeof(p_acb->srv_desp));
- strlcpy(p_acb->provider_name, p_data->api_reg.provider_name,
- sizeof(p_acb->provider_name));
- bta_hl_cb.p_alloc_psm = L2CA_AllocatePSM;
- p_acb->ctrl_psm = bta_hl_cb.p_alloc_psm();
- p_acb->data_psm = bta_hl_cb.p_alloc_psm();
- p_acb->p_mcap_cback = bta_hl_mcap_ctrl_cback;
- status = bta_hl_app_registration(app_idx);
- } else {
- status = BTA_HL_STATUS_NO_RESOURCE;
- }
- } else {
- status = BTA_HL_STATUS_DUPLICATE_APP_ID;
- }
- }
- if (status != BTA_HL_STATUS_OK) {
- if ((status != BTA_HL_STATUS_DUPLICATE_APP_ID) &&
- (status != BTA_HL_STATUS_NO_RESOURCE)) {
- if (p_acb) memset(p_acb, 0, sizeof(tBTA_HL_APP_CB));
- }
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_register status =%s",
- bta_hl_status_code(status));
- }
- #endif
- memset(&evt_data, 0, sizeof(tBTA_HL));
- evt_data.reg_cfm.status = status;
- evt_data.reg_cfm.app_id = p_data->api_reg.app_id;
- if (status == BTA_HL_STATUS_OK)
- evt_data.reg_cfm.app_handle = p_acb->app_handle;
- if (p_data->api_reg.p_cback) {
- p_data->api_reg.p_cback(BTA_HL_REGISTER_CFM_EVT, (tBTA_HL*)&evt_data);
- }
- if (status == BTA_HL_STATUS_OK) {
- evt_data.sdp_info_ind.app_handle = p_acb->app_handle;
- evt_data.sdp_info_ind.ctrl_psm = p_acb->ctrl_psm;
- evt_data.sdp_info_ind.data_psm = p_acb->data_psm;
- evt_data.sdp_info_ind.data_x_spec = BTA_HL_SDP_IEEE_11073_20601;
- evt_data.sdp_info_ind.mcap_sup_procs = BTA_HL_MCAP_SUP_PROC_MASK;
- if (p_data->api_reg.p_cback) {
- p_data->api_reg.p_cback(BTA_HL_SDP_INFO_IND_EVT, (tBTA_HL*)&evt_data);
- }
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_deregister
- *
- * Description Process the API de-registration request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_deregister(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- uint8_t app_idx;
- tBTA_HL_APP_CB* p_acb;
- if (bta_hl_find_app_idx_using_handle(p_data->api_dereg.app_handle,
- &app_idx)) {
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- p_acb->deregistering = true;
- bta_hl_check_deregistration(app_idx, p_data);
- } else {
- APPL_TRACE_ERROR("Invalid app_handle=%d", p_data->api_dereg.app_handle);
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_cch_open
- *
- * Description Process the API CCH open request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_cch_open(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb;
- if (bta_hl_find_app_idx_using_handle(p_data->api_cch_open.app_handle,
- &app_idx)) {
- if (!bta_hl_find_mcl_idx(app_idx, p_data->api_cch_open.bd_addr, &mcl_idx)) {
- if (bta_hl_find_avail_mcl_idx(app_idx, &mcl_idx)) {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- p_mcb->in_use = true;
- p_mcb->req_ctrl_psm = p_data->api_cch_open.ctrl_psm;
- p_mcb->sec_mask = p_data->api_cch_open.sec_mask;
- p_mcb->bd_addr = p_data->api_cch_open.bd_addr;
- p_mcb->cch_oper = BTA_HL_CCH_OP_LOCAL_OPEN;
- } else {
- status = BTA_HL_STATUS_NO_RESOURCE;
- }
- } else {
- /* Only one MCL per BD_ADDR */
- status = BTA_HL_STATUS_DUPLICATE_CCH_OPEN;
- APPL_TRACE_DEBUG("bta_hl_api_cch_open: CCH already open: status =%d",
- status)
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- if (p_acb->p_cback) {
- bta_hl_build_cch_open_cfm(&evt_data, p_data->api_cch_open.app_id,
- p_data->api_cch_open.app_handle,
- p_mcb->mcl_handle,
- p_data->api_cch_open.bd_addr, status);
- p_acb->p_cback(BTA_HL_CCH_OPEN_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_cch_open Null Callback");
- }
- return;
- }
- } else {
- status = BTA_HL_STATUS_INVALID_APP_HANDLE;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_cch_open status =%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_OK:
- bta_hl_cch_sm_execute(app_idx, mcl_idx, BTA_HL_CCH_OPEN_EVT, p_data);
- break;
- case BTA_HL_STATUS_NO_RESOURCE:
- case BTA_HL_STATUS_FAIL:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- bta_hl_build_cch_open_cfm(&evt_data, p_data->api_cch_open.app_id,
- p_data->api_cch_open.app_handle, 0,
- p_data->api_cch_open.bd_addr, status);
- p_acb->p_cback(BTA_HL_CCH_OPEN_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_cch_open Null Callback");
- }
- break;
- default:
- APPL_TRACE_ERROR("status code=%d", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_cch_close
- *
- * Description Process the API CCH close request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_cch_close(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb;
- if (bta_hl_find_mcl_idx_using_handle(p_data->api_cch_close.mcl_handle,
- &app_idx, &mcl_idx)) {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- p_mcb->cch_oper = BTA_HL_CCH_OP_LOCAL_CLOSE;
- } else {
- status = BTA_HL_STATUS_INVALID_MCL_HANDLE;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_cch_close status =%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_OK:
- bta_hl_check_cch_close(app_idx, mcl_idx, p_data, true);
- break;
- case BTA_HL_STATUS_INVALID_MCL_HANDLE:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- bta_hl_build_cch_close_cfm(&evt_data, p_acb->app_handle,
- p_data->api_cch_close.mcl_handle, status);
- p_acb->p_cback(BTA_HL_CCH_CLOSE_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_cch_close Null Callback");
- }
- break;
- default:
- APPL_TRACE_ERROR("status code=%d", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_dch_open
- *
- * Description Process the API DCH open request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_dch_open(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx, mdl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb = NULL;
- tBTA_HL_MDL_CB* p_dcb;
- tBTA_HL_MDEP_CFG* p_mdep_cfg;
- uint8_t mdep_cfg_idx;
- if (bta_hl_find_mcl_idx_using_handle(p_data->api_dch_open.mcl_handle,
- &app_idx, &mcl_idx)) {
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- APPL_TRACE_DEBUG(
- "bta_hl_api_dch_open: app_ix=%d, mcl_idx=%d, cch_state=%d, "
- "mcl_handle=%d",
- app_idx, mcl_idx, p_mcb->cch_state, p_data->api_dch_open.mcl_handle);
- if (p_mcb->cch_state == BTA_HL_CCH_OPEN_ST) {
- if (bta_hl_find_avail_mdl_idx(app_idx, mcl_idx, &mdl_idx)) {
- p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
- if (bta_hl_find_mdep_cfg_idx(
- app_idx, p_data->api_dch_open.local_mdep_id, &mdep_cfg_idx)) {
- if (mdep_cfg_idx &&
- (p_acb->sup_feature.mdep[mdep_cfg_idx].mdep_cfg.mdep_role ==
- BTA_HL_MDEP_ROLE_SINK)) {
- p_data->api_dch_open.local_cfg = BTA_HL_DCH_CFG_NO_PREF;
- }
- status = bta_hl_chk_local_cfg(app_idx, mcl_idx, mdep_cfg_idx,
- p_data->api_dch_open.local_cfg);
- if (status == BTA_HL_STATUS_OK) {
- if (p_data->api_dch_open.local_mdep_id !=
- BTA_HL_ECHO_TEST_MDEP_ID) {
- if (bta_hl_set_ctrl_psm_for_dch(app_idx, mcl_idx, mdl_idx,
- p_data->api_dch_open.ctrl_psm)) {
- p_mdep_cfg = BTA_HL_GET_MDEP_CFG_PTR(app_idx, mdep_cfg_idx);
- p_dcb->in_use = true;
- p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_OPEN;
- p_dcb->sec_mask = p_data->api_dch_open.sec_mask;
- p_dcb->local_mdep_id = p_data->api_dch_open.local_mdep_id;
- p_dcb->peer_mdep_id = p_data->api_dch_open.peer_mdep_id;
- if (p_mdep_cfg->mdep_role == BTA_HL_MDEP_ROLE_SINK) {
- p_dcb->peer_mdep_role = BTA_HL_MDEP_ROLE_SOURCE;
- } else {
- p_dcb->peer_mdep_role = BTA_HL_MDEP_ROLE_SINK;
- }
- p_dcb->local_mdep_cfg_idx = mdep_cfg_idx;
- p_dcb->local_cfg = p_data->api_dch_open.local_cfg;
- bta_hl_find_rxtx_apdu_size(app_idx, mdep_cfg_idx,
- &p_dcb->max_rx_apdu_size,
- &p_dcb->max_tx_apdu_size);
- p_dcb->mdl_id =
- bta_hl_allocate_mdl_id(app_idx, mcl_idx, mdl_idx);
- p_dcb->mdl_cfg_idx_included = false;
- } else {
- status = BTA_HL_STATUS_INVALID_CTRL_PSM;
- }
- } else {
- status = BTA_HL_STATUS_INVALID_LOCAL_MDEP_ID;
- }
- }
- } else {
- status = BTA_HL_STATUS_INVALID_LOCAL_MDEP_ID;
- }
- } else {
- status = BTA_HL_STATUS_NO_RESOURCE;
- }
- } else {
- status = BTA_HL_STATUS_NO_CCH;
- }
- } else {
- status = BTA_HL_STATUS_INVALID_MCL_HANDLE;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_dch_open status =%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_OK:
- if (p_mcb->sdp.num_recs) {
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_OPEN_EVT,
- p_data);
- } else {
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx,
- BTA_HL_DCH_SDP_INIT_EVT, p_data);
- }
- break;
- case BTA_HL_STATUS_INVALID_DCH_CFG:
- case BTA_HL_STATUS_NO_FIRST_RELIABLE:
- case BTA_HL_STATUS_NO_CCH:
- case BTA_HL_STATUS_NO_RESOURCE:
- case BTA_HL_STATUS_FAIL:
- case BTA_HL_STATUS_INVALID_LOCAL_MDEP_ID:
- case BTA_HL_STATUS_INVALID_CTRL_PSM:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- bta_hl_build_dch_open_cfm(
- &evt_data, p_acb->app_handle, p_data->api_dch_open.mcl_handle,
- BTA_HL_INVALID_MDL_HANDLE, 0, 0, 0, 0, 0, status);
- p_acb->p_cback(BTA_HL_DCH_OPEN_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_dch_open Null Callback");
- }
- break;
- default:
- APPL_TRACE_ERROR("Status code=%d", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_dch_close
- *
- * Description Process the API DCH close request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_dch_close(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx, mdl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb;
- tBTA_HL_MDL_CB* p_dcb;
- if (bta_hl_find_mdl_idx_using_handle(p_data->api_dch_close.mdl_handle,
- &app_idx, &mcl_idx, &mdl_idx)) {
- p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
- if (p_dcb->dch_state != BTA_HL_DCH_OPEN_ST) {
- status = BTA_HL_STATUS_FAIL;
- }
- } else {
- status = BTA_HL_STATUS_INVALID_MDL_HANDLE;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_dch_close status =%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_OK:
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_CLOSE_EVT,
- p_data);
- break;
- case BTA_HL_STATUS_FAIL:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- bta_hl_build_dch_close_cfm(&evt_data, p_acb->app_handle,
- p_mcb->mcl_handle,
- p_data->api_dch_close.mdl_handle, status);
- p_acb->p_cback(BTA_HL_DCH_CLOSE_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_dch_close Null Callback");
- }
- break;
- default:
- APPL_TRACE_ERROR("Status code=%d", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_dch_reconnect
- *
- * Description Process the API DCH reconnect request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_dch_reconnect(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx, mdl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb = NULL;
- tBTA_HL_MDL_CB* p_dcb;
- uint8_t mdep_cfg_idx;
- uint8_t mdl_cfg_idx;
- tBTA_HL_MDEP_CFG* p_mdep_cfg;
- if (bta_hl_find_mcl_idx_using_handle(p_data->api_dch_reconnect.mcl_handle,
- &app_idx, &mcl_idx)) {
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- if (p_mcb->cch_state == BTA_HL_CCH_OPEN_ST) {
- if (bta_hl_find_avail_mdl_idx(app_idx, mcl_idx, &mdl_idx)) {
- p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
- if (bta_hl_validate_reconnect_params(app_idx, mcl_idx,
- &(p_data->api_dch_reconnect),
- &mdep_cfg_idx, &mdl_cfg_idx)) {
- if (!bta_hl_is_the_first_reliable_existed(app_idx, mcl_idx) &&
- (p_acb->mdl_cfg[mdl_cfg_idx].dch_mode !=
- BTA_HL_DCH_MODE_RELIABLE)) {
- status = BTA_HL_STATUS_NO_FIRST_RELIABLE;
- } else {
- if (bta_hl_set_ctrl_psm_for_dch(app_idx, mcl_idx, mdl_idx,
- p_data->api_dch_open.ctrl_psm)) {
- p_dcb->in_use = true;
- p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_RECONNECT;
- p_dcb->sec_mask = (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
- p_dcb->local_mdep_id = p_acb->mdl_cfg[mdl_cfg_idx].local_mdep_id;
- p_dcb->local_mdep_cfg_idx = mdep_cfg_idx;
- p_dcb->local_cfg = BTA_HL_DCH_CFG_UNKNOWN;
- p_dcb->mdl_id = p_data->api_dch_reconnect.mdl_id;
- p_dcb->mdl_cfg_idx_included = true;
- p_dcb->mdl_cfg_idx = mdl_cfg_idx;
- p_dcb->dch_mode = p_acb->mdl_cfg[mdl_cfg_idx].dch_mode;
- p_mdep_cfg = BTA_HL_GET_MDEP_CFG_PTR(app_idx, mdep_cfg_idx);
- if (p_mdep_cfg->mdep_role == BTA_HL_MDEP_ROLE_SINK) {
- p_dcb->peer_mdep_role = BTA_HL_MDEP_ROLE_SOURCE;
- APPL_TRACE_DEBUG("peer mdep role = SOURCE ");
- } else {
- p_dcb->peer_mdep_role = BTA_HL_MDEP_ROLE_SINK;
- APPL_TRACE_DEBUG("peer mdep role = SINK ");
- }
- bta_hl_find_rxtx_apdu_size(app_idx, mdep_cfg_idx,
- &p_dcb->max_rx_apdu_size,
- &p_dcb->max_tx_apdu_size);
- } else {
- status = BTA_HL_STATUS_INVALID_CTRL_PSM;
- }
- }
- } else {
- status = BTA_HL_STATUS_INVALID_RECONNECT_CFG;
- }
- } else {
- status = BTA_HL_STATUS_NO_RESOURCE;
- }
- } else {
- status = BTA_HL_STATUS_NO_CCH;
- }
- } else {
- status = BTA_HL_STATUS_INVALID_MCL_HANDLE;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_dch_reconnect status=%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_OK:
- if (p_mcb->sdp.num_recs) {
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx,
- BTA_HL_DCH_RECONNECT_EVT, p_data);
- } else {
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx,
- BTA_HL_DCH_SDP_INIT_EVT, p_data);
- }
- break;
- case BTA_HL_STATUS_INVALID_RECONNECT_CFG:
- case BTA_HL_STATUS_NO_FIRST_RELIABLE:
- case BTA_HL_STATUS_NO_CCH:
- case BTA_HL_STATUS_NO_RESOURCE:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- bta_hl_build_dch_open_cfm(
- &evt_data, p_acb->app_handle, p_data->api_dch_reconnect.mcl_handle,
- BTA_HL_INVALID_MDL_HANDLE, 0, p_data->api_dch_reconnect.mdl_id, 0,
- 0, 0, status);
- p_acb->p_cback(BTA_HL_DCH_RECONNECT_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_dch_reconnect Null Callback");
- }
- break;
- default:
- APPL_TRACE_ERROR("Status code=%d", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_dch_echo_test
- *
- * Description Process the API Echo test request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_dch_echo_test(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx, mdl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb = NULL;
- tBTA_HL_MDL_CB* p_dcb;
- tBTA_HL_ECHO_CFG* p_echo_cfg;
- if (bta_hl_find_mcl_idx_using_handle(p_data->api_dch_echo_test.mcl_handle,
- &app_idx, &mcl_idx)) {
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- if (p_mcb->cch_state == BTA_HL_CCH_OPEN_ST) {
- if (!p_mcb->echo_test) {
- if (bta_hl_find_avail_mdl_idx(app_idx, mcl_idx, &mdl_idx)) {
- p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
- if ((p_data->api_dch_echo_test.local_cfg ==
- BTA_HL_DCH_CFG_RELIABLE) ||
- (p_data->api_dch_echo_test.local_cfg ==
- BTA_HL_DCH_CFG_STREAMING)) {
- bool fcs_use =
- (bool)(p_dcb->chnl_cfg.fcs & BTA_HL_MCA_FCS_USE_MASK);
- p_dcb->p_echo_tx_pkt =
- bta_hl_get_buf(p_data->api_dch_echo_test.pkt_size, fcs_use);
- if (p_dcb->p_echo_tx_pkt != NULL) {
- if (bta_hl_set_ctrl_psm_for_dch(app_idx, mcl_idx, mdl_idx,
- p_data->api_dch_open.ctrl_psm)) {
- p_dcb->in_use = true;
- p_dcb->dch_oper = BTA_HL_DCH_OP_LOCAL_OPEN;
- p_dcb->sec_mask = (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT);
- p_dcb->local_mdep_cfg_idx = BTA_HL_ECHO_TEST_MDEP_CFG_IDX;
- p_dcb->local_cfg = p_data->api_dch_echo_test.local_cfg;
- p_dcb->local_mdep_id = BTA_HL_ECHO_TEST_MDEP_ID;
- p_dcb->peer_mdep_id = BTA_HL_ECHO_TEST_MDEP_ID;
- p_dcb->mdl_id =
- bta_hl_allocate_mdl_id(app_idx, mcl_idx, mdl_idx);
- p_dcb->mdl_cfg_idx_included = false;
- p_echo_cfg = BTA_HL_GET_ECHO_CFG_PTR(app_idx);
- p_dcb->max_rx_apdu_size = p_echo_cfg->max_rx_apdu_size;
- p_dcb->max_tx_apdu_size = p_echo_cfg->max_tx_apdu_size;
- p_mcb->echo_test = true;
- p_mcb->echo_mdl_idx = mdl_idx;
- } else {
- status = BTA_HL_STATUS_INVALID_CTRL_PSM;
- }
- } else {
- status = BTA_HL_STATUS_NO_RESOURCE;
- }
- } else {
- status = BTA_HL_STATUS_INVALID_DCH_CFG;
- }
- } else {
- status = BTA_HL_STATUS_NO_RESOURCE;
- }
- } else {
- status = BTA_HL_STATUS_ECHO_TEST_BUSY;
- }
- } else {
- status = BTA_HL_STATUS_NO_CCH;
- }
- } else {
- status = BTA_HL_STATUS_NO_MCL;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_dch_echo_test status=%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_OK:
- if (p_mcb->sdp.num_recs) {
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx,
- BTA_HL_DCH_ECHO_TEST_EVT, p_data);
- } else {
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx,
- BTA_HL_DCH_SDP_INIT_EVT, p_data);
- }
- break;
- case BTA_HL_STATUS_ECHO_TEST_BUSY:
- case BTA_HL_STATUS_NO_RESOURCE:
- case BTA_HL_STATUS_INVALID_DCH_CFG:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- bta_hl_build_echo_test_cfm(&evt_data, p_acb->app_handle,
- p_mcb->mcl_handle, status);
- p_acb->p_cback(BTA_HL_DCH_ECHO_TEST_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_dch_echo_test Null Callback");
- }
- break;
- default:
- APPL_TRACE_ERROR("Status code=%s", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_sdp_query
- *
- * Description Process the API SDP query request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_sdp_query(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb;
- if (bta_hl_find_app_idx_using_handle(p_data->api_sdp_query.app_handle,
- &app_idx)) {
- if (!bta_hl_find_mcl_idx(app_idx, p_data->api_sdp_query.bd_addr,
- &mcl_idx)) {
- if (bta_hl_find_avail_mcl_idx(app_idx, &mcl_idx)) {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- p_mcb->in_use = true;
- p_mcb->bd_addr = p_data->api_sdp_query.bd_addr;
- APPL_TRACE_DEBUG(
- "bta_hl_api_sdp_query p_mcb->app_id %d app_idx %d mcl_idx %d",
- p_mcb->app_id, app_idx, mcl_idx);
- p_mcb->app_id = p_data->api_sdp_query.app_id;
- p_mcb->sdp_oper = BTA_HL_SDP_OP_SDP_QUERY_NEW;
- } else {
- status = BTA_HL_STATUS_NO_RESOURCE;
- }
- } else {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- p_mcb->app_id = p_data->api_sdp_query.app_id;
- if (p_mcb->sdp_oper != BTA_HL_SDP_OP_NONE) {
- status = BTA_HL_STATUS_SDP_NO_RESOURCE;
- } else {
- p_mcb->sdp_oper = BTA_HL_SDP_OP_SDP_QUERY_CURRENT;
- }
- }
- } else {
- status = BTA_HL_STATUS_INVALID_APP_HANDLE;
- }
- if (status == BTA_HL_STATUS_OK) {
- status = bta_hl_init_sdp(p_mcb->sdp_oper, app_idx, mcl_idx, 0xFF);
- if ((status != BTA_HL_STATUS_OK) &&
- (p_mcb->sdp_oper == BTA_HL_SDP_OP_SDP_QUERY_NEW)) {
- memset(p_mcb, 0, sizeof(tBTA_HL_MCL_CB));
- }
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_sdp_query status=%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_NO_RESOURCE:
- case BTA_HL_STATUS_FAIL:
- case BTA_HL_STATUS_SDP_NO_RESOURCE:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- bta_hl_build_sdp_query_cfm(&evt_data, p_data->api_sdp_query.app_id,
- p_data->api_sdp_query.app_handle,
- p_data->api_sdp_query.bd_addr, NULL, status);
- p_acb->p_cback(BTA_HL_SDP_QUERY_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_sdp_query Null Callback");
- }
- break;
- case BTA_HL_STATUS_OK:
- break;
- default:
- APPL_TRACE_ERROR("Status code=%d", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_sdp_query_results
- *
- * Description Process the SDP query results
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_sdp_query_results(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx = p_data->cch_sdp.app_idx;
- uint8_t mcl_idx = p_data->cch_sdp.mcl_idx;
- tBTA_HL_APP_CB* p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- tBTA_HL_MCL_CB* p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- tBTA_HL_SDP* p_sdp = NULL;
- uint16_t event;
- event = p_data->hdr.event;
- if (event == BTA_HL_SDP_QUERY_OK_EVT) {
- // this is freed in btif_hl_proc_sdp_query_cfm
- p_sdp = (tBTA_HL_SDP*)osi_malloc(sizeof(tBTA_HL_SDP));
- memcpy(p_sdp, &p_mcb->sdp, sizeof(tBTA_HL_SDP));
- } else {
- status = BTA_HL_STATUS_SDP_FAIL;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_sdp_query_results status=%s",
- bta_hl_status_code(status));
- }
- #endif
- APPL_TRACE_DEBUG(
- "bta_hl_sdp_query_results p_mcb->app_id %d app_idx %d mcl_idx %d",
- p_mcb->app_id, app_idx, mcl_idx);
- bta_hl_build_sdp_query_cfm(&evt_data, p_mcb->app_id, p_acb->app_handle,
- p_mcb->bd_addr, p_sdp, status);
- p_acb->p_cback(BTA_HL_SDP_QUERY_CFM_EVT, (tBTA_HL*)&evt_data);
- if (p_data->cch_sdp.release_mcl_cb) {
- memset(p_mcb, 0, sizeof(tBTA_HL_MCL_CB));
- } else {
- if (p_mcb->close_pending)
- bta_hl_check_cch_close(app_idx, mcl_idx, p_data, true);
- if (!p_mcb->ctrl_psm) {
- /* Control channel acceptor: do not store the SDP records */
- memset(&p_mcb->sdp, 0, sizeof(tBTA_HL_SDP));
- }
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_delete_mdl
- *
- * Description Process the API DELETE MDL request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_delete_mdl(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb;
- if (bta_hl_find_mcl_idx_using_handle(p_data->api_delete_mdl.mcl_handle,
- &app_idx, &mcl_idx)) {
- if (bta_hl_is_mdl_value_valid(p_data->api_delete_mdl.mdl_id)) {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- if (bta_hl_is_mdl_exsit_in_mcl(app_idx, p_mcb->bd_addr,
- p_data->api_delete_mdl.mdl_id)) {
- p_mcb->delete_mdl.mcl_handle = p_data->api_delete_mdl.mcl_handle;
- p_mcb->delete_mdl.mdl_id = p_data->api_delete_mdl.mdl_id;
- p_mcb->delete_mdl.delete_req_pending = true;
- if (MCA_Delete((tMCA_CL)p_mcb->mcl_handle,
- p_data->api_delete_mdl.mdl_id) != MCA_SUCCESS) {
- status = BTA_HL_STATUS_FAIL;
- memset(&p_mcb->delete_mdl, 0, sizeof(tBTA_HL_DELETE_MDL));
- }
- } else {
- status = BTA_HL_STATUS_NO_MDL_ID_FOUND;
- }
- } else {
- status = BTA_HL_STATUS_INVALID_MDL_ID;
- }
- } else {
- status = BTA_HL_STATUS_INVALID_MCL_HANDLE;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_delete_mdl status=%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_OK:
- break;
- case BTA_HL_STATUS_FAIL:
- case BTA_HL_STATUS_NO_MDL_ID_FOUND:
- case BTA_HL_STATUS_INVALID_MDL_ID:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- bta_hl_build_delete_mdl_cfm(&evt_data, p_acb->app_handle,
- p_data->api_delete_mdl.mcl_handle,
- p_data->api_delete_mdl.mdl_id, status);
- p_acb->p_cback(BTA_HL_DELETE_MDL_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_delete_mdl Null Callback");
- }
- break;
- default:
- APPL_TRACE_ERROR("status code =%d", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_mca_delete_mdl_cfm
- *
- * Description Process the DELETE MDL confirmation event
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_mca_delete_mdl_cfm(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx;
- tMCA_RSP_EVT* p_delete_cfm = &p_data->mca_evt.mca_data.delete_cfm;
- tBTA_HL_MCL_CB* p_mcb;
- bool send_cfm_evt = true;
- tBTA_HL_APP_CB* p_acb;
- if (bta_hl_find_mcl_idx_using_handle(p_data->mca_evt.mcl_handle, &app_idx,
- &mcl_idx)) {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- if (p_mcb->delete_mdl.delete_req_pending) {
- if (p_delete_cfm->rsp_code == MCA_RSP_SUCCESS) {
- if (!bta_hl_delete_mdl_cfg(app_idx, p_mcb->bd_addr,
- p_delete_cfm->mdl_id)) {
- status = BTA_HL_STATUS_FAIL;
- }
- } else {
- status = BTA_HL_STATUS_FAIL;
- }
- memset(&p_mcb->delete_mdl, 0, sizeof(tBTA_HL_DELETE_MDL));
- } else {
- send_cfm_evt = false;
- }
- } else {
- send_cfm_evt = false;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_delete_mdl status=%s",
- bta_hl_status_code(status));
- }
- #endif
- if (send_cfm_evt) {
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- bta_hl_build_delete_mdl_cfm(&evt_data, p_acb->app_handle,
- p_mcb->mcl_handle, p_delete_cfm->mdl_id,
- status);
- p_acb->p_cback(BTA_HL_DELETE_MDL_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_mca_delete_mdl_cfm Null Callback");
- }
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_mca_delete_mdl_ind
- *
- * Description Process the DELETE MDL indication event
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_mca_delete_mdl_ind(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL evt_data;
- uint8_t app_idx, mcl_idx, mdl_idx;
- tMCA_EVT_HDR* p_delete_ind = &p_data->mca_evt.mca_data.delete_ind;
- tBTA_HL_MCL_CB* p_mcb;
- tBTA_HL_MDL_CB* p_dcb;
- bool send_ind_evt = false;
- tBTA_HL_APP_CB* p_acb;
- if (bta_hl_find_mcl_idx_using_handle(p_data->mca_evt.mcl_handle, &app_idx,
- &mcl_idx)) {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- if (bta_hl_find_mdl_idx(app_idx, mcl_idx, p_delete_ind->mdl_id, &mdl_idx)) {
- p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
- p_dcb->dch_oper = BTA_HL_DCH_OP_REMOTE_DELETE;
- }
- if (bta_hl_delete_mdl_cfg(app_idx, p_mcb->bd_addr, p_delete_ind->mdl_id)) {
- send_ind_evt = true;
- }
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (!send_ind_evt) {
- APPL_TRACE_DEBUG("bta_hl_mca_delete_mdl_ind is_send_ind_evt =%d",
- send_ind_evt);
- }
- #endif
- if (send_ind_evt) {
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- evt_data.delete_mdl_ind.mcl_handle = p_mcb->mcl_handle;
- evt_data.delete_mdl_ind.app_handle = p_acb->app_handle;
- evt_data.delete_mdl_ind.mdl_id = p_delete_ind->mdl_id;
- p_acb->p_cback(BTA_HL_DELETE_MDL_IND_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_mca_delete_mdl_ind Null Callback");
- }
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_api_dch_abort
- *
- * Description Process the API DCH abort request
- *
- * Returns void
- *
- ******************************************************************************/
- static void bta_hl_api_dch_abort(UNUSED_ATTR tBTA_HL_CB* p_cb,
- tBTA_HL_DATA* p_data) {
- tBTA_HL_STATUS status = BTA_HL_STATUS_OK;
- uint8_t app_idx, mcl_idx, mdl_idx;
- tBTA_HL_APP_CB* p_acb;
- tBTA_HL_MCL_CB* p_mcb;
- tBTA_HL_MDL_CB* p_dcb;
- tBTA_HL evt_data;
- if (bta_hl_find_mcl_idx_using_handle(p_data->api_dch_abort.mcl_handle,
- &app_idx, &mcl_idx)) {
- if (!bta_hl_find_dch_setup_mdl_idx(app_idx, mcl_idx, &mdl_idx)) {
- status = BTA_HL_STATUS_NO_MDL_ID_FOUND;
- } else {
- p_dcb = BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
- if (p_dcb->abort_oper) {
- /* abort already in progress*/
- status = BTA_HL_STATUS_FAIL;
- } else {
- p_dcb->abort_oper = BTA_HL_ABORT_LOCAL_MASK;
- }
- }
- } else {
- status = BTA_HL_STATUS_INVALID_MCL_HANDLE;
- }
- #if (BTA_HL_DEBUG == TRUE)
- if (status != BTA_HL_STATUS_OK) {
- APPL_TRACE_DEBUG("bta_hl_api_dch_abort status=%s",
- bta_hl_status_code(status));
- }
- #endif
- switch (status) {
- case BTA_HL_STATUS_OK:
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, BTA_HL_DCH_ABORT_EVT,
- p_data);
- break;
- case BTA_HL_STATUS_NO_MDL_ID_FOUND:
- case BTA_HL_STATUS_FAIL:
- p_acb = BTA_HL_GET_APP_CB_PTR(app_idx);
- if (p_acb->p_cback) {
- p_mcb = BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx);
- bta_hl_build_abort_cfm(&evt_data,
- p_acb->app_handle, p_mcb->mcl_handle,
- BTA_HL_STATUS_FAIL);
- p_acb->p_cback(BTA_HL_DCH_ABORT_CFM_EVT, (tBTA_HL*)&evt_data);
- } else {
- APPL_TRACE_ERROR("bta_hl_api_dch_abort Null Callback");
- }
- break;
- default:
- APPL_TRACE_ERROR("Status code=%d", status);
- break;
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_hdl_event
- *
- * Description HL main event handling function.
- *
- * Returns void
- *
- ******************************************************************************/
- bool bta_hl_hdl_event(BT_HDR* p_msg) {
- uint8_t app_idx, mcl_idx, mdl_idx;
- bool success = true;
- #if (BTA_HL_DEBUG == TRUE)
- APPL_TRACE_DEBUG("BTA HL Event Handler: Event [%s]",
- bta_hl_evt_code(p_msg->event));
- #endif
- switch (p_msg->event) {
- case BTA_HL_API_ENABLE_EVT:
- bta_hl_api_enable(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_DISABLE_EVT:
- bta_hl_api_disable(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_UPDATE_EVT:
- bta_hl_api_update(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_REGISTER_EVT:
- bta_hl_api_register(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_DEREGISTER_EVT:
- bta_hl_api_deregister(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_CCH_OPEN_EVT:
- bta_hl_api_cch_open(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_CCH_CLOSE_EVT:
- bta_hl_api_cch_close(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_DCH_OPEN_EVT:
- bta_hl_api_dch_open(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_DCH_CLOSE_EVT:
- bta_hl_api_dch_close(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_DELETE_MDL_EVT:
- bta_hl_api_delete_mdl(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_DCH_RECONNECT_EVT:
- bta_hl_api_dch_reconnect(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_DCH_ECHO_TEST_EVT:
- bta_hl_api_dch_echo_test(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_SDP_QUERY_EVT:
- bta_hl_api_sdp_query(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_MCA_DELETE_CFM_EVT:
- bta_hl_mca_delete_mdl_cfm(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_MCA_DELETE_IND_EVT:
- bta_hl_mca_delete_mdl_ind(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_SDP_QUERY_OK_EVT:
- case BTA_HL_SDP_QUERY_FAIL_EVT:
- bta_hl_sdp_query_results(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- case BTA_HL_API_DCH_ABORT_EVT:
- bta_hl_api_dch_abort(&bta_hl_cb, (tBTA_HL_DATA*)p_msg);
- break;
- default:
- if (p_msg->event < BTA_HL_DCH_EVT_MIN) {
- if (bta_hl_find_cch_cb_indexes((tBTA_HL_DATA*)p_msg, &app_idx,
- &mcl_idx)) {
- bta_hl_cch_sm_execute(app_idx, mcl_idx, p_msg->event,
- (tBTA_HL_DATA*)p_msg);
- } else {
- #if (BTA_HL_DEBUG == TRUE)
- APPL_TRACE_ERROR(
- "unable to find control block indexes for CCH: [event=%s]",
- bta_hl_evt_code(p_msg->event));
- #else
- APPL_TRACE_ERROR(
- "unable to find control block indexes for CCH: [event=%d]",
- p_msg->event);
- #endif
- success = false;
- }
- } else {
- if (bta_hl_find_dch_cb_indexes((tBTA_HL_DATA*)p_msg, &app_idx, &mcl_idx,
- &mdl_idx)) {
- bta_hl_dch_sm_execute(app_idx, mcl_idx, mdl_idx, p_msg->event,
- (tBTA_HL_DATA*)p_msg);
- } else {
- #if (BTA_HL_DEBUG == TRUE)
- APPL_TRACE_ERROR(
- "unable to find control block indexes for DCH : [event=%s]",
- bta_hl_evt_code(p_msg->event));
- #else
- APPL_TRACE_ERROR(
- "unable to find control block indexes for DCH: [event=%d]",
- p_msg->event);
- #endif
- success = false;
- }
- }
- break;
- }
- return (success);
- }
- /*****************************************************************************
- * Debug Functions
- ****************************************************************************/
- #if (BTA_HL_DEBUG == TRUE)
- /*******************************************************************************
- *
- * Function bta_hl_cch_state_code
- *
- * Description Map CCH state code to the corresponding state string
- *
- * Returns string pointer for the associated state name
- *
- ******************************************************************************/
- static const char* bta_hl_cch_state_code(tBTA_HL_CCH_STATE state_code) {
- switch (state_code) {
- case BTA_HL_CCH_IDLE_ST:
- return "BTA_HL_CCH_IDLE_ST";
- case BTA_HL_CCH_OPENING_ST:
- return "BTA_HL_CCH_OPENING_ST";
- case BTA_HL_CCH_OPEN_ST:
- return "BTA_HL_CCH_OPEN_ST";
- case BTA_HL_CCH_CLOSING_ST:
- return "BTA_HL_CCH_CLOSING_ST";
- default:
- return "Unknown CCH state code";
- }
- }
- /*******************************************************************************
- *
- * Function bta_hl_dch_state_code
- *
- * Description Map DCH state code to the corresponding state string
- *
- * Returns string pointer for the associated state name
- *
- ******************************************************************************/
- static const char* bta_hl_dch_state_code(tBTA_HL_DCH_STATE state_code) {
- switch (state_code) {
- case BTA_HL_DCH_IDLE_ST:
- return "BTA_HL_DCH_IDLE_ST";
- case BTA_HL_DCH_OPENING_ST:
- return "BTA_HL_DCH_OPENING_ST";
- case BTA_HL_DCH_OPEN_ST:
- return "BTA_HL_DCH_OPEN_ST";
- case BTA_HL_DCH_CLOSING_ST:
- return "BTA_HL_DCH_CLOSING_ST";
- default:
- return "Unknown DCH state code";
- }
- }
- #endif /* Debug Functions */
- #endif /* HL_INCLUDED */
|