diff options
author | Etan Cohen <etancohen@google.com> | 2015-03-31 10:41:53 -0700 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2015-03-31 10:41:53 -0700 |
commit | e1a9e52ff59d36bd1bb5b7b3a02fafba6394edfe (patch) | |
tree | 0a82ebb8b0be6acf27f7cbf38a44c9f70425e141 /stack | |
parent | dd05445e57161ac40ae8b37252ae9f453bb31e85 (diff) | |
parent | f7f839985b3931682363d2ef3b7c5cae55a842ee (diff) | |
download | android_system_bt-e1a9e52ff59d36bd1bb5b7b3a02fafba6394edfe.tar.gz android_system_bt-e1a9e52ff59d36bd1bb5b7b3a02fafba6394edfe.tar.bz2 android_system_bt-e1a9e52ff59d36bd1bb5b7b3a02fafba6394edfe.zip |
Merge commit 'f7f839985b3931682363d2ef3b7c5cae55a842ee' into merge
Change-Id: Iaaec1ea0bf3009b7e32a9a60f697631a3f56e889
Diffstat (limited to 'stack')
128 files changed, 3406 insertions, 17235 deletions
diff --git a/stack/Android.mk b/stack/Android.mk index 73ffdf8c3..518188e84 100644 --- a/stack/Android.mk +++ b/stack/Android.mk @@ -17,11 +17,15 @@ LOCAL_C_INCLUDES:= . \ $(LOCAL_PATH)/sdp \ $(LOCAL_PATH)/smp \ $(LOCAL_PATH)/srvc \ + $(LOCAL_PATH)/../btcore/include \ $(LOCAL_PATH)/../vnd/include \ $(LOCAL_PATH)/../vnd/ble \ + $(LOCAL_PATH)/../btif/include \ + $(LOCAL_PATH)/../hci/include \ $(LOCAL_PATH)/../include \ $(LOCAL_PATH)/../gki/common \ $(LOCAL_PATH)/../gki/ulinux \ + $(LOCAL_PATH)/../osi/include \ $(LOCAL_PATH)/../udrv/include \ $(LOCAL_PATH)/../rpc/include \ $(LOCAL_PATH)/../hcis \ @@ -29,6 +33,7 @@ LOCAL_C_INCLUDES:= . \ $(LOCAL_PATH)/../bta/include \ $(LOCAL_PATH)/../bta/sys \ $(LOCAL_PATH)/../utils/include \ + $(LOCAL_PATH)/../ \ $(bdroid_C_INCLUDES) \ LOCAL_CFLAGS += $(bdroid_CFLAGS) -std=c99 @@ -144,15 +149,15 @@ LOCAL_SRC_FILES:= \ ./l2cap/l2c_csm.c \ ./l2cap/l2c_link.c \ ./l2cap/l2c_ble.c \ + ./l2cap/l2cap_client.c \ ./gap/gap_api.c \ ./gap/gap_ble.c \ - ./gap/gap_conn.c \ - ./gap/gap_utils.c \ ../vnd/ble/vendor_ble.c LOCAL_MODULE := libbt-brcm_stack LOCAL_MODULE_TAGS := optional LOCAL_MODULE_CLASS := STATIC_LIBRARIES +LOCAL_STATIC_LIBRARIES := libbt-hci LOCAL_SHARED_LIBRARIES := libcutils libc LOCAL_MULTILIB := 32 # gnu-variable-sized-type-not-at-end is needed for a variable-size header in diff --git a/stack/a2dp/a2d_int.h b/stack/a2dp/a2d_int.h index 4aaa08375..84e109b99 100644 --- a/stack/a2dp/a2d_int.h +++ b/stack/a2dp/a2d_int.h @@ -67,14 +67,14 @@ extern "C" ** Main Control Block *******************************************************************************/ #if A2D_DYNAMIC_MEMORY == FALSE -A2D_API extern tA2D_CB a2d_cb; +extern tA2D_CB a2d_cb; #else -A2D_API extern tA2D_CB *a2d_cb_ptr; +extern tA2D_CB *a2d_cb_ptr; #define a2d_cb (*a2d_cb_ptr) #endif /* Used only for conformance testing */ -A2D_API extern void a2d_set_avdt_sdp_ver (UINT16 avdt_sdp_ver); +extern void a2d_set_avdt_sdp_ver (UINT16 avdt_sdp_ver); #ifdef __cplusplus } diff --git a/stack/a2dp/a2d_sbc.c b/stack/a2dp/a2d_sbc.c index 3858b4a21..4b786b453 100644 --- a/stack/a2dp/a2d_sbc.c +++ b/stack/a2dp/a2d_sbc.c @@ -24,14 +24,13 @@ ******************************************************************************/ #include "bt_target.h" + #include <string.h> #include "a2d_api.h" #include "a2d_int.h" #include "a2d_sbc.h" #include "bt_utils.h" -#if (A2D_SBC_INCLUDED == TRUE) - /************************************************************************************************* * SBC descramble code * Purpose: to tie the SBC code with BTE/mobile stack code, @@ -280,14 +279,13 @@ tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, BOOLEAN for_caps) { tA2D_STATUS status; UINT8 losc; - UINT8 mt; if( p_ie == NULL || p_info == NULL) status = A2D_INVALID_PARAMS; else { losc = *p_info++; - mt = *p_info++; + *p_info++; /* If the function is called for the wrong Media Type or Media Codec Type */ if(losc != A2D_SBC_INFO_LEN || *p_info != A2D_MEDIA_CT_SBC) status = A2D_WRONG_CODEC; @@ -399,57 +397,3 @@ void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, BOOLEAN *p_start, BOOLEAN } } -#else /* A2D_SBC_INCLUDED == TRUE */ - -void A2D_SbcChkFrInit(UINT8 *p_pkt) -{ - UNUSED(p_pkt); -} - -void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len) -{ - UNUSED(p_pkt); - UNUSED(len); -} - -tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie, - UINT8 *p_result) -{ - UNUSED(media_type); - UNUSED(p_ie); - UNUSED(p_result); - return A2D_FAIL; -} - -tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, - BOOLEAN for_caps) -{ - UNUSED(p_ie); - UNUSED(p_info); - UNUSED(for_caps); - return A2D_FAIL; -} - -void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start, - BOOLEAN last, UINT8 num) -{ - UNUSED(p_dst); - UNUSED(frag); - UNUSED(start); - UNUSED(last); - UNUSED(num); -} - -void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, - BOOLEAN *p_start, BOOLEAN *p_last, - UINT8 *p_num) -{ - UNUSED(p_src); - UNUSED(p_frag); - UNUSED(p_start); - UNUSED(p_last); - UNUSED(p_num); -} - - -#endif /* A2D_SBC_INCLUDED == TRUE */ diff --git a/stack/avct/avct_api.c b/stack/avct/avct_api.c index 5b27cc879..5ee928228 100644 --- a/stack/avct/avct_api.c +++ b/stack/avct/avct_api.c @@ -23,7 +23,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "gki.h" diff --git a/stack/avct/avct_ccb.c b/stack/avct/avct_ccb.c index f2c821c13..e0f87de6a 100644 --- a/stack/avct/avct_ccb.c +++ b/stack/avct/avct_ccb.c @@ -24,7 +24,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "avct_api.h" #include "avct_int.h" diff --git a/stack/avct/avct_int.h b/stack/avct/avct_int.h index b93c032ce..29300a5cd 100644 --- a/stack/avct/avct_int.h +++ b/stack/avct/avct_int.h @@ -218,9 +218,9 @@ extern "C" /* Main control block */ #if AVCT_DYNAMIC_MEMORY == FALSE -AVCT_API extern tAVCT_CB avct_cb; +extern tAVCT_CB avct_cb; #else -AVCT_API extern tAVCT_CB *avct_cb_ptr; +extern tAVCT_CB *avct_cb_ptr; #define avct_cb (*avct_cb_ptr) #endif @@ -235,5 +235,3 @@ extern const tL2CAP_APPL_INFO avct_l2c_br_appl; #endif #endif /* AVCT_INT_H */ - - diff --git a/stack/avct/avct_l2c.c b/stack/avct/avct_l2c.c index bb01e89b0..815fa4b33 100644 --- a/stack/avct/avct_l2c.c +++ b/stack/avct/avct_l2c.c @@ -23,7 +23,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avct_api.h" diff --git a/stack/avct/avct_lcb.c b/stack/avct/avct_lcb.c index 6c8fd2e74..eabb8aa2b 100644 --- a/stack/avct/avct_lcb.c +++ b/stack/avct/avct_lcb.c @@ -24,7 +24,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avct_api.h" diff --git a/stack/avct/avct_lcb_act.c b/stack/avct/avct_lcb_act.c index 2240d396e..589af0bdf 100644 --- a/stack/avct/avct_lcb_act.c +++ b/stack/avct/avct_lcb_act.c @@ -23,7 +23,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avct_api.h" @@ -636,7 +636,7 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data) pkt_type = AVCT_PKT_TYPE_END; } } - AVCT_TRACE_DEBUG ("avct_lcb_send_msg tx_q_count:%d", p_lcb->tx_q.count); + AVCT_TRACE_DEBUG ("avct_lcb_send_msg tx_q_count:%d", GKI_queue_length(&p_lcb->tx_q)); return; } @@ -692,6 +692,7 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data) /* parse header byte */ AVCT_PRS_HDR(p, label, type, cr_ipid); + UNUSED(type); /* check for invalid cr_ipid */ if (cr_ipid == AVCT_CR_IPID_INVALID) diff --git a/stack/avdt/avdt_ad.c b/stack/avdt/avdt_ad.c index 46868878e..45e6b36e9 100644 --- a/stack/avdt/avdt_ad.c +++ b/stack/avdt/avdt_ad.c @@ -22,8 +22,10 @@ * ******************************************************************************/ +#include <assert.h> #include <string.h> -#include "data_types.h" + +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avdt_api.h" @@ -31,7 +33,6 @@ #include "avdt_int.h" #include "l2c_api.h" #include "l2cdefs.h" -#include "wcassert.h" /******************************************************************************* @@ -245,7 +246,7 @@ tAVDT_TC_TBL *avdt_ad_tc_tbl_by_type(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_ } } - WC_ASSERT(i != AVDT_NUM_TC_TBL); + assert(i != AVDT_NUM_TC_TBL); return p_tbl; } @@ -276,7 +277,7 @@ tAVDT_TC_TBL *avdt_ad_tc_tbl_alloc(tAVDT_CCB *p_ccb) } /* sanity check */ - WC_ASSERT(i != AVDT_NUM_TC_TBL); + assert(i != AVDT_NUM_TC_TBL); /* initialize entry */ p_tbl->peer_mtu = L2CAP_DEFAULT_MTU; diff --git a/stack/avdt/avdt_api.c b/stack/avdt/avdt_api.c index f18c556ec..96bff7545 100644 --- a/stack/avdt/avdt_api.c +++ b/stack/avdt/avdt_api.c @@ -24,7 +24,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "avdt_api.h" #include "avdtc_api.h" @@ -34,10 +34,6 @@ #include "btu.h" -#if (defined BTTRC_INCLUDED && BTTRC_INCLUDED == TRUE) -#include "bttrc_str_ids.h" -#endif - /* Control block for AVDT */ #if AVDT_DYNAMIC_MEMORY == FALSE tAVDT_CB avdt_cb; @@ -112,9 +108,6 @@ void avdt_process_timeout(TIMER_LIST_ENT *p_tle) *******************************************************************************/ void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback) { - - BTTRC_AVDT_API0(AVDT_TRACE_API_REGISTER); - /* register PSM with L2CAP */ L2CA_Register(AVDT_PSM, (tL2CAP_APPL_INFO *) &avdt_l2c_appl); @@ -142,11 +135,6 @@ void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback) avdt_scb_init(); avdt_ccb_init(); avdt_ad_init(); -#if defined(AVDT_INITIAL_TRACE_LEVEL) - avdt_cb.trace_level = AVDT_INITIAL_TRACE_LEVEL; -#else - avdt_cb.trace_level = BT_TRACE_LEVEL_NONE; -#endif /* copy registration struct */ memcpy(&avdt_cb.rcb, p_reg, sizeof(tAVDT_REG)); @@ -168,8 +156,6 @@ void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback) *******************************************************************************/ void AVDT_Deregister(void) { - BTTRC_AVDT_API0(AVDT_TRACE_API_DEREGISTER); - /* deregister PSM with L2CAP */ L2CA_Deregister(AVDT_PSM); } @@ -255,8 +241,6 @@ UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs) UINT16 result = AVDT_SUCCESS; tAVDT_SCB *p_scb; - BTTRC_AVDT_API0(AVDT_TRACE_API_CREATESTREAM); - /* Verify parameters; if invalid, return failure */ if (((p_cs->cfg.psc_mask & (~AVDT_PSC)) != 0) || (p_cs->p_ctrl_cback == NULL)) { @@ -293,9 +277,6 @@ UINT16 AVDT_RemoveStream(UINT8 handle) UINT16 result = AVDT_SUCCESS; tAVDT_SCB *p_scb; - - BTTRC_AVDT_API0(AVDT_TRACE_API_REMOVESTREAM); - /* look up scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -342,8 +323,6 @@ UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info, UINT16 result = AVDT_SUCCESS; tAVDT_CCB_EVT evt; - BTTRC_AVDT_API0(AVDT_TRACE_API_DISCOVER_REQ); - /* find channel control block for this bd addr; if none, allocate one */ if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) { @@ -448,8 +427,6 @@ UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CTRL_ { tAVDT_CCB_API_GETCAP getcap; - BTTRC_AVDT_API1(AVDT_TRACE_API_GETCAP_REQ, BTTRC_PARAM_UINT8, seid); - getcap.single.seid = seid; getcap.single.sig_id = AVDT_SIG_GETCAP; getcap.p_cfg = p_cfg; @@ -485,8 +462,6 @@ UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CT { tAVDT_CCB_API_GETCAP getcap; - BTTRC_AVDT_API1(AVDT_TRACE_API_GET_ALLCAP_REQ, BTTRC_PARAM_UINT8, seid); - getcap.single.seid = seid; getcap.single.sig_id = AVDT_SIG_GET_ALLCAP; getcap.p_cfg = p_cfg; @@ -511,8 +486,6 @@ UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay) UINT16 result = AVDT_SUCCESS; tAVDT_SCB_EVT evt; - BTTRC_AVDT_API0(AVDT_TRACE_API_DELAY_REPORT); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -549,9 +522,6 @@ UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg) UINT16 result = AVDT_SUCCESS; tAVDT_SCB_EVT evt; - BTTRC_AVDT_API0(AVDT_TRACE_API_OPEN_REQ); - - /* verify SEID */ if ((seid < AVDT_SEID_MIN) || (seid > AVDT_SEID_MAX)) { @@ -603,8 +573,6 @@ UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, UINT8 categor UINT16 result = AVDT_SUCCESS; UINT8 event_code; - BTTRC_AVDT_API0(AVDT_TRACE_API_CONFIG_RSP); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -658,8 +626,6 @@ UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles) UINT16 result = AVDT_SUCCESS; int i; - BTTRC_AVDT_API0(AVDT_TRACE_API_START_REQ); - if ((num_handles == 0) || (num_handles > AVDT_NUM_SEPS)) { result = AVDT_BAD_PARAMS; @@ -716,8 +682,6 @@ UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles) UINT16 result = AVDT_SUCCESS; int i; - BTTRC_AVDT_API0(AVDT_TRACE_API_SUSPEND_REQ); - if ((num_handles == 0) || (num_handles > AVDT_NUM_SEPS)) { result = AVDT_BAD_PARAMS; @@ -772,8 +736,6 @@ UINT16 AVDT_CloseReq(UINT8 handle) tAVDT_SCB *p_scb; UINT16 result = AVDT_SUCCESS; - BTTRC_AVDT_API0(AVDT_TRACE_API_CLOSE_REQ); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -810,8 +772,6 @@ UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg) UINT16 result = AVDT_SUCCESS; tAVDT_SCB_EVT evt; - BTTRC_AVDT_API0(AVDT_TRACE_API_RECONFIG_REQ); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -847,8 +807,6 @@ UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, UINT8 categ tAVDT_SCB_EVT evt; UINT16 result = AVDT_SUCCESS; - BTTRC_AVDT_API0(AVDT_TRACE_API_RECONFIG_RSP); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -886,8 +844,6 @@ UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len) UINT16 result = AVDT_SUCCESS; tAVDT_SCB_EVT evt; - BTTRC_AVDT_API0(AVDT_TRACE_API_SECURITY_REQ); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -924,8 +880,6 @@ UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code, UINT16 result = AVDT_SUCCESS; tAVDT_SCB_EVT evt; - BTTRC_AVDT_API0(AVDT_TRACE_API_SECURITY_RSP); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -985,8 +939,6 @@ UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_ tAVDT_SCB_EVT evt; UINT16 result = AVDT_SUCCESS; - BTTRC_AVDT_API0(AVDT_TRACE_API_WRITE_REQ); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -1066,8 +1018,6 @@ UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask, tAVDT_CTRL_CBACK *p_cbac UINT16 result = AVDT_SUCCESS; tAVDT_CCB_EVT evt; - BTTRC_AVDT_API0(AVDT_TRACE_API_CONNECT_REQ); - /* find channel control block for this bd addr; if none, allocate one */ if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) { @@ -1113,9 +1063,6 @@ UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback) UINT16 result = AVDT_SUCCESS; tAVDT_CCB_EVT evt; - BTTRC_AVDT_API0(AVDT_TRACE_API_DISCONNECT_REQ); - - /* find channel control block for this bd addr; if none, error */ if ((p_ccb = avdt_ccb_by_bd(bd_addr)) == NULL) { @@ -1157,8 +1104,6 @@ UINT16 AVDT_GetL2CapChannel(UINT8 handle) lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid; } - BTTRC_AVDT_API1(AVDT_TRACE_API_GET_L2CAP_CHAN, BTTRC_PARAM_UINT16, lcid); - return (lcid); } @@ -1189,8 +1134,6 @@ UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr) lcid = avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid; } - BTTRC_AVDT_API1(AVDT_TRACE_API_GET_SIGNAL_CHAN, BTTRC_PARAM_UINT16, lcid); - return (lcid); } @@ -1216,16 +1159,14 @@ UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr) ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len, - UINT32 time_stamp, UINT8 m_pt, UINT8 marker) +extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len, + UINT32 time_stamp, UINT8 m_pt, UINT8 marker) { tAVDT_SCB *p_scb; tAVDT_SCB_EVT evt; UINT16 result = AVDT_SUCCESS; - BTTRC_AVDT_API1(AVDT_TRACE_API_WRITE_DATA_REQ, BTTRC_PARAM_UINT32, data_len); - do { /* check length of media frame */ @@ -1304,13 +1245,11 @@ AVDT_API extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 dat ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len) +extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len) { tAVDT_SCB *p_scb; UINT16 result = AVDT_SUCCESS; - BTTRC_AVDT_API0(AVDT_TRACE_API_SET_MEDIABUF); - /* map handle to scb */ if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) { @@ -1357,8 +1296,6 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type, UINT32 ssrc; UINT16 len; - BTTRC_AVDT_API0(AVDT_TRACE_API_SEND_REPORT); - /* map handle to scb && verify parameters */ if (((p_scb = avdt_scb_by_hdl(handle)) != NULL) && (p_scb->p_ccb != NULL) @@ -1484,4 +1421,3 @@ UINT8 AVDT_SetTraceLevel (UINT8 new_level) return (avdt_cb.trace_level); } - diff --git a/stack/avdt/avdt_ccb.c b/stack/avdt/avdt_ccb.c index 2a10ef8ab..09ed39af2 100644 --- a/stack/avdt/avdt_ccb.c +++ b/stack/avdt/avdt_ccb.c @@ -24,7 +24,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avdt_api.h" @@ -304,14 +304,12 @@ void avdt_ccb_event(tAVDT_CCB *p_ccb, UINT8 event, tAVDT_CCB_EVT *p_data) #if AVDT_DEBUG == TRUE AVDT_TRACE_EVENT("CCB ccb=%d event=%s state=%s", avdt_ccb_to_idx(p_ccb), avdt_ccb_evt_str[event], avdt_ccb_st_str[p_ccb->state]); #endif - BTTRC_AVDT_CCB_EVENT(event, p_ccb->state); /* look up the state table for the current state */ state_table = avdt_ccb_st_tbl[p_ccb->state]; /* set next state */ if (p_ccb->state != state_table[event][AVDT_CCB_NEXT_STATE]) { - BTTRC_AVDT_CCB_STATE(state_table[event][AVDT_CCB_NEXT_STATE]); p_ccb->state = state_table[event][AVDT_CCB_NEXT_STATE]; } @@ -320,7 +318,6 @@ void avdt_ccb_event(tAVDT_CCB *p_ccb, UINT8 event, tAVDT_CCB_EVT *p_data) { if ((action = state_table[event][i]) != AVDT_CCB_IGNORE) { - BTTRC_AVDT_CCB_ACTION(action); (*avdt_cb.p_ccb_act[action])(p_ccb, p_data); } else diff --git a/stack/avdt/avdt_ccb_act.c b/stack/avdt/avdt_ccb_act.c index d87dbb1cf..b1ef12ebd 100644 --- a/stack/avdt/avdt_ccb_act.c +++ b/stack/avdt/avdt_ccb_act.c @@ -24,7 +24,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avdt_api.h" diff --git a/stack/avdt/avdt_int.h b/stack/avdt/avdt_int.h index e9752c2c2..fb1b31360 100644 --- a/stack/avdt/avdt_int.h +++ b/stack/avdt/avdt_int.h @@ -32,12 +32,8 @@ #include "btm_api.h" #ifndef AVDT_DEBUG -#if (!defined BTTRC_INCLUDED || BTTRC_INCLUDED == FALSE) -#define AVDT_DEBUG TRUE -#else #define AVDT_DEBUG FALSE #endif -#endif /***************************************************************************** ** constants @@ -727,9 +723,9 @@ extern "C" ** Main Control Block *******************************************************************************/ #if AVDT_DYNAMIC_MEMORY == FALSE -AVDT_API extern tAVDT_CB avdt_cb; +extern tAVDT_CB avdt_cb; #else -AVDT_API extern tAVDT_CB *avdt_cb_ptr; +extern tAVDT_CB *avdt_cb_ptr; #define avdt_cb (*avdt_cb_ptr) #endif diff --git a/stack/avdt/avdt_l2c.c b/stack/avdt/avdt_l2c.c index c13b5b4ce..dbdfc082d 100644 --- a/stack/avdt/avdt_l2c.c +++ b/stack/avdt/avdt_l2c.c @@ -23,7 +23,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avdt_api.h" @@ -356,6 +356,8 @@ void avdt_l2c_config_cfm_cback(UINT16 lcid, tL2CAP_CFG_INFO *p_cfg) /* look up info for this channel */ if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) { + p_tbl->lcid = lcid; + /* if in correct state */ if (p_tbl->state == AVDT_AD_ST_CFG) { diff --git a/stack/avdt/avdt_msg.c b/stack/avdt/avdt_msg.c index 2f38c3af6..4a28b0dfc 100644 --- a/stack/avdt/avdt_msg.c +++ b/stack/avdt/avdt_msg.c @@ -27,7 +27,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avdt_api.h" @@ -1719,6 +1719,8 @@ void avdt_msg_ind(tAVDT_CCB *p_ccb, BT_HDR *p_buf) /* parse the message header */ AVDT_MSG_PRS_HDR(p, label, pkt_type, msg_type); + UNUSED(pkt_type); + /* AVDT_TRACE_DEBUG("msg_type=%d", msg_type); */ /* set up label and ccb_idx in message hdr */ msg.hdr.label = label; diff --git a/stack/avdt/avdt_scb.c b/stack/avdt/avdt_scb.c index 8eb5cc211..f5f5b5a79 100644 --- a/stack/avdt/avdt_scb.c +++ b/stack/avdt/avdt_scb.c @@ -24,7 +24,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avdt_api.h" @@ -531,8 +531,6 @@ void avdt_scb_event(tAVDT_SCB *p_scb, UINT8 event, tAVDT_SCB_EVT *p_data) #if AVDT_DEBUG == TRUE AVDT_TRACE_EVENT("SCB hdl=%d event=%d/%s state=%s", avdt_scb_to_hdl(p_scb), event, avdt_scb_evt_str[event], avdt_scb_st_str[p_scb->state]); #endif - BTTRC_AVDT_SCB_EVENT(event, p_scb->state); - /* set current event */ p_scb->curr_evt = event; @@ -541,7 +539,6 @@ void avdt_scb_event(tAVDT_SCB *p_scb, UINT8 event, tAVDT_SCB_EVT *p_data) /* set next state */ if (p_scb->state != state_table[event][AVDT_SCB_NEXT_STATE]) { - BTTRC_AVDT_SCB_STATE(state_table[event][AVDT_SCB_NEXT_STATE]); p_scb->state = state_table[event][AVDT_SCB_NEXT_STATE]; } @@ -550,7 +547,6 @@ void avdt_scb_event(tAVDT_SCB *p_scb, UINT8 event, tAVDT_SCB_EVT *p_data) { if ((action = state_table[event][i]) != AVDT_SCB_IGNORE) { - BTTRC_AVDT_SCB_ACTION(action); (*avdt_cb.p_scb_act[action])(p_scb, p_data); } else @@ -734,41 +730,36 @@ UINT8 avdt_scb_verify(tAVDT_CCB *p_ccb, UINT8 state, UINT8 *p_seid, UINT16 num_s int i; tAVDT_SCB *p_scb; UINT8 nsc_mask; - UINT8 chk_state; UINT8 ret = 0; AVDT_TRACE_DEBUG("avdt_scb_verify state %d", state); /* set nonsupported command mask */ /* translate public state into private state */ nsc_mask = 0; - chk_state = AVDT_SCB_STREAM_ST; - switch(state) - { - case AVDT_VERIFY_SUSPEND: - nsc_mask = AVDT_NSC_SUSPEND; - break; - case AVDT_VERIFY_OPEN: - case AVDT_VERIFY_START: - chk_state = AVDT_SCB_OPEN_ST; - break; - } + if (state == AVDT_VERIFY_SUSPEND) + nsc_mask = AVDT_NSC_SUSPEND; /* verify every scb */ - for (i = 0; i < num_seid; i++) + for (i = 0, *p_err_code = 0; i < num_seid && *p_err_code == 0; i++) { if ((p_scb = avdt_scb_by_hdl(p_seid[i])) == NULL) - { *p_err_code = AVDT_ERR_BAD_STATE; - break; - } - else if ((p_scb->state != chk_state) || (p_scb->p_ccb != p_ccb)) - { + else if (p_scb->p_ccb != p_ccb) *p_err_code = AVDT_ERR_BAD_STATE; - break; - } else if (p_scb->cs.nsc_mask & nsc_mask) - { *p_err_code = AVDT_ERR_NSC; + + switch (state) { + case AVDT_VERIFY_OPEN: + case AVDT_VERIFY_START: + if (p_scb->state != AVDT_SCB_OPEN_ST && p_scb->state != AVDT_SCB_STREAM_ST) + *p_err_code = AVDT_ERR_BAD_STATE; + break; + + case AVDT_VERIFY_SUSPEND: + case AVDT_VERIFY_STREAMING: + if (p_scb->state != AVDT_SCB_STREAM_ST) + *p_err_code = AVDT_ERR_BAD_STATE; break; } } @@ -777,8 +768,7 @@ UINT8 avdt_scb_verify(tAVDT_CCB *p_ccb, UINT8 state, UINT8 *p_seid, UINT16 num_s { ret = p_seid[i]; } - AVDT_TRACE_DEBUG("avdt_scb_verify state %d, nsc_mask0x%x, ret: %d", - chk_state, nsc_mask, ret); + return ret; } diff --git a/stack/avdt/avdt_scb_act.c b/stack/avdt/avdt_scb_act.c index 72dd3cd46..3ab1c2689 100644 --- a/stack/avdt/avdt_scb_act.c +++ b/stack/avdt/avdt_scb_act.c @@ -24,7 +24,7 @@ ******************************************************************************/ #include <string.h> -#include "data_types.h" +#include "bt_types.h" #include "bt_target.h" #include "bt_utils.h" #include "avdt_api.h" @@ -247,7 +247,6 @@ void avdt_scb_hdl_pkt_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) UINT8 marker; UINT16 seq; UINT32 time_stamp; - UINT32 ssrc; UINT16 offset; UINT16 ex_len; UINT8 pad_len = 0; @@ -259,7 +258,9 @@ void avdt_scb_hdl_pkt_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) AVDT_MSG_PRS_M_PT(p, m_pt, marker); BE_STREAM_TO_UINT16(seq, p); BE_STREAM_TO_UINT32(time_stamp, p); - BE_STREAM_TO_UINT32(ssrc, p); + p += 4; + + UNUSED(o_v); /* skip over any csrc's in packet */ p += o_cc * 4; @@ -336,7 +337,6 @@ UINT8 * avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len) UINT8 *p_start = p; UINT32 ssrc; UINT8 o_v, o_p, o_cc; - UINT16 pkt_len; AVDT_REPORT_TYPE pt; tAVDT_REPORT_DATA report, *p_rpt; @@ -347,9 +347,12 @@ UINT8 * avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len) /* parse report packet header */ AVDT_MSG_PRS_RPT_OCTET1(p, o_v, o_p, o_cc); pt = *p++; - BE_STREAM_TO_UINT16(pkt_len, p); + p += 2; BE_STREAM_TO_UINT32(ssrc, p); + UNUSED(o_p); + UNUSED(o_v); + switch(pt) { case AVDT_RTCP_PT_SR: /* the packet type - SR (Sender Report) */ @@ -573,6 +576,9 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) BE_STREAM_TO_UINT32(time_stamp, p_payload); BE_STREAM_TO_UINT32(ssrc, p_payload); + UNUSED(o_v); + UNUSED(ssrc); + /* skip over any csrc's in packet */ p_payload += o_cc * 4; @@ -1421,7 +1427,7 @@ void avdt_scb_snd_stream_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) BT_HDR *p_frag; AVDT_TRACE_WARNING("avdt_scb_snd_stream_close c:%d, off:%d", - p_scb->frag_q.count, p_scb->frag_off); + GKI_queue_length(&p_scb->frag_q), p_scb->frag_off); /* clean fragments queue */ while((p_frag = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL) GKI_freebuf(p_frag); diff --git a/stack/avrc/avrc_api.c b/stack/avrc/avrc_api.c index 04f59a02d..dbebb993e 100644 --- a/stack/avrc/avrc_api.c +++ b/stack/avrc/avrc_api.c @@ -21,12 +21,12 @@ * Interface to AVRCP mandatory commands * ******************************************************************************/ +#include <assert.h> #include <string.h> #include "gki.h" #include "avrc_api.h" #include "avrc_int.h" -#include "wcassert.h" /***************************************************************************** ** Global data @@ -805,8 +805,8 @@ static BT_HDR * avrc_pass_msg(tAVRC_MSG_PASS *p_msg) BT_HDR *p_cmd = NULL; UINT8 *p_data; - WC_ASSERT(p_msg != NULL); - WC_ASSERT(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->pass_len)); + assert(p_msg != NULL); + assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->pass_len)); if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) { @@ -1084,7 +1084,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt) UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg) { BT_HDR *p_buf; - WC_ASSERT(p_msg != NULL); + assert(p_msg != NULL); if (p_msg) { p_msg->hdr.ctype = AVRC_CMD_CTRL; @@ -1123,7 +1123,7 @@ UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg) UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg) { BT_HDR *p_buf; - WC_ASSERT(p_msg != NULL); + assert(p_msg != NULL); if (p_msg) { p_buf = avrc_pass_msg(p_msg); diff --git a/stack/avrc/avrc_int.h b/stack/avrc/avrc_int.h index 33eebdc46..36bb0c5fa 100644 --- a/stack/avrc/avrc_int.h +++ b/stack/avrc/avrc_int.h @@ -138,9 +138,9 @@ extern "C" ** Main Control Block *******************************************************************************/ #if AVRC_DYNAMIC_MEMORY == FALSE -AVRC_API extern tAVRC_CB avrc_cb; +extern tAVRC_CB avrc_cb; #else -AVRC_API extern tAVRC_CB *avrc_cb_ptr; +extern tAVRC_CB *avrc_cb_ptr; #define avrc_cb (*avrc_cb_ptr) #endif @@ -156,4 +156,3 @@ extern BOOLEAN avrc_is_valid_opcode(UINT8 opcode); #endif #endif /* AVRC_INT_H */ - diff --git a/stack/avrc/avrc_opt.c b/stack/avrc/avrc_opt.c index ff791557a..28a3f1afc 100644 --- a/stack/avrc/avrc_opt.c +++ b/stack/avrc/avrc_opt.c @@ -21,15 +21,13 @@ * Interface to AVRCP optional commands * ******************************************************************************/ +#include <assert.h> #include <string.h> #include "gki.h" #include "avrc_api.h" #include "avrc_int.h" -#include "wcassert.h" - - /****************************************************************************** ** ** Function avrc_vendor_msg @@ -51,13 +49,13 @@ static BT_HDR * avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg) BT_HDR *p_cmd; UINT8 *p_data; - WC_ASSERT(p_msg != NULL); + assert(p_msg != NULL); #if AVRC_METADATA_INCLUDED == TRUE - WC_ASSERT(AVRC_META_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len)); + assert(AVRC_META_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len)); if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_META_CMD_POOL_ID)) != NULL) #else - WC_ASSERT(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len)); + assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len)); if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) #endif { diff --git a/stack/bnep/bnep_api.c b/stack/bnep/bnep_api.c index b1d8c7c2d..76bffca50 100644 --- a/stack/bnep/bnep_api.c +++ b/stack/bnep/bnep_api.c @@ -83,7 +83,6 @@ tBNEP_RESULT BNEP_Register (tBNEP_REGISTER *p_reg_info) return BNEP_SECURITY_FAIL; bnep_cb.profile_registered = TRUE; - BTM_GetLocalDeviceAddr (bnep_cb.my_bda); return BNEP_SUCCESS; } @@ -151,11 +150,6 @@ tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda, if (src_uuid->len != dst_uuid->len) return BNEP_CONN_FAILED_UUID_SIZE; -#if (!defined (BNEP_SUPPORTS_ALL_UUID_LENGTHS) || BNEP_SUPPORTS_ALL_UUID_LENGTHS == FALSE) - if (src_uuid->len != 2) - return BNEP_CONN_FAILED_UUID_SIZE; -#endif - if (!p_bcb) { if ((p_bcb = bnepu_allocate_bcb (p_rem_bda)) == NULL) @@ -432,7 +426,7 @@ tBNEP_RESULT BNEP_WriteBuf (UINT16 handle, } /* Check transmit queue */ - if (p_bcb->xmit_q.count >= BNEP_MAX_XMITQ_DEPTH) + if (GKI_queue_length(&p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH) { GKI_freebuf (p_buf); return (BNEP_Q_SIZE_EXCEEDED); @@ -538,7 +532,7 @@ tBNEP_RESULT BNEP_Write (UINT16 handle, } /* Check transmit queue */ - if (p_bcb->xmit_q.count >= BNEP_MAX_XMITQ_DEPTH) + if (GKI_queue_length(&p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH) return (BNEP_Q_SIZE_EXCEEDED); /* Get a buffer to copy teh data into */ @@ -586,7 +580,6 @@ tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle, UINT16 *p_start_array, UINT16 *p_end_array) { -#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE) UINT16 xx; tBNEP_CONN *p_bcb; @@ -619,9 +612,6 @@ tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle, bnepu_send_peer_our_filters (p_bcb); return (BNEP_SUCCESS); -#else - return (BNEP_SET_FILTER_FAIL); -#endif } @@ -649,7 +639,6 @@ tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle, UINT8 *p_start_array, UINT8 *p_end_array) { -#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE) UINT16 xx; tBNEP_CONN *p_bcb; @@ -685,28 +674,6 @@ tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle, bnepu_send_peer_our_multi_filters (p_bcb); return (BNEP_SUCCESS); -#else - return (BNEP_SET_FILTER_FAIL); -#endif -} - - -/******************************************************************************* -** -** Function BNEP_GetMyBdAddr -** -** Description This function returns a pointer to the local device BD address. -** If the BD address has not been read yet, it returns NULL. -** -** Returns the BD address -** -*******************************************************************************/ -UINT8 *BNEP_GetMyBdAddr (void) -{ - if (bnep_cb.got_my_bd_addr) - return (bnep_cb.my_bda); - else - return (NULL); } /******************************************************************************* @@ -762,7 +729,7 @@ tBNEP_RESULT BNEP_GetStatus (UINT16 handle, tBNEP_STATUS *p_status) p_status->con_status = BNEP_STATUS_CONNECTED; p_status->l2cap_cid = p_bcb->l2cap_cid; p_status->rem_mtu_size = p_bcb->rem_mtu_size; - p_status->xmit_q_depth = p_bcb->xmit_q.count; + p_status->xmit_q_depth = GKI_queue_length(&p_bcb->xmit_q); p_status->sent_num_filters = p_bcb->sent_num_filters; p_status->sent_mcast_filters = p_bcb->sent_mcast_filters; p_status->rcvd_num_filters = p_bcb->rcvd_num_filters; diff --git a/stack/bnep/bnep_int.h b/stack/bnep/bnep_int.h index 0c435efc7..5322e5039 100644 --- a/stack/bnep/bnep_int.h +++ b/stack/bnep/bnep_int.h @@ -183,8 +183,6 @@ typedef struct TIMER_LIST_ENT bnep_tle; BOOLEAN profile_registered; /* TRUE when we got our BD addr */ UINT8 trace_level; - BOOLEAN got_my_bd_addr; /* TRUE when we got our BD addr */ - BD_ADDR my_bda; /* BD Address of this device */ } tBNEP_CB; @@ -195,9 +193,9 @@ extern "C" { /* Global BNEP data */ #if BNEP_DYNAMIC_MEMORY == FALSE -BNEP_API extern tBNEP_CB bnep_cb; +extern tBNEP_CB bnep_cb; #else -BNEP_API extern tBNEP_CB *bnep_cb_ptr; +extern tBNEP_CB *bnep_cb_ptr; #define bnep_cb (*bnep_cb_ptr) #endif @@ -241,7 +239,6 @@ extern void bnep_sec_check_complete (BD_ADDR bd_addr, tBT_TRANSPORT trasn extern tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb, BD_ADDR p_dest_addr, UINT16 protocol, BOOLEAN fw_ext_present, UINT8 *p_data); extern UINT32 bnep_get_uuid32 (tBT_UUID *src_uuid); -extern void bnep_dump_status (void); @@ -251,4 +248,3 @@ extern void bnep_dump_status (void); #endif - diff --git a/stack/bnep/bnep_main.c b/stack/bnep/bnep_main.c index 62fa31635..b29884075 100644 --- a/stack/bnep/bnep_main.c +++ b/stack/bnep/bnep_main.c @@ -43,6 +43,8 @@ #include "bnep_int.h" #include "bt_utils.h" +#include "device/include/controller.h" + /********************************************************************************/ /* G L O B A L B N E P D A T A */ @@ -65,8 +67,6 @@ static void bnep_disconnect_cfm (UINT16 l2cap_cid, UINT16 result); static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg); static void bnep_congestion_ind (UINT16 lcid, BOOLEAN is_congested); -static void bnep_read_addr_cb (void *p_bda); - /******************************************************************************* ** @@ -508,12 +508,11 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf) ** with unknown control extension headers then those should be processed ** according to complain/ignore law */ - UINT8 ext, length, *p_data; + UINT8 ext, length; UINT16 org_len, new_len; /* parse the extension headers and process unknown control headers */ org_len = rem_len; new_len = 0; - p_data = p; do { ext = *p++; @@ -639,7 +638,7 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf) p_src_addr = (UINT8 *) p_bcb->rem_bda; if (!p_dst_addr) - p_dst_addr = (UINT8 *) bnep_cb.my_bda; + p_dst_addr = (UINT8 *) controller_get_interface()->get_address(); /* check whether there are any extensions to be forwarded */ if (ext_type) @@ -677,13 +676,6 @@ void bnep_process_timeout (TIMER_LIST_ENT *p_tle) if (!p_tle->param) { - if (!bnep_cb.got_my_bd_addr) - { - if (BTM_IsDeviceUp()) - BTM_ReadLocalDeviceAddr (bnep_read_addr_cb); - - btu_start_timer (&bnep_cb.bnep_tle, BTU_TTYPE_BNEP, 2); - } return; } @@ -734,7 +726,6 @@ void bnep_process_timeout (TIMER_LIST_ENT *p_tle) bnepu_release_bcb (p_bcb); } -#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE) else if (p_bcb->con_flags & BNEP_FLAGS_FILTER_RESP_PEND) { if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS) @@ -754,8 +745,6 @@ void bnep_process_timeout (TIMER_LIST_ENT *p_tle) return; } } -#endif -#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE) else if (p_bcb->con_flags & BNEP_FLAGS_MULTI_RESP_PEND) { if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS) @@ -775,7 +764,6 @@ void bnep_process_timeout (TIMER_LIST_ENT *p_tle) return; } } -#endif } @@ -810,31 +798,3 @@ void bnep_connected (tBNEP_CONN *p_bcb) if (bnep_cb.p_conn_state_cb) (*bnep_cb.p_conn_state_cb) (p_bcb->handle, p_bcb->rem_bda, BNEP_SUCCESS, is_role_change); } - - -/******************************************************************************* -** -** Function bnep_read_addr_cb -** -** Description This function is called by BTM when the local BD address -** is read. It saves the BD address, and flags it as read. -** -** Returns void -** -*******************************************************************************/ -static void bnep_read_addr_cb (void *p_bda) -{ - UINT8 *bda = (UINT8 *)p_bda; - if (p_bda && - (bda[0] | bda[1] | bda[2] | bda[3] | bda[4] | bda[5]) != 0) - { - /* Save my BD address */ - memcpy (bnep_cb.my_bda, p_bda, BD_ADDR_LEN); - - bnep_cb.got_my_bd_addr = TRUE; - } - else - /* Retry after a couple seconds */ - btu_start_timer (&bnep_cb.bnep_tle, BTU_TTYPE_BNEP, 2); -} - diff --git a/stack/bnep/bnep_utils.c b/stack/bnep/bnep_utils.c index 92061d010..8c76b0028 100644 --- a/stack/bnep/bnep_utils.c +++ b/stack/bnep/bnep_utils.c @@ -30,6 +30,7 @@ #include "btu.h" #include "btm_int.h" #include "bt_utils.h" +#include "device/include/controller.h" /********************************************************************************/ @@ -152,7 +153,7 @@ void bnepu_release_bcb (tBNEP_CONN *p_bcb) p_bcb->p_pending_data = NULL; /* Free transmit queue */ - while (p_bcb->xmit_q.count) + while (!GKI_queue_is_empty(&p_bcb->xmit_q)) { GKI_freebuf (GKI_dequeue (&p_bcb->xmit_q)); } @@ -196,7 +197,6 @@ void bnep_send_conn_req (tBNEP_CONN *p_bcb) UINT16_TO_BE_STREAM (p, p_bcb->dst_uuid.uu.uuid16); UINT16_TO_BE_STREAM (p, p_bcb->src_uuid.uu.uuid16); } -#if (defined (BNEP_SUPPORTS_ALL_UUID_LENGTHS) && BNEP_SUPPORTS_ALL_UUID_LENGTHS == TRUE) else if (p_bcb->dst_uuid.len == 4) { UINT32_TO_BE_STREAM (p, p_bcb->dst_uuid.uu.uuid32); @@ -209,7 +209,6 @@ void bnep_send_conn_req (tBNEP_CONN *p_bcb) memcpy (p, p_bcb->src_uuid.uu.uuid128, p_bcb->dst_uuid.len); p += p_bcb->dst_uuid.len; } -#endif p_buf->len = (UINT16)(p - p_start); @@ -267,7 +266,6 @@ void bnep_send_conn_responce (tBNEP_CONN *p_bcb, UINT16 resp_code) *******************************************************************************/ void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb) { -#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE) BT_HDR *p_buf; UINT8 *p; UINT16 xx; @@ -304,7 +302,6 @@ void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb) /* Start timer waiting for setup response */ btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT); -#endif } @@ -319,7 +316,6 @@ void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb) *******************************************************************************/ void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb) { -#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE) BT_HDR *p_buf; UINT8 *p; UINT16 xx; @@ -358,7 +354,6 @@ void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb) /* Start timer waiting for setup response */ btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT); -#endif } @@ -455,7 +450,7 @@ void bnepu_check_send_packet (tBNEP_CONN *p_bcb, BT_HDR *p_buf) BNEP_TRACE_EVENT ("BNEP - bnepu_check_send_packet for CID: 0x%x", p_bcb->l2cap_cid); if (p_bcb->con_flags & BNEP_FLAGS_L2CAP_CONGESTED) { - if (p_bcb->xmit_q.count >= BNEP_MAX_XMITQ_DEPTH) + if (GKI_queue_length(&p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH) { BNEP_TRACE_EVENT ("BNEP - congested, dropping buf, CID: 0x%x", p_bcb->l2cap_cid); @@ -487,19 +482,20 @@ void bnepu_check_send_packet (tBNEP_CONN *p_bcb, BT_HDR *p_buf) void bnepu_build_bnep_hdr (tBNEP_CONN *p_bcb, BT_HDR *p_buf, UINT16 protocol, UINT8 *p_src_addr, UINT8 *p_dest_addr, BOOLEAN fw_ext_present) { + const controller_t *controller = controller_get_interface(); UINT8 ext_bit, *p = (UINT8 *)NULL; UINT8 type = BNEP_FRAME_COMPRESSED_ETHERNET; ext_bit = fw_ext_present ? 0x80 : 0x00; - if ((p_src_addr) && (memcmp (p_src_addr, bnep_cb.my_bda, BD_ADDR_LEN))) + if ((p_src_addr) && (memcmp (p_src_addr, &controller->get_address()->address, BD_ADDR_LEN))) type = BNEP_FRAME_COMPRESSED_ETHERNET_SRC_ONLY; if (memcmp (p_dest_addr, p_bcb->rem_bda, BD_ADDR_LEN)) type = (type == BNEP_FRAME_COMPRESSED_ETHERNET) ? BNEP_FRAME_COMPRESSED_ETHERNET_DEST_ONLY : BNEP_FRAME_GENERAL_ETHERNET; if (!p_src_addr) - p_src_addr = (UINT8 *)bnep_cb.my_bda; + p_src_addr = (UINT8 *)controller->get_address(); switch (type) { @@ -635,7 +631,6 @@ void bnep_process_setup_conn_req (tBNEP_CONN *p_bcb, UINT8 *p_setup, UINT8 len) return; } } -#if (defined (BNEP_SUPPORTS_ALL_UUID_LENGTHS) && BNEP_SUPPORTS_ALL_UUID_LENGTHS == TRUE) else if (p_bcb->dst_uuid.len == 4) { BE_STREAM_TO_UINT32 (p_bcb->src_uuid.uu.uuid32, p_setup); @@ -648,7 +643,6 @@ void bnep_process_setup_conn_req (tBNEP_CONN *p_bcb, UINT8 *p_setup, UINT8 len) memcpy (p_bcb->dst_uuid.uu.uuid128, p_setup, p_bcb->dst_uuid.len); p_setup += p_bcb->dst_uuid.len; } -#endif else { BNEP_TRACE_ERROR ("BNEP - Bad UID len %d in ConnReq", p_bcb->dst_uuid.len); @@ -900,7 +894,6 @@ UINT8 *bnep_process_control_packet (tBNEP_CONN *p_bcb, UINT8 *p, UINT16 *rem_len *******************************************************************************/ void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 len) { -#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE) UINT16 num_filters = 0; UINT16 xx, resp_code = BNEP_FILTER_CRL_OK; UINT16 start, end; @@ -964,9 +957,6 @@ void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 } bnepu_send_peer_filter_rsp (p_bcb, resp_code); -#else - bnepu_send_peer_filter_rsp (p_bcb, BNEP_FILTER_CRL_UNSUPPORTED); -#endif } @@ -982,7 +972,6 @@ void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 *******************************************************************************/ void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data) { -#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE) UINT16 resp_code; tBNEP_RESULT result; @@ -1015,13 +1004,8 @@ void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data) if (bnep_cb.p_filter_ind_cb) (*bnep_cb.p_filter_ind_cb) (p_bcb->handle, FALSE, result, 0, NULL); - - return; -#endif } - - /******************************************************************************* ** ** Function bnepu_process_multicast_filter_rsp @@ -1034,7 +1018,6 @@ void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data) *******************************************************************************/ void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data) { -#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE) UINT16 resp_code; tBNEP_RESULT result; @@ -1067,13 +1050,8 @@ void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data) if (bnep_cb.p_mfilter_ind_cb) (*bnep_cb.p_mfilter_ind_cb) (p_bcb->handle, FALSE, result, 0, NULL); - - return; -#endif } - - /******************************************************************************* ** ** Function bnepu_process_peer_multicast_filter_set @@ -1087,7 +1065,6 @@ void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data) *******************************************************************************/ void bnepu_process_peer_multicast_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 len) { -#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE) UINT16 resp_code = BNEP_FILTER_CRL_OK; UINT16 num_filters, xx; UINT8 *p_temp_filters, null_bda[BD_ADDR_LEN] = {0,0,0,0,0,0}; @@ -1154,9 +1131,6 @@ void bnepu_process_peer_multicast_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filter if (bnep_cb.p_mfilter_ind_cb) (*bnep_cb.p_mfilter_ind_cb) (p_bcb->handle, TRUE, 0, len, p_filters); -#else - bnepu_send_peer_multicast_filter_rsp (p_bcb, BNEP_FILTER_CRL_UNSUPPORTED); -#endif } @@ -1319,7 +1293,6 @@ tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb, BOOLEAN fw_ext_present, UINT8 *p_data) { -#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE) if (p_bcb->rcvd_num_filters) { UINT16 i, proto; @@ -1357,9 +1330,7 @@ tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb, return BNEP_IGNORE_CMD; } } -#endif -#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE) /* Ckeck for multicast address filtering */ if ((p_dest_addr[0] & 0x01) && p_bcb->rcvd_mcast_filters) @@ -1390,15 +1361,10 @@ tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb, return BNEP_IGNORE_CMD; } } -#endif return BNEP_SUCCESS; } - - - - /******************************************************************************* ** ** Function bnep_get_uuid32 @@ -1423,45 +1389,3 @@ UINT32 bnep_get_uuid32 (tBT_UUID *src_uuid) return result; } } - - - - -/******************************************************************************* -** -** Function bnep_dump_status -** -** Description This function dumps the bnep control block and connection -** blocks information -** -** Returns none -** -*******************************************************************************/ -void bnep_dump_status (void) -{ -#if (defined (BNEP_SUPPORTS_DEBUG_DUMP) && BNEP_SUPPORTS_DEBUG_DUMP == TRUE) - UINT16 i; - char buff[200]; - tBNEP_CONN *p_bcb; - - BNEP_TRACE_DEBUG ("BNEP my BD Addr %x.%x.%x.%x.%x.%x", - bnep_cb.my_bda[0], bnep_cb.my_bda[1], bnep_cb.my_bda[2], - bnep_cb.my_bda[3], bnep_cb.my_bda[4], bnep_cb.my_bda[5]); - BNEP_TRACE_DEBUG ("profile registered %d, trace %d, got_my_bd_addr %d", - bnep_cb.profile_registered, bnep_cb.trace_level, bnep_cb.got_my_bd_addr); - - for (i = 0, p_bcb = bnep_cb.bcb; i < BNEP_MAX_CONNECTIONS; i++, p_bcb++) - { - sprintf (buff, "%d state %d, flags 0x%x, cid %d, pfilts %d, mfilts %d, src 0x%x, dst 0x%x, BD %x.%x.%x.%x.%x.%x", - i, p_bcb->con_state, p_bcb->con_flags, p_bcb->l2cap_cid, - p_bcb->rcvd_num_filters, p_bcb->rcvd_mcast_filters, - p_bcb->src_uuid.uu.uuid16, p_bcb->dst_uuid.uu.uuid16, - p_bcb->rem_bda[0], p_bcb->rem_bda[1], p_bcb->rem_bda[2], - p_bcb->rem_bda[3], p_bcb->rem_bda[4], p_bcb->rem_bda[5]); - - BNEP_TRACE_DEBUG (buff); - } -#endif -} - - diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.c index 9b2c99040..ba3e94b49 100644 --- a/stack/btm/btm_acl.c +++ b/stack/btm/btm_acl.c @@ -30,6 +30,7 @@ #include "bt_types.h" #include "bt_target.h" +#include "device/include/controller.h" #include "gki.h" #include "hcimsgs.h" #include "btu.h" @@ -37,7 +38,6 @@ #include "btm_int.h" #include "l2c_int.h" #include "hcidefs.h" -#include "bd.h" #include "bt_utils.h" static void btm_read_remote_features (UINT16 handle); @@ -62,15 +62,9 @@ void btm_acl_init (void) BTM_TRACE_DEBUG ("btm_acl_init"); #if 0 /* cleared in btm_init; put back in if called from anywhere else! */ memset (&btm_cb.acl_db, 0, sizeof (btm_cb.acl_db)); -#if RFCOMM_INCLUDED == TRUE memset (btm_cb.btm_scn, 0, BTM_MAX_SCN); /* Initialize the SCN usage to FALSE */ -#endif btm_cb.btm_def_link_policy = 0; -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) btm_cb.p_bl_changed_cb = NULL; -#else - btm_cb.p_acl_changed_cb = NULL; -#endif #endif /* Initialize nonzero defaults */ @@ -254,18 +248,13 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, #endif { p->conn_addr_type = BLE_ADDR_PUBLIC; - BTM_GetLocalDeviceAddr(p->conn_addr); + memcpy(p->conn_addr, controller_get_interface()->get_address()->address, BD_ADDR_LEN); } } #endif - p->restore_pkt_types = 0; /* Only exists while SCO is active */ p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE; -#if BTM_PWR_MGR_INCLUDED == FALSE - p->mode = BTM_ACL_MODE_NORMAL; -#else btm_pm_sm_alloc(xx); -#endif /* BTM_PWR_MGR_INCLUDED == FALSE */ memcpy (p->remote_addr, bda, BD_ADDR_LEN); @@ -325,7 +314,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, &p->active_remote_addr_type); #endif - if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features) + if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) || link_role == HCI_ROLE_MASTER) { btsnd_hcic_ble_read_remote_feat(p->hci_handle); @@ -387,13 +376,10 @@ void btm_acl_report_role_change (UINT8 hci_status, BD_ADDR bda) void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport) { tACL_CONN *p; -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) tBTM_BL_EVENT_DATA evt_data; -#endif #if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE) tBTM_SEC_DEV_REC *p_dev_rec=NULL; #endif - BTM_TRACE_DEBUG ("btm_acl_removed"); p = btm_bda_to_acl(bda, transport); if (p != (tACL_CONN *)NULL) @@ -409,7 +395,6 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport) p->link_up_issued = FALSE; /* If anyone cares, tell him database changed */ -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) if (btm_cb.p_bl_changed_cb) { evt_data.event = BTM_BL_DISCN_EVT; @@ -422,14 +407,6 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport) } btm_acl_update_busy_level (BTM_BLI_ACL_DOWN_EVT); -#else - if (btm_cb.p_acl_changed_cb) -#if BLE_INCLUDED == TRUE - (*btm_cb.p_acl_changed_cb) (bda, NULL, NULL, NULL, FALSE, p->hci_handle, p->transport); -#else - (*btm_cb.p_acl_changed_cb) (bda, NULL, NULL, NULL, FALSE); -#endif -#endif } #if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE) @@ -503,7 +480,6 @@ void btm_acl_device_down (void) } } -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) /******************************************************************************* ** ** Function btm_acl_update_busy_level @@ -524,18 +500,9 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event) { case BTM_BLI_ACL_UP_EVT: BTM_TRACE_DEBUG ("BTM_BLI_ACL_UP_EVT"); - btm_cb.num_acl++; break; case BTM_BLI_ACL_DOWN_EVT: - if (btm_cb.num_acl) - { - btm_cb.num_acl--; - BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT", btm_cb.num_acl); - } - else - { - BTM_TRACE_ERROR ("BTM_BLI_ACL_DOWN_EVT issued, but num_acl already zero !!!"); - } + BTM_TRACE_DEBUG ("BTM_BLI_ACL_DOWN_EVT"); break; case BTM_BLI_PAGE_EVT: BTM_TRACE_DEBUG ("BTM_BLI_PAGE_EVT"); @@ -567,7 +534,7 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event) if (btm_cb.is_paging || btm_cb.is_inquiry) busy_level = 10; else - busy_level = (UINT8)btm_cb.num_acl; + busy_level = BTM_GetNumAclLinks(); if ((busy_level != btm_cb.busy_level) ||(old_inquiry_state != btm_cb.is_inquiry)) { @@ -580,8 +547,6 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event) } } } -#endif - /******************************************************************************* ** @@ -634,11 +599,9 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, UINT8 new_role, tBTM_CMPL_CB #if BTM_SCO_INCLUDED == TRUE BOOLEAN is_sco_active; #endif -#if BTM_PWR_MGR_INCLUDED == TRUE tBTM_STATUS status; tBTM_PM_MODE pwr_mode; tBTM_PM_PWR_MD settings; -#endif #if (BT_USE_TRACES == TRUE) BD_ADDR_PTR p_bda; #endif @@ -647,7 +610,7 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, UINT8 new_role, tBTM_CMPL_CB remote_bd_addr[3], remote_bd_addr[4], remote_bd_addr[5]); /* Make sure the local device supports switching */ - if (!(HCI_SWITCH_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))) + if (!controller_get_interface()->supports_master_slave_role_switch()) return(BTM_MODE_UNSUPPORTED); if (btm_cb.devcb.p_switch_role_cb && p_cb) @@ -684,24 +647,6 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, UINT8 new_role, tBTM_CMPL_CB return(BTM_BUSY); } - /* Cannot switch role while parked or sniffing */ -#if BTM_PWR_MGR_INCLUDED == FALSE - if (p->mode == HCI_MODE_PARK) - { - if (!btsnd_hcic_exit_park_mode (p->hci_handle)) - return(BTM_NO_RESOURCES); - - p->switch_role_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE; - } - else if (p->mode == HCI_MODE_SNIFF) - { - if (!btsnd_hcic_exit_sniff_mode (p->hci_handle)) - return(BTM_NO_RESOURCES); - - p->switch_role_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE; - } -#else /* power manager is in use */ - if ((status = BTM_ReadPowerMode(p->remote_addr, &pwr_mode)) != BTM_SUCCESS) return(status); @@ -716,7 +661,6 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, UINT8 new_role, tBTM_CMPL_CB p->switch_role_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE; } -#endif /* some devices do not support switch while encryption is on */ else { @@ -765,163 +709,6 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, UINT8 new_role, tBTM_CMPL_CB /******************************************************************************* ** -** Function BTM_ChangeLinkKey -** -** Description This function is called to change the link key of the -** connection. -** -** Returns BTM_CMD_STARTED if command issued to controller. -** BTM_NO_RESOURCES if couldn't allocate memory to issue command -** BTM_UNKNOWN_ADDR if no active link with bd addr specified -** BTM_BUSY if the previous command is not completed -** -*******************************************************************************/ -tBTM_STATUS BTM_ChangeLinkKey (BD_ADDR remote_bd_addr, tBTM_CMPL_CB *p_cb) -{ - tACL_CONN *p; - tBTM_SEC_DEV_REC *p_dev_rec = NULL; -#if BTM_PWR_MGR_INCLUDED == TRUE - tBTM_STATUS status; - tBTM_PM_MODE pwr_mode; - tBTM_PM_PWR_MD settings; -#endif - BTM_TRACE_DEBUG ("BTM_ChangeLinkKey"); - if ((p = btm_bda_to_acl(remote_bd_addr, BT_TRANSPORT_BR_EDR)) == NULL) - return(BTM_UNKNOWN_ADDR); - - /* Ignore change link key request if the previsous request has not completed */ - if (p->change_key_state != BTM_ACL_SWKEY_STATE_IDLE) - { - BTM_TRACE_DEBUG ("Link key change request declined since the previous request" - " for this device has not completed "); - return(BTM_BUSY); - } - - memset (&btm_cb.devcb.chg_link_key_ref_data, 0, sizeof(tBTM_CHANGE_KEY_CMPL)); - - /* Cannot change key while parked */ -#if BTM_PWR_MGR_INCLUDED == FALSE - if (p->mode == HCI_MODE_PARK) - { - if (!btsnd_hcic_exit_park_mode (p->hci_handle)) - return(BTM_NO_RESOURCES); - - p->change_key_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE; - } -#else /* power manager is in use */ - - - if ((status = BTM_ReadPowerMode(p->remote_addr, &pwr_mode)) != BTM_SUCCESS) - return(status); - - /* Wake up the link if in park before attempting to change link keys */ - if (pwr_mode == BTM_PM_MD_PARK) - { - memset( (void*)&settings, 0, sizeof(settings)); - settings.mode = BTM_PM_MD_ACTIVE; - status = BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p->remote_addr, &settings); - if (status != BTM_CMD_STARTED) - return(BTM_WRONG_MODE); - - p->change_key_state = BTM_ACL_SWKEY_STATE_MODE_CHANGE; - } -#endif - /* some devices do not support change of link key while encryption is on */ - else if (((p_dev_rec = btm_find_dev (remote_bd_addr)) != NULL) - && ((p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED) != 0) && !BTM_EPR_AVAILABLE(p)) - { - /* bypass turning off encryption if switch role is already doing it */ - if (p->encrypt_state != BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF) - { - if (!btsnd_hcic_set_conn_encrypt (p->hci_handle, FALSE)) - return(BTM_NO_RESOURCES); - else - p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF; - } - - p->change_key_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF; - } - else /* Ok to initiate change of link key */ - { - if (!btsnd_hcic_change_link_key (p->hci_handle)) - return(BTM_NO_RESOURCES); - - p->change_key_state = BTM_ACL_SWKEY_STATE_IN_PROGRESS; - } - - /* Initialize return structure in case request fails */ - memcpy (btm_cb.devcb.chg_link_key_ref_data.remote_bd_addr, remote_bd_addr, - BD_ADDR_LEN); - btm_cb.devcb.p_chg_link_key_cb = p_cb; - return(BTM_CMD_STARTED); -} - -/******************************************************************************* -** -** Function btm_acl_link_key_change -** -** Description This function is called to when a change link key event -** is received. -** -*******************************************************************************/ -void btm_acl_link_key_change (UINT16 handle, UINT8 status) -{ - tBTM_CHANGE_KEY_CMPL *p_data; - tACL_CONN *p; - UINT8 xx; - BTM_TRACE_DEBUG ("btm_acl_link_key_change"); - /* Look up the connection by handle and set the current mode */ - xx = btm_handle_to_acl_index(handle); - - /* don't assume that we can never get a bad hci_handle */ - if (xx >= MAX_L2CAP_LINKS) - return; - - p_data = &btm_cb.devcb.chg_link_key_ref_data; - p = &btm_cb.acl_db[xx]; - p_data->hci_status = status; - - /* if switching state is switching we need to turn encryption on */ - /* if idle, we did not change encryption */ - if (p->change_key_state == BTM_ACL_SWKEY_STATE_SWITCHING) - { - /* Make sure there's not also a role switch going on before re-enabling */ - if (p->switch_role_state != BTM_ACL_SWKEY_STATE_SWITCHING) - { - if (btsnd_hcic_set_conn_encrypt (p->hci_handle, TRUE)) - { - p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON; - p->change_key_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON; - return; - } - } - else /* Set the state and wait for change link key */ - { - p->change_key_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON; - return; - } - } - - /* Set the switch_role_state to IDLE since the reply received from HCI */ - /* regardless of its result either success or failed. */ - if (p->change_key_state == BTM_ACL_SWKEY_STATE_IN_PROGRESS) - { - p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE; - p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE; - } - - if (btm_cb.devcb.p_chg_link_key_cb) - { - (*btm_cb.devcb.p_chg_link_key_cb)((void *)p_data); - btm_cb.devcb.p_chg_link_key_cb = NULL; - } - - BTM_TRACE_ERROR("Change Link Key Complete Event: Handle 0x%02x, HCI Status 0x%02x", - handle, p_data->hci_status); -} - -/******************************************************************************* -** ** Function btm_acl_encrypt_change ** ** Description This function is when encryption of the connection is @@ -937,9 +724,7 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) tACL_CONN *p; UINT8 xx; tBTM_SEC_DEV_REC *p_dev_rec; -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) tBTM_BL_ROLE_CHG_DATA evt; -#endif BTM_TRACE_DEBUG ("btm_acl_encrypt_change handle=%d status=%d encr_enabl=%d", handle, status, encr_enable); @@ -987,7 +772,6 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE; btm_acl_report_role_change(btm_cb.devcb.switch_role_ref_data.hci_status, p->remote_addr); -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) /* if role change event is registered, report it now */ if (btm_cb.p_bl_changed_cb && (btm_cb.bl_evt_mask & BTM_BL_ROLE_CHG_MASK)) { @@ -1000,7 +784,6 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) BTM_TRACE_DEBUG("Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d", evt.new_role, evt.hci_status, p->switch_role_state); } -#endif #if BTM_DISC_DURING_RS == TRUE /* If a disconnect is pending, issue it now that role switch has completed */ @@ -1017,45 +800,6 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) } #endif } - - - /* Process Change Link Key if active */ - if (p->change_key_state == BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF) - { - /* if encryption turn off failed we still will try to change link key */ - if (encr_enable) - { - p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE; - p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE; - } - else - { - p->encrypt_state = BTM_ACL_ENCRYPT_STATE_TEMP_FUNC; - p->change_key_state = BTM_ACL_SWKEY_STATE_SWITCHING; - } - - if (!btsnd_hcic_change_link_key (p->hci_handle)) - { - p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE; - p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE; - if (btm_cb.devcb.p_chg_link_key_cb) - { - (*btm_cb.devcb.p_chg_link_key_cb)(&btm_cb.devcb.chg_link_key_ref_data); - btm_cb.devcb.p_chg_link_key_cb = NULL; - } - } - } - /* Finished enabling Encryption after changing link key */ - else if (p->change_key_state == BTM_ACL_SWKEY_STATE_ENCRYPTION_ON) - { - p->encrypt_state = BTM_ACL_ENCRYPT_STATE_IDLE; - p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE; - if (btm_cb.devcb.p_chg_link_key_cb) - { - (*btm_cb.devcb.p_chg_link_key_cb)(&btm_cb.devcb.chg_link_key_ref_data); - btm_cb.devcb.p_chg_link_key_cb = NULL; - } - } } /******************************************************************************* ** @@ -1149,104 +893,6 @@ void BTM_SetDefaultLinkPolicy (UINT16 settings) btsnd_hcic_write_def_policy_set(settings); } - -/******************************************************************************* -** -** Function BTM_ReadLinkPolicy -** -** Description This function is called to read the link policy settings. -** The address of link policy results are returned in the callback. -** (tBTM_LNK_POLICY_RESULTS) -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_ReadLinkPolicy (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb) -{ - tACL_CONN *p; - - BTM_TRACE_API ("BTM_ReadLinkPolicy: RemBdAddr: %02x%02x%02x%02x%02x%02x", - remote_bda[0], remote_bda[1], remote_bda[2], - remote_bda[3], remote_bda[4], remote_bda[5]); - - /* If someone already waiting on the version, do not allow another */ - if (btm_cb.devcb.p_rlinkp_cmpl_cb) - return(BTM_BUSY); - - p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR); - if (p != (tACL_CONN *)NULL) - { - btu_start_timer (&btm_cb.devcb.rlinkp_timer, BTU_TTYPE_BTM_ACL, BTM_DEV_REPLY_TIMEOUT); - btm_cb.devcb.p_rlinkp_cmpl_cb = p_cb; - - if (!btsnd_hcic_read_policy_set (p->hci_handle)) - { - btu_stop_timer (&btm_cb.devcb.rlinkp_timer); - btm_cb.devcb.p_rlinkp_cmpl_cb = NULL; - return(BTM_NO_RESOURCES); - } - - return(BTM_CMD_STARTED); - } - - /* If here, no BD Addr found */ - return(BTM_UNKNOWN_ADDR); -} - - -/******************************************************************************* -** -** Function btm_read_link_policy_complete -** -** Description This function is called when the command complete message -** is received from the HCI for the read local link policy request. -** -** Returns void -** -*******************************************************************************/ -void btm_read_link_policy_complete (UINT8 *p) -{ - tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rlinkp_cmpl_cb; - tBTM_LNK_POLICY_RESULTS lnkpol; - UINT16 handle; - tACL_CONN *p_acl_cb = &btm_cb.acl_db[0]; - UINT16 index; - BTM_TRACE_DEBUG ("btm_read_link_policy_complete"); - btu_stop_timer (&btm_cb.devcb.rlinkp_timer); - - /* If there was a callback address for read local version, call it */ - btm_cb.devcb.p_rlinkp_cmpl_cb = NULL; - - if (p_cb) - { - STREAM_TO_UINT8 (lnkpol.hci_status, p); - - if (lnkpol.hci_status == HCI_SUCCESS) - { - lnkpol.status = BTM_SUCCESS; - - STREAM_TO_UINT16 (handle, p); - - STREAM_TO_UINT16 (lnkpol.settings, p); - - /* Search through the list of active channels for the correct BD Addr */ - for (index = 0; index < MAX_L2CAP_LINKS; index++, p_acl_cb++) - { - if ((p_acl_cb->in_use) && (handle == p_acl_cb->hci_handle)) - { - memcpy (lnkpol.rem_bda, p_acl_cb->remote_addr, BD_ADDR_LEN); - break; - } - } - } - else - lnkpol.status = BTM_ERR_PROCESSING; - - (*p_cb)(&lnkpol); - } -} - - /******************************************************************************* ** ** Function btm_read_remote_version_complete @@ -1333,11 +979,8 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages) void btm_process_remote_ext_features_page (tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec, UINT8 page_idx) { - UINT16 handle; UINT8 req_pend; - handle = p_acl_cb->hci_handle; - memcpy (p_dev_rec->features[page_idx], p_acl_cb->peer_lmp_features[page_idx], HCI_FEATURE_BYTES_PER_PAGE); @@ -1486,7 +1129,7 @@ void btm_read_remote_features_complete (UINT8 *p) HCI_FEATURE_BYTES_PER_PAGE); if ((HCI_LMP_EXTENDED_SUPPORTED(p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) && - (HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(btm_cb.devcb.supported_cmds))) + (controller_get_interface()->supports_reading_remote_extended_features())) { /* if the remote controller has extended features and local controller supports ** HCI_Read_Remote_Extended_Features command then start reading these feature starting @@ -1517,13 +1160,13 @@ void btm_read_remote_features_complete (UINT8 *p) void btm_read_remote_ext_features_complete (UINT8 *p) { tACL_CONN *p_acl_cb; - UINT8 status, page_num, max_page; + UINT8 page_num, max_page; UINT16 handle; UINT8 acl_idx; BTM_TRACE_DEBUG ("btm_read_remote_ext_features_complete"); - STREAM_TO_UINT8 (status, p); + ++p; STREAM_TO_UINT16 (handle, p); STREAM_TO_UINT8 (page_num, p); STREAM_TO_UINT8 (max_page, p); @@ -1611,9 +1254,7 @@ void btm_read_remote_ext_features_failed (UINT8 status, UINT16 handle) *******************************************************************************/ void btm_establish_continue (tACL_CONN *p_acl_cb) { -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) tBTM_BL_EVENT_DATA evt_data; -#endif BTM_TRACE_DEBUG ("btm_establish_continue"); #if (!defined(BTM_BYPASS_EXTRA_ACL_SETUP) || BTM_BYPASS_EXTRA_ACL_SETUP == FALSE) #if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE) @@ -1632,7 +1273,6 @@ void btm_establish_continue (tACL_CONN *p_acl_cb) p_acl_cb->link_up_issued = TRUE; /* If anyone cares, tell him database changed */ -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) if (btm_cb.p_bl_changed_cb) { evt_data.event = BTM_BL_CONN_EVT; @@ -1648,26 +1288,6 @@ void btm_establish_continue (tACL_CONN *p_acl_cb) (*btm_cb.p_bl_changed_cb)(&evt_data); } btm_acl_update_busy_level (BTM_BLI_ACL_UP_EVT); -#else - if (btm_cb.p_acl_changed_cb) -#if BLE_INCLUDED == TRUE - (*btm_cb.p_acl_changed_cb) (p_acl_cb->remote_addr, - p_acl_cb->remote_dc, - p_acl_cb->remote_name, - p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0], - TRUE, - p_acl_cb->hci_handle, - p_acl_cb->transport); -#else - (*btm_cb.p_acl_changed_cb) (p_acl_cb->remote_addr, - p_acl_cb->remote_dc, - p_acl_cb->remote_name, - p_acl_cb->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0], - TRUE); -#endif - -#endif - } @@ -1748,351 +1368,6 @@ tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda, UINT16 timeout) /******************************************************************************* ** -** Function BTM_RegForLstoEvt -** -** Description register for the HCI "Link Supervision Timeout Change" event -** -** Returns void -** -*******************************************************************************/ -void BTM_RegForLstoEvt (tBTM_LSTO_CBACK *p_cback) -{ - BTM_TRACE_DEBUG ("BTM_RegForLstoEvt"); - btm_cb.p_lsto_cback = p_cback; -} - -/******************************************************************************* -** -** Function btm_proc_lsto_evt -** -** Description process the HCI "Link Supervision Timeout Change" event -** -** Returns void -** -*******************************************************************************/ -void btm_proc_lsto_evt(UINT16 handle, UINT16 timeout) -{ - UINT8 xx; - - BTM_TRACE_DEBUG ("btm_proc_lsto_evt"); - if (btm_cb.p_lsto_cback) - { - /* Look up the connection by handle and set the current mode */ - xx = btm_handle_to_acl_index(handle); - - /* don't assume that we can never get a bad hci_handle */ - if (xx < MAX_L2CAP_LINKS) - { - (*btm_cb.p_lsto_cback)(btm_cb.acl_db[xx].remote_addr, timeout); - } - } -} - -#if BTM_PWR_MGR_INCLUDED == FALSE -/******************************************************************************* -** -** Function BTM_SetHoldMode -** -** Description This function is called to set a connection into hold mode. -** A check is made if the connection is in sniff or park mode, -** and if yes, the hold mode is ignored. -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_SetHoldMode (BD_ADDR remote_bda, UINT16 min_interval, UINT16 max_interval) -{ - tACL_CONN *p; - - BTM_TRACE_DEBUG ("BTM_SetHoldMode"); - /* First, check if hold mode is supported */ - if (!HCI_HOLD_MODE_SUPPORTED(BTM_ReadLocalFeatures())) - return(BTM_MODE_UNSUPPORTED); - - p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR); - if (p != (tACL_CONN *)NULL) - { - /* If the connection is in park or sniff mode, forget about holding it */ - if (p->mode != BTM_ACL_MODE_NORMAL) - return(BTM_SUCCESS); - - if (!btsnd_hcic_hold_mode (p->hci_handle, max_interval, min_interval)) - return(BTM_NO_RESOURCES); - - return(BTM_CMD_STARTED); - } - - /* If here, no BD Addr found */ - return(BTM_UNKNOWN_ADDR); -} - - -/******************************************************************************* -** -** Function BTM_SetSniffMode -** -** Description This function is called to set a connection into sniff mode. -** A check is made if the connection is already in sniff or park -** mode, and if yes, the sniff mode is ignored. -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_SetSniffMode (BD_ADDR remote_bda, UINT16 min_period, UINT16 max_period, - UINT16 attempt, UINT16 timeout) -{ - tACL_CONN *p; - BTM_TRACE_DEBUG ("BTM_SetSniffMode"); - /* First, check if sniff mode is supported */ - if (!HCI_SNIFF_MODE_SUPPORTED(BTM_ReadLocalFeatures())) - return(BTM_MODE_UNSUPPORTED); - - p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR); - if (p != (tACL_CONN *)NULL) - { - /* If the connection is in park mode, forget about sniffing it */ - if (p->mode != BTM_ACL_MODE_NORMAL) - return(BTM_WRONG_MODE); - - if (!btsnd_hcic_sniff_mode (p->hci_handle, max_period, - min_period, attempt, timeout)) - return(BTM_NO_RESOURCES); - - return(BTM_CMD_STARTED); - } - - /* If here, no BD Addr found */ - return(BTM_UNKNOWN_ADDR); -} - - - - -/******************************************************************************* -** -** Function BTM_CancelSniffMode -** -** Description This function is called to put a connection out of sniff mode. -** A check is made if the connection is already in sniff mode, -** and if not, the cancel sniff mode is ignored. -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_CancelSniffMode (BD_ADDR remote_bda) -{ - tACL_CONN *p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR); - BTM_TRACE_DEBUG ("BTM_CancelSniffMode "); - if (p == (tACL_CONN *)NULL) - return(BTM_UNKNOWN_ADDR); - - /* If the connection is not in sniff mode, cannot cancel */ - if (p->mode != BTM_ACL_MODE_SNIFF) - return(BTM_WRONG_MODE); - - if (!btsnd_hcic_exit_sniff_mode (p->hci_handle)) - return(BTM_NO_RESOURCES); - - return(BTM_CMD_STARTED); -} - - -/******************************************************************************* -** -** Function BTM_SetParkMode -** -** Description This function is called to set a connection into park mode. -** A check is made if the connection is already in sniff or park -** mode, and if yes, the park mode is ignored. -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_SetParkMode (BD_ADDR remote_bda, UINT16 beacon_min_period, UINT16 beacon_max_period) -{ - tACL_CONN *p; - - BTM_TRACE_DEBUG ("BTM_SetParkMode"); - /* First, check if park mode is supported */ - if (!HCI_PARK_MODE_SUPPORTED(BTM_ReadLocalFeatures())) - return(BTM_MODE_UNSUPPORTED); - - p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR); - if (p != (tACL_CONN *)NULL) - { - /* If the connection is in sniff mode, forget about parking it */ - if (p->mode != BTM_ACL_MODE_NORMAL) - return(BTM_WRONG_MODE); - - /* no park mode if SCO exists -- CR#1982, 1.1 errata 1124 - command status event should be returned /w error code 0x0C "Command Disallowed" - Let LM do this. - */ - if (!btsnd_hcic_park_mode (p->hci_handle, - beacon_max_period, beacon_min_period)) - return(BTM_NO_RESOURCES); - - return(BTM_CMD_STARTED); - } - - /* If here, no BD Addr found */ - return(BTM_UNKNOWN_ADDR); -} - -/******************************************************************************* -** -** Function BTM_CancelParkMode -** -** Description This function is called to put a connection out of park mode. -** A check is made if the connection is already in park mode, -** and if not, the cancel sniff mode is ignored. -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_CancelParkMode (BD_ADDR remote_bda) -{ - tACL_CONN *p; - - BTM_TRACE_DEBUG ("BTM_CancelParkMode"); - p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR); - if (p != (tACL_CONN *)NULL) - { - /* If the connection is not in park mode, cannot cancel */ - if (p->mode != BTM_ACL_MODE_PARK) - return(BTM_WRONG_MODE); - - if (!btsnd_hcic_exit_park_mode (p->hci_handle)) - return(BTM_NO_RESOURCES); - - return(BTM_CMD_STARTED); - } - - /* If here, no BD Addr found */ - return(BTM_UNKNOWN_ADDR); -} -#endif /* BTM_PWR_MGR_INCLUDED == FALSE */ - - -/******************************************************************************* -** -** Function BTM_SetPacketTypes -** -** Description This function is set the packet types used for a specific -** ACL connection, -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_SetPacketTypes (BD_ADDR remote_bda, UINT16 pkt_types) -{ - tACL_CONN *p; - BTM_TRACE_DEBUG ("BTM_SetPacketTypes"); - - if ((p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR)) != NULL) - return(btm_set_packet_types (p, pkt_types)); - - /* If here, no BD Addr found */ - return(BTM_UNKNOWN_ADDR); -} - - -/******************************************************************************* -** -** Function BTM_ReadPacketTypes -** -** Description This function is set the packet types used for a specific -** ACL connection, -** -** Returns packet types supported for the connection, or 0 if no BD address -** -*******************************************************************************/ -UINT16 BTM_ReadPacketTypes (BD_ADDR remote_bda) -{ - tACL_CONN *p; - - BTM_TRACE_DEBUG ("BTM_ReadPacketTypes"); - p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR); - if (p != (tACL_CONN *)NULL) - { - return(p->pkt_types_mask); - } - - /* If here, no BD Addr found */ - return(0); -} - - -/******************************************************************************* -** -** Function BTM_ReadAclMode -** -** Description This returns the current mode for a specific -** ACL connection. -** -** Input Param remote_bda - device address of desired ACL connection -** -** Output Param p_mode - address where the current mode is copied into. -** BTM_ACL_MODE_NORMAL -** BTM_ACL_MODE_HOLD -** BTM_ACL_MODE_SNIFF -** BTM_ACL_MODE_PARK -** (valid only if return code is BTM_SUCCESS) -** -** Returns BTM_SUCCESS if successful, -** BTM_UNKNOWN_ADDR if bd addr is not active or bad -** -*******************************************************************************/ -#if BTM_PWR_MGR_INCLUDED == FALSE -tBTM_STATUS BTM_ReadAclMode (BD_ADDR remote_bda, UINT8 *p_mode) -{ - tACL_CONN *p; - - BTM_TRACE_API ("BTM_ReadAclMode: RemBdAddr: %02x%02x%02x%02x%02x%02x", - remote_bda[0], remote_bda[1], remote_bda[2], - remote_bda[3], remote_bda[4], remote_bda[5]); - - p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR); - if (p != (tACL_CONN *)NULL) - { - *p_mode = p->mode; - return(BTM_SUCCESS); - } - - /* If here, no BD Addr found */ - return(BTM_UNKNOWN_ADDR); -} -#endif /* BTM_PWR_MGR_INCLUDED == FALSE */ - -/******************************************************************************* -** -** Function BTM_ReadClockOffset -** -** Description This returns the clock offset for a specific -** ACL connection. -** -** Input Param remote_bda - device address of desired ACL connection -** -** Returns clock-offset or 0 if unknown -** -*******************************************************************************/ -UINT16 BTM_ReadClockOffset (BD_ADDR remote_bda) -{ - tACL_CONN *p; - - BTM_TRACE_API ("BTM_ReadClockOffset: RemBdAddr: %02x%02x%02x%02x%02x%02x", - remote_bda[0], remote_bda[1], remote_bda[2], - remote_bda[3], remote_bda[4], remote_bda[5]); - - if ( (p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_BR_EDR)) != NULL) - return(p->clock_offset); - - /* If here, no BD Addr found */ - return(0); -} - -/******************************************************************************* -** ** Function BTM_IsAclConnectionUp ** ** Description This function is called to check if an ACL connection exists @@ -2131,48 +1406,15 @@ BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport) *******************************************************************************/ UINT16 BTM_GetNumAclLinks (void) { -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) - return(UINT16)btm_cb.num_acl; -#else - tACL_CONN *p = &btm_cb.acl_db[0]; - UINT16 xx, yy; - BTM_TRACE_DEBUG ("BTM_GetNumAclLinks"); - for (xx = yy = 0; xx < MAX_L2CAP_LINKS; xx++, p++) - { - if (p->in_use) - yy++; - } - - return(yy); -#endif -} - -/******************************************************************************* -** -** Function BTM_GetNumLeLinks -** -** Description This function is called to count the number of -** LE ACL links that are active. -** -** Returns UINT16 Number of active LE links -** -*******************************************************************************/ -UINT16 BTM_GetNumLeLinks (void) -{ - UINT16 yy = 0; + uint16_t num_acl = 0; -#if BLE_INCLUDED == TRUE - tACL_CONN *p = &btm_cb.acl_db[0]; - UINT16 xx; - BTM_TRACE_DEBUG ("BTM_GetNumLeLinks"); - for (xx = yy = 0; xx < MAX_L2CAP_LINKS; xx++, p++) + for (uint16_t i = 0; i < MAX_L2CAP_LINKS; ++i) { - if ((p->in_use) &&(p->transport == BT_TRANSPORT_LE)) - yy++; + if (btm_cb.acl_db[i].in_use) + ++num_acl; } -#endif - return(yy); + return num_acl; } /******************************************************************************* @@ -2217,49 +1459,6 @@ UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport) return(0xFFFF); } -#if BTM_PWR_MGR_INCLUDED == FALSE -/******************************************************************************* -** -** Function btm_process_mode_change -** -** Description This function is called when an HCI mode change event occurs. -** -** Input Parms hci_status - status of the event (HCI_SUCCESS if no errors) -** hci_handle - connection handle associated with the change -** mode - HCI_MODE_ACTIVE, HCI_MODE_HOLD, HCI_MODE_SNIFF, or HCI_MODE_PARK -** interval - number of baseband slots (meaning depends on mode) -** -** Returns void -** -*******************************************************************************/ -void btm_process_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, UINT16 interval) -{ - tACL_CONN *p; - UINT8 xx; - BTM_TRACE_DEBUG ("btm_process_mode_change"); - if (hci_status != HCI_SUCCESS) - { - BTM_TRACE_WARNING ("BTM: HCI Mode Change Error Status: 0x%02x", hci_status); - } - - /* Look up the connection by handle and set the current mode */ - xx = btm_handle_to_acl_index(hci_handle); - - /* don't assume that we can never get a bad hci_handle */ - if (xx >= MAX_L2CAP_LINKS) - return; - - p = &btm_cb.acl_db[xx]; - - /* If status is not success mode does not mean anything */ - if (hci_status == HCI_SUCCESS) - p->mode = mode; - - /* If mode change was because of an active role switch or change link key */ - btm_cont_rswitch_or_chglinkkey(p, btm_find_dev(p->remote_addr), hci_status); -} -#endif /* BTM_PWR_MGR_INCLUDED == FALSE */ - /******************************************************************************* ** ** Function btm_process_clk_off_comp_evt @@ -2300,9 +1499,7 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role) tACL_CONN *p = btm_bda_to_acl(p_bda, BT_TRANSPORT_BR_EDR); tBTM_ROLE_SWITCH_CMPL *p_data = &btm_cb.devcb.switch_role_ref_data; tBTM_SEC_DEV_REC *p_dev_rec; -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) tBTM_BL_ROLE_CHG_DATA evt; -#endif BTM_TRACE_DEBUG ("btm_acl_role_changed"); /* Ignore any stray events */ @@ -2343,18 +1540,9 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role) /* if idle, we did not change encryption */ if (p->switch_role_state == BTM_ACL_SWKEY_STATE_SWITCHING) { - /* Make sure there's not also a change link key going on before re-enabling */ - if (p->change_key_state != BTM_ACL_SWKEY_STATE_SWITCHING) - { - if (btsnd_hcic_set_conn_encrypt (p->hci_handle, TRUE)) - { - p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON; - p->switch_role_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON; - return; - } - } - else /* Set the state and wait for change link key */ + if (btsnd_hcic_set_conn_encrypt (p->hci_handle, TRUE)) { + p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON; p->switch_role_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_ON; return; } @@ -2371,7 +1559,6 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role) /* if role switch complete is needed, report it now */ btm_acl_report_role_change(hci_status, bd_addr); -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) /* if role change event is registered, report it now */ if (btm_cb.p_bl_changed_cb && (btm_cb.bl_evt_mask & BTM_BL_ROLE_CHG_MASK)) { @@ -2384,7 +1571,6 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role) BTM_TRACE_DEBUG("Role Switch Event: new_role 0x%02x, HCI Status 0x%02x, rs_st:%d", p_data->role, p_data->hci_status, p->switch_role_state); -#endif #if BTM_DISC_DURING_RS == TRUE /* If a disconnect is pending, issue it now that role switch has completed */ @@ -2404,7 +1590,6 @@ void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role) } -#if (RFCOMM_INCLUDED==TRUE) /******************************************************************************* ** ** Function BTM_AllocateSCN @@ -2482,51 +1667,6 @@ BOOLEAN BTM_FreeSCN(UINT8 scn) return(FALSE); /* Illegal SCN passed in */ } -#else - -/* Make dummy functions for the RPC to link against */ -UINT8 BTM_AllocateSCN(void) -{ - return(0); -} - -BOOLEAN BTM_FreeSCN(UINT8 scn) -{ - return(FALSE); -} - -#endif - - -/******************************************************************************* -** -** Function btm_acl_timeout -** -** Description This function is called when a timer list entry expires. -** -** Returns void -** -*******************************************************************************/ -void btm_acl_timeout (TIMER_LIST_ENT *p_tle) -{ - UINT32 timer_type = p_tle->param; - - BTM_TRACE_DEBUG ("btm_acl_timeout"); - if (timer_type == TT_DEV_RLNKP) - { - tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rlinkp_cmpl_cb; - tBTM_LNK_POLICY_RESULTS lnkpol; - - lnkpol.status = BTM_ERR_PROCESSING; - lnkpol.settings = 0; - - btm_cb.devcb.p_rlinkp_cmpl_cb = NULL; - - if (p_cb) - (*p_cb)(&lnkpol); - } -} - /******************************************************************************* ** ** Function btm_set_packet_types @@ -2547,15 +1687,8 @@ tBTM_STATUS btm_set_packet_types (tACL_CONN *p, UINT16 pkt_types) btm_cb.btm_acl_pkt_types_supported); /* OR in any exception packet types if at least 2.0 version of spec */ - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) - { - temp_pkt_types |= ((pkt_types & BTM_ACL_EXCEPTION_PKTS_MASK) | - (btm_cb.btm_acl_pkt_types_supported & BTM_ACL_EXCEPTION_PKTS_MASK)); - } - else - { - temp_pkt_types &= (~BTM_ACL_EXCEPTION_PKTS_MASK); - } + temp_pkt_types |= ((pkt_types & BTM_ACL_EXCEPTION_PKTS_MASK) | + (btm_cb.btm_acl_pkt_types_supported & BTM_ACL_EXCEPTION_PKTS_MASK)); /* Exclude packet types not supported by the peer */ btm_acl_chk_peer_pkt_type_support (p, &temp_pkt_types); @@ -2593,7 +1726,7 @@ UINT16 btm_get_max_packet_size (BD_ADDR addr) else { /* Special case for when info for the local device is requested */ - if (memcmp (btm_cb.devcb.local_addr, addr, BD_ADDR_LEN) == 0) + if (memcmp (controller_get_interface()->get_address(), addr, BD_ADDR_LEN) == 0) { pkt_types = btm_cb.btm_acl_pkt_types_supported; } @@ -2750,7 +1883,6 @@ UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr) ** Returns BTM_SUCCESS if successfully registered, otherwise error ** *******************************************************************************/ -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level, tBTM_BL_EVENT_MASK evt_mask) { @@ -2769,28 +1901,6 @@ tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level, return(BTM_SUCCESS); } -#else -/******************************************************************************* -** -** Function BTM_AclRegisterForChanges -** -** Returns This function is called to register a callback for when the -** ACL database changes, i.e. new entry or entry deleted. -** -*******************************************************************************/ -tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb) -{ - BTM_TRACE_DEBUG ("BTM_AclRegisterForChanges"); - if (!p_cb) - btm_cb.p_acl_changed_cb = NULL; - else if (btm_cb.p_acl_changed_cb) - return(BTM_BUSY); - else - btm_cb.p_acl_changed_cb = p_cb; - - return(BTM_SUCCESS); -} -#endif /******************************************************************************* ** @@ -3264,25 +2374,23 @@ UINT8 BTM_SetTraceLevel (UINT8 new_level) /******************************************************************************* ** -** Function btm_cont_rswitch_or_chglinkkey +** Function btm_cont_rswitch ** ** Description This function is called to continue processing an active -** role switch or change of link key procedure. It first -** disables encryption if enabled and EPR is not supported +** role switch. It first disables encryption if enabled and +** EPR is not supported ** ** Returns void ** *******************************************************************************/ -void btm_cont_rswitch_or_chglinkkey (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec, +void btm_cont_rswitch (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec, UINT8 hci_status) { BOOLEAN sw_ok = TRUE; - BOOLEAN chlk_ok = TRUE; - BTM_TRACE_DEBUG ("btm_cont_rswitch_or_chglinkkey "); + BTM_TRACE_DEBUG ("btm_cont_rswitch"); /* Check to see if encryption needs to be turned off if pending change of link key or role switch */ - if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE || - p->change_key_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE) + if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE) { /* Must turn off Encryption first if necessary */ /* Some devices do not support switch or change of link key while encryption is on */ @@ -3294,18 +2402,12 @@ void btm_cont_rswitch_or_chglinkkey (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec, p->encrypt_state = BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF; if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE) p->switch_role_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF; - - if (p->change_key_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE) - p->change_key_state = BTM_ACL_SWKEY_STATE_ENCRYPTION_OFF; } else { /* Error occurred; set states back to Idle */ if (p->switch_role_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE) sw_ok = FALSE; - - if (p->change_key_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE) - chlk_ok = FALSE; } } else /* Encryption not used or EPR supported, continue with switch @@ -3320,12 +2422,6 @@ void btm_cont_rswitch_or_chglinkkey (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec, #endif sw_ok = btsnd_hcic_switch_role (p->remote_addr, (UINT8)!p->link_role); } - - if (p->change_key_state == BTM_ACL_SWKEY_STATE_MODE_CHANGE) - { - p->switch_role_state = BTM_ACL_SWKEY_STATE_IN_PROGRESS; - chlk_ok = btsnd_hcic_change_link_key (p->hci_handle); - } } if (!sw_ok) @@ -3333,17 +2429,6 @@ void btm_cont_rswitch_or_chglinkkey (tACL_CONN *p, tBTM_SEC_DEV_REC *p_dev_rec, p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE; btm_acl_report_role_change(hci_status, p->remote_addr); } - - if (!chlk_ok) - { - p->change_key_state = BTM_ACL_SWKEY_STATE_IDLE; - if (btm_cb.devcb.p_chg_link_key_cb) - { - btm_cb.devcb.chg_link_key_ref_data.hci_status = hci_status; - (*btm_cb.devcb.p_chg_link_key_cb)(&btm_cb.devcb.chg_link_key_ref_data); - btm_cb.devcb.p_chg_link_key_cb = NULL; - } - } } } @@ -3401,19 +2486,6 @@ void btm_acl_reset_paging (void) /******************************************************************************* ** -** Function btm_acl_set_discing -** -** Description set discing to the given value -** -*******************************************************************************/ -void btm_acl_set_discing (BOOLEAN discing) -{ - BTM_TRACE_DEBUG ("btm_acl_set_discing"); - btm_cb.discing = discing; -} - -/******************************************************************************* -** ** Function btm_acl_paging ** ** Description send a paging command or queue it in btm_cb @@ -3470,15 +2542,11 @@ void btm_acl_paging (BT_HDR *p, BD_ADDR bda) ** Description Send connection collision event to upper layer if registered ** ** Returns TRUE if sent out to upper layer, -** FALSE if BTM_BUSY_LEVEL_CHANGE_INCLUDED == FALSE, or no one -** needs the notification. -** -** Note: Function only used if BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE +** FALSE if no one needs the notification. ** *******************************************************************************/ BOOLEAN btm_acl_notif_conn_collision (BD_ADDR bda) { -#if (BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) tBTM_BL_EVENT_DATA evt_data; /* Report possible collision to the upper layer. */ @@ -3499,9 +2567,6 @@ BOOLEAN btm_acl_notif_conn_collision (BD_ADDR bda) } else return FALSE; -#else - return FALSE; -#endif } @@ -3521,31 +2586,27 @@ void btm_acl_chk_peer_pkt_type_support (tACL_CONN *p, UINT16 *p_pkt_type) if (!HCI_5_SLOT_PACKETS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) *p_pkt_type &= ~(BTM_ACL_PKT_TYPES_MASK_DH5 + BTM_ACL_PKT_TYPES_MASK_DM5); - /* If HCI version > 2.0, then also check EDR packet types */ - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) - { - /* 2 and 3 MPS support? */ - if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - /* Not supported. Add 'not_supported' mask for all 2MPS packet types */ - *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + - BTM_ACL_PKT_TYPES_MASK_NO_2_DH5); + /* 2 and 3 MPS support? */ + if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + /* Not supported. Add 'not_supported' mask for all 2MPS packet types */ + *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + + BTM_ACL_PKT_TYPES_MASK_NO_2_DH5); - if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - /* Not supported. Add 'not_supported' mask for all 3MPS packet types */ - *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 + - BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); + if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + /* Not supported. Add 'not_supported' mask for all 3MPS packet types */ + *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 + + BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); - /* EDR 3 and 5 slot support? */ - if (HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]) - || HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - { - if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - /* Not supported. Add 'not_supported' mask for all 3-slot EDR packet types */ - *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3); + /* EDR 3 and 5 slot support? */ + if (HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]) + || HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + { + if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + /* Not supported. Add 'not_supported' mask for all 3-slot EDR packet types */ + *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3); - if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - /* Not supported. Add 'not_supported' mask for all 5-slot EDR packet types */ - *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); - } + if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + /* Not supported. Add 'not_supported' mask for all 5-slot EDR packet types */ + *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); } } diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c index 1552c4e86..d28f6f2f2 100644 --- a/stack/btm/btm_ble.c +++ b/stack/btm/btm_ble.c @@ -39,6 +39,8 @@ #include "bt_utils.h" #include "vendor_ble.h" +#define LOG_TAG "bt_btm_ble" +#include "osi/include/log.h" #if SMP_INCLUDED == TRUE extern BOOLEAN AES_CMAC ( BT_OCTET16 key, UINT8 *input, UINT16 length, UINT16 tlen, UINT8 *p_signature); @@ -1509,13 +1511,13 @@ static void btm_ble_resolve_random_addr_on_conn_cmpl(void * p_rec, void *p_data) { UINT8 *p = (UINT8 *)p_data; tBTM_SEC_DEV_REC *match_rec = (tBTM_SEC_DEV_REC *) p_rec; - UINT8 role, status, bda_type; + UINT8 role, bda_type; UINT16 handle; BD_ADDR bda; UINT16 conn_interval, conn_latency, conn_timeout; BOOLEAN match = FALSE; - STREAM_TO_UINT8 (status, p); + ++p; STREAM_TO_UINT16 (handle, p); STREAM_TO_UINT8 (role, p); STREAM_TO_UINT8 (bda_type, p); @@ -1526,11 +1528,11 @@ static void btm_ble_resolve_random_addr_on_conn_cmpl(void * p_rec, void *p_data) handle = HCID_GET_HANDLE (handle); - BTM_TRACE_EVENT ("btm_ble_resolve_random_addr_master_cmpl"); + BTM_TRACE_EVENT ("%s", __func__); if (match_rec) { - BTM_TRACE_ERROR("Random match"); + LOG_INFO("%s matched and resolved random address", __func__); match = TRUE; match_rec->ble.active_addr_type = BTM_BLE_ADDR_RRA; memcpy(match_rec->ble.cur_rand_addr, bda, BD_ADDR_LEN); @@ -1538,7 +1540,7 @@ static void btm_ble_resolve_random_addr_on_conn_cmpl(void * p_rec, void *p_data) } else { - BTM_TRACE_ERROR("Random unmatch"); + LOG_INFO("%s unable to match and resolve random address", __func__); } btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type, match); @@ -1746,6 +1748,11 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED; case SMP_SEC_REQUEST_EVT: + if (event == SMP_SEC_REQUEST_EVT && btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) + { + BTM_TRACE_DEBUG("%s: Ignoring SMP Security request", __func__); + break; + } memcpy (btm_cb.pairing_bda, bd_addr, BD_ADDR_LEN); p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING; btm_cb.pairing_flags |= BTM_PAIR_FLAGS_LE_ACTIVE; @@ -1800,10 +1807,13 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) BTM_TRACE_DEBUG ("btm_cb.pairing_bda %02x:%02x:%02x:%02x:%02x:%02x", btm_cb.pairing_bda[0], btm_cb.pairing_bda[1], btm_cb.pairing_bda[2], btm_cb.pairing_bda[3], btm_cb.pairing_bda[4], btm_cb.pairing_bda[5]); - - memset (btm_cb.pairing_bda, 0xff, BD_ADDR_LEN); - btm_cb.pairing_state = BTM_PAIR_STATE_IDLE; - btm_cb.pairing_flags = 0; + /* Reset btm state only if the callback address matches pairing address*/ + if(memcmp(bd_addr, btm_cb.pairing_bda, BD_ADDR_LEN) == 0) + { + memset (btm_cb.pairing_bda, 0xff, BD_ADDR_LEN); + btm_cb.pairing_state = BTM_PAIR_STATE_IDLE; + btm_cb.pairing_flags = 0; + } } break; diff --git a/stack/btm/btm_ble_adv_filter.c b/stack/btm/btm_ble_adv_filter.c index 0784b0294..ea87383b4 100644 --- a/stack/btm/btm_ble_adv_filter.c +++ b/stack/btm/btm_ble_adv_filter.c @@ -16,6 +16,8 @@ * ******************************************************************************/ +#define LOG_TAG "bt_btm_ble" + #include <string.h> #include "bt_target.h" @@ -28,6 +30,7 @@ #include "hcidefs.h" #include "btm_ble_api.h" #include "vendor_ble.h" +#include "device/include/controller.h" #define BTM_BLE_ADV_FILT_META_HDR_LENGTH 3 #define BTM_BLE_ADV_FILT_FEAT_SELN_LEN 13 @@ -253,7 +256,8 @@ void btm_ble_scan_pf_cmpl_cback(tBTM_VSC_CMPL *p_params) if (evt_len < 3 || evt_len > 4) { - BTM_TRACE_ERROR("cannot interpret APCF callback status = %d, length = %d", status, evt_len); + BTM_TRACE_ERROR("%s cannot interpret APCF callback status = %d, length = %d", + __func__, status, evt_len); btm_ble_advfilt_deq_op_q(&action, &ocf, &cb_evt, &ref_value, &p_scan_cfg_cback, &p_filt_param_cback); return; @@ -1301,9 +1305,6 @@ void btm_ble_adv_filter_init(void) btm_ble_adv_filt_cb.p_addr_filter_count = (tBTM_BLE_PF_COUNT*) GKI_getbuf( sizeof(tBTM_BLE_PF_COUNT) * cmn_ble_vsc_cb.max_filter); } - - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) - return; } /******************************************************************************* diff --git a/stack/btm/btm_ble_batchscan.c b/stack/btm/btm_ble_batchscan.c index b2181c8d7..7ed61dc28 100644 --- a/stack/btm/btm_ble_batchscan.c +++ b/stack/btm/btm_ble_batchscan.c @@ -25,6 +25,7 @@ #include "bt_utils.h" #include "btu.h" #include "btm_int.h" +#include "device/include/controller.h" #include "hcimsgs.h" #if (BLE_INCLUDED == TRUE) @@ -612,7 +613,7 @@ tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max, UINT8 batch_scan_ ble_batchscan_cb.cur_state, ref_value, batch_scan_full_max, batch_scan_trunc_max, batch_scan_notify_threshold); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb); @@ -685,7 +686,7 @@ tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode, BTM_TRACE_EVENT (" BTM_BleEnableBatchScan: %d, %d, %d, %d, %d, %d", scan_mode, scan_interval, scan_window, addr_type, discard_rule, ref_value); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb); @@ -759,7 +760,7 @@ tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value) tBTM_BLE_VSC_CB cmn_ble_vsc_cb; BTM_TRACE_EVENT (" BTM_BleDisableBatchScan"); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb); @@ -805,7 +806,7 @@ tBTM_STATUS BTM_BleReadScanReports(tBTM_BLE_BATCH_SCAN_MODE scan_mode, BTM_TRACE_EVENT (" BTM_BleReadScanReports; %d, %d", scan_mode, ref_value); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb); @@ -863,7 +864,7 @@ tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback, { tBTM_BLE_VSC_CB cmn_ble_vsc_cb; BTM_TRACE_EVENT (" BTM_BleTrackAdvertiser"); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb); diff --git a/stack/btm/btm_ble_bgconn.c b/stack/btm/btm_ble_bgconn.c index b33aa2e2c..2fabe23d6 100644 --- a/stack/btm/btm_ble_bgconn.c +++ b/stack/btm/btm_ble_bgconn.c @@ -705,7 +705,7 @@ BOOLEAN btm_send_pending_direct_conn(void ) tBTM_BLE_CONN_REQ *p_req; BOOLEAN rt = FALSE; - if ( btm_cb.ble_ctr_cb.conn_pending_q.count ) + if (!GKI_queue_is_empty(&btm_cb.ble_ctr_cb.conn_pending_q)) { p_req = (tBTM_BLE_CONN_REQ*)GKI_dequeue (&btm_cb.ble_ctr_cb.conn_pending_q); diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c index 902c77657..c3b140ebe 100644 --- a/stack/btm/btm_ble_gap.c +++ b/stack/btm/btm_ble_gap.c @@ -31,10 +31,9 @@ #include "btm_int.h" #include "btm_ble_api.h" #include "btu.h" +#include "device/include/controller.h" #include "hcimsgs.h" -#if (GAP_INCLUDED == TRUE) #include "gap_api.h" -#endif #if BLE_INCLUDED == TRUE #include "l2c_int.h" @@ -44,6 +43,8 @@ #include "gatt_int.h" #include "btm_ble_int.h" +#define LOG_TAG "bt_btm_ble" +#include "osi/include/log.h" #define BTM_BLE_NAME_SHORT 0x01 #define BTM_BLE_NAME_CMPL 0x02 @@ -255,7 +256,7 @@ void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy) BTM_TRACE_EVENT ("BTM_BleUpdateAdvFilterPolicy"); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return; if (p_cb->afp != adv_policy) @@ -306,7 +307,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration, BTM_TRACE_EVENT ("BTM_BleObserve : scan_type:%d",btm_cb.btm_inq_vars.scan_type); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; if (start) @@ -380,7 +381,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start) tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; UINT8 evt_type = p_cb->scan_rsp ? BTM_BLE_DISCOVER_EVT: BTM_BLE_NON_CONNECT_EVT; - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; #ifdef BTM_BLE_PC_ADV_TEST_MODE @@ -494,7 +495,7 @@ static void btm_ble_vendor_capability_vsc_cmpl_cback (tBTM_VSC_CMPL *p_vcs_cplt_ ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb) +extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb) { BTM_TRACE_DEBUG("BTM_BleGetVendorCapabilities"); @@ -515,7 +516,7 @@ BTM_API extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb) ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback) +extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback) { if (TRUE == btm_cb.cmn_ble_vsc_cb.values_read) return; @@ -610,7 +611,7 @@ void BTM_BleConfigPrivacy(BOOLEAN enable) ** Returns Max multi adv instance count ** *******************************************************************************/ -BTM_API extern UINT8 BTM_BleMaxMultiAdvInstanceCount() +extern UINT8 BTM_BleMaxMultiAdvInstanceCount() { return btm_cb.cmn_ble_vsc_cb.adv_inst_max < BTM_BLE_MULTI_ADV_MAX ? btm_cb.cmn_ble_vsc_cb.adv_inst_max : BTM_BLE_MULTI_ADV_MAX; @@ -693,7 +694,7 @@ BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE bg_conn_type, BOOLEAN started = TRUE; BTM_TRACE_EVENT ("BTM_BleSetBgConnType "); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return FALSE; if (btm_cb.ble_ctr_cb.bg_conn_type != bg_conn_type) @@ -802,7 +803,7 @@ tBTM_STATUS BTM_BleSetConnMode(BOOLEAN is_directed) tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; BTM_TRACE_EVENT ("BTM_BleSetConnMode is_directed = %d ", is_directed); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; p_cb->directed_conn = is_directed; @@ -882,7 +883,7 @@ tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max, BTM_TRACE_EVENT ("BTM_BleSetAdvParams"); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; if (!BTM_BLE_VALID_PRAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) || @@ -943,7 +944,7 @@ void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max, tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; BTM_TRACE_EVENT ("BTM_BleReadAdvParams "); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return ; *adv_int_min = p_cb->adv_interval_min; @@ -976,7 +977,7 @@ void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_window, tBTM_BLE_SCA tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; BTM_TRACE_EVENT (" BTM_BleSetScanParams"); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return ; if (BTM_BLE_VALID_PRAM(scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) && @@ -1018,7 +1019,7 @@ tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p BTM_TRACE_EVENT (" BTM_BleWriteScanRsp"); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; memset(rsp_data, 0, BTM_BLE_AD_DATA_LEN); @@ -1058,7 +1059,7 @@ tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p BTM_TRACE_EVENT ("BTM_BleWriteAdvData "); - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ILLEGAL_VALUE; memset(p_cb_data, 0, sizeof(tBTM_BLE_LOCAL_ADV_DATA)); @@ -1468,12 +1469,12 @@ void btm_ble_set_adv_flag(UINT16 connect_mode, UINT16 disc_mode) flag &= ~BTM_BLE_BREDR_NOT_SPT; /* if local controller support, mark both controller and host support in flag */ - if (HCI_SIMUL_LE_BREDR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + if (controller_get_interface()->supports_simultaneous_le_bredr()) flag |= (BTM_BLE_DMT_CONTROLLER_SPT|BTM_BLE_DMT_HOST_SPT); else flag &= ~(BTM_BLE_DMT_CONTROLLER_SPT|BTM_BLE_DMT_HOST_SPT); - BTM_TRACE_DEBUG("disc_mode %04x", disc_mode); + LOG_DEBUG("disc_mode %04x", disc_mode); /* update discoverable flag */ if (disc_mode & BTM_BLE_LIMITED_DISCOVERABLE) { @@ -1783,7 +1784,7 @@ tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, t { tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars; - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return BTM_ERR_PROCESSING; if (p_cur && @@ -2527,12 +2528,12 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt if ((result = btm_ble_is_discoverable(bda, evt_type, p)) == 0) { - BTM_TRACE_ERROR("discard adv pkt"); + LOG_WARN("%s device is no longer discoverable so discarding advertising packet pkt", + __func__); return; } if (!update) result &= ~BTM_BLE_INQ_RESULT; -#if BTM_USE_INQ_RESULTS_FILTER == TRUE /* If the number of responses found and limited, issue a cancel inquiry */ if (p_inq->inqparms.max_resps && p_inq->inq_cmpl_info.num_resp == p_inq->inqparms.max_resps) @@ -2551,12 +2552,9 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt btm_ble_stop_inquiry(); -#if BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE btm_acl_update_busy_level (BTM_BLI_INQ_DONE_EVT); -#endif } } -#endif /* background connection in selective connection mode */ if (btm_cb.ble_ctr_cb.bg_conn_type == BTM_BLE_CONN_SELECTIVE) { @@ -3134,7 +3132,9 @@ BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request_state_mask) mask = btm_le_state_combo_tbl[0][request_state - 1][0]; offset = btm_le_state_combo_tbl[0][request_state-1][1]; - if (!BTM_LE_STATES_SUPPORTED(btm_cb.devcb.le_supported_states, mask, offset)) + const uint8_t *ble_supported_states = controller_get_interface()->get_ble_supported_states(); + + if (!BTM_LE_STATES_SUPPORTED(ble_supported_states, mask, offset)) { BTM_TRACE_ERROR("state requested not supported: %d", request_state); return rt; @@ -3152,7 +3152,7 @@ BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request_state_mask) if (mask != 0 && offset != 0) { - if (!BTM_LE_STATES_SUPPORTED(btm_cb.devcb.le_supported_states, mask, offset)) + if (!BTM_LE_STATES_SUPPORTED(ble_supported_states, mask, offset)) { rt = FALSE; break; diff --git a/stack/btm/btm_ble_int.h b/stack/btm/btm_ble_int.h index 2512d3390..4741ca7e5 100644 --- a/stack/btm/btm_ble_int.h +++ b/stack/btm/btm_ble_int.h @@ -413,11 +413,11 @@ extern BOOLEAN btm_random_pseudo_to_public(BD_ADDR random_pseudo, UINT8 *p_stati extern void btm_ble_refresh_rra(BD_ADDR pseudo_bda, BD_ADDR rra); #if BTM_BLE_CONFORMANCE_TESTING == TRUE -BT_API extern void btm_ble_set_no_disc_if_pair_fail (BOOLEAN disble_disc); -BT_API extern void btm_ble_set_test_mac_value (BOOLEAN enable, UINT8 *p_test_mac_val); -BT_API extern void btm_ble_set_test_local_sign_cntr_value(BOOLEAN enable, UINT32 test_local_sign_cntr); -BT_API extern void btm_set_random_address(BD_ADDR random_bda); -BT_API extern void btm_ble_set_keep_rfu_in_auth_req(BOOLEAN keep_rfu); +extern void btm_ble_set_no_disc_if_pair_fail (BOOLEAN disble_disc); +extern void btm_ble_set_test_mac_value (BOOLEAN enable, UINT8 *p_test_mac_val); +extern void btm_ble_set_test_local_sign_cntr_value(BOOLEAN enable, UINT32 test_local_sign_cntr); +extern void btm_set_random_address(BD_ADDR random_bda); +extern void btm_ble_set_keep_rfu_in_auth_req(BOOLEAN keep_rfu); #endif diff --git a/stack/btm/btm_ble_multi_adv.c b/stack/btm/btm_ble_multi_adv.c index 1ca6cd38b..0ad97c4e2 100644 --- a/stack/btm/btm_ble_multi_adv.c +++ b/stack/btm/btm_ble_multi_adv.c @@ -17,7 +17,9 @@ ******************************************************************************/ #include <string.h> + #include "bt_target.h" +#include "device/include/controller.h" #if (BLE_INCLUDED == TRUE) #include "bt_types.h" @@ -125,12 +127,14 @@ void btm_ble_multi_adv_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params) switch (subcode) { case BTM_BLE_MULTI_ADV_ENB: - BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_ENB status = %d", status); - if (status != HCI_SUCCESS) { - btm_multi_adv_cb.p_adv_inst[inst_id-1].inst_id = 0; + BTM_TRACE_DEBUG("BTM_BLE_MULTI_ADV_ENB status = %d", status); + + /* Mark as not in use here, if instance cannot be enabled */ + if (HCI_SUCCESS != status && BTM_BLE_MULTI_ADV_ENB_EVT == cb_evt) + btm_multi_adv_cb.p_adv_inst[inst_id-1].in_use = FALSE; + break; } - break; case BTM_BLE_MULTI_ADV_SET_PARAM: { @@ -260,7 +264,7 @@ tBTM_STATUS btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst, #endif { UINT8_TO_STREAM (pp, BLE_ADDR_PUBLIC); - BDADDR_TO_STREAM (pp, btm_cb.devcb.local_addr); + BDADDR_TO_STREAM (pp, controller_get_interface()->get_address()->address); } BTM_TRACE_EVENT (" btm_ble_multi_adv_set_params,Min %d, Max %d,adv_type %d", @@ -325,7 +329,9 @@ tBTM_STATUS btm_ble_multi_adv_write_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst, BD_ADD UINT8 param[BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN], *pp = param; tBTM_STATUS rt; - BTM_TRACE_EVENT (" btm_ble_multi_adv_set_random_addr"); + BTM_TRACE_EVENT ("%s-BD_ADDR:%02x-%02x-%02x-%02x-%02x-%02x,inst_id:%d", + __FUNCTION__, random_addr[5], random_addr[4], random_addr[3], random_addr[2], + random_addr[1], random_addr[0], p_inst->inst_id); memset(param, 0, BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR_LEN); @@ -408,12 +414,13 @@ void btm_ble_multi_adv_gen_rpa_cmpl(tBTM_RAND_ENC *p) p_inst->rpa[5] = output.param_buf[0]; p_inst->rpa[4] = output.param_buf[1]; p_inst->rpa[3] = output.param_buf[2]; + } - if (p_inst->inst_id != 0 && (p_inst->inst_id < BTM_BleMaxMultiAdvInstanceCount())) - { - /* set it to controller */ - btm_ble_multi_adv_write_rpa(p_inst, p_inst->rpa); - } + if (p_inst->inst_id != BTM_BLE_MULTI_ADV_DEFAULT_STD && + p_inst->inst_id < BTM_BleMaxMultiAdvInstanceCount()) + { + /* set it to controller */ + btm_ble_multi_adv_write_rpa(p_inst, p_inst->rpa); } } #endif @@ -468,7 +475,7 @@ void btm_ble_multi_adv_reenable(UINT8 inst_id) { tBTM_BLE_MULTI_ADV_INST *p_inst = &btm_multi_adv_cb.p_adv_inst[inst_id - 1]; - if (p_inst->inst_id != 0) + if (TRUE == p_inst->in_use) { if (p_inst->adv_evt != BTM_BLE_CONNECT_DIR_EVT) btm_ble_enable_multi_adv (TRUE, p_inst->inst_id, 0); @@ -476,7 +483,7 @@ void btm_ble_multi_adv_reenable(UINT8 inst_id) /* mark directed adv as disabled if adv has been stopped */ { (p_inst->p_cback)(BTM_BLE_MULTI_ADV_DISABLE_EVT,p_inst->inst_id,p_inst->p_ref,0); - p_inst->inst_id = 0; + p_inst->in_use = FALSE; } } } @@ -499,8 +506,13 @@ void btm_ble_multi_adv_enb_privacy(BOOLEAN enable) for (i = 0; i < BTM_BleMaxMultiAdvInstanceCount() - 1; i ++, p_inst++) { + p_inst->in_use = FALSE; if (enable) + { + /* Setup the instance ID before configuring the RPA */ + p_inst->inst_id = i + 1; btm_ble_multi_adv_configure_rpa (p_inst); + } else btu_stop_timer_oneshot(&p_inst->raddr_timer_ent); } @@ -544,10 +556,9 @@ tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params, for (i = 0; i < BTM_BleMaxMultiAdvInstanceCount() - 1; i ++, p_inst++) { - if (p_inst->inst_id == 0) + if (FALSE == p_inst->in_use) { - p_inst->inst_id = i + 1; - + p_inst->in_use = TRUE; /* configure adv parameter */ if (p_params) rt = btm_ble_multi_adv_set_params(p_inst, p_params, 0); @@ -570,7 +581,7 @@ tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params, if (BTM_CMD_STARTED != rt) { - p_inst->inst_id = 0; + p_inst->in_use = FALSE; BTM_TRACE_ERROR("BTM_BleEnableAdvInstance failed"); } break; @@ -609,7 +620,7 @@ tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_par inst_id != BTM_BLE_MULTI_ADV_DEFAULT_STD && p_params != NULL) { - if (p_inst->inst_id == 0) + if (FALSE == p_inst->in_use) { BTM_TRACE_DEBUG("adv instance %d is not active", inst_id); return BTM_WRONG_MODE; @@ -715,7 +726,7 @@ tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id) { btm_ble_multi_adv_configure_rpa(&btm_multi_adv_cb.p_adv_inst[inst_id-1]); btu_stop_timer(&btm_multi_adv_cb.p_adv_inst[inst_id-1].raddr_timer_ent); - btm_multi_adv_cb.p_adv_inst[inst_id-1].inst_id = 0; + btm_multi_adv_cb.p_adv_inst[inst_id-1].in_use = FALSE; } } return rt; @@ -732,7 +743,7 @@ tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id) void btm_ble_multi_adv_vse_cback(UINT8 len, UINT8 *p) { UINT8 sub_event; - UINT8 adv_inst, reason, conn_handle, idx; + UINT8 adv_inst, conn_handle, idx; /* Check if this is a BLE RSSI vendor specific event */ STREAM_TO_UINT8(sub_event, p); @@ -742,7 +753,7 @@ void btm_ble_multi_adv_vse_cback(UINT8 len, UINT8 *p) if ((sub_event == HCI_VSE_SUBCODE_BLE_MULTI_ADV_ST_CHG) && (len >= 4)) { STREAM_TO_UINT8(adv_inst, p); - STREAM_TO_UINT8(reason, p); + ++p; STREAM_TO_UINT16(conn_handle, p); if ((idx = btm_handle_to_acl_index(conn_handle)) != MAX_L2CAP_LINKS) diff --git a/stack/btm/btm_dev.c b/stack/btm/btm_dev.c index f60282f10..d3d04813a 100644 --- a/stack/btm/btm_dev.c +++ b/stack/btm/btm_dev.c @@ -28,6 +28,7 @@ #include <stddef.h> #include "bt_types.h" +#include "device/include/controller.h" #include "gki.h" #include "hcimsgs.h" #include "btu.h" @@ -295,15 +296,6 @@ tBTM_SEC_DEV_REC *btm_sec_alloc_dev (BD_ADDR bd_addr) /* update conn params, use default value for background connection params */ memset(&p_dev_rec->conn_params, 0xff, sizeof(tBTM_LE_CONN_PRAMS)); #endif - -#if BTM_INQ_GET_REMOTE_NAME == TRUE - if (p_inq_info->remote_name_state == BTM_INQ_RMT_NAME_DONE) - { - BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), - (char *)p_inq_info->remote_name, BTM_MAX_REM_BD_NAME_LEN); - p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; - } -#endif } else { @@ -371,7 +363,7 @@ BOOLEAN btm_dev_support_switch (BD_ADDR bd_addr) return(FALSE); #endif p_dev_rec = btm_find_dev (bd_addr); - if (p_dev_rec && HCI_SWITCH_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + if (p_dev_rec && controller_get_interface()->supports_master_slave_role_switch()) { if (HCI_SWITCH_SUPPORTED(p_dev_rec->features[HCI_EXT_FEATURES_PAGE_0])) { diff --git a/stack/btm/btm_devctl.c b/stack/btm/btm_devctl.c index f001c5f9c..03ed726f2 100644 --- a/stack/btm/btm_devctl.c +++ b/stack/btm/btm_devctl.c @@ -23,6 +23,7 @@ * ******************************************************************************/ +#include <assert.h> #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -30,40 +31,25 @@ #include "bt_types.h" #include "bt_utils.h" -#include "hcimsgs.h" -#include "btu.h" #include "btm_int.h" +#include "btu.h" +#include "device/include/controller.h" +#include "hci_layer.h" +#include "hcimsgs.h" #include "l2c_int.h" +#include "btcore/include/module.h" +#include "osi/include/thread.h" #if BLE_INCLUDED == TRUE #include "gatt_int.h" - #endif /* BLE_INCLUDED */ -/* BTM_APP_DEV_INIT should be defined if additional controller initialization is -** needed by the application to be performed after the HCI reset -*/ -#ifdef BTM_APP_DEV_INIT -extern void BTM_APP_DEV_INIT(void); -#endif - -#ifdef BTA_PRM_CHECK_FW_VER -extern BOOLEAN BTA_PRM_CHECK_FW_VER(UINT8 *p); -#endif - -#ifndef TT_DEV_RESET_MASK -#define TT_DEV_RESET_MASK 0xff -#endif +extern thread_t *bt_workqueue_thread; /********************************************************************************/ /* L O C A L D A T A D E F I N I T I O N S */ /********************************************************************************/ -/* The default class of device. */ -#ifndef BTM_INIT_CLASS_OF_DEVICE -#define BTM_INIT_CLASS_OF_DEVICE "\x00\x1F\x00" -#endif - #ifndef BTM_DEV_RESET_TIMEOUT #define BTM_DEV_RESET_TIMEOUT 4 #endif @@ -73,59 +59,11 @@ extern BOOLEAN BTA_PRM_CHECK_FW_VER(UINT8 *p); #define BTM_INFO_TIMEOUT 5 /* 5 seconds for info response */ -/* After Reset a timeout can be specified in the target.h for specific targets - * that may require additional time to reset - * otherwise no timeout is required -*/ -#ifndef BTM_AFTER_RESET_TIMEOUT -#define BTM_AFTER_RESET_TIMEOUT 0 -#endif - -/* Internal baseband so the parameters such as local features, version etc. are known -so there is no need to issue HCI commands and wait for responses at BTM initialization */ -#ifndef BTM_INTERNAL_BB -#define BTM_INTERNAL_BB FALSE -#endif - -/* The local version information in the format specified in the HCI read local version -response message */ -#ifndef BTM_INTERNAL_LOCAL_VER -#define BTM_INTERNAL_LOCAL_VER {0x00, 0x01, 0x05, 0x81, 0x01, 0x30, 0x00, 0x40, 0x8D} -#endif - -/* The local features information in the format specified in the HCI read local features -response message */ -#ifndef BTM_INTERNAL_LOCAL_FEA -#define BTM_INTERNAL_LOCAL_FEA {0x00, 0xFF, 0xF9, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00} -#endif - -#ifndef BTM_SET_DEV_NAME_UPON_RESET -#define BTM_SET_DEV_NAME_UPON_RESET TRUE -#endif - -/* host SCO buffer size */ -#ifndef BTM_SCO_HOST_BUF_SIZE -#define BTM_SCO_HOST_BUF_SIZE 0xff -#endif - /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /********************************************************************************/ -static void btm_dev_reset (void); -static void btm_after_reset_hold_complete (void); -static void btm_continue_reset (void); -static void btm_get_local_ext_features (UINT8 page_number); static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p_features); -static void btm_read_all_lmp_features_complete (UINT8 max_page_number); -static void btm_set_lmp_features_host_may_support (UINT8 max_page_number); -static void btm_get_local_features (void); -static void btm_issue_host_support_for_lmp_features (void); -static void btm_read_local_supported_cmds (UINT8 local_controller_id); - -#if BLE_INCLUDED == TRUE -static void btm_read_ble_local_supported_features (void); -#endif /******************************************************************************* ** @@ -149,7 +87,6 @@ void btm_dev_init (void) btm_cb.devcb.reset_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RESET; btm_cb.devcb.rln_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RLN; - btm_cb.devcb.rlinkp_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RLNKP; btm_cb.btm_acl_pkt_types_supported = BTM_ACL_PKT_TYPES_MASK_DH1 + BTM_ACL_PKT_TYPES_MASK_DM1 + BTM_ACL_PKT_TYPES_MASK_DH3 + BTM_ACL_PKT_TYPES_MASK_DM3 + @@ -161,23 +98,6 @@ void btm_dev_init (void) BTM_SCO_PKT_TYPES_MASK_EV3 + BTM_SCO_PKT_TYPES_MASK_EV4 + BTM_SCO_PKT_TYPES_MASK_EV5; - - btm_cb.first_disabled_channel = 0xff; /* To allow disabling 0th channel alone */ - btm_cb.last_disabled_channel = 0xff; /* To allow disabling 0th channel alone */ - -#if (BTM_AUTOMATIC_HCI_RESET == TRUE) - -#if (BTM_FIRST_RESET_DELAY > 0) - btm_cb.devcb.state = BTM_DEV_STATE_WAIT_RESET_CMPLT; - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_FIRST_RESET_DELAY); -#else - btm_dev_reset(); -#endif - -#else - BTM_TRACE_EVENT ("BTM_AUTOMATIC_HCI_RESET is FALSE, so skip btm reset for now"); -#endif - } @@ -208,15 +128,6 @@ static void btm_db_reset (void) (*p_cb)((void *) NULL); } - if (btm_cb.devcb.p_rlinkp_cmpl_cb) - { - p_cb = btm_cb.devcb.p_rlinkp_cmpl_cb; - btm_cb.devcb.p_rlinkp_cmpl_cb = NULL; - - if (p_cb) - (*p_cb)((void *) &status); - } - if (btm_cb.devcb.p_rssi_cmpl_cb) { p_cb = btm_cb.devcb.p_rssi_cmpl_cb; @@ -227,364 +138,83 @@ static void btm_db_reset (void) } } +static void reset_complete(void *result) { + assert(result == FUTURE_SUCCESS); + const controller_t *controller = controller_get_interface(); + /* Tell L2CAP that all connections are gone */ + l2cu_device_reset (); -/******************************************************************************* -** -** Function btm_dev_absent -** -** Description This function is called by when it is detected that the -** device is not connected any more. -** -** Returns void -** -*******************************************************************************/ -void btm_dev_absent (void) -{ - btm_cb.devcb.state = BTM_DEV_STATE_WAIT_RESET_CMPLT; - - btm_db_reset (); - btm_inq_db_reset(); - - /* If anyone wants device status notifications, give him one */ - btm_report_device_status (BTM_DEV_STATUS_DOWN); + /* Clear current security state */ + for (int devinx = 0; devinx < BTM_SEC_MAX_DEVICE_RECORDS; devinx++) { + btm_cb.sec_dev_rec[devinx].sec_state = BTM_SEC_STATE_IDLE; + } - btu_stop_timer (&btm_cb.devcb.reset_timer); -} + /* After the reset controller should restore all parameters to defaults. */ + btm_cb.btm_inq_vars.inq_counter = 1; + btm_cb.btm_inq_vars.inq_scan_window = HCI_DEF_INQUIRYSCAN_WINDOW; + btm_cb.btm_inq_vars.inq_scan_period = HCI_DEF_INQUIRYSCAN_INTERVAL; + btm_cb.btm_inq_vars.inq_scan_type = HCI_DEF_SCAN_TYPE; + btm_cb.btm_inq_vars.page_scan_window = HCI_DEF_PAGESCAN_WINDOW; + btm_cb.btm_inq_vars.page_scan_period = HCI_DEF_PAGESCAN_INTERVAL; + btm_cb.btm_inq_vars.page_scan_type = HCI_DEF_SCAN_TYPE; -/******************************************************************************* -** -** Function BTM_DeviceReset -** -** Description This function is called to reset the HCI. Callback function -** if provided is called when startup of the device is -** completed. -** -** Returns void -** -*******************************************************************************/ -void BTM_DeviceReset (tBTM_CMPL_CB *p_cb) -{ - tBTM_STATUS status; - - /* If device is already resetting, do not allow another */ - if ((!btm_cb.devcb.p_reset_cmpl_cb) || (btm_cb.devcb.p_reset_cmpl_cb == p_cb)) - { - /* Flush all ACL connections */ - btm_acl_device_down(); - - /* Clear the callback, so application would not hang on reset */ - btm_db_reset(); - - /* Save address of the completion routine, if provided */ - btm_cb.devcb.p_reset_cmpl_cb = p_cb; - - btm_dev_reset (); - } - else - { - /* pass an error to the bad callback, another one was already provided */ - if (p_cb) - { - status = BTM_ILLEGAL_VALUE; - p_cb (&status); - } - } -} - - -/******************************************************************************* -** -** Function BTM_IsDeviceUp -** -** Description This function is called to check if the device is up. -** -** Returns TRUE if device is up, else FALSE -** -*******************************************************************************/ -BOOLEAN BTM_IsDeviceUp (void) -{ - return ((BOOLEAN) (btm_cb.devcb.state == BTM_DEV_STATE_READY)); -} - -/******************************************************************************* -** -** Function BTM_SetAfhChannels -** -** Description This function is called disable channels -** -** Returns tBTM_STATUS -** -*******************************************************************************/ -tBTM_STATUS BTM_SetAfhChannels (UINT8 first, UINT8 last) -{ - BTM_TRACE_API ("BTM_SetAfhChannels first: %d (%d) last: %d (%d)", - first, btm_cb.first_disabled_channel, last, - btm_cb.last_disabled_channel); - - /* Make sure the local device supports the feature before sending */ - if ((!HCI_LMP_AFH_CAP_MASTR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) && - (!HCI_LMP_AFH_CLASS_SLAVE_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) && - (!HCI_LMP_AFH_CLASS_MASTR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]))) - return (BTM_MODE_UNSUPPORTED); - - if (!BTM_IsDeviceUp()) - return (BTM_WRONG_MODE); - - if ((btm_cb.first_disabled_channel != first) - || (btm_cb.last_disabled_channel != last)) - { - if (btsnd_hcic_set_afh_channels (first, last)) - { - btm_cb.first_disabled_channel = first; - btm_cb.last_disabled_channel = last; - } - else - return (BTM_NO_RESOURCES); - } - return (BTM_SUCCESS); -} - -/******************************************************************************* -** -** Function BTM_SetAfhChannelAssessment -** -** Description This function is called to set the channel assessment mode on or off -** -** Returns none -** -*******************************************************************************/ -tBTM_STATUS BTM_SetAfhChannelAssessment (BOOLEAN enable_or_disable) -{ - /* whatever app wants if device is not 1.2 scan type should be STANDARD */ - if (!HCI_LMP_AFH_CAP_SLAVE_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - return (BTM_MODE_UNSUPPORTED); - - if (!btsnd_hcic_write_afh_channel_assessment_mode (enable_or_disable)) - return (BTM_NO_RESOURCES); - - return (BTM_SUCCESS); -} - -/******************************************************************************* -** -** Function BTM_ContinueReset -** -** Description This function is called by the application to continue -** initialization after the application has completed its -** vendor specific sequence. It is only used when -** BTM_APP_DEV_INIT is defined in target.h. -** -** Returns void -** -*******************************************************************************/ -void BTM_ContinueReset (void) -{ -#ifdef BTM_APP_DEV_INIT - btm_continue_reset(); +#if (BLE_INCLUDED == TRUE) + btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE; + btm_cb.ble_ctr_cb.bg_dev_num = 0; + btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE; + btm_cb.ble_ctr_cb.p_select_cback = NULL; + memset(&btm_cb.ble_ctr_cb.bg_dev_list, 0, (sizeof(tBTM_LE_BG_CONN_DEV)*BTM_BLE_MAX_BG_CONN_DEV_NUM)); + gatt_reset_bgdev_list(); + btm_ble_multi_adv_init(); #endif -} - -/******************************************************************************* -** -** Function btm_dev_reset -** -** Description Local function called to send a reset command -** -** Returns void -** -*******************************************************************************/ -static void btm_dev_reset (void) -{ - btm_cb.devcb.state = BTM_DEV_STATE_WAIT_RESET_CMPLT; - - /* flush out the command complete queue and command transmit queue */ - btu_hcif_flush_cmd_queue(); - - /* Start reset timer. When timer expires we will send first command */ - /* from the setup sequence */ - - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, - BTM_DEV_RESET_TIMEOUT); - btsnd_hcic_reset (LOCAL_BR_EDR_CONTROLLER_ID); -} - - -/******************************************************************************* -** -** Function btm_get_hci_buf_size -** -** Description Local function called to send a read buffer size command -** -** Returns void -** -*******************************************************************************/ -void btm_get_hci_buf_size (void) -{ - - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); - - /* Send a Read Buffer Size message to the Host Controller. */ - btsnd_hcic_read_buffer_size (); - -} -#if BLE_INCLUDED == TRUE -/******************************************************************************* -** -** Function btm_read_ble_wl_size -** -** Description Local function called to send a read BLE buffer size command -** -** Returns void -** -*******************************************************************************/ -void btm_read_ble_wl_size(void) -{ - BTM_TRACE_DEBUG("btm_read_ble_wl_size "); - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); - - /* Send a Read Buffer Size message to the Host Controller. */ - btsnd_hcic_ble_read_white_list_size(); -} -/******************************************************************************* -** -** Function btm_get_ble_buffer_size -** -** Description Local function called to send a read BLE buffer size command -** -** Returns void -** -*******************************************************************************/ -void btm_get_ble_buffer_size(void) -{ - BTM_TRACE_DEBUG("btm_get_ble_buffer_size "); - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); - - /* Send a Read Buffer Size message to the Host Controller. */ - btsnd_hcic_ble_read_buffer_size (); -} - -/******************************************************************************* -** -** Function btm_read_ble_local_supported_features -** -** Description Local function called to send a read BLE local supported -** features command -** -** Returns void -** -*******************************************************************************/ -static void btm_read_ble_local_supported_features(void) -{ - BTM_TRACE_DEBUG("btm_read_ble_local_supported_features "); - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); - /* Send a Read Local Supported Features message to the Host Controller. */ - btsnd_hcic_ble_read_local_spt_feat (); -} - -/******************************************************************************* -** -** Function btm_read_ble_local_supported_states -** -** Description Local function called to send a read BLE local supported -** features command -** -** Returns void -** -*******************************************************************************/ -static void btm_read_ble_local_supported_states(void) -{ - BTM_TRACE_DEBUG("btm_read_ble_local_supported_states "); - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); + btm_pm_reset(); - /* Send a Read Local Supported states message to the Host Controller. */ - btsnd_hcic_ble_read_supported_states (); -} + l2c_link_processs_num_bufs(controller->get_acl_buffer_count_classic()); +#if (BLE_INCLUDED == TRUE) + if (controller->supports_ble()) { + l2c_link_processs_ble_num_bufs(controller->get_acl_buffer_count_ble()); + } #endif -/******************************************************************************* -** -** Function btm_get_local_version -** -** Description Local function called to send a read local version to controller -** -** Returns void -** -*******************************************************************************/ -void btm_get_local_version (void) -{ - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); + BTM_SetPinType (btm_cb.cfg.pin_type, btm_cb.cfg.pin_code, btm_cb.cfg.pin_code_len); - /* Send a Read Local Version message to the Host Controller. */ - btsnd_hcic_read_local_ver (LOCAL_BR_EDR_CONTROLLER_ID); - btsnd_hcic_read_bd_addr (); - -#if BTM_PWR_MGR_INCLUDED == TRUE - btm_pm_reset(); -#endif + for (int i = 0; i <= controller->get_last_features_classic_index(); i++) { + btm_decode_ext_features_page(i, controller->get_features_classic(i)->as_array); + } + btm_report_device_status(BTM_DEV_STATUS_UP); } -/******************************************************************************* -** -** Function btm_read_local_supported_cmds -** -** Description Local function called to send a read local supported commands -** -** Returns void -** -*******************************************************************************/ -static void btm_read_local_supported_cmds (UINT8 local_controller_id) -{ - BTM_TRACE_DEBUG("Start reading local supported commands"); - - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); +// TODO(zachoverflow): remove this function +void BTM_DeviceReset (UNUSED_ATTR tBTM_CMPL_CB *p_cb) { + /* Flush all ACL connections */ + btm_acl_device_down(); - btsnd_hcic_read_local_supported_cmds(local_controller_id); -} - -/******************************************************************************* -** -** Function btm_get_local_features -** -** Description Local function called to send a read local features -** -** Returns void -** -*******************************************************************************/ -static void btm_get_local_features (void) -{ - /* If this BT controller supports Read Extended Feature */ - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) - { - btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_0); - } - /* else, if this is a very old BT controller */ - else -{ - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); + /* Clear the callback, so application would not hang on reset */ + btm_db_reset(); - /* Just read the basic features (legacy HCI command) */ - btsnd_hcic_read_local_features (); -} + module_start_up_callbacked_wrapper( + get_module(CONTROLLER_MODULE), + bt_workqueue_thread, + reset_complete + ); } /******************************************************************************* ** -** Function btm_get_local_ext_features +** Function BTM_IsDeviceUp ** -** Description Local function called to send a read local extended features +** Description This function is called to check if the device is up. ** -** Returns void +** Returns TRUE if device is up, else FALSE ** *******************************************************************************/ -static void btm_get_local_ext_features (UINT8 page_number) +BOOLEAN BTM_IsDeviceUp (void) { - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, BTM_DEV_REPLY_TIMEOUT); - - btsnd_hcic_read_local_ext_features(page_number); + return controller_get_interface()->get_is_ready(); } /******************************************************************************* @@ -600,12 +230,7 @@ void btm_dev_timeout (TIMER_LIST_ENT *p_tle) { TIMER_PARAM_TYPE timer_type = (TIMER_PARAM_TYPE)p_tle->param; - if ((timer_type & TT_DEV_RESET_MASK) == TT_DEV_RESET) - { - /* Call device reset as long as there is timeout*/ - btm_dev_reset(); - } - else if (timer_type == (TIMER_PARAM_TYPE)TT_DEV_RLN) + if (timer_type == (TIMER_PARAM_TYPE)TT_DEV_RLN) { tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rln_cmpl_cb; @@ -618,364 +243,6 @@ void btm_dev_timeout (TIMER_LIST_ENT *p_tle) /******************************************************************************* ** -** Function btm_reset_complete -** -** Description This function is called when command complete for HCI_Reset -** is received. It does not make sense to send next command -** because device is resetting after command complete is -** received. Just start timer and set required state. -** -** Returns void -** -*******************************************************************************/ -void btm_reset_complete (void) -{ - int devinx; - - BTM_TRACE_EVENT ("btm_reset_complete"); - - /* Handle if btm initiated the reset */ - if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT) - { - /* Tell L2CAP that all connections are gone */ - l2cu_device_reset (); - - /* Clear current security state */ - for (devinx = 0; devinx < BTM_SEC_MAX_DEVICE_RECORDS; devinx++) - { - btm_cb.sec_dev_rec[devinx].sec_state = BTM_SEC_STATE_IDLE; - } - - /* After the reset controller should restore all parameters to defaults. */ - btm_cb.btm_inq_vars.inq_counter = 1; - btm_cb.btm_inq_vars.inq_scan_window = HCI_DEF_INQUIRYSCAN_WINDOW; - btm_cb.btm_inq_vars.inq_scan_period = HCI_DEF_INQUIRYSCAN_INTERVAL; - btm_cb.btm_inq_vars.inq_scan_type = HCI_DEF_SCAN_TYPE; - - btm_cb.btm_inq_vars.page_scan_window = HCI_DEF_PAGESCAN_WINDOW; - btm_cb.btm_inq_vars.page_scan_period = HCI_DEF_PAGESCAN_INTERVAL; - btm_cb.btm_inq_vars.page_scan_type = HCI_DEF_SCAN_TYPE; - -#if (BTM_AFTER_RESET_TIMEOUT > 0) - btu_start_timer (&btm_cb.devcb.reset_timer, BTU_TTYPE_BTM_DEV_CTL, - BTM_AFTER_RESET_TIMEOUT); -#else - btm_cb.devcb.state = BTM_DEV_STATE_WAIT_AFTER_RESET; - btm_after_reset_hold_complete(); -#endif - -#if (BLE_INCLUDED == TRUE) - btm_cb.ble_ctr_cb.conn_state = BLE_CONN_IDLE; - btm_cb.ble_ctr_cb.bg_dev_num = 0; - btm_cb.ble_ctr_cb.bg_conn_type = BTM_BLE_CONN_NONE; - btm_cb.ble_ctr_cb.p_select_cback = NULL; - memset(&btm_cb.ble_ctr_cb.bg_dev_list, 0, (sizeof(tBTM_LE_BG_CONN_DEV)*BTM_BLE_MAX_BG_CONN_DEV_NUM)); - gatt_reset_bgdev_list(); -#endif - } -} - -/******************************************************************************* -** -** Function btm_continue_reset -** -** Description This function is called when wait period expired after -** device reset or called by the application to continue -** initialization after the application has completed its -** vendor specific sequence. -** -** Returns void -** -*******************************************************************************/ -void btm_continue_reset (void) -{ - - /* Reinitialize the default class of device */ -#if BTM_INTERNAL_BB == TRUE - btsnd_hcic_read_bd_addr (); -#if BTM_PWR_MGR_INCLUDED == TRUE - btm_pm_reset(); -#endif -#endif - - btm_get_hci_buf_size (); - - /* default device class */ - BTM_SetDeviceClass((UINT8 *) BTM_INIT_CLASS_OF_DEVICE); - -#if (BTM_MAX_LOC_BD_NAME_LEN > 0) && (BTM_SET_DEV_NAME_UPON_RESET == TRUE) - BTM_SetLocalDeviceName(btm_cb.cfg.bd_name); -#endif - - BTM_SetPinType (btm_cb.cfg.pin_type, btm_cb.cfg.pin_code, btm_cb.cfg.pin_code_len); -} - -/******************************************************************************* -** -** Function btm_after_reset_hold_complete -** -** Description This function is called when wait period expired after -** device reset. Continue intitialization -** -** Returns void -** -*******************************************************************************/ -void btm_after_reset_hold_complete (void) -{ -#ifdef BTM_APP_DEV_INIT - btu_stop_timer(&btm_cb.devcb.reset_timer); - BTM_APP_DEV_INIT(); -#else - btm_continue_reset(); -#endif -} - - -/******************************************************************************* -** -** Function btm_read_hci_buf_size_complete -** -** Description This function is called when command complete for -** get HCI buffer size is received. Start timer and send -** read local features request -** -** Returns void -** -*******************************************************************************/ -void btm_read_hci_buf_size_complete (UINT8 *p, UINT16 evt_len) -{ - UINT8 status; - UINT8 lm_sco_buf_size; - UINT16 lm_num_acl_bufs; - UINT16 lm_num_sco_bufs; - UINT16 acl_buf_size; - UNUSED(evt_len); - - STREAM_TO_UINT8 (status, p); - if (status == HCI_SUCCESS) - { - STREAM_TO_UINT16 (btu_cb.hcit_acl_data_size, p); - STREAM_TO_UINT8 (lm_sco_buf_size, p); - STREAM_TO_UINT16 (lm_num_acl_bufs, p); - STREAM_TO_UINT16 (lm_num_sco_bufs, p); - - btu_cb.hcit_acl_pkt_size = btu_cb.hcit_acl_data_size + HCI_DATA_PREAMBLE_SIZE; - - l2c_link_processs_num_bufs (lm_num_acl_bufs); - -#if BTM_ACL_BUF_SIZE > 0 - acl_buf_size = (BTM_ACL_BUF_SIZE < L2CAP_MTU_SIZE) ? BTM_ACL_BUF_SIZE : L2CAP_MTU_SIZE; -#else - acl_buf_size = L2CAP_MTU_SIZE; -#endif - /* Tell the controller what our buffer sizes are. ?? Need SCO info */ - btsnd_hcic_set_host_buf_size (acl_buf_size, BTM_SCO_HOST_BUF_SIZE, L2CAP_HOST_FC_ACL_BUFS, 10); - -#if L2CAP_HOST_FLOW_CTRL == TRUE - btsnd_hcic_set_host_flow_ctrl (HCI_HOST_FLOW_CTRL_ACL_ON); -#endif - } - - /* Set the device into connectable and/or discoverable mode (if configured to do so) */ -#if BTM_IS_CONNECTABLE == TRUE - (void) BTM_SetConnectability (BTM_CONNECTABLE, BTM_DEFAULT_CONN_WINDOW, BTM_DEFAULT_CONN_INTERVAL); -#endif - -#if BTM_IS_DISCOVERABLE == TRUE - (void) BTM_SetDiscoverability (BTM_DEFAULT_DISC_MODE, BTM_DEFAULT_DISC_WINDOW, BTM_DEFAULT_DISC_INTERVAL); -#endif - -#if BTM_INTERNAL_BB == TRUE - { - UINT8 buf[9] = BTM_INTERNAL_LOCAL_VER; - btm_read_local_version_complete( buf, 9 ); - } -#else - btm_get_local_version (); -#endif -} - -#if (BLE_INCLUDED == TRUE) -/******************************************************************************* -** -** Function btm_read_ble_buf_size_complete -** -** Description This function is called when command complete for -** get HCI buffer size is received. Start timer and send -** read local supported features request -** -** Returns void -** -*******************************************************************************/ -void btm_read_ble_buf_size_complete (UINT8 *p, UINT16 evt_len) -{ - UINT8 status; - UINT16 lm_num_le_bufs; - UNUSED(evt_len); - - BTM_TRACE_DEBUG("btm_read_ble_buf_size_complete "); - STREAM_TO_UINT8 (status, p); - if (status == HCI_SUCCESS) - { - STREAM_TO_UINT16 (btu_cb.hcit_ble_acl_data_size, p); - STREAM_TO_UINT8 (lm_num_le_bufs, p); - - if (btu_cb.hcit_ble_acl_data_size == 0) - btu_cb.hcit_ble_acl_data_size = btu_cb.hcit_acl_data_size; - - btu_cb.hcit_ble_acl_pkt_size = btu_cb.hcit_ble_acl_data_size + HCI_DATA_PREAMBLE_SIZE; - - l2c_link_processs_ble_num_bufs (lm_num_le_bufs); - } - btm_read_ble_local_supported_states(); -} -/******************************************************************************* -** -** Function btm_read_ble_local_supported_states_complete -** -** Description This function is called when command complete for -** Read LE Local Supported states complete is received. -** -** Returns void -** -*******************************************************************************/ -void btm_read_ble_local_supported_states_complete (UINT8 *p, UINT16 evt_len) -{ - UINT8 status; - - UNUSED(evt_len); - BTM_TRACE_DEBUG("btm_read_ble_local_supported_states_complete "); - - btu_stop_timer (&btm_cb.devcb.reset_timer); - - STREAM_TO_UINT8 (status, p); - if (status == HCI_SUCCESS) - { - STREAM_TO_ARRAY(&btm_cb.devcb.le_supported_states, p, BTM_LE_SUPPORT_STATE_SIZE); - } - else - { - BTM_TRACE_WARNING ("btm_read_ble_local_supported_features_complete status = %d", status); - } - - btm_read_ble_local_supported_features(); -} - -/******************************************************************************* -** -** Function btm_read_ble_local_supported_features_complete -** -** Description This function is called when command complete for -** Read LE Local Supported Features is received. Start timer and send -** read LMP local features request -** -** Returns void -** -*******************************************************************************/ -void btm_read_ble_local_supported_features_complete (UINT8 *p, UINT16 evt_len) -{ - UINT8 status; - UNUSED(evt_len); - - BTM_TRACE_DEBUG("btm_read_ble_local_supported_features_complete "); - - btu_stop_timer (&btm_cb.devcb.reset_timer); - - STREAM_TO_UINT8 (status, p); - if (status == HCI_SUCCESS) - { - STREAM_TO_ARRAY(&btm_cb.devcb.local_le_features, p, HCI_FEATURE_BYTES_PER_PAGE); - } - else - { - BTM_TRACE_WARNING ("btm_read_ble_local_supported_features_complete status = %d", status); - } - - btsnd_hcic_ble_set_evt_mask((UINT8 *)HCI_BLE_EVENT_MASK_DEF); - -#if BTM_INTERNAL_BB == TRUE - { - UINT8 buf[9] = BTM_INTERNAL_LOCAL_FEA; - btm_read_local_features_complete( buf, 9 ); - } -#else - - /* get local feature if BRCM specific feature is not included */ - btm_reset_ctrlr_complete(); -#endif - -} - -/******************************************************************************* -** -** Function btm_read_white_list_size_complete -** -** Description This function read the current white list size. -*******************************************************************************/ -void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len) -{ - UINT8 status; - UNUSED(evt_len); - - BTM_TRACE_DEBUG("btm_read_white_list_size_complete "); - STREAM_TO_UINT8 (status, p); - - if (status == HCI_SUCCESS) - { - STREAM_TO_UINT8(btm_cb.ble_ctr_cb.max_filter_entries, p); - btm_cb.ble_ctr_cb.num_empty_filter = btm_cb.ble_ctr_cb.max_filter_entries; - } - /* write LE host support and simultatunous LE supported */ - btsnd_hcic_ble_write_host_supported(BTM_BLE_HOST_SUPPORT, BTM_BLE_SIMULTANEOUS_HOST); - - btm_get_ble_buffer_size(); -} - -#endif -/******************************************************************************* -** -** Function btm_read_local_version_complete -** -** Description This function is called when local BD Addr read complete -** message is received from the HCI. -** -** Returns void -** -*******************************************************************************/ -void btm_read_local_version_complete (UINT8 *p, UINT16 evt_len) -{ - tBTM_VERSION_INFO *p_vi = &btm_cb.devcb.local_version; - UINT8 status; - UNUSED(evt_len); - -#ifdef BTA_PRM_CHECK_FW_VER - if(BTA_PRM_CHECK_FW_VER(p)) - return; -#endif - - STREAM_TO_UINT8 (status, p); - if (status == HCI_SUCCESS) - { - - STREAM_TO_UINT8 (p_vi->hci_version, p); - STREAM_TO_UINT16 (p_vi->hci_revision, p); - STREAM_TO_UINT8 (p_vi->lmp_version, p); - STREAM_TO_UINT16 (p_vi->manufacturer, p); - STREAM_TO_UINT16 (p_vi->lmp_subversion, p); - } - - if (p_vi->hci_version >= HCI_PROTO_VERSION_1_2) - { - btm_read_local_supported_cmds(LOCAL_BR_EDR_CONTROLLER_ID); - } - else - { - btm_get_local_features (); - } -} - -/******************************************************************************* -** ** Function btm_decode_ext_features_page ** ** Description This function is decodes a features page. @@ -985,6 +252,9 @@ void btm_read_local_version_complete (UINT8 *p, UINT16 evt_len) *******************************************************************************/ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_features) { + UINT8 last; + UINT8 first; + BTM_TRACE_DEBUG ("btm_decode_ext_features_page page: %d", page_number); switch (page_number) { @@ -1003,37 +273,32 @@ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_feat btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH5 + BTM_ACL_PKT_TYPES_MASK_DM5); - /* _NO_X_DXX masks are reserved before ver 2.0. - Set them only for later versions of controller */ - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) + /* Add in EDR related ACL types */ + if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features)) { - /* Add in EDR related ACL types */ - if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features)) - { - btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + - BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + - BTM_ACL_PKT_TYPES_MASK_NO_2_DH5); - } + btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + + BTM_ACL_PKT_TYPES_MASK_NO_2_DH5); + } - if (!HCI_EDR_ACL_3MPS_SUPPORTED(p_features)) - { - btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + - BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 + - BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); - } + if (!HCI_EDR_ACL_3MPS_SUPPORTED(p_features)) + { + btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 + + BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); + } - /* Check to see if 3 and 5 slot packets are available */ - if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) || - HCI_EDR_ACL_3MPS_SUPPORTED(p_features)) - { - if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features)) - btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + - BTM_ACL_PKT_TYPES_MASK_NO_3_DH3); + /* Check to see if 3 and 5 slot packets are available */ + if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) || + HCI_EDR_ACL_3MPS_SUPPORTED(p_features)) + { + if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features)) + btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3); - if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features)) - btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 + - BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); - } + if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features)) + btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 + + BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); } BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x", @@ -1159,444 +424,6 @@ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_feat /******************************************************************************* ** -** Function btm_reset_ctrlr_complete -** -** Description This is the last step of BR/EDR controller startup sequence. -** -** Returns void -** -*******************************************************************************/ -void btm_reset_ctrlr_complete () -{ - tBTM_DEVCB *p_devcb = &btm_cb.devcb; - tBTM_CMPL_CB *p_cb = p_devcb->p_reset_cmpl_cb; - BOOLEAN found = FALSE; - UINT8 i, j, max_page_number; - - btu_stop_timer (&btm_cb.devcb.reset_timer); - - /* find the highest feature page number which contains non-zero bits */ - for (i = HCI_EXT_FEATURES_PAGE_MAX; ; i--) - { - for (j = 0; j < HCI_FEATURE_BYTES_PER_PAGE; j++) - { - if (p_devcb->local_lmp_features[i][j] != 0) - { - found = TRUE; - break; - } - } - if (found || !i) - { - break; - } - } - - if (!found) - BTM_TRACE_WARNING ("btm_reset_ctrlr_complete: NONE of local controller features is set"); - - max_page_number = i; - - BTM_TRACE_DEBUG ("btm_reset_ctrlr_complete: max_page_number: %d", max_page_number); - - /* - * Set State to Ready (needs to be done before btm_decode_ext_features_page - * to allow it to send some HCI configuration commands) - */ - p_devcb->state = BTM_DEV_STATE_READY; - - /* For every received/saved feature page */ - for (i = 0; i <= max_page_number; i++) - { - /* Decode the saved Feature Page */ - btm_decode_ext_features_page(i, p_devcb->local_lmp_features[i]); - } - - /* If there was a callback address for reset complete, reset it */ - p_devcb->p_reset_cmpl_cb = NULL; - - /* If anyone wants device status notifications, give him one */ - btm_report_device_status(BTM_DEV_STATUS_UP); - - /* Reset sequence is complete. If this was an application originated */ - /* reset, tell him its done. */ - if (p_cb) - (*p_cb)((void *) NULL); -} - -/******************************************************************************* -** -** Function btm_issue_host_support_for_lmp_features -** -** Description This function: -** - issues commands to set host supported LMP features (one at -** a time); -** - after this is done it issues command to re-read LMP features -** page 1; -** - after this is done it calls the last step of BR/EDR -** controller startup sequence. -** -** Returns void -** -*******************************************************************************/ -static void btm_issue_host_support_for_lmp_features (void) -{ - BTM_TRACE_DEBUG("btm_issue_host_support_for_lmp_features lmp_features_host_may_support: 0x%02x", btm_cb.devcb.lmp_features_host_may_support); - - if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SSP) - { - btsnd_hcic_write_simple_pairing_mode(HCI_SP_MODE_ENABLED); - return; - } - -#if (BLE_INCLUDED == TRUE) - if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_LE) - { - if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SIMULT_BR_LE) - { - btsnd_hcic_ble_write_host_supported(BTM_BLE_HOST_SUPPORT, BTM_BLE_SIMULTANEOUS_HOST); - } - else - { - btsnd_hcic_ble_write_host_supported(BTM_BLE_HOST_SUPPORT, 0); - } - return; - } -#endif - - if (btm_cb.devcb.lmp_features_host_may_support & BTM_RE_READ_1ST_PAGE) - { - btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_1); - return; - } - - if (!btm_cb.devcb.lmp_features_host_may_support) - { -#if BLE_INCLUDED == TRUE - if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) - { - btm_read_ble_wl_size(); - } - else -#elif BTM_INTERNAL_BB == TRUE - { - UINT8 buf[9] = BTM_INTERNAL_LOCAL_FEA; - btm_read_local_features_complete( buf, 9 ); - } -#endif - { - btm_reset_ctrlr_complete(); - } - return; - } - - BTM_TRACE_ERROR("%s lmp_features_host_may_support: 0x%02x. This is unexpected.",__FUNCTION__, - btm_cb.devcb.lmp_features_host_may_support); -} - -/******************************************************************************* -** -** Function btm_set_lmp_features_host_may_support -** -** Description This function is called after all LMP features provided by -** controller are read. It sets the mask that indicates LMP -** features the host may support based on LMP features supported -** by controller. -** Example: -** Host may set SSP (host support) bit only if SSP (controller -** support) bit is set by controller. -** -** Returns void -** -*******************************************************************************/ -static void btm_set_lmp_features_host_may_support (UINT8 max_page_number) -{ - btm_cb.devcb.lmp_features_host_may_support = 0; - - /* LMP page 0 is always read */ - if (HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - { - /* host may support SSP */ - btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_SSP; - } - -#if (BLE_INCLUDED == TRUE) - if (HCI_LE_SPT_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - { - /* host may support LE */ - btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_LE; - - if (HCI_SIMUL_LE_BREDR_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - { - /* host may support BR/EDR and LE simultaneously */ - btm_cb.devcb.lmp_features_host_may_support |= BTM_HOST_MAY_SUPP_SIMULT_BR_LE; - } - } -#endif - - if (max_page_number >= HCI_EXT_FEATURES_PAGE_1) - { - /* nothing yet for HCI_EXT_FEATURES_PAGE_1 */ - } - - if (max_page_number >= HCI_EXT_FEATURES_PAGE_1) - { - /* nothing yet for HCI_EXT_FEATURES_PAGE_2 */ - } - - if (btm_cb.devcb.lmp_features_host_may_support) - btm_cb.devcb.lmp_features_host_may_support |= BTM_RE_READ_1ST_PAGE; -} - -/******************************************************************************* -** -** Function btm_read_all_lmp_features_complete -** -** Description This function is called after all LMP features provided by -** controller are read. -** It works with controller supported LMP features which host -** may support too. -** -** Returns void -** -*******************************************************************************/ -static void btm_read_all_lmp_features_complete (UINT8 max_page_number) -{ - btm_set_lmp_features_host_may_support(max_page_number); - - btm_issue_host_support_for_lmp_features(); -} - -/******************************************************************************* -** -** Function btm_read_local_features_complete -** -** Description This function is called when local supported features read -** is complete. -** -** Returns void -** -*******************************************************************************/ -void btm_read_local_features_complete (UINT8 *p, UINT16 evt_len) -{ - tBTM_DEVCB *p_devcb = &btm_cb.devcb; - UINT8 status; - UNUSED(evt_len); - - btu_stop_timer (&p_devcb->reset_timer); - - STREAM_TO_UINT8 (status, p); - if (status == HCI_SUCCESS) - { - /* Save the Feature Page 0 */ - STREAM_TO_ARRAY(p_devcb->local_lmp_features[0], - p, HCI_FEATURE_BYTES_PER_PAGE); - - if ((HCI_LMP_EXTENDED_SUPPORTED(p_devcb->local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) && - (HCI_READ_LOCAL_EXT_FEATURES_SUPPORTED(p_devcb->supported_cmds))) - { - /* if local controller has extended features and supports - **HCI_Read_Local_Extended_Features command, - ** then start reading these feature starting with extended features page 1 */ - BTM_TRACE_DEBUG ("Start reading local extended features"); - btm_get_local_ext_features(HCI_EXT_FEATURES_PAGE_1); - } - else - { - btm_read_all_lmp_features_complete (HCI_EXT_FEATURES_PAGE_0); - } - } -} - -/******************************************************************************* -** -** Function btm_read_local_ext_features_complete -** -** Description This function is called when read local extended features -** command complete message is received from the HCI. -** -** Returns void -** -*******************************************************************************/ -void btm_read_local_ext_features_complete (UINT8 *p, UINT16 evt_len) -{ - UINT8 status; - UINT8 page_number; - UINT8 page_number_max; - UNUSED(evt_len); - - btu_stop_timer (&btm_cb.devcb.reset_timer); - - STREAM_TO_UINT8 (status, p); - - if (status != HCI_SUCCESS) - { - BTM_TRACE_WARNING("btm_read_local_ext_features_complete status = 0x%02X", status); - btm_read_all_lmp_features_complete (HCI_EXT_FEATURES_PAGE_0); - return; - } - - /* Extract Page number */ - STREAM_TO_UINT8 (page_number, p); - - /* Extract Page number Max */ - STREAM_TO_UINT8 (page_number_max, p); - - if (page_number > HCI_EXT_FEATURES_PAGE_MAX) - { - BTM_TRACE_ERROR("btm_read_local_ext_features_complete page=%d unknown", - page_number); - return; - } - - /* Save the extended features Page received */ - STREAM_TO_ARRAY(btm_cb.devcb.local_lmp_features[page_number], - p, HCI_FEATURE_BYTES_PER_PAGE); - - /* If this is re-read of the 1-st extended page after host supported LMP features are set */ - if ((page_number == HCI_EXT_FEATURES_PAGE_1) && - (btm_cb.devcb.lmp_features_host_may_support == BTM_RE_READ_1ST_PAGE)) - { - btm_cb.devcb.lmp_features_host_may_support &= ~BTM_RE_READ_1ST_PAGE; - btm_issue_host_support_for_lmp_features(); - return; - } - - /* If this is the last page supported by the local BT controller OR */ - /* if this is the last page supported by the Host */ - if ((page_number == page_number_max) || - (page_number == HCI_EXT_FEATURES_PAGE_MAX)) - { - BTM_TRACE_DEBUG("BTM reached last extended features page (%d)", page_number); - btm_read_all_lmp_features_complete(page_number); - } - /* Else (another page must be read) */ - else - { - /* Read the next features page */ - page_number++; - BTM_TRACE_DEBUG("BTM reads next extended features page (%d)", page_number); - btm_get_local_ext_features(page_number); - } -} - -/******************************************************************************* -** -** Function btm_read_local_supported_cmds_complete -** -** Description This function is called when local supported commands read -** is complete. -** -** Returns void -** -*******************************************************************************/ -void btm_read_local_supported_cmds_complete (UINT8 *p) -{ - tBTM_DEVCB *p_devcb = &btm_cb.devcb; - UINT8 status; - - btu_stop_timer (&(p_devcb->reset_timer)); - - STREAM_TO_UINT8 (status, p); - BTM_TRACE_DEBUG("btm_read_local_supported_cmds_complete status (0x%02x)", status); - - if (status == HCI_SUCCESS) - { - /* Save the supported commands bit mask */ - STREAM_TO_ARRAY(p_devcb->supported_cmds, p, HCI_NUM_SUPP_COMMANDS_BYTES); - } - - btm_get_local_features(); -} - -/******************************************************************************* -** -** Function btm_write_simple_paring_mode_complete -** -** Description This function is called when the command complete message -** is received from the HCI for the write simple pairing mode -** command. -** -** Returns void -** -*******************************************************************************/ -void btm_write_simple_paring_mode_complete (UINT8 *p) -{ - UINT8 status; - - STREAM_TO_UINT8 (status, p); - - if (status != HCI_SUCCESS) - { - BTM_TRACE_WARNING("btm_write_simple_paring_mode_complete status: 0x%02x", status); - } - - if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SSP) - { - btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_SSP; - btm_issue_host_support_for_lmp_features(); - } -} - -/******************************************************************************* -** -** Function btm_write_le_host_supported_complete -** -** Description This function is called when the command complete message -** is received from the HCI for the write LE host supported -** command. -** -** Returns void -** -*******************************************************************************/ -void btm_write_le_host_supported_complete (UINT8 *p) -{ - UINT8 status; - - STREAM_TO_UINT8 (status, p); - - if (status != HCI_SUCCESS) - { - BTM_TRACE_WARNING("btm_write_le_host_supported_complete status: 0x%02x", status); - } - - if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_LE) - { - btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_LE; - if (btm_cb.devcb.lmp_features_host_may_support & BTM_HOST_MAY_SUPP_SIMULT_BR_LE) - { - btm_cb.devcb.lmp_features_host_may_support &= ~BTM_HOST_MAY_SUPP_SIMULT_BR_LE; - } - btm_issue_host_support_for_lmp_features(); - } -} - -/******************************************************************************* -** -** Function btm_get_voice_coding_support -** -** Description This function is provides a way to get the voice coding schemes -** supported the device. -** -** Returns A bit mask - Bit 0 if set indicates CVSD support -** Bit 1 if set indicates PCM A-law support -** Bit 2 if set indicates PCM Mu-law support -** -*******************************************************************************/ - -UINT8 btm_get_voice_coding_support( void ) -{ - UINT8 code = 0; - - if( HCI_LMP_CVSD_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x01 ; - if( HCI_LMP_A_LAW_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x02 ; - if( HCI_LMP_U_LAW_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) ) code |= 0x04 ; - - return code ; -} - -/******************************************************************************* -** ** Function BTM_SetLocalDeviceName ** ** Description This function is called to set the local device name. @@ -1611,8 +438,7 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name) if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN)) return (BTM_ILLEGAL_VALUE); - if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT || - btm_cb.devcb.state == BTM_DEV_STATE_WAIT_AFTER_RESET) + if (!controller_get_interface()->get_is_ready()) return (BTM_DEV_RESET); #if BTM_MAX_LOC_BD_NAME_LEN > 0 @@ -1717,87 +543,6 @@ void btm_read_local_name_complete (UINT8 *p, UINT16 evt_len) } } - -/******************************************************************************* -** -** Function BTM_GetLocalDeviceAddr -** -** Description This function is called to read the local device address -** -** Returns void -** the local device address is copied into bd_addr -** -*******************************************************************************/ -void BTM_GetLocalDeviceAddr (BD_ADDR bd_addr) -{ - memcpy (bd_addr, btm_cb.devcb.local_addr, BD_ADDR_LEN); -} - -/******************************************************************************* -** -** Function BTM_ReadLocalDeviceAddr -** -** Description This function is called to read the local device address -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_ReadLocalDeviceAddr (tBTM_CMPL_CB *p_cb) -{ - if(p_cb) - (*p_cb)(btm_cb.devcb.local_addr); - - return (BTM_SUCCESS); -} - - -/******************************************************************************* -** -** Function btm_read_local_addr_complete -** -** Description This function is called when local BD Addr read complete -** message is received from the HCI. -** -** Returns void -** -*******************************************************************************/ -void btm_read_local_addr_complete (UINT8 *p, UINT16 evt_len) -{ - UINT8 status; - UNUSED(evt_len); - - STREAM_TO_UINT8 (status, p); - - if (status == HCI_SUCCESS) - { - STREAM_TO_BDADDR (btm_cb.devcb.local_addr, p); - } -} - - -/******************************************************************************* -** -** Function BTM_ReadLocalVersion -** -** Description This function is called to read the local device version -** -** Returns status of the operation -** -*******************************************************************************/ -tBTM_STATUS BTM_ReadLocalVersion (tBTM_VERSION_INFO *p_vers) -{ - /* Make sure the device has retrieved the info (not being reset) */ - if (btm_cb.devcb.state < BTM_DEV_STATE_READY) - return (BTM_DEV_RESET); - - *p_vers = btm_cb.devcb.local_version; - - return (BTM_SUCCESS); -} - - - - /******************************************************************************* ** ** Function BTM_SetDeviceClass @@ -1814,8 +559,7 @@ tBTM_STATUS BTM_SetDeviceClass (DEV_CLASS dev_class) memcpy (btm_cb.devcb.dev_class, dev_class, DEV_CLASS_LEN); - if (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT || - btm_cb.devcb.state == BTM_DEV_STATE_WAIT_AFTER_RESET) + if (!controller_get_interface()->get_is_ready()) return (BTM_DEV_RESET); if (!btsnd_hcic_write_dev_class (dev_class)) @@ -1849,43 +593,11 @@ UINT8 *BTM_ReadDeviceClass (void) ** Returns pointer to the local features string ** *******************************************************************************/ +// TODO(zachoverflow): get rid of this function UINT8 *BTM_ReadLocalFeatures (void) { - return (btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]); -} - -/******************************************************************************* -** -** Function BTM_ReadLocalExtendedFeatures -** -** Description This function is called to read the local extended features -** -** Returns pointer to the local extended features mask or NULL if bad -** page -** -*******************************************************************************/ -UINT8 *BTM_ReadLocalExtendedFeatures (UINT8 page_number) -{ - if (page_number <= HCI_EXT_FEATURES_PAGE_MAX) - return (btm_cb.devcb.local_lmp_features[page_number]); - - BTM_TRACE_ERROR("Warning: BTM_ReadLocalExtendedFeatures page %d unknown", - page_number); - return NULL; -} - -/******************************************************************************* -** -** Function BTM_ReadBrcmFeatures -** -** Description This function is called to read the Broadcom specific features -** -** Returns pointer to the Broadcom features string -** -*******************************************************************************/ -UINT8 *BTM_ReadBrcmFeatures (void) -{ - return (btm_cb.devcb.brcm_features); + // Discarding const modifier for now, until this function dies + return (UINT8 *)controller_get_interface()->get_features_classic(0)->as_array; } /******************************************************************************* @@ -2157,11 +869,11 @@ tBTM_STATUS BTM_EnableTestMode(void) } /* mask off all of event from controller */ - if (!btsnd_hcic_set_event_mask(LOCAL_BR_EDR_CONTROLLER_ID, - (UINT8 *)"\x00\x00\x00\x00\x00\x00\x00\x00")) - { - return BTM_NO_RESOURCES; - } + hci_layer_get_interface()->transmit_command( + hci_packet_factory_get_interface()->make_set_event_mask((const bt_event_mask_t *)("\x00\x00\x00\x00\x00\x00\x00\x00")), + NULL, + NULL, + NULL); /* Send the HCI command */ if (btsnd_hcic_enable_test_mode ()) @@ -2172,106 +884,6 @@ tBTM_STATUS BTM_EnableTestMode(void) /******************************************************************************* ** -** Function btm_get_hci_version -** -** Description Local function called to retrieve the current HCI version -** -** Returns Bluetooth HCI Version returned by the controller -** -*******************************************************************************/ -UINT8 btm_get_hci_version (void) -{ - return (btm_cb.devcb.local_version.hci_version); -} - - - -/******************************************************************************* -** -** Function BTM_ReadStoredLinkKey -** -** Description This function is called to obtain link key for the specified -** device from the NVRAM storage attached to the Bluetooth -** controller. -** -** Parameters: bd_addr - Address of the device -** p_cb - Call back function to be called to return -** the results -** -*******************************************************************************/ -tBTM_STATUS BTM_ReadStoredLinkKey (BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb) -{ - BD_ADDR local_bd_addr; - BOOLEAN read_all_flag = FALSE; - - /* Check if the previous command is completed */ - if (btm_cb.devcb.p_stored_link_key_cmpl_cb) - return (BTM_BUSY); - - if (!bd_addr) - { - /* This is to read all the link keys */ - read_all_flag = TRUE; - - /* We don't care the BD address. Just pass a non zero pointer */ - bd_addr = local_bd_addr; - } - - BTM_TRACE_EVENT ("BTM: BTM_ReadStoredLinkKey: Read_All: %s", - read_all_flag ? "TRUE" : "FALSE"); - - /* Send the HCI command */ - btm_cb.devcb.p_stored_link_key_cmpl_cb = p_cb; - if (btsnd_hcic_read_stored_key (bd_addr, read_all_flag)) - return (BTM_SUCCESS); - else - return (BTM_NO_RESOURCES); - -} - - -/******************************************************************************* -** -** Function BTM_WriteStoredLinkKey -** -** Description This function is called to write link keys for the specified -** device addresses to the NVRAM storage attached to the Bluetooth -** controller. -** -** Parameters: num_keys - Number of link keys -** bd_addr - Addresses of the devices -** link_key - Link Keys to be stored -** p_cb - Call back function to be called to return -** the results -** -*******************************************************************************/ -tBTM_STATUS BTM_WriteStoredLinkKey (UINT8 num_keys, - BD_ADDR *bd_addr, - LINK_KEY *link_key, - tBTM_CMPL_CB *p_cb) -{ - /* Check if the previous command is completed */ - if (btm_cb.devcb.p_stored_link_key_cmpl_cb) - return (BTM_BUSY); - - BTM_TRACE_EVENT ("BTM: BTM_WriteStoredLinkKey: num_keys: %d", num_keys); - - /* Check the maximum number of link keys */ - if(num_keys > HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD) - num_keys = HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD; - - /* Send the HCI command */ - btm_cb.devcb.p_stored_link_key_cmpl_cb = p_cb; - if (btsnd_hcic_write_stored_key (num_keys, bd_addr, link_key)) - return (BTM_SUCCESS); - else - return (BTM_NO_RESOURCES); - -} - - -/******************************************************************************* -** ** Function BTM_DeleteStoredLinkKey ** ** Description This function is called to delete link key for the specified @@ -2314,82 +926,6 @@ tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb) return (BTM_SUCCESS); } - -/******************************************************************************* -** -** Function btm_read_stored_link_key_complete -** -** Description This function is called when the command complete message -** is received from the HCI for the read stored link key command. -** -** Returns void -** -*******************************************************************************/ -void btm_read_stored_link_key_complete (UINT8 *p) -{ - tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_stored_link_key_cmpl_cb; - tBTM_READ_STORED_LINK_KEY_COMPLETE result; - - /* If there was a callback registered for read stored link key, call it */ - btm_cb.devcb.p_stored_link_key_cmpl_cb = NULL; - - if (p_cb) - { - /* Set the call back event to indicate command complete */ - result.event = BTM_CB_EVT_READ_STORED_LINK_KEYS; - - /* Extract the result fields from the HCI event if status is success */ - STREAM_TO_UINT8 (result.status, p); - if (result.status == HCI_SUCCESS) - { - STREAM_TO_UINT16 (result.max_keys, p); - STREAM_TO_UINT16 (result.read_keys, p); - } - else - { - BTM_TRACE_WARNING("Read stored link key status %d", result.status); - result.max_keys = 0; - result.read_keys = 0; - } - /* Call the call back and pass the result */ - (*p_cb)(&result); - } -} - - -/******************************************************************************* -** -** Function btm_write_stored_link_key_complete -** -** Description This function is called when the command complete message -** is received from the HCI for the write stored link key command. -** -** Returns void -** -*******************************************************************************/ -void btm_write_stored_link_key_complete (UINT8 *p) -{ - tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_stored_link_key_cmpl_cb; - tBTM_WRITE_STORED_LINK_KEY_COMPLETE result; - - /* If there was a callback registered for read stored link key, call it */ - btm_cb.devcb.p_stored_link_key_cmpl_cb = NULL; - - if (p_cb) - { - /* Set the call back event to indicate command complete */ - result.event = BTM_CB_EVT_WRITE_STORED_LINK_KEYS; - - /* Extract the result fields from the HCI event */ - STREAM_TO_UINT8 (result.status, p); - STREAM_TO_UINT8 (result.num_keys, p); - - /* Call the call back and pass the result */ - (*p_cb)(&result); - } -} - - /******************************************************************************* ** ** Function btm_delete_stored_link_key_complete @@ -2422,49 +958,6 @@ void btm_delete_stored_link_key_complete (UINT8 *p) } } - -/******************************************************************************* -** -** Function btm_return_link_keys_evt -** -** Description This function is called when the return link keys event -** is received from the HCI for the read stored link key command. -** -** Returns void -** -*******************************************************************************/ -void btm_return_link_keys_evt (tBTM_RETURN_LINK_KEYS_EVT *result) -{ - tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_stored_link_key_cmpl_cb; - UINT8 i, *p, *p1; - UINT8 bd_addr[BD_ADDR_LEN]; - UINT8 link_key[LINK_KEY_LEN]; - - /* Call the call back to pass the link keys to application */ - if (p_cb) - { - /* Change the BD addr and Link key in to big endian order */ - p = (UINT8 *)(result + 1); - for (i=0; i<result->num_keys; i++) - { - /* Initialize the backup pointer */ - p1 = p; - - /* Extract the BD Addr and Link Key */ - REVERSE_STREAM_TO_ARRAY(bd_addr, p1, BD_ADDR_LEN); - REVERSE_STREAM_TO_ARRAY(link_key, p1, LINK_KEY_LEN); - - /* Write the BD Addr and Link Key back in big endian format */ - ARRAY_TO_STREAM(p, bd_addr, BD_ADDR_LEN); - ARRAY_TO_STREAM(p, link_key, LINK_KEY_LEN); - } - - (*p_cb)(result); - } -} - - - /******************************************************************************* ** ** Function btm_report_device_status diff --git a/stack/btm/btm_inq.c b/stack/btm/btm_inq.c index 4cabf25fc..5311436c2 100644 --- a/stack/btm/btm_inq.c +++ b/stack/btm/btm_inq.c @@ -31,6 +31,7 @@ #include <stddef.h> #include "bt_types.h" +#include "device/include/controller.h" #include "gki.h" #include "hcimsgs.h" #include "btu.h" @@ -50,8 +51,6 @@ static const LAP general_inq_lap = {0x9e,0x8b,0x33}; static const LAP limited_inq_lap = {0x9e,0x8b,0x00}; -#if (( BTM_EIR_CLIENT_INCLUDED == TRUE )||( BTM_EIR_SERVER_INCLUDED == TRUE )) -#ifndef BTM_EIR_UUID_LKUP_TBL const UINT16 BTM_EIR_UUID_LKUP_TBL[BTM_EIR_MAX_SERVICES] = { UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER, @@ -124,20 +123,6 @@ const UINT16 BTM_EIR_UUID_LKUP_TBL[BTM_EIR_MAX_SERVICES] = UUID_SERVCLASS_HDP_SOURCE, UUID_SERVCLASS_HDP_SINK }; -#else -/* -If customized UUID look-up table needs to be used, -the followings should be defined in bdroid_buildcfg.h. -BTM_EIR_UUID_LKUP_TBL = <customized UUID list> -BTM_EIR_MAX_SERVICES = <number of UUID in list> -*/ -#if (BTM_EIR_MAX_SERVICES == 0) -const UINT16 BTM_EIR_UUID_LKUP_TBL[]; -#else -extern UINT16 BTM_EIR_UUID_LKUP_TBL[BTM_EIR_MAX_SERVICES]; -#endif -#endif -#endif /* BTM_EIR_UUID_LKUP_TBL*/ /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ @@ -146,15 +131,11 @@ static void btm_initiate_inquiry (tBTM_INQUIRY_VAR_ST *p_inq); static tBTM_STATUS btm_set_inq_event_filter (UINT8 filter_cond_type, tBTM_INQ_FILT_COND *p_filt_cond); static void btm_clr_inq_result_flt (void); -#if ((BTM_EIR_SERVER_INCLUDED == TRUE)||(BTM_EIR_CLIENT_INCLUDED == TRUE)) static UINT8 btm_convert_uuid_to_eir_service( UINT16 uuid16 ); -#endif -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) static void btm_set_eir_uuid( UINT8 *p_eir, tBTM_INQ_RESULTS *p_results ); static UINT8 *btm_eir_get_uuid_list( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid, UINT8 *p_uuid_list_type ); static UINT16 btm_convert_uuid_to_uuid16( UINT8 *p_uuid, UINT8 uuid_size ); -#endif /******************************************************************************* ** @@ -185,7 +166,7 @@ tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window, UINT16 inter BTM_TRACE_API ("BTM_SetDiscoverability"); #if (BLE_INCLUDED == TRUE && BLE_INCLUDED == TRUE) - if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (controller_get_interface()->supports_ble()) { if (btm_ble_set_discoverability((UINT16)(inq_mode)) == BTM_SUCCESS) @@ -202,7 +183,7 @@ tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window, UINT16 inter return (BTM_ILLEGAL_VALUE); /* Make sure the controller is active */ - if (btm_cb.devcb.state < BTM_DEV_STATE_READY) + if (!controller_get_interface()->get_is_ready()) return (BTM_DEV_RESET); /* If the window and/or interval is '0', set to default values */ @@ -316,7 +297,7 @@ tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type) return (BTM_ILLEGAL_VALUE); /* whatever app wants if device is not 1.2 scan type should be STANDARD */ - if (!HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + if (!controller_get_interface()->supports_interlaced_inquiry_scan()) return (BTM_MODE_UNSUPPORTED); /* Check for scan type if configuration has been changed */ @@ -353,7 +334,7 @@ tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type) return (BTM_ILLEGAL_VALUE); /* whatever app wants if device is not 1.2 scan type should be STANDARD */ - if (!HCI_LMP_INTERLACED_PAGE_SCAN_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + if (!controller_get_interface()->supports_interlaced_inquiry_scan()) return (BTM_MODE_UNSUPPORTED); /* Check for scan type if configuration has been changed */ @@ -389,6 +370,7 @@ tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type) *******************************************************************************/ tBTM_STATUS BTM_SetInquiryMode (UINT8 mode) { + const controller_t *controller = controller_get_interface(); BTM_TRACE_API ("BTM_SetInquiryMode"); if (mode == BTM_INQ_RESULT_STANDARD) { @@ -396,16 +378,14 @@ tBTM_STATUS BTM_SetInquiryMode (UINT8 mode) } else if (mode == BTM_INQ_RESULT_WITH_RSSI) { - if (!HCI_LMP_INQ_RSSI_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - return (BTM_MODE_UNSUPPORTED); + if (!controller->supports_rssi_with_inquiry_results()) + return (BTM_MODE_UNSUPPORTED); } -#if (( BTM_EIR_CLIENT_INCLUDED == TRUE )||( BTM_EIR_SERVER_INCLUDED == TRUE )) else if (mode == BTM_INQ_RESULT_EXTENDED) { - if (!HCI_EXT_INQ_RSP_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + if (!controller->supports_extended_inquiry_response()) return (BTM_MODE_UNSUPPORTED); } -#endif else return (BTM_ILLEGAL_VALUE); @@ -523,14 +503,6 @@ tBTM_STATUS BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms, UINT16 max_d (BTM_LIMITED_INQUIRY_ACTIVE | BTM_PERIODIC_INQUIRY_ACTIVE) : (BTM_GENERAL_INQUIRY_ACTIVE | BTM_PERIODIC_INQUIRY_ACTIVE)); -#if (defined(BTM_BYPASS_EVENT_FILTERING) && BTM_BYPASS_EVENT_FILTERING == TRUE) - BTM_TRACE_WARNING("BTM: Bypassing event filtering..."); - - p_inq->state = BTM_INQ_ACTIVE_STATE; - p_inq->inqfilt_active = FALSE; - btm_initiate_inquiry (p_inq); - status = BTM_CMD_STARTED; -#else /* If a filter is specified, then save it for later and clear the current filter. The setting of the filter is done upon completion of clearing of the previous filter. @@ -552,7 +524,6 @@ tBTM_STATUS BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms, UINT16 max_d } -#endif return (status); } @@ -622,7 +593,7 @@ tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window, UINT16 inter BTM_TRACE_API ("BTM_SetConnectability"); #if (BLE_INCLUDED == TRUE && BLE_INCLUDED == TRUE) - if (HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (controller_get_interface()->supports_ble()) { if (btm_ble_set_connectability(page_mode) != BTM_SUCCESS) { @@ -639,7 +610,7 @@ tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window, UINT16 inter return (BTM_ILLEGAL_VALUE); /* Make sure the controller is active */ - if (btm_cb.devcb.state < BTM_DEV_STATE_READY) + if (!controller_get_interface()->get_is_ready()) return (BTM_DEV_RESET); /* If the window and/or interval is '0', set to default values */ @@ -803,12 +774,10 @@ tBTM_STATUS BTM_CancelInquiry(void) #endif } -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) /* Do not send the BUSY_LEVEL event yet. Wait for the cancel_complete event * and then send the BUSY_LEVEL event * btm_acl_update_busy_level (BTM_BLI_INQ_DONE_EVT); */ -#endif p_inq->inq_counter++; btm_clr_inq_result_flt(); @@ -946,7 +915,7 @@ tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, tBTM_INQ_RESULTS_CB *p BTM_TRACE_API("BTM:Starting LE Scan with duration %d and activeMode:0x%02x", p_inqparms->duration, (p_inqparms->mode & BTM_BLE_INQUIRY_MASK)); #endif - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) { p_inq->inqparms.mode &= ~ BTM_BLE_INQUIRY_MASK; status = BTM_ILLEGAL_VALUE; @@ -997,12 +966,6 @@ tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, tBTM_INQ_RESULTS_CB *p { p_inq->inq_active = (p_inqparms->mode & BTM_BR_INQUIRY_MASK); #endif -#if (defined(BTM_BYPASS_EVENT_FILTERING) && BTM_BYPASS_EVENT_FILTERING == TRUE) - BTM_TRACE_WARNING("BTM: Bypassing event filtering..."); - p_inq->inqfilt_active = FALSE; - btm_initiate_inquiry (p_inq); - status = BTM_CMD_STARTED; -#else /* If a filter is specified, then save it for later and clear the current filter. The setting of the filter is done upon completion of clearing of the previous filter. @@ -1030,7 +993,6 @@ tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, tBTM_INQ_RESULTS_CB *p if ((status = btm_set_inq_event_filter (p_inqparms->filter_cond_type, &p_inqparms->filter_cond)) != BTM_CMD_STARTED) p_inq->state = BTM_INQ_INACTIVE_STATE; -#endif #if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE) if (p_inq->next_state==BTM_NO_INTERLEAVING) @@ -1093,10 +1055,6 @@ tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb if ((p_i = btm_inq_db_find (remote_bda)) != NULL) { p_cur = &p_i->inq_info; - -#if (BTM_INQ_GET_REMOTE_NAME == TRUE) - p_cur->remote_name_state = BTM_INQ_RMT_NAME_EMPTY; -#endif } BTM_TRACE_API ("no device found in inquiry db"); @@ -1158,71 +1116,6 @@ tBTM_STATUS BTM_CancelRemoteDeviceName (void) /******************************************************************************* ** -** Function BTM_InqFirstResult -** -** Description This function looks through the inquiry database for the first -** used entrysince the LAST inquiry. This is used in conjunction -** with BTM_InqNext by applications as a way to walk through the -** inquiry results database. -** -** Returns pointer to first in-use entry, or NULL if DB is empty -** -*******************************************************************************/ -tBTM_INQ_INFO *BTM_InqFirstResult (void) -{ - UINT16 xx; - tINQ_DB_ENT *p_ent = btm_cb.btm_inq_vars.inq_db; - UINT32 cur_inq_count = btm_cb.btm_inq_vars.inq_counter - 1; - - for (xx = 0; xx < BTM_INQ_DB_SIZE; xx++, p_ent++) - { - if (p_ent->in_use && p_ent->inq_count == cur_inq_count) - return (&p_ent->inq_info); - } - - /* If here, no used entry found */ - return ((tBTM_INQ_INFO *)NULL); -} - - -/******************************************************************************* -** -** Function BTM_InqNextResult -** -** Description This function looks through the inquiry database for the next -** used entrysince the LAST inquiry. If the input parameter is NULL, -** the first entry is returned. -** -** Returns pointer to next in-use entry, or NULL if no more found. -** -*******************************************************************************/ -tBTM_INQ_INFO *BTM_InqNextResult (tBTM_INQ_INFO *p_cur) -{ - tINQ_DB_ENT *p_ent; - UINT16 inx; - UINT32 cur_inq_count = btm_cb.btm_inq_vars.inq_counter - 1; - - if (p_cur) - { - p_ent = (tINQ_DB_ENT *) ((UINT8 *)p_cur - offsetof (tINQ_DB_ENT, inq_info)); - inx = (UINT16)((p_ent - btm_cb.btm_inq_vars.inq_db) + 1); - - for (p_ent = &btm_cb.btm_inq_vars.inq_db[inx]; inx < BTM_INQ_DB_SIZE; inx++, p_ent++) - { - if (p_ent->in_use && p_ent->inq_count == cur_inq_count) - return (&p_ent->inq_info); - } - - /* If here, more entries found */ - return ((tBTM_INQ_INFO *)NULL); - } - else - return (BTM_InqDbFirst()); -} - - -/******************************************************************************* -** ** Function BTM_InqDbRead ** ** Description This function looks through the inquiry database for a match @@ -1234,20 +1127,14 @@ tBTM_INQ_INFO *BTM_InqNextResult (tBTM_INQ_INFO *p_cur) *******************************************************************************/ tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda) { - UINT16 xx; - tINQ_DB_ENT *p_ent = btm_cb.btm_inq_vars.inq_db; - BTM_TRACE_API ("BTM_InqDbRead: bd addr [%02x%02x%02x%02x%02x%02x]", p_bda[0], p_bda[1], p_bda[2], p_bda[3], p_bda[4], p_bda[5]); - for (xx = 0; xx < BTM_INQ_DB_SIZE; xx++, p_ent++) - { - if ((p_ent->in_use) && (!memcmp (p_ent->inq_info.results.remote_bd_addr, p_bda, BD_ADDR_LEN))) - return (&p_ent->inq_info); - } + tINQ_DB_ENT *p_ent = btm_inq_db_find(p_bda); + if (!p_ent) + return NULL; - /* If here, not found */ - return ((tBTM_INQ_INFO *)NULL); + return &p_ent->inq_info; } @@ -1342,67 +1229,6 @@ tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda) return (BTM_SUCCESS); } - -/******************************************************************************* -** -** Function BTM_ReadNumInqDbEntries -** -** Returns This function returns the number of entries in the inquiry database. -** -*******************************************************************************/ -UINT8 BTM_ReadNumInqDbEntries (void) -{ - UINT8 num_entries; - UINT8 num_results; - tINQ_DB_ENT *p_ent = btm_cb.btm_inq_vars.inq_db; - - for (num_entries = 0, num_results = 0; num_entries < BTM_INQ_DB_SIZE; num_entries++, p_ent++) - { - if (p_ent->in_use) - num_results++; - } - - return (num_results); -} - - -/******************************************************************************* -** -** Function BTM_InquiryRegisterForChanges -** -** Returns This function is called to register a callback for when the -** inquiry database changes, i.e. new entry or entry deleted. -** -*******************************************************************************/ -tBTM_STATUS BTM_InquiryRegisterForChanges (tBTM_INQ_DB_CHANGE_CB *p_cb) -{ - if (!p_cb) - btm_cb.btm_inq_vars.p_inq_change_cb = NULL; - else if (btm_cb.btm_inq_vars.p_inq_change_cb) - return (BTM_BUSY); - else - btm_cb.btm_inq_vars.p_inq_change_cb = p_cb; - - return (BTM_SUCCESS); -} - - -/******************************************************************************* -** -** Function BTM_SetInquiryFilterCallback -** -** Description Host can register to be asked whenever an inquiry result -** is received. If host does not like the device no name -** request is issued for the device -** -** Returns void -** -*******************************************************************************/ -void BTM_SetInquiryFilterCallback (tBTM_FILTER_CB *p_callback) -{ - btm_cb.p_inq_filter_cb = p_callback; -} - /******************************************************************************* ** ** Function BTM_ReadInquiryRspTxPower @@ -1433,31 +1259,7 @@ tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb) else return (BTM_CMD_STARTED); } -/******************************************************************************* -** -** Function BTM_WriteInquiryTxPower -** -** Description This command is used to write the inquiry transmit power level -** used to transmit the inquiry (ID) data packets. The Controller -** should use the supported TX power level closest to the Tx_Power -** parameter. -** -** Returns BTM_SUCCESS if successful -** -*******************************************************************************/ -tBTM_STATUS BTM_WriteInquiryTxPower (INT8 tx_power) -{ - tBTM_STATUS status = BTM_SUCCESS; - - if (tx_power < BTM_MIN_INQ_TX_POWER || tx_power > BTM_MAX_INQ_TX_POWER) - { - status = BTM_ILLEGAL_VALUE; - } - else if (!btsnd_hcic_write_inq_tx_power(tx_power)) - status = BTM_NO_RESOURCES; - return status; -} /********************************************************************************* ********************************************************************************** ** ** @@ -1651,12 +1453,6 @@ void btm_clr_inq_db (BD_ADDR p_bda) (!memcmp (p_ent->inq_info.results.remote_bd_addr, p_bda, BD_ADDR_LEN))) { p_ent->in_use = FALSE; -#if (BTM_INQ_GET_REMOTE_NAME == TRUE) - p_ent->inq_info.remote_name_state = BTM_INQ_RMT_NAME_EMPTY; -#endif - - if (btm_cb.btm_inq_vars.p_inq_change_cb) - (*btm_cb.btm_inq_vars.p_inq_change_cb) (&p_ent->inq_info, FALSE); } } } @@ -1679,7 +1475,6 @@ void btm_clr_inq_db (BD_ADDR p_bda) *******************************************************************************/ static void btm_clr_inq_result_flt (void) { -#if BTM_USE_INQ_RESULTS_FILTER == TRUE tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars; if (p_inq->p_bd_db) @@ -1689,7 +1484,6 @@ static void btm_clr_inq_result_flt (void) } p_inq->num_bd_entries = 0; p_inq->max_bd_entries = 0; -#endif } /******************************************************************************* @@ -1704,7 +1498,6 @@ static void btm_clr_inq_result_flt (void) *******************************************************************************/ BOOLEAN btm_inq_find_bdaddr (BD_ADDR p_bda) { -#if BTM_USE_INQ_RESULTS_FILTER == TRUE tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars; tINQ_BDADDR *p_db = &p_inq->p_bd_db[0]; UINT16 xx; @@ -1727,7 +1520,6 @@ BOOLEAN btm_inq_find_bdaddr (BD_ADDR p_bda) p_inq->num_bd_entries++; } -#endif /* If here, New Entry */ return (FALSE); } @@ -1783,10 +1575,6 @@ tINQ_DB_ENT *btm_inq_db_new (BD_ADDR p_bda) memcpy (p_ent->inq_info.results.remote_bd_addr, p_bda, BD_ADDR_LEN); p_ent->in_use = TRUE; -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) - p_ent->inq_info.remote_name_state = BTM_INQ_RMT_NAME_EMPTY; -#endif - return (p_ent); } @@ -1799,19 +1587,10 @@ tINQ_DB_ENT *btm_inq_db_new (BD_ADDR p_bda) /* If here, no free entry found. Return the oldest. */ - /* Before deleting the oldest, if anyone is registered for change */ - /* notifications, then tell him we are deleting an entry. */ - if (btm_cb.btm_inq_vars.p_inq_change_cb) - (*btm_cb.btm_inq_vars.p_inq_change_cb) (&p_old->inq_info, FALSE); - memset (p_old, 0, sizeof (tINQ_DB_ENT)); memcpy (p_old->inq_info.results.remote_bd_addr, p_bda, BD_ADDR_LEN); p_old->in_use = TRUE; -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) - p_old->inq_info.remote_name_state = BTM_INQ_RMT_NAME_EMPTY; -#endif - return (p_old); } @@ -2013,9 +1792,7 @@ static void btm_initiate_inquiry (tBTM_INQUIRY_VAR_ST *p_inq) BTM_TRACE_DEBUG ("btm_initiate_inquiry: inq_active:0x%x state:%d inqfilt_active:%d", btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state, btm_cb.btm_inq_vars.inqfilt_active); #endif -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) btm_acl_update_busy_level (BTM_BLI_INQ_EVT); -#endif if (p_inq->inq_active & BTM_SSP_INQUIRY_ACTIVE) { @@ -2038,7 +1815,6 @@ static void btm_initiate_inquiry (tBTM_INQUIRY_VAR_ST *p_inq) } else { -#if BTM_USE_INQ_RESULTS_FILTER == TRUE btm_clr_inq_result_flt(); /* Allocate memory to hold bd_addrs responding */ @@ -2051,9 +1827,6 @@ static void btm_initiate_inquiry (tBTM_INQUIRY_VAR_ST *p_inq) } if (!btsnd_hcic_inquiry(*lap, p_inqparms->duration, 0)) -#else - if (!btsnd_hcic_inquiry(*lap, p_inqparms->duration, p_inqparms->max_resps)) -#endif /* BTM_USE_INQ_RESULTS_FILTER */ btm_process_inq_complete (BTM_NO_RESOURCES, (UINT8)(p_inqparms->mode & BTM_BR_INQUIRY_MASK)); } } @@ -2090,12 +1863,7 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) UINT8 rssi = 0; DEV_CLASS dc; UINT16 clock_offset; -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) UINT8 *p_eir_data = NULL; -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) - UINT8 remote_name_len; -#endif -#endif #if (BTM_INQ_DEBUG == TRUE) BTM_TRACE_DEBUG ("btm_process_inq_results inq_active:0x%x state:%d inqfilt_active:%d", @@ -2129,7 +1897,6 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) p_i = btm_inq_db_find (bda); -#if BTM_USE_INQ_RESULTS_FILTER == TRUE /* Only process the num_resp is smaller than max_resps. If results are queued to BTU task while canceling inquiry, or when more than one result is in this response, > max_resp @@ -2150,7 +1917,6 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) /* BTM_TRACE_WARNING("INQ RES: Extra Response Received...ignoring"); */ return; } -#endif /* Check if this address has already been processed for this inquiry */ if (btm_inq_find_bdaddr(bda)) @@ -2186,15 +1952,6 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) continue; } - /* Host can be registered to verify comming BDA or DC */ - if (btm_cb.p_inq_filter_cb) - { - if (!(* btm_cb.p_inq_filter_cb) (bda, dc)) - { - continue; - } - } - /* If existing entry, use that, else get a new one (possibly reusing the oldest) */ if (p_i == NULL) { @@ -2208,7 +1965,7 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) */ else if (p_i->inq_count == p_inq->inq_counter #if (BLE_INCLUDED == TRUE ) - && (p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BREDR) + && (p_i->inq_info.results.device_type == BT_DEVICE_TYPE_BREDR) #endif ) is_new = FALSE; @@ -2231,7 +1988,7 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) p_cur->dev_class[2] = dc[2]; p_cur->clock_offset = clock_offset | BTM_CLOCK_OFFSET_VALID; - p_i->time_of_resp = GKI_get_tick_count (); + p_i->time_of_resp = GKI_get_os_tick_count(); if (p_i->inq_count != p_inq->inq_counter) p_inq->inq_cmpl_info.num_resp++; /* A new response was found */ @@ -2248,7 +2005,6 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) #endif p_i->inq_count = p_inq->inq_counter; /* Mark entry for current inquiry */ -#if BTM_USE_INQ_RESULTS_FILTER == TRUE /* If the number of responses found and not unlimited, issue a cancel inquiry */ if (!(p_inq->inq_active & BTM_PERIODIC_INQUIRY_ACTIVE) && p_inq->inqparms.max_resps && @@ -2268,52 +2024,14 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) if ((p_inq->inqparms.mode & BTM_BLE_INQUIRY_MASK) != 0) btm_ble_stop_inquiry(); #endif - - -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) btm_acl_update_busy_level (BTM_BLI_INQ_DONE_EVT); -#endif } -#endif /* Initialize flag to FALSE. This flag is set/used by application */ p_i->inq_info.appl_knows_rem_name = FALSE; } if (is_new || update) { -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) - if( inq_res_mode == BTM_INQ_RESULT_EXTENDED ) - { - if((p_eir_data = BTM_CheckEirData( p, BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, - &remote_name_len )) == NULL) - { - p_eir_data = BTM_CheckEirData( p, BTM_EIR_SHORTENED_LOCAL_NAME_TYPE, - &remote_name_len ); - } - - if( p_eir_data ) - { - if( remote_name_len > BTM_MAX_REM_BD_NAME_LEN ) - remote_name_len = BTM_MAX_REM_BD_NAME_LEN; - - p_i->inq_info.remote_name_len = remote_name_len; - memcpy( p_i->inq_info.remote_name, p_eir_data, p_i->inq_info.remote_name_len ); - p_i->inq_info.remote_name[p_i->inq_info.remote_name_len] = 0; - p_i->inq_info.remote_name_state = BTM_INQ_RMT_NAME_DONE; - } - else - p_i->inq_info.remote_name_state = BTM_INQ_RMT_NAME_EMPTY; - } - else -#endif - { - /* Clear out the device name so that it can be re-read */ - p_i->inq_info.remote_name_state = BTM_INQ_RMT_NAME_EMPTY; - } -#endif /*(BTM_INQ_GET_REMOTE_NAME==TRUE)*/ - -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) if( inq_res_mode == BTM_INQ_RESULT_EXTENDED ) { memset( p_cur->eir_uuid, 0, @@ -2324,19 +2042,10 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode) } else p_eir_data = NULL; -#endif /* If a callback is registered, call it with the results */ if (p_inq_results_cb) -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) (p_inq_results_cb)((tBTM_INQ_RESULTS *) p_cur, p_eir_data); -#else - (p_inq_results_cb)((tBTM_INQ_RESULTS *) p_cur, NULL); -#endif - - /* If anyone is registered for change notifications, then tell him we added an entry. */ - if (p_inq->p_inq_change_cb) - (*p_inq->p_inq_change_cb) (&p_i->inq_info, TRUE); } } } @@ -2400,10 +2109,6 @@ void btm_process_inq_complete (UINT8 status, UINT8 mode) tBTM_CMPL_CB *p_inq_cb = btm_cb.btm_inq_vars.p_inq_cmpl_cb; tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars; -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) - tBTM_INQ_INFO *p_cur; - UINT8 tempstate; -#endif #if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE) /* inquiry inactive case happens when inquiry is cancelled. Make mode 0 for no further inquiries from the current inquiry process @@ -2435,35 +2140,12 @@ void btm_process_inq_complete (UINT8 status, UINT8 mode) BTM_TRACE_DEBUG ("btm_process_inq_complete inq_active:0x%x state:%d inqfilt_active:%d", btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.state, btm_cb.btm_inq_vars.inqfilt_active); #endif -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) btm_acl_update_busy_level (BTM_BLI_INQ_DONE_EVT); -#endif /* Ignore any stray or late complete messages if the inquiry is not active */ if (p_inq->inq_active) { p_inq->inq_cmpl_info.status = (tBTM_STATUS)((status == HCI_SUCCESS) ? BTM_SUCCESS : BTM_ERR_PROCESSING); -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) - if (p_inq->inq_cmpl_info.status == BTM_SUCCESS) - { - for (p_cur = BTM_InqDbFirst(); p_cur; p_cur = BTM_InqDbNext (p_cur)) - { - if (p_cur->remote_name_state == BTM_INQ_RMT_NAME_EMPTY) - { - tempstate = p_cur->remote_name_state; - p_cur->remote_name_state = BTM_INQ_RMT_NAME_PENDING; - - if (btm_initiate_rem_name (p_cur->results.remote_bd_addr, - p_cur, BTM_RMT_NAME_INQ, - BTM_INQ_RMT_NAME_TIMEOUT, NULL) != BTM_CMD_STARTED) - p_cur->remote_name_state = tempstate; - else - return; - } - } - } -#endif - /* Notify caller that the inquiry has completed; (periodic inquiries do not send completion events */ if (!(p_inq->inq_active & BTM_PERIODIC_INQUIRY_ACTIVE) && p_inq->inqparms.mode == 0) { @@ -2475,7 +2157,7 @@ void btm_process_inq_complete (UINT8 status, UINT8 mode) btm_clr_inq_result_flt(); if((p_inq->inq_cmpl_info.status == BTM_SUCCESS) && - HCI_LMP_INQ_RSSI_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + controller_get_interface()->supports_rssi_with_inquiry_results()) { btm_sort_inq_result(); } @@ -2534,9 +2216,7 @@ void btm_process_inq_complete (UINT8 status, UINT8 mode) *******************************************************************************/ void btm_process_cancel_complete(UINT8 status, UINT8 mode) { -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) btm_acl_update_busy_level (BTM_BLI_INQ_CANCEL_EVT); -#endif btm_process_inq_complete(status, mode); } /******************************************************************************* @@ -2619,40 +2299,10 @@ tBTM_STATUS btm_initiate_rem_name (BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, return BTM_NO_RESOURCES; } } - /* If the inquire feature is on */ -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) - - else if (origin == BTM_RMT_NAME_INQ) - { - /* If the database entry exists for the device, use its clock offset */ - if (p_cur) - { - cmd_ok = btsnd_hcic_rmt_name_req (remote_bda, - p_cur->results.page_scan_rep_mode, - p_cur->results.page_scan_mode, - (UINT16)(p_cur->results.clock_offset | - BTM_CLOCK_OFFSET_VALID)); - } - else - { - cmd_ok = FALSE - } - - if (cmd_ok) - return BTM_CMD_STARTED; - else - return BTM_NO_RESOURCES; - } -#endif else { - return BTM_ILLEGAL_VALUE; - - } - - } /******************************************************************************* @@ -2675,14 +2325,6 @@ void btm_process_remote_name (BD_ADDR bda, BD_NAME bdn, UINT16 evt_len, UINT8 hc UINT16 temp_evt_len; -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) - /*** These are only used if part of the Inquiry Process ***/ - tBTM_CMPL_CB *p_inq_cb; - tINQ_DB_ENT *p_i = NULL; - UINT8 *p_n; - tBTM_INQ_INFO *p_cur; -#endif - if (bda != NULL) { BTM_TRACE_EVENT("BDA %02x:%02x:%02x:%02x:%02x:%02x",bda[0], bda[1], @@ -2690,7 +2332,7 @@ void btm_process_remote_name (BD_ADDR bda, BD_NAME bdn, UINT16 evt_len, UINT8 hc bda[4], bda[5]); } - BTM_TRACE_EVENT("Inquire BDA %02x:%02x:%02x:%02x:%02x:%02x",p_inq->remname_bda[0], p_inq->remname_bda[1], + BTM_TRACE_EVENT("Inquire BDA %02x:%02x:%02x:%02x:%02x:%02x",p_inq->remname_bda[0], p_inq->remname_bda[1], p_inq->remname_bda[2], p_inq->remname_bda[3], p_inq->remname_bda[4], p_inq->remname_bda[5]); @@ -2701,7 +2343,7 @@ void btm_process_remote_name (BD_ADDR bda, BD_NAME bdn, UINT16 evt_len, UINT8 hc (((bda != NULL) && (memcmp(bda, p_inq->remname_bda,BD_ADDR_LEN)==0)) || bda == NULL)) - { + { #if BLE_INCLUDED == TRUE if (BTM_UseLeLink(p_inq->remname_bda)) { @@ -2749,98 +2391,6 @@ void btm_process_remote_name (BD_ADDR bda, BD_NAME bdn, UINT16 evt_len, UINT8 hc if (p_cb) (p_cb)((tBTM_REMOTE_DEV_NAME *)&rem_name); } - - -#if (BTM_INQ_GET_REMOTE_NAME==TRUE) - /* If existing entry, update the name */ - if ((bda != NULL) && ((p_i = btm_inq_db_find (bda)) != NULL) - && (hci_status == HCI_SUCCESS)) - { - p_i->inq_info.remote_name_state = BTM_INQ_RMT_NAME_DONE; - p_n = p_i->inq_info.remote_name; - memset(p_n, 0, BTM_MAX_REM_BD_NAME_LEN + 1); - p_i->inq_info.remote_name_len = (rem_name.length < BTM_MAX_REM_BD_NAME_LEN) ? - rem_name.length : BTM_MAX_REM_BD_NAME_LEN; - evt_len = p_i->inq_info.remote_name_len; - p_n1 = (UINT8 *)rem_name.remote_bd_name; - while (evt_len > 0) - { - *p_n++ = *p_n1++; - evt_len--; - } - - if (btm_cb.btm_inq_vars.p_inq_change_cb) - (*btm_cb.btm_inq_vars.p_inq_change_cb) (&p_i->inq_info, TRUE); - } - else - { - if (p_i) - p_i->inq_info.remote_name_state = BTM_INQ_RMT_NAME_FAILED; - else - { - /* Find the entry which is currently doing name request */ - for (p_cur = BTM_InqDbFirst(); p_cur; p_cur = BTM_InqDbNext (p_cur)) - { - if (p_cur->remote_name_state == BTM_INQ_RMT_NAME_PENDING) - { - /* Should be only one */ - p_cur->remote_name_state = BTM_INQ_RMT_NAME_FAILED; - break; - } - } - } - } - - /* If an inquiry is in progress then update other entries */ - if (p_inq->inq_active) - { - /* Check if there are any more entries inquired but not named */ - for (p_cur = BTM_InqDbFirst(); p_cur; p_cur = BTM_InqDbNext (p_cur)) - { - if (p_cur->remote_name_state == BTM_INQ_RMT_NAME_EMPTY) - { - p_cur->remote_name_state = BTM_INQ_RMT_NAME_PENDING; -#if (BLE_INCLUDED == TRUE) - if (BTM_UseLeLink(remote_bda)) - { - if (btm_ble_read_remote_name(remote_bda, p_cur, p_cb) != BTM_CMD_STARTED) - p_cur->remote_name_state = BTM_INQ_RMT_NAME_FAILED; - else - return; - } - else -#endif - { - if (btm_initiate_rem_name (p_cur->results.remote_bd_addr, - p_cur, BTM_RMT_NAME_INQ, - BTM_INQ_RMT_NAME_TIMEOUT, NULL) != BTM_CMD_STARTED) - p_cur->remote_name_state = BTM_INQ_RMT_NAME_FAILED; - else - return; - } - } - } - - /* The inquiry has finished so call the callback for the inquiry */ - p_inq_cb = p_inq->p_inq_cmpl_cb; - p_inq->state = BTM_INQ_INACTIVE_STATE; - p_inq->inq_active = BTM_INQUIRY_INACTIVE; - p_inq->p_inq_cmpl_cb = NULL; - - /* If we have a callback registered for inquiry complete, call it */ - if (p_inq_cb) - (p_inq_cb)((tBTM_INQUIRY_CMPL *) &p_inq->inq_cmpl_info); - - /* In some cases we can not get name of the device once but will be */ - /* able to do it next time. Until we have better solution we will */ - /* try to get name every time */ - for (p_cur = BTM_InqDbFirst(); p_cur; p_cur = BTM_InqDbNext (p_cur)) - { - if (p_cur->remote_name_state == BTM_INQ_RMT_NAME_FAILED) - p_cur->remote_name_state = BTM_INQ_RMT_NAME_EMPTY; - } - } -#endif /* BTM_INQ_GET_REMOTE_NAME == TRUE */ } /******************************************************************************* @@ -2917,8 +2467,7 @@ void btm_read_linq_tx_power_complete(UINT8 *p) *******************************************************************************/ tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff ) { -#if (BTM_EIR_SERVER_INCLUDED == TRUE) - if (HCI_EXT_INQ_RSP_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + if (controller_get_interface()->supports_extended_inquiry_response()) { BTM_TRACE_API("Write Extended Inquiry Response to controller"); btsnd_hcic_write_ext_inquiry_response (p_buff, BTM_EIR_DEFAULT_FEC_REQUIRED); @@ -2929,10 +2478,6 @@ tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff ) GKI_freebuf(p_buff); return BTM_MODE_UNSUPPORTED; } -#else - GKI_freebuf(p_buff); - return BTM_SUCCESS; -#endif } /******************************************************************************* @@ -2950,7 +2495,6 @@ tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff ) *******************************************************************************/ UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length ) { -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) UINT8 *p = p_eir; UINT8 length; UINT8 eir_type; @@ -2972,9 +2516,6 @@ UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length ) *p_length = 0; return NULL; -#else - return NULL; -#endif } /******************************************************************************* @@ -2989,7 +2530,6 @@ UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length ) ** BTM_EIR_MAX_SERVICES - if not found ** *******************************************************************************/ -#if (( BTM_EIR_CLIENT_INCLUDED == TRUE )||( BTM_EIR_SERVER_INCLUDED == TRUE )) static UINT8 btm_convert_uuid_to_eir_service( UINT16 uuid16 ) { UINT8 xx; @@ -3003,7 +2543,6 @@ static UINT8 btm_convert_uuid_to_eir_service( UINT16 uuid16 ) } return BTM_EIR_MAX_SERVICES; } -#endif /******************************************************************************* ** @@ -3020,7 +2559,6 @@ static UINT8 btm_convert_uuid_to_eir_service( UINT16 uuid16 ) *******************************************************************************/ BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ) { -#if ((BTM_EIR_SERVER_INCLUDED == TRUE)||(BTM_EIR_CLIENT_INCLUDED == TRUE)) UINT8 service_id; service_id = btm_convert_uuid_to_eir_service(uuid16); @@ -3028,9 +2566,6 @@ BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ) return( BTM_EIR_HAS_SERVICE( p_eir_uuid, service_id )); else return( FALSE ); -#else - return( FALSE ); -#endif } /******************************************************************************* @@ -3049,7 +2584,6 @@ BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ) *******************************************************************************/ tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results, UINT16 uuid16 ) { -#if ((BTM_EIR_SERVER_INCLUDED == TRUE)||(BTM_EIR_CLIENT_INCLUDED == TRUE)) if( BTM_HasEirService( p_results->eir_uuid, uuid16 )) { return BTM_EIR_FOUND; @@ -3060,9 +2594,6 @@ tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results, UI } else return BTM_EIR_UNKNOWN; -#else - return BTM_EIR_UNKNOWN; -#endif } /******************************************************************************* @@ -3079,13 +2610,11 @@ tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results, UI *******************************************************************************/ void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ) { -#if ((BTM_EIR_SERVER_INCLUDED == TRUE)||(BTM_EIR_CLIENT_INCLUDED == TRUE)) UINT8 service_id; service_id = btm_convert_uuid_to_eir_service(uuid16); if( service_id < BTM_EIR_MAX_SERVICES ) BTM_EIR_SET_SERVICE( p_eir_uuid, service_id ); -#endif } /******************************************************************************* @@ -3102,13 +2631,11 @@ void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ) *******************************************************************************/ void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ) { -#if (BTM_EIR_SERVER_INCLUDED == TRUE) UINT8 service_id; service_id = btm_convert_uuid_to_eir_service(uuid16); if( service_id < BTM_EIR_MAX_SERVICES ) BTM_EIR_CLR_SERVICE( p_eir_uuid, service_id ); -#endif } /******************************************************************************* @@ -3129,7 +2656,6 @@ void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ) UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid, UINT8 **p, UINT8 max_num_uuid16, UINT8 *p_num_uuid16) { -#if (BTM_EIR_SERVER_INCLUDED == TRUE) UINT8 service_index; *p_num_uuid16 = 0; @@ -3151,9 +2677,6 @@ UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid, UINT8 **p, } } return BTM_EIR_COMPLETE_16BITS_UUID_TYPE; -#else - return BTM_EIR_COMPLETE_16BITS_UUID_TYPE; -#endif } /******************************************************************************* @@ -3180,7 +2703,6 @@ UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid, UINT8 **p, UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid, UINT8 *p_uuid_list, UINT8 max_num_uuid) { -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) UINT8 *p_uuid_data; UINT8 type; UINT8 yy, xx; @@ -3231,14 +2753,9 @@ UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid, } return type; -#else - *p_num_uuid = 0; - return 0x00; -#endif } -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) /******************************************************************************* ** ** Function btm_eir_get_uuid_list @@ -3422,5 +2939,3 @@ void btm_set_eir_uuid( UINT8 *p_eir, tBTM_INQ_RESULTS *p_results ) } } } -#endif - diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h index fcb17bb5c..37931e76a 100644 --- a/stack/btm/btm_int.h +++ b/stack/btm/btm_int.h @@ -29,9 +29,7 @@ #include "gki.h" #include "hcidefs.h" -#if RFCOMM_INCLUDED == TRUE #include "rfcdefs.h" -#endif #include "btm_api.h" @@ -69,10 +67,10 @@ typedef char tBTM_LOC_BD_NAME[BTM_MAX_LOC_BD_NAME_LEN + 1]; HCI_PKT_TYPES_MASK_NO_3_DH5) #define BTM_EPR_AVAILABLE(p) ((HCI_ATOMIC_ENCRYPT_SUPPORTED((p)->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]) && \ - HCI_ATOMIC_ENCRYPT_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) \ + HCI_ATOMIC_ENCRYPT_SUPPORTED(controller_get_interface()->get_features_classic(0)->as_array)) \ ? TRUE : FALSE) -#define BTM_IS_BRCM_CONTROLLER() (btm_cb.devcb.local_version.manufacturer == LMP_COMPID_BROADCOM) +#define BTM_IS_BRCM_CONTROLLER() (controller_get_interface()->get_bt_version()->manufacturer == LMP_COMPID_BROADCOM) /* Define the ACL Management control structure */ @@ -80,7 +78,6 @@ typedef struct { UINT16 hci_handle; UINT16 pkt_types_mask; - UINT16 restore_pkt_types; /* when coming in/out of SCO connection restore the packet types */ UINT16 clock_offset; BD_ADDR remote_addr; DEV_CLASS remote_dc; @@ -104,7 +101,6 @@ typedef struct #define BTM_ACL_SWKEY_STATE_ENCRYPTION_ON 4 #define BTM_ACL_SWKEY_STATE_IN_PROGRESS 5 UINT8 switch_role_state; - UINT8 change_key_state; #define BTM_ACL_ENCRYPT_STATE_IDLE 0 #define BTM_ACL_ENCRYPT_STATE_ENCRYPT_OFF 1 /* encryption turning off */ @@ -112,10 +108,6 @@ typedef struct #define BTM_ACL_ENCRYPT_STATE_ENCRYPT_ON 3 /* encryption turning on */ UINT8 encrypt_state; /* overall BTM encryption state */ -#if BTM_PWR_MGR_INCLUDED == FALSE - UINT8 mode; -#endif /* BTM_PWR_MGR_INCLUDED */ - #if BLE_INCLUDED == TRUE tBT_TRANSPORT transport; BD_ADDR conn_addr; /* local device address used for this connection */ @@ -145,14 +137,10 @@ typedef struct tBTM_CMPL_CB *p_stored_link_key_cmpl_cb; /* Read/Write/Delete stored link key */ TIMER_LIST_ENT reset_timer; - tBTM_CMPL_CB *p_reset_cmpl_cb; /* Callback function to be called */ - /* when startup of the device is done */ + TIMER_LIST_ENT rln_timer; tBTM_CMPL_CB *p_rln_cmpl_cb; /* Callback function to be called when */ /* read local name function complete */ - TIMER_LIST_ENT rlinkp_timer; - tBTM_CMPL_CB *p_rlinkp_cmpl_cb; /* Callback function to be called when */ - /* read link policy function completes */ TIMER_LIST_ENT rssi_timer; tBTM_CMPL_CB *p_rssi_cmpl_cb; /* Callback function to be called when */ /* read rssi function completes */ @@ -171,36 +159,21 @@ typedef struct tBTM_CMPL_CB *p_switch_role_cb; /* Callback function to be called when */ /* requested switch role is completed */ - tBTM_CHANGE_KEY_CMPL chg_link_key_ref_data; - tBTM_CMPL_CB *p_chg_link_key_cb; /* Callback function to be called when */ - /* change of link key is completed */ - TIMER_LIST_ENT tx_power_timer; tBTM_CMPL_CB *p_tx_power_cmpl_cb;/* Callback function to be called */ - BD_ADDR local_addr; /* BD_ADDR of the local device */ - tBTM_VERSION_INFO local_version; /* Local Version Information */ DEV_CLASS dev_class; /* Local device class */ - /* Local LMP Extended features mask table for the device */ - BD_FEATURES local_lmp_features[HCI_EXT_FEATURES_PAGE_MAX + 1]; - #if BLE_INCLUDED == TRUE tBTM_CMPL_CB *p_le_test_cmd_cmpl_cb; /* Callback function to be called when LE test mode command has been sent successfully */ BD_ADDR read_tx_pwr_addr; /* read TX power target address */ - BD_FEATURES local_le_features; /* Local LE Supported features mask for the device */ tBTM_BLE_LOCAL_ID_KEYS id_keys; /* local BLE ID keys */ BT_OCTET16 er; /* BLE encryption key */ -#define BTM_LE_SUPPORT_STATE_SIZE 8 -UINT8 le_supported_states[BTM_LE_SUPPORT_STATE_SIZE]; - - - #if BTM_BLE_CONFORMANCE_TESTING == TRUE BOOLEAN no_disc_if_pair_fail; BOOLEAN enable_test_mac_val; @@ -212,23 +185,8 @@ UINT8 le_supported_states[BTM_LE_SUPPORT_STATE_SIZE]; #endif /* BLE_INCLUDED */ -#define BTM_DEV_STATE_WAIT_RESET_CMPLT 0 -#define BTM_DEV_STATE_WAIT_AFTER_RESET 1 -#define BTM_DEV_STATE_READY 2 - - UINT8 state; tBTM_IO_CAP loc_io_caps; /* IO capability of the local device */ tBTM_AUTH_REQ loc_auth_req; /* the auth_req flag */ - BD_FEATURES brcm_features; /* Broadcom specific features bit mask */ -#define BTM_RELOAD_LE_HOST_FEATURE 0x10 - -#define BTM_RE_READ_1ST_PAGE 0x01 /* Set it if you set at least one of "..._HOST_MAY_SUPP_..." bits */ -#define BTM_HOST_MAY_SUPP_SSP 0x02 -#define BTM_HOST_MAY_SUPP_LE 0x04 -#define BTM_HOST_MAY_SUPP_SIMULT_BR_LE 0x08 - UINT8 lmp_features_host_may_support; /* The flags of LMP features host may support via BR/EDR ctrlr + BTM_RE_READ_1ST_PAGE */ - UINT8 supported_cmds[HCI_NUM_SUPP_COMMANDS_BYTES]; /* Supported Commands bit field */ - } tBTM_DEVCB; @@ -246,7 +204,6 @@ UINT8 le_supported_states[BTM_LE_SUPPORT_STATE_SIZE]; #define BTM_MIN_INQ_TX_POWER -70 #define BTM_MAX_INQ_TX_POWER 20 -#if BTM_USE_INQ_RESULTS_FILTER == TRUE typedef struct { UINT32 inq_count; /* Used for determining if a response has already been */ @@ -255,7 +212,6 @@ typedef struct /* the same device. */ BD_ADDR bd_addr; } tINQ_BDADDR; -#endif typedef struct { @@ -313,16 +269,13 @@ typedef struct tBTM_CMPL_CB *p_inq_ble_cmpl_cb; /*completion callback exclusively for LE Observe*/ tBTM_INQ_RESULTS_CB *p_inq_ble_results_cb;/*results callback exclusively for LE observe*/ tBTM_CMPL_CB *p_inqfilter_cmpl_cb; /* Called (if not NULL) after inquiry filter completed */ - tBTM_INQ_DB_CHANGE_CB *p_inq_change_cb; /* Inquiry database changed callback */ UINT32 inq_counter; /* Counter incremented each time an inquiry completes */ /* Used for determining whether or not duplicate devices */ /* have responded to the same inquiry */ TIMER_LIST_ENT inq_timer_ent; -#if BTM_USE_INQ_RESULTS_FILTER == TRUE tINQ_BDADDR *p_bd_db; /* Pointer to memory that holds bdaddrs */ UINT16 num_bd_entries; /* Number of entries in database */ UINT16 max_bd_entries; /* Maximum number of entries that can be stored */ -#endif tINQ_DB_ENT inq_db[BTM_INQ_DB_SIZE]; tBTM_INQ_PARMS inqparms; /* Contains the parameters for the current inquiry */ tBTM_INQUIRY_CMPL inq_cmpl_info; /* Status and number of responses from the last inquiry */ @@ -643,7 +596,6 @@ typedef struct UINT8 def_inq_scan_mode; /* ??? limited/general/none */ } tBTM_CFG; -#if BTM_PWR_MGR_INCLUDED == TRUE enum { BTM_PM_ST_ACTIVE = BTM_PM_STS_ACTIVE, @@ -708,7 +660,6 @@ typedef struct tBTM_PM_STATUS_CBACK *cback;/* to notify the registered party of mode change event */ UINT8 mask; /* registered request mask. 0, if this entry is not used */ } tBTM_PM_RCB; -#endif /* BTM_PWR_MGR_INCLUDED */ enum { @@ -784,18 +735,6 @@ typedef BOOLEAN CONNECTION_TYPE; #define BTM_STATE_BUFFER_SIZE 5 /* size of state buffer */ -#if (BTM_PCM2_INCLUDED == TRUE) -/* Define pcm2_action */ -enum -{ - BTM_PCM2_ACT_NONE, - BTM_PCM2_ACT_SENT_ARC, - BTM_PCM2_READ_PARAM, - BTM_PCM2_WRITE_PARAM, -}; -typedef UINT8 tBTM_PCM2_ACTION; -#endif - typedef struct { tBTM_CFG cfg; /* Device configuration */ @@ -804,30 +743,20 @@ typedef struct ** ACL Management ****************************************************/ tACL_CONN acl_db[MAX_L2CAP_LINKS]; -#if( RFCOMM_INCLUDED==TRUE) UINT8 btm_scn[BTM_MAX_SCN]; /* current SCNs: TRUE if SCN is in use */ -#endif UINT16 btm_def_link_policy; UINT16 btm_def_link_super_tout; -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) tBTM_BL_EVENT_MASK bl_evt_mask; tBTM_BL_CHANGE_CB *p_bl_changed_cb; /* Callback for when Busy Level changed */ -#else - tBTM_ACL_DB_CHANGE_CB *p_acl_changed_cb; /* Callback for when ACL DB changed */ -#endif - - tBTM_LSTO_CBACK *p_lsto_cback; /* for link supervision timeout change event */ /**************************************************** ** Power Management ****************************************************/ -#if BTM_PWR_MGR_INCLUDED == TRUE tBTM_PM_MCB pm_mode_db[MAX_L2CAP_LINKS]; /* per ACL link */ tBTM_PM_RCB pm_reg_db[BTM_MAX_PM_RECORDS+1]; /* per application/module */ UINT8 pm_pend_link; /* the index of acl_db, which has a pending PM cmd */ UINT8 pm_pend_id; /* the id pf the module, which has a pending PM cmd */ -#endif /* BTM_PWR_MGR_INCLUDED == TRUE */ /***************************************************** ** Device control @@ -856,8 +785,6 @@ typedef struct ** Inquiry *****************************************************/ tBTM_INQUIRY_VAR_ST btm_inq_vars; - tBTM_FILTER_CB *p_inq_filter_cb; /* Callback that can be set if host */ - /* wants to verify inquiry filters */ /***************************************************** ** SCO Management @@ -874,9 +801,6 @@ typedef struct #define BTM_SEC_MAX_RMT_NAME_CALLBACKS 2 tBTM_RMT_NAME_CALLBACK *p_rmt_name_callback[BTM_SEC_MAX_RMT_NAME_CALLBACKS]; - tBTM_FILTER_CB *p_conn_filter_cb; /* Callback that can be set if host */ - /* wants to verify connectability filters*/ - tBTM_SEC_DEV_REC *p_collided_dev_rec; TIMER_LIST_ENT sec_collision_tle; UINT32 collision_start_time; @@ -910,17 +834,11 @@ typedef struct BD_ADDR connecting_bda; DEV_CLASS connecting_dc; - UINT8 first_disabled_channel; - UINT8 last_disabled_channel; - UINT8 acl_disc_reason; UINT8 trace_level; -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) - UINT8 num_acl; /* num of active ACL links */ UINT8 busy_level; /* the current busy level */ BOOLEAN is_paging; /* TRUE, if paging is in progess */ BOOLEAN is_inquiry; /* TRUE, if inquiry is in progess */ -#endif BUFFER_Q page_queue; BOOLEAN paging; BOOLEAN discing; @@ -930,12 +848,6 @@ typedef struct char state_temp_buffer[BTM_STATE_BUFFER_SIZE]; #endif -#if (defined(BTM_PCM2_INCLUDED) && BTM_PCM2_INCLUDED == TRUE) - UINT16 sys_features; - UINT8 pcm2_params[BRCM_PCM2_SETUP_WRITE_SIZE]; - tBTM_PCM2_ACTION pcm2_action; -#endif - } tBTM_CB; @@ -945,9 +857,9 @@ extern "C" #endif #if BTM_DYNAMIC_MEMORY == FALSE -BTM_API extern tBTM_CB btm_cb; +extern tBTM_CB btm_cb; #else -BTM_API extern tBTM_CB *btm_cb_ptr; +extern tBTM_CB *btm_cb_ptr; #define btm_cb (*btm_cb_ptr) #endif @@ -980,25 +892,21 @@ extern void btm_inq_clear_ssp(void); extern tINQ_DB_ENT *btm_inq_db_find (BD_ADDR p_bda); extern BOOLEAN btm_inq_find_bdaddr (BD_ADDR p_bda); -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) extern BOOLEAN btm_lookup_eir(BD_ADDR_PTR p_rem_addr); -#endif /* Internal functions provided by btm_acl.c ******************************************** */ extern void btm_acl_init (void); -extern void btm_acl_timeout (TIMER_LIST_ENT *p_tle); extern void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn, UINT16 hci_handle, UINT8 link_role, tBT_TRANSPORT transport); extern void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport); extern void btm_acl_device_down (void); extern void btm_acl_update_busy_level (tBTM_BLI_EVENT event); -extern void btm_acl_link_key_change (UINT16 handle, UINT8 status); -extern void btm_cont_rswitch_or_chglinkkey (tACL_CONN *p, - tBTM_SEC_DEV_REC *p_dev_rec, - UINT8 hci_status); +extern void btm_cont_rswitch (tACL_CONN *p, + tBTM_SEC_DEV_REC *p_dev_rec, + UINT8 hci_status); extern UINT8 btm_handle_to_acl_index (UINT16 hci_handle); extern void btm_read_link_policy_complete (UINT8 *p); @@ -1009,8 +917,8 @@ extern tBTM_STATUS btm_set_packet_types (tACL_CONN *p, UINT16 pkt_types); extern void btm_process_clk_off_comp_evt (UINT16 hci_handle, UINT16 clock_offset); extern void btm_acl_role_changed (UINT8 hci_status, BD_ADDR bd_addr, UINT8 new_role); extern void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable); -BTM_API extern UINT16 btm_get_acl_disc_reason_code (void); -BTM_API extern tBTM_STATUS btm_remove_acl (BD_ADDR bd_addr, tBT_TRANSPORT transport); +extern UINT16 btm_get_acl_disc_reason_code (void); +extern tBTM_STATUS btm_remove_acl (BD_ADDR bd_addr, tBT_TRANSPORT transport); extern void btm_read_remote_features_complete (UINT8 *p); extern void btm_read_remote_ext_features_complete (UINT8 *p); extern void btm_read_remote_ext_features_failed (UINT8 status, UINT16 handle); @@ -1025,14 +933,6 @@ extern UINT16 btm_get_max_packet_size (BD_ADDR addr); extern tACL_CONN *btm_bda_to_acl (BD_ADDR bda, tBT_TRANSPORT transport); extern BOOLEAN btm_acl_notif_conn_collision (BD_ADDR bda); -#if BTM_PWR_MGR_INCLUDED == FALSE -extern void btm_process_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, - UINT16 interval); - -/* Internal functions provided by btm_pm.c -******************************************** -*/ -#else extern void btm_pm_reset(void); extern void btm_pm_sm_alloc(UINT8 ind); extern void btm_pm_proc_cmd_status(UINT8 status); @@ -1044,7 +944,6 @@ extern void btm_sco_chk_pend_unpark (UINT8 hci_status, UINT16 hci_handle); #else #define btm_sco_chk_pend_unpark(hci_status, hci_handle) #endif /* BTM_SCO_INCLUDED */ -#endif /* BTM_PWR_MGR_INCLUDED == FALSE */ extern void btm_qos_setup_complete (UINT8 status, UINT16 handle, FLOW_SPEC *p_flow); @@ -1073,24 +972,10 @@ extern void btm_sco_flush_sco_data(UINT16 sco_inx); ********************************************** */ extern void btm_dev_init (void); -extern void btm_dev_absent (void); extern void btm_dev_timeout (TIMER_LIST_ENT *p_tle); -extern void btm_reset_complete (void); -extern void btm_read_local_version_complete (UINT8 *p, UINT16 evt_len); -extern void btm_read_hci_buf_size_complete (UINT8 *p, UINT16 evt_len); -extern void btm_read_local_supported_cmds_complete (UINT8 *p); -extern void btm_read_local_features_complete (UINT8 *p, UINT16 evt_len); -extern void btm_read_local_ext_features_complete (UINT8 *p, UINT16 evt_len); extern void btm_read_local_name_complete (UINT8 *p, UINT16 evt_len); -extern void btm_read_local_addr_complete (UINT8 *p, UINT16 evt_len); -extern void btm_reset_ctrlr_complete (void); -extern void btm_write_simple_paring_mode_complete (UINT8 *p); -extern void btm_write_le_host_supported_complete (UINT8 *p); #if (BLE_INCLUDED == TRUE) -extern void btm_read_ble_buf_size_complete (UINT8 *p, UINT16 evt_len); -extern void btm_read_ble_local_supported_features_complete (UINT8 *p, UINT16 evt_len); -extern void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len); extern void btm_ble_add_2_white_list_complete(UINT8 status); extern void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len); extern void btm_ble_clear_white_list_complete(UINT8 *p, UINT16 evt_len); @@ -1101,11 +986,7 @@ extern void btm_vsc_complete (UINT8 *p, UINT16 cc_opcode, UINT16 evt_len, tBTM_CMPL_CB *p_vsc_cplt_cback); extern void btm_inq_db_reset (void); extern void btm_vendor_specific_evt (UINT8 *p, UINT8 evt_len); -extern UINT8 btm_get_hci_version (void); -extern void btm_read_stored_link_key_complete (UINT8 *p); -extern void btm_write_stored_link_key_complete (UINT8 *p); extern void btm_delete_stored_link_key_complete (UINT8 *p); -extern void btm_return_link_keys_evt (tBTM_RETURN_LINK_KEYS_EVT *result); extern void btm_report_device_status (tBTM_DEV_STATUS status); @@ -1113,7 +994,6 @@ extern void btm_report_device_status (tBTM_DEV_STATUS status); ********************************************** */ extern BOOLEAN btm_dev_support_switch (BD_ADDR bd_addr); -extern UINT8 btm_get_voice_coding_support (void); extern tBTM_SEC_DEV_REC *btm_sec_alloc_dev (BD_ADDR bd_addr); extern void btm_sec_free_dev (tBTM_SEC_DEV_REC *p_dev_rec); @@ -1133,14 +1013,12 @@ extern tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOL tBTM_SEC_CALLBACK *p_callback, void *p_ref_data); extern void btm_sec_conn_req (UINT8 *bda, UINT8 *dc); extern void btm_create_conn_cancel_complete (UINT8 *p); -extern void btm_proc_lsto_evt(UINT16 handle, UINT16 timeout); extern void btm_read_linq_tx_power_complete (UINT8 *p); extern void btm_sec_init (UINT8 sec_mode); extern void btm_sec_dev_reset (void); extern void btm_sec_abort_access_req (BD_ADDR bd_addr); extern void btm_sec_auth_complete (UINT16 handle, UINT8 status); -extern void btm_sec_mkey_comp_event (UINT16 handle, UINT8 status, UINT8 key_flg); extern void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable); extern void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode); extern tBTM_STATUS btm_sec_disconnect (UINT16 handle, UINT8 reason); @@ -1178,7 +1056,6 @@ extern void btm_read_local_oob_complete (UINT8 *p); extern void btm_acl_resubmit_page (void); extern void btm_acl_reset_paging (void); extern void btm_acl_paging (BT_HDR *p, BD_ADDR dest); -extern void btm_acl_set_discing (BOOLEAN discing); extern UINT8 btm_sec_clr_service_by_psm (UINT16 psm); extern void btm_sec_clr_temp_auth_service (BD_ADDR bda); @@ -1187,4 +1064,3 @@ extern void btm_sec_clr_temp_auth_service (BD_ADDR bda); #endif #endif - diff --git a/stack/btm/btm_pm.c b/stack/btm/btm_pm.c index 76bfc048b..b22b5de68 100644 --- a/stack/btm/btm_pm.c +++ b/stack/btm/btm_pm.c @@ -28,10 +28,13 @@ * *****************************************************************************/ +#define LOG_TAG "bt_btm_pm" + #include <stdlib.h> #include <string.h> #include <stdio.h> #include <stddef.h> + #include "bt_types.h" #include "gki.h" #include "hcimsgs.h" @@ -41,17 +44,7 @@ #include "l2c_int.h" #include "hcidefs.h" #include "bt_utils.h" - -#if BTM_PWR_MGR_INCLUDED == TRUE - -/* This compile option is only useful when the FW has a bug - * it automatically uses single slot when entering SNIFF mode, but does not restore the setting - * This issue was found when A2DP link goes into sniff and existing sniff still has choppy audio. - * If this issue is seen, look for FW solution first. - * This work around code will be removed later. */ -#ifndef BTM_PM_SNIFF_SLOT_WORK_AROUND -#define BTM_PM_SNIFF_SLOT_WORK_AROUND FALSE -#endif +#include "osi/include/log.h" /*****************************************************************************/ /* to handle different modes */ @@ -87,6 +80,7 @@ const UINT8 btm_pm_md_comp_matrix[BTM_PM_NUM_SET_MODES*BTM_PM_NUM_SET_MODES] = /* function prototype */ static int btm_pm_find_acl_ind(BD_ADDR remote_bda); static tBTM_STATUS btm_pm_snd_md_req( UINT8 pm_id, int link_ind, tBTM_PM_PWR_MD *p_mode ); +static const char *mode_to_string(tBTM_PM_MODE mode); /* #ifdef BTM_PM_DEBUG @@ -121,7 +115,7 @@ const char * btm_pm_action_str[] = "pm_hci_sts_action", "pm_update_action" }; -#endif +#endif // BTM_PM_DEBUG /*****************************************************************************/ /* P U B L I C F U N C T I O N S */ @@ -241,7 +235,7 @@ tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda, tBTM_PM_PWR_MD *p { #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "BTM_SetPowerMode: Saving cmd acl_ind %d temp_pm_id %d", acl_ind,temp_pm_id); -#endif +#endif // BTM_PM_DEBUG /* Make sure mask is set to BTM_PM_REG_SET */ btm_cb.pm_reg_db[temp_pm_id].mask |= BTM_PM_REG_SET; *(&p_cb->req_mode[temp_pm_id]) = *((tBTM_PM_PWR_MD *)p_mode); @@ -250,7 +244,7 @@ tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda, tBTM_PM_PWR_MD *p #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm state:0x%x, pm_pend_link: %d", p_cb->state, btm_cb.pm_pend_link); -#endif +#endif // BTM_PM_DEBUG /* if mode == hold or pending, return */ if( (p_cb->state == BTM_PM_STS_HOLD) || (p_cb->state == BTM_PM_STS_PENDING) || @@ -345,7 +339,7 @@ tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat, return BTM_CMD_STORED; #else return BTM_ILLEGAL_ACTION; -#endif +#endif // BTM_SSR_INCLUDED } /******************************************************************************* @@ -400,7 +394,7 @@ void btm_pm_sm_alloc(UINT8 ind) p_db->state = BTM_PM_ST_ACTIVE; #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm_sm_alloc ind:%d st:%d", ind, p_db->state); -#endif +#endif // BTM_PM_DEBUG } /******************************************************************************* @@ -423,12 +417,12 @@ static int btm_pm_find_acl_ind(BD_ADDR remote_bda) if ((p->in_use) && (!memcmp (p->remote_addr, remote_bda, BD_ADDR_LEN)) #if (BLE_INCLUDED == TRUE) && p->transport == BT_TRANSPORT_BR_EDR -#endif +#endif // BLE_INCLUDED ) { #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm_find_acl_ind ind:%d, st:%d", xx, btm_cb.pm_mode_db[xx].state); -#endif +#endif // BTM_PM_DEBUG break; } } @@ -593,7 +587,7 @@ static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, int link_ind, tBTM_PM_PWR_MD * #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm_snd_md_req link_ind:%d, mode: %d", link_ind, mode); -#endif +#endif // BTM_PM_DEBUG if( p_cb->state == mode) { @@ -619,7 +613,7 @@ static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, int link_ind, tBTM_PM_PWR_MD * p_cb->min_rmt_to, p_cb->min_loc_to); p_cb->max_lat = 0; } -#endif +#endif // BTM_SSR_INCLUDED /* Default is failure */ btm_cb.pm_pend_link = MAX_L2CAP_LINKS; @@ -628,7 +622,9 @@ static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, int link_ind, tBTM_PM_PWR_MD * #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG("btm_pm_snd_md_req state:0x%x, link_ind: %d", p_cb->state, link_ind); -#endif +#endif // BTM_PM_DEBUG + + LOG_DEBUG("%s switching from %s to %s.", __func__, mode_to_string(p_cb->state), mode_to_string(md_res.mode)); switch(md_res.mode) { case BTM_PM_MD_ACTIVE: @@ -686,7 +682,7 @@ static tBTM_STATUS btm_pm_snd_md_req(UINT8 pm_id, int link_ind, tBTM_PM_PWR_MD * /* the command was not sent */ #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "pm_pend_link: %d",btm_cb.pm_pend_link); -#endif +#endif // BTM_PM_DEBUG return (BTM_NO_RESOURCES); } @@ -748,7 +744,7 @@ void btm_pm_proc_cmd_status(UINT8 status) pm_status = BTM_PM_STS_PENDING; #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm_proc_cmd_status new state:0x%x", p_cb->state); -#endif +#endif // BTM_PM_DEBUG } else /* the command was not successfull. Stay in the same state */ { @@ -766,7 +762,7 @@ void btm_pm_proc_cmd_status(UINT8 status) #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm_proc_cmd_status state:0x%x, pm_pend_link: %d(new: %d)", p_cb->state, btm_cb.pm_pend_link, MAX_L2CAP_LINKS); -#endif +#endif // BTM_PM_DEBUG btm_cb.pm_pend_link = MAX_L2CAP_LINKS; btm_pm_check_stored(); @@ -800,57 +796,13 @@ void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, U p = &btm_cb.acl_db[xx]; - /*** 2035 and 2045 work around: If mode is active and coming out of a SCO disconnect, restore packet types ***/ - if (mode == HCI_MODE_ACTIVE) - { - if(BTM_GetNumScoLinks() == 0) - { - if(p->restore_pkt_types) - { - BTM_TRACE_DEBUG("btm mode change AFTER unsniffing; hci hdl 0x%x, types 0x%02x/0x%02x", - hci_handle, p->pkt_types_mask, p->restore_pkt_types); - p->pkt_types_mask = p->restore_pkt_types; - p->restore_pkt_types = 0; /* Only exists while SCO is active */ - btsnd_hcic_change_conn_type (p->hci_handle, p->pkt_types_mask); - } -#if (BTM_PM_SNIFF_SLOT_WORK_AROUND == TRUE) - else - { - BTM_TRACE_DEBUG("btm mode change AFTER unsniffing; hci hdl 0x%x, types 0x%02x", - hci_handle, btm_cb.btm_acl_pkt_types_supported); - btm_set_packet_types (p, btm_cb.btm_acl_pkt_types_supported); - } -#endif - } -#if (BTM_PM_SNIFF_SLOT_WORK_AROUND == TRUE) - else - { - /* Mode changed from Sniff to Active while SCO is open. */ - /* Packet types of active mode, not sniff mode, should be used for ACL when SCO is closed. */ - p->restore_pkt_types = btm_cb.btm_acl_pkt_types_supported; - - /* Exclude packet types not supported by the peer */ - btm_acl_chk_peer_pkt_type_support (p, &p->restore_pkt_types); - } -#endif - } -#if (BTM_PM_SNIFF_SLOT_WORK_AROUND == TRUE) - else if (mode == HCI_MODE_SNIFF) - { - BTM_TRACE_DEBUG("btm mode change to sniff; hci hdl 0x%x use single slot", - hci_handle); - btm_set_packet_types (p, (HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1)); - } -#endif - /* update control block */ p_cb = &(btm_cb.pm_mode_db[xx]); old_state = p_cb->state; p_cb->state = mode; p_cb->interval = interval; -#if BTM_PM_DEBUG == TRUE - BTM_TRACE_DEBUG( "btm_pm_proc_mode_change new state:0x%x (old:0x%x)", p_cb->state, old_state); -#endif + + LOG_DEBUG("%s switched from %s to %s.", __func__, mode_to_string(old_state), mode_to_string(p_cb->state)); if ((p_lcb = l2cu_find_lcb_by_bd_addr(p->remote_addr, BT_TRANSPORT_BR_EDR)) != NULL) { @@ -876,7 +828,7 @@ void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, U { #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm_proc_mode_change: Sending stored req:%d", xx); -#endif +#endif // BTM_PM_DEBUG btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, xx, NULL); } else @@ -887,7 +839,7 @@ void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, U { #if BTM_PM_DEBUG == TRUE BTM_TRACE_DEBUG( "btm_pm_proc_mode_change: Sending PM req :%d", zz); -#endif +#endif // BTM_PM_DEBUG btm_pm_snd_md_req(BTM_PM_SET_ONLY_ID, zz, NULL); break; } @@ -905,7 +857,7 @@ void btm_pm_proc_mode_change (UINT8 hci_status, UINT16 hci_handle, UINT8 mode, U } /* If mode change was because of an active role switch or change link key */ - btm_cont_rswitch_or_chglinkkey(p, btm_find_dev(p->remote_addr), hci_status); + btm_cont_rswitch(p, btm_find_dev(p->remote_addr), hci_status); } /******************************************************************************* @@ -922,7 +874,7 @@ void btm_pm_proc_ssr_evt (UINT8 *p, UINT16 evt_len) { UINT8 status; UINT16 handle; - UINT16 max_tx_lat, max_rx_lat; + UINT16 max_rx_lat; int xx, yy; tBTM_PM_MCB *p_cb; tACL_CONN *p_acl=NULL; @@ -936,7 +888,7 @@ void btm_pm_proc_ssr_evt (UINT8 *p, UINT16 evt_len) if ((xx = btm_handle_to_acl_index(handle)) >= MAX_L2CAP_LINKS) return; - STREAM_TO_UINT16 (max_tx_lat, p); + p += 2; STREAM_TO_UINT16 (max_rx_lat, p); p_cb = &(btm_cb.pm_mode_db[xx]); @@ -959,52 +911,7 @@ void btm_pm_proc_ssr_evt (UINT8 *p, UINT16 evt_len) } } } - -#endif - -#else /* BTM_PWR_MGR_INCLUDED == TRUE */ - -/******************************************************************************* -** -** Functions BTM_PmRegister, BTM_SetPowerMode, and BTM_ReadPowerMode -** -** Description Stubbed versions for BTM_PWR_MGR_INCLUDED = FALSE -** -** Returns BTM_MODE_UNSUPPORTED. -** -*******************************************************************************/ -tBTM_STATUS BTM_PmRegister (UINT8 mask, UINT8 *p_pm_id, tBTM_PM_STATUS_CBACK *p_cb) -{ - return BTM_MODE_UNSUPPORTED; -} - -tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda, tBTM_PM_PWR_MD *p_mode) -{ - return BTM_MODE_UNSUPPORTED; -} - -tBTM_STATUS BTM_ReadPowerMode (BD_ADDR remote_bda, tBTM_PM_MODE *p_mode) -{ - return BTM_MODE_UNSUPPORTED; -} - -#endif - - -/******************************************************************************* -** -** Function BTM_IsPowerManagerOn -** -** Description This function is called to check if power manager is included. -** in the BTE version. -** -** Returns BTM_PWR_MGR_INCLUDED. -** -*******************************************************************************/ -BOOLEAN BTM_IsPowerManagerOn (void) -{ - return BTM_PWR_MGR_INCLUDED; -} +#endif // BTM_SSR_INCLUDED /******************************************************************************* ** @@ -1020,9 +927,9 @@ BOOLEAN btm_pm_device_in_active_or_sniff_mode(void) /* The active state is the highest state-includes connected device and sniff mode*/ /* Covers active and sniff modes */ - if (btm_cb.num_acl > 0) + if (BTM_GetNumAclLinks() > 0) { - BTM_TRACE_DEBUG("btm_pm_device_in_active_or_sniff_mode-acl:%d", btm_cb.num_acl); + BTM_TRACE_DEBUG("%s - ACL links: %d", __func__, BTM_GetNumAclLinks()); return TRUE; } @@ -1030,8 +937,7 @@ BOOLEAN btm_pm_device_in_active_or_sniff_mode(void) /* Check BLE states */ if (btm_ble_get_conn_st() != BLE_CONN_IDLE) { - BTM_TRACE_DEBUG("btm_pm_device_in_active_or_sniff_mode- BLE state: %x", - btm_ble_get_conn_st()); + BTM_TRACE_DEBUG("%s - BLE state: %x", __func__, btm_ble_get_conn_st()); return TRUE; } #endif @@ -1053,7 +959,7 @@ BOOLEAN btm_pm_device_in_scan_state(void) /* Scan state-paging, inquiry, and trying to connect */ /* Check for paging */ - if (btm_cb.is_paging || btm_cb.page_queue.count > 0 || + if (btm_cb.is_paging || GKI_queue_length(&btm_cb.page_queue) > 0 || BTM_BL_PAGING_STARTED == btm_cb.busy_level) { BTM_TRACE_DEBUG("btm_pm_device_in_scan_state- paging"); @@ -1090,3 +996,12 @@ tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void) return BTM_CONTRL_IDLE; } +static const char *mode_to_string(tBTM_PM_MODE mode) { + switch (mode) { + case BTM_PM_MD_ACTIVE: return "ACTIVE"; + case BTM_PM_MD_SNIFF: return "SNIFF"; + case BTM_PM_MD_PARK: return "PARK"; + case BTM_PM_MD_HOLD: return "HOLD"; + default: return "UNKNOWN"; + } +} diff --git a/stack/btm/btm_sco.c b/stack/btm/btm_sco.c index d9d0fbc49..801896d14 100644 --- a/stack/btm/btm_sco.c +++ b/stack/btm/btm_sco.c @@ -176,61 +176,50 @@ static void btm_esco_conn_rsp (UINT16 sco_inx, UINT8 hci_status, BD_ADDR bda, else /* Connection is being accepted */ { p_sco->state = SCO_ST_CONNECTING; - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_1_2) + p_setup = &p_sco->esco.setup; + /* If parameters not specified use the default */ + if (p_parms) + *p_setup = *p_parms; + else /* Use the last setup passed thru BTM_SetEscoMode (or defaults) */ { - p_setup = &p_sco->esco.setup; - /* If parameters not specified use the default */ - if (p_parms) - *p_setup = *p_parms; - else /* Use the last setup passed thru BTM_SetEscoMode (or defaults) */ - { - *p_setup = btm_cb.sco_cb.def_esco_parms; - } + *p_setup = btm_cb.sco_cb.def_esco_parms; + } - temp_pkt_types = (p_setup->packet_types & - BTM_SCO_SUPPORTED_PKTS_MASK & - btm_cb.btm_sco_pkt_types_supported); + temp_pkt_types = (p_setup->packet_types & + BTM_SCO_SUPPORTED_PKTS_MASK & + btm_cb.btm_sco_pkt_types_supported); - /* Make sure at least one eSCO packet type is sent, else might confuse peer */ - /* Taking this out to confirm with BQB tests - ** Real application would like to include this though, as many devices - ** do not retry with SCO only if an eSCO connection fails. - if (!(temp_pkt_types & BTM_ESCO_LINK_ONLY_MASK)) - { - temp_pkt_types |= BTM_SCO_PKT_TYPES_MASK_EV3; - } - */ - /* If SCO request, remove eSCO packet types (conformance) */ - if (p_sco->esco.data.link_type == BTM_LINK_TYPE_SCO) - { - temp_pkt_types &= BTM_SCO_LINK_ONLY_MASK; - - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) - { - temp_pkt_types |= BTM_SCO_EXCEPTION_PKTS_MASK; - } - } - /* OR in any exception packet types if at least 2.0 version of spec */ - else if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) - { - temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | - (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK)); - } + /* Make sure at least one eSCO packet type is sent, else might confuse peer */ + /* Taking this out to confirm with BQB tests + ** Real application would like to include this though, as many devices + ** do not retry with SCO only if an eSCO connection fails. + if (!(temp_pkt_types & BTM_ESCO_LINK_ONLY_MASK)) + { + temp_pkt_types |= BTM_SCO_PKT_TYPES_MASK_EV3; + } + */ + /* If SCO request, remove eSCO packet types (conformance) */ + if (p_sco->esco.data.link_type == BTM_LINK_TYPE_SCO) + { + temp_pkt_types &= BTM_SCO_LINK_ONLY_MASK; + temp_pkt_types |= BTM_SCO_EXCEPTION_PKTS_MASK; + } + else + { + /* OR in any exception packet types */ + temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | + (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK)); + } - if (btsnd_hcic_accept_esco_conn (bda, p_setup->tx_bw, p_setup->rx_bw, - p_setup->max_latency, p_setup->voice_contfmt, - p_setup->retrans_effort, temp_pkt_types)) - { - p_setup->packet_types = temp_pkt_types; - } - else - { - BTM_TRACE_ERROR("Could not accept SCO conn: No Buffer!!!"); - } + if (btsnd_hcic_accept_esco_conn (bda, p_setup->tx_bw, p_setup->rx_bw, + p_setup->max_latency, p_setup->voice_contfmt, + p_setup->retrans_effort, temp_pkt_types)) + { + p_setup->packet_types = temp_pkt_types; } - else /* Controller is version 1.1 or earlier */ + else { - btsnd_hcic_accept_conn (bda, 0); + BTM_TRACE_ERROR("Could not accept SCO conn: No Buffer!!!"); } } #endif @@ -421,12 +410,9 @@ static tBTM_STATUS btm_send_connect_request(UINT16 acl_handle, temp_pkt_types = (p_setup->packet_types & BTM_SCO_SUPPORTED_PKTS_MASK & btm_cb.btm_sco_pkt_types_supported); - /* OR in any exception packet types if at least 2.0 version of spec */ - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) - { - temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | - (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK)); - } + /* OR in any exception packet types */ + temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | + (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK)); /* Finally, remove EDR eSCO if the remote device doesn't support it */ /* UPF25: Only SCO was brought up in this case */ @@ -570,12 +556,12 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types UINT16 temp_pkt_types; tACL_CONN *p_acl; -#if (BTM_PWR_MGR_INCLUDED == TRUE) && (BTM_SCO_WAKE_PARKED_LINK == TRUE) +#if (BTM_SCO_WAKE_PARKED_LINK == TRUE) tBTM_PM_MODE md; tBTM_PM_PWR_MD pm; -#else +#else // BTM_SCO_WAKE_PARKED_LINK UINT8 mode; -#endif +#endif // BTM_SCO_WAKE_PARKED_LINK *p_sco_inx = BTM_INVALID_SCO_INDEX; @@ -619,7 +605,7 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types if (is_orig) { /* can not create SCO link if in park mode */ -#if (BTM_PWR_MGR_INCLUDED == TRUE) && (BTM_SCO_WAKE_PARKED_LINK == TRUE) +#if BTM_SCO_WAKE_PARKED_LINK == TRUE if(BTM_ReadPowerMode(remote_bda, &md) == BTM_SUCCESS) { if (md == BTM_PM_MD_PARK || md == BTM_PM_MD_SNIFF) @@ -630,13 +616,10 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types p->state = SCO_ST_PEND_UNPARK; } } -#elif BTM_PWR_MGR_INCLUDED == TRUE +#else // BTM_SCO_WAKE_PARKED_LINK if( (BTM_ReadPowerMode(remote_bda, &mode) == BTM_SUCCESS) && (mode == BTM_PM_MD_PARK) ) return (BTM_WRONG_MODE); -#else - if( (BTM_ReadAclMode(remote_bda, &mode) == BTM_SUCCESS) && (mode == BTM_ACL_MODE_PARK) ) - return (BTM_WRONG_MODE); -#endif +#endif // BTM_SCO_WAKE_PARKED_LINK } memcpy (p->esco.data.bd_addr, remote_bda, BD_ADDR_LEN); p->rem_bd_known = TRUE; @@ -656,18 +639,15 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types temp_pkt_types = (p_setup->packet_types & BTM_SCO_SUPPORTED_PKTS_MASK & btm_cb.btm_sco_pkt_types_supported); - /* OR in any exception packet types if at least 2.0 version of spec */ - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) + /* OR in any exception packet types */ + if (btm_cb.sco_cb.desired_sco_mode == HCI_LINK_TYPE_ESCO) { - if (btm_cb.sco_cb.desired_sco_mode == HCI_LINK_TYPE_ESCO) - { - temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | - (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK)); - } - else /* Only using SCO packet types; turn off EDR also */ - { - temp_pkt_types |= BTM_SCO_EXCEPTION_PKTS_MASK; - } + temp_pkt_types |= ((p_setup->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | + (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK)); + } + else /* Only using SCO packet types; turn off EDR also */ + { + temp_pkt_types |= BTM_SCO_EXCEPTION_PKTS_MASK; } p_setup->packet_types = temp_pkt_types; @@ -719,7 +699,7 @@ tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, UINT16 pkt_types return (BTM_NO_RESOURCES); } -#if (BTM_PWR_MGR_INCLUDED == TRUE) && (BTM_SCO_WAKE_PARKED_LINK == TRUE) +#if (BTM_SCO_WAKE_PARKED_LINK == TRUE) /******************************************************************************* ** ** Function btm_sco_chk_pend_unpark @@ -750,9 +730,9 @@ void btm_sco_chk_pend_unpark (UINT8 hci_status, UINT16 hci_handle) p->state = SCO_ST_CONNECTING; } } -#endif +#endif // BTM_MAX_SCO_LINKS } -#endif +#endif // BTM_SCO_WAKE_PARKED_LINK /******************************************************************************* ** @@ -810,8 +790,10 @@ void btm_sco_conn_req (BD_ADDR bda, DEV_CLASS dev_class, UINT8 link_type) * If the sco state is in the SCO_ST_CONNECTING state, we still need * to return accept sco to avoid race conditon for sco creation */ - if (((p->state == SCO_ST_LISTENING && p->rem_bd_known) || p->state == SCO_ST_CONNECTING) - && (!memcmp (p->esco.data.bd_addr, bda, BD_ADDR_LEN))) + int rem_bd_matches = p->rem_bd_known && + !memcmp (p->esco.data.bd_addr, bda, BD_ADDR_LEN); + if (((p->state == SCO_ST_CONNECTING) && rem_bd_matches) || + ((p->state == SCO_ST_LISTENING) && (rem_bd_matches || !p->rem_bd_known))) { /* If this guy was a wildcard, he is not one any more */ p->rem_bd_known = TRUE; @@ -1366,11 +1348,8 @@ tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode, tBTM_ESCO_PARAMS *p_parms) p_def->voice_contfmt = 0x0060; p_def->retrans_effort = 0; - /* OR in any exception packet types if at least 2.0 version of spec */ - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) - { - p_def->packet_types |= BTM_SCO_EXCEPTION_PKTS_MASK; - } + /* OR in any exception packet types */ + p_def->packet_types |= BTM_SCO_EXCEPTION_PKTS_MASK; } } p_esco->desired_sco_mode = sco_mode; @@ -1534,12 +1513,9 @@ tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx, tBTM_CHG_ESCO_PARAMS *p_par temp_pkt_types = (p_parms->packet_types & BTM_SCO_SUPPORTED_PKTS_MASK & btm_cb.btm_sco_pkt_types_supported); - /* OR in any exception packet types if at least 2.0 version of spec */ - if (btm_cb.devcb.local_version.hci_version >= HCI_PROTO_VERSION_2_0) - { - temp_pkt_types |= ((p_parms->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | - (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK)); - } + /* OR in any exception packet types */ + temp_pkt_types |= ((p_parms->packet_types & BTM_SCO_EXCEPTION_PKTS_MASK) | + (btm_cb.btm_sco_pkt_types_supported & BTM_SCO_EXCEPTION_PKTS_MASK)); BTM_TRACE_API("BTM_ChangeEScoLinkParms -> eSCO Link for handle 0x%04x", p_sco->hci_handle); BTM_TRACE_API(" txbw 0x%x, rxbw 0x%x, lat 0x%x, voice 0x%x, retrans 0x%02x, pkt 0x%04x", diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.c index f6810fed2..68eecc56f 100644 --- a/stack/btm/btm_sec.c +++ b/stack/btm/btm_sec.c @@ -22,13 +22,18 @@ * ******************************************************************************/ +#define LOG_TAG "bt_btm_sec" + #include <string.h> + #include "bt_types.h" +#include "device/include/controller.h" #include "hcimsgs.h" #include "btu.h" #include "btm_int.h" #include "l2c_int.h" #include "bt_utils.h" +#include "osi/include/log.h" #if (BT_USE_TRACES == TRUE && BT_TRACE_VERBOSE == FALSE) /* needed for sprintf() */ @@ -39,7 +44,7 @@ #include "gatt_int.h" #endif -#define BTM_SEC_MAX_COLLISION_DELAY (GKI_SECS_TO_TICKS(5)) +#define BTM_SEC_MAX_COLLISION_DELAY (5000) #ifdef APPL_AUTH_WRITE_EXCEPTION BOOLEAN (APPL_AUTH_WRITE_EXCEPTION)(BD_ADDR bd_addr); @@ -190,65 +195,42 @@ static BOOLEAN btm_serv_trusted(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_SEC_SERV_REC * ** Returns TRUE if registered OK, else FALSE ** *******************************************************************************/ -BOOLEAN BTM_SecRegister (tBTM_APPL_INFO *p_cb_info) +BOOLEAN BTM_SecRegister(tBTM_APPL_INFO *p_cb_info) { #if BLE_INCLUDED == TRUE BT_OCTET16 temp_value = {0}; #endif - BTM_TRACE_EVENT ("BTM_Sec: application registered"); + BTM_TRACE_EVENT("%s application registered", __func__); #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE + LOG_INFO("%s p_cb_info->p_le_callback == 0x%p", __func__, p_cb_info->p_le_callback); if (p_cb_info->p_le_callback) { - BTM_TRACE_ERROR ("BTM_SecRegister:p_cb_info->p_le_callback == 0x%x ", p_cb_info->p_le_callback); - - if (p_cb_info->p_le_callback) - { - #if SMP_INCLUDED == TRUE - BTM_TRACE_EVENT ("BTM_Sec: SMP_Register( btm_proc_smp_cback )"); - SMP_Register(btm_proc_smp_cback); - #endif - /* if no IR is loaded, need to regenerate all the keys */ - if (memcmp(btm_cb.devcb.id_keys.ir, &temp_value, sizeof(BT_OCTET16)) == 0) - { - btm_ble_reset_id(); - } - } - else - { - BTM_TRACE_ERROR ("BTM_SecRegister:p_cb_info->p_le_callback == NULL "); - } +#if SMP_INCLUDED == TRUE + BTM_TRACE_EVENT("%s SMP_Register( btm_proc_smp_cback )", __func__); + SMP_Register(btm_proc_smp_cback); +#endif + /* if no IR is loaded, need to regenerate all the keys */ + if (memcmp(btm_cb.devcb.id_keys.ir, &temp_value, sizeof(BT_OCTET16)) == 0) + { + btm_ble_reset_id(); + } + } + else + { + LOG_WARN("%s p_cb_info->p_le_callback == NULL", __func__); } #endif btm_cb.api = *p_cb_info; #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE - BTM_TRACE_ERROR ("BTM_SecRegister: btm_cb.api.p_le_callback = 0x%x ", btm_cb.api.p_le_callback); + LOG_INFO("%s btm_cb.api.p_le_callback = 0x%p ", __func__, btm_cb.api.p_le_callback); #endif - BTM_TRACE_EVENT ("BTM_Sec: application registered"); + BTM_TRACE_EVENT("%s application registered", __func__); return(TRUE); } - -/******************************************************************************* -** -** Function BTM_SecRegisterLinkKeyNotificationCallback -** -** Description Application manager calls this function to register for -** link key notification. When there is nobody registered -** we should avoid changing link key -** -** Returns TRUE if registered OK, else FALSE -** -*******************************************************************************/ -BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback (tBTM_LINK_KEY_CALLBACK *p_callback) -{ - btm_cb.api.p_link_key_callback = p_callback; - return(TRUE); -} - - /******************************************************************************* ** ** Function BTM_SecAddRmtNameNotifyCallback @@ -302,38 +284,6 @@ BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback) return(FALSE); } - -/******************************************************************************* -** -** Function BTM_SecSetConnectFilterCallback -** -** Description Host can register to be asked whenever a HCI connection -** request is received. In the registered function host -** suppose to check connectibility filters. Yes/No result -** should be returned syncronously -** -** Returns void -** -*******************************************************************************/ -void BTM_SecSetConnectFilterCallback (tBTM_FILTER_CB *p_callback) -{ - btm_cb.p_conn_filter_cb = p_callback; -} - -/******************************************************************************* -** -** Function BTM_GetSecurityMode -** -** Description Get security mode for the device -** -** Returns void -** -*******************************************************************************/ -UINT8 BTM_GetSecurityMode (void) -{ - return(btm_cb.security_mode); -} - /******************************************************************************* ** ** Function BTM_GetSecurityFlags @@ -385,75 +335,6 @@ BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr, UINT8 * p_sec_flags, /******************************************************************************* ** -** Function BTM_SetSecurityMode -** -** Description Set security mode for the device -** -** Returns void -** -*******************************************************************************/ -void BTM_SetSecurityMode (UINT8 security_mode) -{ - UINT8 sp_mode = HCI_SP_MODE_ENABLED; - UINT8 sp_debug_mode = HCI_SPD_MODE_DISABLED; - - switch (security_mode) - { -#if (BTM_PRE_LISBON_INCLUDED == TRUE) - case BTM_SEC_MODE_NONE: - case BTM_SEC_MODE_SERVICE: - case BTM_SEC_MODE_LINK: - break; -#endif - - case BTM_SEC_MODE_SP_DEBUG: - sp_debug_mode = HCI_SPD_MODE_ENABLED; - break; - case BTM_SEC_MODE_SP: - /* the default is enabled */ - break; - default: - BTM_TRACE_ERROR ("BTM_SetSecurityMode: unknown mode:%d", security_mode); - return; - } - btm_cb.security_mode = security_mode; - - if (HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) - { - /* Lisbon devices and only use BTM_SEC_MODE_SP */ - btm_cb.security_mode = BTM_SEC_MODE_SP; - BTM_TRACE_DEBUG("BTM_SetSecurityMode: SP:%d, debug:%d", sp_mode, sp_debug_mode); - btsnd_hcic_write_simple_pairing_mode(sp_mode); - btsnd_hcic_write_simp_pair_debug_mode(sp_debug_mode); - return; - } - - /* must be a pre-Lisbon device */ -#if (BTM_PRE_LISBON_INCLUDED == TRUE) - /* If previously security mode was Link Level and now lesser notify */ - /* controller not to perform authentication, encryption on startup */ - if ((old_mode == BTM_SEC_MODE_LINK) - && ( security_mode != BTM_SEC_MODE_LINK)) - { - BTM_TRACE_DEBUG("BTM_SetSecurityMode: Authen Enable -> FALSE"); - btsnd_hcic_write_auth_enable (FALSE); - btsnd_hcic_write_encr_mode (HCI_ENCRYPT_MODE_DISABLED); - } - - /* If previously security is increased to Link Level notify */ - /* controller to perform authentication, encryption on startup */ - if ((old_mode != BTM_SEC_MODE_LINK) - && ( security_mode == BTM_SEC_MODE_LINK)) - { - BTM_TRACE_DEBUG("BTM_SetSecurityMode: Authen Enable -> TRUE"); - btsnd_hcic_write_auth_enable (TRUE); - btsnd_hcic_write_encr_mode (HCI_ENCRYPT_MODE_POINT_TO_POINT); - } -#endif /* BTM_PRE_LISBON_INCLUDED == TRUE */ -} - -/******************************************************************************* -** ** Function BTM_SetPinType ** ** Description Set PIN type for the device. @@ -468,7 +349,7 @@ void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len) /* If device is not up security mode will be set as a part of startup */ if ( (btm_cb.cfg.pin_type != pin_type) - && (btm_cb.devcb.state > BTM_DEV_STATE_WAIT_AFTER_RESET) ) + && controller_get_interface()->get_is_ready() ) { btsnd_hcic_write_pin_type (pin_type); } @@ -505,51 +386,6 @@ void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired) /******************************************************************************* ** -** Function BTM_SetUCDSecurityLevel -** -** Description Register UCD service security level with Security Manager -** -** Parameters: is_originator - TRUE if originating the connection, FALSE if not -** p_name - Name of the service relevant only if -** authorization will show this name to user. ignored -** if BTM_SEC_SERVICE_NAME_LEN is 0. -** service_id - service ID for the service passed to authorization callback -** sec_level - bit mask of the security features -** psm - L2CAP PSM -** mx_proto_id - protocol ID of multiplexing proto below -** mx_chan_id - channel ID of multiplexing proto below -** -** Returns TRUE if registered OK, else FALSE -** -*******************************************************************************/ -BOOLEAN BTM_SetUCDSecurityLevel (BOOLEAN is_originator, char *p_name, UINT8 service_id, - UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id, - UINT32 mx_chan_id) -{ -#if (L2CAP_UCD_INCLUDED == TRUE) - CONNECTION_TYPE conn_type; - - if (is_originator) - conn_type = CONNLESS_ORIG; - else - conn_type = CONNLESS_TERM; - - return(btm_sec_set_security_level (conn_type, p_name, service_id, - sec_level, psm, mx_proto_id, mx_chan_id)); -#else - UNUSED(is_originator); - UNUSED(p_name); - UNUSED(service_id); - UNUSED(sec_level); - UNUSED(psm); - UNUSED(mx_proto_id); - UNUSED(mx_chan_id); - return FALSE; -#endif -} - -/******************************************************************************* -** ** Function BTM_SetSecurityLevel ** ** Description Register service security level with Security Manager @@ -922,45 +758,6 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda) /******************************************************************************* ** -** -** Function BTM_SecClrUCDService -** -** Description -** -** Parameters Service ID - Id of the service to remove. -** ('0' removes all service records ) -** -** Returns Number of records that were cleared. -** -*******************************************************************************/ -UINT8 BTM_SecClrUCDService (UINT8 service_id) -{ -#if (L2CAP_UCD_INCLUDED == TRUE) - tBTM_SEC_SERV_REC *p_srec = &btm_cb.sec_serv_rec[0]; - UINT8 num_cleared = 0; - int i; - - for (i = 0; i < BTM_SEC_MAX_SERVICE_RECORDS; i++, p_srec++) - { - /* Delete services with specified name (if in use and not SDP) */ - if ((p_srec->security_flags & BTM_SEC_IN_USE) && - (!service_id || (service_id == (UINT32)p_srec->service_id))) - { - BTM_TRACE_API("BTM_UCD_SEC_CLR[%d]: id %d", i, service_id); - p_srec->ucd_security_flags = 0; - num_cleared++; - } - } - - return(num_cleared); -#else - UNUSED(service_id); - return(0); -#endif -} - -/******************************************************************************* -** ** Function BTM_PINCodeReply ** ** Description This function is called after Security Manager submitted @@ -1082,67 +879,6 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, btsnd_hcic_pin_code_req_reply (bd_addr, pin_len, p_pin); } - -/******************************************************************************* -** -** Function BTM_DeviceAuthorized -** -** Description This function is called after Security Manager submitted -** authorization request to the UI. -** -** Parameters: bd_addr - Address of the device for which PIN was requested -** res - result of the operation BTM_SUCCESS if success -** -*******************************************************************************/ -void BTM_DeviceAuthorized (BD_ADDR bd_addr, UINT8 res, UINT32 trusted_mask[]) -{ - tBTM_SEC_DEV_REC *p_dev_rec; - - if ((p_dev_rec = btm_find_dev (bd_addr)) == NULL) - { - BTM_TRACE_WARNING ("Security Manager: Attempting Authorization of Unknown Device Address [%02x%02x%02x%02x%02x%02x]", - bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]); - return; - } - - BTM_TRACE_EVENT ("Security Manager: authorized status:%d State:%d Trusted:%08x %08x", - res, (p_dev_rec) ? p_dev_rec->sec_state : 0, trusted_mask[0], trusted_mask[1]); - - if (res == BTM_SUCCESS) - { - p_dev_rec->sec_flags |= BTM_SEC_AUTHORIZED; - if (trusted_mask) - { - BTM_SEC_COPY_TRUSTED_DEVICE(trusted_mask, p_dev_rec->trusted_mask); - } - - /* Save the currently authorized service in case we are asked again - by another multiplexer layer */ - if (!p_dev_rec->is_originator) - { - BTM_TRACE_DEBUG("BTM_DeviceAuthorized: Setting last_author_service_id to %d", - p_dev_rec->p_cur_service->service_id); - p_dev_rec->last_author_service_id = p_dev_rec->p_cur_service->service_id; - } - } - - if (p_dev_rec->sec_state != BTM_SEC_STATE_AUTHORIZING) - return; - - p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; - - if (res != BTM_SUCCESS) - { - btm_sec_dev_rec_cback_event (p_dev_rec, res, FALSE); - return; - } - - if ((res = (UINT8)btm_sec_execute_procedure (p_dev_rec)) != BTM_CMD_STARTED) - { - btm_sec_dev_rec_cback_event (p_dev_rec, res, FALSE); - } -} - /******************************************************************************* ** ** Function btm_sec_bond_by_transport @@ -1241,7 +977,7 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, BTM_TRACE_DEBUG ("after update sec_flags=0x%x", p_dev_rec->sec_flags); - if (!HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + if (!controller_get_interface()->supports_simple_pairing()) { /* The special case when we authenticate keyboard. Set pin type to fixed */ /* It would be probably better to do it from the application, but it is */ @@ -1284,7 +1020,7 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport, } BTM_TRACE_DEBUG ("sec mode: %d sm4:x%x", btm_cb.security_mode, p_dev_rec->sm4); - if (!HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0]) + if (!controller_get_interface()->supports_simple_pairing() || (p_dev_rec->sm4 == BTM_SM4_KNOWN)) { if ( btm_sec_check_prefetch_pin (p_dev_rec) ) @@ -1470,37 +1206,6 @@ tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr) /******************************************************************************* ** -** Function BTM_SecUseMasterLinkKey -** -** Description This function is called to tell master of the piconet to -** switch to master link key -** -** Parameters: use_master_key - If true Master Link Key shoul be used -** -*******************************************************************************/ -tBTM_STATUS BTM_SecUseMasterLinkKey (BOOLEAN use_master_key) -{ - return(btsnd_hcic_master_link_key (use_master_key) ? BTM_SUCCESS : - BTM_NO_RESOURCES); -} - -/******************************************************************************* -** -** Function BTM_SetMasterKeyCompCback -** -** Description This function is called to register for the master key complete -** status event. -** -** Parameters: mkey_cback - callback registered with the security manager -** -*******************************************************************************/ -void BTM_SetMasterKeyCompCback( tBTM_MKEY_CALLBACK *mkey_cback ) -{ - btm_cb.mkey_cback = mkey_cback; -} - -/******************************************************************************* -** ** Function BTM_SecGetDeviceLinkKey ** ** Description This function is called to obtain link key for the device @@ -1935,7 +1640,7 @@ UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c, { /* add mandatory part */ UINT16_TO_STREAM(p, len); - BDADDR_TO_STREAM(p, btm_cb.devcb.local_addr); + BDADDR_TO_STREAM(p, controller_get_interface()->get_address()->address); len = BTM_OOB_MANDATORY_SIZE; max_len -= len; @@ -2485,7 +2190,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle 2046 may report HCI_Encryption_Change and L2C Connection Request out of sequence because of data path issues. Delay this disconnect a little bit */ - BTM_TRACE_ERROR ("peer should have initiated security process by now (SM4 to SM4)"); + LOG_INFO("%s peer should have initiated security process by now (SM4 to SM4)", __func__); p_dev_rec->p_callback = p_callback; p_dev_rec->sec_state = BTM_SEC_STATE_DELAY_FOR_ENC; (*p_callback) (bd_addr, transport, p_ref_data, rc); @@ -2677,7 +2382,7 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda); /* Some device may request a connection before we are done with the HCI_Reset sequence */ - if (btm_cb.devcb.state != BTM_DEV_STATE_READY) + if (!controller_get_interface()->get_is_ready()) { BTM_TRACE_EVENT ("Security Manager: connect request when device not ready"); btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE); @@ -2710,19 +2415,6 @@ void btm_sec_conn_req (UINT8 *bda, UINT8 *dc) } #endif - /* Host can be registered to verify comming BDA or DC */ - if (btm_cb.p_conn_filter_cb) - { - if (!(* btm_cb.p_conn_filter_cb) (bda, dc)) - { - BTM_TRACE_EVENT ("Security Manager: connect request did not pass filter"); - - /* incomming call did not pass connection filters. Reject */ - btsnd_hcic_reject_conn (bda, HCI_ERR_HOST_REJECT_DEVICE); - return; - } - } - if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) &&(btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) &&(!memcmp (btm_cb.pairing_bda, bda, BD_ADDR_LEN))) @@ -2926,38 +2618,13 @@ void btm_sec_device_down (void) *******************************************************************************/ void btm_sec_dev_reset (void) { -#if (BTM_PRE_LISBON_INCLUDED == TRUE) - if (btm_cb.security_mode == BTM_SEC_MODE_LINK) - { - btsnd_hcic_write_auth_enable (TRUE); - btsnd_hcic_write_encr_mode (HCI_ENCRYPT_MODE_POINT_TO_POINT); - } -#endif -#if (BTM_PRE_LISBON_INCLUDED == TRUE) - else -#endif - /* btm_sec_dev_reset() is only called from btm_decode_ext_features_page(...) - * right now. */ - if (HCI_SIMPLE_PAIRING_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_0])) + if (controller_get_interface()->supports_simple_pairing()) { - btsnd_hcic_write_simple_pairing_mode(HCI_SP_MODE_ENABLED); -#if BLE_INCLUDED == TRUE - btsnd_hcic_set_event_mask(LOCAL_BR_EDR_CONTROLLER_ID, - (UINT8 *)HCI_DUMO_EVENT_MASK_EXT); - - btsnd_hcic_ble_set_evt_mask((UINT8 *)HCI_BLE_EVENT_MASK_DEF); - -#else - btsnd_hcic_set_event_mask(LOCAL_BR_EDR_CONTROLLER_ID, - (UINT8 *)HCI_LISBON_EVENT_MASK_EXT); -#endif /* set the default IO capabilities */ btm_cb.devcb.loc_io_caps = BTM_LOCAL_IO_CAPS; /* add mx service to use no security */ -#if (RFCOMM_INCLUDED == TRUE) BTM_SetSecurityLevel(FALSE, "RFC_MUX", BTM_SEC_SERVICE_RFC_MUX, BTM_SEC_NONE, BT_PSM_RFCOMM, BTM_SEC_PROTO_RFCOMM, 0); -#endif } else { @@ -2986,9 +2653,6 @@ void btm_sec_abort_access_req (BD_ADDR bd_addr) if (!p_dev_rec) return; - if (btm_cb.api.p_abort_callback) - (*btm_cb.api.p_abort_callback)(bd_addr, p_dev_rec->dev_class, p_dev_rec->sec_bd_name); - if ((p_dev_rec->sec_state != BTM_SEC_STATE_AUTHORIZING) && (p_dev_rec->sec_state != BTM_SEC_STATE_AUTHENTICATING)) return; @@ -3034,9 +2698,7 @@ static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec) return(BTM_NO_RESOURCES); } -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) btm_acl_update_busy_level (BTM_BLI_PAGE_EVT); -#endif BTM_TRACE_DEBUG ("Security Manager: btm_sec_dd_create_conn [%02x%02x%02x%02x%02x%02x]", p_dev_rec->bd_addr[0], p_dev_rec->bd_addr[1], p_dev_rec->bd_addr[2], @@ -3896,9 +3558,9 @@ static void btm_sec_auth_collision (UINT16 handle) tBTM_SEC_DEV_REC *p_dev_rec; if (!btm_cb.collision_start_time) - btm_cb.collision_start_time = GKI_get_tick_count (); + btm_cb.collision_start_time = GKI_get_os_tick_count(); - if ((GKI_get_tick_count () - btm_cb.collision_start_time) < btm_cb.max_collision_delay) + if ((GKI_get_os_tick_count() - btm_cb.collision_start_time) < btm_cb.max_collision_delay) { if (handle == BTM_SEC_INVALID_HANDLE) { @@ -4103,35 +3765,6 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status) /******************************************************************************* ** -** Function btm_sec_mkey_comp_event -** -** Description This function is when encryption of the connection is -** completed by the LM -** -** Returns void -** -*******************************************************************************/ -void btm_sec_mkey_comp_event (UINT16 handle, UINT8 status, UINT8 key_flg) -{ - tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); - UINT8 bd_addr[BD_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} ; - - BTM_TRACE_EVENT ("Security Manager: mkey comp status:%d State:%d", - status, (p_dev_rec) ? p_dev_rec->sec_state : 0); - - /* If encryption setup failed, notify the waiting layer */ - /* There is no next procedure or start of procedure failed, notify the waiting layer */ - if (btm_cb.mkey_cback) - { - if (!p_dev_rec) - (btm_cb.mkey_cback)(bd_addr, status, key_flg ); - else - (btm_cb.mkey_cback)(p_dev_rec->bd_addr, status, key_flg ); - } -} - -/******************************************************************************* -** ** Function btm_sec_encrypt_change ** ** Description This function is when encryption of the connection is @@ -4231,38 +3864,6 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable) /******************************************************************************* ** -** Function btm_sec_create_conn -** -** Description This function records current role and forwards request to -** HCI -** -** Returns void -** -*******************************************************************************/ -BOOLEAN btm_sec_create_conn (BD_ADDR bda, UINT16 packet_types, - UINT8 page_scan_rep_mode, UINT8 page_scan_mode, - UINT16 clock_offset, UINT8 allow_switch) -{ - tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (bda); - - memcpy (btm_cb.connecting_bda, p_dev_rec->bd_addr, BD_ADDR_LEN); - memcpy (btm_cb.connecting_dc, p_dev_rec->dev_class, DEV_CLASS_LEN); - - btm_cb.acl_disc_reason = 0xff ; - - p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; - p_dev_rec->role_master = TRUE; - - /* If any SCO link up, do not allow a switch */ - if (BTM_GetNumScoLinks() != 0) - allow_switch = HCI_CR_CONN_NOT_ALLOW_SWITCH; - - return(btsnd_hcic_create_conn (bda, packet_types, page_scan_rep_mode, - page_scan_mode, clock_offset, allow_switch)); -} - -/******************************************************************************* -** ** Function btm_sec_connect_after_reject_timeout ** ** Description Connection for bonding could not start because of the collision @@ -4597,48 +4198,6 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode) /******************************************************************************* ** -** Function btm_sec_role_changed -** -** Description This function is colled when controller reports role -** changed, or failed command status for Role Change request -** -** Returns void -** -*******************************************************************************/ -void btm_sec_role_changed (void *p_ref_data) -{ - tBTM_SEC_DEV_REC *p_dev_rec = (tBTM_SEC_DEV_REC *)p_ref_data; - UINT8 res; - - BTM_TRACE_EVENT ("Security Manager: role changed"); - - /* If this role switch was started by peer do not need to do anything */ - if (p_dev_rec->sec_state != BTM_SEC_STATE_SWITCHING_ROLE) - return; - - /* If serurity required was to FORCE switch and it failed, notify the waiting layer */ - if (((p_dev_rec->security_required & BTM_SEC_FORCE_MASTER) && !p_dev_rec->role_master) - || ((p_dev_rec->security_required & BTM_SEC_FORCE_SLAVE) && p_dev_rec->role_master)) - { - btm_sec_dev_rec_cback_event (p_dev_rec, BTM_ERR_PROCESSING, FALSE); - return; - } - - p_dev_rec->sec_flags |= BTM_SEC_ROLE_SWITCHED; - - p_dev_rec->security_required &= ~(BTM_SEC_FORCE_MASTER | BTM_SEC_ATTEMPT_MASTER | - BTM_SEC_FORCE_SLAVE | BTM_SEC_ATTEMPT_SLAVE); - - p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; - - if ((res = (UINT8)btm_sec_execute_procedure (p_dev_rec)) != BTM_CMD_STARTED) - { - btm_sec_dev_rec_cback_event (p_dev_rec, res, FALSE); - } -} - -/******************************************************************************* -** ** Function btm_sec_disconnect ** ** Description This function is called to disconnect HCI link @@ -4701,18 +4260,19 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason) p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */ #if BTM_DISC_DURING_RS == TRUE - BTM_TRACE_ERROR("btm_sec_disconnected - Clearing Pending flag"); + LOG_INFO("%s clearing pending flag handle:%d reason:%d", __func__, handle, reason); p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */ #endif /* clear unused flags */ p_dev_rec->sm4 &= BTM_SM4_TRUE; - BTM_TRACE_EVENT("btm_sec_disconnected() sec_req:x%x State: %s reason:%d bda:%04x%08x RName:%s", - p_dev_rec->security_required, btm_pair_state_descr(btm_cb.pairing_state), reason, (p_dev_rec->bd_addr[0]<<8)+p_dev_rec->bd_addr[1], - (p_dev_rec->bd_addr[2]<<24)+(p_dev_rec->bd_addr[3]<<16)+(p_dev_rec->bd_addr[4]<<8)+p_dev_rec->bd_addr[5], p_dev_rec->sec_bd_name); + uint8_t *bd_addr = (uint8_t *)p_dev_rec->bd_addr; + BTM_TRACE_EVENT("%s sec_req:x%x state:%s reason:%d bd_addr:%02x:%02x:%02x:%02x:%02x:%02x" + " remote_name:%s", __func__, p_dev_rec->security_required, btm_pair_state_descr(btm_cb.pairing_state), + reason, bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5], p_dev_rec->sec_bd_name); - BTM_TRACE_EVENT("before Update sec_flags=0x%x", p_dev_rec->sec_flags); + BTM_TRACE_EVENT("%s before update sec_flags=0x%x", __func__, p_dev_rec->sec_flags); /* If we are in the process of bonding we need to tell client that auth failed */ if ( (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) @@ -4769,7 +4329,7 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason) (*p_callback) (p_dev_rec->bd_addr, transport, p_dev_rec->p_ref_data, BTM_ERR_PROCESSING); } - BTM_TRACE_EVENT("after Update sec_flags=0x%x", p_dev_rec->sec_flags); + BTM_TRACE_EVENT("%s after update sec_flags=0x%x", __func__, p_dev_rec->sec_flags); } /******************************************************************************* @@ -4794,9 +4354,6 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t /* If connection was made to do bonding restore link security if changed */ btm_restore_mode(); - /* Override the key type if version is pre-1.1 */ - if (btm_cb.devcb.local_version.hci_version < HCI_VERSION_1_1) - p_dev_rec->link_key_type = BTM_LKEY_TYPE_IGNORE; if (key_type != BTM_LKEY_TYPE_CHANGED_COMB) p_dev_rec->link_key_type = key_type; @@ -4895,20 +4452,6 @@ void btm_sec_link_key_request (UINT8 *p_bda) /* Notify L2CAP to increase timeout */ l2c_pin_code_request (p_bda); - /* Only ask the host for a key if this guy is not already bonding */ - if ( (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) - || (memcmp (p_bda, btm_cb.pairing_bda, BD_ADDR_LEN) != 0) ) - { - if (btm_cb.api.p_link_key_req_callback) - { - if ((*btm_cb.api.p_link_key_req_callback)(p_bda, p_dev_rec->link_key) == BTM_SUCCESS) - { - btsnd_hcic_link_key_req_reply (p_bda, p_dev_rec->link_key); - return; - } - } - } - /* The link key is not in the database and it is not known to the manager */ btsnd_hcic_link_key_neg_reply (p_bda); } @@ -5755,41 +5298,6 @@ tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state) /******************************************************************************* ** -** Function BTM_snd_conn_encrypt -** -** Description This function is called to start/stop encryption -** Used by JSR-82 -** -** Returns TRUE if request started -** -*******************************************************************************/ -BOOLEAN BTM_snd_conn_encrypt (UINT16 handle, BOOLEAN enable) -{ - tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev_by_handle (handle); - - BTM_TRACE_EVENT ("BTM_snd_conn_encrypt Security Manager: encrypt_change p_dev_rec : 0x%x, enable = %s", p_dev_rec, (enable == TRUE) ? "TRUE" : "FALSE"); - - if (!p_dev_rec) - { - BTM_TRACE_EVENT ("BTM_snd_conn_encrypt Error no p_dev_rec : 0x%x\n", p_dev_rec); - return(FALSE); - } - - if ( p_dev_rec->sec_state == BTM_SEC_STATE_IDLE) - { - if (!btsnd_hcic_set_conn_encrypt (handle, enable)) - return(FALSE); - - p_dev_rec->sec_state = BTM_SEC_STATE_ENCRYPTING; - - return(TRUE); - } - else - return(FALSE); -} - -/******************************************************************************* -** ** Function btm_sec_change_pairing_state ** ** Description This function is called to change pairing state diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c index 9ec8dd3cb..c8a45d384 100644 --- a/stack/btu/btu_hcif.c +++ b/stack/btu/btu_hcif.c @@ -25,6 +25,9 @@ * ******************************************************************************/ +#define LOG_TAG "bt_btu_hcif" + +#include <assert.h> #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -36,39 +39,25 @@ #include "l2c_int.h" #include "btm_api.h" #include "btm_int.h" +#include "bt_utils.h" +#include "osi/include/osi.h" +#include "osi/include/log.h" +#include "hci_layer.h" + +// TODO(zachoverflow): remove this horrible hack +#include "btu.h" +extern fixed_queue_t *btu_hci_msg_queue; extern void btm_process_cancel_complete(UINT8 status, UINT8 mode); extern void btm_ble_test_command_complete(UINT8 *p); -// btla-specific ++ -#define LOG_TAG "BTLD" -#if (defined(ANDROID_APP_INCLUDED) && (ANDROID_APP_INCLUDED == TRUE) && (!defined(LINUX_NATIVE)) ) -#include <cutils/log.h> -#else -#define LOGV(format, ...) fprintf (stdout, LOG_TAG format"\n", ## __VA_ARGS__) -#define LOGE(format, ...) fprintf (stderr, LOG_TAG format"\n", ## __VA_ARGS__) -#define LOGI(format, ...) fprintf (stdout, LOG_TAG format"\n", ## __VA_ARGS__) -#endif - -// btla-specific ++ -/* BTE application task */ -#if APPL_INCLUDED == TRUE -#include "bte_appl.h" -#endif -// btla-specific -- - -//Counter to track number of HCI command timeout -static int num_hci_cmds_timed_out; - /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /********************************************************************************/ static void btu_hcif_inquiry_comp_evt (UINT8 *p); static void btu_hcif_inquiry_result_evt (UINT8 *p); static void btu_hcif_inquiry_rssi_result_evt (UINT8 *p); -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) static void btu_hcif_extended_inquiry_result_evt (UINT8 *p); -#endif static void btu_hcif_connection_comp_evt (UINT8 *p); static void btu_hcif_connection_request_evt (UINT8 *p); @@ -76,20 +65,17 @@ static void btu_hcif_disconnection_comp_evt (UINT8 *p); static void btu_hcif_authentication_comp_evt (UINT8 *p); static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len); static void btu_hcif_encryption_change_evt (UINT8 *p); -static void btu_hcif_change_conn_link_key_evt (UINT8 *p); -static void btu_hcif_master_link_key_comp_evt (UINT8 *p); static void btu_hcif_read_rmt_features_comp_evt (UINT8 *p); static void btu_hcif_read_rmt_ext_features_comp_evt (UINT8 *p); static void btu_hcif_read_rmt_version_comp_evt (UINT8 *p); static void btu_hcif_qos_setup_comp_evt (UINT8 *p); -static void btu_hcif_command_complete_evt (UINT8 controller_id, UINT8 *p, UINT16 evt_len); -static void btu_hcif_command_status_evt (UINT8 controller_id, UINT8 *p); +static void btu_hcif_command_complete_evt (BT_HDR *response, void *context); +static void btu_hcif_command_status_evt (uint8_t status, BT_HDR *command, void *context); static void btu_hcif_hardware_error_evt (UINT8 *p); static void btu_hcif_flush_occured_evt (void); static void btu_hcif_role_change_evt (UINT8 *p); static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p); static void btu_hcif_mode_change_evt (UINT8 *p); -static void btu_hcif_return_link_keys_evt (UINT8 *p); static void btu_hcif_pin_code_request_evt (UINT8 *p); static void btu_hcif_link_key_request_evt (UINT8 *p); static void btu_hcif_link_key_notification_evt (UINT8 *p); @@ -112,7 +98,6 @@ static void btu_hcif_user_conf_request_evt (UINT8 *p); static void btu_hcif_user_passkey_request_evt (UINT8 *p); static void btu_hcif_user_passkey_notif_evt (UINT8 *p); static void btu_hcif_keypress_notif_evt (UINT8 *p); -static void btu_hcif_link_super_tout_evt (UINT8 *p); #if BTM_OOB_INCLUDED == TRUE static void btu_hcif_rem_oob_request_evt (UINT8 *p); @@ -127,11 +112,6 @@ static void btu_hcif_enhanced_flush_complete_evt (void); static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len); #endif /* BTM_SSR_INCLUDED == TRUE */ - #if (HID_DEV_INCLUDED == TRUE) && (HID_DEV_PM_INCLUDED == TRUE) -extern void hidd_pm_proc_mode_change( UINT8 hci_status, UINT8 mode, UINT16 interval ); - #endif - - #if BLE_INCLUDED == TRUE static void btu_ble_ll_conn_complete_evt (UINT8 *p, UINT16 evt_len); static void btu_ble_process_adv_pkt (UINT8 *p); @@ -143,77 +123,6 @@ static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p); static void btu_ble_rc_param_req_evt(UINT8 *p); #endif #endif -/******************************************************************************* -** -** Function btu_hcif_store_cmd -** -** Description This function stores a copy of an outgoing command and -** and sets a timer waiting for a event in response to the -** command. -** -** Returns void -** -*******************************************************************************/ -static void btu_hcif_store_cmd (UINT8 controller_id, BT_HDR *p_buf) -{ - tHCI_CMD_CB *p_hci_cmd_cb; - UINT16 opcode; - BT_HDR *p_cmd; - UINT8 *p; - - /* Validate controller ID */ - if (controller_id >= BTU_MAX_LOCAL_CTRLS) - return; - - p_hci_cmd_cb = &(btu_cb.hci_cmd_cb[controller_id]); - p = (UINT8 *)(p_buf + 1) + p_buf->offset; - - /* get command opcode */ - STREAM_TO_UINT16 (opcode, p); - - /* don't do anything for certain commands */ - if ((opcode == HCI_RESET) || (opcode == HCI_HOST_NUM_PACKETS_DONE)) - { - return; - } - - /* allocate buffer (HCI_GET_CMD_BUF will either get a buffer from HCI_CMD_POOL or from 'best-fit' pool) */ - if ((p_cmd = HCI_GET_CMD_BUF(p_buf->len + p_buf->offset - HCIC_PREAMBLE_SIZE)) == NULL) - { - return; - } - - /* copy buffer */ - memcpy (p_cmd, p_buf, sizeof(BT_HDR)); - - /* If vendor specific save the callback function */ - if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC -#if BLE_INCLUDED == TRUE - || (opcode == HCI_BLE_RAND ) - || (opcode == HCI_BLE_ENCRYPT) -#endif - ) - { - memcpy ((UINT8 *)(p_cmd + 1), (UINT8 *)(p_buf + 1), sizeof(void *)); - } - - memcpy ((UINT8 *)(p_cmd + 1) + p_cmd->offset, - (UINT8 *)(p_buf + 1) + p_buf->offset, p_buf->len); - - /* queue copy of cmd */ - GKI_enqueue(&(p_hci_cmd_cb->cmd_cmpl_q), p_cmd); - - /* start timer */ - if (BTU_CMD_CMPL_TIMEOUT > 0) - { -#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE) - p_hci_cmd_cb->checked_hcisu = FALSE; -#endif - btu_start_timer (&(p_hci_cmd_cb->cmd_cmpl_timer), - (UINT16)(BTU_TTYPE_BTU_CMD_CMPL + controller_id), - BTU_CMD_CMPL_TIMEOUT); - } -} /******************************************************************************* ** @@ -225,7 +134,7 @@ static void btu_hcif_store_cmd (UINT8 controller_id, BT_HDR *p_buf) ** Returns void ** *******************************************************************************/ -void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) +void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) { UINT8 *p = (UINT8 *)(p_msg + 1) + p_msg->offset; UINT8 hci_evt_code, hci_evt_len; @@ -246,11 +155,9 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) case HCI_INQUIRY_RSSI_RESULT_EVT: btu_hcif_inquiry_rssi_result_evt (p); break; -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) case HCI_EXTENDED_INQUIRY_RESULT_EVT: btu_hcif_extended_inquiry_result_evt (p); break; -#endif case HCI_CONNECTION_COMP_EVT: btu_hcif_connection_comp_evt (p); break; @@ -274,12 +181,6 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) btu_hcif_encryption_key_refresh_cmpl_evt(p); break; #endif - case HCI_CHANGE_CONN_LINK_KEY_EVT: - btu_hcif_change_conn_link_key_evt (p); - break; - case HCI_MASTER_LINK_KEY_COMP_EVT: - btu_hcif_master_link_key_comp_evt (p); - break; case HCI_READ_RMT_FEATURES_COMP_EVT: btu_hcif_read_rmt_features_comp_evt (p); break; @@ -293,10 +194,12 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) btu_hcif_qos_setup_comp_evt (p); break; case HCI_COMMAND_COMPLETE_EVT: - btu_hcif_command_complete_evt (controller_id, p, hci_evt_len); + LOG_ERROR("%s should not have received a command complete event. " + "Someone didn't go through the hci transmit_command function.", __func__); break; case HCI_COMMAND_STATUS_EVT: - btu_hcif_command_status_evt (controller_id, p); + LOG_ERROR("%s should not have received a command status event. " + "Someone didn't go through the hci transmit_command function.", __func__); break; case HCI_HARDWARE_ERROR_EVT: btu_hcif_hardware_error_evt (p); @@ -313,9 +216,6 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) case HCI_MODE_CHANGE_EVT: btu_hcif_mode_change_evt (p); break; - case HCI_RETURN_LINK_KEYS_EVT: - btu_hcif_return_link_keys_evt (p); - break; case HCI_PIN_CODE_REQUEST_EVT: btu_hcif_pin_code_request_evt (p); break; @@ -389,9 +289,6 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) case HCI_KEYPRESS_NOTIFY_EVT: btu_hcif_keypress_notif_evt (p); break; - case HCI_LINK_SUPER_TOUT_CHANGED_EVT: - btu_hcif_link_super_tout_evt (p); - break; #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE case HCI_ENHANCED_FLUSH_COMPLETE_EVT: btu_hcif_enhanced_flush_complete_evt (); @@ -434,8 +331,6 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) btm_vendor_specific_evt (p, hci_evt_len); break; } - // reset the num_hci_cmds_timed_out upon receving any event from controller. - num_hci_cmds_timed_out = 0; } @@ -443,88 +338,40 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) ** ** Function btu_hcif_send_cmd ** -** Description This function is called to check if it can send commands -** to the Host Controller. It may be passed the address of -** a packet to send. +** Description This function is called to send commands to the Host Controller. ** ** Returns void ** *******************************************************************************/ -void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_buf) +void btu_hcif_send_cmd (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_buf) { - tHCI_CMD_CB * p_hci_cmd_cb = &(btu_cb.hci_cmd_cb[controller_id]); - -#if ((L2CAP_HOST_FLOW_CTRL == TRUE)||defined(HCI_TESTER)) - UINT8 *pp; - UINT16 code; -#endif - - /* If there are already commands in the queue, then enqueue this command */ - if ((p_buf) && (p_hci_cmd_cb->cmd_xmit_q.count)) - { - GKI_enqueue (&(p_hci_cmd_cb->cmd_xmit_q), p_buf); - p_buf = NULL; - } + if (!p_buf) + return; - /* Allow for startup case, where no acks may be received */ - if ( ((controller_id == LOCAL_BR_EDR_CONTROLLER_ID) - && (p_hci_cmd_cb->cmd_window == 0) - && (btm_cb.devcb.state == BTM_DEV_STATE_WAIT_RESET_CMPLT)) ) - { - p_hci_cmd_cb->cmd_window = p_hci_cmd_cb->cmd_xmit_q.count + 1; - } - - /* See if we can send anything */ - while (p_hci_cmd_cb->cmd_window != 0) - { - if (!p_buf) - p_buf = (BT_HDR *)GKI_dequeue (&(p_hci_cmd_cb->cmd_xmit_q)); - - if (p_buf) - { - btu_hcif_store_cmd(controller_id, p_buf); + uint16_t opcode; + uint8_t *stream = p_buf->data + p_buf->offset; + void * vsc_callback = NULL; -#if ((L2CAP_HOST_FLOW_CTRL == TRUE)||defined(HCI_TESTER)) - pp = (UINT8 *)(p_buf + 1) + p_buf->offset; + STREAM_TO_UINT16(opcode, stream); - STREAM_TO_UINT16 (code, pp); - - /* - * We do not need to decrease window for host flow control, - * host flow control does not receive an event back from controller - */ - if (code != HCI_HOST_NUM_PACKETS_DONE) + // Eww...horrible hackery here + /* If command was a VSC, then extract command_complete callback */ + if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC +#if BLE_INCLUDED == TRUE + || (opcode == HCI_BLE_RAND) + || (opcode == HCI_BLE_ENCRYPT) #endif - p_hci_cmd_cb->cmd_window--; - - if (controller_id == LOCAL_BR_EDR_CONTROLLER_ID) - { - HCI_CMD_TO_LOWER(p_buf); - } - else - { - /* Unknown controller */ - HCI_TRACE_WARNING("BTU HCI(ctrl id=%d) controller ID not recognized", controller_id); - GKI_freebuf(p_buf);; - } - - p_buf = NULL; - } - else - break; + ) { + vsc_callback = *((void **)(p_buf + 1)); } - if (p_buf) - GKI_enqueue (&(p_hci_cmd_cb->cmd_xmit_q), p_buf); - -#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE) - if (controller_id == LOCAL_BR_EDR_CONTROLLER_ID) - { - /* check if controller can go to sleep */ - btu_check_bt_sleep (); - } -#endif + hci_layer_get_interface()->transmit_command( + p_buf, + btu_hcif_command_complete_evt, + btu_hcif_command_status_evt, + vsc_callback); + btu_check_bt_sleep (); } @@ -616,13 +463,11 @@ static void btu_hcif_inquiry_rssi_result_evt (UINT8 *p) ** Returns void ** *******************************************************************************/ -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) static void btu_hcif_extended_inquiry_result_evt (UINT8 *p) { /* Store results in the cache */ btm_process_inq_results (p, BTM_INQ_RESULT_EXTENDED); } -#endif /******************************************************************************* ** @@ -715,11 +560,10 @@ static void btu_hcif_connection_request_evt (UINT8 *p) *******************************************************************************/ static void btu_hcif_disconnection_comp_evt (UINT8 *p) { - UINT8 status; UINT16 handle; UINT8 reason; - STREAM_TO_UINT8 (status, p); + ++p; STREAM_TO_UINT16 (handle, p); STREAM_TO_UINT8 (reason, p); @@ -806,51 +650,6 @@ static void btu_hcif_encryption_change_evt (UINT8 *p) btm_sec_encrypt_change (handle, status, encr_enable); } - -/******************************************************************************* -** -** Function btu_hcif_change_conn_link_key_evt -** -** Description Process event HCI_CHANGE_CONN_LINK_KEY_EVT -** -** Returns void -** -*******************************************************************************/ -static void btu_hcif_change_conn_link_key_evt (UINT8 *p) -{ - UINT8 status; - UINT16 handle; - - STREAM_TO_UINT8 (status, p); - STREAM_TO_UINT16 (handle, p); - - btm_acl_link_key_change (handle, status); -} - - -/******************************************************************************* -** -** Function btu_hcif_master_link_key_comp_evt -** -** Description Process event HCI_MASTER_LINK_KEY_COMP_EVT -** -** Returns void -** -*******************************************************************************/ -static void btu_hcif_master_link_key_comp_evt (UINT8 *p) -{ - UINT8 status; - UINT16 handle; - UINT8 key_flg; - - STREAM_TO_UINT8 (status, p); - STREAM_TO_UINT16 (handle, p); - STREAM_TO_UINT8 (key_flg, p); - - btm_sec_mkey_comp_event (handle, status, key_flg); -} - - /******************************************************************************* ** ** Function btu_hcif_read_rmt_features_comp_evt @@ -1014,10 +813,6 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l { switch (opcode) { - case HCI_RESET: - btm_reset_complete (); /* BR/EDR */ - break; - case HCI_INQUIRY_CANCEL: /* Tell inquiry processing that we are done */ btm_process_cancel_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK); @@ -1026,50 +821,14 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_event_filter_complete (p); break; - case HCI_READ_STORED_LINK_KEY: - btm_read_stored_link_key_complete (p); - break; - - case HCI_WRITE_STORED_LINK_KEY: - btm_write_stored_link_key_complete (p); - break; - case HCI_DELETE_STORED_LINK_KEY: btm_delete_stored_link_key_complete (p); break; - case HCI_READ_LOCAL_VERSION_INFO: - btm_read_local_version_complete (p, evt_len); - break; - - case HCI_READ_POLICY_SETTINGS: - btm_read_link_policy_complete (p); - break; - - case HCI_READ_BUFFER_SIZE: - btm_read_hci_buf_size_complete (p, evt_len); - break; - - case HCI_READ_LOCAL_SUPPORTED_CMDS: - btm_read_local_supported_cmds_complete (p); - break; - - case HCI_READ_LOCAL_FEATURES: - btm_read_local_features_complete (p, evt_len); - break; - - case HCI_READ_LOCAL_EXT_FEATURES: - btm_read_local_ext_features_complete (p, evt_len); - break; - case HCI_READ_LOCAL_NAME: btm_read_local_name_complete (p, evt_len); break; - case HCI_READ_BD_ADDR: - btm_read_local_addr_complete (p, evt_len); - break; - case HCI_GET_LINK_QUALITY: btm_read_link_quality_complete (p); break; @@ -1097,20 +856,8 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_read_linq_tx_power_complete (p); break; - case HCI_WRITE_SIMPLE_PAIRING_MODE: - btm_write_simple_paring_mode_complete (p); - break; - - case HCI_WRITE_LE_HOST_SUPPORTED: - btm_write_le_host_supported_complete (p); - break; - #if (BLE_INCLUDED == TRUE) /* BLE Commands sComplete*/ - case HCI_BLE_READ_WHITE_LIST_SIZE : - btm_read_white_list_size_complete(p, evt_len); - break; - case HCI_BLE_ADD_WHITE_LIST: btm_ble_add_2_white_list_complete(*p); break; @@ -1128,14 +875,6 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_ble_rand_enc_complete (p, opcode, (tBTM_RAND_ENC_CB *)p_cplt_cback); break; - case HCI_BLE_READ_BUFFER_SIZE: - btm_read_ble_buf_size_complete(p, evt_len); - break; - - case HCI_BLE_READ_LOCAL_SPT_FEAT: - btm_read_ble_local_supported_features_complete(p, evt_len); - break; - case HCI_BLE_READ_ADV_CHNL_TX_POWER: btm_read_tx_power_complete(p, TRUE); break; @@ -1144,10 +883,6 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_ble_write_adv_enable_complete(p); break; - case HCI_BLE_READ_SUPPORTED_STATES: - btm_read_ble_local_supported_states_complete(p, evt_len); - break; - case HCI_BLE_CREATE_LL_CONN: btm_ble_create_ll_conn_complete(*p); break; @@ -1175,91 +910,36 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l ** Returns void ** *******************************************************************************/ -static void btu_hcif_command_complete_evt (UINT8 controller_id, UINT8 *p, UINT16 evt_len) +static void btu_hcif_command_complete_evt_on_task(BT_HDR *event) { - tHCI_CMD_CB *p_hci_cmd_cb = &(btu_cb.hci_cmd_cb[controller_id]); - UINT16 cc_opcode; - BT_HDR *p_cmd; - void *p_cplt_cback = NULL; - - STREAM_TO_UINT8 (p_hci_cmd_cb->cmd_window, p); - -#if (defined(HCI_MAX_SIMUL_CMDS) && (HCI_MAX_SIMUL_CMDS > 0)) - if (p_hci_cmd_cb->cmd_window > HCI_MAX_SIMUL_CMDS) - p_hci_cmd_cb->cmd_window = HCI_MAX_SIMUL_CMDS; -#endif - - STREAM_TO_UINT16 (cc_opcode, p); - - evt_len -= 3; - - /* only do this for certain commands */ - if ((cc_opcode != HCI_RESET) && (cc_opcode != HCI_HOST_NUM_PACKETS_DONE) && - (cc_opcode != HCI_COMMAND_NONE)) - { - /* dequeue and free stored command */ - -/* always use cmd code check, when one cmd timeout waiting for cmd_cmpl, - it'll cause the rest of the command goes in wrong order */ - p_cmd = (BT_HDR *) GKI_getfirst (&p_hci_cmd_cb->cmd_cmpl_q); - - while (p_cmd) - { - UINT16 opcode_dequeued; - UINT8 *p_dequeued; - - /* Make sure dequeued command is for the command_cplt received */ - p_dequeued = (UINT8 *)(p_cmd + 1) + p_cmd->offset; - STREAM_TO_UINT16 (opcode_dequeued, p_dequeued); + command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0]; - if (opcode_dequeued != cc_opcode) - { - /* opcode does not match, check next command in the queue */ - p_cmd = (BT_HDR *) GKI_getnext(p_cmd); - continue; - } - GKI_remove_from_queue(&p_hci_cmd_cb->cmd_cmpl_q, p_cmd); + command_opcode_t opcode; + uint8_t *stream = hack->response->data + hack->response->offset + 3; // 2 to skip the event headers, 1 to skip the command credits + STREAM_TO_UINT16(opcode, stream); - /* If command was a VSC, then extract command_complete callback */ - if ((cc_opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC -#if BLE_INCLUDED == TRUE - || (cc_opcode == HCI_BLE_RAND ) - || (cc_opcode == HCI_BLE_ENCRYPT) -#endif - ) - { - p_cplt_cback = *((void **)(p_cmd + 1)); - } + btu_hcif_hdl_command_complete( + opcode, + stream, + hack->response->len - 5, // 3 for the command complete headers, 2 for the event headers + hack->context); - GKI_freebuf (p_cmd); + GKI_freebuf(hack->response); + osi_free(event); +} - break; - } +static void btu_hcif_command_complete_evt(BT_HDR *response, void *context) +{ + BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_complete_hack_t)); + command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0]; - /* if more commands in queue restart timer */ - if (BTU_CMD_CMPL_TIMEOUT > 0) - { - if (!GKI_queue_is_empty (&(p_hci_cmd_cb->cmd_cmpl_q))) - { -#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE) - p_hci_cmd_cb->checked_hcisu = FALSE; -#endif - btu_start_timer (&(p_hci_cmd_cb->cmd_cmpl_timer), - (UINT16)(BTU_TTYPE_BTU_CMD_CMPL + controller_id), - BTU_CMD_CMPL_TIMEOUT); - } - else - { - btu_stop_timer (&(p_hci_cmd_cb->cmd_cmpl_timer)); - } - } - } + hack->callback = btu_hcif_command_complete_evt_on_task; + hack->response = response; + hack->context = context; - /* handle event */ - btu_hcif_hdl_command_complete (cc_opcode, p, evt_len, p_cplt_cback); + event->event = BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK; - /* see if we can send more commands */ - btu_hcif_send_cmd (controller_id, NULL); + fixed_queue_enqueue(btu_hci_msg_queue, event); } @@ -1281,7 +961,6 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c tBTM_ESCO_DATA esco_data; #endif -#if BTM_PWR_MGR_INCLUDED == TRUE switch (opcode) { case HCI_EXIT_SNIFF_MODE: @@ -1307,7 +986,6 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c break; default: -#endif /* BTM_PWR_MGR_INCLUDED */ /* If command failed to start, we may need to tell BTM */ if (status != HCI_SUCCESS) { @@ -1325,18 +1003,6 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c btm_sec_rmt_name_request_complete (NULL, NULL, status); break; - case HCI_CHANGE_CONN_LINK_KEY: - /* Let host know we're done with error */ - /* read handle out of stored command */ - if (p_cmd != NULL) - { - p_cmd++; - STREAM_TO_UINT16 (handle, p_cmd); - - btm_acl_link_key_change (handle, status); - } - break; - case HCI_QOS_SETUP_COMP_EVT: /* Tell qos setup that we are done */ btm_qos_setup_complete(status,0,NULL); @@ -1430,9 +1096,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) btm_vsc_complete (&status, opcode, 1, (tBTM_CMPL_CB *)p_vsc_status_cback); } -#if BTM_PWR_MGR_INCLUDED == TRUE } -#endif } /******************************************************************************* @@ -1444,246 +1108,37 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c ** Returns void ** *******************************************************************************/ -static void btu_hcif_command_status_evt (UINT8 controller_id, UINT8 *p) +static void btu_hcif_command_status_evt_on_task(BT_HDR *event) { - tHCI_CMD_CB * p_hci_cmd_cb = &(btu_cb.hci_cmd_cb[controller_id]); - UINT8 status; - UINT16 opcode; - UINT16 cmd_opcode; - BT_HDR *p_cmd = NULL; - UINT8 *p_data = NULL; - void *p_vsc_status_cback = NULL; - - STREAM_TO_UINT8 (status, p); - STREAM_TO_UINT8 (p_hci_cmd_cb->cmd_window, p); - -#if (defined(HCI_MAX_SIMUL_CMDS) && (HCI_MAX_SIMUL_CMDS > 0)) - if (p_hci_cmd_cb->cmd_window > HCI_MAX_SIMUL_CMDS) - p_hci_cmd_cb->cmd_window = HCI_MAX_SIMUL_CMDS; -#endif + command_status_hack_t *hack = (command_status_hack_t *)&event->data[0]; - STREAM_TO_UINT16 (opcode, p); + command_opcode_t opcode; + uint8_t *stream = hack->command->data + hack->command->offset; + STREAM_TO_UINT16(opcode, stream); - /* only do this for certain commands */ - if ((opcode != HCI_RESET) && (opcode != HCI_HOST_NUM_PACKETS_DONE) && - (opcode != HCI_COMMAND_NONE)) - { - /*look for corresponding command in cmd_queue*/ - p_cmd = (BT_HDR *) GKI_getfirst(&(p_hci_cmd_cb->cmd_cmpl_q)); - while (p_cmd) - { - p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset; - STREAM_TO_UINT16 (cmd_opcode, p_data); - - /* Make sure this command is for the command_status received */ - if (cmd_opcode != opcode) - { - /* opcode does not match, check next command in the queue */ - p_cmd = (BT_HDR *) GKI_getnext(p_cmd); - continue; - } - else - { - GKI_remove_from_queue(&p_hci_cmd_cb->cmd_cmpl_q, p_cmd); - - /* If command was a VSC, then extract command_status callback */ - if ((cmd_opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) - { - p_vsc_status_cback = *((void **)(p_cmd + 1)); - } - break; - } - } + btu_hcif_hdl_command_status( + opcode, + hack->status, + stream, + hack->context); - /* if more commands in queue restart timer */ - if (BTU_CMD_CMPL_TIMEOUT > 0) - { - if (!GKI_queue_is_empty (&(p_hci_cmd_cb->cmd_cmpl_q))) - { -#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE) - p_hci_cmd_cb->checked_hcisu = FALSE; -#endif - btu_start_timer (&(p_hci_cmd_cb->cmd_cmpl_timer), - (UINT16)(BTU_TTYPE_BTU_CMD_CMPL + controller_id), - BTU_CMD_CMPL_TIMEOUT); - } - else - { - btu_stop_timer (&(p_hci_cmd_cb->cmd_cmpl_timer)); - } - } - } - - /* handle command */ - btu_hcif_hdl_command_status (opcode, status, p_data, p_vsc_status_cback); - - /* free stored command */ - if (p_cmd != NULL) - { - GKI_freebuf (p_cmd); - } - else - { - HCI_TRACE_WARNING("No command in queue matching opcode %d", opcode); - } - - /* See if we can forward any more commands */ - btu_hcif_send_cmd (controller_id, NULL); + GKI_freebuf(hack->command); + osi_free(event); } -/******************************************************************************* -** -** Function btu_hcif_cmd_timeout -** -** Description Handle a command timeout -** -** Returns void -** -*******************************************************************************/ -void btu_hcif_cmd_timeout (UINT8 controller_id) +static void btu_hcif_command_status_evt(uint8_t status, BT_HDR *command, void *context) { - tHCI_CMD_CB * p_hci_cmd_cb = &(btu_cb.hci_cmd_cb[controller_id]); - BT_HDR *p_cmd; - UINT8 *p; - void *p_cplt_cback = NULL; - UINT16 opcode; - UINT16 event; - -#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE) - if (!(p_hci_cmd_cb->checked_hcisu)) - { - HCI_TRACE_WARNING("BTU HCI(id=%d) command timeout - double check HCISU", controller_id); - - /* trigger HCISU to read any pending data in transport buffer */ - GKI_send_event(HCISU_TASK, HCISU_EVT_MASK); - - btu_start_timer (&(p_hci_cmd_cb->cmd_cmpl_timer), - (UINT16)(BTU_TTYPE_BTU_CMD_CMPL + controller_id), - 2); /* start short timer, if timer is set to 1 then it could expire before HCISU checks. */ - - p_hci_cmd_cb->checked_hcisu = TRUE; - - return; - } -#endif - - /* set the controller cmd window to 1, as if we received a response, so - ** the flow of commands from the stack doesn't hang */ - p_hci_cmd_cb->cmd_window = 1; - - /* get queued command */ - if ((p_cmd = (BT_HDR *) GKI_dequeue (&(p_hci_cmd_cb->cmd_cmpl_q))) == NULL) - { - HCI_TRACE_WARNING("Cmd timeout; no cmd in queue"); - return; - } - - /* if more commands in queue restart timer */ - if (BTU_CMD_CMPL_TIMEOUT > 0) - { - if (!GKI_queue_is_empty (&(p_hci_cmd_cb->cmd_cmpl_q))) - { -#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE) - p_hci_cmd_cb->checked_hcisu = FALSE; -#endif - btu_start_timer (&(p_hci_cmd_cb->cmd_cmpl_timer), - (UINT16)(BTU_TTYPE_BTU_CMD_CMPL + controller_id), - BTU_CMD_CMPL_TIMEOUT); - } - } - - p = (UINT8 *)(p_cmd + 1) + p_cmd->offset; -#if (NFC_INCLUDED == TRUE) - if (controller_id == NFC_CONTROLLER_ID) - { - //TODO call nfc_ncif_cmd_timeout - HCI_TRACE_WARNING("BTU NCI command timeout - header 0x%02x%02x", p[0], p[1]); - return; - } -#endif + BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_status_hack_t)); + command_status_hack_t *hack = (command_status_hack_t *)&event->data[0]; - /* get opcode from stored command */ - STREAM_TO_UINT16 (opcode, p); + hack->callback = btu_hcif_command_status_evt_on_task; + hack->status = status; + hack->command = command; + hack->context = context; -// btla-specific ++ -#if (defined(ANDROID_APP_INCLUDED) && (ANDROID_APP_INCLUDED == TRUE)) - ALOGE("######################################################################"); - ALOGE("#"); - ALOGE("# WARNING : BTU HCI(id=%d) command timeout. opcode=0x%x", controller_id, opcode); - ALOGE("#"); - ALOGE("######################################################################"); -#else - HCI_TRACE_WARNING("BTU HCI(id=%d) command timeout. opcode=0x%x", controller_id, opcode); -#endif -// btla-specific ++ + event->event = BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK; - /* send stack a fake command complete or command status, but first determine - ** which to send - */ - switch (opcode) - { - case HCI_HOLD_MODE: - case HCI_SNIFF_MODE: - case HCI_EXIT_SNIFF_MODE: - case HCI_PARK_MODE: - case HCI_EXIT_PARK_MODE: - case HCI_INQUIRY: - case HCI_RMT_NAME_REQUEST: - case HCI_QOS_SETUP_COMP_EVT: - case HCI_CREATE_CONNECTION: - case HCI_CHANGE_CONN_LINK_KEY: - case HCI_SWITCH_ROLE: - case HCI_READ_RMT_EXT_FEATURES: - case HCI_AUTHENTICATION_REQUESTED: - case HCI_SET_CONN_ENCRYPTION: -#if BTM_SCO_INCLUDED == TRUE - case HCI_SETUP_ESCO_CONNECTION: -#endif - /* fake a command status */ - btu_hcif_hdl_command_status (opcode, HCI_ERR_UNSPECIFIED, p, NULL); - break; - - default: - /* If vendor specific restore the callback function */ - if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC -#if BLE_INCLUDED == TRUE - || (opcode == HCI_BLE_RAND ) || - (opcode == HCI_BLE_ENCRYPT) -#endif - ) - { - p_cplt_cback = *((void **)(p_cmd + 1)); - } - - /* fake a command complete; first create a fake event */ - event = HCI_ERR_UNSPECIFIED; - btu_hcif_hdl_command_complete (opcode, (UINT8 *)&event, 1, p_cplt_cback); - break; - } - - /* free stored command */ - GKI_freebuf(p_cmd); - - num_hci_cmds_timed_out++; - /* When we receive consecutive HCI cmd timeouts for >=BTM_MAX_HCI_CMD_TOUT_BEFORE_RESTART - times, Bluetooth process will be killed and restarted */ - if (num_hci_cmds_timed_out >= BTM_MAX_HCI_CMD_TOUT_BEFORE_RESTART) - { - HCI_TRACE_ERROR("Num consecutive HCI Cmd tout =%d Restarting BT process",num_hci_cmds_timed_out); - - usleep(10000); /* 10 milliseconds */ - /* Killing the process to force a restart as part of fault tolerance */ - kill(getpid(), SIGKILL); - } - else - { - HCI_TRACE_WARNING("HCI Cmd timeout counter %d", num_hci_cmds_timed_out); - - /* If anyone wants device status notifications, give him one */ - btm_report_device_status (BTM_DEV_STATUS_CMD_TOUT); - } - /* See if we can forward any more commands */ - btu_hcif_send_cmd (controller_id, NULL); + fixed_queue_enqueue(btu_hci_msg_queue, event); } /******************************************************************************* @@ -1785,14 +1240,10 @@ static void btu_hcif_mode_change_evt (UINT8 *p) STREAM_TO_UINT16 (handle, p); STREAM_TO_UINT8 (current_mode, p); STREAM_TO_UINT16 (interval, p); -#if BTM_PWR_MGR_INCLUDED == TRUE #if BTM_SCO_WAKE_PARKED_LINK == TRUE btm_sco_chk_pend_unpark (status, handle); #endif btm_pm_proc_mode_change (status, handle, current_mode, interval); -#else - btm_process_mode_change (status, handle, current_mode, interval); -#endif /* BTM_PWR_MGR_INCLUDED == TRUE */ #if (HID_DEV_INCLUDED == TRUE) && (HID_DEV_PM_INCLUDED == TRUE) hidd_pm_proc_mode_change( status, current_mode, interval ) ; @@ -1811,44 +1262,10 @@ static void btu_hcif_mode_change_evt (UINT8 *p) #if (BTM_SSR_INCLUDED == TRUE) static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len) { -#if (BTM_PWR_MGR_INCLUDED == TRUE) btm_pm_proc_ssr_evt(p, evt_len); -#endif } #endif - -/******************************************************************************* -** -** Function btu_hcif_return_link_keys_evt -** -** Description Process event HCI_RETURN_LINK_KEYS_EVT -** -** Returns void -** -*******************************************************************************/ - -static void btu_hcif_return_link_keys_evt (UINT8 *p) -{ - UINT8 num_keys; - tBTM_RETURN_LINK_KEYS_EVT *result; - - /* get the number of link keys */ - num_keys = *p; - - /* If there are no link keys don't call the call back */ - if (!num_keys) - return; - - /* Take one extra byte at the beginning to specify event */ - result = (tBTM_RETURN_LINK_KEYS_EVT *)(--p); - result->event = BTM_CB_EVT_RETURN_LINK_KEYS; - - /* Call the BTM function to pass the link keys to application */ - btm_return_link_keys_evt (result); -} - - /******************************************************************************* ** ** Function btu_hcif_pin_code_request_evt @@ -2156,24 +1573,6 @@ static void btu_hcif_keypress_notif_evt (UINT8 *p) /******************************************************************************* ** -** Function btu_hcif_link_super_tout_evt -** -** Description Process event HCI_LINK_SUPER_TOUT_CHANGED_EVT -** -** Returns void -** -*******************************************************************************/ -static void btu_hcif_link_super_tout_evt (UINT8 *p) -{ - UINT16 handle, timeout; - STREAM_TO_UINT16 (handle, p); - STREAM_TO_UINT16 (timeout, p); - - btm_proc_lsto_evt(handle, timeout); -} - -/******************************************************************************* -** ** Function btu_hcif_rem_oob_request_evt ** ** Description Process event HCI_REMOTE_OOB_DATA_REQUEST_EVT @@ -2201,30 +1600,6 @@ static void btu_hcif_simple_pair_complete_evt (UINT8 *p) { btm_simple_pair_complete(p); } -/******************************************************************************* -** -** Function btu_hcif_flush_cmd_queue -** -** Description Flush the HCI command complete queue and transmit queue when -** needed. -** -** Returns void -** -*******************************************************************************/ -void btu_hcif_flush_cmd_queue(void) -{ - BT_HDR *p_cmd; - - btu_cb.hci_cmd_cb[0].cmd_window = 0; - while ((p_cmd = (BT_HDR *) GKI_dequeue (&btu_cb.hci_cmd_cb[0].cmd_cmpl_q)) != NULL) - { - GKI_freebuf (p_cmd); - } - while ((p_cmd = (BT_HDR *) GKI_dequeue (&btu_cb.hci_cmd_cb[0].cmd_xmit_q)) != NULL) - { - GKI_freebuf (p_cmd); - } -} /******************************************************************************* ** diff --git a/stack/btu/btu_init.c b/stack/btu/btu_init.c index c29d3e2e3..0888cb57e 100644 --- a/stack/btu/btu_init.c +++ b/stack/btu/btu_init.c @@ -16,21 +16,26 @@ * ******************************************************************************/ -/****************************************************************************** - * - * This module contains the routines that load and shutdown the core stack - * components. - * - ******************************************************************************/ +#define LOG_TAG "bt_task" + +#include <assert.h> #include "bt_target.h" +#include <pthread.h> #include <string.h> #include "dyn_mem.h" +#include "osi/include/alarm.h" +#include "device/include/controller.h" +#include "osi/include/fixed_queue.h" +#include "osi/include/hash_map.h" #include "btu.h" #include "btm_int.h" +#include "osi/include/hash_functions.h" #include "sdpint.h" +#include "osi/include/thread.h" #include "l2c_int.h" +#include "osi/include/log.h" #if (BLE_INCLUDED == TRUE) #include "gatt_api.h" @@ -40,15 +45,45 @@ #endif #endif +extern fixed_queue_t *btif_msg_queue; + +// Communication queue from bta thread to bt_workqueue. +fixed_queue_t *btu_bta_msg_queue; + +// Communication queue from hci thread to bt_workqueue. +extern fixed_queue_t *btu_hci_msg_queue; + +// General timer queue. +fixed_queue_t *btu_general_alarm_queue; +hash_map_t *btu_general_alarm_hash_map; +pthread_mutex_t btu_general_alarm_lock; +static const size_t BTU_GENERAL_ALARM_HASH_MAP_SIZE = 17; + +// Oneshot timer queue. +fixed_queue_t *btu_oneshot_alarm_queue; +hash_map_t *btu_oneshot_alarm_hash_map; +pthread_mutex_t btu_oneshot_alarm_lock; +static const size_t BTU_ONESHOT_ALARM_HASH_MAP_SIZE = 17; + +// l2cap timer queue. +fixed_queue_t *btu_l2cap_alarm_queue; +hash_map_t *btu_l2cap_alarm_hash_map; +pthread_mutex_t btu_l2cap_alarm_lock; +static const size_t BTU_L2CAP_ALARM_HASH_MAP_SIZE = 17; + +thread_t *bt_workqueue_thread; +static const char *BT_WORKQUEUE_NAME = "bt_workqueue"; + extern void PLATFORM_DisableHciTransport(UINT8 bDisable); /***************************************************************************** ** V A R I A B L E S * ******************************************************************************/ +// TODO(cmanton) Move this out of this file const BD_ADDR BT_BD_ANY = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -/***************************************************************************** -** F U N C T I O N S * -******************************************************************************/ +void btu_task_start_up(void *context); +void btu_task_shut_down(void *context); + /***************************************************************************** ** ** Function btu_init_core @@ -77,48 +112,129 @@ void btu_init_core(void) #endif } - /***************************************************************************** ** -** Function BTE_Init +** Function btu_free_core ** -** Description Initializes the BTU control block. +** Description Releases control block memory for each core component. ** -** NOTE: Must be called before creating any tasks -** (RPC, BTU, HCIT, APPL, etc.) ** ** Returns void ** ******************************************************************************/ -void BTE_Init(void) +void btu_free_core(void) { - int i = 0; + /* Free the mandatory core stack components */ + l2c_free(); - memset (&btu_cb, 0, sizeof (tBTU_CB)); - btu_cb.hcit_acl_pkt_size = BTU_DEFAULT_DATA_SIZE + HCI_DATA_PREAMBLE_SIZE; -#if (BLE_INCLUDED == TRUE) - btu_cb.hcit_ble_acl_pkt_size = BTU_DEFAULT_BLE_DATA_SIZE + HCI_DATA_PREAMBLE_SIZE; +#if BLE_INCLUDED == TRUE + gatt_free(); #endif - btu_cb.trace_level = HCI_INITIAL_TRACE_LEVEL; - - for ( i = 0; i < BTU_MAX_LOCAL_CTRLS; i++ ) /* include BR/EDR */ - btu_cb.hci_cmd_cb[i].cmd_window = 1; } - /***************************************************************************** ** -** Function BTU_AclPktSize +** Function BTU_StartUp ** -** Description export the ACL packet size. +** Description Initializes the BTU control block. ** -** Returns UINT16 +** NOTE: Must be called before creating any tasks +** (RPC, BTU, HCIT, APPL, etc.) +** +** Returns void ** ******************************************************************************/ -UINT16 BTU_AclPktSize(void) +void BTU_StartUp(void) { - return btu_cb.hcit_acl_pkt_size; + memset (&btu_cb, 0, sizeof (tBTU_CB)); + btu_cb.trace_level = HCI_INITIAL_TRACE_LEVEL; + + btu_bta_msg_queue = fixed_queue_new(SIZE_MAX); + if (btu_bta_msg_queue == NULL) + goto error_exit; + + btu_general_alarm_hash_map = hash_map_new(BTU_GENERAL_ALARM_HASH_MAP_SIZE, + hash_function_pointer, NULL, (data_free_fn)alarm_free, NULL); + if (btu_general_alarm_hash_map == NULL) + goto error_exit; + + if (pthread_mutex_init(&btu_general_alarm_lock, NULL)) + goto error_exit; + + btu_general_alarm_queue = fixed_queue_new(SIZE_MAX); + if (btu_general_alarm_queue == NULL) + goto error_exit; + + btu_oneshot_alarm_hash_map = hash_map_new(BTU_ONESHOT_ALARM_HASH_MAP_SIZE, + hash_function_pointer, NULL, (data_free_fn)alarm_free, NULL); + if (btu_oneshot_alarm_hash_map == NULL) + goto error_exit; + + if (pthread_mutex_init(&btu_oneshot_alarm_lock, NULL)) + goto error_exit; + + btu_oneshot_alarm_queue = fixed_queue_new(SIZE_MAX); + if (btu_oneshot_alarm_queue == NULL) + goto error_exit; + + btu_l2cap_alarm_hash_map = hash_map_new(BTU_L2CAP_ALARM_HASH_MAP_SIZE, + hash_function_pointer, NULL, (data_free_fn)alarm_free, NULL); + if (btu_l2cap_alarm_hash_map == NULL) + goto error_exit; + + if (pthread_mutex_init(&btu_l2cap_alarm_lock, NULL)) + goto error_exit; + + btu_l2cap_alarm_queue = fixed_queue_new(SIZE_MAX); + if (btu_l2cap_alarm_queue == NULL) + goto error_exit; + + bt_workqueue_thread = thread_new(BT_WORKQUEUE_NAME); + if (bt_workqueue_thread == NULL) + goto error_exit; + + // Continue startup on bt workqueue thread. + thread_post(bt_workqueue_thread, btu_task_start_up, NULL); + return; + + error_exit:; + LOG_ERROR("%s Unable to allocate resources for bt_workqueue", __func__); + BTU_ShutDown(); } + +void BTU_ShutDown(void) { + btu_task_shut_down(NULL); + + fixed_queue_free(btu_bta_msg_queue, NULL); + + hash_map_free(btu_general_alarm_hash_map); + pthread_mutex_destroy(&btu_general_alarm_lock); + fixed_queue_free(btu_general_alarm_queue, NULL); + + hash_map_free(btu_oneshot_alarm_hash_map); + pthread_mutex_destroy(&btu_oneshot_alarm_lock); + fixed_queue_free(btu_oneshot_alarm_queue, NULL); + + hash_map_free(btu_l2cap_alarm_hash_map); + pthread_mutex_destroy(&btu_l2cap_alarm_lock); + fixed_queue_free(btu_l2cap_alarm_queue, NULL); + + thread_free(bt_workqueue_thread); + + btu_bta_msg_queue = NULL; + + btu_general_alarm_hash_map = NULL; + btu_general_alarm_queue = NULL; + + btu_oneshot_alarm_hash_map = NULL; + btu_oneshot_alarm_queue = NULL; + + btu_l2cap_alarm_hash_map = NULL; + btu_l2cap_alarm_queue = NULL; + + bt_workqueue_thread = NULL; +} + /***************************************************************************** ** ** Function BTU_BleAclPktSize @@ -131,7 +247,7 @@ UINT16 BTU_AclPktSize(void) UINT16 BTU_BleAclPktSize(void) { #if BLE_INCLUDED == TRUE - return btu_cb.hcit_ble_acl_pkt_size; + return controller_get_interface()->get_acl_packet_size_ble(); #else return 0; #endif @@ -147,11 +263,9 @@ UINT16 BTU_BleAclPktSize(void) ** Returns void ** *******************************************************************************/ -void btu_uipc_rx_cback(BT_HDR *p_msg) -{ - BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, "btu_uipc_rx_cback event 0x%x, len %d, offset %d", - p_msg->event, p_msg->len, p_msg->offset); - GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_msg); - +void btu_uipc_rx_cback(BT_HDR *p_msg) { + assert(p_msg != NULL); + BT_TRACE(TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, "btu_uipc_rx_cback event 0x%x," + " len %d, offset %d", p_msg->event, p_msg->len, p_msg->offset); + fixed_queue_enqueue(btu_hci_msg_queue, p_msg); } - diff --git a/stack/btu/btu_task.c b/stack/btu/btu_task.c index f93e63724..e2b899efd 100644 --- a/stack/btu/btu_task.c +++ b/stack/btu/btu_task.c @@ -16,72 +16,38 @@ * ******************************************************************************/ -/****************************************************************************** - * - * This file contains the main Bluetooth Upper Layer processing loop. - * The Broadcom implementations of L2CAP RFCOMM, SDP and the BTIf run as one - * GKI task. This btu_task switches between them. - * - * Note that there will always be an L2CAP, but there may or may not be an - * RFCOMM or SDP. Whether these layers are present or not is determined by - * compile switches. - * - ******************************************************************************/ +#define LOG_TAG "bt_btu_task" +#include <assert.h> #include <stdlib.h> -#include <string.h> #include <stdio.h> +#include <string.h> +#include "osi/include/alarm.h" #include "bt_target.h" -#include "gki.h" +#include "bt_trace.h" #include "bt_types.h" +#include "bt_utils.h" +#include "btif_common.h" +#include "btm_api.h" +#include "btm_int.h" +#include "btu.h" +#include "osi/include/fixed_queue.h" +#include "osi/include/future.h" +#include "gki.h" +#include "osi/include/hash_map.h" #include "hcimsgs.h" #include "l2c_int.h" -#include "btu.h" -#include "bt_utils.h" -#include <sys/prctl.h> - +#include "btcore/include/module.h" +#include "osi/include/osi.h" +#include "osi/include/log.h" #include "sdpint.h" +#include "osi/include/thread.h" -#if ( defined(RFCOMM_INCLUDED) && RFCOMM_INCLUDED == TRUE ) #include "port_api.h" #include "port_ext.h" -#endif -#include "btm_api.h" -#include "btm_int.h" - -#if (defined(EVAL) && EVAL == TRUE) -#include "btu_eval.h" -#endif - -#if GAP_INCLUDED == TRUE #include "gap_int.h" -#endif - -#if (defined(OBX_INCLUDED) && OBX_INCLUDED == TRUE) -#include "obx_int.h" - -#if (defined(BIP_INCLUDED) && BIP_INCLUDED == TRUE) -#include "bip_int.h" -#endif /* BIP */ - -#if (BPP_SND_INCLUDED == TRUE || BPP_INCLUDED == TRUE) -#include "bpp_int.h" -#endif /* BPP */ - -#endif /* OBX */ - -#include "bt_trace.h" - -/* BTE application task */ -#if APPL_INCLUDED == TRUE -#include "bte_appl.h" -#endif - -#if (defined(RPC_INCLUDED) && RPC_INCLUDED == TRUE) -#include "rpct_main.h" -#endif #if (defined(BNEP_INCLUDED) && BNEP_INCLUDED == TRUE) #include "bnep_int.h" @@ -91,14 +57,6 @@ #include "pan_int.h" #endif -#if (defined(SAP_SERVER_INCLUDED) && SAP_SERVER_INCLUDED == TRUE) -#include "sap_int.h" -#endif - -#if (defined(HID_DEV_INCLUDED) && HID_DEV_INCLUDED == TRUE ) -#include "hidd_int.h" -#endif - #if (defined(HID_HOST_INCLUDED) && HID_HOST_INCLUDED == TRUE ) #include "hidh_int.h" #endif @@ -115,10 +73,7 @@ extern void avdt_rcv_sync_info (BT_HDR *p_buf); /* this is for hci_test */ #include "mca_int.h" #endif - -#if (defined(BTU_BTA_INCLUDED) && BTU_BTA_INCLUDED == TRUE) #include "bta_sys.h" -#endif #if (BLE_INCLUDED == TRUE) #include "gatt_int.h" @@ -128,16 +83,7 @@ extern void avdt_rcv_sync_info (BT_HDR *p_buf); /* this is for hci_test */ #include "btm_ble_int.h" #endif -#ifdef __cplusplus -extern "C" -{ -#endif - -BT_API extern void BTE_InitStack(void); - -#ifdef __cplusplus -} -#endif +extern void BTE_InitStack(void); /* Define BTU storage area */ @@ -145,551 +91,386 @@ BT_API extern void BTE_InitStack(void); tBTU_CB btu_cb; #endif +// Communication queue between btu_task and bta. +extern fixed_queue_t *btu_bta_msg_queue; + +// Communication queue between btu_task and hci. +extern fixed_queue_t *btu_hci_msg_queue; + +// General timer queue. +extern fixed_queue_t *btu_general_alarm_queue; +extern hash_map_t *btu_general_alarm_hash_map; +extern pthread_mutex_t btu_general_alarm_lock; + +// Oneshot timer queue. +extern fixed_queue_t *btu_oneshot_alarm_queue; +extern hash_map_t *btu_oneshot_alarm_hash_map; +extern pthread_mutex_t btu_oneshot_alarm_lock; + +// l2cap timer queue. +extern fixed_queue_t *btu_l2cap_alarm_queue; +extern hash_map_t *btu_l2cap_alarm_hash_map; +extern pthread_mutex_t btu_l2cap_alarm_lock; + +extern fixed_queue_t *event_queue; +extern fixed_queue_t *btif_msg_queue; + +extern thread_t *bt_workqueue_thread; /* Define a function prototype to allow a generic timeout handler */ typedef void (tUSER_TIMEOUT_FUNC) (TIMER_LIST_ENT *p_tle); -/******************************************************************************* -** -** Function btu_task -** -** Description This is the main task of the Bluetooth Upper Layers unit. -** It sits in a loop waiting for messages, and dispatches them -** to the appropiate handlers. -** -** Returns should never return -** -*******************************************************************************/ -BTU_API UINT32 btu_task (UINT32 param) -{ - UINT16 event; - BT_HDR *p_msg; - UINT8 i; - UINT16 mask; - BOOLEAN handled; - UNUSED(param); - -#if (defined(HCISU_H4_INCLUDED) && HCISU_H4_INCLUDED == TRUE) - /* wait an event that HCISU is ready */ - BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_API, - "btu_task pending for preload complete event"); - - for (;;) - { - event = GKI_wait (0xFFFF, 0); - if (event & EVENT_MASK(GKI_SHUTDOWN_EVT)) - { - /* indicates BT ENABLE abort */ - BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_WARNING, - "btu_task start abort!"); - return (0); - } - else if (event & BT_EVT_PRELOAD_CMPL) - { - break; - } - else - { - BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_WARNING, - "btu_task ignore evt %04x while pending for preload complete", - event); - } - } +static void btu_l2cap_alarm_process(TIMER_LIST_ENT *p_tle); +static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle); +static void btu_bta_alarm_process(TIMER_LIST_ENT *p_tle); +static void btu_hci_msg_process(BT_HDR *p_msg); - BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_API, - "btu_task received preload complete event"); -#endif +void btu_hci_msg_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) { + BT_HDR *p_msg = (BT_HDR *)fixed_queue_dequeue(queue); + btu_hci_msg_process(p_msg); +} - /* Initialize the mandatory core stack control blocks - (BTU, BTM, L2CAP, and SDP) - */ - btu_init_core(); +void btu_general_alarm_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) { + TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)fixed_queue_dequeue(queue); + btu_general_alarm_process(p_tle); +} - /* Initialize any optional stack components */ - BTE_InitStack(); +void btu_oneshot_alarm_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) { + TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)fixed_queue_dequeue(queue); + btu_general_alarm_process(p_tle); -#if (defined(BTU_BTA_INCLUDED) && BTU_BTA_INCLUDED == TRUE) - bta_sys_init(); + switch (p_tle->event) { +#if (defined(BLE_INCLUDED) && BLE_INCLUDED == TRUE) + case BTU_TTYPE_BLE_RANDOM_ADDR: + btm_ble_timeout(p_tle); + break; #endif - /* Initialise platform trace levels at this point as BTE_InitStack() and bta_sys_init() - * reset the control blocks and preset the trace level with XXX_INITIAL_TRACE_LEVEL - */ -#if ( BT_USE_TRACES==TRUE ) - BTE_InitTraceLevels(); -#endif + case BTU_TTYPE_USER_FUNC: + { + tUSER_TIMEOUT_FUNC *p_uf = (tUSER_TIMEOUT_FUNC *)p_tle->param; + (*p_uf)(p_tle); + } + break; - /* Send a startup evt message to BTIF_TASK to kickstart the init procedure */ - GKI_send_event(BTIF_TASK, BT_EVT_TRIGGER_STACK_INIT); + default: + // FAIL + BTM_TRACE_WARNING("Received unexpected oneshot timer event:0x%x\n", + p_tle->event); + break; + } +} - prctl(PR_SET_NAME, (unsigned long)"BTU TASK", 0, 0, 0); +void btu_l2cap_alarm_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) { + TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)fixed_queue_dequeue(queue); + btu_l2cap_alarm_process(p_tle); +} - raise_priority_a2dp(TASK_HIGH_BTU); +void btu_bta_msg_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) { + BT_HDR *p_msg = (BT_HDR *)fixed_queue_dequeue(queue); + bta_sys_event(p_msg); +} - /* Wait for, and process, events */ - for (;;) - { - event = GKI_wait (0xFFFF, 0); +void btu_bta_alarm_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) { + TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)fixed_queue_dequeue(queue); + btu_bta_alarm_process(p_tle); +} - if (event & TASK_MBOX_0_EVT_MASK) - { - /* Process all messages in the queue */ - while ((p_msg = (BT_HDR *) GKI_read_mbox (BTU_HCI_RCV_MBOX)) != NULL) - { - /* Determine the input message type. */ - switch (p_msg->event & BT_EVT_MASK) - { - case BT_EVT_TO_BTU_HCI_ACL: - /* All Acl Data goes to L2CAP */ - l2c_rcv_acl_data (p_msg); - break; +static void btu_hci_msg_process(BT_HDR *p_msg) { + /* Determine the input message type. */ + switch (p_msg->event & BT_EVT_MASK) + { + case BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK: // TODO(zachoverflow): remove this + ((post_to_task_hack_t *)(&p_msg->data[0]))->callback(p_msg); + break; + case BT_EVT_TO_BTU_HCI_ACL: + /* All Acl Data goes to L2CAP */ + l2c_rcv_acl_data (p_msg); + break; - case BT_EVT_TO_BTU_L2C_SEG_XMIT: - /* L2CAP segment transmit complete */ - l2c_link_segments_xmitted (p_msg); - break; + case BT_EVT_TO_BTU_L2C_SEG_XMIT: + /* L2CAP segment transmit complete */ + l2c_link_segments_xmitted (p_msg); + break; - case BT_EVT_TO_BTU_HCI_SCO: + case BT_EVT_TO_BTU_HCI_SCO: #if BTM_SCO_INCLUDED == TRUE - btm_route_sco_data (p_msg); - break; + btm_route_sco_data (p_msg); + break; #endif - case BT_EVT_TO_BTU_HCI_EVT: - btu_hcif_process_event ((UINT8)(p_msg->event & BT_SUB_EVT_MASK), p_msg); - GKI_freebuf(p_msg); + case BT_EVT_TO_BTU_HCI_EVT: + btu_hcif_process_event ((UINT8)(p_msg->event & BT_SUB_EVT_MASK), p_msg); + GKI_freebuf(p_msg); #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE) - /* If host receives events which it doesn't response to, */ - /* host should start idle timer to enter sleep mode. */ - btu_check_bt_sleep (); + /* If host receives events which it doesn't response to, */ + /* host should start idle timer to enter sleep mode. */ + btu_check_bt_sleep (); #endif - break; - - case BT_EVT_TO_BTU_HCI_CMD: - btu_hcif_send_cmd ((UINT8)(p_msg->event & BT_SUB_EVT_MASK), p_msg); - break; - -#if (defined(OBX_INCLUDED) && OBX_INCLUDED == TRUE) -#if (defined(OBX_SERVER_INCLUDED) && OBX_SERVER_INCLUDED == TRUE) - case BT_EVT_TO_OBX_SR_MSG: - obx_sr_proc_evt((tOBX_PORT_EVT *)(p_msg + 1)); - GKI_freebuf (p_msg); - break; - - case BT_EVT_TO_OBX_SR_L2C_MSG: - obx_sr_proc_l2c_evt((tOBX_L2C_EVT_MSG *)(p_msg + 1)); - GKI_freebuf (p_msg); - break; -#endif - -#if (defined(OBX_CLIENT_INCLUDED) && OBX_CLIENT_INCLUDED == TRUE) - case BT_EVT_TO_OBX_CL_MSG: - obx_cl_proc_evt((tOBX_PORT_EVT *)(p_msg + 1)); - GKI_freebuf (p_msg); - break; + break; - case BT_EVT_TO_OBX_CL_L2C_MSG: - obx_cl_proc_l2c_evt((tOBX_L2C_EVT_MSG *)(p_msg + 1)); - GKI_freebuf (p_msg); - break; -#endif + case BT_EVT_TO_BTU_HCI_CMD: + btu_hcif_send_cmd ((UINT8)(p_msg->event & BT_SUB_EVT_MASK), p_msg); + break; -#if (defined(BIP_INCLUDED) && BIP_INCLUDED == TRUE) - case BT_EVT_TO_BIP_CMDS : - bip_proc_btu_event(p_msg); - GKI_freebuf (p_msg); - break; -#endif /* BIP */ -#if (BPP_SND_INCLUDED == TRUE || BPP_INCLUDED == TRUE) - case BT_EVT_TO_BPP_PR_CMDS: - bpp_pr_proc_event(p_msg); - GKI_freebuf (p_msg); - break; - case BT_EVT_TO_BPP_SND_CMDS: - bpp_snd_proc_event(p_msg); - GKI_freebuf (p_msg); - break; - -#endif /* BPP */ - -#endif /* OBX */ - -#if (defined(SAP_SERVER_INCLUDED) && SAP_SERVER_INCLUDED == TRUE) - case BT_EVT_TO_BTU_SAP : - sap_proc_btu_event(p_msg); - GKI_freebuf (p_msg); - break; -#endif /* SAP */ -#if (defined(GAP_CONN_INCLUDED) && GAP_CONN_INCLUDED == TRUE && GAP_CONN_POST_EVT_INCLUDED == TRUE) - case BT_EVT_TO_GAP_MSG : - gap_proc_btu_event(p_msg); - GKI_freebuf (p_msg); - break; -#endif - case BT_EVT_TO_START_TIMER : - /* Start free running 1 second timer for list management */ - GKI_start_timer (TIMER_0, GKI_SECS_TO_TICKS (1), TRUE); - GKI_freebuf (p_msg); - break; - - case BT_EVT_TO_STOP_TIMER: - if (GKI_timer_queue_is_empty(&btu_cb.timer_queue)) { - GKI_stop_timer(TIMER_0); - } - GKI_freebuf (p_msg); - break; - - case BT_EVT_TO_START_TIMER_ONESHOT: - if (!GKI_timer_queue_is_empty(&btu_cb.timer_queue_oneshot)) { - TIMER_LIST_ENT *tle = GKI_timer_getfirst(&btu_cb.timer_queue_oneshot); - // Start non-repeating timer. - GKI_start_timer(TIMER_3, tle->ticks, FALSE); - } else { - BTM_TRACE_WARNING("Oneshot timer queue empty when received start request"); - } - GKI_freebuf(p_msg); - break; - - case BT_EVT_TO_STOP_TIMER_ONESHOT: - if (GKI_timer_queue_is_empty(&btu_cb.timer_queue_oneshot)) { - GKI_stop_timer(TIMER_3); - } else { - BTM_TRACE_WARNING("Oneshot timer queue not empty when received stop request"); - } - GKI_freebuf (p_msg); - break; + default:; + int i = 0; + uint16_t mask = (UINT16) (p_msg->event & BT_EVT_MASK); + BOOLEAN handled = FALSE; -#if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) - case BT_EVT_TO_START_QUICK_TIMER : - GKI_start_timer (TIMER_2, QUICK_TIMER_TICKS, TRUE); - GKI_freebuf (p_msg); - break; -#endif + for (; !handled && i < BTU_MAX_REG_EVENT; i++) + { + if (btu_cb.event_reg[i].event_cb == NULL) + continue; - default: - i = 0; - mask = (UINT16) (p_msg->event & BT_EVT_MASK); - handled = FALSE; - - for (; !handled && i < BTU_MAX_REG_EVENT; i++) - { - if (btu_cb.event_reg[i].event_cb == NULL) - continue; - - if (mask == btu_cb.event_reg[i].event_range) - { - if (btu_cb.event_reg[i].event_cb) - { - btu_cb.event_reg[i].event_cb(p_msg); - handled = TRUE; - } - } - } - - if (handled == FALSE) - GKI_freebuf (p_msg); - - break; + if (mask == btu_cb.event_reg[i].event_range) + { + if (btu_cb.event_reg[i].event_cb) + { + btu_cb.event_reg[i].event_cb(p_msg); + handled = TRUE; + } } } - } - - if (event & TIMER_0_EVT_MASK) { - GKI_update_timer_list (&btu_cb.timer_queue, 1); + if (handled == FALSE) + GKI_freebuf (p_msg); - while (!GKI_timer_queue_is_empty(&btu_cb.timer_queue)) { - TIMER_LIST_ENT *p_tle = GKI_timer_getfirst(&btu_cb.timer_queue); - if (p_tle->ticks != 0) - break; + break; + } - GKI_remove_from_timer_list(&btu_cb.timer_queue, p_tle); +} - switch (p_tle->event) { - case BTU_TTYPE_BTM_DEV_CTL: - btm_dev_timeout(p_tle); - break; +static void btu_bta_alarm_process(TIMER_LIST_ENT *p_tle) { + /* call timer callback */ + if (p_tle->p_cback) { + (*p_tle->p_cback)(p_tle); + } else if (p_tle->event) { + BT_HDR *p_msg; + if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) { + p_msg->event = p_tle->event; + p_msg->layer_specific = 0; + bta_sys_sendmsg(p_msg); + } + } +} - case BTU_TTYPE_BTM_ACL: - btm_acl_timeout(p_tle); - break; +void btu_task_start_up(UNUSED_ATTR void *context) { + BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_API, + "btu_task pending for preload complete event"); - case BTU_TTYPE_L2CAP_LINK: - case BTU_TTYPE_L2CAP_CHNL: - case BTU_TTYPE_L2CAP_HOLD: - case BTU_TTYPE_L2CAP_INFO: - case BTU_TTYPE_L2CAP_FCR_ACK: - l2c_process_timeout (p_tle); - break; + LOG_INFO("Bluetooth chip preload is complete"); - case BTU_TTYPE_SDP: - sdp_conn_timeout ((tCONN_CB *)p_tle->param); - break; + BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_API, + "btu_task received preload complete event"); - case BTU_TTYPE_BTM_RMT_NAME: - btm_inq_rmt_name_failed(); - break; + /* Initialize the mandatory core stack control blocks + (BTU, BTM, L2CAP, and SDP) + */ + btu_init_core(); -#if (defined(RFCOMM_INCLUDED) && RFCOMM_INCLUDED == TRUE) - case BTU_TTYPE_RFCOMM_MFC: - case BTU_TTYPE_RFCOMM_PORT: - rfcomm_process_timeout (p_tle); - break; + /* Initialize any optional stack components */ + BTE_InitStack(); -#endif /* If defined(RFCOMM_INCLUDED) && RFCOMM_INCLUDED == TRUE */ + bta_sys_init(); -#if ((defined(BNEP_INCLUDED) && BNEP_INCLUDED == TRUE)) - case BTU_TTYPE_BNEP: - bnep_process_timeout(p_tle); - break; + /* Initialise platform trace levels at this point as BTE_InitStack() and bta_sys_init() + * reset the control blocks and preset the trace level with XXX_INITIAL_TRACE_LEVEL + */ +#if ( BT_USE_TRACES==TRUE ) + module_init(get_module(BTE_LOGMSG_MODULE)); #endif + // Inform the bt jni thread initialization is ok. + btif_transfer_context(btif_init_ok, 0, NULL, 0, NULL); -#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE) - case BTU_TTYPE_AVDT_CCB_RET: - case BTU_TTYPE_AVDT_CCB_RSP: - case BTU_TTYPE_AVDT_CCB_IDLE: - case BTU_TTYPE_AVDT_SCB_TC: - avdt_process_timeout(p_tle); - break; -#endif + fixed_queue_register_dequeue(btu_bta_msg_queue, + thread_get_reactor(bt_workqueue_thread), + btu_bta_msg_ready, + NULL); -#if (defined(OBX_INCLUDED) && OBX_INCLUDED == TRUE) -#if (defined(OBX_CLIENT_INCLUDED) && OBX_CLIENT_INCLUDED == TRUE) - case BTU_TTYPE_OBX_CLIENT_TO: - obx_cl_timeout(p_tle); - break; -#endif -#if (defined(OBX_SERVER_INCLUDED) && OBX_SERVER_INCLUDED == TRUE) - case BTU_TTYPE_OBX_SERVER_TO: - obx_sr_timeout(p_tle); - break; - - case BTU_TTYPE_OBX_SVR_SESS_TO: - obx_sr_sess_timeout(p_tle); - break; -#endif -#endif + fixed_queue_register_dequeue(btu_hci_msg_queue, + thread_get_reactor(bt_workqueue_thread), + btu_hci_msg_ready, + NULL); -#if (defined(SAP_SERVER_INCLUDED) && SAP_SERVER_INCLUDED == TRUE) - case BTU_TTYPE_SAP_TO: - sap_process_timeout(p_tle); - break; -#endif + fixed_queue_register_dequeue(btu_general_alarm_queue, + thread_get_reactor(bt_workqueue_thread), + btu_general_alarm_ready, + NULL); - case BTU_TTYPE_BTU_CMD_CMPL: - btu_hcif_cmd_timeout((UINT8)(p_tle->event - BTU_TTYPE_BTU_CMD_CMPL)); - break; + fixed_queue_register_dequeue(btu_oneshot_alarm_queue, + thread_get_reactor(bt_workqueue_thread), + btu_oneshot_alarm_ready, + NULL); -#if (defined(HID_HOST_INCLUDED) && HID_HOST_INCLUDED == TRUE) - case BTU_TTYPE_HID_HOST_REPAGE_TO : - hidh_proc_repage_timeout(p_tle); - break; -#endif + fixed_queue_register_dequeue(btu_l2cap_alarm_queue, + thread_get_reactor(bt_workqueue_thread), + btu_l2cap_alarm_ready, + NULL); +} -#if (defined(BLE_INCLUDED) && BLE_INCLUDED == TRUE) - case BTU_TTYPE_BLE_INQUIRY: - case BTU_TTYPE_BLE_GAP_LIM_DISC: - case BTU_TTYPE_BLE_GAP_FAST_ADV: - case BTU_TTYPE_BLE_OBSERVE: - btm_ble_timeout(p_tle); - break; - - case BTU_TTYPE_ATT_WAIT_FOR_RSP: - gatt_rsp_timeout(p_tle); - break; - - case BTU_TTYPE_ATT_WAIT_FOR_IND_ACK: - gatt_ind_ack_timeout(p_tle); - break; -#if (defined(SMP_INCLUDED) && SMP_INCLUDED == TRUE) - case BTU_TTYPE_SMP_PAIRING_CMD: - smp_rsp_timeout(p_tle); - break; -#endif +void btu_task_shut_down(UNUSED_ATTR void *context) { + fixed_queue_unregister_dequeue(btu_bta_msg_queue); + fixed_queue_unregister_dequeue(btu_hci_msg_queue); + fixed_queue_unregister_dequeue(btu_general_alarm_queue); + fixed_queue_unregister_dequeue(btu_oneshot_alarm_queue); + fixed_queue_unregister_dequeue(btu_l2cap_alarm_queue); +#if ( BT_USE_TRACES==TRUE ) + module_clean_up(get_module(BTE_LOGMSG_MODULE)); #endif -#if (MCA_INCLUDED == TRUE) - case BTU_TTYPE_MCA_CCB_RSP: - mca_process_timeout(p_tle); - break; -#endif - case BTU_TTYPE_USER_FUNC: - { - tUSER_TIMEOUT_FUNC *p_uf = (tUSER_TIMEOUT_FUNC *)p_tle->param; - (*p_uf)(p_tle); - } - break; - - default: - i = 0; - handled = FALSE; - - for (; !handled && i < BTU_MAX_REG_TIMER; i++) - { - if (btu_cb.timer_reg[i].timer_cb == NULL) - continue; - if (btu_cb.timer_reg[i].p_tle == p_tle) - { - btu_cb.timer_reg[i].timer_cb(p_tle); - handled = TRUE; - } - } - break; - } - } + bta_sys_free(); + btu_free_core(); +} - /* if timer list is empty stop periodic GKI timer */ - if (btu_cb.timer_queue.p_first == NULL) - { - GKI_stop_timer(TIMER_0); - } - } +/******************************************************************************* +** +** Function btu_start_timer +** +** Description Start a timer for the specified amount of time. +** NOTE: The timeout resolution is in SECONDS! (Even +** though the timer structure field is ticks) +** +** Returns void +** +*******************************************************************************/ +static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) { + assert(p_tle != NULL); -#if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) - if (event & TIMER_2_EVT_MASK) - { - btu_process_quick_timer_evt(); - } -#endif + switch (p_tle->event) { + case BTU_TTYPE_BTM_DEV_CTL: + btm_dev_timeout(p_tle); + break; + case BTU_TTYPE_L2CAP_LINK: + case BTU_TTYPE_L2CAP_CHNL: + case BTU_TTYPE_L2CAP_HOLD: + case BTU_TTYPE_L2CAP_INFO: + case BTU_TTYPE_L2CAP_FCR_ACK: + l2c_process_timeout (p_tle); + break; -#if (RPC_INCLUDED == TRUE) - /* if RPC message queue event */ - if (event & RPCGEN_MSG_EVT) - { - if ((p_msg = (BT_HDR *) GKI_read_mbox(RPCGEN_MSG_MBOX)) != NULL) - RPCT_RpcgenMsg(p_msg); /* handle RPC message queue */ - } -#endif + case BTU_TTYPE_SDP: + sdp_conn_timeout ((tCONN_CB *)p_tle->param); + break; -#if (defined(BTU_BTA_INCLUDED) && BTU_BTA_INCLUDED == TRUE) - if (event & TASK_MBOX_2_EVT_MASK) - { - while ((p_msg = (BT_HDR *) GKI_read_mbox(TASK_MBOX_2)) != NULL) - { - bta_sys_event(p_msg); - } - } + case BTU_TTYPE_BTM_RMT_NAME: + btm_inq_rmt_name_failed(); + break; - if (event & TIMER_1_EVT_MASK) - { - bta_sys_timer_update(); - } -#endif + case BTU_TTYPE_RFCOMM_MFC: + case BTU_TTYPE_RFCOMM_PORT: + rfcomm_process_timeout (p_tle); + break; - if (event & TIMER_3_EVT_MASK) { - BTM_TRACE_API("Received oneshot timer event complete"); - if (!GKI_timer_queue_is_empty(&btu_cb.timer_queue_oneshot)) { - INT32 ticks_since_last_update = GKI_timer_ticks_getinitial(GKI_timer_getfirst(&btu_cb.timer_queue_oneshot)); - GKI_update_timer_list(&btu_cb.timer_queue_oneshot, ticks_since_last_update); - } +#if ((defined(BNEP_INCLUDED) && BNEP_INCLUDED == TRUE)) + case BTU_TTYPE_BNEP: + bnep_process_timeout(p_tle); + break; +#endif - while (!GKI_timer_queue_is_empty(&btu_cb.timer_queue_oneshot)) { - TIMER_LIST_ENT *p_tle = GKI_timer_getfirst(&btu_cb.timer_queue_oneshot); - if (p_tle->ticks != 0) - break; - GKI_remove_from_timer_list(&btu_cb.timer_queue_oneshot, p_tle); +#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE) + case BTU_TTYPE_AVDT_CCB_RET: + case BTU_TTYPE_AVDT_CCB_RSP: + case BTU_TTYPE_AVDT_CCB_IDLE: + case BTU_TTYPE_AVDT_SCB_TC: + avdt_process_timeout(p_tle); + break; +#endif - switch (p_tle->event) { -#if (defined(BLE_INCLUDED) && BLE_INCLUDED == TRUE) - case BTU_TTYPE_BLE_RANDOM_ADDR: - btm_ble_timeout(p_tle); - break; +#if (defined(HID_HOST_INCLUDED) && HID_HOST_INCLUDED == TRUE) + case BTU_TTYPE_HID_HOST_REPAGE_TO : + hidh_proc_repage_timeout(p_tle); + break; #endif - case BTU_TTYPE_USER_FUNC: - { - tUSER_TIMEOUT_FUNC *p_uf = (tUSER_TIMEOUT_FUNC *)p_tle->param; - (*p_uf)(p_tle); - } - break; - - default: - // FAIL - BTM_TRACE_WARNING("Received unexpected oneshot timer event:0x%x\n", - p_tle->event); - break; - } - } +#if (defined(BLE_INCLUDED) && BLE_INCLUDED == TRUE) + case BTU_TTYPE_BLE_INQUIRY: + case BTU_TTYPE_BLE_GAP_LIM_DISC: + case BTU_TTYPE_BLE_RANDOM_ADDR: + case BTU_TTYPE_BLE_GAP_FAST_ADV: + case BTU_TTYPE_BLE_OBSERVE: + btm_ble_timeout(p_tle); + break; - /* Update GKI timer with new tick value from first timer. */ - if (!GKI_timer_queue_is_empty(&btu_cb.timer_queue_oneshot)) { - TIMER_LIST_ENT *p_tle = GKI_timer_getfirst(&btu_cb.timer_queue_oneshot); - if (p_tle->ticks > 0) - GKI_start_timer(TIMER_3, p_tle->ticks, FALSE); - } else { - GKI_stop_timer(TIMER_3); - } - } + case BTU_TTYPE_ATT_WAIT_FOR_RSP: + gatt_rsp_timeout(p_tle); + break; - if (event & EVENT_MASK(APPL_EVT_7)) + case BTU_TTYPE_ATT_WAIT_FOR_IND_ACK: + gatt_ind_ack_timeout(p_tle); break; - } +#if (defined(SMP_INCLUDED) && SMP_INCLUDED == TRUE) + case BTU_TTYPE_SMP_PAIRING_CMD: + smp_rsp_timeout(p_tle); + break; +#endif - return(0); -} +#endif -/******************************************************************************* -** -** Function btu_start_timer -** -** Description Start a timer for the specified amount of time. -** NOTE: The timeout resolution is in SECONDS! (Even -** though the timer structure field is ticks) -** -** Returns void -** -*******************************************************************************/ -void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout) -{ - BT_HDR *p_msg; - GKI_disable(); - /* if timer list is currently empty, start periodic GKI timer */ - if (btu_cb.timer_queue.p_first == NULL) - { - /* if timer starts on other than BTU task */ - if (GKI_get_taskid() != BTU_TASK) - { - /* post event to start timer in BTU task */ - if ((p_msg = (BT_HDR *)GKI_getbuf(BT_HDR_SIZE)) != NULL) +#if (MCA_INCLUDED == TRUE) + case BTU_TTYPE_MCA_CCB_RSP: + mca_process_timeout(p_tle); + break; +#endif + case BTU_TTYPE_USER_FUNC: { - p_msg->event = BT_EVT_TO_START_TIMER; - GKI_send_msg (BTU_TASK, TASK_MBOX_0, p_msg); + tUSER_TIMEOUT_FUNC *p_uf = (tUSER_TIMEOUT_FUNC *)p_tle->param; + (*p_uf)(p_tle); } - } - else - { - /* Start free running 1 second timer for list management */ - GKI_start_timer (TIMER_0, GKI_SECS_TO_TICKS (1), TRUE); - } - } + break; - GKI_remove_from_timer_list (&btu_cb.timer_queue, p_tle); + default:; + int i = 0; + BOOLEAN handled = FALSE; + + for (; !handled && i < BTU_MAX_REG_TIMER; i++) + { + if (btu_cb.timer_reg[i].timer_cb == NULL) + continue; + if (btu_cb.timer_reg[i].p_tle == p_tle) + { + btu_cb.timer_reg[i].timer_cb(p_tle); + handled = TRUE; + } + } + break; + } +} - p_tle->event = type; - p_tle->ticks = timeout; - p_tle->ticks_initial = timeout; +void btu_general_alarm_cb(void *data) { + assert(data != NULL); + TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data; - GKI_add_to_timer_list (&btu_cb.timer_queue, p_tle); - GKI_enable(); + fixed_queue_enqueue(btu_general_alarm_queue, p_tle); } -/******************************************************************************* -** -** Function btu_remaining_time -** -** Description Return amount of time to expire -** -** Returns time in second -** -*******************************************************************************/ -UINT32 btu_remaining_time (TIMER_LIST_ENT *p_tle) -{ - return(GKI_get_remaining_ticks (&btu_cb.timer_queue, p_tle)); +void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) { + assert(p_tle != NULL); + + // Get the alarm for the timer list entry. + pthread_mutex_lock(&btu_general_alarm_lock); + if (!hash_map_has_key(btu_general_alarm_hash_map, p_tle)) { + hash_map_set(btu_general_alarm_hash_map, p_tle, alarm_new()); + } + pthread_mutex_unlock(&btu_general_alarm_lock); + + alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_tle); + if (alarm == NULL) { + LOG_ERROR("%s Unable to create alarm", __func__); + return; + } + alarm_cancel(alarm); + + p_tle->event = type; + // NOTE: This value is in seconds but stored in a ticks field. + p_tle->ticks = timeout_sec; + p_tle->in_use = TRUE; + alarm_set(alarm, (period_ms_t)(timeout_sec * 1000), btu_general_alarm_cb, (void *)p_tle); } /******************************************************************************* @@ -701,31 +482,20 @@ UINT32 btu_remaining_time (TIMER_LIST_ENT *p_tle) ** Returns void ** *******************************************************************************/ -void btu_stop_timer (TIMER_LIST_ENT *p_tle) -{ - BT_HDR *p_msg; - GKI_disable(); - GKI_remove_from_timer_list (&btu_cb.timer_queue, p_tle); - - /* if timer is stopped on other than BTU task */ - if (GKI_get_taskid() != BTU_TASK) - { - /* post event to stop timer in BTU task */ - if ((p_msg = (BT_HDR *)GKI_getbuf(BT_HDR_SIZE)) != NULL) - { - p_msg->event = BT_EVT_TO_STOP_TIMER; - GKI_send_msg (BTU_TASK, TASK_MBOX_0, p_msg); - } - } - else - { - /* if timer list is empty stop periodic GKI timer */ - if (btu_cb.timer_queue.p_first == NULL) - { - GKI_stop_timer(TIMER_0); - } - } - GKI_enable(); +void btu_stop_timer(TIMER_LIST_ENT *p_tle) { + assert(p_tle != NULL); + + if (p_tle->in_use == FALSE) + return; + p_tle->in_use = FALSE; + + // Get the alarm for the timer list entry. + alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_tle); + if (alarm == NULL) { + LOG_WARN("%s Unable to find expected alarm in hashmap", __func__); + return; + } + alarm_cancel(alarm); } #if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) @@ -733,47 +503,55 @@ void btu_stop_timer (TIMER_LIST_ENT *p_tle) ** ** Function btu_start_quick_timer ** -** Description Start a timer for the specified amount of time. -** NOTE: The timeout resolution depends on including modules. -** QUICK_TIMER_TICKS_PER_SEC should be used to convert from -** time to ticks. -** +** Description Start a timer for the specified amount of time in ticks. ** ** Returns void ** *******************************************************************************/ -void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout) -{ - BT_HDR *p_msg; - - GKI_disable(); - /* if timer list is currently empty, start periodic GKI timer */ - if (btu_cb.quick_timer_queue.p_first == NULL) - { - /* script test calls stack API without posting event */ - if (GKI_get_taskid() != BTU_TASK) - { - /* post event to start timer in BTU task */ - if ((p_msg = (BT_HDR *)GKI_getbuf(BT_HDR_SIZE)) != NULL) - { - p_msg->event = BT_EVT_TO_START_QUICK_TIMER; - GKI_send_msg (BTU_TASK, TASK_MBOX_0, p_msg); - } - } - else - GKI_start_timer(TIMER_2, QUICK_TIMER_TICKS, TRUE); - } - - GKI_remove_from_timer_list (&btu_cb.quick_timer_queue, p_tle); +static void btu_l2cap_alarm_process(TIMER_LIST_ENT *p_tle) { + assert(p_tle != NULL); + + switch (p_tle->event) { + case BTU_TTYPE_L2CAP_CHNL: /* monitor or retransmission timer */ + case BTU_TTYPE_L2CAP_FCR_ACK: /* ack timer */ + l2c_process_timeout (p_tle); + break; + + default: + break; + } +} - p_tle->event = type; - p_tle->ticks = timeout; - p_tle->ticks_initial = timeout; +static void btu_l2cap_alarm_cb(void *data) { + assert(data != NULL); + TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data; - GKI_add_to_timer_list (&btu_cb.quick_timer_queue, p_tle); - GKI_enable(); + fixed_queue_enqueue(btu_l2cap_alarm_queue, p_tle); } +void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ticks) { + assert(p_tle != NULL); + + // Get the alarm for the timer list entry. + pthread_mutex_lock(&btu_l2cap_alarm_lock); + if (!hash_map_has_key(btu_l2cap_alarm_hash_map, p_tle)) { + hash_map_set(btu_l2cap_alarm_hash_map, p_tle, alarm_new()); + } + pthread_mutex_unlock(&btu_l2cap_alarm_lock); + + alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle); + if (alarm == NULL) { + LOG_ERROR("%s Unable to create alarm", __func__); + return; + } + alarm_cancel(alarm); + + p_tle->event = type; + p_tle->ticks = timeout_ticks; + p_tle->in_use = TRUE; + // The quick timer ticks are 100ms long. + alarm_set(alarm, (period_ms_t)(timeout_ticks * 100), btu_l2cap_alarm_cb, (void *)p_tle); +} /******************************************************************************* ** @@ -784,126 +562,73 @@ void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout) ** Returns void ** *******************************************************************************/ -void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle) -{ - GKI_disable(); - GKI_remove_from_timer_list (&btu_cb.quick_timer_queue, p_tle); - - /* if timer list is empty stop periodic GKI timer */ - if (btu_cb.quick_timer_queue.p_first == NULL) - { - GKI_stop_timer(TIMER_2); - } - GKI_enable(); -} - -/******************************************************************************* -** -** Function btu_process_quick_timer_evt -** -** Description Process quick timer event -** -** Returns void -** -*******************************************************************************/ -void btu_process_quick_timer_evt(void) -{ - process_quick_timer_evt(&btu_cb.quick_timer_queue); - - /* if timer list is empty stop periodic GKI timer */ - if (btu_cb.quick_timer_queue.p_first == NULL) - { - GKI_stop_timer(TIMER_2); - } +void btu_stop_quick_timer(TIMER_LIST_ENT *p_tle) { + assert(p_tle != NULL); + + if (p_tle->in_use == FALSE) + return; + p_tle->in_use = FALSE; + + // Get the alarm for the timer list entry. + alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle); + if (alarm == NULL) { + LOG_WARN("%s Unable to find expected alarm in hashmap", __func__); + return; + } + alarm_cancel(alarm); } +#endif /* defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) */ -/******************************************************************************* -** -** Function process_quick_timer_evt -** -** Description Process quick timer event -** -** Returns void -** -*******************************************************************************/ -void process_quick_timer_evt(TIMER_LIST_Q *p_tlq) -{ - TIMER_LIST_ENT *p_tle; - - GKI_update_timer_list (p_tlq, 1); +void btu_oneshot_alarm_cb(void *data) { + assert(data != NULL); + TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data; - while ((p_tlq->p_first) && (!p_tlq->p_first->ticks)) - { - p_tle = p_tlq->p_first; - GKI_remove_from_timer_list (p_tlq, p_tle); - - switch (p_tle->event) - { - case BTU_TTYPE_L2CAP_CHNL: /* monitor or retransmission timer */ - case BTU_TTYPE_L2CAP_FCR_ACK: /* ack timer */ - l2c_process_timeout (p_tle); - break; + btu_stop_timer_oneshot(p_tle); - default: - break; - } - } + fixed_queue_enqueue(btu_oneshot_alarm_queue, p_tle); } -#endif /* defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) */ /* * Starts a oneshot timer with a timeout in seconds. */ -void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_in_secs) { - INT32 timeout_in_ticks = GKI_SECS_TO_TICKS(timeout_in_secs); - BTM_TRACE_DEBUG("Starting oneshot timer type:%d timeout:%ds", type, timeout_in_secs); - GKI_disable(); - if (GKI_timer_queue_is_empty(&btu_cb.timer_queue_oneshot)) { - } - - GKI_remove_from_timer_list(&btu_cb.timer_queue_oneshot, p_tle); - - p_tle->event = type; - p_tle->ticks = timeout_in_ticks; - p_tle->ticks_initial = timeout_in_ticks; - - GKI_add_to_timer_list(&btu_cb.timer_queue_oneshot, p_tle); - /* RPC to BTU thread if timer start request from non-BTU task */ - if (GKI_get_taskid() != BTU_TASK) { - /* post event to start timer in BTU task */ - BTM_TRACE_WARNING("Posting oneshot timer event to btu_task"); - BT_HDR *p_msg = (BT_HDR *)GKI_getbuf(BT_HDR_SIZE); - if (p_msg != NULL) { - p_msg->event = BT_EVT_TO_START_TIMER_ONESHOT; - GKI_send_msg (BTU_TASK, TASK_MBOX_0, p_msg); - } - } else { - TIMER_LIST_ENT *tle = GKI_timer_getfirst(&btu_cb.timer_queue_oneshot); - GKI_start_timer(TIMER_3, tle->ticks, FALSE); - } - GKI_enable(); +void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) { + assert(p_tle != NULL); + + // Get the alarm for the timer list entry. + pthread_mutex_lock(&btu_oneshot_alarm_lock); + if (!hash_map_has_key(btu_oneshot_alarm_hash_map, p_tle)) { + hash_map_set(btu_oneshot_alarm_hash_map, p_tle, alarm_new()); + } + pthread_mutex_unlock(&btu_oneshot_alarm_lock); + + alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle); + if (alarm == NULL) { + LOG_ERROR("%s Unable to create alarm", __func__); + return; + } + alarm_cancel(alarm); + + p_tle->event = type; + p_tle->in_use = TRUE; + // NOTE: This value is in seconds but stored in a ticks field. + p_tle->ticks = timeout_sec; + alarm_set(alarm, (period_ms_t)(timeout_sec * 1000), btu_oneshot_alarm_cb, (void *)p_tle); } void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle) { - GKI_disable(); - GKI_remove_from_timer_list(&btu_cb.timer_queue_oneshot, p_tle); - - if (GKI_get_taskid() != BTU_TASK) { - /* post event to stop timer in BTU task */ - BT_HDR *p_msg = (BT_HDR *)GKI_getbuf(BT_HDR_SIZE); - if (p_msg != NULL) { - p_msg->event = BT_EVT_TO_STOP_TIMER_ONESHOT; - GKI_send_msg (BTU_TASK, TASK_MBOX_0, p_msg); - } - } else { - if (GKI_timer_queue_is_empty(&btu_cb.timer_queue_oneshot)) { - BTM_TRACE_WARNING("Stopping oneshot timer"); - GKI_stop_timer(TIMER_3); - } else { - BTM_TRACE_WARNING("Request to stop oneshot timer with non empty queue"); - } - } - GKI_enable(); + assert(p_tle != NULL); + + if (p_tle->in_use == FALSE) + return; + p_tle->in_use = FALSE; + + // Get the alarm for the timer list entry. + alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle); + if (alarm == NULL) { + LOG_WARN("%s Unable to find expected alarm in hashmap", __func__); + return; + } + alarm_cancel(alarm); } #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE) @@ -918,14 +643,10 @@ void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle) { *******************************************************************************/ void btu_check_bt_sleep (void) { - if ((btu_cb.hci_cmd_cb[LOCAL_BR_EDR_CONTROLLER_ID].cmd_cmpl_q.count == 0) - &&(btu_cb.hci_cmd_cb[LOCAL_BR_EDR_CONTROLLER_ID].cmd_xmit_q.count == 0)) + // TODO(zachoverflow) take pending commands into account? + if (l2cb.controller_xmit_window == l2cb.num_lm_acl_bufs) { - if (l2cb.controller_xmit_window == l2cb.num_lm_acl_bufs) - { - /* enable dev to sleep in the cmd cplt and cmd status only and num cplt packet */ - HCI_LP_ALLOW_BT_DEVICE_SLEEP(); - } + bte_main_lpm_allow_bt_device_sleep(); } } #endif diff --git a/stack/gap/gap_api.c b/stack/gap/gap_api.c index 530d1413a..a81efdca5 100644 --- a/stack/gap/gap_api.c +++ b/stack/gap/gap_api.c @@ -21,831 +21,8 @@ #include "bt_target.h" #include "bt_utils.h" #include "gap_int.h" -#include "btm_int.h" -#include "gki.h" -#include "btu.h" -/******************************************************************************* -** -** Function GAP_SetDiscoverableMode -** -** Description This function is called to allow or disallow a service to -** discovered (Inquiry Scans). -** -** Parameters: mode - GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE, -** or GAP_GENERAL_DISCOVERABLE -** -** duration - Amount of time for the duration of an inquiry scan. -** The step size is in 0.625 msec intervals. -** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs) -** -** If a value of '0' is entered the default of -** 0x0012 (11.25 msecs) will be used. -** Note: The duration must be less than or equal to -** the interval. -** -** interval - Amount of time between the start of two inquiry scans. -** The step size is in 0.625 msec intervals. -** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs) -** If a value of '0' is entered the default of -** 0x800 (1.28 secs) will be used. -** -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_ILL_PARM if a bad parameter is detected, -** GAP_DEVICE_NOT_UP if the device is not active, -** GAP_ERR_PROCESSING if not enough resources to carry out request -** -*******************************************************************************/ -UINT16 GAP_SetDiscoverableMode (UINT16 mode, UINT16 duration, UINT16 interval) -{ - tBTM_STATUS status; - - status = BTM_SetDiscoverability(mode, duration, interval); - - return (gap_convert_btm_status (status)); -} - - -/******************************************************************************* -** -** Function GAP_ReadDiscoverableMode -** -** Description This function is called to retrieve the current discoverable mode -** for the local device. -** -** Parameters: duration - pointer to the amount of time of an inquiry scan. -** The step size is in 0.625 msec intervals. -** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs) -** -** interval - pointer to the amount of time between the start of -** two inquiry scans. -** The step size is in 0.625 msec intervals. -** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs) -** -** -** Returns GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE, or -** GAP_GENERAL_DISCOVERABLE -** -*******************************************************************************/ -UINT16 GAP_ReadDiscoverableMode (UINT16 *duration, UINT16 *interval) -{ - return (BTM_ReadDiscoverability(duration, interval)); -} - - -/******************************************************************************* -** -** Function GAP_SetConnectableMode -** -** Description This function is called to allow or disallow a -** connections on the local device. -** -** Parameters: mode - GAP_NON_CONNECTABLE, GAP_CONNECTABLE, -** -** duration - Amount of time for the duration of a page scan. -** The step size is in 0.625 msec intervals. -** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs) -** -** If a value of '0' is entered the default of -** 0x0012 (11.25 msecs) will be used. -** Note: The duration must be less than or equal to -** the interval. -** -** interval - Amount of time between the start of two page scans. -** The step size is in 0.625 msec intervals. -** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs) -** If a value of '0' is entered the default of -** 0x800 (1.28 secs) will be used. -** -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_ILL_PARM if a bad parameter is detected, -** GAP_DEVICE_NOT_UP if the device is not active, -** GAP_ERR_PROCESSING if not enough resources to carry out request -** -*******************************************************************************/ -UINT16 GAP_SetConnectableMode (UINT16 mode, UINT16 duration, UINT16 interval) -{ - tBTM_STATUS status; - - status = BTM_SetConnectability(mode, duration, interval); - - return (gap_convert_btm_status (status)); -} - - -/******************************************************************************* -** -** Function GAP_FindAddrByName -** -** Description This function is called to retrieve a device address given -** a device name. It first looks in the current local inquiry -** database for the device with the specified name. If not found -** it initiates a general inquiry. Upon completion, it retrieves -** the name for each device until a match is found or all devices -** have been checked. Note: This process can take a while to -** complete. -** -** Parameters: devname - -** -** inqparms - pointer to the inquiry information -** mode - GAP_GENERAL_INQUIRY or GAP_LIMITED_INQUIRY inquiry -** duration - length in 1.28 sec intervals -** max_resps - maximum amount of devices to search for before ending the inquiry -** filter_cond_type - GAP_CLR_INQUIRY_FILTER, GAP_FILTER_COND_DEVICE_CLASS, or -** GAP_FILTER_COND_BD_ADDR -** filter_cond - value for the filter (based on filter_cond_type) -** -** -** Returns BT_PASS if the name was immediately available. (BD_ADDR is returned) -** GAP_CMD_INITIATED if an inquiry has been initiated -** -*******************************************************************************/ -UINT16 GAP_FindAddrByName (BD_NAME devname, tGAP_INQ_PARMS *p_inq_parms, tGAP_CALLBACK *p_addr_cb, - BD_ADDR bd_addr) -{ - UINT16 status; - tBTM_STATUS btm_status; - - - /* If the remote name is retrieved automatically during an inquiry search the local db first */ - if ((status = gap_find_local_addr_by_name (devname, bd_addr)) != BT_PASS) - { - /* If this code is used, the name wasn't in the current inquiry database */ - /* A general inquiry must now be initiated */ - if (gap_cb.findaddr_cb.in_use == FALSE) - { - gap_cb.findaddr_cb.p_cback = p_addr_cb; - gap_cb.findaddr_cb.p_cur_inq = (tBTM_INQ_INFO *) NULL; /* Reset to the beginning of the database */ - BCM_STRNCPY_S ((char *)gap_cb.findaddr_cb.results.devname, sizeof(gap_cb.findaddr_cb.results.devname), (char *)devname, BTM_MAX_REM_BD_NAME_LEN); - - /* make sure we have an end of string char */ - gap_cb.findaddr_cb.results.devname[BTM_MAX_REM_BD_NAME_LEN] = 0; - - btm_status = BTM_StartInquiry (p_inq_parms, (tBTM_INQ_RESULTS_CB *) NULL, - (tBTM_CMPL_CB *) gap_find_addr_inq_cb); - gap_cb.findaddr_cb.in_use = TRUE; - - /* convert the error code into a GAP code and check the results for any errors */ - if ((status = gap_convert_btm_status (btm_status)) == GAP_CMD_INITIATED) - gap_cb.findaddr_cb.in_use = TRUE; - } - else - status = GAP_ERR_BUSY; - } - - return (status); -} - - -/******************************************************************************* -** -** Function GAP_ReadConnectableMode -** -** Description This function is called to retrieve the current connectability -** mode for the local device. -** -** Parameters: duration - pointer to the amount of time of an page scan. -** The step size is in 0.625 msec intervals. -** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs) -** -** interval - pointer to the amount of time between the start of -** two page scans. -** The step size is in 0.625 msec intervals. -** Range: 0x0012 - 0x1000 (11.25 - 2560 msecs) -** -** -** Returns GAP_NON_CONNECTABLE, GAP_CONNECTABLE -** -*******************************************************************************/ - -UINT16 GAP_ReadConnectableMode (UINT16 *duration, UINT16 *interval) -{ - return (BTM_ReadConnectability(duration, interval)); -} - - -/******************************************************************************* -** -** Function GAP_SetSecurityMode -** -** Description Set security mode for the device -** -** Returns void -** -*******************************************************************************/ -void GAP_SetSecurityMode (UINT8 sec_mode) -{ - BTM_SetSecurityMode (sec_mode); -} - - -/******************************************************************************* -** -** Function GAP_Bond -** -** Description This function is called to perform bonding with peer device -** -** Parameters: bd_addr - Address of the device to bond -** pin_len - length in bytes of the PIN Code -** p_pin - pointer to array with the PIN Code -** trusted_mask - bitwise OR of trusted services (array of UINT32) -** -*******************************************************************************/ -UINT8 GAP_Bond (BD_ADDR bd_addr, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) -{ - return ((UINT8) BTM_SecBond (bd_addr, pin_len, p_pin, trusted_mask)); -} - - -/******************************************************************************* -** -** Function GAP_SecRegister -** -** Description Application manager calls this function to register for -** security services. There can be one and only one application -** saving link keys. BTM allows only first registration. -** -** Returns TRUE if registered OK, else FALSE -** -*******************************************************************************/ -BOOLEAN GAP_SecRegister (tBTM_APPL_INFO *p_cb_info) -{ - return (BTM_SecRegister (p_cb_info)); -} - - -/******************************************************************************* -** -** Function GAP_PinRsp -** -** Description This function is called from UI after Security Manager submitted -** PIN code request. -** -** Parameters: bd_addr - Address of the device for which PIN was requested -** res - result of the operation BTM_SUCCESS if success -** pin_len - length in bytes of the PIN Code -** p_pin - pointer to array with the PIN Code -** trusted_mask - bitwise OR of trusted services (array of UINT32) -** -*******************************************************************************/ -void GAP_PinRsp (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin, UINT32 trusted_mask[]) -{ - BTM_PINCodeReply (bd_addr, res, pin_len, p_pin, trusted_mask); -} - - -/******************************************************************************* -** -** Function GAP_AuthorizeRsp -** -** Description This function is called from UI after Security Manager submitted -** authorization request -** -** Parameters: bd_addr - Address of the device for which PIN was requested -** res - result of the operation BTM_SUCCESS if success -** trusted_mask - bitwise OR of trusted services (array of UINT32) -** -*******************************************************************************/ -void GAP_AuthorizeRsp (BD_ADDR bd_addr, UINT8 res, UINT32 trusted_mask[]) -{ - BTM_DeviceAuthorized (bd_addr, res, trusted_mask); -} - - -/******************************************************************************* -** -** Function GAP_SetPairableMode -** -** Description This function is called to allow or disallow pairing -** on the local device. -** -** Parameters: mode - GAP_ALLOW_PAIRING, GAP_DISALLOW_PAIRING -** connect_only_pairable - TRUE or FALSE connect only to paired devices -** -** callback - The callback is called when a pin number is requested. -** -** Returns BT_PASS (0) if successful, or a non-zero error code -** -*******************************************************************************/ - -UINT16 GAP_SetPairableMode (UINT16 mode, BOOLEAN connect_only_paired) -{ - tBTM_STATUS btm_status; - UINT16 status = BT_PASS; - - if (mode == GAP_ALLOW_PAIRING) - { - btm_status = BTM_SetConnectability(BTM_CONNECTABLE, 0, 0); - - if ((status = gap_convert_btm_status (btm_status)) == BT_PASS) - BTM_SetPairableMode (TRUE, connect_only_paired); - } - else if (mode == GAP_DISALLOW_PAIRING) - { - BTM_SetPairableMode (FALSE, connect_only_paired); - } - else - { - GAP_TRACE_ERROR ("GAP_SetPairableMode: illegal mode %d", mode); - status = GAP_ERR_ILL_MODE; - } - return (status); -} - - -/******************************************************************************* -** -** Function GAP_StartInquiry -** -** Description This function initiates a single inquiry. -** -** Parameters: p_inqparms - pointer to the inquiry information -** mode - GAP_GENERAL_INQUIRY or GAP_LIMITED_INQUIRY inquiry -** duration - length in 1.28 sec intervals -** max_resps - maximum amount of devices to search for before ending the inquiry -** filter_cond_type - GAP_CLR_INQUIRY_FILTER, GAP_FILTER_COND_DEVICE_CLASS, or -** GAP_FILTER_COND_BD_ADDR -** filter_cond - value for the filter (based on filter_cond_type) -** -** p_results_cb - Pointer to the callback routine which gets called -** upon receipt of an inquiry result. If this field is -** NULL, the application is not notified. -** -** p_cmpl_cb - Pointer to the callback routine which gets called -** upon completion. If this field is NULL, the -** application is not notified when completed. -** -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_ILL_MODE if a bad mode parameter was passed -** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed -** GAP_ERR_NO_CTRL_BLK if out of control blocks -** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM -** GAP_ERR_BUSY if the device already has an iquiry active -** GAP_DEVICE_NOT_UP if the device is not initialized yet -** GAP_ERR_PROCESSING if any other BTM error was returned -** -*******************************************************************************/ -UINT16 GAP_StartInquiry (tGAP_INQ_PARMS *p_inq_parms, tGAP_CALLBACK *p_results_cb, tGAP_CALLBACK *p_cmpl_cb) -{ - tGAP_INFO *p_cb; - tBTM_STATUS btm_status; - UINT16 retval; - - /*** Make sure the parameters are valid before continuing ***/ - if (p_inq_parms->mode != GAP_GENERAL_INQUIRY && p_inq_parms->mode != GAP_LIMITED_INQUIRY) - return (GAP_ERR_ILL_MODE); - - if (p_inq_parms->duration < GAP_MIN_INQUIRY_LEN || - p_inq_parms->duration > GAP_MAX_INQUIRY_LENGTH) - return (GAP_ERR_ILL_INQ_TIME); - - /*** get a control block for this operation ***/ - if ((p_cb = gap_allocate_cb()) != NULL) - { - p_cb->gap_cback = p_cmpl_cb; - p_cb->gap_inq_rslt_cback = p_results_cb; - p_cb->event = GAP_EVT_INQUIRY_COMPLETE; /* Return event expected */ - - btm_status = BTM_StartInquiry(p_inq_parms, gap_inq_results_cb, - (tBTM_CMPL_CB *) gap_cb.btm_cback[p_cb->index]); - - /* convert the error code into a GAP code and check the results for any errors */ - if ((retval = gap_convert_btm_status (btm_status)) != GAP_CMD_INITIATED) - gap_free_cb(p_cb); /* Error starting the inquiry */ - } - else - retval = GAP_ERR_NO_CTRL_BLK; - - return (retval); -} - - -/******************************************************************************* -** -** Function GAP_StartPeriodicInquiry -** -** Description This function initiates a periodic inquiry. -** -** Parameters: p_inqparms - pointer to the inquiry information -** mode - GAP_GENERAL_INQUIRY or GAP_LIMITED_INQUIRY inquiry -** duration - length in 1.28 sec intervals -** max_resps - maximum amount of devices to search for before ending the inquiry -** filter_cond_type - GAP_CLR_INQUIRY_FILTER, GAP_FILTER_COND_DEVICE_CLASS, or -** GAP_FILTER_COND_BD_ADDR -** filter_cond - value for the filter (based on filter_cond_type) -** -** min_time - Minimum amount of time between consecutive inquiries. -** The value is in 1.28 second intervals. -** Range: 0x0002 - 0xFFFE (2.56 - 83883.52 seconds) -** -** max_time - Maximum amount of time between consecutive inquiries. -** The value is in 1.28 sec intervals. -** Range: 0x0003 - 0xFFFF (3.84 - 83884.8 seconds) -** -** p_results_cb - Pointer to the callback routine which gets called -** upon receipt of an inquiry result. If this field is -** NULL, the application is not notified. -** -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_ILL_MODE if a bad mode parameter was passed -** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed -** GAP_ERR_NO_CTRL_BLK if out of control blocks -** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM -** GAP_ERR_BUSY if the device already has an iquiry active -** GAP_DEVICE_NOT_UP if the device is not initialized yet -** GAP_ERR_PROCESSING if any other BTM error was returned -** -*******************************************************************************/ - -UINT16 GAP_StartPeriodicInquiry (tGAP_INQ_PARMS *p_inq_parms, UINT16 min_time, - UINT16 max_time, tGAP_CALLBACK *p_results_cb) -{ - tGAP_INFO *p_cb; - tBTM_STATUS btm_status; - UINT16 retval = BT_PASS; - - /*** Make sure the parameters are valid before continuing ***/ - if (p_inq_parms->mode != GAP_GENERAL_INQUIRY && p_inq_parms->mode != GAP_LIMITED_INQUIRY) - return (GAP_ERR_ILL_MODE); - - if (p_inq_parms->duration < GAP_MIN_INQUIRY_LEN || - p_inq_parms->duration > GAP_MAX_INQUIRY_LENGTH || - min_time <= p_inq_parms->duration || - min_time < GAP_PER_INQ_MIN_MIN_PERIOD || - min_time > GAP_PER_INQ_MAX_MIN_PERIOD || - max_time <= min_time || - max_time < GAP_PER_INQ_MIN_MAX_PERIOD) - { - return (GAP_ERR_ILL_INQ_TIME); - } - - /*** get a control block for this operation ***/ - if ((p_cb = gap_allocate_cb()) != NULL) - { - p_cb->gap_inq_rslt_cback = p_results_cb; - p_cb->event = GAP_EVT_INQUIRY_COMPLETE; /* mark the inquiry event active */ - - btm_status = BTM_SetPeriodicInquiryMode(p_inq_parms, max_time, min_time, - gap_inq_results_cb); - - /* convert the error code into a GAP code and check the results for any errors */ - if ((retval = gap_convert_btm_status (btm_status)) != GAP_CMD_INITIATED) - gap_free_cb(p_cb); /* Error starting the inquiry */ - } - else - retval = GAP_ERR_NO_CTRL_BLK; - - return (retval); -} - - -/******************************************************************************* -** -** Function GAP_CancelInquiry -** -** Description This function cancels a single inquiry (if in progress) -** -** Parameters: None -** -** Returns BOOLEAN (TRUE if successful, otherwise FALSE) -** -*******************************************************************************/ -UINT16 GAP_CancelInquiry(void) -{ - tGAP_INFO *p_cb = &gap_cb.blk[0]; - UINT8 x; - tBTM_STATUS btm_status; - UINT16 status; - - btm_status = BTM_CancelInquiry(); - if ((status = gap_convert_btm_status (btm_status)) == BT_PASS) - { - /* Free the control block that is waiting for the inquiry complete event */ - for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++) - { - if (p_cb->in_use && p_cb->event == GAP_EVT_INQUIRY_COMPLETE) - { - gap_free_cb(p_cb); - return (BT_PASS); - } - } - - /* If here the control block was not found */ - status = GAP_ERR_NO_CTRL_BLK; - } - - return (status); -} - - -/******************************************************************************* -** -** Function GAP_CancelPeriodicInquiry -** -** Description This function cancels a periodic inquiry (if in progress) -** -** Parameters: None -** -** Returns BOOLEAN: (TRUE if successful, otherwise FALSE) -** -*******************************************************************************/ -UINT16 GAP_CancelPeriodicInquiry(void) -{ - tGAP_INFO *p_cb = &gap_cb.blk[0]; - UINT8 x; - tBTM_STATUS btm_status; - UINT16 status; - - btm_status = BTM_CancelPeriodicInquiry(); - if ((status = gap_convert_btm_status (btm_status)) == BT_PASS) - { - /* Free the control block that is waiting for the inquiry complete event */ - for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++) - { - if (p_cb->in_use && p_cb->event == GAP_EVT_INQUIRY_COMPLETE) - { - gap_free_cb(p_cb); - return (BT_PASS); - } - } - - /* If here the control block was not found */ - status = GAP_ERR_NO_CTRL_BLK; - } - - return (status); -} - - -/******************************************************************************* -** -** Function GAP_GetFirstInquiryResult -** -** Description This function retrieves the first valid inquiry result. -** -** Parameters: p_results - pointer to the inquiry results -** -** Returns BT_PASS (0) if successful, or a non-zero error code -** GAP_EOINQDB if no more entries in the database. -** -*******************************************************************************/ -UINT16 GAP_GetFirstInquiryResult(tGAP_INQ_RESULTS *p_results) -{ - UINT8 *ptr; - - gap_cb.cur_inqptr = BTM_InqFirstResult(); - - if (gap_cb.cur_inqptr != NULL) - { - memcpy(p_results, &gap_cb.cur_inqptr->results, sizeof(tBTM_INQ_RESULTS)); - - ptr = (UINT8 *)gap_cb.cur_inqptr->results.remote_bd_addr; - GAP_TRACE_EVENT("GAP_GetFirstInqResult %02x%02x%02x%02x%02x%02x", - ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5]); - return(BT_PASS); - } - else - { - GAP_TRACE_EVENT("GAP_FirstInqResults: No BD_ADDRs Found"); - memset(p_results, 0, sizeof(tBTM_INQ_RESULTS)); - return(GAP_EOINQDB); - } -} - - -/******************************************************************************* -** -** Function GAP_GetNextInquiryResult -** -** Description This function retrieves the next valid inquiry result. -** -** Parameters: p_results - pointer to the inquiry results -** -** Returns BT_PASS (0) if successful, or a non-zero status code -** GAP_EOINQDB if no more entries in the database. -** -*******************************************************************************/ -UINT16 GAP_GetNextInquiryResult(tGAP_INQ_RESULTS *p_results) -{ - UINT8 *ptr; - - /*** if the current inquiry db pointer is NULL then call the first entry ***/ - if (gap_cb.cur_inqptr) - { - gap_cb.cur_inqptr = BTM_InqNextResult(gap_cb.cur_inqptr); - if (gap_cb.cur_inqptr != NULL) - { - memcpy(p_results, &gap_cb.cur_inqptr->results, - sizeof(tGAP_INQ_RESULTS)); - - ptr = (UINT8 *)gap_cb.cur_inqptr->results.remote_bd_addr; - GAP_TRACE_EVENT("GAP_GetNextInqResult %02x%02x%02x%02x%02x%02x", - ptr[0],ptr[1],ptr[2],ptr[3],ptr[4],ptr[5]); - - return(BT_PASS); - } - else - { - GAP_TRACE_EVENT("GAP_NextInqResults: No BD_ADDRs Found"); - memset(p_results, 0, sizeof(tBTM_INQ_RESULTS)); - return(GAP_EOINQDB); - } - } - else - return (GAP_GetFirstInquiryResult(p_results)); -} - - -/******************************************************************************* -** -** Function GAP_ReadLocalDeviceInfo -** -** Description This function retrieves local device information to the caller. -** -** Parameters: name - (output) pointer to the UTF-8 encoded string representing -** the device name. -** -** addr - (output) pointer to the Bluetooth device address (BD_ADDR). -** -** verinfo - (output) pointer to the LMP version information. -** -** features - (output) pointer to the LMP features for the device. -** -** NOTE: Return parameters that are set to NULL are not retrieved. -** -** Returns BT_PASS (0) if successful, or a non-zero error code -** -*******************************************************************************/ - -UINT16 GAP_ReadLocalDeviceInfo(UINT8 *name, BD_ADDR *addr, tGAP_LMP_VERSION *verinfo, - tGAP_LMP_FEATURES *features) -{ - UNUSED(name); - UNUSED(addr); - UNUSED(verinfo); - UNUSED(features); - return (GAP_UNSUPPORTED); -} - - - -/******************************************************************************* -** -** Function GAP_GetRemoteDeviceName -** -** Description The remote name is retrieved from the specified remote device. If -** GAP_CMD_INITIATED is returned by the function, the command was -** successfully sent to the controller. The GAP_EVT_NAME_RESP event -** is passed in the callback when the remote device name has been retrieved. -** -** Parameters: addr - The Bluetooth device address (BD_ADDR) of the remote -** device. -** -** callback - pointer to the callback which is called after the -** remote device has been retrieved. -** p_data in the callback points to the structure containing the -** status, device name length, and the UTF-8 encoded -** device name. (type tBTM_REMOTE_DEV_NAME) -** The event field in the callback is set to GAP_EVT_REM_NAME_COMPLETE. -** The callback is not called unless (GAP_CMD_INITIATED) is returned. -** -** -** Returns -** GAP_CMD_INITIATED if remote search successfully initiated -** GAP_ERR_BUSY if a remote name request is already in progress, -** GAP_ERR_NO_CTRL_BLK if out of control blocks (too many commands pending) -** GAP_BAD_BD_ADDR if the device address is bad, -** GAP_DEVICE_NOT_UP if the device has not been initialized yet -** GAP_ERR_PROCESSING if any other BTM error has been returned -** -*******************************************************************************/ -UINT16 GAP_GetRemoteDeviceName (BD_ADDR addr, tGAP_CALLBACK *callback) -{ - tGAP_INFO *p_cb; - UINT16 retval; - tBTM_STATUS btm_status; - - if ((p_cb = gap_allocate_cb()) != NULL) - { - p_cb->gap_cback = callback; - p_cb->event = GAP_EVT_REM_NAME_COMPLETE; /* Return event expected */ - - btm_status = BTM_ReadRemoteDeviceName (addr, gap_cb.btm_cback[p_cb->index], BT_TRANSPORT_BR_EDR); - - /* If the name was not returned immediately, or if an error occurred, release the control block */ - if ((retval = gap_convert_btm_status (btm_status)) != GAP_CMD_INITIATED) - gap_free_cb (p_cb); - } - else - retval = GAP_ERR_NO_CTRL_BLK; - - return (retval); -} - -/******************************************************************************* -** -** Function GAP_SetDeviceClass -** -** Description This function updates the local Device Class. -** -** Parameters: -** p_cod - Pointer to the device class to set to -** -** cmd - the fields of the device class to update. -** GAP_SET_COD_MAJOR_MINOR, - overwrite major, minor class -** GAP_SET_COD_SERVICE_CLASS - set the bits in the input -** GAP_CLR_COD_SERVICE_CLASS - clear the bits in the input -** GAP_SET_COD_ALL - overwrite major, minor, set the bits in service class -** GAP_INIT_COD - overwrite major, minor, and service class -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_BUSY if a discovery is already in progress -** GAP_ERR_ILL_PARM if an illegal parameter was detected -** GAP_ERR_PROCESSING if any other BTM error has been returned -** -*******************************************************************************/ -UINT16 GAP_SetDeviceClass(tGAP_COD *p_cod, UINT8 cmd) -{ - tBTM_STATUS btm_status; - UINT8 *dev; - UINT16 service; - UINT8 minor, major; - DEV_CLASS dev_class; - - dev = BTM_ReadDeviceClass(); - BTM_COD_SERVICE_CLASS( service, dev ); - BTM_COD_MINOR_CLASS(minor, dev ); - BTM_COD_MAJOR_CLASS(major, dev ); - - switch(cmd) - { - case GAP_SET_COD_MAJOR_MINOR: - minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK; - major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK; - break; - - case GAP_SET_COD_SERVICE_CLASS: - /* clear out the bits that is not SERVICE_CLASS bits */ - p_cod->service &= BTM_COD_SERVICE_CLASS_MASK; - service = service | p_cod->service; - break; - - case GAP_CLR_COD_SERVICE_CLASS: - p_cod->service &= BTM_COD_SERVICE_CLASS_MASK; - service = service & (~p_cod->service); - break; - - case GAP_SET_COD_ALL: - minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK; - major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK; - p_cod->service &= BTM_COD_SERVICE_CLASS_MASK; - service = service | p_cod->service; - break; - - case GAP_INIT_COD: - minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK; - major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK; - service = p_cod->service & BTM_COD_SERVICE_CLASS_MASK; - break; - - default: - return GAP_ERR_ILL_PARM; - } - - /* convert the fields into the device class type */ - FIELDS_TO_COD(dev_class, minor, major, service); - - btm_status = BTM_SetDeviceClass(dev_class); - return (gap_convert_btm_status (btm_status)); -} - -/******************************************************************************* -** -** Function GAP_ReadDeviceClass -** -** Description This function reads the local Device Class. -** -** Parameters: -** -** Returns PASS -** -*******************************************************************************/ -UINT16 GAP_ReadDeviceClass(tGAP_COD *p_cod) -{ - UINT8 *dev; - - dev = BTM_ReadDeviceClass(); - - BTM_COD_SERVICE_CLASS( p_cod->service, dev ); - BTM_COD_MINOR_CLASS( p_cod->minor, dev ); - BTM_COD_MAJOR_CLASS( p_cod->major, dev ); - - return (BT_PASS); -} +tGAP_CB gap_cb; /******************************************************************************* ** @@ -881,26 +58,12 @@ void GAP_Init(void) { memset (&gap_cb, 0, sizeof (tGAP_CB)); - /*** Initialize the callbacks for BTM; Needs to be one per GAP_MAX_BLOCKS ***/ - gap_cb.btm_cback[0] = gap_btm_cback0; -#if GAP_MAX_BLOCKS > 1 - gap_cb.btm_cback[1] = gap_btm_cback1; -#endif -#if GAP_MAX_BLOCKS > 2 - gap_cb.btm_cback[2] = gap_btm_cback2; -#endif - #if defined(GAP_INITIAL_TRACE_LEVEL) gap_cb.trace_level = GAP_INITIAL_TRACE_LEVEL; #else gap_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */ #endif - /* Initialize the connection control block if included in build */ -#if GAP_CONN_INCLUDED == TRUE - gap_conn_init(); -#endif /* GAP_CONN_INCLUDED */ - #if BLE_INCLUDED == TRUE gap_attr_db_init(); #endif diff --git a/stack/gap/gap_conn.c b/stack/gap/gap_conn.c deleted file mode 100644 index 6bab72d53..000000000 --- a/stack/gap/gap_conn.c +++ /dev/null @@ -1,1271 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2013 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. - * - ******************************************************************************/ - - -#include "bt_target.h" -#include "bt_utils.h" -#include "btu.h" -#include "gap_int.h" -#include "l2cdefs.h" -#include "l2c_int.h" -#include <string.h> -#if GAP_CONN_INCLUDED == TRUE -#include "btm_int.h" - -/********************************************************************************/ -/* L O C A L F U N C T I O N P R O T O T Y P E S */ -/********************************************************************************/ -static void gap_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id); -static void gap_connect_cfm (UINT16 l2cap_cid, UINT16 result); -static void gap_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg); -static void gap_config_cfm (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg); -static void gap_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed); -static void gap_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg); -static void gap_congestion_ind (UINT16 lcid, BOOLEAN is_congested); - -static tGAP_CCB *gap_find_ccb_by_cid (UINT16 cid); -static tGAP_CCB *gap_find_ccb_by_handle (UINT16 handle); -static tGAP_CCB *gap_allocate_ccb (void); -static void gap_release_ccb (tGAP_CCB *p_ccb); - -/******************************************************************************* -** -** Function gap_conn_init -** -** Description This function is called to initialize GAP connection management -** -** Returns void -** -*******************************************************************************/ -void gap_conn_init (void) -{ -#if AMP_INCLUDED == TRUE - gap_cb.conn.reg_info.pAMP_ConnectInd_Cb = gap_connect_ind; - gap_cb.conn.reg_info.pAMP_ConnectCfm_Cb = gap_connect_cfm; - gap_cb.conn.reg_info.pAMP_ConnectPnd_Cb = NULL; - gap_cb.conn.reg_info.pAMP_ConfigInd_Cb = gap_config_ind; - gap_cb.conn.reg_info.pAMP_ConfigCfm_Cb = gap_config_cfm; - gap_cb.conn.reg_info.pAMP_DisconnectInd_Cb = gap_disconnect_ind; - gap_cb.conn.reg_info.pAMP_DisconnectCfm_Cb = NULL; - gap_cb.conn.reg_info.pAMP_QoSViolationInd_Cb = NULL; - gap_cb.conn.reg_info.pAMP_DataInd_Cb = gap_data_ind; - gap_cb.conn.reg_info.pAMP_CongestionStatus_Cb = gap_congestion_ind; - gap_cb.conn.reg_info.pAMP_TxComplete_Cb = NULL; - gap_cb.conn.reg_info.pAMP_MoveInd_Cb = NULL; - gap_cb.conn.reg_info.pAMP_MoveRsp_Cb = NULL; - gap_cb.conn.reg_info.pAMP_MoveCfm_Cb = NULL; //gap_move_cfm - gap_cb.conn.reg_info.pAMP_MoveCfmRsp_Cb = NULL; //gap_move_cfm_rsp - -#else - gap_cb.conn.reg_info.pL2CA_ConnectInd_Cb = gap_connect_ind; - gap_cb.conn.reg_info.pL2CA_ConnectCfm_Cb = gap_connect_cfm; - gap_cb.conn.reg_info.pL2CA_ConnectPnd_Cb = NULL; - gap_cb.conn.reg_info.pL2CA_ConfigInd_Cb = gap_config_ind; - gap_cb.conn.reg_info.pL2CA_ConfigCfm_Cb = gap_config_cfm; - gap_cb.conn.reg_info.pL2CA_DisconnectInd_Cb = gap_disconnect_ind; - gap_cb.conn.reg_info.pL2CA_DisconnectCfm_Cb = NULL; - gap_cb.conn.reg_info.pL2CA_QoSViolationInd_Cb = NULL; - gap_cb.conn.reg_info.pL2CA_DataInd_Cb = gap_data_ind; - gap_cb.conn.reg_info.pL2CA_CongestionStatus_Cb = gap_congestion_ind; - gap_cb.conn.reg_info.pL2CA_TxComplete_Cb = NULL; -#endif -} - - -/******************************************************************************* -** -** Function GAP_ConnOpen -** -** Description This function is called to open an L2CAP connection. -** -** Parameters: is_server - If TRUE, the connection is not created -** but put into a "listen" mode waiting for -** the remote side to connect. -** -** service_id - Unique service ID from -** BTM_SEC_SERVICE_FIRST_EMPTY (6) -** to BTM_SEC_MAX_SERVICE_RECORDS (32) -** -** p_rem_bda - Pointer to remote BD Address. -** If a server, and we don't care about the -** remote BD Address, then NULL should be passed. -** -** psm - the PSM used for the connection -** -** p_config - Optional pointer to configuration structure. -** If NULL, the default GAP configuration will -** be used. -** -** security - security flags -** chan_mode_mask - (GAP_FCR_CHAN_OPT_BASIC, GAP_FCR_CHAN_OPT_ERTM, GAP_FCR_CHAN_OPT_STREAM) -** -** p_cb - Pointer to callback function for events. -** -** Returns handle of the connection if successful, else GAP_INVALID_HANDLE -** -*******************************************************************************/ -UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server, - BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg, - UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb) -{ - tGAP_CCB *p_ccb; - UINT16 cid; - - GAP_TRACE_EVENT ("GAP_CONN - Open Request"); - - /* Allocate a new CCB. Return if none available. */ - if ((p_ccb = gap_allocate_ccb()) == NULL) - return (GAP_INVALID_HANDLE); - - /* If caller specified a BD address, save it */ - if (p_rem_bda) - { - /* the bd addr is not BT_BD_ANY, then a bd address was specified */ - if (memcmp (p_rem_bda, BT_BD_ANY, BD_ADDR_LEN)) - p_ccb->rem_addr_specified = TRUE; - - memcpy (&p_ccb->rem_dev_address[0], p_rem_bda, BD_ADDR_LEN); - } - else if (!is_server) - { - /* remore addr is not specified and is not a server -> bad */ - return (GAP_INVALID_HANDLE); - } - - /* A client MUST have specified a bd addr to connect with */ - if (!p_ccb->rem_addr_specified && !is_server) - { - gap_release_ccb (p_ccb); - GAP_TRACE_ERROR ("GAP ERROR: Client must specify a remote BD ADDR to connect to!"); - return (GAP_INVALID_HANDLE); - } - - /* Check if configuration was specified */ - if (p_cfg) - p_ccb->cfg = *p_cfg; - - p_ccb->p_callback = p_cb; - - /* If originator, use a dynamic PSM */ -#if AMP_INCLUDED == TRUE - if (!is_server) - gap_cb.conn.reg_info.pAMP_ConnectInd_Cb = NULL; - else - gap_cb.conn.reg_info.pAMP_ConnectInd_Cb = gap_connect_ind; -#else - if (!is_server) - gap_cb.conn.reg_info.pL2CA_ConnectInd_Cb = NULL; - else - gap_cb.conn.reg_info.pL2CA_ConnectInd_Cb = gap_connect_ind; -#endif - - /* Register the PSM with L2CAP */ - if ((p_ccb->psm = L2CA_REGISTER (psm, &gap_cb.conn.reg_info, AMP_AUTOSWITCH_ALLOWED|AMP_USE_AMP_IF_POSSIBLE)) == 0) - { - GAP_TRACE_ERROR ("GAP_ConnOpen: Failure registering PSM 0x%04x", psm); - gap_release_ccb (p_ccb); - return (GAP_INVALID_HANDLE); - } - - /* Register with Security Manager for the specific security level */ - p_ccb->service_id = service_id; - if (!BTM_SetSecurityLevel ((UINT8)!is_server, p_serv_name, p_ccb->service_id, security, p_ccb->psm, 0, 0)) - { - GAP_TRACE_ERROR ("GAP_CONN - Security Error"); - gap_release_ccb (p_ccb); - return (GAP_INVALID_HANDLE); - } - - /* Fill in eL2CAP parameter data */ - if( p_ccb->cfg.fcr_present ) - { - p_ccb->ertm_info.preferred_mode = p_ccb->cfg.fcr.mode; - p_ccb->ertm_info.user_rx_pool_id = GAP_DATA_POOL_ID; - p_ccb->ertm_info.user_tx_pool_id = GAP_DATA_POOL_ID; - p_ccb->ertm_info.fcr_rx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID; - p_ccb->ertm_info.fcr_tx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID; - } - - /* optional FCR channel modes */ - p_ccb->ertm_info.allowed_modes = (chan_mode_mask) ? chan_mode_mask : (UINT8)L2CAP_FCR_CHAN_OPT_BASIC; - - if (is_server) - { - p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; /* assume btm/l2cap would handle it */ - p_ccb->con_state = GAP_CCB_STATE_LISTENING; - return (p_ccb->gap_handle); - } - else - { - /* We are the originator of this connection */ - p_ccb->con_flags = GAP_CCB_FLAGS_IS_ORIG; - - /* Transition to the next appropriate state, waiting for connection confirm. */ - p_ccb->con_state = GAP_CCB_STATE_CONN_SETUP; - - /* mark security done flag, when security is not required */ - if ((security & (BTM_SEC_OUT_AUTHORIZE | BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT) ) == 0) - p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; - - /* Check if L2CAP started the connection process */ - if (p_rem_bda && ((cid = L2CA_CONNECT_REQ (p_ccb->psm, p_rem_bda, &p_ccb->ertm_info, &bt_uuid)) != 0)) - { - p_ccb->connection_id = cid; - return (p_ccb->gap_handle); - } - else - { - gap_release_ccb (p_ccb); - return (GAP_INVALID_HANDLE); - } - } -} - - -/******************************************************************************* -** -** Function GAP_ConnClose -** -** Description This function is called to close a connection. -** -** Parameters: handle - Handle of the connection returned by GAP_ConnOpen -** -** Returns BT_PASS - closed OK -** GAP_ERR_BAD_HANDLE - invalid handle -** -*******************************************************************************/ -UINT16 GAP_ConnClose (UINT16 gap_handle) -{ - tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle); - - GAP_TRACE_EVENT ("GAP_CONN - close handle: 0x%x", gap_handle); - - if (p_ccb) - { - /* Check if we have a connection ID */ - if (p_ccb->con_state != GAP_CCB_STATE_LISTENING) - L2CA_DISCONNECT_REQ (p_ccb->connection_id); - - gap_release_ccb (p_ccb); - - return (BT_PASS); - } - - return (GAP_ERR_BAD_HANDLE); -} - - - -/******************************************************************************* -** -** Function GAP_ConnReadData -** -** Description Normally not GKI aware application will call this function -** after receiving GAP_EVT_RXDATA event. -** -** Parameters: handle - Handle of the connection returned in the Open -** p_data - Data area -** max_len - Byte count requested -** p_len - Byte count received -** -** Returns BT_PASS - data read -** GAP_ERR_BAD_HANDLE - invalid handle -** GAP_NO_DATA_AVAIL - no data available -** -*******************************************************************************/ -UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT16 *p_len) -{ - tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle); - BT_HDR *p_buf; - UINT16 copy_len; - - if (!p_ccb) - return (GAP_ERR_BAD_HANDLE); - - *p_len = 0; - - p_buf = (BT_HDR *)GKI_getfirst (&p_ccb->rx_queue); - if (!p_buf) - return (GAP_NO_DATA_AVAIL); - - GKI_disable(); - - while (max_len && p_buf) - { - copy_len = (p_buf->len > max_len)?max_len:p_buf->len; - max_len -= copy_len; - *p_len += copy_len; - if (p_data) - { - memcpy (p_data, (UINT8 *)(p_buf + 1) + p_buf->offset, copy_len); - p_data += copy_len; - } - - if (p_buf->len > copy_len) - { - p_buf->offset += copy_len; - p_buf->len -= copy_len; - break; - } - else - { - if (max_len) - { - p_buf = (BT_HDR *)GKI_getnext (p_buf); - } - GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue)); - } - } - - p_ccb->rx_queue_size -= *p_len; - - GKI_enable(); - - GAP_TRACE_EVENT ("GAP_ConnReadData - rx_queue_size left=%d, *p_len=%d", - p_ccb->rx_queue_size, *p_len); - - return (BT_PASS); -} - -/******************************************************************************* -** -** Function GAP_GetRxQueueCnt -** -** Description This function return number of bytes on the rx queue. -** -** Parameters: handle - Handle returned in the GAP_ConnOpen -** p_rx_queue_count - Pointer to return queue count in. -** -** -*******************************************************************************/ -int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count) -{ - tGAP_CCB *p_ccb; - int rc = BT_PASS; - - /* Check that handle is valid */ - if (handle < GAP_MAX_CONNECTIONS) - { - p_ccb = &gap_cb.conn.ccb_pool[handle]; - - if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED) - { - *p_rx_queue_count = p_ccb->rx_queue_size; - } - else - rc = GAP_INVALID_HANDLE; - } - else - rc = GAP_INVALID_HANDLE; - - GAP_TRACE_EVENT ("GAP_GetRxQueueCnt - rc = 0x%04x, rx_queue_count=%d", - rc , *p_rx_queue_count); - - return (rc); -} - -/******************************************************************************* -** -** Function GAP_ConnBTRead -** -** Description Bluetooth aware applications will call this function after receiving -** GAP_EVT_RXDATA event. -** -** Parameters: handle - Handle of the connection returned in the Open -** pp_buf - pointer to address of buffer with data, -** -** Returns BT_PASS - data read -** GAP_ERR_BAD_HANDLE - invalid handle -** GAP_NO_DATA_AVAIL - no data available -** -*******************************************************************************/ -UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf) -{ - tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle); - BT_HDR *p_buf; - - if (!p_ccb) - return (GAP_ERR_BAD_HANDLE); - - p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->rx_queue); - - if (p_buf) - { - *pp_buf = p_buf; - - p_ccb->rx_queue_size -= p_buf->len; - return (BT_PASS); - } - else - { - *pp_buf = NULL; - return (GAP_NO_DATA_AVAIL); - } -} - - -/******************************************************************************* -** -** Function GAP_ConnBTWrite -** -** Description Bluetooth Aware applications can call this function to write data. -** -** Parameters: handle - Handle of the connection returned in the Open -** p_buf - pointer to address of buffer with data, -** -** Returns BT_PASS - data read -** GAP_ERR_BAD_HANDLE - invalid handle -** GAP_ERR_BAD_STATE - connection not established -** GAP_INVALID_BUF_OFFSET - buffer offset is invalid -*******************************************************************************/ -UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf) -{ - tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle); - - if (!p_ccb) - { - GKI_freebuf (p_buf); - return (GAP_ERR_BAD_HANDLE); - } - - if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED) - { - GKI_freebuf (p_buf); - return (GAP_ERR_BAD_STATE); - } - - if (p_buf->offset < L2CAP_MIN_OFFSET) - { - GKI_freebuf (p_buf); - return (GAP_ERR_BUF_OFFSET); - } - - GKI_enqueue (&p_ccb->tx_queue, p_buf); - - if (p_ccb->is_congested) - { - return (BT_PASS); - } - - /* Send the buffer through L2CAP */ -#if (GAP_CONN_POST_EVT_INCLUDED == TRUE) - gap_send_event (gap_handle); -#else - while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL) - { - UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf); - - if (status == L2CAP_DW_CONGESTED) - { - p_ccb->is_congested = TRUE; - break; - } - else if (status != L2CAP_DW_SUCCESS) - return (GAP_ERR_BAD_STATE); - } -#endif - return (BT_PASS); -} - - -/******************************************************************************* -** -** Function GAP_ConnWriteData -** -** Description Normally not GKI aware application will call this function -** to send data to the connection. -** -** Parameters: handle - Handle of the connection returned in the Open -** p_data - Data area -** max_len - Byte count requested -** p_len - Byte count received -** -** Returns BT_PASS - data read -** GAP_ERR_BAD_HANDLE - invalid handle -** GAP_ERR_BAD_STATE - connection not established -** GAP_CONGESTION - system is congested -** -*******************************************************************************/ -UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT16 *p_len) -{ - tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle); - BT_HDR *p_buf; - - *p_len = 0; - - if (!p_ccb) - return (GAP_ERR_BAD_HANDLE); - - if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED) - return (GAP_ERR_BAD_STATE); - - while (max_len) - { - if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) - { - if ((p_buf = (BT_HDR *)GKI_getpoolbuf (p_ccb->ertm_info.user_tx_pool_id)) == NULL) - return (GAP_ERR_CONGESTED); - } - else - { - if ((p_buf = (BT_HDR *)GKI_getpoolbuf (GAP_DATA_POOL_ID)) == NULL) - return (GAP_ERR_CONGESTED); - } - - p_buf->offset = L2CAP_MIN_OFFSET; - p_buf->len = (p_ccb->rem_mtu_size < max_len) ? p_ccb->rem_mtu_size : max_len; - p_buf->event = BT_EVT_TO_BTU_SP_DATA; - - memcpy ((UINT8 *)(p_buf + 1) + p_buf->offset, p_data, p_buf->len); - - *p_len += p_buf->len; - max_len -= p_buf->len; - p_data += p_buf->len; - - GAP_TRACE_EVENT ("GAP_WriteData %d bytes", p_buf->len); - - GKI_enqueue (&p_ccb->tx_queue, p_buf); - } - - if (p_ccb->is_congested) - { - return (BT_PASS); - } - - /* Send the buffer through L2CAP */ -#if (GAP_CONN_POST_EVT_INCLUDED == TRUE) - gap_send_event (gap_handle); -#else - while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL) - { - UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf); - - if (status == L2CAP_DW_CONGESTED) - { - p_ccb->is_congested = TRUE; - break; - } - else if (status != L2CAP_DW_SUCCESS) - return (GAP_ERR_BAD_STATE); - } -#endif - return (BT_PASS); -} - - -/******************************************************************************* -** -** Function GAP_ConnReconfig -** -** Description Applications can call this function to reconfigure the connection. -** -** Parameters: handle - Handle of the connection -** p_cfg - Pointer to new configuration -** -** Returns BT_PASS - config process started -** GAP_ERR_BAD_HANDLE - invalid handle -** -*******************************************************************************/ -UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg) -{ - tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle); - - if (!p_ccb) - return (GAP_ERR_BAD_HANDLE); - - p_ccb->cfg = *p_cfg; - - if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED) - L2CA_CONFIG_REQ (p_ccb->connection_id, p_cfg); - - return (BT_PASS); -} - - - -/******************************************************************************* -** -** Function GAP_ConnSetIdleTimeout -** -** Description Higher layers call this function to set the idle timeout for -** a connection, or for all future connections. The "idle timeout" -** is the amount of time that a connection can remain up with -** no L2CAP channels on it. A timeout of zero means that the -** connection will be torn down immediately when the last channel -** is removed. A timeout of 0xFFFF means no timeout. Values are -** in seconds. -** -** Parameters: handle - Handle of the connection -** timeout - in secs -** 0 = immediate disconnect when last channel is removed -** 0xFFFF = no idle timeout -** -** Returns BT_PASS - config process started -** GAP_ERR_BAD_HANDLE - invalid handle -** -*******************************************************************************/ -UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout) -{ - tGAP_CCB *p_ccb; - - if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL) - return (GAP_ERR_BAD_HANDLE); - - if (L2CA_SetIdleTimeout (p_ccb->connection_id, timeout, FALSE)) - return (BT_PASS); - else - return (GAP_ERR_BAD_HANDLE); -} - - - -/******************************************************************************* -** -** Function GAP_ConnGetRemoteAddr -** -** Description This function is called to get the remote BD address -** of a connection. -** -** Parameters: handle - Handle of the connection returned by GAP_ConnOpen -** -** Returns BT_PASS - closed OK -** GAP_ERR_BAD_HANDLE - invalid handle -** -*******************************************************************************/ -UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle) -{ - tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle); - - GAP_TRACE_EVENT ("GAP_ConnGetRemoteAddr gap_handle = %d", gap_handle); - - if ((p_ccb) && (p_ccb->con_state > GAP_CCB_STATE_LISTENING)) - { - GAP_TRACE_EVENT("GAP_ConnGetRemoteAddr bda :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", \ - p_ccb->rem_dev_address[0],p_ccb->rem_dev_address[1],p_ccb->rem_dev_address[2], - p_ccb->rem_dev_address[3],p_ccb->rem_dev_address[4],p_ccb->rem_dev_address[5]); - return (p_ccb->rem_dev_address); - } - else - { - GAP_TRACE_EVENT ("GAP_ConnGetRemoteAddr return Error "); - return (NULL); - } -} - - -/******************************************************************************* -** -** Function GAP_ConnGetRemMtuSize -** -** Description Returns the remote device's MTU size -** -** Parameters: handle - Handle of the connection -** -** Returns UINT16 - maximum size buffer that can be transmitted to the peer -** -*******************************************************************************/ -UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle) -{ - tGAP_CCB *p_ccb; - - if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL) - return (0); - - return (p_ccb->rem_mtu_size); -} - -/******************************************************************************* -** -** Function GAP_ConnGetL2CAPCid -** -** Description Returns the L2CAP channel id -** -** Parameters: handle - Handle of the connection -** -** Returns UINT16 - The L2CAP channel id -** 0, if error -** -*******************************************************************************/ -UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle) -{ - tGAP_CCB *p_ccb; - - if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL) - return (0); - - return (p_ccb->connection_id); -} - - -/******************************************************************************* -** -** Function gap_connect_ind -** -** Description This function handles an inbound connection indication -** from L2CAP. This is the case where we are acting as a -** server. -** -** Returns void -** -*******************************************************************************/ -static void gap_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id) -{ - UINT16 xx; - tGAP_CCB *p_ccb; - - /* See if we have a CCB listening for the connection */ - for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) - { - if ((p_ccb->con_state == GAP_CCB_STATE_LISTENING) - && (p_ccb->psm == psm) - && ((p_ccb->rem_addr_specified == FALSE) - || (!memcmp (bd_addr, p_ccb->rem_dev_address, BD_ADDR_LEN)))) - break; - } - - if (xx == GAP_MAX_CONNECTIONS) - { - GAP_TRACE_WARNING("*******"); - GAP_TRACE_WARNING("WARNING: GAP Conn Indication for Unexpected Bd Addr...Disconnecting"); - GAP_TRACE_WARNING("*******"); - - /* Disconnect because it is an unexpected connection */ - L2CA_DISCONNECT_REQ (l2cap_cid); - return; - } - - /* Transition to the next appropriate state, waiting for config setup. */ - p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP; - - /* Save the BD Address and Channel ID. */ - memcpy (&p_ccb->rem_dev_address[0], bd_addr, BD_ADDR_LEN); - p_ccb->connection_id = l2cap_cid; - - /* Send response to the L2CAP layer. */ - L2CA_CONNECT_RSP (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK, &p_ccb->ertm_info, &bt_uuid); - - GAP_TRACE_EVENT("GAP_CONN - Rcvd L2CAP conn ind, CID: 0x%x", p_ccb->connection_id); - - /* Send a Configuration Request. */ - L2CA_CONFIG_REQ (l2cap_cid, &p_ccb->cfg); -} - -/******************************************************************************* -** -** Function gap_checks_con_flags -** -** Description This function processes the L2CAP configuration indication -** event. -** -** Returns void -** -*******************************************************************************/ -static void gap_checks_con_flags (tGAP_CCB *p_ccb) -{ - GAP_TRACE_EVENT ("gap_checks_con_flags conn_flags:0x%x, ", p_ccb->con_flags); - /* if all the required con_flags are set, report the OPEN event now */ - if ((p_ccb->con_flags & GAP_CCB_FLAGS_CONN_DONE) == GAP_CCB_FLAGS_CONN_DONE) - { - p_ccb->con_state = GAP_CCB_STATE_CONNECTED; - - p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_OPENED); - } -} - -/******************************************************************************* -** -** Function gap_sec_check_complete -** -** Description The function called when Security Manager finishes -** verification of the service side connection -** -** Returns void -** -*******************************************************************************/ -static void gap_sec_check_complete (BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_data, UINT8 res) -{ - tGAP_CCB *p_ccb = (tGAP_CCB *)p_ref_data; - UNUSED(bd_addr); - UNUSED (transport); - - GAP_TRACE_EVENT ("gap_sec_check_complete conn_state:%d, conn_flags:0x%x, status:%d", - p_ccb->con_state, p_ccb->con_flags, res); - if (p_ccb->con_state == GAP_CCB_STATE_IDLE) - return; - - if (res == BTM_SUCCESS) - { - p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; - gap_checks_con_flags (p_ccb); - } - else - { - /* security failed - disconnect the channel */ - L2CA_DISCONNECT_REQ (p_ccb->connection_id); - } -} - -/******************************************************************************* -** -** Function gap_connect_cfm -** -** Description This function handles the connect confirm events -** from L2CAP. This is the case when we are acting as a -** client and have sent a connect request. -** -** Returns void -** -*******************************************************************************/ -static void gap_connect_cfm (UINT16 l2cap_cid, UINT16 result) -{ - tGAP_CCB *p_ccb; - - /* Find CCB based on CID */ - if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL) - return; - - /* initiate security process, if needed */ - if ( (p_ccb->con_flags & GAP_CCB_FLAGS_SEC_DONE) == 0) - { - btm_sec_mx_access_request (p_ccb->rem_dev_address, p_ccb->psm, TRUE, - 0, 0, &gap_sec_check_complete, p_ccb); - } - - /* If the connection response contains success status, then */ - /* Transition to the next state and startup the timer. */ - if ((result == L2CAP_CONN_OK) && (p_ccb->con_state == GAP_CCB_STATE_CONN_SETUP)) - { - p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP; - - /* Send a Configuration Request. */ - L2CA_CONFIG_REQ (l2cap_cid, &p_ccb->cfg); - } - else - { - /* Tell the user if he has a callback */ - if (p_ccb->p_callback) - (*p_ccb->p_callback) (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED); - - gap_release_ccb (p_ccb); - } -} - -/******************************************************************************* -** -** Function gap_config_ind -** -** Description This function processes the L2CAP configuration indication -** event. -** -** Returns void -** -*******************************************************************************/ -static void gap_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg) -{ - tGAP_CCB *p_ccb; - UINT16 local_mtu_size; - - /* Find CCB based on CID */ - if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL) - return; - - /* Remember the remote MTU size */ - - if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) - { - local_mtu_size = GKI_get_pool_bufsize (p_ccb->ertm_info.user_tx_pool_id) - - sizeof(BT_HDR) - L2CAP_MIN_OFFSET; - } - else - local_mtu_size = L2CAP_MTU_SIZE; - - if ((!p_cfg->mtu_present)||(p_cfg->mtu > local_mtu_size)) - { - p_ccb->rem_mtu_size = local_mtu_size; - } - else - p_ccb->rem_mtu_size = p_cfg->mtu; - - /* For now, always accept configuration from the other side */ - p_cfg->flush_to_present = FALSE; - p_cfg->mtu_present = FALSE; - p_cfg->result = L2CAP_CFG_OK; - p_cfg->fcs_present = FALSE; - - L2CA_CONFIG_RSP (l2cap_cid, p_cfg); - - p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE; - - gap_checks_con_flags (p_ccb); -} - - -/******************************************************************************* -** -** Function gap_config_cfm -** -** Description This function processes the L2CAP configuration confirmation -** event. -** -** Returns void -** -*******************************************************************************/ -static void gap_config_cfm (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg) -{ - tGAP_CCB *p_ccb; - - /* Find CCB based on CID */ - if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL) - return; - - if (p_cfg->result == L2CAP_CFG_OK) - { - p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE; - - - if (p_ccb->cfg.fcr_present) - p_ccb->cfg.fcr.mode = p_cfg->fcr.mode; - else - p_ccb->cfg.fcr.mode = L2CAP_FCR_BASIC_MODE; - - gap_checks_con_flags (p_ccb); - } - else - { - p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED); - gap_release_ccb (p_ccb); - } -} - - -/******************************************************************************* -** -** Function gap_disconnect_ind -** -** Description This function handles a disconnect event from L2CAP. If -** requested to, we ack the disconnect before dropping the CCB -** -** Returns void -** -*******************************************************************************/ -static void gap_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed) -{ - tGAP_CCB *p_ccb; - - GAP_TRACE_EVENT ("GAP_CONN - Rcvd L2CAP disc, CID: 0x%x", l2cap_cid); - - /* Find CCB based on CID */ - if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL) - return; - - if (ack_needed) - L2CA_DISCONNECT_RSP (l2cap_cid); - - p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED); - gap_release_ccb (p_ccb); -} - - -/******************************************************************************* -** -** Function gap_data_ind -** -** Description This function is called when data is received from L2CAP. -** -** Returns void -** -*******************************************************************************/ -static void gap_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg) -{ - tGAP_CCB *p_ccb; - - /* Find CCB based on CID */ - if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL) - { - GKI_freebuf (p_msg); - return; - } - - if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED) - { - GKI_enqueue (&p_ccb->rx_queue, p_msg); - - p_ccb->rx_queue_size += p_msg->len; - /* - GAP_TRACE_EVENT ("gap_data_ind - rx_queue_size=%d, msg len=%d", - p_ccb->rx_queue_size, p_msg->len); - */ - - p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_DATA_AVAIL); - } - else - { - GKI_freebuf (p_msg); - } -} - - -/******************************************************************************* -** -** Function gap_congestion_ind -** -** Description This is a callback function called by L2CAP when -** data L2CAP congestion status changes -** -*******************************************************************************/ -static void gap_congestion_ind (UINT16 lcid, BOOLEAN is_congested) -{ - tGAP_CCB *p_ccb; - UINT16 event; - BT_HDR *p_buf; - UINT8 status; - - GAP_TRACE_EVENT ("GAP_CONN - Rcvd L2CAP Is Congested (%d), CID: 0x%x", - is_congested, lcid); - - /* Find CCB based on CID */ - if ((p_ccb = gap_find_ccb_by_cid (lcid)) == NULL) - return; - - p_ccb->is_congested = is_congested; - - event = (is_congested) ? GAP_EVT_CONN_CONGESTED : GAP_EVT_CONN_UNCONGESTED; - p_ccb->p_callback (p_ccb->gap_handle, event); - - if (!is_congested) - { - while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL) - { - status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf); - - if (status == L2CAP_DW_CONGESTED) - { - p_ccb->is_congested = TRUE; - break; - } - else if (status != L2CAP_DW_SUCCESS) - break; - } - } -} - - -/******************************************************************************* -** -** Function gap_find_ccb_by_cid -** -** Description This function searches the CCB table for an entry with the -** passed CID. -** -** Returns the CCB address, or NULL if not found. -** -*******************************************************************************/ -static tGAP_CCB *gap_find_ccb_by_cid (UINT16 cid) -{ - UINT16 xx; - tGAP_CCB *p_ccb; - - /* Look through each connection control block */ - for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) - { - if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && (p_ccb->connection_id == cid)) - return (p_ccb); - } - - /* If here, not found */ - return (NULL); -} - - -/******************************************************************************* -** -** Function gap_find_ccb_by_handle -** -** Description This function searches the CCB table for an entry with the -** passed handle. -** -** Returns the CCB address, or NULL if not found. -** -*******************************************************************************/ -static tGAP_CCB *gap_find_ccb_by_handle (UINT16 handle) -{ - tGAP_CCB *p_ccb; - - /* Check that handle is valid */ - if (handle < GAP_MAX_CONNECTIONS) - { - p_ccb = &gap_cb.conn.ccb_pool[handle]; - - if (p_ccb->con_state != GAP_CCB_STATE_IDLE) - return (p_ccb); - } - - /* If here, handle points to invalid connection */ - return (NULL); -} - - -/******************************************************************************* -** -** Function gap_allocate_ccb -** -** Description This function allocates a new CCB. -** -** Returns CCB address, or NULL if none available. -** -*******************************************************************************/ -static tGAP_CCB *gap_allocate_ccb (void) -{ - UINT16 xx; - tGAP_CCB *p_ccb; - - /* Look through each connection control block for a free one */ - for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) - { - if (p_ccb->con_state == GAP_CCB_STATE_IDLE) - { - memset (p_ccb, 0, sizeof (tGAP_CCB)); - - p_ccb->gap_handle = xx; - p_ccb->rem_mtu_size = L2CAP_MTU_SIZE; - - return (p_ccb); - } - } - - /* If here, no free CCB found */ - return (NULL); -} - - -/******************************************************************************* -** -** Function gap_release_ccb -** -** Description This function releases a CCB. -** -** Returns void -** -*******************************************************************************/ -static void gap_release_ccb (tGAP_CCB *p_ccb) -{ - UINT16 xx; - UINT16 psm = p_ccb->psm; - UINT8 service_id = p_ccb->service_id; - - /* Drop any buffers we may be holding */ - p_ccb->rx_queue_size = 0; - - while (p_ccb->rx_queue.p_first) - GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue)); - - while (p_ccb->tx_queue.p_first) - GKI_freebuf (GKI_dequeue (&p_ccb->tx_queue)); - - p_ccb->con_state = GAP_CCB_STATE_IDLE; - - /* If no-one else is using the PSM, deregister from L2CAP */ - for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) - { - if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && (p_ccb->psm == psm)) - return; - } - - /* Free the security record for this PSM */ - BTM_SecClrService(service_id); - L2CA_DEREGISTER (psm); -} - -#if (GAP_CONN_POST_EVT_INCLUDED == TRUE) - -/******************************************************************************* -** -** Function gap_send_event -** -** Description Send BT_EVT_TO_GAP_MSG event to BTU task -** -** Returns None -** -*******************************************************************************/ -void gap_send_event (UINT16 gap_handle) -{ - BT_HDR *p_msg; - - if ((p_msg = (BT_HDR*)GKI_getbuf(BT_HDR_SIZE)) != NULL) - { - p_msg->event = BT_EVT_TO_GAP_MSG; - p_msg->len = 0; - p_msg->offset = 0; - p_msg->layer_specific = gap_handle; - - GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_msg); - } - else - { - GAP_TRACE_ERROR("Unable to allocate message buffer for event."); - } -} - -/******************************************************************************* -** -** Function gap_proc_btu_event -** -** Description Event handler for BT_EVT_TO_GAP_MSG event from BTU task -** -** Returns None -** -*******************************************************************************/ -void gap_proc_btu_event(BT_HDR *p_msg) -{ - tGAP_CCB *p_ccb = gap_find_ccb_by_handle (p_msg->layer_specific); - UINT8 status; - BT_HDR *p_buf; - - if (!p_ccb) - { - return; - } - - if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED) - { - return; - } - - if (p_ccb->is_congested) - { - return; - } - - /* Send the buffer through L2CAP */ - - while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL) - { - status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf); - - if (status == L2CAP_DW_CONGESTED) - { - p_ccb->is_congested = TRUE; - break; - } - else if (status != L2CAP_DW_SUCCESS) - break; - } - -} -#endif /* (GAP_CONN_POST_EVT_INCLUDED == TRUE) */ -#endif /* GAP_CONN_INCLUDED */ diff --git a/stack/gap/gap_int.h b/stack/gap/gap_int.h index 295ad831e..40fe96a08 100644 --- a/stack/gap/gap_int.h +++ b/stack/gap/gap_int.h @@ -22,104 +22,11 @@ #include "bt_target.h" #include "gap_api.h" -#include "btm_api.h" #include "gki.h" #include "gatt_api.h" -#if AMP_INCLUDED == TRUE - #include "amp_api.h" -#endif - -#if defined BLE_INCLUDED && BLE_INCLUDED == TRUE - #include "gatt_api.h" -#endif - -#define GAP_MAX_BLOCKS 2 /* Concurrent GAP commands pending at a time*/ -/* There must be a different btm callback for*/ -/* each control block.*/ - - -/* Definitions of limits for inquiries */ -#define GAP_PER_INQ_MIN_MAX_PERIOD BTM_PER_INQ_MIN_MAX_PERIOD -#define GAP_PER_INQ_MAX_MAX_PERIOD BTM_PER_INQ_MAX_MAX_PERIOD -#define GAP_PER_INQ_MIN_MIN_PERIOD BTM_PER_INQ_MIN_MIN_PERIOD -#define GAP_PER_INQ_MAX_MIN_PERIOD BTM_PER_INQ_MAX_MIN_PERIOD -#define GAP_MAX_INQUIRY_LENGTH BTM_MAX_INQUIRY_LENGTH -#define GAP_MIN_INQUIRY_LEN BTM_MIN_INQUIRY_LEN - -/* Define the Generic Access Profile control structure */ -typedef struct -{ - void *p_data; /* Pointer to any data returned in callback */ - tGAP_CALLBACK *gap_cback; /* Pointer to users callback function */ - tGAP_CALLBACK *gap_inq_rslt_cback; /* Used for inquiry results */ - UINT16 event; /* Passed back in the callback */ - UINT8 index; /* Index of this control block and callback */ - BOOLEAN in_use; /* True when structure is allocated */ -} tGAP_INFO; - -/* Define the control block for the FindAddrByName operation (Only 1 active at a time) */ -typedef struct -{ - tGAP_CALLBACK *p_cback; - tBTM_INQ_INFO *p_cur_inq; /* Pointer to the current inquiry database entry */ - tGAP_FINDADDR_RESULTS results; - BOOLEAN in_use; -} tGAP_FINDADDR_CB; - - -/* Define the GAP Connection Control Block. -*/ -typedef struct -{ -#define GAP_CCB_STATE_IDLE 0 -#define GAP_CCB_STATE_LISTENING 1 -#define GAP_CCB_STATE_CONN_SETUP 2 -#define GAP_CCB_STATE_CFG_SETUP 3 -#define GAP_CCB_STATE_WAIT_SEC 4 -#define GAP_CCB_STATE_CONNECTED 5 - UINT8 con_state; - -#define GAP_CCB_FLAGS_IS_ORIG 0x01 -#define GAP_CCB_FLAGS_HIS_CFG_DONE 0x02 -#define GAP_CCB_FLAGS_MY_CFG_DONE 0x04 -#define GAP_CCB_FLAGS_SEC_DONE 0x08 -#define GAP_CCB_FLAGS_CONN_DONE 0x0E - UINT8 con_flags; - - UINT8 service_id; /* Used by BTM */ - UINT16 gap_handle; /* GAP handle */ - UINT16 connection_id; /* L2CAP CID */ - BOOLEAN rem_addr_specified; - UINT8 chan_mode_mask; /* Supported channel modes (FCR) */ - BD_ADDR rem_dev_address; - UINT16 psm; - UINT16 rem_mtu_size; - - BOOLEAN is_congested; - BUFFER_Q tx_queue; /* Queue of buffers waiting to be sent */ - BUFFER_Q rx_queue; /* Queue of buffers waiting to be read */ - - UINT32 rx_queue_size; /* Total data count in rx_queue */ - - tGAP_CONN_CALLBACK *p_callback; /* Users callback function */ - - tL2CAP_CFG_INFO cfg; /* Configuration */ - tL2CAP_ERTM_INFO ertm_info; /* Pools and modes for ertm */ -} tGAP_CCB; - -typedef struct -{ -#if AMP_INCLUDED == TRUE - tAMP_APPL_INFO reg_info; -#else - tL2CAP_APPL_INFO reg_info; /* L2CAP Registration info */ -#endif - tGAP_CCB ccb_pool[GAP_MAX_CONNECTIONS]; -} tGAP_CONN; - #if BLE_INCLUDED == TRUE - #define GAP_MAX_CHAR_NUM 5 +#define GAP_MAX_CHAR_NUM 5 typedef struct { @@ -161,15 +68,7 @@ typedef struct typedef struct { - tGAP_INFO blk[GAP_MAX_BLOCKS]; - tBTM_CMPL_CB *btm_cback[GAP_MAX_BLOCKS]; UINT8 trace_level; - tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */ - tBTM_INQ_INFO *cur_inqptr; - -#if GAP_CONN_INCLUDED == TRUE - tGAP_CONN conn; -#endif /* LE GAP attribute database */ #if BLE_INCLUDED == TRUE @@ -182,50 +81,10 @@ typedef struct } tGAP_CB; -#ifdef __cplusplus -extern "C" { -#endif - -#if GAP_DYNAMIC_MEMORY == FALSE - GAP_API extern tGAP_CB gap_cb; -#else - GAP_API extern tGAP_CB *gap_cb_ptr; -#define gap_cb (*gap_cb_ptr) -#endif - - extern tGAP_INFO *gap_allocate_cb(void); - extern void gap_free_cb(tGAP_INFO *p_cb); - - /* GAP inquiry functions */ - extern void gap_inq_results_cb(tGAP_INQ_RESULTS *p_results, UINT8 *p_eir); - extern UINT16 gap_find_local_addr_by_name (const BD_NAME devname, BD_ADDR bd_addr); - extern void gap_find_addr_inq_cb (tBTM_INQUIRY_CMPL *p); - - extern BOOLEAN gap_is_service_busy (UINT16 request); - extern UINT16 gap_convert_btm_status (tBTM_STATUS btm_status); - - extern void gap_btm_cback0(void *p1); -#if GAP_MAX_BLOCKS > 1 - extern void gap_btm_cback1(void *p1); -#endif -#if GAP_MAX_BLOCKS > 2 - extern void gap_btm_cback2(void *p1); -#endif - -#if (GAP_CONN_INCLUDED == TRUE) - extern void gap_conn_init(void); -#if (GAP_CONN_POST_EVT_INCLUDED == TRUE) - void gap_send_event (UINT16 gap_handle); - void gap_proc_btu_event(BT_HDR *p_msg); -#endif -#endif +extern tGAP_CB gap_cb; #if (BLE_INCLUDED == TRUE) extern void gap_attr_db_init(void); #endif -#ifdef __cplusplus -} -#endif - #endif diff --git a/stack/gap/gap_utils.c b/stack/gap/gap_utils.c deleted file mode 100644 index 3ef893d2b..000000000 --- a/stack/gap/gap_utils.c +++ /dev/null @@ -1,436 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2013 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. - * - ******************************************************************************/ - -#include <string.h> -#include "bt_target.h" -#include "bt_utils.h" -#include "gap_int.h" - -/*****************************************************************************/ -/* G L O B A L GAP D A T A */ -/*****************************************************************************/ -#if GAP_DYNAMIC_MEMORY == FALSE -tGAP_CB gap_cb; -#endif - -/***************************************************************************** -** Callbacks passed to BTM - -** There are different callbacks based on the control block index so that -** more than one command can be pending at a time. -** NOTE: There must be 1 callback for each control block defined -** GAP_MAX_BLOCKS -** -** Also, the inquiry results event has its own callback; Not handled here! -******************************************************************************/ -static void btm_cback(UINT16 index, void *p_data) -{ - tGAP_INFO *p_cb; - tGAP_INQ_CMPL inq_cmpl; - - /* Make sure that the index is valid AND it is in use */ - if (index < GAP_MAX_BLOCKS && gap_cb.blk[index].in_use) - { - p_cb = &gap_cb.blk[index]; - - /* If the callback is non-NULL, call it with the specified event */ - switch (p_cb->event) - { - case GAP_EVT_INQUIRY_COMPLETE: - /* pass the number of results to caller */ - inq_cmpl.num_results = ((tBTM_INQUIRY_CMPL *)p_data)->num_resp; - - inq_cmpl.status = (((tBTM_INQUIRY_CMPL *)p_data)->status == BTM_SUCCESS) ? BT_PASS : GAP_ERR_PROCESSING; - - p_data = &inq_cmpl; - - GAP_TRACE_EVENT(" GAP Inquiry Complete Event (Status 0x%04x, Result(s) %d)", - inq_cmpl.status, inq_cmpl.num_results); - break; - - case GAP_EVT_DISCOVERY_COMPLETE: - if (*((UINT16 *) p_data)) - { - GAP_TRACE_EVENT(" GAP Discovery Complete Event(SDP Result: 0x%04x)", *((UINT16 *) p_data)); - } - else - { - GAP_TRACE_EVENT(" GAP Discovery Successfully Completed"); - } - - break; - - case GAP_EVT_REM_NAME_COMPLETE: - /* override the BTM error code with a GAP error code */ - ((tGAP_REMOTE_DEV_NAME *)p_data)->status = - gap_convert_btm_status ((tBTM_STATUS)((tBTM_REMOTE_DEV_NAME *)p_data)->status); - - GAP_TRACE_EVENT(" GAP Remote Name Complete Event (status 0x%04x)", ((tGAP_REMOTE_DEV_NAME *)p_data)->status); - - break; - }; - - if (p_cb->gap_cback) - p_cb->gap_cback(p_cb->event, p_data); - - /* Deallocate the control block */ - gap_free_cb(p_cb); - } -} - - -/*** Callback functions for BTM_CMPL_CB ***/ -void gap_btm_cback0(void *p1) -{ - btm_cback(0, p1); -} - -#if GAP_MAX_BLOCKS > 1 -void gap_btm_cback1(void *p1) -{ - btm_cback(1, p1); -} -#endif -#if GAP_MAX_BLOCKS > 2 -void gap_btm_cback2(void *p1) -{ - btm_cback(2, p1); -} -#endif - -/* There is only one instance of this because only 1 inquiry can be active at a time */ -void gap_inq_results_cb(tBTM_INQ_RESULTS *p_results, UINT8 *p_eir) -{ - tGAP_INFO *p_cb; - UINT8 index; - UNUSED(p_eir); - - GAP_TRACE_EVENT ("GAP Inquiry Results Callback (bdaddr [%02x%02x%02x%02x%02x%02x])", - p_results->remote_bd_addr[0], p_results->remote_bd_addr[1], - p_results->remote_bd_addr[2], p_results->remote_bd_addr[3], - p_results->remote_bd_addr[4], p_results->remote_bd_addr[5]); - GAP_TRACE_EVENT (" (COD [%02x%02x%02x], clkoff 0x%04x)", - p_results->dev_class[0], p_results->dev_class[1], p_results->dev_class[2], - p_results->clock_offset); - - /* Find the control block which has an Inquiry Active and call its results callback */ - for (index = 0, p_cb = &gap_cb.blk[0]; index < GAP_MAX_BLOCKS; index++, p_cb++) - { - /* Look for the control block that is using inquiry */ - if (p_cb->in_use && (p_cb->event == GAP_EVT_INQUIRY_COMPLETE)) - { - /* Notify the higher layer if they care */ - if (p_cb->gap_inq_rslt_cback) - p_cb->gap_inq_rslt_cback (GAP_EVT_INQUIRY_RESULTS, (tGAP_INQ_RESULTS *)p_results); - } - } -} - - -/******************************************************************************* -** -** Function gap_find_addr_name_cb -** -** Description Processes the remote name request event when the Find Addr by Name -** request is active. The following procedure takes place: -** 1. Check the resulting name (If return status is ok) -** 2. If name matches requested name, we're done, call the appl's callback -** with the BD ADDR. -** 3. Otherwise get the next BD ADDR out of the inquiry database and intiate -** another remote name request. -** 4. If there are no more BD ADDRs, then call the appl's callback with a FAIL -** status. -** -** Returns void -** -*******************************************************************************/ -void gap_find_addr_name_cb (tBTM_REMOTE_DEV_NAME *p) -{ - tGAP_FINDADDR_CB *p_cb = &gap_cb.findaddr_cb; - tGAP_FINDADDR_RESULTS *p_result = &p_cb->results; - - if (p_cb->in_use) - { - if (p->status == BTM_SUCCESS) - { - GAP_TRACE_EVENT(" GAP: FindAddrByName Rem Name Cmpl Evt (Status 0x%04x, Name [%s])", - p->status, p->remote_bd_name); - - /* See if the returned name matches the desired name; if not initiate another search */ - if (!strncmp ((char *)p_result->devname, (char *) p->remote_bd_name, strlen ((char *) p_result->devname))) - { - /* We found the device! Copy it into the return structure */ - memcpy (p_result->bd_addr, p_cb->p_cur_inq->results.remote_bd_addr, BD_ADDR_LEN); - p_result->status = BT_PASS; - } - else /* The name doesn't match so initiate another search */ - { - /* Get the device address of the next database entry */ - if ((p_cb->p_cur_inq = BTM_InqDbNext(p_cb->p_cur_inq)) != NULL) - { - if ((BTM_ReadRemoteDeviceName (p_cb->p_cur_inq->results.remote_bd_addr, - (tBTM_CMPL_CB *) gap_find_addr_name_cb, BT_TRANSPORT_BR_EDR)) == BTM_CMD_STARTED) - return; /* This routine will get called again with the next results */ - else - p_result->status = gap_convert_btm_status ((tBTM_STATUS) p->status); - } - else - p_result->status = GAP_EOINQDB; /* No inquiry results; we're done! */ - } - } - else - { - GAP_TRACE_EVENT(" GAP: FindAddrByName Rem Name Cmpl Evt (Status 0x%04x)", p->status); - p_result->status = gap_convert_btm_status ((tBTM_STATUS) p->status); - } - - /* If this code is reached, the process has completed so call the appl's callback with results */ - if (p_cb->p_cback) - p_cb->p_cback (GAP_EVT_FIND_ADDR_COMPLETE, (tGAP_FINDADDR_RESULTS *) p_result); - - /* Clear out the control block */ - p_cb->in_use = FALSE; - p_cb->p_cback = (tGAP_CALLBACK *) NULL; - } -} - -/******************************************************************************* -** -** Function gap_find_addr_inq_cb -** -** Description Processes the inquiry complete event when the Find Addr by Name -** request is active. This callback performs one of the two following -** steps: -** 1. If the remote name is retrieved automatically, the DB is searched -** immediately, and the results are returned in the appls callback. -** -** 2. If remote name is not automatic, retrieve the first BTM INQ -** database entry and initiate a remote name request. -** -** Returns void -** -*******************************************************************************/ -void gap_find_addr_inq_cb (tBTM_INQUIRY_CMPL *p) -{ - tGAP_FINDADDR_CB *p_cb = &gap_cb.findaddr_cb; - tGAP_FINDADDR_RESULTS *p_result = &p_cb->results; - - if (p_cb->in_use) - { - - GAP_TRACE_EVENT(" GAP: FindAddrByName Inq Cmpl Evt (Status 0x%04x, Result(s) %d)", - p->status, p->num_resp); - - if (p->status == BTM_SUCCESS) - { - /* Step 1: If automatically retrieving remote names then search the local database */ - if ((p_result->status = gap_find_local_addr_by_name (p_result->devname, p_result->bd_addr)) == GAP_NO_DATA_AVAIL) - { - /* Step 2: The name is not stored automatically, so a search of all devices needs to - * be initiated. - */ - if ((p_cb->p_cur_inq = BTM_InqDbFirst()) != NULL) - { - if ((BTM_ReadRemoteDeviceName (p_cb->p_cur_inq->results.remote_bd_addr, - (tBTM_CMPL_CB *) gap_find_addr_name_cb, BT_TRANSPORT_BR_EDR)) == BTM_CMD_STARTED) - return; /* Wait for the response in gap_find_addr_name_cb() */ - else - p_result->status = gap_convert_btm_status (p->status); - } - else - p_result->status = GAP_EOINQDB; /* No inquiry results; we're done! */ - } - } - else - p_result->status = gap_convert_btm_status (p->status); - - /* If this code is reached, the process has completed so call the appl's callback with results */ - if (p_cb->p_cback) - p_cb->p_cback (GAP_EVT_FIND_ADDR_COMPLETE, (tGAP_FINDADDR_RESULTS *) p_result); - - /* Clear out the control block */ - p_cb->in_use = FALSE; - p_cb->p_cback = (tGAP_CALLBACK *) NULL; - } -} - -/******************************************************************************* -** -** Function gap_find_local_addr_by_name -** -** Description Searches through the internal inquiry database for a device -** that has the same name as the one passed in. If found, the -** device address is filled in. -** -** NOTE: It only searches up to the first BTM_MAX_REM_BD_NAME_LEN -** bytes because the inquiry database uses tBTM_BD_NAME. -** -** Returns BT_PASS if the name was found and the device address is filled in -** GAP_EOINQDB if the name was not found in the database -** GAP_NO_DATA_AVAIL if the name is not saved with the inquiry -** -*******************************************************************************/ -UINT16 gap_find_local_addr_by_name (const tBTM_BD_NAME devname, BD_ADDR bd_addr) -{ - -/* If the remote name is retrieved automatically during an inquiry search the local db */ -#if (BTM_INQ_GET_REMOTE_NAME == TRUE) - tBTM_INQ_INFO *p_result; - - p_result = BTM_InqDbFirst(); - - while (p_result) - { - /* Check the entry for a device name match */ - if (!strncmp ((char *)devname, (char *)p_result->remote_name, BTM_MAX_REM_BD_NAME_LEN)) - { - memcpy (bd_addr, p_result->results.remote_bd_addr, BD_ADDR_LEN); - return (BT_PASS); - } - else - p_result = BTM_InqDbNext(p_result); - }; - - return (GAP_EOINQDB); -#else - UNUSED(devname); - UNUSED(bd_addr); - /* No data available because we are not automatically saving the data */ - return (GAP_NO_DATA_AVAIL); -#endif -} - - -/******************************************************************************* -** -** Function gap_allocate_cb -** -** Description Look through the GAP Control Blocks for a free one. -** -** Returns Pointer to the control block or NULL if not found -** -*******************************************************************************/ -tGAP_INFO *gap_allocate_cb (void) -{ - tGAP_INFO *p_cb = &gap_cb.blk[0]; - UINT8 x; - - for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++) - { - if (!p_cb->in_use) - { - memset (p_cb, 0, sizeof (tGAP_INFO)); - - p_cb->in_use = TRUE; - p_cb->index = x; - p_cb->p_data = (void *)NULL; - return (p_cb); - } - } - - /* If here, no free control blocks found */ - return (NULL); -} - - -/******************************************************************************* -** -** Function gap_free_cb -** -** Description Release GAP control block. -** -** Returns Pointer to the control block or NULL if not found -** -*******************************************************************************/ -void gap_free_cb (tGAP_INFO *p_cb) -{ - if (p_cb) - { - p_cb->gap_cback = NULL; - p_cb->in_use = FALSE; - } -} - - -/******************************************************************************* -** -** Function gap_is_service_busy -** -** Description Look through the GAP Control Blocks that are in use -** and check to see if the event waiting for is the command -** requested. -** -** Returns TRUE if already in use -** FALSE if not busy -** -*******************************************************************************/ -BOOLEAN gap_is_service_busy (UINT16 request) -{ - tGAP_INFO *p_cb = &gap_cb.blk[0]; - UINT8 x; - - for (x = 0; x < GAP_MAX_BLOCKS; x++, p_cb++) - { - if (p_cb->in_use && p_cb->event == request) - return (TRUE); - } - - /* If here, service is not busy */ - return (FALSE); -} - - -/******************************************************************************* -** -** Function gap_convert_btm_status -** -** Description Converts a BTM error status into a GAP error status -** -** -** Returns GAP_UNKNOWN_BTM_STATUS is returned if not recognized -** -*******************************************************************************/ -UINT16 gap_convert_btm_status (tBTM_STATUS btm_status) -{ - switch (btm_status) - { - case BTM_SUCCESS: - return (BT_PASS); - - case BTM_CMD_STARTED: - return (GAP_CMD_INITIATED); - - case BTM_BUSY: - return (GAP_ERR_BUSY); - - case BTM_MODE_UNSUPPORTED: - case BTM_ILLEGAL_VALUE: - return (GAP_ERR_ILL_PARM); - - case BTM_WRONG_MODE: - return (GAP_DEVICE_NOT_UP); - - case BTM_UNKNOWN_ADDR: - return (GAP_BAD_BD_ADDR); - - case BTM_DEVICE_TIMEOUT: - return (GAP_ERR_TIMEOUT); - - default: - return (GAP_ERR_PROCESSING); - } -} diff --git a/stack/gatt/gatt_api.c b/stack/gatt/gatt_api.c index 6683cb6cd..d7b06e40b 100644 --- a/stack/gatt/gatt_api.c +++ b/stack/gatt/gatt_api.c @@ -1323,7 +1323,7 @@ void GATT_Deregister (tGATT_IF gatt_if) ** ** Parameter gatt_if: applicaiton interface. ** -** Returns 0 for error, otherwise the index of the client registered with GATT +** Returns None. ** *******************************************************************************/ void GATT_StartIf (tGATT_IF gatt_if) @@ -1338,7 +1338,6 @@ void GATT_StartIf (tGATT_IF gatt_if) GATT_TRACE_API ("GATT_StartIf gatt_if=%d", gatt_if); if ((p_reg = gatt_get_regcb(gatt_if)) != NULL) { - p_reg = &gatt_cb.cl_rcb[gatt_if - 1]; start_idx = 0; while (gatt_find_the_connected_bda(start_idx, bda, &found_idx, &transport)) { @@ -1602,7 +1601,6 @@ BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, UINT16 *p_c BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr) { tGATT_REG *p_reg; - BOOLEAN status = TRUE; GATT_TRACE_API ("GATT_Listen gatt_if=%d", gatt_if); @@ -1615,7 +1613,7 @@ BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr) if (bd_addr != NULL) { - status = gatt_update_auto_connect_dev(gatt_if,start, bd_addr, FALSE); + gatt_update_auto_connect_dev(gatt_if,start, bd_addr, FALSE); } else { diff --git a/stack/gatt/gatt_attr.c b/stack/gatt/gatt_attr.c index 8773036bc..fe3fcc422 100644 --- a/stack/gatt/gatt_attr.c +++ b/stack/gatt/gatt_attr.c @@ -98,7 +98,7 @@ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_conn_id(UINT16 conn_id) return p_clcb; } - return p_clcb; + return NULL; } /******************************************************************************* @@ -122,7 +122,7 @@ static tGATT_PROFILE_CLCB *gatt_profile_find_clcb_by_bd_addr(BD_ADDR bda, tBT_TR return p_clcb; } - return p_clcb; + return NULL; } /******************************************************************************* @@ -151,7 +151,10 @@ tGATT_PROFILE_CLCB *gatt_profile_clcb_alloc (UINT16 conn_id, BD_ADDR bda, tBT_TR break; } } - return p_clcb; + if(i_clcb < GATT_MAX_APPS) + return p_clcb; + + return NULL; } /******************************************************************************* diff --git a/stack/gatt/gatt_auth.c b/stack/gatt/gatt_auth.c index 10cf76e88..ae5214592 100644 --- a/stack/gatt/gatt_auth.c +++ b/stack/gatt/gatt_auth.c @@ -192,7 +192,7 @@ void gatt_enc_cmpl_cback(BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_d gatt_sec_check_complete(status , p_buf->p_clcb, p_tcb->sec_act); GKI_freebuf(p_buf); /* start all other pending operation in queue */ - count = p_tcb->pending_enc_clcb.count; + count = GKI_queue_length(&p_tcb->pending_enc_clcb); for (; count > 0; count --) { if ((p_buf = (tGATT_PENDING_ENC_CLCB *)GKI_dequeue (&p_tcb->pending_enc_clcb)) != NULL) @@ -246,7 +246,7 @@ void gatt_notify_enc_cmpl(BD_ADDR bd_addr) { gatt_set_sec_act(p_tcb, GATT_SEC_NONE); - count = p_tcb->pending_enc_clcb.count; + count = GKI_queue_length(&p_tcb->pending_enc_clcb); for (; count > 0; count --) { diff --git a/stack/gatt/gatt_db.c b/stack/gatt/gatt_db.c index b7887c975..ef4f468b6 100644 --- a/stack/gatt/gatt_db.c +++ b/stack/gatt/gatt_db.c @@ -62,6 +62,8 @@ static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code, BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service, BOOLEAN is_pri, UINT16 s_hdl, UINT16 num_handle) { + GKI_init_q(&p_db->svc_buffer); + if (!allocate_svc_db_buf(p_db)) { GATT_TRACE_ERROR("gatts_init_service_db failed, no resources"); @@ -214,7 +216,6 @@ static tGATT_STATUS read_attr_value (void *p_attr, UINT16 len = 0, uuid16 = 0; UINT8 *p = *p_data; tGATT_STATUS status; - UINT16 read_long_uuid=0; tGATT_ATTR16 *p_attr16 = (tGATT_ATTR16 *)p_attr; GATT_TRACE_DEBUG("read_attr_value uuid=0x%04x perm=0x%0x sec_flag=0x%x offset=%d read_long=%d", @@ -234,12 +235,6 @@ static tGATT_STATUS read_attr_value (void *p_attr, status = GATT_NO_RESOURCES; - if (read_long && - (uuid16 == GATT_UUID_CHAR_DESCRIPTION || uuid16 == GATT_UUID_CHAR_AGG_FORMAT)) - { - read_long_uuid = p_attr16->uuid; - } - if (uuid16 == GATT_UUID_PRI_SERVICE || uuid16 == GATT_UUID_SEC_SERVICE) { len = p_attr16->p_value->uuid.len; diff --git a/stack/gatt/gatt_int.h b/stack/gatt/gatt_int.h index d49c6e117..ccdb14819 100644 --- a/stack/gatt/gatt_int.h +++ b/stack/gatt/gatt_int.h @@ -533,14 +533,14 @@ extern "C" { /* Global GATT data */ #if GATT_DYNAMIC_MEMORY == FALSE -GATT_API extern tGATT_CB gatt_cb; +extern tGATT_CB gatt_cb; #else -GATT_API extern tGATT_CB *gatt_cb_ptr; +extern tGATT_CB *gatt_cb_ptr; #define gatt_cb (*gatt_cb_ptr) #endif #if GATT_CONFORMANCE_TESTING == TRUE -GATT_API extern void gatt_set_err_rsp(BOOLEAN enable, UINT8 req_op_code, UINT8 err_status); +extern void gatt_set_err_rsp(BOOLEAN enable, UINT8 req_op_code, UINT8 err_status); #endif #ifdef __cplusplus @@ -549,6 +549,7 @@ GATT_API extern void gatt_set_err_rsp(BOOLEAN enable, UINT8 req_op_code, UINT8 e /* internal functions */ extern void gatt_init (void); +extern void gatt_free(void); /* from gatt_main.c */ extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb); @@ -709,5 +710,3 @@ extern tBT_UUID * gatts_get_service_uuid (tGATT_SVC_DB *p_db); extern void gatt_reset_bgdev_list(void); #endif - - diff --git a/stack/gatt/gatt_main.c b/stack/gatt/gatt_main.c index 54951b2bc..f0a0229ec 100644 --- a/stack/gatt/gatt_main.c +++ b/stack/gatt/gatt_main.c @@ -102,6 +102,8 @@ void gatt_init (void) #endif gatt_cb.def_mtu_size = GATT_DEF_BLE_MTU_SIZE; GKI_init_q (&gatt_cb.sign_op_queue); + GKI_init_q (&gatt_cb.srv_chg_clt_q); + GKI_init_q (&gatt_cb.pending_new_srv_start_q); /* First, register fixed L2CAP channel for ATT over BLE */ fixed_reg.fixed_chnl_opts.mode = L2CAP_FCR_BASIC_MODE; fixed_reg.fixed_chnl_opts.max_transmit = 0xFF; @@ -134,6 +136,24 @@ void gatt_init (void) } +/******************************************************************************* +** +** Function gatt_free +** +** Description This function frees resources used by the GATT profile. +** +** Returns void +** +*******************************************************************************/ +void gatt_free(void) +{ + int i; + GATT_TRACE_DEBUG("gatt_free()"); + for (i = 0; i < GATT_MAX_SR_PROFILES; i++) + { + gatt_free_hdl_buffer(&gatt_cb.hdl_list[i]); + } +} /******************************************************************************* ** diff --git a/stack/gatt/gatt_sr.c b/stack/gatt/gatt_sr.c index dafaf30bd..ecf2427b2 100755 --- a/stack/gatt/gatt_sr.c +++ b/stack/gatt/gatt_sr.c @@ -106,7 +106,7 @@ void gatt_dequeue_sr_cmd (tGATT_TCB *p_tcb) GKI_freebuf (p_tcb->sr_cmd.p_rsp_msg); } - while (p_tcb->sr_cmd.multi_rsp_q.p_first) + while (GKI_getfirst(&p_tcb->sr_cmd.multi_rsp_q)) GKI_freebuf (GKI_dequeue (&p_tcb->sr_cmd.multi_rsp_q)); memset( &p_tcb->sr_cmd, 0, sizeof(tGATT_SR_CMD)); } @@ -145,9 +145,9 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status, if (status == GATT_SUCCESS) { GATT_TRACE_DEBUG ("Multi read count=%d num_hdls=%d", - p_cmd->multi_rsp_q.count, p_cmd->multi_req.num_handles); + GKI_queue_length(&p_cmd->multi_rsp_q), p_cmd->multi_req.num_handles); /* Wait till we get all the responses */ - if (p_cmd->multi_rsp_q.count == p_cmd->multi_req.num_handles) + if (GKI_queue_length(&p_cmd->multi_rsp_q) == p_cmd->multi_req.num_handles) { len = sizeof(BT_HDR) + L2CAP_MIN_OFFSET + mtu; if ((p_buf = (BT_HDR *)GKI_getbuf(len)) == NULL) diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.c index 0e841a92c..11d8dff71 100644 --- a/stack/gatt/gatt_utils.c +++ b/stack/gatt/gatt_utils.c @@ -93,7 +93,7 @@ void gatt_free_pending_ind(tGATT_TCB *p_tcb) { GATT_TRACE_DEBUG("gatt_free_pending_ind"); /* release all queued indications */ - while (p_tcb->pending_ind_q.p_first) + while (!GKI_queue_is_empty(&p_tcb->pending_ind_q)) GKI_freebuf (GKI_dequeue (&p_tcb->pending_ind_q)); } @@ -110,7 +110,7 @@ void gatt_free_pending_enc_queue(tGATT_TCB *p_tcb) { GATT_TRACE_DEBUG("gatt_free_pending_enc_queue"); /* release all queued indications */ - while (p_tcb->pending_enc_clcb.p_first) + while (!GKI_queue_is_empty(&p_tcb->pending_enc_clcb)) GKI_freebuf (GKI_dequeue (&p_tcb->pending_enc_clcb)); } @@ -373,7 +373,7 @@ void gatt_free_hdl_buffer(tGATT_HDL_LIST_ELEM *p) if (p) { - while (p->svc_db.svc_buffer.p_first) + while (!GKI_queue_is_empty(&p->svc_db.svc_buffer)) GKI_freebuf (GKI_dequeue (&p->svc_db.svc_buffer)); memset(p, 0, sizeof(tGATT_HDL_LIST_ELEM)); } @@ -397,7 +397,7 @@ void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id) { if (memcmp(p_app_id, &p_elem->asgn_range.app_uuid128, sizeof(tBT_UUID)) == 0) { - while (p_elem->svc_db.svc_buffer.p_first) + while (!GKI_queue_is_empty(&p_elem->svc_db.svc_buffer)) GKI_freebuf (GKI_dequeue (&p_elem->svc_db.svc_buffer)); p_elem->svc_db.mem_free = 0; @@ -1363,7 +1363,7 @@ UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list ) p_sreg->e_hdl = p_list->asgn_range.e_handle; p_sreg->p_db = &p_list->svc_db; - GATT_TRACE_DEBUG ("total GKI buffer in db [%d]",p_sreg->p_db->svc_buffer.count); + GATT_TRACE_DEBUG ("total GKI buffer in db [%d]",GKI_queue_length(&p_sreg->p_db->svc_buffer)); break; } } @@ -1562,15 +1562,20 @@ tGATT_REG *gatt_get_regcb (tGATT_IF gatt_if) UINT8 ii = (UINT8)gatt_if; tGATT_REG *p_reg = NULL; - if (ii) - { - ii--; /* convert from one based to zero based */ - p_reg = &gatt_cb.cl_rcb[ii]; - if ( (ii < GATT_MAX_APPS) && (p_reg->in_use) ) - return(p_reg); + if (ii < 1 || ii > GATT_MAX_APPS) { + GATT_TRACE_WARNING("gatt_if out of range [ = %d]", ii); + return NULL; } - return NULL; + // Index for cl_rcb is always 1 less than gatt_if. + p_reg = &gatt_cb.cl_rcb[ii - 1]; + + if (!p_reg->in_use) { + GATT_TRACE_WARNING("gatt_if found but not in use."); + return NULL; + } + + return p_reg; } diff --git a/stack/hcic/hciblecmds.c b/stack/hcic/hciblecmds.c index 860fb7a10..fa46decaa 100644 --- a/stack/hcic/hciblecmds.c +++ b/stack/hcic/hciblecmds.c @@ -35,68 +35,6 @@ #if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) -BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_EVENT_MASK)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_EVENT_MASK; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_BLE_SET_EVENT_MASK); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_EVENT_MASK); - ARRAY8_TO_STREAM (pp, event_mask); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - - -BOOLEAN btsnd_hcic_ble_read_buffer_size (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_BLE_READ_BUFFER_SIZE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_BLE_READ_LOCAL_SPT_FEAT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]) { BT_HDR *p; @@ -391,26 +329,6 @@ BOOLEAN btsnd_hcic_ble_create_conn_cancel (void) return (TRUE); } -BOOLEAN btsnd_hcic_ble_read_white_list_size (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_BLE_READ_WHITE_LIST_SIZE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_ble_clear_white_list (void) { BT_HDR *p; @@ -707,26 +625,6 @@ BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle) return (TRUE); } -BOOLEAN btsnd_hcic_ble_read_supported_states (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_BLE_READ_SUPPORTED_STATES); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq) { BT_HDR *p; @@ -806,35 +704,13 @@ BOOLEAN btsnd_hcic_ble_read_host_supported (void) p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; p->offset = 0; - UINT16_TO_STREAM (pp, HCI_READ_LE_HOST_SUPPORTED); + UINT16_TO_STREAM (pp, HCI_READ_LE_HOST_SUPPORT); UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); return (TRUE); } -BOOLEAN btsnd_hcic_ble_write_host_supported (UINT8 le_host_spt, UINT8 simul_le_host_spt) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_LE_HOST_SUPPORTED); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED); - UINT8_TO_STREAM (pp, le_host_spt); - UINT8_TO_STREAM (pp, simul_le_host_spt); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE) BOOLEAN btsnd_hcic_ble_rc_param_req_reply( UINT16 handle, diff --git a/stack/hcic/hcicmds.c b/stack/hcic/hcicmds.c index a530d2aed..13d755895 100644 --- a/stack/hcic/hcicmds.c +++ b/stack/hcic/hcicmds.c @@ -24,6 +24,7 @@ ******************************************************************************/ #include "bt_target.h" +#include "btcore/include/counter.h" #include "gki.h" #include "hcidefs.h" #include "hcimsgs.h" @@ -33,12 +34,7 @@ #include <stddef.h> #include <string.h> -#if defined (LMP_TEST) -#include <script.h> -#define btu_hcif_send_cmd(p1, p2) HCI_CMD_TO_LOWER((p2)) -#else #include "btm_int.h" /* Included for UIPC_* macro definitions */ -#endif BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration, UINT8 response_cnt) { @@ -163,12 +159,7 @@ BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types, #if !defined (BT_10A) UINT8_TO_STREAM (pp, allow_switch); #endif -/* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */ -#if (!defined (LMP_TEST) && !defined(BTISE)) btm_acl_paging (p, dest); -#else - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); -#endif return (TRUE); } @@ -191,12 +182,6 @@ BOOLEAN btsnd_hcic_disconnect (UINT16 handle, UINT8 reason) UINT8_TO_STREAM (pp, reason); btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); -/* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */ -#if (!defined (LMP_TEST) && !defined(BTISE)) -// btla-specific ++ - // btm_acl_set_discing(TRUE); -// btla-specific -- -#endif return (TRUE); } @@ -265,6 +250,8 @@ BOOLEAN btsnd_hcic_accept_conn (BD_ADDR dest, UINT8 role) BDADDR_TO_STREAM (pp, dest); UINT8_TO_STREAM (pp, role); + counter_add("hci.conn.accept", 1); + btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); return (TRUE); } @@ -288,6 +275,8 @@ BOOLEAN btsnd_hcic_reject_conn (BD_ADDR dest, UINT8 reason) BDADDR_TO_STREAM (pp, dest); UINT8_TO_STREAM (pp, reason); + counter_add("hci.conn.reject", 1); + btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); return (TRUE); } @@ -459,50 +448,6 @@ BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable) return (TRUE); } -BOOLEAN btsnd_hcic_change_link_key (UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_CHANGE_CONN_LINK_KEY); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_master_link_key (BOOLEAN key_flag) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_MASTER_LINK_KEY)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_MASTER_LINK_KEY; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_MASTER_LINK_KEY); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_MASTER_LINK_KEY); - - UINT8_TO_STREAM (pp, key_flag); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, UINT8 page_scan_rep_mode, UINT8 page_scan_mode, UINT16 clock_offset) { @@ -525,12 +470,7 @@ BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, UINT8 page_scan_rep_mode, UINT8_TO_STREAM (pp, page_scan_mode); UINT16_TO_STREAM (pp, clock_offset); -/* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */ -#if (!defined (LMP_TEST) && !defined(BTISE)) btm_acl_paging (p, bd_addr); -#else - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); -#endif return (TRUE); } @@ -903,28 +843,6 @@ BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags, UINT8 service_type, return (TRUE); } -BOOLEAN btsnd_hcic_role_discovery (UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_ROLE_DISCOVERY); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role) { BT_HDR *p; @@ -948,28 +866,6 @@ BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role) return (TRUE); } -BOOLEAN btsnd_hcic_read_policy_set (UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_POLICY_SETTINGS); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_policy_set (UINT16 handle, UINT16 settings) { BT_HDR *p; @@ -992,26 +888,6 @@ BOOLEAN btsnd_hcic_write_policy_set (UINT16 handle, UINT16 settings) return (TRUE); } -BOOLEAN btsnd_hcic_read_def_policy_set (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_DEF_POLICY_SET)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_DEF_POLICY_SET; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_DEF_POLICY_SETTINGS); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_DEF_POLICY_SET); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_def_policy_set (UINT16 settings) { BT_HDR *p; @@ -1033,108 +909,6 @@ BOOLEAN btsnd_hcic_write_def_policy_set (UINT16 settings) return (TRUE); } -BOOLEAN btsnd_hcic_flow_specification(UINT16 handle, UINT8 flags, UINT8 flow_direct, - UINT8 service_type, UINT32 token_rate, - UINT32 token_bucket_size, UINT32 peak, - UINT32 latency) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_FLOW_SPEC)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_FLOW_SPEC; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_FLOW_SPECIFICATION); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_FLOW_SPEC); - - UINT16_TO_STREAM (pp, handle); - UINT8_TO_STREAM (pp, flags); - UINT8_TO_STREAM (pp, flow_direct); - UINT8_TO_STREAM (pp, service_type); - UINT32_TO_STREAM (pp, token_rate); - UINT32_TO_STREAM (pp, token_bucket_size); - UINT32_TO_STREAM (pp, peak); - UINT32_TO_STREAM (pp, latency); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_set_event_mask(UINT8 local_controller_id, BT_EVENT_MASK event_mask) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_EVENT_MASK)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_EVENT_MASK; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_SET_EVENT_MASK); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_EVENT_MASK); - ARRAY8_TO_STREAM (pp, event_mask); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_set_event_mask_page_2 (UINT8 local_controller_id, BT_EVENT_MASK event_mask) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_EVENT_MASK_PAGE_2)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_EVENT_MASK_PAGE_2; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_SET_EVENT_MASK_PAGE_2); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_EVENT_MASK_PAGE_2); - ARRAY8_TO_STREAM (pp, event_mask); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_reset (UINT8 local_controller_id) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RESET)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RESET; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_RESET); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_RESET); - - btu_hcif_send_cmd (local_controller_id, p); -/* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */ -#if (!defined (LMP_TEST) && !defined(BTISE)) - if (local_controller_id == LOCAL_BR_EDR_CONTROLLER_ID) - { - btm_acl_reset_paging (); - btm_acl_set_discing (FALSE); - } -#endif - return (TRUE); -} - BOOLEAN btsnd_hcic_set_event_filter (UINT8 filt_type, UINT8 filt_cond_type, UINT8 *filt_cond, UINT8 filt_cond_len) { @@ -1191,47 +965,6 @@ BOOLEAN btsnd_hcic_set_event_filter (UINT8 filt_type, UINT8 filt_cond_type, return (TRUE); } -BOOLEAN btsnd_hcic_flush (UINT8 local_controller_id, UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - UINT16_TO_STREAM (pp, HCI_FLUSH); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_pin_type (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_PIN_TYPE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_pin_type (UINT8 type) { BT_HDR *p; @@ -1254,83 +987,6 @@ BOOLEAN btsnd_hcic_write_pin_type (UINT8 type) return (TRUE); } -BOOLEAN btsnd_hcic_new_unit_key (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_NEW_UNIT_KEY)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_NEW_UNIT_KEY; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_CREATE_NEW_UNIT_KEY); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_NEW_UNIT_KEY); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_stored_key (BD_ADDR bd_addr, BOOLEAN read_all_flag) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_STORED_KEY)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_STORED_KEY; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_STORED_LINK_KEY); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_STORED_KEY); - - BDADDR_TO_STREAM (pp, bd_addr); - UINT8_TO_STREAM (pp, read_all_flag); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_stored_key (UINT8 num_keys, BD_ADDR *bd_addr, - LINK_KEY *link_key) -{ - BT_HDR *p; - UINT8 *pp; - int j; - - if ((p = HCI_GET_CMD_BUF(1 + (num_keys * (BD_ADDR_LEN + LINK_KEY_LEN)))) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - - p->len = HCIC_PREAMBLE_SIZE + 1 + (num_keys * (BD_ADDR_LEN + LINK_KEY_LEN)); - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_STORED_LINK_KEY); - UINT8_TO_STREAM (pp, p->len - HCIC_PREAMBLE_SIZE); - - if(num_keys > HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD) - num_keys = HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD; - - UINT8_TO_STREAM (pp, num_keys); - - for (j = 0; j < num_keys; j++) - { - BDADDR_TO_STREAM (pp, bd_addr[j]); - ARRAY16_TO_STREAM (pp, link_key[j]); - } - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag) { BT_HDR *p; @@ -1401,68 +1057,6 @@ BOOLEAN btsnd_hcic_read_name (void) return (TRUE); } -BOOLEAN btsnd_hcic_read_conn_acc_tout (UINT8 local_controller_id) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_CONN_ACCEPT_TOUT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_conn_acc_tout (UINT8 local_controller_id, UINT16 timeout) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_CONN_ACCEPT_TOUT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM2); - - UINT16_TO_STREAM (pp, timeout); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_page_tout (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_PAGE_TOUT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_page_tout (UINT16 timeout) { BT_HDR *p; @@ -1485,26 +1079,6 @@ BOOLEAN btsnd_hcic_write_page_tout (UINT16 timeout) return (TRUE); } -BOOLEAN btsnd_hcic_read_scan_enable (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_SCAN_ENABLE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_scan_enable (UINT8 flag) { BT_HDR *p; @@ -1527,26 +1101,6 @@ BOOLEAN btsnd_hcic_write_scan_enable (UINT8 flag) return (TRUE); } -BOOLEAN btsnd_hcic_read_pagescan_cfg(void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_CFG); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval, UINT16 window) { BT_HDR *p; @@ -1570,26 +1124,6 @@ BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval, UINT16 window) return (TRUE); } -BOOLEAN btsnd_hcic_read_inqscan_cfg(void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_INQUIRYSCAN_CFG); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window) { BT_HDR *p; @@ -1613,26 +1147,6 @@ BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window) return (TRUE); } -BOOLEAN btsnd_hcic_read_auth_enable (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_AUTHENTICATION_ENABLE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_auth_enable (UINT8 flag) { BT_HDR *p; @@ -1655,68 +1169,6 @@ BOOLEAN btsnd_hcic_write_auth_enable (UINT8 flag) return (TRUE); } -BOOLEAN btsnd_hcic_read_encr_mode (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_ENCRYPTION_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_encr_mode (UINT8 mode) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_ENCRYPTION_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, mode); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_dev_class(void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_CLASS_OF_DEVICE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev_class) { BT_HDR *p; @@ -1739,26 +1191,6 @@ BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev_class) return (TRUE); } -BOOLEAN btsnd_hcic_read_voice_settings(void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_VOICE_SETTINGS); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags) { BT_HDR *p; @@ -1781,28 +1213,6 @@ BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags) return (TRUE); } -BOOLEAN btsnd_hcic_read_auto_flush_tout (UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_AUTO_FLUSH_TOUT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_auto_flush_tout (UINT16 handle, UINT16 tout) { BT_HDR *p; @@ -1826,90 +1236,6 @@ BOOLEAN btsnd_hcic_write_auto_flush_tout (UINT16 handle, UINT16 tout) return (TRUE); } -BOOLEAN btsnd_hcic_read_num_bcast_xmit (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_NUM_BCAST_REXMITS); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_num_bcast_xmit (UINT8 num) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_NUM_BCAST_REXMITS); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, num); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_hold_mode_act (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_HOLD_MODE_ACTIVITY); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_hold_mode_act (UINT8 flags) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_HOLD_MODE_ACTIVITY); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, flags); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_read_tx_power (UINT16 handle, UINT8 type) { BT_HDR *p; @@ -1933,96 +1259,6 @@ BOOLEAN btsnd_hcic_read_tx_power (UINT16 handle, UINT8 type) return (TRUE); } -BOOLEAN btsnd_hcic_read_sco_flow_enable (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_SCO_FLOW_CTRL_ENABLE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_sco_flow_enable (UINT8 flag) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_SCO_FLOW_CTRL_ENABLE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, flag); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_set_host_flow_ctrl (UINT8 value) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_SET_HC_TO_HOST_FLOW_CTRL); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, value); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_set_host_buf_size (UINT16 acl_len, UINT8 sco_len, - UINT16 acl_num, UINT16 sco_num) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_HOST_BUFFER_SIZE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE); - - UINT16_TO_STREAM (pp, acl_len); - UINT8_TO_STREAM (pp, sco_len); - UINT16_TO_STREAM (pp, acl_num); - UINT16_TO_STREAM (pp, sco_num); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, UINT16 *handle, UINT16 *num_pkts) { @@ -2053,28 +1289,6 @@ BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, UINT16 *handle, return (TRUE); } -BOOLEAN btsnd_hcic_read_link_super_tout (UINT8 local_controller_id, UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_LINK_SUPER_TOUT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_link_super_tout (UINT8 local_controller_id, UINT16 handle, UINT16 timeout) { BT_HDR *p; @@ -2098,46 +1312,6 @@ BOOLEAN btsnd_hcic_write_link_super_tout (UINT8 local_controller_id, UINT16 hand return (TRUE); } -BOOLEAN btsnd_hcic_read_max_iac (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_NUM_SUPPORTED_IAC); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_cur_iac_lap (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_CURRENT_IAC_LAP); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac, LAP * const iac_lap) { BT_HDR *p; @@ -2164,90 +1338,6 @@ BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac, LAP * const iac_lap) return (TRUE); } -BOOLEAN btsnd_hcic_read_page_scan_per (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_PERIOD_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_page_scan_per (UINT8 mode) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_PERIOD_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, mode); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_page_scan_mode (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_page_scan_mode (UINT8 mode) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, mode); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - /****************************************** ** Lisbon Features *******************************************/ @@ -2280,28 +1370,7 @@ BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat, } #endif /* BTM_SSR_INCLUDED */ -#if (BTM_EIR_SERVER_INCLUDED == TRUE) /**** Extended Inquiry Response Commands ****/ -BOOLEAN btsnd_hcic_read_ext_inquiry_response (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_EXT_INQ_RESPONSE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - void btsnd_hcic_write_ext_inquiry_response (void *buffer, UINT8 fec_req) { BT_HDR *p = (BT_HDR *)buffer; @@ -2317,72 +1386,6 @@ void btsnd_hcic_write_ext_inquiry_response (void *buffer, UINT8 fec_req) btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); } -#endif /* BTM_EIR_SERVER_INCLUDED == TRUE */ - -/**** Simple Pairing Commands ****/ -BOOLEAN btsnd_hcic_write_simple_pairing_mode (UINT8 mode) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_SIMP_PAIR)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_SIMP_PAIR; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_SIMPLE_PAIRING_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_SIMP_PAIR); - - UINT8_TO_STREAM (pp, mode); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_simple_pairing_mode (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_SIMP_PAIR)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_SIMP_PAIR; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_SIMPLE_PAIRING_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_SIMP_PAIR); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_simp_pair_debug_mode(UINT8 debug_mode) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SIMP_PAIR_DBUG)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SIMP_PAIR_DBUG; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_SIMP_PAIR_DEBUG_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SIMP_PAIR_DBUG); - - UINT8_TO_STREAM (pp, debug_mode); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability, UINT8 oob_present, UINT8 auth_req) @@ -2597,72 +1600,6 @@ BOOLEAN btsnd_hcic_read_inq_tx_power (void) return (TRUE); } -BOOLEAN btsnd_hcic_write_inq_tx_power (INT8 level) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_TX_POWER)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_TX_POWER; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_INQ_TX_POWER_LEVEL); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_TX_POWER); - - INT8_TO_STREAM (pp, level); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -#if 0 /* currently not been used */ -BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_ERR_DATA_RPT)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_ERR_DATA_RPT; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_ERRONEOUS_DATA_RPT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_ERR_DATA_RPT); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} -#endif - -BOOLEAN btsnd_hcic_write_default_erroneous_data_rpt (UINT8 flag) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_ERR_DATA_RPT)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_ERR_DATA_RPT; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_ERRONEOUS_DATA_RPT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_ERR_DATA_RPT); - - UINT8_TO_STREAM (pp, flag); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif) { BT_HDR *p; @@ -2712,217 +1649,10 @@ BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type) } #endif - -BOOLEAN btsnd_hcic_refresh_encryption_key (UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - UINT16_TO_STREAM (pp, HCI_REFRESH_ENCRYPTION_KEY); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} /************************* ** End of Lisbon Commands **************************/ -BOOLEAN btsnd_hcic_read_local_ver (UINT8 local_controller_id) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_LOCAL_VERSION_INFO); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_local_supported_cmds (UINT8 local_controller_id) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_LOCAL_SUPPORTED_CMDS); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_local_features (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_LOCAL_FEATURES); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_local_ext_features (UINT8 page_num) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_LOCAL_EXT_FEATURES); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES); - - UINT8_TO_STREAM (pp, page_num); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_buffer_size (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_BUFFER_SIZE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_country_code (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_COUNTRY_CODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_bd_addr (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_BD_ADDR); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_fail_contact_count (UINT8 local_controller_id, UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_FAILED_CONTACT_COUNT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_reset_fail_contact_count (UINT8 local_controller_id, UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_RESET_FAILED_CONTACT_COUNT); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (local_controller_id, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle) { BT_HDR *p; @@ -2967,48 +1697,6 @@ BOOLEAN btsnd_hcic_read_rssi (UINT16 handle) return (TRUE); } -BOOLEAN btsnd_hcic_read_loopback_mode (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_LOOPBACK_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_write_loopback_mode (UINT8 mode) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_LOOPBACK_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, mode); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_enable_test_mode (void) { BT_HDR *p; @@ -3029,173 +1717,6 @@ BOOLEAN btsnd_hcic_enable_test_mode (void) return (TRUE); } -BOOLEAN btsnd_hcic_write_afh_channel_assessment_mode (UINT8 mode) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_WRITE_AFH_ASSESSMENT_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); - - UINT8_TO_STREAM (pp, mode); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_afh_channel_assessment_mode(void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_AFH_ASSESSMENT_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_set_afh_channels (UINT8 first, UINT8 last) -{ - BT_HDR *p; - UINT8 *pp; - UINT8 channels[10] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F}; - int i; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_AFH_CHANNELS)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_AFH_CHANNELS; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_SET_AFH_CHANNELS); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_AFH_CHANNELS); - - /* Just make sure that caller did not exceed 79 Bluetooth channels */ - if ((first <= last) && (last <= 78)) - { - for (i = first; i <= last; i++) - { - int byte_offset = i / 8; - int bit_offset = i % 8; - channels[byte_offset] &= ~(1 << bit_offset); - } - } - for (i = 0; i < 10; i++) - *pp++ = channels[i]; - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_set_afh_host_channel_class (UINT8 *p_afhchannelmap) -{ - BT_HDR *p; - UINT8 *pp; - int i; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_AFH_CHANNELS)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_AFH_CHANNELS; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_SET_AFH_CHANNELS); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_AFH_CHANNELS); - - /* Copy and convert */ - for (i = 0; i < 10; i++) - *pp++ = p_afhchannelmap[9-i]; - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_afh_channel_map (UINT16 handle) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_AFH_CH_MAP); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE); - - UINT16_TO_STREAM (pp, handle); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_clock (UINT16 handle, UINT8 which_clock) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CLOCK)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CLOCK; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_CLOCK); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CLOCK); - - UINT16_TO_STREAM (pp, handle); - UINT8_TO_STREAM (pp, which_clock); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - -BOOLEAN btsnd_hcic_read_inqscan_type(void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_INQSCAN_TYPE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_inqscan_type (UINT8 type) { BT_HDR *p; @@ -3218,26 +1739,6 @@ BOOLEAN btsnd_hcic_write_inqscan_type (UINT8 type) return (TRUE); } -BOOLEAN btsnd_hcic_read_inquiry_mode (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_INQUIRY_MODE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_inquiry_mode (UINT8 mode) { BT_HDR *p; @@ -3260,26 +1761,6 @@ BOOLEAN btsnd_hcic_write_inquiry_mode (UINT8 mode) return (TRUE); } -BOOLEAN btsnd_hcic_read_pagescan_type (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_TYPE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - BOOLEAN btsnd_hcic_write_pagescan_type (UINT8 type) { BT_HDR *p; @@ -3303,7 +1784,7 @@ BOOLEAN btsnd_hcic_write_pagescan_type (UINT8 type) } /* Must have room to store BT_HDR + max VSC length + callback pointer */ -#if !defined (LMP_TEST) && (HCI_CMD_POOL_BUF_SIZE < 268) +#if (HCI_CMD_POOL_BUF_SIZE < 268) #error "HCI_CMD_POOL_BUF_SIZE must be larger than 268" #endif @@ -3325,41 +1806,3 @@ void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, UINT8 len, btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); } - -void btsnd_hcic_data (BT_HDR *p_buf, UINT16 len, UINT16 handle, UINT8 boundary, UINT8 broadcast) -{ - UINT8 *p; - - /* Higher layer should have left 4 bytes for us to fill the header */ - p_buf->offset -= 4; - p_buf->len += 4; - - /* Find the pointer to the beginning of the data */ - p = (UINT8 *)(p_buf + 1) + p_buf->offset; - - UINT16_TO_STREAM (p, handle | ((boundary & 3) << 12) | ((broadcast & 3) << 14)); - UINT16_TO_STREAM (p, len); - - HCI_ACL_DATA_TO_LOWER (p_buf); -} - -BOOLEAN btsnd_hcic_nop (void) -{ - BT_HDR *p; - UINT8 *pp; - - if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) - return (FALSE); - - pp = (UINT8 *)(p + 1); - - p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; - p->offset = 0; - - UINT16_TO_STREAM (pp, HCI_COMMAND_NONE); - UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); - - btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); - return (TRUE); -} - diff --git a/stack/hid/hidh_conn.c b/stack/hid/hidh_conn.c index 3a354cc40..d8b619da2 100644 --- a/stack/hid/hidh_conn.c +++ b/stack/hid/hidh_conn.c @@ -321,9 +321,7 @@ void hidh_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT transport, voi { tHID_HOST_DEV_CTB *p_dev = (tHID_HOST_DEV_CTB *) p_ref_data; UINT8 dhandle; -#if (HID_HOST_MAX_CONN_RETRY > 0) - UINT32 cb_res = HID_ERR_AUTH_FAILED; -#endif + UINT32 reason; UNUSED(bd_addr); UNUSED (transport); @@ -350,8 +348,6 @@ void hidh_sec_check_complete_orig (BD_ADDR bd_addr, tBT_TRANSPORT transport, voi hidh_conn_retry (dhandle); return; } - else - cb_res = HID_L2CAP_CONN_FAIL | HCI_ERR_PAGE_TIMEOUT ; } #endif p_dev->conn.disc_reason = HID_ERR_AUTH_FAILED; /* Save reason for disconnecting */ @@ -456,13 +452,11 @@ static void hidh_l2cif_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg) { UINT8 dhandle; tHID_CONN *p_hcon = NULL; - tHID_HOST_DEV_CTB *p_dev; UINT32 reason; /* Find CCB based on CID */ if( (dhandle = find_conn_by_cid(l2cap_cid)) < HID_HOST_MAX_DEVICES ) { - p_dev = &hh_cb.devices[dhandle]; p_hcon = &hh_cb.devices[dhandle].conn; } diff --git a/stack/hid/hidh_int.h b/stack/hid/hidh_int.h index ad074129c..3fedea2b1 100644 --- a/stack/hid/hidh_int.h +++ b/stack/hid/hidh_int.h @@ -80,9 +80,9 @@ extern "C" ** Main Control Block *******************************************************************************/ #if HID_DYNAMIC_MEMORY == FALSE -HID_API extern tHID_HOST_CTB hh_cb; +extern tHID_HOST_CTB hh_cb; #else -HID_API extern tHID_HOST_CTB *hidh_cb_ptr; +extern tHID_HOST_CTB *hidh_cb_ptr; #define hh_cb (*hidh_cb_ptr) #endif @@ -91,4 +91,3 @@ HID_API extern tHID_HOST_CTB *hidh_cb_ptr; #endif #endif - diff --git a/stack/include/a2d_api.h b/stack/include/a2d_api.h index f21ba6c96..f786670ab 100644 --- a/stack/include/a2d_api.h +++ b/stack/include/a2d_api.h @@ -163,7 +163,7 @@ extern "C" ** A2D_FAIL if function execution failed. ** ******************************************************************************/ -A2D_API extern tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name, +extern tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name, UINT16 features, UINT32 sdp_handle); /****************************************************************************** @@ -201,8 +201,8 @@ A2D_API extern tA2D_STATUS A2D_AddRecord(UINT16 service_uuid, char *p_service_na ** A2D_FAIL if function execution failed. ** ******************************************************************************/ -A2D_API extern tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr, - tA2D_SDP_DB_PARAMS *p_db, tA2D_FIND_CBACK *p_cback); +extern tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr, + tA2D_SDP_DB_PARAMS *p_db, tA2D_FIND_CBACK *p_cback); /****************************************************************************** ** @@ -225,7 +225,7 @@ A2D_API extern tA2D_STATUS A2D_FindService(UINT16 service_uuid, BD_ADDR bd_addr, ** the input parameter is 0xff. ** ******************************************************************************/ -A2D_API extern UINT8 A2D_SetTraceLevel (UINT8 new_level); +extern UINT8 A2D_SetTraceLevel (UINT8 new_level); /****************************************************************************** ** Function A2D_BitsSet @@ -235,7 +235,7 @@ A2D_API extern UINT8 A2D_SetTraceLevel (UINT8 new_level); ** A2D_SET_ZERO_BIT, if all bits clear ** A2D_SET_MULTL_BIT, if multiple bits are set ******************************************************************************/ -A2D_API extern UINT8 A2D_BitsSet(UINT8 num); +extern UINT8 A2D_BitsSet(UINT8 num); #ifdef __cplusplus } @@ -252,6 +252,6 @@ A2D_API extern UINT8 A2D_BitsSet(UINT8 num); ** Returns void ** *******************************************************************************/ -A2D_API extern void A2D_Init(void); +extern void A2D_Init(void); #endif /* A2D_API_H */ diff --git a/stack/include/a2d_sbc.h b/stack/include/a2d_sbc.h index dad0b8b43..a7beb7381 100644 --- a/stack/include/a2d_sbc.h +++ b/stack/include/a2d_sbc.h @@ -101,7 +101,7 @@ extern "C" ** ** Returns nothing. ******************************************************************************/ -A2D_API extern void A2D_SbcChkFrInit(UINT8 *p_pkt); +extern void A2D_SbcChkFrInit(UINT8 *p_pkt); /****************************************************************************** ** @@ -111,7 +111,7 @@ A2D_API extern void A2D_SbcChkFrInit(UINT8 *p_pkt); ** ** Returns nothing. ******************************************************************************/ -A2D_API extern void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len); +extern void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len); /****************************************************************************** ** @@ -131,8 +131,8 @@ A2D_API extern void A2D_SbcDescramble(UINT8 *p_pkt, UINT16 len); ** Returns A2D_SUCCESS if function execution succeeded. ** Error status code, otherwise. ******************************************************************************/ -A2D_API extern tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie, - UINT8 *p_result); +extern tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie, + UINT8 *p_result); /****************************************************************************** ** @@ -152,8 +152,8 @@ A2D_API extern tA2D_STATUS A2D_BldSbcInfo(UINT8 media_type, tA2D_SBC_CIE *p_ie, ** Returns A2D_SUCCESS if function execution succeeded. ** Error status code, otherwise. ******************************************************************************/ -A2D_API extern tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, - BOOLEAN for_caps); +extern tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, + BOOLEAN for_caps); /****************************************************************************** ** @@ -177,8 +177,8 @@ A2D_API extern tA2D_STATUS A2D_ParsSbcInfo(tA2D_SBC_CIE *p_ie, UINT8 *p_info, ** ** Returns void. ******************************************************************************/ -A2D_API extern void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start, - BOOLEAN last, UINT8 num); +extern void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start, + BOOLEAN last, UINT8 num); /****************************************************************************** ** @@ -202,9 +202,9 @@ A2D_API extern void A2D_BldSbcMplHdr(UINT8 *p_dst, BOOLEAN frag, BOOLEAN start, ** ** Returns void. ******************************************************************************/ -A2D_API extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, - BOOLEAN *p_start, BOOLEAN *p_last, - UINT8 *p_num); +extern void A2D_ParsSbcMplHdr(UINT8 *p_src, BOOLEAN *p_frag, + BOOLEAN *p_start, BOOLEAN *p_last, + UINT8 *p_num); #ifdef __cplusplus } #endif diff --git a/stack/include/avct_api.h b/stack/include/avct_api.h index 288001195..001ca1bdb 100644 --- a/stack/include/avct_api.h +++ b/stack/include/avct_api.h @@ -138,7 +138,7 @@ extern "C" ** Returns void ** *******************************************************************************/ -AVCT_API extern void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask); +extern void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask); /******************************************************************************* ** @@ -154,7 +154,7 @@ AVCT_API extern void AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask); ** Returns void ** *******************************************************************************/ -AVCT_API extern void AVCT_Deregister(void); +extern void AVCT_Deregister(void); /******************************************************************************* ** @@ -172,8 +172,8 @@ AVCT_API extern void AVCT_Deregister(void); ** Returns AVCT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVCT_API extern UINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc, - BD_ADDR peer_addr); +extern UINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc, + BD_ADDR peer_addr); /******************************************************************************* ** @@ -188,7 +188,7 @@ AVCT_API extern UINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc, ** Returns AVCT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVCT_API extern UINT16 AVCT_RemoveConn(UINT8 handle); +extern UINT16 AVCT_RemoveConn(UINT8 handle); /******************************************************************************* ** @@ -206,7 +206,7 @@ AVCT_API extern UINT16 AVCT_RemoveConn(UINT8 handle); ** Returns AVCT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVCT_API extern UINT16 AVCT_CreateBrowse(UINT8 handle, UINT8 role); +extern UINT16 AVCT_CreateBrowse(UINT8 handle, UINT8 role); /******************************************************************************* ** @@ -221,7 +221,7 @@ AVCT_API extern UINT16 AVCT_CreateBrowse(UINT8 handle, UINT8 role); ** Returns AVCT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVCT_API extern UINT16 AVCT_RemoveBrowse(UINT8 handle); +extern UINT16 AVCT_RemoveBrowse(UINT8 handle); /******************************************************************************* ** @@ -233,7 +233,7 @@ AVCT_API extern UINT16 AVCT_RemoveBrowse(UINT8 handle); ** Returns the peer browsing channel MTU. ** *******************************************************************************/ -AVCT_API extern UINT16 AVCT_GetBrowseMtu (UINT8 handle); +extern UINT16 AVCT_GetBrowseMtu (UINT8 handle); /******************************************************************************* ** @@ -245,7 +245,7 @@ AVCT_API extern UINT16 AVCT_GetBrowseMtu (UINT8 handle); ** Returns the peer MTU size. ** *******************************************************************************/ -AVCT_API extern UINT16 AVCT_GetPeerMtu (UINT8 handle); +extern UINT16 AVCT_GetPeerMtu (UINT8 handle); /******************************************************************************* ** @@ -268,7 +268,7 @@ AVCT_API extern UINT16 AVCT_GetPeerMtu (UINT8 handle); ** Returns AVCT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVCT_API extern UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg); +extern UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg); #ifdef __cplusplus } @@ -276,4 +276,3 @@ AVCT_API extern UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR * #endif /* AVCT_API_H */ - diff --git a/stack/include/avdt_api.h b/stack/include/avdt_api.h index 93ed6aebc..a9613c0ff 100644 --- a/stack/include/avdt_api.h +++ b/stack/include/avdt_api.h @@ -437,7 +437,7 @@ extern "C" ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback); +extern void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback); /******************************************************************************* ** @@ -452,7 +452,7 @@ AVDT_API extern void AVDT_Register(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDT_Deregister(void); +extern void AVDT_Deregister(void); /******************************************************************************* @@ -467,7 +467,7 @@ AVDT_API extern void AVDT_Deregister(void); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDT_SINK_Activate(void); +extern void AVDT_SINK_Activate(void); /******************************************************************************* ** @@ -481,7 +481,7 @@ AVDT_API extern void AVDT_SINK_Activate(void); ** Returns void. ** *******************************************************************************/ -AVDT_API extern void AVDT_SINK_Deactivate(void); +extern void AVDT_SINK_Deactivate(void); /******************************************************************************* ** @@ -497,7 +497,7 @@ AVDT_API extern void AVDT_SINK_Deactivate(void); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs); +extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs); /******************************************************************************* ** @@ -513,7 +513,7 @@ AVDT_API extern UINT16 AVDT_CreateStream(UINT8 *p_handle, tAVDT_CS *p_cs); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_RemoveStream(UINT8 handle); +extern UINT16 AVDT_RemoveStream(UINT8 handle); /******************************************************************************* ** @@ -541,8 +541,8 @@ AVDT_API extern UINT16 AVDT_RemoveStream(UINT8 handle); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info, - UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback); +extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_info, + UINT8 max_seps, tAVDT_CTRL_CBACK *p_cback); /******************************************************************************* @@ -569,8 +569,8 @@ AVDT_API extern UINT16 AVDT_DiscoverReq(BD_ADDR bd_addr, tAVDT_SEP_INFO *p_sep_i ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, - tAVDT_CTRL_CBACK *p_cback); +extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, + tAVDT_CTRL_CBACK *p_cback); /******************************************************************************* ** @@ -596,8 +596,8 @@ AVDT_API extern UINT16 AVDT_GetCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_ ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, - tAVDT_CTRL_CBACK *p_cback); +extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, + tAVDT_CTRL_CBACK *p_cback); /******************************************************************************* ** @@ -610,7 +610,7 @@ AVDT_API extern UINT16 AVDT_GetAllCapReq(BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay); +extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay); /******************************************************************************* ** @@ -625,8 +625,8 @@ AVDT_API extern UINT16 AVDT_DelayReport(UINT8 handle, UINT8 seid, UINT16 delay); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid, - tAVDT_CFG *p_cfg); +extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid, + tAVDT_CFG *p_cfg); /******************************************************************************* @@ -641,8 +641,8 @@ AVDT_API extern UINT16 AVDT_OpenReq(UINT8 handle, BD_ADDR bd_addr, UINT8 seid, ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, - UINT8 category); +extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, + UINT8 category); /******************************************************************************* ** @@ -658,7 +658,7 @@ AVDT_API extern UINT16 AVDT_ConfigRsp(UINT8 handle, UINT8 label, UINT8 error_cod ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles); +extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles); /******************************************************************************* ** @@ -675,7 +675,7 @@ AVDT_API extern UINT16 AVDT_StartReq(UINT8 *p_handles, UINT8 num_handles); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles); +extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles); /******************************************************************************* ** @@ -691,7 +691,7 @@ AVDT_API extern UINT16 AVDT_SuspendReq(UINT8 *p_handles, UINT8 num_handles); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_CloseReq(UINT8 handle); +extern UINT16 AVDT_CloseReq(UINT8 handle); /******************************************************************************* ** @@ -709,7 +709,7 @@ AVDT_API extern UINT16 AVDT_CloseReq(UINT8 handle); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg); +extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg); /******************************************************************************* ** @@ -723,8 +723,8 @@ AVDT_API extern UINT16 AVDT_ReconfigReq(UINT8 handle, tAVDT_CFG *p_cfg); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, - UINT8 category); +extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_code, + UINT8 category); /******************************************************************************* ** @@ -740,7 +740,7 @@ AVDT_API extern UINT16 AVDT_ReconfigRsp(UINT8 handle, UINT8 label, UINT8 error_c ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len); +extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len); /******************************************************************************* ** @@ -756,8 +756,8 @@ AVDT_API extern UINT16 AVDT_SecurityReq(UINT8 handle, UINT8 *p_data, UINT16 len) ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code, - UINT8 *p_data, UINT16 len); +extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_code, + UINT8 *p_data, UINT16 len); /******************************************************************************* ** @@ -792,8 +792,8 @@ AVDT_API extern UINT16 AVDT_SecurityRsp(UINT8 handle, UINT8 label, UINT8 error_c ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, - UINT8 m_pt); +extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, + UINT8 m_pt); /******************************************************************************* ** ** Function AVDT_WriteReqOpt @@ -830,8 +830,8 @@ AVDT_API extern UINT16 AVDT_WriteReq(UINT8 handle, BT_HDR *p_pkt, UINT32 time_st ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, - UINT8 m_pt, tAVDT_DATA_OPT_MASK opt); +extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, + UINT8 m_pt, tAVDT_DATA_OPT_MASK opt); /******************************************************************************* ** @@ -848,8 +848,8 @@ AVDT_API extern UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask, - tAVDT_CTRL_CBACK *p_cback); +extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask, + tAVDT_CTRL_CBACK *p_cback); /******************************************************************************* ** @@ -863,7 +863,7 @@ AVDT_API extern UINT16 AVDT_ConnectReq(BD_ADDR bd_addr, UINT8 sec_mask, ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback); +extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_cback); /******************************************************************************* ** @@ -874,7 +874,7 @@ AVDT_API extern UINT16 AVDT_DisconnectReq(BD_ADDR bd_addr, tAVDT_CTRL_CBACK *p_c ** Returns CID if successful, otherwise 0. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_GetL2CapChannel(UINT8 handle); +extern UINT16 AVDT_GetL2CapChannel(UINT8 handle); /******************************************************************************* ** @@ -885,7 +885,7 @@ AVDT_API extern UINT16 AVDT_GetL2CapChannel(UINT8 handle); ** Returns CID if successful, otherwise 0. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr); +extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr); /******************************************************************************* ** @@ -908,8 +908,8 @@ AVDT_API extern UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr); ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len, - UINT32 time_stamp, UINT8 m_pt, UINT8 marker); +extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len, + UINT32 time_stamp, UINT8 m_pt, UINT8 marker); /******************************************************************************* ** @@ -929,7 +929,7 @@ AVDT_API extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 dat ** Returns AVDT_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len); +extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_len); /******************************************************************************* ** @@ -942,8 +942,8 @@ AVDT_API extern UINT16 AVDT_SetMediaBuf(UINT8 handle, UINT8 *p_buf, UINT32 buf_l ** Returns ** *******************************************************************************/ -AVDT_API extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type, - tAVDT_REPORT_DATA *p_data); +extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type, + tAVDT_REPORT_DATA *p_data); /****************************************************************************** ** @@ -966,7 +966,7 @@ AVDT_API extern UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type, ** the input parameter is 0xff. ** ******************************************************************************/ -AVDT_API extern UINT8 AVDT_SetTraceLevel (UINT8 new_level); +extern UINT8 AVDT_SetTraceLevel (UINT8 new_level); #ifdef __cplusplus } diff --git a/stack/include/avdtc_api.h b/stack/include/avdtc_api.h index 14a1a21cc..96b20e77b 100644 --- a/stack/include/avdtc_api.h +++ b/stack/include/avdtc_api.h @@ -76,7 +76,7 @@ extern "C" ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_Init(tAVDTC_CTRL_CBACK *p_cback); +extern void AVDTC_Init(tAVDTC_CTRL_CBACK *p_cback); /******************************************************************************* ** @@ -87,8 +87,8 @@ AVDT_API extern void AVDTC_Init(tAVDTC_CTRL_CBACK *p_cback); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_DiscoverRsp(BD_ADDR bd_addr, UINT8 label, - tAVDT_SEP_INFO sep_info[], UINT8 num_seps); +extern void AVDTC_DiscoverRsp(BD_ADDR bd_addr, UINT8 label, + tAVDT_SEP_INFO sep_info[], UINT8 num_seps); /******************************************************************************* ** @@ -99,7 +99,7 @@ AVDT_API extern void AVDTC_DiscoverRsp(BD_ADDR bd_addr, UINT8 label, ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_GetCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap); +extern void AVDTC_GetCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap); /******************************************************************************* ** @@ -110,7 +110,7 @@ AVDT_API extern void AVDTC_GetCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_ ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_GetAllCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap); +extern void AVDTC_GetAllCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG *p_cap); /******************************************************************************* ** @@ -121,7 +121,7 @@ AVDT_API extern void AVDTC_GetAllCapRsp(BD_ADDR bd_addr, UINT8 label, tAVDT_CFG ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_GetConfigReq(UINT8 handle); +extern void AVDTC_GetConfigReq(UINT8 handle); /******************************************************************************* ** @@ -132,7 +132,7 @@ AVDT_API extern void AVDTC_GetConfigReq(UINT8 handle); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_GetConfigRsp(UINT8 handle, UINT8 label, tAVDT_CFG *p_cfg); +extern void AVDTC_GetConfigRsp(UINT8 handle, UINT8 label, tAVDT_CFG *p_cfg); /******************************************************************************* ** @@ -143,7 +143,7 @@ AVDT_API extern void AVDTC_GetConfigRsp(UINT8 handle, UINT8 label, tAVDT_CFG *p_ ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_OpenReq(UINT8 handle); +extern void AVDTC_OpenReq(UINT8 handle); /******************************************************************************* ** @@ -154,7 +154,7 @@ AVDT_API extern void AVDTC_OpenReq(UINT8 handle); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_OpenRsp(UINT8 handle, UINT8 label); +extern void AVDTC_OpenRsp(UINT8 handle, UINT8 label); /******************************************************************************* ** @@ -165,7 +165,7 @@ AVDT_API extern void AVDTC_OpenRsp(UINT8 handle, UINT8 label); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_StartRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label); +extern void AVDTC_StartRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label); /******************************************************************************* ** @@ -176,7 +176,7 @@ AVDT_API extern void AVDTC_StartRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 l ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_CloseRsp(UINT8 handle, UINT8 label); +extern void AVDTC_CloseRsp(UINT8 handle, UINT8 label); /******************************************************************************* ** @@ -187,7 +187,7 @@ AVDT_API extern void AVDTC_CloseRsp(UINT8 handle, UINT8 label); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_SuspendRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label); +extern void AVDTC_SuspendRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 label); /******************************************************************************* ** @@ -198,7 +198,7 @@ AVDT_API extern void AVDTC_SuspendRsp(UINT8 *p_handles, UINT8 num_handles, UINT8 ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_AbortReq(UINT8 handle); +extern void AVDTC_AbortReq(UINT8 handle); /******************************************************************************* ** @@ -209,7 +209,7 @@ AVDT_API extern void AVDTC_AbortReq(UINT8 handle); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_AbortRsp(UINT8 handle, UINT8 label); +extern void AVDTC_AbortRsp(UINT8 handle, UINT8 label); /******************************************************************************* ** @@ -220,12 +220,11 @@ AVDT_API extern void AVDTC_AbortRsp(UINT8 handle, UINT8 label); ** Returns void ** *******************************************************************************/ -AVDT_API extern void AVDTC_Rej(UINT8 handle, BD_ADDR bd_addr, UINT8 cmd, UINT8 label, - UINT8 err_code, UINT8 err_param); +extern void AVDTC_Rej(UINT8 handle, BD_ADDR bd_addr, UINT8 cmd, UINT8 label, + UINT8 err_code, UINT8 err_param); #ifdef __cplusplus } #endif #endif /* AVDT_CAPI_H */ - diff --git a/stack/include/avrc_api.h b/stack/include/avrc_api.h index cc6db7f3e..2198074d9 100644 --- a/stack/include/avrc_api.h +++ b/stack/include/avrc_api.h @@ -89,6 +89,9 @@ * send messages. */ #define AVRC_BROWSE_UNCONG_IND_EVT 7 +/* AVRC_CMD_TIMEOUT_EVT event indicates timeout waiting for AVRC command response from the peer */ +#define AVRC_CMD_TIMEOUT_EVT 8 + /* Supported categories */ #define AVRC_SUPF_CT_CAT1 0x0001 /* Category 1 */ #define AVRC_SUPF_CT_CAT2 0x0002 /* Category 2 */ @@ -200,7 +203,7 @@ extern "C" ** AVRC_NO_RESOURCES if not enough resources to build the SDP record. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name, +extern UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name, char *p_provider_name, UINT16 categories, UINT32 sdp_handle); /****************************************************************************** @@ -240,8 +243,8 @@ AVRC_API extern UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name, ** perform the service search. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr, - tAVRC_SDP_DB_PARAMS *p_db, tAVRC_FIND_CBACK *p_cback); +extern UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr, + tAVRC_SDP_DB_PARAMS *p_db, tAVRC_FIND_CBACK *p_cback); /****************************************************************************** ** @@ -288,8 +291,8 @@ AVRC_API extern UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr, ** the connection. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb, - BD_ADDR_PTR peer_addr); +extern UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb, + BD_ADDR_PTR peer_addr); /****************************************************************************** ** @@ -309,7 +312,7 @@ AVRC_API extern UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb, ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_Close(UINT8 handle); +extern UINT16 AVRC_Close(UINT8 handle); /****************************************************************************** ** @@ -325,7 +328,7 @@ AVRC_API extern UINT16 AVRC_Close(UINT8 handle); ** the connection. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_OpenBrowse(UINT8 handle, UINT8 conn_role); +extern UINT16 AVRC_OpenBrowse(UINT8 handle, UINT8 conn_role); /****************************************************************************** ** @@ -339,7 +342,7 @@ AVRC_API extern UINT16 AVRC_OpenBrowse(UINT8 handle, UINT8 conn_role); ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_CloseBrowse(UINT8 handle); +extern UINT16 AVRC_CloseBrowse(UINT8 handle); /****************************************************************************** ** @@ -357,7 +360,7 @@ AVRC_API extern UINT16 AVRC_CloseBrowse(UINT8 handle); ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt); +extern UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt); /****************************************************************************** ** @@ -380,7 +383,7 @@ AVRC_API extern UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_H ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label); +extern UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label); /****************************************************************************** ** @@ -407,7 +410,7 @@ AVRC_API extern UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label); ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page); +extern UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page); /****************************************************************************** @@ -433,7 +436,7 @@ AVRC_API extern UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page); ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg); +extern UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg); /****************************************************************************** ** @@ -460,7 +463,7 @@ AVRC_API extern UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg); +extern UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg); /****************************************************************************** @@ -486,7 +489,7 @@ AVRC_API extern UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg); +extern UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg); /****************************************************************************** @@ -514,7 +517,7 @@ AVRC_API extern UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VEN ** AVRC_BAD_HANDLE if handle is invalid. ** ******************************************************************************/ -AVRC_API extern UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg); +extern UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg); /****************************************************************************** @@ -538,7 +541,7 @@ AVRC_API extern UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VEN ** the input parameter is 0xff. ** ******************************************************************************/ -AVRC_API extern UINT8 AVRC_SetTraceLevel (UINT8 new_level); +extern UINT8 AVRC_SetTraceLevel (UINT8 new_level); /******************************************************************************* ** @@ -551,7 +554,7 @@ AVRC_API extern UINT8 AVRC_SetTraceLevel (UINT8 new_level); ** Returns void ** *******************************************************************************/ -AVRC_API extern void AVRC_Init(void); +extern void AVRC_Init(void); /******************************************************************************* ** @@ -563,8 +566,8 @@ AVRC_API extern void AVRC_Init(void); ** Otherwise, the error code defined by AVRCP 1.4 ** *******************************************************************************/ -AVRC_API extern tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_result, - UINT8 *p_buf, UINT16 buf_len); +extern tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_result, + UINT8 *p_buf, UINT16 buf_len); /******************************************************************************* ** @@ -576,8 +579,8 @@ AVRC_API extern tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_r ** Otherwise, the error code defined by AVRCP 1.4 ** *******************************************************************************/ -AVRC_API extern tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result, - UINT8 *p_buf, UINT16 buf_len); +extern tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result, + UINT8 *p_buf, UINT16 buf_len); /******************************************************************************* ** @@ -590,7 +593,7 @@ AVRC_API extern tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p ** Otherwise, the error code. ** *******************************************************************************/ -AVRC_API extern tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt); +extern tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt); /******************************************************************************* ** @@ -603,7 +606,7 @@ AVRC_API extern tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt ** Otherwise, the error code. ** *******************************************************************************/ -AVRC_API extern tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt); +extern tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt); /************************************************************************** ** @@ -615,7 +618,7 @@ AVRC_API extern tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, ** ** *******************************************************************************/ -AVRC_API extern BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type); +extern BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type); /******************************************************************************* ** @@ -627,7 +630,7 @@ AVRC_API extern BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type); ** Returns returns TRUE if it is valid ** *******************************************************************************/ -AVRC_API extern BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr); +extern BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr); #ifdef __cplusplus } diff --git a/stack/include/bnep_api.h b/stack/include/bnep_api.h index b2bc0fd11..3ca31d5d3 100644 --- a/stack/include/bnep_api.h +++ b/stack/include/bnep_api.h @@ -242,7 +242,7 @@ extern "C" { ** BNEP_FAILURE if connection state callback is missing ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_Register (tBNEP_REGISTER *p_reg_info); +extern tBNEP_RESULT BNEP_Register (tBNEP_REGISTER *p_reg_info); /******************************************************************************* ** @@ -257,7 +257,7 @@ BNEP_API extern tBNEP_RESULT BNEP_Register (tBNEP_REGISTER *p_reg_info); ** Returns void ** *******************************************************************************/ -BNEP_API extern void BNEP_Deregister (void); +extern void BNEP_Deregister (void); /******************************************************************************* @@ -276,10 +276,10 @@ BNEP_API extern void BNEP_Deregister (void); ** BNEP_NO_RESOURCES if no resources ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda, - tBT_UUID *src_uuid, - tBT_UUID *dst_uuid, - UINT16 *p_handle); +extern tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda, + tBT_UUID *src_uuid, + tBT_UUID *dst_uuid, + UINT16 *p_handle); /******************************************************************************* ** @@ -296,7 +296,7 @@ BNEP_API extern tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda, ** BNEP_WRONG_STATE if the responce is not expected ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_ConnectResp (UINT16 handle, tBNEP_RESULT resp); +extern tBNEP_RESULT BNEP_ConnectResp (UINT16 handle, tBNEP_RESULT resp); /******************************************************************************* ** @@ -310,7 +310,7 @@ BNEP_API extern tBNEP_RESULT BNEP_ConnectResp (UINT16 handle, tBNEP_RESULT resp) ** BNEP_WRONG_HANDLE if no connection is not found ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_Disconnect (UINT16 handle); +extern tBNEP_RESULT BNEP_Disconnect (UINT16 handle); /******************************************************************************* ** @@ -333,12 +333,12 @@ BNEP_API extern tBNEP_RESULT BNEP_Disconnect (UINT16 handle); ** BNEP_SUCCESS - If written successfully ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_WriteBuf (UINT16 handle, - UINT8 *p_dest_addr, - BT_HDR *p_buf, - UINT16 protocol, - UINT8 *p_src_addr, - BOOLEAN fw_ext_present); +extern tBNEP_RESULT BNEP_WriteBuf (UINT16 handle, + UINT8 *p_dest_addr, + BT_HDR *p_buf, + UINT16 protocol, + UINT8 *p_src_addr, + BOOLEAN fw_ext_present); /******************************************************************************* ** @@ -362,13 +362,13 @@ BNEP_API extern tBNEP_RESULT BNEP_WriteBuf (UINT16 handle, ** BNEP_SUCCESS - If written successfully ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_Write (UINT16 handle, - UINT8 *p_dest_addr, - UINT8 *p_data, - UINT16 len, - UINT16 protocol, - UINT8 *p_src_addr, - BOOLEAN fw_ext_present); +extern tBNEP_RESULT BNEP_Write (UINT16 handle, + UINT8 *p_dest_addr, + UINT8 *p_data, + UINT16 len, + UINT16 protocol, + UINT8 *p_src_addr, + BOOLEAN fw_ext_present); /******************************************************************************* ** @@ -387,10 +387,10 @@ BNEP_API extern tBNEP_RESULT BNEP_Write (UINT16 handle, ** BNEP_SUCCESS - if request sent successfully ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle, - UINT16 num_filters, - UINT16 *p_start_array, - UINT16 *p_end_array); +extern tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle, + UINT16 num_filters, + UINT16 *p_start_array, + UINT16 *p_end_array); /******************************************************************************* ** @@ -411,22 +411,10 @@ BNEP_API extern tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle, ** BNEP_SUCCESS - if request sent successfully ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle, - UINT16 num_filters, - UINT8 *p_start_array, - UINT8 *p_end_array); - -/******************************************************************************* -** -** Function BNEP_GetMyBdAddr -** -** Description This function returns a pointer to the local device BD address. -** If the BD address has not been read yet, it returns NULL. -** -** Returns the BD address -** -*******************************************************************************/ -BNEP_API extern UINT8 *BNEP_GetMyBdAddr (void); +extern tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle, + UINT16 num_filters, + UINT8 *p_start_array, + UINT8 *p_end_array); /******************************************************************************* ** @@ -438,7 +426,7 @@ BNEP_API extern UINT8 *BNEP_GetMyBdAddr (void); ** Returns the new (current) trace level ** *******************************************************************************/ -BNEP_API extern UINT8 BNEP_SetTraceLevel (UINT8 new_level); +extern UINT8 BNEP_SetTraceLevel (UINT8 new_level); /******************************************************************************* ** @@ -450,7 +438,7 @@ BNEP_API extern UINT8 BNEP_SetTraceLevel (UINT8 new_level); ** Returns void ** *******************************************************************************/ -BNEP_API extern void BNEP_Init (void); +extern void BNEP_Init (void); /******************************************************************************* ** @@ -464,7 +452,7 @@ BNEP_API extern void BNEP_Init (void); ** BNEP_WRONG_STATE - if not in connected state ** *******************************************************************************/ -BNEP_API extern tBNEP_RESULT BNEP_GetStatus (UINT16 handle, tBNEP_STATUS *p_status); +extern tBNEP_RESULT BNEP_GetStatus (UINT16 handle, tBNEP_STATUS *p_status); diff --git a/stack/include/bt_types.h b/stack/include/bt_types.h index 617eaf3a6..441cd1754 100644 --- a/stack/include/bt_types.h +++ b/stack/include/bt_types.h @@ -19,14 +19,38 @@ #ifndef BT_TYPES_H #define BT_TYPES_H -#include "data_types.h" +#include <stdint.h> +#include <stdbool.h> -#ifdef _WIN32 -#ifdef BLUESTACK_TESTER - #include "bte_stack_entry.h" +#ifndef FALSE +# define FALSE false #endif + +#ifndef TRUE +# define TRUE true +#endif + +typedef uint8_t UINT8; +typedef uint16_t UINT16; +typedef uint32_t UINT32; +typedef uint64_t UINT64; + +typedef int8_t INT8; +typedef int16_t INT16; +typedef int32_t INT32; +typedef bool BOOLEAN; + +#ifdef __arm +# define PACKED __packed +# define INLINE __inline +#else +# define PACKED +# define INLINE #endif +#define BCM_STRCPY_S(x1,x2,x3) strcpy((x1),(x3)) +#define BCM_STRNCPY_S(x1,x2,x3,x4) strncpy((x1),(x3),(x4)) + /* READ WELL !! ** ** This section defines global events. These are events that cross layers. @@ -87,15 +111,8 @@ #define BT_EVT_TO_TCS_CMDS 0x3000 -#define BT_EVT_TO_OBX_CL_MSG 0x3100 -#define BT_EVT_TO_OBX_SR_MSG 0x3200 - #define BT_EVT_TO_CTP_CMDS 0x3300 -/* Obex Over L2CAP */ -#define BT_EVT_TO_OBX_CL_L2C_MSG 0x3400 -#define BT_EVT_TO_OBX_SR_L2C_MSG 0x3500 - /* ftp events */ #define BT_EVT_TO_FTP_SRVR_CMDS 0x3600 #define BT_EVT_TO_FTP_CLNT_CMDS 0x3700 @@ -109,16 +126,6 @@ /* gap events */ #define BT_EVT_TO_GAP_MSG 0x3b00 -/* start timer */ -#define BT_EVT_TO_START_TIMER 0x3c00 - -/* stop timer */ -#define BT_EVT_TO_STOP_TIMER 0x3d00 - -/* start quick timer */ -#define BT_EVT_TO_START_QUICK_TIMER 0x3e00 - - /* for NFC */ /************************************/ #define BT_EVT_TO_NFC_NCI 0x4000 /* NCI Command, Notification or Data*/ @@ -128,12 +135,6 @@ #define BT_EVT_TO_NFCCSIM_NCI 0x4a00 /* events to NFCC simulation (NCI packets) */ -/* start timer */ -#define BT_EVT_TO_START_TIMER_ONESHOT 0x4c00 - -/* stop timer */ -#define BT_EVT_TO_STOP_TIMER_ONESHOT 0x4d00 - /* HCISU Events */ #define BT_EVT_HCISU 0x5000 @@ -196,11 +197,6 @@ #define BT_EVT_BTIF 0xA000 #define BT_EVT_CONTEXT_SWITCH_EVT (0x0001 | BT_EVT_BTIF) -#define BT_EVT_TRIGGER_STACK_INIT EVENT_MASK(APPL_EVT_0) -#define BT_EVT_HARDWARE_INIT_FAIL EVENT_MASK(APPL_EVT_1) - -#define BT_EVT_PRELOAD_CMPL EVENT_MASK(APPL_EVT_6) - /* Define the header of each buffer used in the Bluetooth stack. */ typedef struct @@ -269,6 +265,9 @@ typedef struct #define STREAM_TO_ARRAY(a, p, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;} #define REVERSE_STREAM_TO_ARRAY(a, p, len) {register int ijk; register UINT8 *_pa = (UINT8 *)a + len - 1; for (ijk = 0; ijk < len; ijk++) *_pa-- = *p++;} +#define STREAM_SKIP_UINT8(p) do { (p) += 1; } while (0) +#define STREAM_SKIP_UINT16(p) do { (p) += 2; } while (0) + /******************************************************************************** ** Macros to get and put bytes to and from a field (Little Endian format). ** These are the same as to stream, except the pointer is not incremented. @@ -568,8 +567,6 @@ typedef UINT8 tBT_DEVICE_TYPE; #define TRACE_LAYER_OBEX 0x000c0000 #define TRACE_LAYER_BTM 0x000d0000 #define TRACE_LAYER_GAP 0x000e0000 -#define TRACE_LAYER_DUN 0x000f0000 -#define TRACE_LAYER_GOEP 0x00100000 #define TRACE_LAYER_ICP 0x00110000 #define TRACE_LAYER_HSP2 0x00120000 #define TRACE_LAYER_SPP 0x00130000 @@ -702,5 +699,99 @@ typedef UINT8 tBT_DEVICE_TYPE; /* Define a function for logging */ typedef void (BT_LOG_FUNC) (int trace_type, const char *fmt_str, ...); +/* bd addr length and type */ +#ifndef BD_ADDR_LEN +#define BD_ADDR_LEN 6 +typedef uint8_t BD_ADDR[BD_ADDR_LEN]; +#endif + +// From bd.c + +/***************************************************************************** +** Constants +*****************************************************************************/ + +/* global constant for "any" bd addr */ +static const BD_ADDR bd_addr_any = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; +static const BD_ADDR bd_addr_null= {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +/***************************************************************************** +** Functions +*****************************************************************************/ + +/******************************************************************************* +** +** Function bdcpy +** +** Description Copy bd addr b to a. +** +** +** Returns void +** +*******************************************************************************/ +inline void bdcpy(BD_ADDR a, const BD_ADDR b) +{ + int i; + + for (i = BD_ADDR_LEN; i != 0; i--) + { + *a++ = *b++; + } +} + +/******************************************************************************* +** +** Function bdcmp +** +** Description Compare bd addr b to a. +** +** +** Returns Zero if b==a, nonzero otherwise (like memcmp). +** +*******************************************************************************/ +inline int bdcmp(const BD_ADDR a, const BD_ADDR b) +{ + int i; + + for (i = BD_ADDR_LEN; i != 0; i--) + { + if (*a++ != *b++) + { + return -1; + } + } + return 0; +} + +/******************************************************************************* +** +** Function bdcmpany +** +** Description Compare bd addr to "any" bd addr. +** +** +** Returns Zero if a equals bd_addr_any. +** +*******************************************************************************/ +static inline int bdcmpany(const BD_ADDR a) +{ + return bdcmp(a, bd_addr_any); +} + +/******************************************************************************* +** +** Function bdsetany +** +** Description Set bd addr to "any" bd addr. +** +** +** Returns void +** +*******************************************************************************/ +static inline void bdsetany(BD_ADDR a) +{ + bdcpy(a, bd_addr_any); +} #endif + diff --git a/stack/include/btm_api.h b/stack/include/btm_api.h index dbd0fb2fb..731ac3462 100644 --- a/stack/include/btm_api.h +++ b/stack/include/btm_api.h @@ -411,7 +411,6 @@ typedef UINT8 (tBTM_FILTER_CB) (BD_ADDR bd_addr, DEV_CLASS dc); /* BTM service definitions ** Used for storing EIR data to bit mask */ -#ifndef BTM_EIR_UUID_LKUP_TBL enum { BTM_EIR_UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER, @@ -488,7 +487,6 @@ enum BTM_EIR_UUID_SERVCLASS_HDP_SINK, BTM_EIR_MAX_SERVICES }; -#endif /* BTM_EIR_UUID_LKUP_TBL */ /* search result in EIR of inquiry database */ #define BTM_EIR_FOUND 0 @@ -611,10 +609,8 @@ typedef struct UINT8 page_scan_per_mode; UINT8 page_scan_mode; INT8 rssi; /* Set to BTM_INQ_RES_IGNORE_RSSI if not valid */ -#if (BTM_EIR_CLIENT_INCLUDED == TRUE) UINT32 eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE]; BOOLEAN eir_complete_list; -#endif #if (BLE_INCLUDED == TRUE) tBT_DEVICE_TYPE device_type; UINT8 inq_result_type; @@ -635,15 +631,6 @@ typedef struct BOOLEAN appl_knows_rem_name; /* set by application if it knows the remote name of the peer device. This is later used by application to determine if remote name request is required to be done. Having the flag here avoid duplicate store of inquiry results */ - - -#if (BTM_INQ_GET_REMOTE_NAME == TRUE || BLE_INCLUDED == TRUE) - UINT16 remote_name_len; - tBTM_BD_NAME remote_name; - UINT8 remote_name_state; - UINT8 remote_name_type; -#endif - } tBTM_INQ_INFO; @@ -724,17 +711,6 @@ typedef void (tBTM_INQ_RESULTS_CB) (tBTM_INQ_RESULTS *p_inq_results, UINT8 *p_ei ** ACL Types ****************/ -/* Structure returned with link policy information (in tBTM_CMPL_CB callback function) -** in response to BTM_ReadLinkPolicy call. -*/ -typedef struct -{ - tBTM_STATUS status; - UINT8 hci_status; - BD_ADDR rem_bda; - UINT16 settings; -} tBTM_LNK_POLICY_RESULTS; - /* Structure returned with Role Switch information (in tBTM_CMPL_CB callback function) ** in response to BTM_SwitchRole call. */ @@ -745,17 +721,6 @@ typedef struct BD_ADDR remote_bd_addr; /* Remote BD addr involved with the switch */ } tBTM_ROLE_SWITCH_CMPL; - -/* Structure returned with Change Link Key information (in tBTM_CMPL_CB callback function) -** in response to BTM_ChangeLinkKey call. -*/ -typedef struct -{ - UINT8 hci_status; /* HCI status returned with the event */ - BD_ADDR remote_bd_addr; /* Remote BD addr involved with the change link key */ -} tBTM_CHANGE_KEY_CMPL; - - /* Structure returned with QoS information (in tBTM_CMPL_CB callback function) ** in response to BTM_SetQoS call. */ @@ -976,6 +941,8 @@ typedef UINT8 tBTM_SCO_ROUTE_TYPE; /******************* ** SCO Codec Types ********************/ +// TODO(google) This should use common definitions +// in hci/include/hci_audio.h #define BTM_SCO_CODEC_NONE 0x0000 #define BTM_SCO_CODEC_CVSD 0x0001 #define BTM_SCO_CODEC_MSBC 0x0002 @@ -1350,13 +1317,6 @@ typedef UINT8 (tBTM_AUTHORIZE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class, typedef UINT8 (tBTM_PIN_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class, tBTM_BD_NAME bd_name); - -/* Get Link Key for the connection. Parameters are -** BD Address of remote -** Link Key -*/ -typedef UINT8 (tBTM_LINK_KEY_REQ_CALLBACK) (BD_ADDR bd_addr, LINK_KEY key); - /* New Link Key for the connection. Parameters are ** BD Address of remote ** Link Key @@ -1384,14 +1344,6 @@ typedef void (tBTM_RMT_NAME_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dc, typedef UINT8 (tBTM_AUTH_COMPLETE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class, tBTM_BD_NAME bd_name, int result); -/* Operation abort. Called by the stack when link goes down during. Pin code -** request or authorization. Parameters are -** BD Address of remote -** -*/ -typedef UINT8 (tBTM_ABORT_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class, - tBTM_BD_NAME bd_name); - enum { BTM_SP_IO_REQ_EVT, /* received IO_CAPABILITY_REQUEST event */ @@ -1752,9 +1704,7 @@ typedef struct tBTM_AUTHORIZE_CALLBACK *p_authorize_callback; tBTM_PIN_CALLBACK *p_pin_callback; tBTM_LINK_KEY_CALLBACK *p_link_key_callback; - tBTM_LINK_KEY_REQ_CALLBACK *p_link_key_req_callback; tBTM_AUTH_COMPLETE_CALLBACK *p_auth_complete_callback; - tBTM_ABORT_CALLBACK *p_abort_callback; tBTM_BOND_CANCEL_CMPL_CALLBACK *p_bond_cancel_cmpl_callback; tBTM_SP_CALLBACK *p_sp_callback; #if BLE_INCLUDED == TRUE @@ -1829,90 +1779,16 @@ typedef void (tBTM_PM_STATUS_CBACK) (BD_ADDR p_bda, tBTM_PM_STATUS status, /************************ ** Stored Linkkey Types *************************/ -#define BTM_CB_EVT_RETURN_LINK_KEYS 1 -#define BTM_CB_EVT_READ_STORED_LINK_KEYS 2 -#define BTM_CB_EVT_WRITE_STORED_LINK_KEYS 3 #define BTM_CB_EVT_DELETE_STORED_LINK_KEYS 4 typedef struct { UINT8 event; - -} tBTM_STORED_LINK_KEYS_EVT; - - -typedef struct -{ - UINT8 event; - UINT8 num_keys; - -} tBTM_RETURN_LINK_KEYS_EVT; - - -typedef struct -{ - BD_ADDR bd_addr; - LINK_KEY link_key; - -} tBTM_BD_ADDR_LINK_KEY_PAIR; - - -typedef struct -{ - UINT8 event; - UINT8 status; - UINT16 max_keys; - UINT16 read_keys; - -} tBTM_READ_STORED_LINK_KEY_COMPLETE; - - -typedef struct -{ - UINT8 event; - UINT8 status; - UINT8 num_keys; - -} tBTM_WRITE_STORED_LINK_KEY_COMPLETE; - - -typedef struct -{ - UINT8 event; UINT8 status; UINT16 num_keys; } tBTM_DELETE_STORED_LINK_KEY_COMPLETE; - -/* These macros are defined to check the Broadcom features supported in controller - * (the return value for BTM_ReadBrcmFeatures() */ -/* multi-av */ -#define BTM_FEATURE_MULTI_AV_MASK 0x01 -#define BTM_FEATURE_MULTI_AV_OFF 0 -#define BTM_VSC_MULTI_AV_SUPPORTED(x) ((x)[BTM_FEATURE_MULTI_AV_OFF] & BTM_FEATURE_MULTI_AV_MASK) - -/* WBS SBC codec */ -#define BTM_FEATURE_WBS_SBC_MASK 0x02 -#define BTM_FEATURE_WBS_SBC_OFF 0 -#define BTM_VSC_WBS_SBC_SUPPORTED(x) ((x)[BTM_FEATURE_WBS_SBC_OFF] & BTM_FEATURE_WBS_SBC_MASK) - -/* Advanced Audio LC-PLC */ -#define BTM_FEATURE_AUDIO_LC_PLC_MASK 0x04 -#define BTM_FEATURE_AUDIO_LC_PLC_OFF 0 -#define BTM_VSC_AUDIO_LC_PLC_SUPPORTED(x) ((x)[BTM_FEATURE_AUDIO_LC_PLC_OFF] & BTM_FEATURE_AUDIO_LC_PLC_MASK) - -/* Light stack for audio routing in Controller */ -#define BTM_FEATURE_LIGHT_STACK_MASK 0x08 -#define BTM_FEATURE_LIGHT_STACK_OFF 0 -#define BTM_VSC_LIGHT_STACK_SUPPORTED(x) ((x)[BTM_FEATURE_LIGHT_STACK_OFF] & BTM_FEATURE_LIGHT_STACK_MASK) - -/* NFC support */ -#define BTM_FEATURE_NFC_MASK (HCI_BRCM_FEATURE_NFC_MASK) /* 0x10 */ -#define BTM_FEATURE_NFC_OFF (HCI_BRCM_FEATURE_NFC_OFF) /* 0 */ -#define BTM_VSC_NFC_SUPPORTED(x) ((x)[BTM_FEATURE_NFC_OFF] & BTM_FEATURE_NFC_MASK) - - /* MIP evnets, callbacks */ enum { @@ -1995,28 +1871,6 @@ extern "C" { /******************************************************************************* ** -** Function BTM_SetAfhChannels -** -** Description This function is called to disable channels -** -** Returns status -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetAfhChannels (UINT8 first, UINT8 last); - -/******************************************************************************* -** -** Function BTM_SetAfhChannelAssessment -** -** Description This function is called to set the channel assessment mode on or off -** -** Returns status -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetAfhChannelAssessment (BOOLEAN enable_or_disable); - -/******************************************************************************* -** ** Function BTM_DeviceReset ** ** Description This function is called to reset the controller.The Callback function @@ -2026,7 +1880,7 @@ extern "C" { ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_DeviceReset (tBTM_CMPL_CB *p_cb); +extern void BTM_DeviceReset (tBTM_CMPL_CB *p_cb); /******************************************************************************* @@ -2038,7 +1892,7 @@ extern "C" { ** Returns TRUE if device is up, else FALSE ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_IsDeviceUp (void); +extern BOOLEAN BTM_IsDeviceUp (void); /******************************************************************************* @@ -2050,7 +1904,7 @@ extern "C" { ** Returns BTM_CMD_STARTED if successful, otherwise an error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetLocalDeviceName (char *p_name); +extern tBTM_STATUS BTM_SetLocalDeviceName (char *p_name); /******************************************************************************* ** @@ -2061,7 +1915,7 @@ extern "C" { ** Returns BTM_SUCCESS if successful, otherwise an error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetDeviceClass (DEV_CLASS dev_class); +extern tBTM_STATUS BTM_SetDeviceClass (DEV_CLASS dev_class); /******************************************************************************* @@ -2077,7 +1931,7 @@ extern "C" { ** is returned and p_name is set to NULL ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name); +extern tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name); /******************************************************************************* ** @@ -2089,45 +1943,7 @@ extern "C" { ** Returns BTM_CMD_STARTED if successful, otherwise an error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cmpl_cback); - -/******************************************************************************* -** -** Function BTM_ReadLocalVersion -** -** Description This function is called to read the local device version -** -** Returns BTM_SUCCESS if successful, otherwise an error -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadLocalVersion (tBTM_VERSION_INFO *p_vers); - - -/******************************************************************************* -** -** Function BTM_ReadLocalDeviceAddr -** -** Description This function is called to read the local device address -** -** Returns BTM_SUCCESS -** Callback returns the local device address -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadLocalDeviceAddr (tBTM_CMPL_CB *p_cb); - - -/******************************************************************************* -** -** Function BTM_GetLocalDeviceAddr -** -** Description This function is called to read the local device address -** -** Returns void -** the local device address is copied into bd_addr -** -*******************************************************************************/ - BTM_API extern void BTM_GetLocalDeviceAddr (BD_ADDR bd_addr); - +extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cmpl_cback); /******************************************************************************* ** @@ -2138,7 +1954,7 @@ extern "C" { ** Returns pointer to the device class ** *******************************************************************************/ - BTM_API extern UINT8 *BTM_ReadDeviceClass (void); +extern UINT8 *BTM_ReadDeviceClass (void); /******************************************************************************* @@ -2150,30 +1966,7 @@ extern "C" { ** Returns pointer to the local features string ** *******************************************************************************/ - BTM_API extern UINT8 *BTM_ReadLocalFeatures (void); - -/******************************************************************************* -** -** Function BTM_ReadLocalExtendedFeatures -** -** Description This function is called to read the local extended features -** -** Returns pointer to the local extended features mask or NULL if bad -** page -** -*******************************************************************************/ - BTM_API extern UINT8 *BTM_ReadLocalExtendedFeatures (UINT8 page_number); - -/******************************************************************************* -** -** Function BTM_ReadBrcmFeatures -** -** Description This function is called to read the Broadcom specific features -** -** Returns pointer to the Broadcom features string -** -*******************************************************************************/ - BTM_API extern UINT8 *BTM_ReadBrcmFeatures (void); +extern UINT8 *BTM_ReadLocalFeatures (void); /******************************************************************************* ** @@ -2186,7 +1979,7 @@ extern "C" { ** registration. ** *******************************************************************************/ - BTM_API extern tBTM_DEV_STATUS_CB *BTM_RegisterForDeviceStatusNotif (tBTM_DEV_STATUS_CB *p_cb); +extern tBTM_DEV_STATUS_CB *BTM_RegisterForDeviceStatusNotif (tBTM_DEV_STATUS_CB *p_cb); /******************************************************************************* @@ -2204,25 +1997,7 @@ extern "C" { ** registered. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_RegisterForVSEvents (tBTM_VS_EVT_CB *p_cb, BOOLEAN is_register); - - -/******************************************************************************* -** -** Function BTM_ContinueReset -** -** Description Instructs stack to continue its stack initialization after -** an application has completed any vender specific commands -** sent to the controller. -** -** Note: This function is only called if an application -** initialization function has been inserted in the reset -** sequence. (BTM_APP_DEV_INIT is defined with a function). -** -** Returns void -** -*******************************************************************************/ - BTM_API extern void BTM_ContinueReset (void); +extern tBTM_STATUS BTM_RegisterForVSEvents (tBTM_VS_EVT_CB *p_cb, BOOLEAN is_register); /******************************************************************************* @@ -2239,10 +2014,10 @@ extern "C" { ** prior command. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode, - UINT8 param_len, - UINT8 *p_param_buf, - tBTM_VSC_CMPL_CB *p_cb); +extern tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode, + UINT8 param_len, + UINT8 *p_param_buf, + tBTM_VSC_CMPL_CB *p_cb); /******************************************************************************* @@ -2255,7 +2030,7 @@ extern "C" { ** Returns Allocated SCN number or 0 if none. ** *******************************************************************************/ - BTM_API extern UINT8 BTM_AllocateSCN(void); +extern UINT8 BTM_AllocateSCN(void); // btla-specific ++ /******************************************************************************* @@ -2267,7 +2042,7 @@ extern "C" { ** Returns Returns TRUE if server channel was available ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); +extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); // btla-specific -- @@ -2280,7 +2055,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns TRUE if successful, FALSE if SCN is not in use or invalid ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_FreeSCN(UINT8 scn); +extern BOOLEAN BTM_FreeSCN(UINT8 scn); /******************************************************************************* @@ -2293,7 +2068,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns The new or current trace level ** *******************************************************************************/ - BTM_API extern UINT8 BTM_SetTraceLevel (UINT8 new_level); +extern UINT8 BTM_SetTraceLevel (UINT8 new_level); /******************************************************************************* @@ -2307,7 +2082,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_NO_RESOURCES If out of resources to send the command. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout); +extern tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout); /******************************************************************************* ** @@ -2322,7 +2097,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings); +extern tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings); /******************************************************************************* ** @@ -2339,7 +2114,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_EnableTestMode(void); +extern tBTM_STATUS BTM_EnableTestMode(void); /***************************************************************************** @@ -2362,8 +2137,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window, - UINT16 interval); +extern tBTM_STATUS BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window, + UINT16 interval); /******************************************************************************* @@ -2380,8 +2155,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_GENERAL_DISCOVERABLE ** *******************************************************************************/ - BTM_API extern UINT16 BTM_ReadDiscoverability (UINT16 *p_window, - UINT16 *p_interval); +extern UINT16 BTM_ReadDiscoverability (UINT16 *p_window, + UINT16 *p_interval); /******************************************************************************* @@ -2411,9 +2186,9 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms, - UINT16 max_delay, UINT16 min_delay, - tBTM_INQ_RESULTS_CB *p_results_cb); +extern tBTM_STATUS BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms, + UINT16 max_delay, UINT16 min_delay, + tBTM_INQ_RESULTS_CB *p_results_cb); /******************************************************************************* @@ -2445,9 +2220,9 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, - tBTM_INQ_RESULTS_CB *p_results_cb, - tBTM_CMPL_CB *p_cmpl_cb); +extern tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, + tBTM_INQ_RESULTS_CB *p_results_cb, + tBTM_CMPL_CB *p_cmpl_cb); /******************************************************************************* @@ -2462,7 +2237,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active ** *******************************************************************************/ - BTM_API extern UINT16 BTM_IsInquiryActive (void); +extern UINT16 BTM_IsInquiryActive (void); /******************************************************************************* @@ -2476,7 +2251,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_CancelInquiry(void); +extern tBTM_STATUS BTM_CancelInquiry(void); /******************************************************************************* @@ -2491,21 +2266,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_CancelPeriodicInquiry(void); - - -/******************************************************************************* -** -** Function BTM_SetInquiryFilterCallback -** -** Description Host can register to be asked whenever an inquiry result -** is received. If host does not like the device no name -** request is issued for the device -** -** Returns void -** -*******************************************************************************/ - BTM_API extern void BTM_SetInquiryFilterCallback(tBTM_FILTER_CB *p_callback); +extern tBTM_STATUS BTM_CancelPeriodicInquiry(void); /******************************************************************************* @@ -2521,8 +2282,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window, - UINT16 interval); +extern tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window, + UINT16 interval); /******************************************************************************* @@ -2537,7 +2298,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_NON_CONNECTABLE or BTM_CONNECTABLE ** *******************************************************************************/ - BTM_API extern UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval); +extern UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval); /******************************************************************************* @@ -2556,7 +2317,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BT_API extern tBTM_STATUS BTM_SetInquiryMode (UINT8 mode); +extern tBTM_STATUS BTM_SetInquiryMode (UINT8 mode); /******************************************************************************* ** @@ -2572,7 +2333,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BT_API extern tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type); +extern tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type); /******************************************************************************* ** @@ -2589,7 +2350,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** *******************************************************************************/ - BT_API extern tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type); +extern tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type); /******************************************************************************* ** @@ -2613,9 +2374,9 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if the device is not up. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda, - tBTM_CMPL_CB *p_cb, - tBT_TRANSPORT transport); +extern tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda, + tBTM_CMPL_CB *p_cb, + tBT_TRANSPORT transport); /******************************************************************************* @@ -2634,7 +2395,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_WRONG_MODE if there is not an active remote name request. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_CancelRemoteDeviceName (void); +extern tBTM_STATUS BTM_CancelRemoteDeviceName (void); /******************************************************************************* ** @@ -2645,10 +2406,10 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_SUCCESS if successful, otherwise an error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadRemoteVersion (BD_ADDR addr, - UINT8 *lmp_version, - UINT16 *manufacturer, - UINT16 *lmp_sub_version); +extern tBTM_STATUS BTM_ReadRemoteVersion (BD_ADDR addr, + UINT8 *lmp_version, + UINT16 *manufacturer, + UINT16 *lmp_sub_version); /******************************************************************************* ** @@ -2663,7 +2424,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns pointer to the remote supported features mask ** *******************************************************************************/ - BTM_API extern UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr); +extern UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr); /******************************************************************************* ** @@ -2682,7 +2443,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** or NULL if page_number is not valid ** *******************************************************************************/ - BTM_API extern UINT8 *BTM_ReadRemoteExtendedFeatures (BD_ADDR addr, UINT8 page_number); +extern UINT8 *BTM_ReadRemoteExtendedFeatures (BD_ADDR addr, UINT8 page_number); /******************************************************************************* ** @@ -2694,7 +2455,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns number of features pages read from the remote device ** *******************************************************************************/ - BTM_API extern UINT8 BTM_ReadNumberRemoteFeaturesPages (BD_ADDR addr); +extern UINT8 BTM_ReadNumberRemoteFeaturesPages (BD_ADDR addr); /******************************************************************************* ** @@ -2709,36 +2470,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1). ** *******************************************************************************/ - BTM_API extern UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr); - -/******************************************************************************* -** -** Function BTM_InqFirstResult -** -** Description This function looks through the inquiry database for the first -** used entrysince the LAST inquiry. This is used in conjunction -** with BTM_InqNext by applications as a way to walk through the -** inquiry results database. -** -** Returns pointer to first in-use entry, or NULL if DB is empty -** -*******************************************************************************/ - BTM_API extern tBTM_INQ_INFO *BTM_InqFirstResult (void); - - -/******************************************************************************* -** -** Function BTM_InqNextResult -** -** Description This function looks through the inquiry database for the next -** used entrysince the LAST inquiry. If the input parameter is NULL, -** the first entry is returned. -** -** Returns pointer to next in-use entry, or NULL if no more found. -** -*******************************************************************************/ - BTM_API extern tBTM_INQ_INFO *BTM_InqNextResult (tBTM_INQ_INFO *p_cur); - +extern UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr); /******************************************************************************* ** @@ -2751,7 +2483,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns pointer to entry, or NULL if not found ** *******************************************************************************/ - BTM_API extern tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda); +extern tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda); /******************************************************************************* @@ -2766,7 +2498,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns pointer to first in-use entry, or NULL if DB is empty ** *******************************************************************************/ - BTM_API extern tBTM_INQ_INFO *BTM_InqDbFirst (void); +extern tBTM_INQ_INFO *BTM_InqDbFirst (void); /******************************************************************************* @@ -2780,7 +2512,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns pointer to next in-use entry, or NULL if no more found. ** *******************************************************************************/ - BTM_API extern tBTM_INQ_INFO *BTM_InqDbNext (tBTM_INQ_INFO *p_cur); +extern tBTM_INQ_INFO *BTM_InqDbNext (tBTM_INQ_INFO *p_cur); /******************************************************************************* @@ -2797,30 +2529,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** is active, otherwise BTM_SUCCESS ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda); - - -/******************************************************************************* -** -** Function BTM_ReadNumInqDbEntries -** -** Returns This function returns the number of entries in the inquiry database. -** -*******************************************************************************/ - BTM_API extern UINT8 BTM_ReadNumInqDbEntries (void); - - -/******************************************************************************* -** -** Function BTM_InquiryRegisterForChanges -** -** Description This function is called to register a callback for when the -** inquiry database changes, i.e. new entry or entry deleted. -** -** Returns BTM_SUCCESS if successful, otherwise error code -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_InquiryRegisterForChanges (tBTM_INQ_DB_CHANGE_CB *p_cb); +extern tBTM_STATUS BTM_ClearInqDb (BD_ADDR p_bda); /******************************************************************************* ** @@ -2833,21 +2542,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_SUCCESS if successful ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb); - -/******************************************************************************* -** -** Function BTM_WriteInquiryTxPower -** -** Description This command is used to write the inquiry transmit power level -** used to transmit the inquiry (ID) data packets. The Controller -** should use the supported TX power level closest to the Tx_Power -** parameter. -** -** Returns BTM_SUCCESS if successful -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_WriteInquiryTxPower (INT8 tx_power); +extern tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb); /******************************************************************************* ** @@ -2864,8 +2559,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_ERR_PROCESSING if err initiating the command ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_StartDiscovery (tBTM_CMPL_CB *p_cmpl_cb, - BD_ADDR_PTR p_rem_addr); +extern tBTM_STATUS BTM_StartDiscovery (tBTM_CMPL_CB *p_cmpl_cb, + BD_ADDR_PTR p_rem_addr); /******************************************************************************* @@ -2879,8 +2574,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns Pointer to matching record, or NULL ** *******************************************************************************/ - BTM_API extern tSDP_DISC_REC *BTM_FindAttribute (UINT16 attr_id, - tSDP_DISC_REC *p_start_rec); +extern tSDP_DISC_REC *BTM_FindAttribute (UINT16 attr_id, + tSDP_DISC_REC *p_start_rec); /******************************************************************************* @@ -2894,8 +2589,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns Pointer to matching record, or NULL ** *******************************************************************************/ - BTM_API extern tSDP_DISC_REC *BTM_FindService (UINT16 service_uuid, - tSDP_DISC_REC *p_start_rec); +extern tSDP_DISC_REC *BTM_FindService (UINT16 service_uuid, + tSDP_DISC_REC *p_start_rec); /******************************************************************************* @@ -2909,8 +2604,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_SetDiscoveryParams (UINT16 num_uuid, tSDP_UUID *p_uuid_list, - UINT16 num_attr, UINT16 *p_attr_list); +extern void BTM_SetDiscoveryParams (UINT16 num_uuid, tSDP_UUID *p_uuid_list, + UINT16 num_attr, UINT16 *p_attr_list); /***************************************************************************** @@ -2925,24 +2620,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetLinkPolicy (BD_ADDR remote_bda, - UINT16 *settings); - - -/******************************************************************************* -** -** Function BTM_ReadLinkPolicy -** -** Description This function is called to read the link policy settings. -** The address of link policy results are returned in the callback. -** (tBTM_LNK_POLICY_RESULTS) -** -** Returns BTM_CMD_STARTED if successfully initiated, otherwise error -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadLinkPolicy (BD_ADDR remote_bda, - tBTM_CMPL_CB *p_cb); - +extern tBTM_STATUS BTM_SetLinkPolicy (BD_ADDR remote_bda, + UINT16 *settings); /******************************************************************************* ** @@ -2954,7 +2633,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_SetDefaultLinkPolicy (UINT16 settings); +extern void BTM_SetDefaultLinkPolicy (UINT16 settings); /******************************************************************************* @@ -2967,7 +2646,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_SetDefaultLinkSuperTout (UINT16 timeout); +extern void BTM_SetDefaultLinkSuperTout (UINT16 timeout); /******************************************************************************* @@ -2979,8 +2658,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda, - UINT16 timeout); +extern tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda, + UINT16 timeout); /******************************************************************************* ** ** Function BTM_GetLinkSuperTout @@ -2990,148 +2669,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns status of the operation ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda, - UINT16 *p_timeout); - -/******************************************************************************* -** -** Function BTM_RegForLstoEvt -** -** Description register for the HCI "Link Supervision Timeout Change" event -** -** Returns void -** -*******************************************************************************/ - BTM_API extern void BTM_RegForLstoEvt (tBTM_LSTO_CBACK *p_cback); - - -/* These next APIs are available if the power manager is not compiled in */ -#if BTM_PWR_MGR_INCLUDED == FALSE -/******************************************************************************* -** -** Function BTM_SetHoldMode -** -** Description This function is called to set a connection into hold mode. -** A check is made if the connection is in sniff or park mode, -** and if yes, the hold mode is ignored. -** -** Returns BTM_CMD_STARTED if successfully initiated, otherwise error -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetHoldMode (BD_ADDR remote_bda, UINT16 min_interval, - UINT16 max_interval); - - -/******************************************************************************* -** -** Function BTM_SetSniffMode -** -** Description This function is called to set a connection into sniff mode. -** A check is made if the connection is already in sniff or park -** mode, and if yes, the sniff mode is ignored. -** -** Returns BTM_CMD_STARTED if successfully initiated, otherwise error -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetSniffMode (BD_ADDR remote_bda, UINT16 min_period, - UINT16 max_period, UINT16 attempt, - UINT16 timeout); - - -/******************************************************************************* -** -** Function BTM_CancelSniffMode -** -** Description This function is called to put a connection out of sniff mode. -** A check is made if the connection is already in sniff mode, -** and if not, the cancel sniff mode is ignored. -** -** Returns BTM_CMD_STARTED if successfully initiated, otherwise error -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_CancelSniffMode (BD_ADDR remote_bda); - - -/******************************************************************************* -** -** Function BTM_SetParkMode -** -** Description This function is called to set a connection into park mode. -** A check is made if the connection is already in sniff or park -** mode, and if yes, the park mode is ignored. -** -** Returns BTM_CMD_STARTED if successfully initiated, otherwise error -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetParkMode (BD_ADDR remote_bda, - UINT16 beacon_min_period, - UINT16 beacon_max_period); - - -/******************************************************************************* -** -** Function BTM_CancelParkMode -** -** Description This function is called to put a connection out of park mode. -** A check is made if the connection is already in park mode, -** and if not, the cancel sniff mode is ignored. -** -** Returns BTM_CMD_STARTED if successfully initiated, otherwise error -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_CancelParkMode (BD_ADDR remote_bda); - - -/******************************************************************************* -** -** Function BTM_ReadAclMode -** -** Description This returns the current mode for a specific -** ACL connection. -** -** Input Param remote_bda - device address of desired ACL connection -** -** Output Param p_mode - address where the current mode is copied into. -** BTM_ACL_MODE_NORMAL -** BTM_ACL_MODE_HOLD -** BTM_ACL_MODE_SNIFF -** BTM_ACL_MODE_PARK -** (valid only if return code is BTM_SUCCESS) -** -** Returns BTM_SUCCESS if successful, -** BTM_UNKNOWN_ADDR if bd addr is not active or bad -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadAclMode (BD_ADDR remote_bda, UINT8 *p_mode); - -#endif /* if BTM_PWR_MGR_INCLUDED == FALSE */ - - -/******************************************************************************* -** -** Function BTM_SetPacketTypes -** -** Description This function is set the packet types used for a specific -** ACL connection, -** -** Returns BTM_CMD_STARTED if successfully initiated, otherwise error -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetPacketTypes (BD_ADDR remote_bda, UINT16 pkt_types); - - -/******************************************************************************* -** -** Function BTM_ReadPacketTypes -** -** Description This function is set the packet types used for the specified -** ACL connection, -** -** Returns packet types supported for the connection, or 0 if no BD address -** -*******************************************************************************/ - BTM_API extern UINT16 BTM_ReadPacketTypes (BD_ADDR remote_bda); - +extern tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda, + UINT16 *p_timeout); /******************************************************************************* ** @@ -3143,7 +2682,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns TRUE if connection is up, else FALSE. ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport); +extern BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport); /******************************************************************************* @@ -3157,7 +2696,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_UNKNOWN_ADDR if no active link with bd addr specified ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role); +extern tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role); @@ -3177,25 +2716,9 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_MODE_UNSUPPORTED if local device does not support role switching ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, - UINT8 new_role, - tBTM_CMPL_CB *p_cb); - -/******************************************************************************* -** -** Function BTM_ChangeLinkKey -** -** Description This function is called to change the link key of the -** connection. -** -** Returns BTM_CMD_STARTED if command issued to controller. -** BTM_NO_RESOURCES if couldn't allocate memory to issue command -** BTM_UNKNOWN_ADDR if no active link with bd addr specified -** BTM_BUSY if the previous command is not completed -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ChangeLinkKey (BD_ADDR remote_bd_addr, - tBTM_CMPL_CB *p_cb); +extern tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr, + UINT8 new_role, + tBTM_CMPL_CB *p_cb); /******************************************************************************* ** @@ -3211,7 +2734,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_BUSY if command is already in progress ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb); +extern tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb); /******************************************************************************* @@ -3229,8 +2752,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_BUSY if command is already in progress ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda, - tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb); +extern tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda, + tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb); /******************************************************************************* ** @@ -3246,7 +2769,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_BUSY if command is already in progress ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadLinkQuality (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb); +extern tBTM_STATUS BTM_ReadLinkQuality (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb); /******************************************************************************* ** @@ -3258,8 +2781,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_SUCCESS if successfully registered, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level, - tBTM_BL_EVENT_MASK evt_mask); +extern tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level, + tBTM_BL_EVENT_MASK evt_mask); /******************************************************************************* ** @@ -3271,7 +2794,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_SUCCESS if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb); +extern tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb); /******************************************************************************* ** @@ -3283,21 +2806,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns UINT16 Number of active ACL links ** *******************************************************************************/ - BTM_API extern UINT16 BTM_GetNumAclLinks (void); - - -/******************************************************************************* -** -** Function BTM_ReadClockOffset -** -** Description This returns the clock offset for a specific -** ACL connection. -** -** Returns clock-offset or 0 if unknown -** -*******************************************************************************/ - BTM_API extern UINT16 BTM_ReadClockOffset (BD_ADDR remote_bda); - +extern UINT16 BTM_GetNumAclLinks (void); /******************************************************************************* ** @@ -3308,8 +2817,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetQoS(BD_ADDR bd, FLOW_SPEC *p_flow, - tBTM_CMPL_CB *p_cb); +extern tBTM_STATUS BTM_SetQoS(BD_ADDR bd, FLOW_SPEC *p_flow, + tBTM_CMPL_CB *p_cb); /***************************************************************************** @@ -3332,10 +2841,10 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** with the sco index used for the connection. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, - UINT16 pkt_types, UINT16 *p_sco_inx, - tBTM_SCO_CB *p_conn_cb, - tBTM_SCO_CB *p_disc_cb); +extern tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig, + UINT16 pkt_types, UINT16 *p_sco_inx, + tBTM_SCO_CB *p_conn_cb, + tBTM_SCO_CB *p_disc_cb); /******************************************************************************* @@ -3347,7 +2856,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_RemoveSco (UINT16 sco_inx); +extern tBTM_STATUS BTM_RemoveSco (UINT16 sco_inx); /******************************************************************************* @@ -3370,7 +2879,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetScoPacketTypes (UINT16 sco_inx, UINT16 pkt_types); +extern tBTM_STATUS BTM_SetScoPacketTypes (UINT16 sco_inx, UINT16 pkt_types); /******************************************************************************* @@ -3391,7 +2900,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns packet types supported for the connection ** *******************************************************************************/ - BTM_API extern UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx); +extern UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx); /******************************************************************************* @@ -3404,7 +2913,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns packet types supported by the device. ** *******************************************************************************/ - BTM_API extern UINT16 BTM_ReadDeviceScoPacketTypes (void); +extern UINT16 BTM_ReadDeviceScoPacketTypes (void); /******************************************************************************* @@ -3417,7 +2926,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns handle for the connection, or 0xFFFF if invalid SCO index. ** *******************************************************************************/ - BTM_API extern UINT16 BTM_ReadScoHandle (UINT16 sco_inx); +extern UINT16 BTM_ReadScoHandle (UINT16 sco_inx); /******************************************************************************* @@ -3430,7 +2939,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns pointer to BD address or NULL if not known ** *******************************************************************************/ - BTM_API extern UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx); +extern UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx); /******************************************************************************* @@ -3444,7 +2953,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set. ** *******************************************************************************/ - BTM_API extern UINT16 BTM_ReadScoDiscReason (void); +extern UINT16 BTM_ReadScoDiscReason (void); /******************************************************************************* @@ -3460,8 +2969,8 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** BTM_BUSY if there are one or more active (e)SCO links. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode, - tBTM_ESCO_PARAMS *p_parms); +extern tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode, + tBTM_ESCO_PARAMS *p_parms); /******************************************************************************* ** @@ -3474,7 +2983,7 @@ BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn); ** ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); +extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); /******************************************************************************* ** @@ -3489,8 +2998,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_ILLEGAL_VALUE if there is an illegal sco_inx ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_RegForEScoEvts (UINT16 sco_inx, - tBTM_ESCO_CBACK *p_esco_cback); +extern tBTM_STATUS BTM_RegForEScoEvts (UINT16 sco_inx, + tBTM_ESCO_CBACK *p_esco_cback); /******************************************************************************* ** @@ -3513,8 +3022,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** 1.2 specification. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadEScoLinkParms (UINT16 sco_inx, - tBTM_ESCO_DATA *p_parms); +extern tBTM_STATUS BTM_ReadEScoLinkParms (UINT16 sco_inx, + tBTM_ESCO_DATA *p_parms); /******************************************************************************* ** @@ -3535,8 +3044,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** 1.2 specification. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx, - tBTM_CHG_ESCO_PARAMS *p_parms); +extern tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx, + tBTM_CHG_ESCO_PARAMS *p_parms); /******************************************************************************* ** @@ -3556,8 +3065,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_EScoConnRsp (UINT16 sco_inx, UINT8 hci_status, - tBTM_ESCO_PARAMS *p_parms); +extern void BTM_EScoConnRsp (UINT16 sco_inx, UINT8 hci_status, + tBTM_ESCO_PARAMS *p_parms); /******************************************************************************* ** @@ -3568,7 +3077,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns UINT8 ** *******************************************************************************/ - BTM_API extern UINT8 BTM_GetNumScoLinks (void); +extern UINT8 BTM_GetNumScoLinks (void); /***************************************************************************** ** SECURITY MANAGEMENT FUNCTIONS @@ -3584,21 +3093,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns TRUE if registered OK, else FALSE ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_SecRegister (tBTM_APPL_INFO *p_cb_info); - - -/******************************************************************************* -** -** Function BTM_SecRegisterLinkKeyNotificationCallback -** -** Description Profiles can register to be notified when a new Link Key -** is generated per connection. -** -** Returns TRUE if registered OK, else FALSE -** -*******************************************************************************/ - BTM_API extern BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback ( - tBTM_LINK_KEY_CALLBACK *p_callback); +extern BOOLEAN BTM_SecRegister (tBTM_APPL_INFO *p_cb_info); /******************************************************************************* @@ -3611,8 +3106,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns TRUE if registered OK, else FALSE ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_SecAddRmtNameNotifyCallback ( - tBTM_RMT_NAME_CALLBACK *p_callback); +extern BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback); /******************************************************************************* @@ -3625,36 +3119,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns TRUE if OK, else FALSE ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_SecDeleteRmtNameNotifyCallback ( - tBTM_RMT_NAME_CALLBACK *p_callback); - - -/******************************************************************************* -** -** Function BTM_SecSetConnectFilterCallback -** -** Description Host can register to be asked whenever an HCI connection -** request is received. In the registered function host -** suppose to check connectibility filters. Yes/No result -** should be returned synchronously. -** -** Returns void -** -*******************************************************************************/ - BTM_API extern void BTM_SecSetConnectFilterCallback (tBTM_FILTER_CB *p_callback); - - -/******************************************************************************* -** -** Function BTM_GetSecurityMode -** -** Description Get security mode for the device -** -** Returns void -** -*******************************************************************************/ - BTM_API extern UINT8 BTM_GetSecurityMode (void); - +extern BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback); /******************************************************************************* ** @@ -3665,7 +3130,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns BOOLEAN TRUE or FALSE is device found ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 * p_sec_flags); +extern BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 * p_sec_flags); /******************************************************************************* ** @@ -3680,8 +3145,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns BOOLEAN TRUE or FALSE is device found ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr, - UINT8 * p_sec_flags, tBT_TRANSPORT transport); +extern BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr, + UINT8 * p_sec_flags, tBT_TRANSPORT transport); /******************************************************************************* ** @@ -3693,20 +3158,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** otherwise, the trusted mask ** *******************************************************************************/ - BTM_API extern UINT32 * BTM_ReadTrustedMask (BD_ADDR bd_addr); - - -/******************************************************************************* -** -** Function BTM_SetSecurityMode -** -** Description Set security mode for the device -** -** Returns void -** -*******************************************************************************/ - BTM_API extern void BTM_SetSecurityMode (UINT8 sec_mode); - +extern UINT32 * BTM_ReadTrustedMask (BD_ADDR bd_addr); /******************************************************************************* ** @@ -3717,7 +3169,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len); +extern void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len); /******************************************************************************* @@ -3734,7 +3186,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired); +extern void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired); /******************************************************************************* ** @@ -3748,27 +3200,10 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns TRUE if registered OK, else FALSE ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name, - UINT8 service_id, UINT16 sec_level, - UINT16 psm, UINT32 mx_proto_id, - UINT32 mx_chan_id); - -/******************************************************************************* -** -** Function BTM_SetUCDSecurityLevel -** -** Description Register UCD service security level with Security Manager. Each -** service must register its requirements regardless of the -** security level that is used. This API is called once for originators -** and again for acceptors of connections. -** -** Returns TRUE if registered OK, else FALSE -** -*******************************************************************************/ - BTM_API extern BOOLEAN BTM_SetUCDSecurityLevel (BOOLEAN is_originator, char *p_name, - UINT8 service_id, UINT16 sec_level, - UINT16 psm, UINT32 mx_proto_id, - UINT32 mx_chan_id); +extern BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name, + UINT8 service_id, UINT16 sec_level, + UINT16 psm, UINT32 mx_proto_id, + UINT32 mx_chan_id); /******************************************************************************* ** @@ -3780,7 +3215,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id); +extern void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id); /******************************************************************************* ** @@ -3795,21 +3230,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns Number of records that were freed. ** *******************************************************************************/ - BTM_API extern UINT8 BTM_SecClrService (UINT8 service_id); - -/******************************************************************************* -** -** Function BTM_SecClrUCDService -** -** Description -** -** Parameters Service ID - Id of the service to remove. ('0' removes all service -** records. -** -** Returns Number of records that were freed. -** -*******************************************************************************/ - BTM_API extern UINT8 BTM_SecClrUCDService (UINT8 service_id); +extern UINT8 BTM_SecClrService (UINT8 service_id); /******************************************************************************* ** @@ -3823,10 +3244,10 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, - BD_NAME bd_name, UINT8 *features, - UINT32 trusted_mask[], LINK_KEY link_key, - UINT8 key_type, tBTM_IO_CAP io_cap); +extern BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, + BD_NAME bd_name, UINT8 *features, + UINT32 trusted_mask[], LINK_KEY link_key, + UINT8 key_type, tBTM_IO_CAP io_cap); /******************************************************************************* @@ -3838,35 +3259,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns TRUE if rmoved OK, FALSE if not found ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr); - - -/******************************************************************************* -** -** Function BTM_SecUseMasterLinkKey -** -** Description This function is called to tell master of the piconet to -** switch to master link key -** -** Returns BTM_SUCCESS if command is successully initiated -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SecUseMasterLinkKey (BOOLEAN use_master_key); - - -/******************************************************************************* -** -** Function BTM_SetMasterKeyCompCback -** -** Description This function is called to register for the master key complete -** status event. -** -** Parameters: mkey_cback - callback registered with the security manager -** -** Returns void -** -*******************************************************************************/ - BTM_API extern void BTM_SetMasterKeyCompCback(tBTM_MKEY_CALLBACK *mkey_cback ); +extern BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr); /******************************************************************************* @@ -3881,8 +3274,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns BTM_SUCCESS if successful, otherwise error code ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr, - LINK_KEY link_key); +extern tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr, + LINK_KEY link_key); /******************************************************************************* @@ -3901,25 +3294,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns void ** *******************************************************************************/ - BTM_API extern void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, - UINT8 *p_pin, UINT32 trusted_mask[]); - - -/******************************************************************************* -** -** Function BTM_DeviceAuthorized -** -** Description This function is called after Security Manager submitted -** authorization request to the UI. -** -** Parameters: bd_addr - Address of the device for which PIN was requested -** res - result of the operation BTM_SUCCESS if success -** -** Returns void -** -*******************************************************************************/ - BTM_API extern void BTM_DeviceAuthorized (BD_ADDR bd_addr, UINT8 res, - UINT32 trusted_mask[]); +extern void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, + UINT8 *p_pin, UINT32 trusted_mask[]); /******************************************************************************* @@ -3936,9 +3312,9 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, - UINT8 pin_len, UINT8 *p_pin, - UINT32 trusted_mask[]); +extern tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr, + UINT8 pin_len, UINT8 *p_pin, + UINT32 trusted_mask[]); /******************************************************************************* ** @@ -3955,10 +3331,10 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr, - tBT_TRANSPORT transport, - UINT8 pin_len, UINT8 *p_pin, - UINT32 trusted_mask[]); +extern tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr, + tBT_TRANSPORT transport, + UINT8 pin_len, UINT8 *p_pin, + UINT32 trusted_mask[]); /******************************************************************************* ** @@ -3970,7 +3346,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns BTM_CMD_STARTED if successfully initiated, otherwise error ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr); +extern tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr); /******************************************************************************* ** @@ -3997,8 +3373,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_MODE_UNSUPPORTED - if security manager not linked in. ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, - tBTM_SEC_CBACK *p_callback, void *p_ref_data); +extern tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, + tBTM_SEC_CBACK *p_callback, void *p_ref_data); /******************************************************************************* ** @@ -4011,7 +3387,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** bd_addr - Address of the peer device ** *******************************************************************************/ - BTM_API extern void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr); +extern void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr); /******************************************************************************* ** @@ -4025,7 +3401,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** passkey - numeric value in the range of 0 - 999999(0xF423F). ** *******************************************************************************/ - BTM_API extern void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey); +extern void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey); /******************************************************************************* ** @@ -4041,7 +3417,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** type - notification type ** *******************************************************************************/ - BTM_API extern void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type); +extern void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type); /******************************************************************************* ** @@ -4058,8 +3434,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** auth_req- MITM protection required or not. ** *******************************************************************************/ - BTM_API extern void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, - tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req); +extern void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap, + tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req); /******************************************************************************* ** @@ -4069,7 +3445,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** LM ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadLocalOobData(void); +extern tBTM_STATUS BTM_ReadLocalOobData(void); /******************************************************************************* ** @@ -4083,8 +3459,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** r - simple pairing Randomizer C. ** *******************************************************************************/ - BTM_API extern void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, - BT_OCTET16 c, BT_OCTET16 r); +extern void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr, + BT_OCTET16 c, BT_OCTET16 r); /******************************************************************************* ** @@ -4104,8 +3480,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns Number of bytes in p_data. ** *******************************************************************************/ - BTM_API extern UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c, - BT_OCTET16 r, UINT8 name_len); +extern UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c, + BT_OCTET16 r, UINT8 name_len); /******************************************************************************* ** @@ -4122,7 +3498,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** NULL, if the tag is not found. ** *******************************************************************************/ - BTM_API extern UINT8 * BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len); +extern UINT8 * BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len); /******************************************************************************* ** @@ -4134,7 +3510,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns Pointer to the name or NULL ** *******************************************************************************/ - BTM_API extern char *BTM_SecReadDevName (BD_ADDR bd_addr); +extern char *BTM_SecReadDevName (BD_ADDR bd_addr); /***************************************************************************** @@ -4151,8 +3527,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_ILLEGAL_VALUE ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_PmRegister (UINT8 mask, UINT8 *p_pm_id, - tBTM_PM_STATUS_CBACK *p_cb); +extern tBTM_STATUS BTM_PmRegister (UINT8 mask, UINT8 *p_pm_id, + tBTM_PM_STATUS_CBACK *p_cb); /******************************************************************************* @@ -4166,8 +3542,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_UNKNOWN_ADDR if bd addr is not active or bad ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda, - tBTM_PM_PWR_MD *p_mode); +extern tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda, + tBTM_PM_PWR_MD *p_mode); /******************************************************************************* @@ -4190,8 +3566,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_UNKNOWN_ADDR if bd addr is not active or bad ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadPowerMode (BD_ADDR remote_bda, - tBTM_PM_MODE *p_mode); +extern tBTM_STATUS BTM_ReadPowerMode (BD_ADDR remote_bda, + tBTM_PM_MODE *p_mode); /******************************************************************************* ** @@ -4211,21 +3587,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_CMD_STORED if the command is stored ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat, - UINT16 min_rmt_to, UINT16 min_loc_to); - -/******************************************************************************* -** -** Function BTM_IsPowerManagerOn -** -** Description This function is called to check if power manager is included. -** in the BTE version. -** -** Returns TRUE if power manager is compiled in, otherwise FALSE. -** -*******************************************************************************/ - BTM_API extern BOOLEAN BTM_IsPowerManagerOn (void); - +extern tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat, + UINT16 min_rmt_to, UINT16 min_loc_to); /******************************************************************************* ** @@ -4237,45 +3600,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns the handle of the connection, or 0xFFFF if none. ** *******************************************************************************/ - BTM_API extern UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport); - - -/******************************************************************************* -** -** Function BTM_ReadStoredLinkKey -** -** Description This function is called to obtain link key for the specified -** device from the NVRAM storage attached to the Bluetooth -** controller. -** -** Parameters: bd_addr - Address of the device -** p_cb - Call back function to be called to return -** the results -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ReadStoredLinkKey (BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb); - - -/******************************************************************************* -** -** Function BTM_WriteStoredLinkKey -** -** Description This function is called to write link keys for the specified -** device addresses to the NVRAM storage attached to the Bluetooth -** controller. -** -** Parameters: num_keys - Number of link keys -** bd_addr - Addresses of the devices -** link_key - Link Keys to be stored -** p_cb - Call back function to be called to return -** the results -** -*******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_WriteStoredLinkKey (UINT8 num_keys, - BD_ADDR *bd_addr, - LINK_KEY *link_key, - tBTM_CMPL_CB *p_cb); - +extern UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport); /******************************************************************************* ** @@ -4290,7 +3615,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** the results ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb); +extern tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb); /******************************************************************************* ** @@ -4305,7 +3630,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_MODE_UNSUPPORTED - if local device cannot support it ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_WriteEIR( BT_HDR * p_buff ); +extern tBTM_STATUS BTM_WriteEIR( BT_HDR * p_buff ); /******************************************************************************* ** @@ -4320,7 +3645,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns pointer of EIR data ** *******************************************************************************/ - BTM_API extern UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length ); +extern UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length ); /******************************************************************************* ** @@ -4335,7 +3660,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** FALSE - if not found ** *******************************************************************************/ - BTM_API extern BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ); +extern BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ); /******************************************************************************* ** @@ -4351,8 +3676,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_EIR_UNKNOWN - if not found and it is not complete list ** *******************************************************************************/ - BTM_API extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results, - UINT16 uuid16 ); +extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results, + UINT16 uuid16 ); /******************************************************************************* ** @@ -4366,7 +3691,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns None ** *******************************************************************************/ - BTM_API extern void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ); +extern void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ); /******************************************************************************* ** @@ -4380,7 +3705,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns None ** *******************************************************************************/ - BTM_API extern void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ); +extern void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 ); /******************************************************************************* ** @@ -4397,8 +3722,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise ** *******************************************************************************/ - BTM_API extern UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid, UINT8 **p, - UINT8 max_num_uuid16, UINT8 *p_num_uuid16); +extern UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid, UINT8 **p, + UINT8 max_num_uuid16, UINT8 *p_num_uuid16); /******************************************************************************* ** @@ -4421,8 +3746,8 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** BTM_EIR_MORE_128BITS_UUID_TYPE ** *******************************************************************************/ - BTM_API extern UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid, - UINT8 *p_uuid_list, UINT8 max_num_uuid); +extern UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid, + UINT8 *p_uuid_list, UINT8 max_num_uuid); /***************************************************************************** ** SCO OVER HCI @@ -4451,10 +3776,10 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_ConfigScoPath (tBTM_SCO_ROUTE_TYPE path, - tBTM_SCO_DATA_CB *p_sco_data_cb, - tBTM_SCO_PCM_PARAM *p_pcm_param, - BOOLEAN err_data_rpt); +extern tBTM_STATUS BTM_ConfigScoPath (tBTM_SCO_ROUTE_TYPE path, + tBTM_SCO_DATA_CB *p_sco_data_cb, + tBTM_SCO_PCM_PARAM *p_pcm_param, + BOOLEAN err_data_rpt); /******************************************************************************* ** @@ -4477,7 +3802,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** ** *******************************************************************************/ - BTM_API extern tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf); +extern tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf); /******************************************************************************* ** @@ -4488,7 +3813,7 @@ BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type); ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_SetARCMode (UINT8 iface, UINT8 arc_mode, tBTM_VSC_CMPL_CB *p_arc_cb); +extern void BTM_SetARCMode (UINT8 iface, UINT8 arc_mode, tBTM_VSC_CMPL_CB *p_arc_cb); /******************************************************************************* @@ -4500,7 +3825,7 @@ BTM_API extern void BTM_SetARCMode (UINT8 iface, UINT8 arc_mode, tBTM_VSC_CMPL_C ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb); +extern void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb); /******************************************************************************* @@ -4512,7 +3837,7 @@ BTM_API extern void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p ** Returns Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and BTM_CONTRL_IDLE) ** *******************************************************************************/ -BTM_API extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void); +extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void); #ifdef __cplusplus } diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h index 0e7646862..5f93c5359 100644 --- a/stack/include/btm_ble_api.h +++ b/stack/include/btm_ble_api.h @@ -451,6 +451,7 @@ typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_i typedef struct { UINT8 inst_id; + BOOLEAN in_use; UINT8 adv_evt; BD_ADDR rpa; TIMER_LIST_ENT raddr_timer_ent; @@ -843,7 +844,7 @@ extern "C" { ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, +extern BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type); /******************************************************************************* @@ -861,8 +862,8 @@ BTM_API extern BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, - tBTM_LE_KEY_TYPE key_type); +extern BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, + tBTM_LE_KEY_TYPE key_type); /******************************************************************************* ** @@ -875,8 +876,8 @@ BTM_API extern BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_l ** Returns void ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max, - tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map); +extern tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max, + tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map); /******************************************************************************* ** @@ -889,8 +890,8 @@ BTM_API extern tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_in ** Returns void ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, - tBTM_BLE_ADV_DATA *p_data); +extern tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, + tBTM_BLE_ADV_DATA *p_data); /******************************************************************************* ** @@ -906,8 +907,8 @@ BTM_API extern tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max, - tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map); +extern void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max, + tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map); /******************************************************************************* ** @@ -935,8 +936,8 @@ extern void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_window, - tBTM_BLE_SCAN_MODE scan_type); +extern void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_window, + tBTM_BLE_SCAN_MODE scan_type); /******************************************************************************* ** ** Function BTM_BleGetVendorCapabilities @@ -948,7 +949,7 @@ BTM_API extern void BTM_BleSetScanParams(UINT16 scan_interval, UINT16 scan_windo ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); +extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); /******************************************************************************* ** ** Function BTM_BleSetStorageConfig @@ -965,7 +966,7 @@ BTM_API extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); ** Returns tBTM_STATUS ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max, +extern tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max, UINT8 batch_scan_trunc_max, UINT8 batch_scan_notify_threshold, tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback, @@ -988,7 +989,7 @@ BTM_API extern tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max, ** Returns tBTM_STATUS ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode, +extern tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode, UINT32 scan_interval, UINT32 scan_window, tBTM_BLE_DISCARD_RULE discard_rule, tBLE_ADDR_TYPE addr_type, @@ -1005,7 +1006,7 @@ BTM_API extern tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_ ** Returns void ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value); +extern tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value); /******************************************************************************* ** @@ -1019,7 +1020,7 @@ BTM_API extern tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value) ** Returns tBTM_STATUS ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleReadScanReports(tBTM_BLE_SCAN_MODE scan_mode, +extern tBTM_STATUS BTM_BleReadScanReports(tBTM_BLE_SCAN_MODE scan_mode, tBTM_BLE_REF_VALUE ref_value); /******************************************************************************* @@ -1034,7 +1035,7 @@ BTM_API extern tBTM_STATUS BTM_BleReadScanReports(tBTM_BLE_SCAN_MODE scan_mode, ** Returns tBTM_STATUS ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback, +extern tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback, tBTM_BLE_REF_VALUE ref_value); /******************************************************************************* @@ -1048,8 +1049,8 @@ BTM_API extern tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_tr ** Returns status ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, - tBTM_BLE_ADV_DATA *p_data); +extern tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, + tBTM_BLE_ADV_DATA *p_data); /******************************************************************************* ** @@ -1063,8 +1064,8 @@ BTM_API extern tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, ** Returns void ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration, - tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb); +extern tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration, + tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb); /******************************************************************************* @@ -1078,7 +1079,7 @@ BTM_API extern tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration, ** the local device ER is copied into er ** *******************************************************************************/ -BTM_API extern void BTM_GetDeviceIDRoot (BT_OCTET16 ir); +extern void BTM_GetDeviceIDRoot (BT_OCTET16 ir); /******************************************************************************* ** @@ -1091,7 +1092,7 @@ BTM_API extern void BTM_GetDeviceIDRoot (BT_OCTET16 ir); ** the local device ER is copied into er ** *******************************************************************************/ -BTM_API extern void BTM_GetDeviceEncRoot (BT_OCTET16 er); +extern void BTM_GetDeviceEncRoot (BT_OCTET16 er); /******************************************************************************* ** @@ -1103,7 +1104,7 @@ BTM_API extern void BTM_GetDeviceEncRoot (BT_OCTET16 er); ** the local device DHK is copied into dhk ** *******************************************************************************/ -BTM_API extern void BTM_GetDeviceDHK (BT_OCTET16 dhk); +extern void BTM_GetDeviceDHK (BT_OCTET16 dhk); /******************************************************************************* ** @@ -1118,7 +1119,7 @@ BTM_API extern void BTM_GetDeviceDHK (BT_OCTET16 dhk); ** Returns None ** *******************************************************************************/ -BTM_API extern void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res); +extern void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res); /******************************************************************************* ** @@ -1133,7 +1134,7 @@ BTM_API extern void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res); ** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)). ** *******************************************************************************/ -BTM_API extern void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey); +extern void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey); /******************************************************************************* ** @@ -1147,7 +1148,7 @@ BTM_API extern void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 pass ** p_data - simple pairing Randomizer C. ** *******************************************************************************/ -BTM_API extern void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data); +extern void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data); /******************************************************************************* @@ -1166,8 +1167,8 @@ BTM_API extern void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, U ** Returns TRUE if signing sucessul, otherwise FALSE. ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, - BLE_SIGNATURE signature); +extern BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, + BLE_SIGNATURE signature); /******************************************************************************* ** @@ -1184,9 +1185,9 @@ BTM_API extern BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UIN ** Returns TRUE if signature verified correctly; otherwise FALSE. ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, - UINT16 len, UINT32 counter, - UINT8 *p_comp); +extern BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, + UINT16 len, UINT32 counter, + UINT8 *p_comp); /******************************************************************************* ** @@ -1198,7 +1199,7 @@ BTM_API extern BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr, +extern void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr, tBLE_ADDR_TYPE *p_addr_type); @@ -1213,7 +1214,7 @@ BTM_API extern void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_co ** Returns void ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr, +extern BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr, BD_ADDR conn_addr, tBLE_ADDR_TYPE *p_addr_type); @@ -1230,7 +1231,7 @@ BTM_API extern BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr, ** Returns non2. ** *******************************************************************************/ -BTM_API extern void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key); +extern void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key); /******************************************************************************* @@ -1247,7 +1248,7 @@ BTM_API extern void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_ ** Returns void ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE conn_type, +extern BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE conn_type, tBTM_BLE_SEL_CBACK *p_select_cback); /******************************************************************************* @@ -1265,7 +1266,7 @@ BTM_API extern BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE conn_type, ** Returns void ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remote_bda); +extern BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remote_bda); /******************************************************************************* ** @@ -1280,7 +1281,7 @@ BTM_API extern BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remo ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleClearBgConnDev(void); +extern void BTM_BleClearBgConnDev(void); /******************************************************** ** @@ -1300,7 +1301,7 @@ BTM_API extern void BTM_BleClearBgConnDev(void); ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, +extern void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, UINT16 min_conn_int, UINT16 max_conn_int, UINT16 slave_latency, UINT16 supervision_tout); @@ -1316,7 +1317,7 @@ BTM_API extern void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan_window); +extern void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan_window); /****************************************************************************** ** @@ -1329,7 +1330,7 @@ BTM_API extern void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback); +extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback); /******************************************************************************* ** @@ -1344,7 +1345,7 @@ BTM_API extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK ** Returns pointer of ADV data ** *******************************************************************************/ -BTM_API extern UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length); +extern UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length); /******************************************************************************* ** @@ -1358,7 +1359,7 @@ BTM_API extern UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_leng ** p_addr_type: output parameter to read the address type. ** *******************************************************************************/ -BTM_API extern void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, +extern void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR_TYPE *p_addr_type); /******************************************************************************* @@ -1372,7 +1373,7 @@ BTM_API extern void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_ ** Returns status. ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleBroadcast(BOOLEAN start); +extern tBTM_STATUS BTM_BleBroadcast(BOOLEAN start); /******************************************************************************* ** @@ -1387,7 +1388,7 @@ BTM_API extern tBTM_STATUS BTM_BleBroadcast(BOOLEAN start); ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_RegisterScanReqEvt(tBTM_BLE_SCAN_REQ_CBACK *p_scan_req_cback); +extern void BTM_RegisterScanReqEvt(tBTM_BLE_SCAN_REQ_CBACK *p_scan_req_cback); /******************************************************************************* ** @@ -1401,7 +1402,7 @@ BTM_API extern void BTM_RegisterScanReqEvt(tBTM_BLE_SCAN_REQ_CBACK *p_scan_req_c ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleConfigPrivacy(BOOLEAN enable); +extern void BTM_BleConfigPrivacy(BOOLEAN enable); /******************************************************************************* ** @@ -1412,7 +1413,7 @@ BTM_API extern void BTM_BleConfigPrivacy(BOOLEAN enable); ** Returns Return TRUE if local privacy is enabled else FALSE ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_BleLocalPrivacyEnabled(); +extern BOOLEAN BTM_BleLocalPrivacyEnabled(); /******************************************************************************* ** @@ -1423,7 +1424,7 @@ BTM_API extern BOOLEAN BTM_BleLocalPrivacyEnabled(); ** Returns Max multi adv instance count ** *******************************************************************************/ -BTM_API extern UINT8 BTM_BleMaxMultiAdvInstanceCount(); +extern UINT8 BTM_BleMaxMultiAdvInstanceCount(); /******************************************************************************* ** @@ -1438,7 +1439,7 @@ BTM_API extern UINT8 BTM_BleMaxMultiAdvInstanceCount(); ** Returns void ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleSetConnMode(BOOLEAN directed); +extern tBTM_STATUS BTM_BleSetConnMode(BOOLEAN directed); /******************************************************************************* ** @@ -1453,7 +1454,7 @@ BTM_API extern tBTM_STATUS BTM_BleSetConnMode(BOOLEAN directed); ** Returns void ** *******************************************************************************/ -BTM_API extern void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr, +extern void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr, BOOLEAN privacy_on); @@ -1466,7 +1467,7 @@ BTM_API extern void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr, ** Returns void ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda); +extern BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda); /******************************************************************************* ** @@ -1478,7 +1479,7 @@ BTM_API extern BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emo ** ** Return void *******************************************************************************/ -BTM_API extern void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy); +extern void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy); /******************************************************************************* ** @@ -1528,7 +1529,7 @@ void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback); ** Returns TRUE to use LE, FALSE use BR/EDR. ** *******************************************************************************/ -BTM_API extern BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr); +extern BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr); /******************************************************************************* ** @@ -1542,7 +1543,7 @@ BTM_API extern BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr); ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable); +extern tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable); /*******************************************************************************/ /* Multi ADV API */ @@ -1561,7 +1562,7 @@ BTM_API extern tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable); ** Returns status ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params, +extern tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params, tBTM_BLE_MULTI_ADV_CBACK *p_cback, void *p_ref); @@ -1578,7 +1579,7 @@ BTM_API extern tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_para ** Returns status ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params); +extern tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params); /******************************************************************************* ** @@ -1595,7 +1596,7 @@ BTM_API extern tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_AD ** Returns status ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp, +extern tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp, tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p_data); @@ -1610,7 +1611,7 @@ BTM_API extern tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan ** Returns status ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id); +extern tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id); /******************************************************************************* ** @@ -1626,7 +1627,7 @@ BTM_API extern tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id); ** Returns void ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, +extern tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, tBTM_BLE_PF_FILT_INDEX filt_index, tBTM_BLE_PF_FILT_PARAMS *p_filt_params, tBLE_BD_ADDR *p_target, tBTM_BLE_PF_PARAM_CBACK *p_cmpl_cback, @@ -1646,7 +1647,7 @@ BTM_API extern tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, ** Returns tBTM_STATUS ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action, +extern tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_COND_TYPE cond_type, tBTM_BLE_PF_FILT_INDEX filt_index, tBTM_BLE_PF_COND_PARAM *p_cond, @@ -1665,7 +1666,7 @@ BTM_API extern tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP actio ** Returns tBTM_STATUS ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable, +extern tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable, tBTM_BLE_PF_STATUS_CBACK *p_stat_cback, tBTM_BLE_REF_VALUE ref_value); @@ -1680,7 +1681,7 @@ BTM_API extern tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable, ** Returns status ** *******************************************************************************/ -BTM_API extern tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback); +extern tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback); #ifdef __cplusplus } diff --git a/stack/include/btu.h b/stack/include/btu.h index 552653616..ca563016a 100644 --- a/stack/include/btu.h +++ b/stack/include/btu.h @@ -30,10 +30,24 @@ #include "bt_target.h" #include "gki.h" -/* Define the BTU mailbox usage -*/ -#define BTU_HCI_RCV_MBOX TASK_MBOX_0 /* Messages from HCI */ -#define BTU_BTIF_MBOX TASK_MBOX_1 /* Messages to BTIF */ +// HACK(zachoverflow): temporary dark magic +#define BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK 0x1700 // didn't look used in bt_types...here goes nothing +typedef struct { + void (*callback)(BT_HDR *); +} post_to_task_hack_t; + +typedef struct { + void (*callback)(BT_HDR *); + BT_HDR *response; + void *context; +} command_complete_hack_t; + +typedef struct { + void (*callback)(BT_HDR *); + uint8_t status; + BT_HDR *command; + void *context; +} command_status_hack_t; /* callbacks */ @@ -99,12 +113,6 @@ typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr); /* BNEP Timers */ #define BTU_TTYPE_BNEP 50 -/* OBX */ -#define BTU_TTYPE_OBX_CLIENT_TO 51 -#define BTU_TTYPE_OBX_SERVER_TO 52 -#define BTU_TTYPE_OBX_SVR_SESS_TO 53 - - #define BTU_TTYPE_HSP2_SDP_FAIL_TO 55 #define BTU_TTYPE_HSP2_SDP_RTRY_TO 56 @@ -136,12 +144,6 @@ typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr); #define BTU_TTYPE_L2CAP_FCR_ACK 78 #define BTU_TTYPE_L2CAP_INFO 79 -/* BTU internal for BR/EDR and AMP HCI command timeout (reserve up to 3 AMP controller) */ -#define BTU_TTYPE_BTU_CMD_CMPL 80 -#define BTU_TTYPE_BTU_AMP1_CMD_CMPL 81 -#define BTU_TTYPE_BTU_AMP2_CMD_CMPL 82 -#define BTU_TTYPE_BTU_AMP3_CMD_CMPL 83 - #define BTU_TTYPE_MCA_CCB_RSP 98 /* BTU internal timer for BLE activity */ @@ -159,14 +161,6 @@ typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr); #define BTU_TTYPE_UCD_TO 108 - - -/* Define the BTU_TASK APPL events -*/ -#if (defined(NFC_SHARED_TRANSPORT_ENABLED) && (NFC_SHARED_TRANSPORT_ENABLED==TRUE)) -#define BTU_NFC_AVAILABLE_EVT EVENT_MASK(APPL_EVT_0) /* Notifies BTU task that NFC is available (used for shared NFC+BT transport) */ -#endif - /* This is the inquiry response information held by BTU, and available ** to applications. */ @@ -210,18 +204,6 @@ typedef struct #define NFC_CONTROLLER_ID (1) #define BTU_MAX_LOCAL_CTRLS (1 + NFC_MAX_LOCAL_CTRLS) /* only BR/EDR */ -/* AMP HCI control block */ -typedef struct -{ - BUFFER_Q cmd_xmit_q; - BUFFER_Q cmd_cmpl_q; - UINT16 cmd_window; - TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */ -#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE) - BOOLEAN checked_hcisu; -#endif -} tHCI_CMD_CB; - /* Define structure holding BTU variables */ typedef struct @@ -229,26 +211,8 @@ typedef struct tBTU_TIMER_REG timer_reg[BTU_MAX_REG_TIMER]; tBTU_EVENT_REG event_reg[BTU_MAX_REG_EVENT]; - TIMER_LIST_Q quick_timer_queue; /* Timer queue for transport level (100/10 msec)*/ - TIMER_LIST_Q timer_queue; /* Timer queue for normal BTU task (1 second) */ - TIMER_LIST_Q timer_queue_oneshot; /* Timer queue for oneshot BTU tasks */ - - TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */ - - UINT16 hcit_acl_data_size; /* Max ACL data size across HCI transport */ - UINT16 hcit_acl_pkt_size; /* Max ACL packet size across HCI transport */ - /* (this is data size plus 4 bytes overhead) */ - -#if BLE_INCLUDED == TRUE - UINT16 hcit_ble_acl_data_size; /* Max BLE ACL data size across HCI transport */ - UINT16 hcit_ble_acl_pkt_size; /* Max BLE ACL packet size across HCI transport */ - /* (this is data size plus 4 bytes overhead) */ -#endif - BOOLEAN reset_complete; /* TRUE after first ack from device received */ UINT8 trace_level; /* Trace level for HCI layer */ - - tHCI_CMD_CB hci_cmd_cb[BTU_MAX_LOCAL_CTRLS]; /* including BR/EDR */ } tBTU_CB; #ifdef __cplusplus @@ -257,57 +221,55 @@ extern "C" { /* Global BTU data */ #if BTU_DYNAMIC_MEMORY == FALSE -BTU_API extern tBTU_CB btu_cb; +extern tBTU_CB btu_cb; #else -BTU_API extern tBTU_CB *btu_cb_ptr; +extern tBTU_CB *btu_cb_ptr; #define btu_cb (*btu_cb_ptr) #endif -BTU_API extern const BD_ADDR BT_BD_ANY; +extern const BD_ADDR BT_BD_ANY; /* Functions provided by btu_task.c ************************************ */ -BTU_API extern void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); -BTU_API extern void btu_stop_timer (TIMER_LIST_ENT *p_tle); -BTU_API extern void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); -BTU_API extern void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle); - -BTU_API extern UINT32 btu_remaining_time (TIMER_LIST_ENT *p_tle); +extern void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); +extern void btu_stop_timer (TIMER_LIST_ENT *p_tle); +extern void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); +extern void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle); -BTU_API extern void btu_uipc_rx_cback(BT_HDR *p_msg); +extern void btu_uipc_rx_cback(BT_HDR *p_msg); -BTU_API extern void btu_hcif_flush_cmd_queue(void); /* ** Quick Timer */ #if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) -#define QUICK_TIMER_TICKS (GKI_SECS_TO_TICKS (1)/QUICK_TIMER_TICKS_PER_SEC) -BTU_API extern void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); -BTU_API extern void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle); -BTU_API extern void btu_process_quick_timer_evt (void); -BTU_API extern void process_quick_timer_evt (TIMER_LIST_Q *p_tlq); +extern void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); +extern void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle); +extern void btu_process_quick_timer_evt (void); #endif #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE) -BTU_API extern void btu_check_bt_sleep (void); +extern void btu_check_bt_sleep (void); #endif /* Functions provided by btu_hcif.c ************************************ */ -BTU_API extern void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf); -BTU_API extern void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg); -BTU_API extern void btu_hcif_send_host_rdy_for_data(void); -BTU_API extern void btu_hcif_cmd_timeout (UINT8 controller_id); +extern void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf); +extern void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg); +extern void btu_hcif_send_host_rdy_for_data(void); +extern void btu_hcif_cmd_timeout (UINT8 controller_id); /* Functions provided by btu_core.c ************************************ */ -BTU_API extern void btu_init_core(void); -BTU_API extern void BTE_Init(void); -BTU_API extern UINT16 BTU_AclPktSize(void); -BTU_API extern UINT16 BTU_BleAclPktSize(void); +extern void btu_init_core(void); +extern void btu_free_core(void); + +void BTU_StartUp(void); +void BTU_ShutDown(void); + +extern UINT16 BTU_BleAclPktSize(void); #ifdef __cplusplus } diff --git a/stack/include/dyn_mem.h b/stack/include/dyn_mem.h index 3ad83612f..2693ae636 100644 --- a/stack/include/dyn_mem.h +++ b/stack/include/dyn_mem.h @@ -19,15 +19,6 @@ #define DYN_MEM_H /**************************************************************************** -** Define memory usage for GKI (if not defined in bdroid_buildcfg.h) -** The default for GKI is to use static memory allocation for its control -** block. -*/ -#ifndef GKI_DYNAMIC_MEMORY -#define GKI_DYNAMIC_MEMORY FALSE -#endif - -/**************************************************************************** ** Define memory usage for each CORE component (if not defined in bdroid_buildcfg.h) ** The default for each component is to use static memory allocations. */ @@ -55,10 +46,6 @@ #define TCS_DYNAMIC_MEMORY FALSE #endif -#ifndef OBX_DYNAMIC_MEMORY -#define OBX_DYNAMIC_MEMORY FALSE -#endif - #ifndef BNEP_DYNAMIC_MEMORY #define BNEP_DYNAMIC_MEMORY FALSE #endif @@ -111,22 +98,10 @@ #define CTP_DYNAMIC_MEMORY FALSE #endif -#ifndef DUN_DYNAMIC_MEMORY -#define DUN_DYNAMIC_MEMORY FALSE -#endif - #ifndef FTP_DYNAMIC_MEMORY #define FTP_DYNAMIC_MEMORY FALSE #endif -#ifndef GAP_DYNAMIC_MEMORY -#define GAP_DYNAMIC_MEMORY FALSE -#endif - -#ifndef GOEP_DYNAMIC_MEMORY -#define GOEP_DYNAMIC_MEMORY FALSE -#endif - #ifndef HCRP_DYNAMIC_MEMORY #define HCRP_DYNAMIC_MEMORY FALSE #endif @@ -175,13 +150,5 @@ #define BTA_DYNAMIC_MEMORY FALSE #endif -/**************************************************************************** -** Define memory usage for BT Trace (if not defined in bdroid_buildcfg.h) -** The default is to use static memory allocations. -*/ -#ifndef BTTRC_DYNAMIC_MEMORY -#define BTTRC_DYNAMIC_MEMORY FALSE -#endif - #endif /* #ifdef DYN_MEM_H */ diff --git a/stack/include/gap_api.h b/stack/include/gap_api.h index a210f69ef..0d86d0723 100644 --- a/stack/include/gap_api.h +++ b/stack/include/gap_api.h @@ -19,117 +19,10 @@ #ifndef GAP_API_H #define GAP_API_H -#include "profiles_api.h" -#include "btm_api.h" -#include "l2c_api.h" - /***************************************************************************** ** Constants *****************************************************************************/ -/*** GAP Error and Status Codes ***/ -#define GAP_UNSUPPORTED (GAP_ERR_GRP + 0x01) /* Unsupported call */ -#define GAP_EOINQDB (GAP_ERR_GRP + 0x02) /* End of inquiry database marker */ -#define GAP_ERR_BUSY (GAP_ERR_GRP + 0x03) /* The requested function was busy */ -#define GAP_ERR_NO_CTRL_BLK (GAP_ERR_GRP + 0x04) /* No control blocks available */ -#define GAP_ERR_STARTING_CMD (GAP_ERR_GRP + 0x05) /* Error occurred while initiating the command */ -#define GAP_NO_BDADDR_REC (GAP_ERR_GRP + 0x06) /* No Inquiry DB record for BD_ADDR */ -#define GAP_ERR_ILL_MODE (GAP_ERR_GRP + 0x07) /* An illegal mode parameter was detected */ -#define GAP_ERR_ILL_INQ_TIME (GAP_ERR_GRP + 0x08) /* An illegal time parameter was detected */ -#define GAP_ERR_ILL_PARM (GAP_ERR_GRP + 0x09) /* An illegal parameter was detected */ -#define GAP_ERR_REM_NAME (GAP_ERR_GRP + 0x0a) /* Error starting the remote device name request */ -#define GAP_CMD_INITIATED (GAP_ERR_GRP + 0x0b) /* The GAP command was started (result pending) */ -#define GAP_DEVICE_NOT_UP (GAP_ERR_GRP + 0x0c) /* The device was not up; the request was not executed */ -#define GAP_BAD_BD_ADDR (GAP_ERR_GRP + 0x0d) /* The bd addr passed in was not found or invalid */ - -#define GAP_ERR_BAD_HANDLE (GAP_ERR_GRP + 0x0e) /* Bad GAP handle */ -#define GAP_ERR_BUF_OFFSET (GAP_ERR_GRP + 0x0f) /* Buffer offset invalid */ -#define GAP_ERR_BAD_STATE (GAP_ERR_GRP + 0x10) /* Connection is in invalid state */ -#define GAP_NO_DATA_AVAIL (GAP_ERR_GRP + 0x11) /* No data available */ -#define GAP_ERR_CONGESTED (GAP_ERR_GRP + 0x12) /* BT stack is congested */ -#define GAP_ERR_SECURITY (GAP_ERR_GRP + 0x13) /* Security failed */ - -#define GAP_ERR_PROCESSING (GAP_ERR_GRP + 0x14) /* General error processing BTM request */ -#define GAP_ERR_TIMEOUT (GAP_ERR_GRP + 0x15) /* Timeout occurred while processing cmd */ - -/** GAP Events - definitions of GAP return events ***/ -#define GAP_EVT_INQUIRY_RESULTS 0x0001 -#define GAP_EVT_INQUIRY_COMPLETE 0x0002 -#define GAP_EVT_DISCOVERY_COMPLETE 0x0003 -#define GAP_EVT_REM_NAME_COMPLETE 0x0004 -#define GAP_EVT_FIND_ADDR_COMPLETE 0x0005 - -#define GAP_EVT_CONN_OPENED 0x0100 -#define GAP_EVT_CONN_CLOSED 0x0101 -#define GAP_EVT_CONN_DATA_AVAIL 0x0102 -#define GAP_EVT_CONN_CONGESTED 0x0103 -#define GAP_EVT_CONN_UNCONGESTED 0x0104 - -/* Values for 'chan_mode_mask' field */ -/* GAP_ConnOpen() - optional channels to negotiate */ -#define GAP_FCR_CHAN_OPT_BASIC L2CAP_FCR_CHAN_OPT_BASIC -#define GAP_FCR_CHAN_OPT_ERTM L2CAP_FCR_CHAN_OPT_ERTM -#define GAP_FCR_CHAN_OPT_STREAM L2CAP_FCR_CHAN_OPT_STREAM - -/*** discovery of devices ***/ -#define GAP_INQUIRY_NONE BTM_INQUIRY_NONE -#define GAP_GENERAL_INQUIRY BTM_GENERAL_INQUIRY -#define GAP_LIMITED_INQUIRY BTM_LIMITED_INQUIRY - -#if BLE_INCLUDED == TRUE -#define GAP_BLE_INQUIRY_NONE BTM_BLE_INQUIRY_NONE -#define GAP_BLE_GENERAL_INQUIRY BTM_BLE_GENERAL_INQUIRY -#define GAP_BLE_LIMITED_INQUIRY BTM_BLE_LIMITED_INQUIRY -#endif - -/*** discoverable modes ***/ -#define GAP_NON_DISCOVERABLE BTM_NON_DISCOVERABLE -#define GAP_LIMITED_DISCOVERABLE BTM_LIMITED_DISCOVERABLE -#define GAP_GENERAL_DISCOVERABLE BTM_GENERAL_DISCOVERABLE - -/*** Inquiry Filter Condition types (The values are defined in btm_api.h) ***/ -#define GAP_CLR_INQUIRY_FILTER BTM_CLR_INQUIRY_FILTER /* Inquiry Filtering is turned off */ -#define GAP_FILTER_COND_DEVICE_CLASS BTM_FILTER_COND_DEVICE_CLASS /* Filter on device class */ -#define GAP_FILTER_COND_BD_ADDR BTM_FILTER_COND_BD_ADDR /* Filter on device addr */ - -/*** connectability ***/ -#define GAP_NON_CONNECTABLE BTM_NON_CONNECTABLE -#define GAP_CONNECTABLE BTM_CONNECTABLE - -/*** security features ***/ -#define GAP_DISALLOW_PAIRING 0 -#define GAP_ALLOW_PAIRING 1 - -/*** class of device settings ***/ -#define GAP_SET_COD_MAJOR_MINOR 0x01 -#define GAP_SET_COD_SERVICE_CLASS 0x02 /* only set the bits in the input */ -#define GAP_CLR_COD_SERVICE_CLASS 0x04 -#define GAP_SET_COD_ALL 0x08 /* take service class as the input (may clear some set bits!!) */ -#define GAP_INIT_COD 0x0a - -/*** used in connection variables and functions ***/ -#define GAP_INVALID_HANDLE 0xFFFF - -/* This is used to change the criteria for AMP */ -#define GAP_PROTOCOL_ID (UUID_PROTOCOL_UDP) - -/* slave preferred parameter, minimum connection interval */ -#ifndef GAP_SL_CONN_INT_MIN -#define GAP_SL_CONN_INT_MIN 6 -#endif -/* slave preferred parameter, maximum connection interval */ -#ifndef GAP_SL_CONN_INT_MAX -#define GAP_SL_CONN_INT_MAX 20 -#endif -/* slave preferred parameter */ -#ifndef GAP_SL_LATENCY -#define GAP_SL_LATENCY 2 -#endif - -#ifndef GAP_BLE_PRIVACY_RECONN_ADDR_PERM -#define GAP_BLE_PRIVACY_RECONN_ADDR_PERM (GATT_PERM_READ|GATT_PERM_WRITE) -#endif - #ifndef GAP_PREFER_CONN_INT_MAX #define GAP_PREFER_CONN_INT_MAX BTM_BLE_CONN_INT_MIN #endif @@ -149,60 +42,6 @@ /***************************************************************************** ** Type Definitions *****************************************************************************/ -/* -** Callback function for connection services -*/ -typedef void (tGAP_CONN_CALLBACK) (UINT16 gap_handle, UINT16 event); - -/* -** Define the callback function prototypes. Parameters are specific -** to each event and are described below -*/ -typedef void (tGAP_CALLBACK) (UINT16 event, void *p_data); - -typedef tBTM_REMOTE_DEV_NAME tGAP_REMOTE_DEV_NAME; /* see btm_api.h */ -typedef tBTM_INQ_PARMS tGAP_INQ_PARMS; /* see btm_api.h */ -typedef tBTM_INQ_RESULTS tGAP_INQ_RESULTS; /* see btm_api.h */ - -/* Inquiry results structure */ -typedef struct -{ - UINT16 status; - UINT8 num_results; -} tGAP_INQ_CMPL; - -/* Definition of the GAP_FindAddrByName results structure */ -typedef struct -{ - UINT16 status; - BD_ADDR bd_addr; - tBTM_BD_NAME devname; -} tGAP_FINDADDR_RESULTS; - -/** for GAP_SetDeviceClass() **/ -/* Define Class of Device related values - * - * >>> changes to this type need to also be made to tHSP_COD in hsp2_int.h - */ -typedef struct -{ - UINT8 minor; - UINT8 major; - UINT16 service; -} tGAP_COD; - -/*** Constants and functions for device features ***/ -typedef struct -{ - UINT8 lmp_version; - UINT16 mfc_name; - UINT16 lmp_subversion; -} tGAP_LMP_VERSION; - -typedef struct -{ - UINT8 lmp_features[8]; -} tGAP_LMP_FEATURES; typedef struct { @@ -229,482 +68,6 @@ typedef void (tGAP_BLE_RECONN_ADDR_CBACK)(BOOLEAN status, BD_ADDR addr, BD_ADDR /***************************************************************************** ** External Function Declarations *****************************************************************************/ -#ifdef __cplusplus -extern "C" -{ -#endif - -/******************************************************************************* -** -** Function GAP_SetDiscoverableMode -** -** Description This function is called to allow or disallow a service to -** discovered (Inquiry Scans). -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_ILL_PARM if a bad parameter is detected, -** GAP_DEVICE_NOT_UP if the device is not active, -** GAP_ERR_PROCESSING if not enough resources to carry out request -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_SetDiscoverableMode (UINT16 mode, UINT16 duration, - UINT16 interval); - -/******************************************************************************* -** -** Function GAP_ReadDiscoverableMode -** -** Description This function is called to retrieve the current discoverable -** mode for the local device. -** -** Returns GAP_NON_DISCOVERABLE, GAP_LIMITED_DISCOVERABLE, or -** GAP_GENERAL_DISCOVERABLE -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ReadDiscoverableMode (UINT16 *duration, UINT16 *interval); - -/******************************************************************************* -** -** Function GAP_StartInquiry -** -** Description This function initiates a single inquiry. -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_ILL_MODE if a bad mode parameter was passed -** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed -** GAP_ERR_NO_CTRL_BLK if out of control blocks -** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM -** GAP_ERR_BUSY if the device already has an iquiry active -** GAP_DEVICE_NOT_UP if the device is not initialized yet -** GAP_ERR_PROCESSING if any other BTM error was returned -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_StartInquiry (tGAP_INQ_PARMS *p_inq_parms, - tGAP_CALLBACK *p_results_cb, - tGAP_CALLBACK *p_cmpl_cb); - -/******************************************************************************* -** -** Function GAP_StartPeriodicInquiry -** -** Description This function initiates a periodic inquiry. -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_ILL_MODE if a bad mode parameter was passed -** GAP_ERR_ILL_INQ_TIME if a bad interval or duration was passed -** GAP_ERR_NO_CTRL_BLK if out of control blocks -** GAP_ERR_ILL_PARM if a bad parameter was detected in BTM -** GAP_ERR_BUSY if the device already has an iquiry active -** GAP_DEVICE_NOT_UP if the device is not initialized yet -** GAP_ERR_PROCESSING if any other BTM error was returned -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_StartPeriodicInquiry (tGAP_INQ_PARMS *p_inq_parms, - UINT16 min_time, - UINT16 max_time, - tGAP_CALLBACK *p_results_cb); - -/******************************************************************************* -** -** Function GAP_CancelInquiry -** -** Description This function cancels a single inquiry (if in progress) -** -** Returns BOOLEAN (TRUE if successful, otherwise FALSE) -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_CancelInquiry(void); - -/******************************************************************************* -** -** Function GAP_CancelPeriodicInquiry -** -** Description This function cancels a periodic inquiry (if in progress) -** -** Returns BOOLEAN: (TRUE if successful, otherwise FALSE) -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_CancelPeriodicInquiry(void); - -/******************************************************************************* -** -** Function GAP_GetFirstInquiryResult -** -** Description This function retrieves the first valid inquiry result. -** -** Returns BT_PASS (0) if successful, or a non-zero error code -** GAP_EOINQDB if no more entries in the database. -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_GetFirstInquiryResult(tGAP_INQ_RESULTS *p_results); - -/******************************************************************************* -** -** Function GAP_GetNextInquiryResult -** -** Description This function retrieves the next valid inquiry result. -** -** Returns BT_PASS (0) if successful, or a non-zero status code -** GAP_EOINQDB if no more entries in the database. -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_GetNextInquiryResult(tGAP_INQ_RESULTS *p_results); - -/******************************************************************************* -** -** Function GAP_FindAddrByName -** -** Description This function is called to retrieve a device address given -** a device name. It first looks in the current local inquiry -** database for the device with the specified name. If not found -** it initiates a general inquiry. Upon completion, it retrieves -** the name for each device until a match is found or all devices -** have been checked. Note: This process can take a while to -** complete. -** -** Returns BT_PASS if the name was immediately available. (BD_ADDR is returned) -** GAP_CMD_INITIATED if an inquiry has been initiated -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_FindAddrByName (BD_NAME devname, - tGAP_INQ_PARMS *p_inq_parms, - tGAP_CALLBACK *p_addr_cb, - BD_ADDR bd_addr); - -/******************************************************************************* -** -** Function GAP_SetConnectableMode -** -** Description This function is called to allow or disallow a -** connections on the local device. -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_ILL_PARM if a bad parameter is detected, -** GAP_DEVICE_NOT_UP if the device is not active, -** GAP_ERR_PROCESSING if not enough resources to carry out request -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_SetConnectableMode (UINT16 mode, UINT16 duration, - UINT16 interval); - -/******************************************************************************* -** -** Function GAP_ReadConnectableMode -** -** Description This function is called to retrieve the current connectability -** mode for the local device. -** -** Returns GAP_NON_CONNECTABLE, GAP_CONNECTABLE -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ReadConnectableMode (UINT16 *duration, UINT16 *interval); - -/******************************************************************************* -** -** Function GAP_SetSecurityMode -** -** Description Set security mode for the device (Service or Link level) -** -** Returns void -** -*******************************************************************************/ -GAP_API extern void GAP_SetSecurityMode (UINT8 sec_mode); - -/******************************************************************************* -** -** Function GAP_SecRegister -** -** Description Application calls this function to register for -** security services. -** -** Returns TRUE if registered OK, else FALSE -** -*******************************************************************************/ -GAP_API extern BOOLEAN GAP_SecRegister (tBTM_APPL_INFO *p_cb_info); - -/******************************************************************************* -** -** Function GAP_SetPairableMode -** -** Description This function is called to allow or disallow pairing -** on the local device. -** -** Returns BT_PASS (0) if successful, or a non-zero error code -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_SetPairableMode (UINT16 mode, BOOLEAN connect_only_paired); - -/******************************************************************************* -** -** Function GAP_Bond -** -** Description This function is called to initiate bonding with peer device -** -** Parameters: bd_addr - Address of the device to bond -** pin_len - length in bytes of the PIN Code -** p_pin - pointer to array with the PIN Code -** trusted_mask - bitwise OR of trusted services (array of UINT32) -** -** Returns tBTM_STATUS - BTM_CMD_STARTED of successfully initiated -** -*******************************************************************************/ -GAP_API extern UINT8 GAP_Bond (BD_ADDR bd_addr, UINT8 pin_len, - UINT8 *p_pin, UINT32 trusted_mask[]); - -/******************************************************************************* -** -** Function GAP_PinRsp -** -** Description This function is called from UI after Security Manager submitted -** PIN code request. -** -** Returns void -** -*******************************************************************************/ -GAP_API extern void GAP_PinRsp (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, - UINT8 *p_pin, UINT32 trusted_mask[]); - -/******************************************************************************* -** -** Function GAP_AuthorizeRsp -** -** Description This function is called from UI after Security Manager submitted -** an authorization request. -** -** Returns void -** -*******************************************************************************/ -GAP_API extern void GAP_AuthorizeRsp (BD_ADDR bd_addr, UINT8 res, - UINT32 trusted_mask[]); - -/******************************************************************************* -** -** Function GAP_SetDeviceClass -** -** Description This function updates the local Device Class. -** -** Returns BT_PASS (0) if successful, -** GAP_ERR_BUSY if a discovery is already in progress -** GAP_ERR_ILL_PARM if an illegal parameter was detected -** GAP_ERR_PROCESSING if any other BTM error has been returned -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_SetDeviceClass(tGAP_COD *p_cod, UINT8 cmd); - -/******************************************************************************* -** -** Function GAP_ReadDeviceClass -** -** Description This function reads the current local Device Class setting. -** -** Returns BT_PASS -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ReadDeviceClass(tGAP_COD *p_cod); - -/******************************************************************************* -** -** Function GAP_ReadLocalDeviceInfo -** -** Description This function retrieves local device information to the caller. -** NOTE: Return parameters that are set to NULL are not retrieved. -** -** Returns BT_PASS (0) if successful, or a non-zero error code -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ReadLocalDeviceInfo( UINT8 *name, BD_ADDR *addr, - tGAP_LMP_VERSION *verinfo, - tGAP_LMP_FEATURES *features); - - -/******************************************************************************* -** -** Function GAP_GetRemoteDeviceName -** -** Description The remote name is retrieved from the specified remote device. If -** GAP_CMD_INITIATED is returned by the function, the command was -** successfully sent to the controller. The GAP_EVT_NAME_RESP event -** is passed in the callback when the remote device name has been retrieved. -** -** Returns -** GAP_CMD_INITIATED if remote search successfully initiated -** GAP_ERR_BUSY if a remote name request is already in progress, -** GAP_ERR_NO_CTRL_BLK if out of control blocks (too many commands pending) -** GAP_BAD_BD_ADDR if the device address is bad, -** GAP_DEVICE_NOT_UP if the device has not been initialized yet -** GAP_ERR_PROCESSING if any other BTM error has been returned -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_GetRemoteDeviceName (BD_ADDR addr, tGAP_CALLBACK *callback); - -/*** Functions for L2CAP connection interface ***/ -/******************************************************************************* -** -** Function GAP_ConnOpen -** -** Description This function is called to open a generic L2CAP connection. -** -** Returns handle of the connection if successful, else GAP_INVALID_HANDLE -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server, - BD_ADDR p_rem_bda, UINT16 psm, tL2CAP_CFG_INFO *p_cfg, - UINT16 security, UINT8 chan_mode_mask, tGAP_CONN_CALLBACK *p_cb); - -/******************************************************************************* -** -** Function GAP_ConnClose -** -** Description This function is called to close a connection. -** -** Returns BT_PASS - closed OK -** GAP_ERR_BAD_HANDLE - invalid handle -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnClose (UINT16 gap_handle); - -/******************************************************************************* -** -** Function GAP_ConnReadData -** -** Description GKI buffer unaware application will call this function -** after receiving GAP_EVT_RXDATA event. A data copy is made -** into the receive buffer parameter. -** -** Returns BT_PASS - data read -** GAP_ERR_BAD_HANDLE - invalid handle -** GAP_NO_DATA_AVAIL - no data available -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data, - UINT16 max_len, UINT16 *p_len); - -/******************************************************************************* -** -** Function GAP_GetRxQueueCnt -** -** Description This function return number of bytes on the rx queue. -** -** Parameters: handle - Handle returned in the GAP_ConnOpen -** p_rx_queue_count - Pointer to return queue count in. -** -** -*******************************************************************************/ -GAP_API extern int GAP_GetRxQueueCnt (UINT16 handle, UINT32 *p_rx_queue_count); - -/******************************************************************************* -** -** Function GAP_ConnBTRead -** -** Description GKI buffer aware applications will call this function after -** receiving an GAP_EVT_RXDATA event to process the incoming -** data buffer. -** -** Returns BT_PASS - data read -** GAP_ERR_BAD_HANDLE - invalid handle -** GAP_NO_DATA_AVAIL - no data available -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf); - -/******************************************************************************* -** -** Function GAP_ConnBTWrite -** -** Description GKI buffer aware applications can call this function to write data -** by passing a pointer to the GKI buffer of data. -** -** Returns BT_PASS - data read -** GAP_ERR_BAD_HANDLE - invalid handle -** GAP_ERR_BAD_STATE - connection not established -** GAP_INVALID_BUF_OFFSET - buffer offset is invalid -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf); - -/******************************************************************************* -** -** Function GAP_ConnWriteData -** -** Description GKI buffer unaware application will call this function -** to send data to the connection. A data copy is made into a GKI -** buffer. -** -** Returns BT_PASS - data read -** GAP_ERR_BAD_HANDLE - invalid handle -** GAP_ERR_BAD_STATE - connection not established -** GAP_CONGESTION - system is congested -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data, - UINT16 max_len, UINT16 *p_len); - -/******************************************************************************* -** -** Function GAP_ConnReconfig -** -** Description Applications can call this function to reconfigure the connection. -** -** Returns BT_PASS - config process started -** GAP_ERR_BAD_HANDLE - invalid handle -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnReconfig (UINT16 gap_handle, tL2CAP_CFG_INFO *p_cfg); - -/******************************************************************************* -** -** Function GAP_ConnSetIdleTimeout -** -** Description Higher layers call this function to set the idle timeout for -** a connection, or for all future connections. The "idle timeout" -** is the amount of time that a connection can remain up with -** no L2CAP channels on it. A timeout of zero means that the -** connection will be torn down immediately when the last channel -** is removed. A timeout of 0xFFFF means no timeout. Values are -** in seconds. -** -** Returns BT_PASS - config process started -** GAP_ERR_BAD_HANDLE - invalid handle -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnSetIdleTimeout (UINT16 gap_handle, UINT16 timeout); - -/******************************************************************************* -** -** Function GAP_ConnGetRemoteAddr -** -** Description This function is called to get the remote BD address -** of a connection. -** -** Returns BT_PASS - closed OK -** GAP_ERR_BAD_HANDLE - invalid handle -** -*******************************************************************************/ -GAP_API extern UINT8 *GAP_ConnGetRemoteAddr (UINT16 gap_handle); - -/******************************************************************************* -** -** Function GAP_ConnGetRemMtuSize -** -** Description Returns the remote device's MTU size. -** -** Returns UINT16 - maximum size buffer that can be transmitted to the peer -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnGetRemMtuSize (UINT16 gap_handle); - -/******************************************************************************* -** -** Function GAP_ConnGetL2CAPCid -** -** Description Returns the L2CAP channel id -** -** Parameters: handle - Handle of the connection -** -** Returns UINT16 - The L2CAP channel id -** 0, if error -** -*******************************************************************************/ -GAP_API extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle); /******************************************************************************* ** @@ -716,7 +79,7 @@ GAP_API extern UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle); ** Returns The new or current trace level ** *******************************************************************************/ -GAP_API extern UINT8 GAP_SetTraceLevel (UINT8 new_level); +extern UINT8 GAP_SetTraceLevel (UINT8 new_level); /******************************************************************************* ** @@ -729,7 +92,7 @@ GAP_API extern UINT8 GAP_SetTraceLevel (UINT8 new_level); ** Returns Nothing ** *******************************************************************************/ -GAP_API extern void GAP_Init(void); +extern void GAP_Init(void); #if (BLE_INCLUDED == TRUE) /******************************************************************************* @@ -741,7 +104,7 @@ GAP_API extern void GAP_Init(void); ** Returns Nothing ** *******************************************************************************/ -GAP_API extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value); +extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value); /******************************************************************************* @@ -754,7 +117,7 @@ GAP_API extern void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p ** Returns TRUE if read started, else FALSE if GAP is busy ** *******************************************************************************/ -GAP_API extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda); +extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda); /******************************************************************************* ** @@ -765,7 +128,7 @@ GAP_API extern BOOLEAN GAP_BleReadPeerPrefConnParams (BD_ADDR peer_bda); ** Returns TRUE if request accepted ** *******************************************************************************/ -GAP_API extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_DEV_NAME_CBACK *p_cback); +extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_DEV_NAME_CBACK *p_cback); /******************************************************************************* @@ -777,7 +140,7 @@ GAP_API extern BOOLEAN GAP_BleReadPeerDevName (BD_ADDR peer_bda, tGAP_BLE_DEV_NA ** Returns TRUE if request accepted ** *******************************************************************************/ -GAP_API extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda); +extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda); /******************************************************************************* ** @@ -789,15 +152,10 @@ GAP_API extern BOOLEAN GAP_BleCancelReadPeerDevName (BD_ADDR peer_bda); ** Returns TRUE if read started, else FALSE if GAP is busy ** *******************************************************************************/ -GAP_API extern BOOLEAN GAP_BleUpdateReconnectAddr (BD_ADDR peer_bda, - BD_ADDR reconn_addr, - tGAP_BLE_RECONN_ADDR_CBACK *p_cback); - -#endif +extern BOOLEAN GAP_BleUpdateReconnectAddr (BD_ADDR peer_bda, + BD_ADDR reconn_addr, + tGAP_BLE_RECONN_ADDR_CBACK *p_cback); -#ifdef __cplusplus -} #endif #endif /* GAP_API_H */ - diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h index 2c99c0254..3c8b50404 100644 --- a/stack/include/gatt_api.h +++ b/stack/include/gatt_api.h @@ -678,7 +678,7 @@ extern "C" ** Returns The new or current trace level ** *******************************************************************************/ - GATT_API extern UINT8 GATT_SetTraceLevel (UINT8 new_level); +extern UINT8 GATT_SetTraceLevel (UINT8 new_level); /*******************************************************************************/ @@ -699,7 +699,7 @@ extern "C" ** *******************************************************************************/ - GATT_API extern BOOLEAN GATTS_AddHandleRange(tGATTS_HNDL_RANGE *p_hndl_range); +extern BOOLEAN GATTS_AddHandleRange(tGATTS_HNDL_RANGE *p_hndl_range); /******************************************************************************* ** @@ -714,7 +714,7 @@ extern "C" ** Returns TRUE if registered OK, else FALSE ** *******************************************************************************/ - GATT_API extern BOOLEAN GATTS_NVRegister (tGATT_APPL_INFO *p_cb_info); +extern BOOLEAN GATTS_NVRegister (tGATT_APPL_INFO *p_cb_info); /******************************************************************************* @@ -734,8 +734,8 @@ extern "C" ** Returns service handle if sucessful, otherwise 0. ** *******************************************************************************/ - GATT_API extern UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, - UINT16 svc_inst, UINT16 num_handles, BOOLEAN is_pri); +extern UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, + UINT16 svc_inst, UINT16 num_handles, BOOLEAN is_pri); /******************************************************************************* @@ -751,8 +751,8 @@ extern "C" ** fail. ** *******************************************************************************/ - GATT_API extern UINT16 GATTS_AddIncludeService (UINT16 service_handle, - UINT16 include_svc_handle); +extern UINT16 GATTS_AddIncludeService (UINT16 service_handle, + UINT16 include_svc_handle); /******************************************************************************* @@ -773,8 +773,8 @@ extern "C" ** characteristic failed. ** *******************************************************************************/ - GATT_API extern UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *char_uuid, - tGATT_PERM perm,tGATT_CHAR_PROP property); +extern UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *char_uuid, + tGATT_PERM perm,tGATT_CHAR_PROP property); /******************************************************************************* ** @@ -795,8 +795,8 @@ extern "C" ** characteristic descriptor failed. ** *******************************************************************************/ - GATT_API extern UINT16 GATTS_AddCharDescriptor (UINT16 service_handle, tGATT_PERM perm, - tBT_UUID * p_descr_uuid); +extern UINT16 GATTS_AddCharDescriptor (UINT16 service_handle, tGATT_PERM perm, + tBT_UUID * p_descr_uuid); /******************************************************************************* ** @@ -811,8 +811,8 @@ extern "C" ** Returns TRUE if operation succeed, FALSE if handle block was not found. ** *******************************************************************************/ - GATT_API extern BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, - UINT16 svc_inst); +extern BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, + UINT16 svc_inst); /******************************************************************************* ** @@ -827,8 +827,8 @@ extern "C" ** return GATT_SUCCESS if sucessfully started; otherwise error code. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle, - tGATT_TRANSPORT sup_transport); +extern tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle, + tGATT_TRANSPORT sup_transport); /******************************************************************************* @@ -842,7 +842,7 @@ extern "C" ** Returns None. ** *******************************************************************************/ - GATT_API extern void GATTS_StopService (UINT16 service_handle); +extern void GATTS_StopService (UINT16 service_handle); /******************************************************************************* @@ -859,9 +859,9 @@ extern "C" ** Returns GATT_SUCCESS if sucessfully sent or queued; otherwise error code. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, - UINT16 attr_handle, - UINT16 val_len, UINT8 *p_val); +extern tGATT_STATUS GATTS_HandleValueIndication (UINT16 conn_id, + UINT16 attr_handle, + UINT16 val_len, UINT8 *p_val); /******************************************************************************* ** @@ -877,8 +877,8 @@ extern "C" ** Returns GATT_SUCCESS if sucessfully sent; otherwise error code. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle, - UINT16 val_len, UINT8 *p_val); +extern tGATT_STATUS GATTS_HandleValueNotification (UINT16 conn_id, UINT16 attr_handle, + UINT16 val_len, UINT8 *p_val); /******************************************************************************* @@ -895,8 +895,8 @@ extern "C" ** Returns GATT_SUCCESS if sucessfully sent; otherwise error code. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id, - tGATT_STATUS status, tGATTS_RSP *p_msg); +extern tGATT_STATUS GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id, + tGATT_STATUS status, tGATTS_RSP *p_msg); /*******************************************************************************/ @@ -916,7 +916,7 @@ extern "C" ** Returns GATT_SUCCESS if command started successfully. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu); +extern tGATT_STATUS GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu); /******************************************************************************* ** @@ -931,9 +931,9 @@ extern "C" ** Returns GATT_SUCCESS if command received/sent successfully. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTC_Discover (UINT16 conn_id, - tGATT_DISC_TYPE disc_type, - tGATT_DISC_PARAM *p_param ); +extern tGATT_STATUS GATTC_Discover (UINT16 conn_id, + tGATT_DISC_TYPE disc_type, + tGATT_DISC_PARAM *p_param ); /******************************************************************************* ** ** Function GATTC_Read @@ -948,8 +948,8 @@ extern "C" ** Returns GATT_SUCCESS if command started successfully. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, - tGATT_READ_PARAM *p_read); +extern tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, + tGATT_READ_PARAM *p_read); /******************************************************************************* ** @@ -965,8 +965,8 @@ extern "C" ** Returns GATT_SUCCESS if command started successfully. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, - tGATT_VALUE *p_write); +extern tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, + tGATT_VALUE *p_write); /******************************************************************************* @@ -982,7 +982,7 @@ extern "C" ** Returns GATT_SUCCESS if command started successfully. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute); +extern tGATT_STATUS GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute); /******************************************************************************* ** @@ -997,7 +997,7 @@ extern "C" ** Returns GATT_SUCCESS if command started successfully. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle); +extern tGATT_STATUS GATTC_SendHandleValueConfirm (UINT16 conn_id, UINT16 handle); /******************************************************************************* @@ -1014,8 +1014,8 @@ extern "C" ** Returns void ** *******************************************************************************/ - GATT_API extern void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout, - tGATT_TRANSPORT transport); +extern void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout, + tGATT_TRANSPORT transport); /******************************************************************************* @@ -1031,7 +1031,7 @@ extern "C" ** Returns 0 for error, otherwise the index of the client registered with GATT ** *******************************************************************************/ - GATT_API extern tGATT_IF GATT_Register (tBT_UUID *p_app_uuid128, tGATT_CBACK *p_cb_info); +extern tGATT_IF GATT_Register (tBT_UUID *p_app_uuid128, tGATT_CBACK *p_cb_info); /******************************************************************************* ** @@ -1044,7 +1044,7 @@ extern "C" ** Returns None. ** *******************************************************************************/ - GATT_API extern void GATT_Deregister (tGATT_IF gatt_if); +extern void GATT_Deregister (tGATT_IF gatt_if); /******************************************************************************* ** @@ -1059,7 +1059,7 @@ extern "C" ** Returns None ** *******************************************************************************/ - GATT_API extern void GATT_StartIf (tGATT_IF gatt_if); +extern void GATT_StartIf (tGATT_IF gatt_if); /******************************************************************************* ** @@ -1076,8 +1076,8 @@ extern "C" ** Returns TRUE if connection started; FALSE if connection start failure. ** *******************************************************************************/ - GATT_API extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, - BOOLEAN is_direct, tBT_TRANSPORT transport); +extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, + BOOLEAN is_direct, tBT_TRANSPORT transport); /******************************************************************************* @@ -1095,8 +1095,8 @@ extern "C" ** Returns TRUE if connection started; FALSE if connection start failure. ** *******************************************************************************/ - GATT_API extern BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, - BOOLEAN is_direct); +extern BOOLEAN GATT_CancelConnect (tGATT_IF gatt_if, BD_ADDR bd_addr, + BOOLEAN is_direct); /******************************************************************************* ** @@ -1110,7 +1110,7 @@ extern "C" ** Returns GATT_SUCCESS if disconnected. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS GATT_Disconnect (UINT16 conn_id); +extern tGATT_STATUS GATT_Disconnect (UINT16 conn_id); @@ -1129,8 +1129,8 @@ extern "C" ** Returns TRUE the ligical link information is found for conn_id ** *******************************************************************************/ - GATT_API extern BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if, - BD_ADDR bd_addr, tBT_TRANSPORT *p_transport); +extern BOOLEAN GATT_GetConnectionInfor(UINT16 conn_id, tGATT_IF *p_gatt_if, + BD_ADDR bd_addr, tBT_TRANSPORT *p_transport); /******************************************************************************* @@ -1148,8 +1148,8 @@ extern "C" ** Returns TRUE the ligical link is connected ** *******************************************************************************/ - GATT_API extern BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, - UINT16 *p_conn_id, tBT_TRANSPORT transport); +extern BOOLEAN GATT_GetConnIdIfConnected(tGATT_IF gatt_if, BD_ADDR bd_addr, + UINT16 *p_conn_id, tBT_TRANSPORT transport); /******************************************************************************* @@ -1167,7 +1167,7 @@ extern "C" ** Returns TRUE if advertisement is started; FALSE if adv start failure. ** *******************************************************************************/ - GATT_API extern BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr); +extern BOOLEAN GATT_Listen (tGATT_IF gatt_if, BOOLEAN start, BD_ADDR_PTR bd_addr); /******************************************************************************* ** @@ -1178,7 +1178,7 @@ extern "C" ** Returns None. ** *******************************************************************************/ - GATT_API extern void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, +extern void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSPORT transport); #ifdef __cplusplus diff --git a/stack/include/goep_fs.h b/stack/include/goep_fs.h deleted file mode 100644 index c5d054e77..000000000 --- a/stack/include/goep_fs.h +++ /dev/null @@ -1,393 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2000-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. - * - ******************************************************************************/ -#ifndef GOEP_FS_H -#define GOEP_FS_H - -#include "bt_target.h" - -/***************************************************************************** -** Constants -*****************************************************************************/ - -/* Flags passed to the open function (tGOEP_OPEN_CBACK) -** Values are OR'd together. (First 3 are -** mutually exclusive. -*/ -#define GOEP_O_RDONLY 0x0000 -#define GOEP_O_WRONLY 0x0001 -#define GOEP_O_RDWR 0x0002 - -#define GOEP_O_CREAT 0x0100 -#define GOEP_O_EXCL 0x0200 -#define GOEP_O_TRUNC 0x1000 - - -#define GOEP_LEN_UNKNOWN 0xFFFFFFFF -#define GOEP_INVALID_FD (-1) - -/* Values passed to the access function (tGOEP_ACCESS_CBACK) -*/ -#define GOEP_ACC_EXIST 0x0 -#define GOEP_ACC_READ 0x4 -#define GOEP_ACC_RDWR 0x6 - -/* Constants used in directory listing structure */ -#define GOEP_A_RDONLY 0x1 -#define GOEP_A_DIR 0x2 /* Entry is a sub directory */ - -#define GOEP_CTIME_LEN 17 /* Creation time "yyyymmddTHHMMSSZ" */ - -/***************************************************************************** -** Seek Constants -*****************************************************************************/ -/* Origin for the seek function (tGOEP_SEEK_CBACK) */ -#define GOEP_SEEK_SET 0 -#define GOEP_SEEK_CUR 1 -#define GOEP_SEEK_END 2 - - - -/***************************************************************************** -** Typedefs -*****************************************************************************/ -typedef INT32 tGOEP_FD; - -enum -{ - GOEP_OK, - GOEP_FAIL, - GOEP_EACCES, - GOEP_ENOTEMPTY, - GOEP_EOF, - GOEP_EODIR, - GOEP_ENOSPACE, - GOEP_EIS_DIR, - GOEP_RESUME, - GOEP_NONE -}; -typedef UINT16 tGOEP_STATUS; - -/* Structure passed in Directory Entry Callback to be filled in */ -typedef struct -{ - UINT32 refdata; /* holder for OS specific data used to get next entry */ - UINT32 filesize; - char crtime[GOEP_CTIME_LEN]; /* "yyyymmddTHHMMSSZ", or "" if none */ - char *p_name; /* Contains the addr of memory to copy name into */ - UINT8 mode; /* GOEP_A_RDONLY and/or GOEP_A_DIR */ -} tGOEP_DIRENTRY; - - -/***************************************************************************** -** Typedefs for messages from response functions -*****************************************************************************/ -typedef struct -{ - BT_HDR hdr; - tGOEP_FD fd; - tGOEP_STATUS status; - UINT32 file_size; -} tGOEP_OPEN_RSP; - -typedef struct -{ - BT_HDR hdr; - tGOEP_FD fd; - tGOEP_STATUS status; - UINT16 bytes_read; -} tGOEP_READ_RSP; - -typedef struct -{ - BT_HDR hdr; - tGOEP_FD fd; - tGOEP_STATUS status; -} tGOEP_WRITE_RSP; - -typedef struct -{ - BT_HDR hdr; - tGOEP_STATUS status; -} tGOEP_DIRENTRY_RSP; - -/***************************************************************************** -** Object Store Interface -*****************************************************************************/ -/******************************************************************************* -** -** Callback Function: tGOEP_OPEN_CBACK -** -** Description This function is executed by OBX profiles to open -** a file for reading or writing. -** -** Parameters p_path - Fully qualified path and file name. -** flags - permissions and mode (see constants above) -** size - size of file to put (0 if unavailable or not applicable) -** event_id - code that must be passed to the call-in function. -** -** Returns void -** -** Note: Upon completion of the request, a file descriptor (tGOEP_FD), -** file size (UINT32), and an status code (tGOEP_STATUS) -** are returned in GOEP_OpenRsp(). -** -*******************************************************************************/ -typedef void (tGOEP_OPEN_CBACK) (const UINT8 *p_name, UINT16 flags, UINT32 size, - UINT16 event_id, UINT8 app_id); - -/******************************************************************************* -** -** Callback Function: tGOEP_CLOSE_CBACK -** -** Description This function is executed by OBX profiles when the file descriptor -** is no longer in use. -** -** Returns void -** -*******************************************************************************/ -typedef void (tGOEP_CLOSE_CBACK) (tGOEP_FD fd, UINT8 app_id); - -/******************************************************************************* -** -** Callback Function: tGOEP_READ_CBACK -** -** Description This function is executed by OBX profiles to read in data from the -** previously opened file. -** -** Returns void -** -** Note: Upon completion of the request, GOEP_ReadRsp() is -** called with the buffer of data, along with the number -** of bytes read into the buffer, and a status. The -** call-in function should only be called when ALL requested -** bytes have been read, the end of file has been detected, -** or an error has occurred. -** -*******************************************************************************/ -typedef void (tGOEP_READ_CBACK) (tGOEP_FD fd, void *p_data, INT16 size, - UINT16 event_id, UINT8 app_id); - -/******************************************************************************* -** -** Callback Function: tGOEP_WRITE_CBACK -** -** Description This function is executed by OBX profiles to write the data to the -** previously opened file. -** -** Returns void -** -** Note: Upon completion of the request, GOEP_WriteRsp() is -** called with the file descriptor and the status. The -** call-in function should only be called when ALL requested -** bytes have been written, or an error has been detected, -** -*******************************************************************************/ -typedef void (tGOEP_WRITE_CBACK) (tGOEP_FD fd, const void *p_data, INT16 size, - UINT16 event_id, UINT8 app_id); - -/******************************************************************************* -** -** Callback Function: tGOEP_SEEK_CBACK -** -** Description This function is executed by OBX profiles to Move a file pointer -** of a previously opened file to the specified location for the -** next read or write operation. -** -** Returns void -** -*******************************************************************************/ -typedef void (tGOEP_SEEK_CBACK) (tGOEP_FD fd, INT32 offset, INT16 origin, UINT8 app_id); - - -/******************************************************************************* -** -** Callback Function: tGOEP_DIRENTRY_CBACK -** -** Description This function is called to retrieve a directory entry for the -** specified path. The first/next directory should be filled -** into the location specified by p_entry. -** -** Parameters p_path - directory to search (Fully qualified path) -** first_item - TRUE if first search, FALSE if next search -** (p_cur contains previous) -** p_entry (input/output) - Points to last entry data (valid when -** first_item is FALSE) -** event_id - event that must be passed into the call-in function. -** -** Returns void -** -** Note: Upon completion of the request, GOEP_DirentryRsp() is -** filled in entry and the status. -** GOEP_OK is returned when p_entry is valid, -** GOEP_EODIR is returned when no more entries [finished] -** GOEP_FAIL is returned if an error occurred -** -*******************************************************************************/ -typedef void (tGOEP_DIRENTRY_CBACK) (const char *p_path, BOOLEAN first_item, - tGOEP_DIRENTRY *p_entry, UINT16 event_id, - UINT8 app_id); - -/******************************************************************************* -** -** Callback Function: tGOEP_ACCESS_CBACK -** -** Description This function is called to check the existence of a file or -** directory. -** -** Returns (tGOEP_STATUS) status of the call. -** [GOEP_OK if it exists] -** [GOEP_EACCES if permissions are wrong] -** [GOEP_FAIL if it does not exist] -** -*******************************************************************************/ -typedef tGOEP_STATUS (tGOEP_ACCESS_CBACK) (const char *p_path, UINT16 mode, - BOOLEAN *p_is_dir, UINT8 app_id); - -/******************************************************************************* -** -** Callback Function: tGOEP_MKDIR_CBACK -** -** Description This function is called to create a directory with -** the pathname given by path. The pathname is a null terminated -** string. All components of the path must already exist. -** -** Parameters p_path - (input) name of directory to create (fully qualified path). -** -** Returns (tGOEP_STATUS) status of the call. -** [GOEP_OK if successful] -** [GOEP_FAIL if unsuccessful] -** -*******************************************************************************/ -typedef tGOEP_STATUS (tGOEP_MKDIR_CBACK) (const char *p_path, UINT8 app_id); - -/******************************************************************************* -** -** Callback Function: tGOEP_RMDIR_CBACK -** -** Description This function is called to remove a directory whose -** name is given by path. The directory must be empty. -** -** Parameters p_path - (input) name of directory to remove (fully qualified path). -** -** Returns (tGOEP_STATUS) status of the call. -** [GOEP_OK if successful] -** [GOEP_EACCES if read-only] -** [GOEP_ENOTEMPTY if directory is not empty] -** [GOEP_FAIL otherwise] -** -*******************************************************************************/ -typedef tGOEP_STATUS (tGOEP_RMDIR_CBACK) (const char *p_path, UINT8 app_id); - -/******************************************************************************* -** -** Callback Function: tGOEP_UNLINK_CBACK -** -** Description This function is called to remove a directory whose -** name is given by path. The directory must be empty. -** -** Parameters p_path - (input) name of file to remove (fully qualified path). -** -** Returns (tGOEP_STATUS) status of the call. -** [GOEP_OK if successful] -** [GOEP_EACCES if read-only] -** [GOEP_FAIL otherwise] -** -*******************************************************************************/ -typedef tGOEP_STATUS (tGOEP_UNLINK_CBACK) (const char *p_path, UINT8 app_id); - - -/***************************************************************************** -** Prototypes -*****************************************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/***************************************************************************** -** -** Function: GOEP_OpenRsp -** -** Purpose: Report the status of tGOEP_OPEN_CBACK callback function. -** -** Parameters: fd - File handle. -** status - Status of the operation. -** file_size - total number of bytes in this file. -** event_id - event id as given in the tGOEP_OPEN_CBACK function. -** -** Returns: void -** -*****************************************************************************/ -GOEP_API extern void GOEP_OpenRsp (tGOEP_FD fd, tGOEP_STATUS status, - UINT32 file_size, UINT16 event_id); - -/***************************************************************************** -** -** Function: GOEP_ReadRsp -** -** Purpose: Report the status of tGOEP_READ_CBACK callback function. -** -** Parameters: fd - File handle. -** status - Status of the operation. -** bytes_read - total number of bytes read from the file. -** event_id - event id as given in the tGOEP_READ_CBACK function. -** -** Returns: void -** -*****************************************************************************/ -GOEP_API extern void GOEP_ReadRsp (tGOEP_FD fd, tGOEP_STATUS status, - UINT16 bytes_read, UINT16 event_id); - -/***************************************************************************** -** -** Function: GOEP_WriteRsp -** -** Purpose: Report the status of tGOEP_WRITE_CBACK callback function. -** -** Parameters: fd - File handle. -** status - Status of the operation. -** event_id - event id as given in the tGOEP_WRITE_CBACK function. -** -** Returns: void -** -*****************************************************************************/ -GOEP_API extern void GOEP_WriteRsp (tGOEP_FD fd, tGOEP_STATUS status, UINT16 event_id); - -/******************************************************************************* -** -** Function GOEP_DirentryRsp -** -** Description This function is called in response to the -** tGOEP_DIRENTRY_CBACK function with a filled in directory listing -** entry. -** -** Parameters status - GOEP_OK if p_entry points to a valid entry. -** GOEP_EODIR if no more entries (p_entry is ignored). -** GOEP_FAIL if any errors have occurred. -** event_id - event id as given in the tGOEP_DIRENTRY_CBACK function. -** -** Returns void -** -*******************************************************************************/ -GOEP_API extern void GOEP_DirentryRsp(tGOEP_STATUS status, UINT16 event_id); - -#ifdef __cplusplus -} -#endif - -#endif /* GOEP_FS_H */ diff --git a/stack/include/hcidefs.h b/stack/include/hcidefs.h index 0349d6aa7..63a0bc5d4 100644 --- a/stack/include/hcidefs.h +++ b/stack/include/hcidefs.h @@ -218,8 +218,8 @@ #define HCI_READ_BE_FLUSH_TOUT (0x0069 | HCI_GRP_HOST_CONT_BASEBAND_CMDS) #define HCI_WRITE_BE_FLUSH_TOUT (0x006A | HCI_GRP_HOST_CONT_BASEBAND_CMDS) #define HCI_SHORT_RANGE_MODE (0x006B | HCI_GRP_HOST_CONT_BASEBAND_CMDS) /* 802.11 only */ -#define HCI_READ_LE_HOST_SUPPORTED (0x006C | HCI_GRP_HOST_CONT_BASEBAND_CMDS) -#define HCI_WRITE_LE_HOST_SUPPORTED (0x006D | HCI_GRP_HOST_CONT_BASEBAND_CMDS) +#define HCI_READ_LE_HOST_SUPPORT (0x006C | HCI_GRP_HOST_CONT_BASEBAND_CMDS) +#define HCI_WRITE_LE_HOST_SUPPORT (0x006D | HCI_GRP_HOST_CONT_BASEBAND_CMDS) /* MWS coexistence */ @@ -588,14 +588,6 @@ #define HCI_SUPP_LE_STATES_INIT_MASTER_SLAVE_OFF 5 #define HCI_LE_STATES_INIT_MASTER_SLAVE_SUPPORTED(x) ((x)[HCI_SUPP_LE_STATES_INIT_MASTER_SLAVE_OFF] & HCI_SUPP_LE_STATES_INIT_MASTER_SLAVE_MASK) -#define HCI_BRCM_ENABLE_WBS_MODIFIED (0x0102 | HCI_GRP_VENDOR_SPECIFIC) - -/* ConnectionLess Broadcast Stream VSC */ -#define HCI_BRCM_SET_CLB_STREAM (0x0111 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_BRCM_RECEIVE_CLB_STREAM (0x0112 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_BRCM_WRITE_CLB_STREAM_DATA (0x0113 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_BRCM_CLB_STREAM_FLUSH (0x0114 | HCI_GRP_VENDOR_SPECIFIC) - /* ** Definitions for HCI Events */ @@ -1351,164 +1343,9 @@ typedef struct #define LMP_TESTCTL_POWCTL_FIXEDTX_OP 0 #define LMP_TESTCTL_POWCTL_ADAPTIVE 1 - -/* -** Define company IDs (from Bluetooth Assigned Numbers v1.1, section 2.2) -*/ -#define LMP_COMPID_ERICSSON 0 -#define LMP_COMPID_NOKIA 1 -#define LMP_COMPID_INTEL 2 -#define LMP_COMPID_IBM 3 -#define LMP_COMPID_TOSHIBA 4 -#define LMP_COMPID_3COM 5 -#define LMP_COMPID_MICROSOFT 6 -#define LMP_COMPID_LUCENT 7 -#define LMP_COMPID_MOTOROLA 8 -#define LMP_COMPID_INFINEON 9 -#define LMP_COMPID_CSR 10 -#define LMP_COMPID_SILICON_WAVE 11 -#define LMP_COMPID_DIGIANSWER 12 -#define LMP_COMPID_TEXAS_INSTRUMENTS 13 -#define LMP_COMPID_PARTHUS 14 +// TODO(zachoverflow): remove this once broadcom specific hacks are removed #define LMP_COMPID_BROADCOM 15 -#define LMP_COMPID_MITEL_SEMI 16 -#define LMP_COMPID_WIDCOMM 17 -#define LMP_COMPID_ZEEVO 18 -#define LMP_COMPID_ATMEL 19 -#define LMP_COMPID_MITSUBISHI 20 -#define LMP_COMPID_RTX_TELECOM 21 -#define LMP_COMPID_KC_TECH 22 -#define LMP_COMPID_NEWLOGIC 23 -#define LMP_COMPID_TRANSILICA 24 -#define LMP_COMPID_ROHDE_SCHWARZ 25 -#define LMP_COMPID_TTPCOM 26 -#define LMP_COMPID_SIGNIA 27 -#define LMP_COMPID_CONEXANT 28 -#define LMP_COMPID_QUALCOMM 29 -#define LMP_COMPID_INVENTEL 30 -#define LMP_COMPID_AVM 31 -#define LMP_COMPID_BANDSPEED 32 -#define LMP_COMPID_MANSELLA 33 -#define LMP_COMPID_NEC_CORP 34 -#define LMP_COMPID_WAVEPLUS 35 -#define LMP_COMPID_ALCATEL 36 -#define LMP_COMPID_PHILIPS 37 -#define LMP_COMPID_C_TECHNOLOGIES 38 -#define LMP_COMPID_OPEN_INTERFACE 39 -#define LMP_COMPID_RF_MICRO 40 -#define LMP_COMPID_HITACHI 41 -#define LMP_COMPID_SYMBOL_TECH 42 -#define LMP_COMPID_TENOVIS 43 -#define LMP_COMPID_MACRONIX 44 -#define LMP_COMPID_GCT_SEMI 45 -#define LMP_COMPID_NORWOOD_SYSTEMS 46 -#define LMP_COMPID_MEWTEL_TECH 47 -#define LMP_COMPID_STM 48 -#define LMP_COMPID_SYNOPSYS 49 -#define LMP_COMPID_RED_M_LTD 50 -#define LMP_COMPID_COMMIL_LTD 51 -#define LMP_COMPID_CATC 52 -#define LMP_COMPID_ECLIPSE 53 -#define LMP_COMPID_RENESAS_TECH 54 -#define LMP_COMPID_MOBILIAN_CORP 55 -#define LMP_COMPID_TERAX 56 -#define LMP_COMPID_ISSC 57 -#define LMP_COMPID_MATSUSHITA 58 -#define LMP_COMPID_GENNUM_CORP 59 -#define LMP_COMPID_RESEARCH_IN_MOTION 60 -#define LMP_COMPID_IPEXTREME 61 -#define LMP_COMPID_SYSTEMS_AND_CHIPS 62 -#define LMP_COMPID_BLUETOOTH_SIG 63 -#define LMP_COMPID_SEIKO_EPSON_CORP 64 -#define LMP_COMPID_ISS_TAIWAN 65 -#define LMP_COMPID_CONWISE_TECHNOLOGIES 66 -#define LMP_COMPID_PARROT_SA 67 -#define LMP_COMPID_SOCKET_COMM 68 -#define LMP_COMPID_ALTHEROS 69 -#define LMP_COMPID_MEDIATEK 70 -#define LMP_COMPID_BLUEGIGA 71 -#define LMP_COMPID_MARVELL 72 -#define LMP_COMPID_3DSP_CORP 73 -#define LMP_COMPID_ACCEL_SEMICONDUCTOR 74 -#define LMP_COMPID_CONTINENTAL_AUTO 75 -#define LMP_COMPID_APPLE 76 -#define LMP_COMPID_STACCATO 77 -#define LMP_COMPID_AVAGO_TECHNOLOGIES 78 -#define LMP_COMPID_APT_LTD 79 -#define LMP_COMPID_SIRF_TECHNOLOGY 80 -#define LMP_COMPID_TZERO_TECHNOLOGY 81 -#define LMP_COMPID_J_AND_M_CORP 82 -#define LMP_COMPID_FREE_2_MOVE 83 -#define LMP_COMPID_3DIJOY_CORP 84 -#define LMP_COMPID_PLANTRONICS 85 -#define LMP_COMPID_SONY_ERICSSON_MOBILE 86 -#define LMP_COMPID_HARMON_INTL_IND 87 -#define LMP_COMPID_VIZIO 88 -#define LMP_COMPID_NORDIC SEMI 89 -#define LMP_COMPID_EM MICRO 90 -#define LMP_COMPID_RALINK TECH 91 -#define LMP_COMPID_BELKIN INC 92 -#define LMP_COMPID_REALTEK SEMI 93 -#define LMP_COMPID_STONESTREET ONE 94 -#define LMP_COMPID_WICENTRIC 95 -#define LMP_COMPID_RIVIERAWAVES 96 -#define LMP_COMPID_RDA MICRO 97 -#define LMP_COMPID_GIBSON GUITARS 98 -#define LMP_COMPID_MICOMMAND INC 99 -#define LMP_COMPID_BAND XI 100 -#define LMP_COMPID_HP COMPANY 101 -#define LMP_COMPID_9SOLUTIONS OY 102 -#define LMP_COMPID_GN NETCOM 103 -#define LMP_COMPID_GENERAL MOTORS 104 -#define LMP_COMPID_AD ENGINEERING 105 -#define LMP_COMPID_MINDTREE LTD 106 -#define LMP_COMPID_POLAR ELECTRO 107 -#define LMP_COMPID_BEAUTIFUL ENTERPRISE 108 -#define LMP_COMPID_BRIARTEK 109 -#define LMP_COMPID_SUMMIT DATA COMM 110 -#define LMP_COMPID_SOUND ID 111 -#define LMP_COMPID_MONSTER LLC 112 -#define LMP_COMPID_CONNECTBLU 113 - -#define LMP_COMPID_SHANGHAI_SSE 114 -#define LMP_COMPID_GROUP_SENSE 115 -#define LMP_COMPID_ZOMM 116 -#define LMP_COMPID_SAMSUNG 117 -#define LMP_COMPID_CREATIVE_TECH 118 -#define LMP_COMPID_LAIRD_TECH 119 -#define LMP_COMPID_NIKE 120 -#define LMP_COMPID_LESSWIRE 121 -#define LMP_COMPID_MSTAR_SEMI 122 -#define LMP_COMPID_HANLYNN_TECH 123 -#define LMP_COMPID_AR_CAMBRIDGE 124 -#define LMP_COMPID_SEERS_TECH 125 -#define LMP_COMPID_SPORTS_TRACKING 126 -#define LMP_COMPID_AUTONET_MOBILE 127 -#define LMP_COMPID_DELORME_PUBLISH 128 -#define LMP_COMPID_WUXI_VIMICRO 129 -#define LMP_COMPID_SENNHEISER 130 -#define LMP_COMPID_TIME_KEEPING_SYS 131 -#define LMP_COMPID_LUDUS_HELSINKI 132 -#define LMP_COMPID_BLUE_RADIOS 133 -#define LMP_COMPID_EQUINUX 134 -#define LMP_COMPID_GARMIN_INTL 135 -#define LMP_COMPID_ECOTEST 136 -#define LMP_COMPID_GN_RESOUND 137 -#define LMP_COMPID_JAWBONE 138 -#define LMP_COMPID_TOPCON_POSITIONING 139 -#define LMP_COMPID_QUALCOMM_LABS 140 -#define LMP_COMPID_ZSCAN_SOFTWARE 141 -#define LMP_COMPID_QUINTIC 142 -#define LMP_COMPID_STOLLMAN_EV 143 -#define LMP_COMPID_FUNAI_ELECTRONIC 144 -#define LMP_COMPID_ADV_PANMOBILE 145 -#define LMP_COMPID_THINK_OPTICS 146 -#define LMP_COMPID_UNIVERSAL_ELEC 147 -#define LMP_COMPID_AIROHA_TECH 148 -#define LMP_COMPID_MAX_ID 149 /* this is a place holder */ -#define LMP_COMPID_INTERNAL 65535 - -#define MAX_LMP_COMPID (LMP_COMPID_MAX_ID) + /* ** Define the packet types in the packet header, and a couple extra */ @@ -1798,14 +1635,8 @@ typedef struct #define HCI_FEATURE_NON_FLUSHABLE_PB_MASK 0x40 #define HCI_FEATURE_NON_FLUSHABLE_PB_OFF 6 -// btla-specific ++ -#ifdef ANDROID_APP_INCLUDED /* This feature is causing frequent link drops when doing call switch with certain av/hfp headsets */ #define HCI_NON_FLUSHABLE_PB_SUPPORTED(x) (0)//((x)[HCI_FEATURE_NON_FLUSHABLE_PB_OFF] & HCI_FEATURE_NON_FLUSHABLE_PB_MASK) -#else -#define HCI_NON_FLUSHABLE_PB_SUPPORTED(x) ((x)[HCI_FEATURE_NON_FLUSHABLE_PB_OFF] & HCI_FEATURE_NON_FLUSHABLE_PB_MASK) -#endif -// btla-specific -- #define HCI_FEATURE_LINK_SUP_TO_EVT_MASK 0x01 #define HCI_FEATURE_LINK_SUP_TO_EVT_OFF 7 @@ -2714,98 +2545,5 @@ typedef struct #define HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_NEG_RPY_OFF 33 #define HCI_LE_RC_CONN_PARAM_UPD_NEG_RPY_SUPPORTED(x) ((x)[HCI_SUPP_COMMANDS_LE_RC_CONN_PARAM_UPD_NEG_RPY_OFF] & HCI_SUPP_COMMANDS_RLE_RC_CONN_PARAM_UPD_NEG_RPY_MASK) -/* -Commands of HCI_GRP_VENDOR_SPECIFIC group for WIDCOMM SW LM Simulator -*/ -#ifdef _WIDCOMM - -#define HCI_SET_HCI_TRACE (0x0001 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_SET_LM_TRACE (0x0002 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_WRITE_COUNTRY_CODE (0x0004 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_READ_LM_HISTORY (0x0005 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_WRITE_BD_ADDR (0x0006 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_DISABLE_ENCRYPTION (0x0007 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_DISABLE_AUTHENTICATION (0x0008 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_GENERIC_LC_CMD (0x000A | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_INCR_POWER (0x000B | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_DECR_POWER (0x000C | HCI_GRP_VENDOR_SPECIFIC) - -/* Definitions for the local transactions */ -#define LM_DISCONNECT (0x00D0 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_AUTHENTICATION_REQUESTED (0x00D1 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_SET_CONN_ENCRYPTION (0x00D2 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_START_ENCRYPT_KEY_SIZE (0x00D3 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_START_ENCRYPTION (0x00D4 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_STOP_ENCRYPTION (0x00D5 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_CHANGE_CONN_PACKET_TYPE (0x00D6 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_RMT_NAME_REQUEST (0x00D7 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_READ_RMT_FEATURES (0x00D8 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_READ_RMT_VERSION_INFO (0x00D9 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_READ_RMT_TIMING_INFO (0x00DA | HCI_GRP_VENDOR_SPECIFIC) -#define LM_READ_RMT_CLOCK_OFFSET (0x00DB | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HOLD_MODE (0x00DC | HCI_GRP_VENDOR_SPECIFIC) -#define LM_EXIT_PARK_MODE (0x00DD | HCI_GRP_VENDOR_SPECIFIC) - -#define LM_SCO_LINK_REQUEST (0x00E0 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_SCO_CHANGE (0x00E4 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_SCO_REMOVE (0x00E8 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_MAX_SLOTS (0x00F1 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_MAX_SLOTS_REQUEST (0x00F2 | HCI_GRP_VENDOR_SPECIFIC) - -#ifdef INCLUDE_OPTIONAL_PAGING_SCHEME -#define LM_OPTIONAL_PAGE_REQUEST (0x00F3 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_OPTIONAL_PAGESCAN_REQUEST (0x00F4 | HCI_GRP_VENDOR_SPECIFIC) -#endif - -#define LM_SETUP_COMPLETE (0x00FF | HCI_GRP_VENDOR_SPECIFIC) - -#define LM_HIST_SEND_LMP_FRAME (0x0100 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_RECV_LMP_FRAME (0x0101 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_HCIT_ERROR (0x0102 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_PER_INQ_TOUT (0x0103 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_INQ_SCAN_TOUT (0x0104 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_PAGE_SCAN_TOUT (0x0105 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_RESET_TOUT (0x0106 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_MANDAT_PSCAN_TOUT (0x0107 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_ACL_START_TRANS (0x0108 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_ACL_HOST_REPLY (0x0109 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_ACL_TIMEOUT (0x010A | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_ACL_TX_COMP (0x010B | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_ACL_HCID_SUSPENDED (0x010C | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_ACL_FAILED (0x010D | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_HCI_COMMAND (0x010E | HCI_GRP_VENDOR_SPECIFIC) - -#define LM_HIST_HCI_EVENT (0x010F | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_HCI_UPDATA (0x0110 | HCI_GRP_VENDOR_SPECIFIC) -#define LM_HIST_HCI_DNDATA (0x0111 | HCI_GRP_VENDOR_SPECIFIC) - -#define HCI_ENTER_TEST_MODE (0x0300 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_LMP_TEST_CNTRL (0x0301 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_DEBUG_LC_CMD_MIN (0x0300 | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_DEBUG_LC_CMD_MAX (0x03FF | HCI_GRP_VENDOR_SPECIFIC) -#define HCI_DEBUG_LC_COMMAND HCI_DEBUG_LC_CMD_MAX - -#endif - - -/* AMP VSE events -*/ -#define AMP_VSE_CHANSPEC_CHAN_MASK 0x00ff - -#define AMP_VSE_CHANSPEC_CTL_SB_MASK 0x0300 -#define AMP_VSE_CHANSPEC_CTL_SB_LOWER 0x0100 -#define AMP_VSE_CHANSPEC_CTL_SB_UPPER 0x0200 -#define AMP_VSE_CHANSPEC_CTL_SB_NONE 0x0300 - -#define AMP_VSE_CHANSPEC_BW_MASK 0x0C00 -#define AMP_VSE_CHANSPEC_BW_10 0x0400 -#define AMP_VSE_CHANSPEC_BW_20 0x0800 -#define AMP_VSE_CHANSPEC_BW_40 0x0C00 - -#define AMP_VSE_CHANSPEC_BAND_MASK 0xf000 -#define AMP_VSE_CHANSPEC_BAND_5G 0x1000 -#define AMP_VSE_CHANSPEC_BAND_2G 0x2000 - - #endif diff --git a/stack/include/hcimsgs.h b/stack/include/hcimsgs.h index 3201f75d5..1447ccea7 100644 --- a/stack/include/hcimsgs.h +++ b/stack/include/hcimsgs.h @@ -23,58 +23,13 @@ #include "hcidefs.h" #include "bt_types.h" - -#ifdef __cplusplus -extern "C" { -#endif +void bte_main_hci_send(BT_HDR *p_msg, UINT16 event); +void bte_main_lpm_allow_bt_device_sleep(void); /* Message by message.... */ -#define HCIC_GET_UINT8(p, off) (UINT8)(*((UINT8 *)((p) + 1) + p->offset + 3 + (off))) - -#define HCIC_GET_UINT16(p, off) (UINT16)((*((UINT8 *)((p) + 1) + p->offset + 3 + (off)) + \ - (*((UINT8 *)((p) + 1) + p->offset + 3 + (off) + 1) << 8))) - -#define HCIC_GET_UINT32(p, off) (UINT32)((*((UINT8 *)((p) + 1) + p->offset + 3 + (off)) + \ - (*((UINT8 *)((p) + 1) + p->offset + 3 + (off) + 1) << 8) + \ - (*((UINT8 *)((p) + 1) + p->offset + 3 + (off) + 2) << 16) + \ - (*((UINT8 *)((p) + 1) + p->offset + 3 + (off) + 3) << 24))) - -#define HCIC_GET_ARRAY(p, off, x, len) \ -{ \ - UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x; \ - int ii; for (ii = 0; ii < len; ii++) *rr++ = *qq++; \ -} - -#define HCIC_GET_ARRAY16(p, off, x) \ -{ \ - UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x + 15; \ - int ii; for (ii = 0; ii < 16; ii++) *rr-- = *qq++; \ -} - -#define HCIC_GET_BDADDR(p, off, x) \ -{ \ - UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x + BD_ADDR_LEN - 1; \ - int ii; for (ii = 0; ii < BD_ADDR_LEN; ii++) *rr-- = *qq++; \ -} - -#define HCIC_GET_DEVCLASS(p, off, x) \ -{ \ - UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x + DEV_CLASS_LEN - 1; \ - int ii; for (ii = 0; ii < DEV_CLASS_LEN; ii++) *rr-- = *qq++; \ -} - -#define HCIC_GET_LAP(p, off, x) \ -{ \ - UINT8 *qq = ((UINT8 *)((p) + 1) + p->offset + 3 + (off)); UINT8 *rr = (UINT8 *)x + LAP_LEN - 1; \ - int ii; for (ii = 0; ii < LAP_LEN; ii++) *rr-- = *qq++; \ -} - -#define HCIC_GET_POINTER(p, off) ((UINT8 *)((p) + 1) + p->offset + 3 + (off)) - - -HCI_API extern BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration, - UINT8 response_cnt); +extern BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration, + UINT8 response_cnt); #define HCIC_PARAM_SIZE_INQUIRY 5 @@ -85,14 +40,14 @@ HCI_API extern BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration, /* Inquiry */ /* Inquiry Cancel */ -HCI_API extern BOOLEAN btsnd_hcic_inq_cancel(void); +extern BOOLEAN btsnd_hcic_inq_cancel(void); #define HCIC_PARAM_SIZE_INQ_CANCEL 0 /* Periodic Inquiry Mode */ -HCI_API extern BOOLEAN btsnd_hcic_per_inq_mode(UINT16 max_period, UINT16 min_period, - const LAP inq_lap, UINT8 duration, - UINT8 response_cnt); +extern BOOLEAN btsnd_hcic_per_inq_mode(UINT16 max_period, UINT16 min_period, + const LAP inq_lap, UINT8 duration, + UINT8 response_cnt); #define HCIC_PARAM_SIZE_PER_INQ_MODE 9 @@ -104,15 +59,15 @@ HCI_API extern BOOLEAN btsnd_hcic_per_inq_mode(UINT16 max_period, UINT16 min_per /* Periodic Inquiry Mode */ /* Exit Periodic Inquiry Mode */ -HCI_API extern BOOLEAN btsnd_hcic_exit_per_inq(void); +extern BOOLEAN btsnd_hcic_exit_per_inq(void); #define HCIC_PARAM_SIZE_EXIT_PER_INQ 0 /* Create Connection */ -HCI_API extern BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types, - UINT8 page_scan_rep_mode, - UINT8 page_scan_mode, - UINT16 clock_offset, - UINT8 allow_switch); +extern BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types, + UINT8 page_scan_rep_mode, + UINT8 page_scan_mode, + UINT16 clock_offset, + UINT8 allow_switch); #define HCIC_PARAM_SIZE_CREATE_CONN 13 @@ -125,7 +80,7 @@ HCI_API extern BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types, /* Create Connection */ /* Disconnect */ -HCI_API extern BOOLEAN btsnd_hcic_disconnect(UINT16 handle, UINT8 reason); +extern BOOLEAN btsnd_hcic_disconnect(UINT16 handle, UINT8 reason); #define HCIC_PARAM_SIZE_DISCONNECT 3 @@ -135,7 +90,7 @@ HCI_API extern BOOLEAN btsnd_hcic_disconnect(UINT16 handle, UINT8 reason); #if BTM_SCO_INCLUDED == TRUE /* Add SCO Connection */ -HCI_API extern BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_types); +extern BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_types); #endif /* BTM_SCO_INCLUDED */ #define HCIC_PARAM_SIZE_ADD_SCO_CONN 4 @@ -145,7 +100,7 @@ HCI_API extern BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_typ /* Add SCO Connection */ /* Create Connection Cancel */ -HCI_API extern BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest); +extern BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest); #define HCIC_PARAM_SIZE_CREATE_CONN_CANCEL 6 @@ -153,7 +108,7 @@ HCI_API extern BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest); /* Create Connection Cancel */ /* Accept Connection Request */ -HCI_API extern BOOLEAN btsnd_hcic_accept_conn (BD_ADDR bd_addr, UINT8 role); +extern BOOLEAN btsnd_hcic_accept_conn (BD_ADDR bd_addr, UINT8 role); #define HCIC_PARAM_SIZE_ACCEPT_CONN 7 @@ -162,7 +117,7 @@ HCI_API extern BOOLEAN btsnd_hcic_accept_conn (BD_ADDR bd_addr, UINT8 role); /* Accept Connection Request */ /* Reject Connection Request */ -HCI_API extern BOOLEAN btsnd_hcic_reject_conn (BD_ADDR bd_addr, UINT8 reason); +extern BOOLEAN btsnd_hcic_reject_conn (BD_ADDR bd_addr, UINT8 reason); #define HCIC_PARAM_SIZE_REJECT_CONN 7 @@ -171,8 +126,8 @@ HCI_API extern BOOLEAN btsnd_hcic_reject_conn (BD_ADDR bd_addr, UINT8 reason); /* Reject Connection Request */ /* Link Key Request Reply */ -HCI_API extern BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr, - LINK_KEY link_key); +extern BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr, + LINK_KEY link_key); #define HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY 22 @@ -181,7 +136,7 @@ HCI_API extern BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr, /* Link Key Request Reply */ /* Link Key Request Neg Reply */ -HCI_API extern BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr); +extern BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr); #define HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY 6 @@ -189,9 +144,9 @@ HCI_API extern BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr); /* Link Key Request Neg Reply */ /* PIN Code Request Reply */ -HCI_API extern BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr, - UINT8 pin_code_len, - PIN_CODE pin_code); +extern BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr, + UINT8 pin_code_len, + PIN_CODE pin_code); #define HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY 23 @@ -201,7 +156,7 @@ HCI_API extern BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr, /* PIN Code Request Reply */ /* Link Key Request Neg Reply */ -HCI_API extern BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr); +extern BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr); #define HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY 6 @@ -209,7 +164,7 @@ HCI_API extern BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr); /* Link Key Request Neg Reply */ /* Change Connection Type */ -HCI_API extern BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet_types); +extern BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet_types); #define HCIC_PARAM_SIZE_CHANGE_CONN_TYPE 4 @@ -221,10 +176,10 @@ HCI_API extern BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet #define HCI_CMD_HANDLE_HANDLE_OFF 0 -HCI_API extern BOOLEAN btsnd_hcic_auth_request (UINT16 handle); /* Authentication Request */ +extern BOOLEAN btsnd_hcic_auth_request (UINT16 handle); /* Authentication Request */ /* Set Connection Encryption */ -HCI_API extern BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable); +extern BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable); #define HCIC_PARAM_SIZE_SET_CONN_ENCRYPT 3 @@ -232,21 +187,11 @@ HCI_API extern BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enabl #define HCI_SET_ENCRYPT_ENABLE_OFF 2 /* Set Connection Encryption */ -HCI_API extern BOOLEAN btsnd_hcic_change_link_key (UINT16 handle); /* Change Connection Link Key */ - - /* Master Link Key */ -HCI_API extern BOOLEAN btsnd_hcic_master_link_key (BOOLEAN key_flag); - -#define HCIC_PARAM_SIZE_MASTER_LINK_KEY 1 - -#define HCI_MASTER_KEY_FLAG_OFF 0 - /* Master Link Key */ - /* Remote Name Request */ -HCI_API extern BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, - UINT8 page_scan_rep_mode, - UINT8 page_scan_mode, - UINT16 clock_offset); +extern BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, + UINT8 page_scan_rep_mode, + UINT8 page_scan_mode, + UINT16 clock_offset); #define HCIC_PARAM_SIZE_RMT_NAME_REQ 10 @@ -257,17 +202,17 @@ HCI_API extern BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, /* Remote Name Request */ /* Remote Name Request Cancel */ -HCI_API extern BOOLEAN btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr); +extern BOOLEAN btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr); #define HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL 6 #define HCI_RMT_NAME_CANCEL_BD_ADDR_OFF 0 /* Remote Name Request Cancel */ -HCI_API extern BOOLEAN btsnd_hcic_rmt_features_req(UINT16 handle); /* Remote Features Request */ +extern BOOLEAN btsnd_hcic_rmt_features_req(UINT16 handle); /* Remote Features Request */ /* Remote Extended Features */ -HCI_API extern BOOLEAN btsnd_hcic_rmt_ext_features(UINT16 handle, UINT8 page_num); +extern BOOLEAN btsnd_hcic_rmt_ext_features(UINT16 handle, UINT8 page_num); #define HCIC_PARAM_SIZE_RMT_EXT_FEATURES 3 @@ -276,24 +221,15 @@ HCI_API extern BOOLEAN btsnd_hcic_rmt_ext_features(UINT16 handle, UINT8 page_num /* Remote Extended Features */ - /* Local Extended Features */ -HCI_API extern BOOLEAN btsnd_hcic_read_local_ext_features (UINT8 page_num); - -#define HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES 1 - -#define HCI_LOCAL_EXT_FEATURES_PAGE_NUM_OFF 0 - /* Local Extended Features */ +extern BOOLEAN btsnd_hcic_rmt_ver_req(UINT16 handle); /* Remote Version Info Request */ +extern BOOLEAN btsnd_hcic_read_rmt_clk_offset(UINT16 handle); /* Remote Clock Offset */ +extern BOOLEAN btsnd_hcic_read_lmp_handle(UINT16 handle); /* Remote LMP Handle */ - -HCI_API extern BOOLEAN btsnd_hcic_rmt_ver_req(UINT16 handle); /* Remote Version Info Request */ -HCI_API extern BOOLEAN btsnd_hcic_read_rmt_clk_offset(UINT16 handle); /* Remote Clock Offset */ -HCI_API extern BOOLEAN btsnd_hcic_read_lmp_handle(UINT16 handle); /* Remote LMP Handle */ - -HCI_API extern BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle, - UINT32 tx_bw, UINT32 rx_bw, - UINT16 max_latency, UINT16 voice, - UINT8 retrans_effort, - UINT16 packet_types); +extern BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle, + UINT32 tx_bw, UINT32 rx_bw, + UINT16 max_latency, UINT16 voice, + UINT8 retrans_effort, + UINT16 packet_types); #define HCIC_PARAM_SIZE_SETUP_ESCO 17 #define HCI_SETUP_ESCO_HANDLE_OFF 0 @@ -305,12 +241,12 @@ HCI_API extern BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle, #define HCI_SETUP_ESCO_PKT_TYPES_OFF 15 -HCI_API extern BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr, - UINT32 tx_bw, UINT32 rx_bw, - UINT16 max_latency, - UINT16 content_fmt, - UINT8 retrans_effort, - UINT16 packet_types); +extern BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr, + UINT32 tx_bw, UINT32 rx_bw, + UINT16 max_latency, + UINT16 content_fmt, + UINT8 retrans_effort, + UINT16 packet_types); #define HCIC_PARAM_SIZE_ACCEPT_ESCO 21 #define HCI_ACCEPT_ESCO_BDADDR_OFF 0 @@ -322,15 +258,15 @@ HCI_API extern BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr, #define HCI_ACCEPT_ESCO_PKT_TYPES_OFF 19 -HCI_API extern BOOLEAN btsnd_hcic_reject_esco_conn (BD_ADDR bd_addr, UINT8 reason); +extern BOOLEAN btsnd_hcic_reject_esco_conn (BD_ADDR bd_addr, UINT8 reason); #define HCIC_PARAM_SIZE_REJECT_ESCO 7 #define HCI_REJECT_ESCO_BDADDR_OFF 0 #define HCI_REJECT_ESCO_REASON_OFF 6 /* Hold Mode */ -HCI_API extern BOOLEAN btsnd_hcic_hold_mode(UINT16 handle, UINT16 max_hold_period, - UINT16 min_hold_period); +extern BOOLEAN btsnd_hcic_hold_mode(UINT16 handle, UINT16 max_hold_period, + UINT16 min_hold_period); #define HCIC_PARAM_SIZE_HOLD_MODE 6 @@ -340,11 +276,11 @@ HCI_API extern BOOLEAN btsnd_hcic_hold_mode(UINT16 handle, UINT16 max_hold_perio /* Hold Mode */ /* Sniff Mode */ -HCI_API extern BOOLEAN btsnd_hcic_sniff_mode(UINT16 handle, - UINT16 max_sniff_period, - UINT16 min_sniff_period, - UINT16 sniff_attempt, - UINT16 sniff_timeout); +extern BOOLEAN btsnd_hcic_sniff_mode(UINT16 handle, + UINT16 max_sniff_period, + UINT16 min_sniff_period, + UINT16 sniff_attempt, + UINT16 sniff_timeout); #define HCIC_PARAM_SIZE_SNIFF_MODE 10 @@ -356,12 +292,12 @@ HCI_API extern BOOLEAN btsnd_hcic_sniff_mode(UINT16 handle, #define HCI_SNIFF_MODE_TIMEOUT_OFF 8 /* Sniff Mode */ -HCI_API extern BOOLEAN btsnd_hcic_exit_sniff_mode(UINT16 handle); /* Exit Sniff Mode */ +extern BOOLEAN btsnd_hcic_exit_sniff_mode(UINT16 handle); /* Exit Sniff Mode */ /* Park Mode */ -HCI_API extern BOOLEAN btsnd_hcic_park_mode (UINT16 handle, - UINT16 beacon_max_interval, - UINT16 beacon_min_interval); +extern BOOLEAN btsnd_hcic_park_mode (UINT16 handle, + UINT16 beacon_max_interval, + UINT16 beacon_min_interval); #define HCIC_PARAM_SIZE_PARK_MODE 6 @@ -370,13 +306,13 @@ HCI_API extern BOOLEAN btsnd_hcic_park_mode (UINT16 handle, #define HCI_PARK_MODE_MIN_PER_OFF 4 /* Park Mode */ -HCI_API extern BOOLEAN btsnd_hcic_exit_park_mode(UINT16 handle); /* Exit Park Mode */ +extern BOOLEAN btsnd_hcic_exit_park_mode(UINT16 handle); /* Exit Park Mode */ /* QoS Setup */ -HCI_API extern BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags, - UINT8 service_type, - UINT32 token_rate, UINT32 peak, - UINT32 latency, UINT32 delay_var); +extern BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags, + UINT8 service_type, + UINT32 token_rate, UINT32 peak, + UINT32 latency, UINT32 delay_var); #define HCIC_PARAM_SIZE_QOS_SETUP 20 @@ -389,10 +325,8 @@ HCI_API extern BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags, #define HCI_QOS_DELAY_VAR_OFF 16 /* QoS Setup */ -HCI_API extern BOOLEAN btsnd_hcic_role_discovery (UINT16 handle); /* Role Discovery */ - /* Switch Role Request */ -HCI_API extern BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role); +extern BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role); #define HCIC_PARAM_SIZE_SWITCH_ROLE 7 @@ -400,10 +334,8 @@ HCI_API extern BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role); #define HCI_SWITCH_ROLE_OFF 6 /* Switch Role Request */ -HCI_API extern BOOLEAN btsnd_hcic_read_policy_set(UINT16 handle); /* Read Policy Settings */ - /* Write Policy Settings */ -HCI_API extern BOOLEAN btsnd_hcic_write_policy_set(UINT16 handle, UINT16 settings); +extern BOOLEAN btsnd_hcic_write_policy_set(UINT16 handle, UINT16 settings); #define HCIC_PARAM_SIZE_WRITE_POLICY_SET 4 @@ -411,48 +343,22 @@ HCI_API extern BOOLEAN btsnd_hcic_write_policy_set(UINT16 handle, UINT16 setting #define HCI_WRITE_POLICY_SETTINGS_OFF 2 /* Write Policy Settings */ - /* Read Default Policy Settings */ -HCI_API extern BOOLEAN btsnd_hcic_read_def_policy_set(void); - -#define HCIC_PARAM_SIZE_READ_DEF_POLICY_SET 0 - /* Read Default Policy Settings */ - /* Write Default Policy Settings */ -HCI_API extern BOOLEAN btsnd_hcic_write_def_policy_set(UINT16 settings); +extern BOOLEAN btsnd_hcic_write_def_policy_set(UINT16 settings); #define HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET 2 #define HCI_WRITE_DEF_POLICY_SETTINGS_OFF 0 /* Write Default Policy Settings */ - /* Flow Specification */ -HCI_API extern BOOLEAN btsnd_hcic_flow_specification(UINT16 handle, UINT8 flags, - UINT8 flow_direct, - UINT8 service_type, - UINT32 token_rate, - UINT32 token_bucket_size, - UINT32 peak, UINT32 latency); - -#define HCIC_PARAM_SIZE_FLOW_SPEC 21 - -#define HCI_FLOW_SPEC_HANDLE_OFF 0 -#define HCI_FLOW_SPEC_FLAGS_OFF 2 -#define HCI_FLOW_SPEC_FLOW_DIRECT_OFF 3 -#define HCI_FLOW_SPEC_SERVICE_TYPE_OFF 4 -#define HCI_FLOW_SPEC_TOKEN_RATE_OFF 5 -#define HCI_FLOW_SPEC_TOKEN_BUCKET_SIZE_OFF 9 -#define HCI_FLOW_SPEC_PEAK_BANDWIDTH_OFF 13 -#define HCI_FLOW_SPEC_LATENCY_OFF 17 - /* Flow Specification */ - /****************************************** ** Lisbon Features *******************************************/ #if BTM_SSR_INCLUDED == TRUE /* Sniff Subrating */ -HCI_API extern BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat, - UINT16 min_remote_lat, - UINT16 min_local_lat); +extern BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat, + UINT16 min_remote_lat, + UINT16 min_local_lat); #define HCIC_PARAM_SIZE_SNIFF_SUB_RATE 8 @@ -469,42 +375,15 @@ HCI_API extern BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat, #endif /* BTM_SSR_INCLUDED */ /* Extended Inquiry Response */ -#if (BTM_EIR_SERVER_INCLUDED == TRUE) -HCI_API extern void btsnd_hcic_write_ext_inquiry_response(void *buffer, UINT8 fec_req); +extern void btsnd_hcic_write_ext_inquiry_response(void *buffer, UINT8 fec_req); #define HCIC_PARAM_SIZE_EXT_INQ_RESP 241 #define HCIC_EXT_INQ_RESP_FEC_OFF 0 #define HCIC_EXT_INQ_RESP_RESPONSE 1 - -HCI_API extern BOOLEAN btsnd_hcic_read_ext_inquiry_response(void); /* Read Extended Inquiry Response */ -#else -#define btsnd_hcic_write_ext_inquiry_response(buffer, fec_req) -#define btsnd_hcic_read_ext_inquiry_response() FALSE -#endif - /* Write Simple Pairing Mode */ -/**** Simple Pairing Commands ****/ -HCI_API extern BOOLEAN btsnd_hcic_write_simple_pairing_mode(UINT8 mode); - -#define HCIC_PARAM_SIZE_W_SIMP_PAIR 1 - -#define HCIC_WRITE_SP_MODE_OFF 0 - - -HCI_API extern BOOLEAN btsnd_hcic_read_simple_pairing_mode (void); - -#define HCIC_PARAM_SIZE_R_SIMP_PAIR 0 - - /* Write Simple Pairing Debug Mode */ -HCI_API extern BOOLEAN btsnd_hcic_write_simp_pair_debug_mode(UINT8 debug_mode); - -#define HCIC_PARAM_SIZE_SIMP_PAIR_DBUG 1 - -#define HCIC_WRITE_SP_DBUG_MODE_OFF 0 - - /* IO Capabilities Response */ -HCI_API extern BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability, - UINT8 oob_present, UINT8 auth_req); + /* IO Capabilities Response */ +extern BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability, + UINT8 oob_present, UINT8 auth_req); #define HCIC_PARAM_SIZE_IO_CAP_RESP 9 @@ -514,7 +393,7 @@ HCI_API extern BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capab #define HCI_IO_CAP_AUTH_REQ_OFF 8 /* IO Capabilities Req Neg Reply */ -HCI_API extern BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code); +extern BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code); #define HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY 7 @@ -522,19 +401,19 @@ HCI_API extern BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 e #define HCI_IO_CAP_NR_ERR_CODE 6 /* Read Local OOB Data */ -HCI_API extern BOOLEAN btsnd_hcic_read_local_oob_data (void); +extern BOOLEAN btsnd_hcic_read_local_oob_data (void); #define HCIC_PARAM_SIZE_R_LOCAL_OOB 0 -HCI_API extern BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes); +extern BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes); #define HCIC_PARAM_SIZE_UCONF_REPLY 6 #define HCI_USER_CONF_BD_ADDR_OFF 0 -HCI_API extern BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value); +extern BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value); #define HCIC_PARAM_SIZE_U_PKEY_REPLY 10 @@ -542,15 +421,15 @@ HCI_API extern BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 va #define HCI_USER_PASSKEY_VALUE_OFF 6 -HCI_API extern BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr); +extern BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr); #define HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY 6 #define HCI_USER_PASSKEY_NEG_BD_ADDR_OFF 0 /* Remote OOB Data Request Reply */ -HCI_API extern BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c, - UINT8 *p_r); +extern BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c, + UINT8 *p_r); #define HCIC_PARAM_SIZE_REM_OOB_REPLY 38 @@ -559,83 +438,45 @@ HCI_API extern BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c, #define HCI_REM_OOB_DATA_R_OFF 22 /* Remote OOB Data Request Negative Reply */ -HCI_API extern BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr); +extern BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr); #define HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY 6 #define HCI_REM_OOB_DATA_NEG_BD_ADDR_OFF 0 /* Read Tx Power Level */ -HCI_API extern BOOLEAN btsnd_hcic_read_inq_tx_power (void); +extern BOOLEAN btsnd_hcic_read_inq_tx_power (void); #define HCIC_PARAM_SIZE_R_TX_POWER 0 - /* Write Tx Power Level */ -HCI_API extern BOOLEAN btsnd_hcic_write_inq_tx_power (INT8 level); - -#define HCIC_PARAM_SIZE_W_TX_POWER 1 - -#define HCIC_WRITE_TX_POWER_LEVEL_OFF 0 /* Read Default Erroneous Data Reporting */ -HCI_API extern BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void); +extern BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void); #define HCIC_PARAM_SIZE_R_ERR_DATA_RPT 0 - /* Write Default Erroneous Data Reporting */ -HCI_API extern BOOLEAN btsnd_hcic_write_default_erroneous_data_rpt (UINT8 level); - -#define HCIC_PARAM_SIZE_W_ERR_DATA_RPT 1 - -#define HCIC_WRITE_ERR_DATA_RPT_OFF 0 - - #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE -HCI_API extern BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type); +extern BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type); #define HCIC_PARAM_SIZE_ENHANCED_FLUSH 3 #endif -HCI_API extern BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif); +extern BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif); #define HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF 7 #define HCI_SEND_KEYPRESS_NOTIF_BD_ADDR_OFF 0 #define HCI_SEND_KEYPRESS_NOTIF_NOTIF_OFF 6 - -HCI_API extern BOOLEAN btsnd_hcic_refresh_encryption_key(UINT16 handle); /* Refresh Encryption Key */ - /**** end of Simple Pairing Commands ****/ - -HCI_API extern BOOLEAN btsnd_hcic_set_event_mask(UINT8 local_controller_id, BT_EVENT_MASK evt_mask); - -#define HCIC_PARAM_SIZE_SET_EVENT_MASK 8 -#define HCI_EVENT_MASK_MASK_OFF 0 - /* Set Event Mask */ - - /* Reset */ -HCI_API extern BOOLEAN btsnd_hcic_set_event_mask_page_2 (UINT8 local_controller_id, - BT_EVENT_MASK event_mask); - -#define HCIC_PARAM_SIZE_SET_EVENT_MASK_PAGE_2 8 -#define HCI_EVENT_MASK_MASK_OFF 0 - /* Set Event Mask Page 2 */ - - /* Reset */ -HCI_API extern BOOLEAN btsnd_hcic_reset(UINT8 local_controller_id); - -#define HCIC_PARAM_SIZE_RESET 0 - /* Reset */ - /* Store Current Settings */ #define MAX_FILT_COND (sizeof (BD_ADDR) + 1) -HCI_API extern BOOLEAN btsnd_hcic_set_event_filter(UINT8 filt_type, - UINT8 filt_cond_type, - UINT8 *filt_cond, - UINT8 filt_cond_len); +extern BOOLEAN btsnd_hcic_set_event_filter(UINT8 filt_type, + UINT8 filt_cond_type, + UINT8 *filt_cond, + UINT8 filt_cond_len); #define HCIC_PARAM_SIZE_SET_EVT_FILTER 9 @@ -644,40 +485,8 @@ HCI_API extern BOOLEAN btsnd_hcic_set_event_filter(UINT8 filt_type, #define HCI_FILT_COND_FILT_OFF 2 /* Set Event Filter */ -HCI_API extern BOOLEAN btsnd_hcic_flush(UINT8 local_controller_id, UINT16 handle); /* Flush */ - - /* Create New Unit Type */ -HCI_API extern BOOLEAN btsnd_hcic_new_unit_key(void); - -#define HCIC_PARAM_SIZE_NEW_UNIT_KEY 0 - /* Create New Unit Type */ - - /* Read Stored Key */ -HCI_API extern BOOLEAN btsnd_hcic_read_stored_key (BD_ADDR bd_addr, - BOOLEAN read_all_flag); - -#define HCIC_PARAM_SIZE_READ_STORED_KEY 7 - -#define HCI_READ_KEY_BD_ADDR_OFF 0 -#define HCI_READ_KEY_ALL_FLAG_OFF 6 - /* Read Stored Key */ - -#define MAX_WRITE_KEYS 10 - /* Write Stored Key */ -HCI_API extern BOOLEAN btsnd_hcic_write_stored_key (UINT8 num_keys, BD_ADDR *bd_addr, - LINK_KEY *link_key); - -#define HCIC_PARAM_SIZE_WRITE_STORED_KEY sizeof(btmsg_hcic_write_stored_key_t) - -#define HCI_WRITE_KEY_NUM_KEYS_OFF 0 -#define HCI_WRITE_KEY_BD_ADDR_OFF 1 -#define HCI_WRITE_KEY_KEY_OFF 7 -/* only 0x0b keys cab be sent in one HCI command */ -#define HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD 0x0b - /* Write Stored Key */ - /* Delete Stored Key */ -HCI_API extern BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag); +extern BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag); #define HCIC_PARAM_SIZE_DELETE_STORED_KEY 7 @@ -686,7 +495,7 @@ HCI_API extern BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN de /* Delete Stored Key */ /* Change Local Name */ -HCI_API extern BOOLEAN btsnd_hcic_change_name(BD_NAME name); +extern BOOLEAN btsnd_hcic_change_name(BD_NAME name); #define HCIC_PARAM_SIZE_CHANGE_NAME BD_NAME_LEN @@ -710,21 +519,13 @@ HCI_API extern BOOLEAN btsnd_hcic_change_name(BD_NAME name); #define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10 -HCI_API extern BOOLEAN btsnd_hcic_read_pin_type(void); /* Read PIN Type */ -HCI_API extern BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */ -HCI_API extern BOOLEAN btsnd_hcic_read_auto_accept(void); /* Read Auto Accept */ -HCI_API extern BOOLEAN btsnd_hcic_write_auto_accept(UINT8 flag); /* Write Auto Accept */ -HCI_API extern BOOLEAN btsnd_hcic_read_name (void); /* Read Local Name */ -HCI_API extern BOOLEAN btsnd_hcic_read_conn_acc_tout(UINT8 local_controller_id); /* Read Connection Accept Timout */ -HCI_API extern BOOLEAN btsnd_hcic_write_conn_acc_tout(UINT8 local_controller_id, UINT16 tout); /* Write Connection Accept Timout */ -HCI_API extern BOOLEAN btsnd_hcic_read_page_tout(void); /* Read Page Timout */ -HCI_API extern BOOLEAN btsnd_hcic_write_page_tout(UINT16 timeout); /* Write Page Timout */ -HCI_API extern BOOLEAN btsnd_hcic_read_scan_enable(void); /* Read Scan Enable */ -HCI_API extern BOOLEAN btsnd_hcic_write_scan_enable(UINT8 flag); /* Write Scan Enable */ -HCI_API extern BOOLEAN btsnd_hcic_read_pagescan_cfg(void); /* Read Page Scan Activity */ - -HCI_API extern BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval, - UINT16 window); /* Write Page Scan Activity */ +extern BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */ +extern BOOLEAN btsnd_hcic_write_auto_accept(UINT8 flag); /* Write Auto Accept */ +extern BOOLEAN btsnd_hcic_read_name (void); /* Read Local Name */ +extern BOOLEAN btsnd_hcic_write_page_tout(UINT16 timeout); /* Write Page Timout */ +extern BOOLEAN btsnd_hcic_write_scan_enable(UINT8 flag); /* Write Scan Enable */ +extern BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval, + UINT16 window); /* Write Page Scan Activity */ #define HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG 4 @@ -732,10 +533,8 @@ HCI_API extern BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval, #define HCI_SCAN_CFG_WINDOW_OFF 2 /* Write Page Scan Activity */ -HCI_API extern BOOLEAN btsnd_hcic_read_inqscan_cfg(void); /* Read Inquiry Scan Activity */ - /* Write Inquiry Scan Activity */ -HCI_API extern BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window); +extern BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window); #define HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG 4 @@ -743,14 +542,9 @@ HCI_API extern BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 wind #define HCI_SCAN_CFG_WINDOW_OFF 2 /* Write Inquiry Scan Activity */ -HCI_API extern BOOLEAN btsnd_hcic_read_auth_enable(void); /* Read Authentication Enable */ -HCI_API extern BOOLEAN btsnd_hcic_write_auth_enable(UINT8 flag); /* Write Authentication Enable */ -HCI_API extern BOOLEAN btsnd_hcic_read_encr_mode (void); /* Read encryption mode */ -HCI_API extern BOOLEAN btsnd_hcic_write_encr_mode (UINT8 mode); /* Write encryption mode */ -HCI_API extern BOOLEAN btsnd_hcic_read_dev_class(void); /* Read Class of Device */ -HCI_API extern BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev); /* Write Class of Device */ -HCI_API extern BOOLEAN btsnd_hcic_read_voice_settings(void); /* Read Voice Settings */ -HCI_API extern BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags); /* Write Voice Settings */ +extern BOOLEAN btsnd_hcic_write_auth_enable(UINT8 flag); /* Write Authentication Enable */ +extern BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev); /* Write Class of Device */ +extern BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags); /* Write Voice Settings */ /* Host Controller to Host flow control */ #define HCI_HOST_FLOW_CTRL_OFF 0 @@ -758,25 +552,15 @@ HCI_API extern BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags); #define HCI_HOST_FLOW_CTRL_SCO_ON 2 #define HCI_HOST_FLOW_CTRL_BOTH_ON 3 -HCI_API extern BOOLEAN btsnd_hcic_set_host_flow_ctrl (UINT8 value); /* Enable/disable flow control toward host */ - - -HCI_API extern BOOLEAN btsnd_hcic_read_auto_flush_tout(UINT16 handle); /* Read Retransmit Timout */ - -HCI_API extern BOOLEAN btsnd_hcic_write_auto_flush_tout(UINT16 handle, - UINT16 timeout); /* Write Retransmit Timout */ +extern BOOLEAN btsnd_hcic_write_auto_flush_tout(UINT16 handle, + UINT16 timeout); /* Write Retransmit Timout */ #define HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT 4 #define HCI_FLUSH_TOUT_HANDLE_OFF 0 #define HCI_FLUSH_TOUT_TOUT_OFF 2 -HCI_API extern BOOLEAN btsnd_hcic_read_num_bcast_xmit(void); /* Read Num Broadcast Retransmits */ -HCI_API extern BOOLEAN btsnd_hcic_write_num_bcast_xmit(UINT8 num); /* Write Num Broadcast Retransmits */ -HCI_API extern BOOLEAN btsnd_hcic_read_hold_mode_act(void); /* Read Hold Mode Activity */ -HCI_API extern BOOLEAN btsnd_hcic_write_hold_mode_act(UINT8 flags); /* Write Hold Mode Activity */ - -HCI_API extern BOOLEAN btsnd_hcic_read_tx_power(UINT16 handle, UINT8 type); /* Read Tx Power */ +extern BOOLEAN btsnd_hcic_read_tx_power(UINT16 handle, UINT8 type); /* Read Tx Power */ #define HCIC_PARAM_SIZE_READ_TX_POWER 3 @@ -787,26 +571,9 @@ HCI_API extern BOOLEAN btsnd_hcic_read_tx_power(UINT16 handle, UINT8 type); #define HCI_READ_CURRENT 0x00 #define HCI_READ_MAXIMUM 0x01 -HCI_API extern BOOLEAN btsnd_hcic_read_sco_flow_enable(void); /* Read Authentication Enable */ -HCI_API extern BOOLEAN btsnd_hcic_write_sco_flow_enable(UINT8 flag); /* Write Authentication Enable */ - - /* Set Host Buffer Size */ -HCI_API extern BOOLEAN btsnd_hcic_set_host_buf_size (UINT16 acl_len, - UINT8 sco_len, - UINT16 acl_num, - UINT16 sco_num); - -#define HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE 7 - -#define HCI_HOST_BUF_SIZE_ACL_LEN_OFF 0 -#define HCI_HOST_BUF_SIZE_SCO_LEN_OFF 2 -#define HCI_HOST_BUF_SIZE_ACL_NUM_OFF 3 -#define HCI_HOST_BUF_SIZE_SCO_NUM_OFF 5 - - -HCI_API extern BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, - UINT16 *handle, - UINT16 *num_pkts); /* Set Host Buffer Size */ +extern BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, + UINT16 *handle, + UINT16 *num_pkts); /* Set Host Buffer Size */ #define HCIC_PARAM_SIZE_NUM_PKTS_DONE_SIZE sizeof(btmsg_hcic_num_pkts_done_t) @@ -816,10 +583,8 @@ HCI_API extern BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, #define HCI_PKTS_DONE_HANDLE_OFF 1 #define HCI_PKTS_DONE_NUM_PKTS_OFF 3 -HCI_API extern BOOLEAN btsnd_hcic_read_link_super_tout(UINT8 local_controller_id, UINT16 handle); /* Read Link Supervision Timeout */ - /* Write Link Supervision Timeout */ -HCI_API extern BOOLEAN btsnd_hcic_write_link_super_tout(UINT8 local_controller_id, UINT16 handle, UINT16 timeout); +extern BOOLEAN btsnd_hcic_write_link_super_tout(UINT8 local_controller_id, UINT16 handle, UINT16 timeout); #define HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT 4 @@ -827,11 +592,8 @@ HCI_API extern BOOLEAN btsnd_hcic_write_link_super_tout(UINT8 local_controller_i #define HCI_LINK_SUPER_TOUT_TOUT_OFF 2 /* Write Link Supervision Timeout */ -HCI_API extern BOOLEAN btsnd_hcic_read_max_iac (void); /* Read Num Supported IAC */ -HCI_API extern BOOLEAN btsnd_hcic_read_cur_iac_lap (void); /* Read Current IAC LAP */ - -HCI_API extern BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac, - LAP * const iac_lap); /* Write Current IAC LAP */ +extern BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac, + LAP * const iac_lap); /* Write Current IAC LAP */ #define MAX_IAC_LAPS 0x40 @@ -839,66 +601,12 @@ HCI_API extern BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac, #define HCI_WRITE_IAC_LAP_LAP_OFF 1 /* Write Current IAC LAP */ - /* Read Clock */ -HCI_API extern BOOLEAN btsnd_hcic_read_clock (UINT16 handle, UINT8 which_clock); - -#define HCIC_PARAM_SIZE_READ_CLOCK 3 - -#define HCI_READ_CLOCK_HANDLE_OFF 0 -#define HCI_READ_CLOCK_WHICH_CLOCK 2 - /* Read Clock */ - -#ifdef TESTER_ENABLE - -#define HCIC_PARAM_SIZE_ENTER_TEST_MODE 2 - -#define HCI_ENTER_TEST_HANDLE_OFF 0 - -#define HCIC_PARAM_SIZE_TEST_CNTRL 10 -#define HCI_TEST_CNTRL_HANDLE_OFF 0 -#define HCI_TEST_CNTRL_SCENARIO_OFF 2 -#define HCI_TEST_CNTRL_HOPPINGMODE_OFF 3 -#define HCI_TEST_CNTRL_TX_FREQ_OFF 4 -#define HCI_TEST_CNTRL_RX_FREQ_OFF 5 -#define HCI_TEST_CNTRL_PWR_CNTRL_MODE_OFF 6 -#define HCI_TEST_CNTRL_POLL_PERIOD_OFF 7 -#define HCI_TEST_CNTRL_PKT_TYPE_OFF 8 -#define HCI_TEST_CNTRL_LENGTH_OFF 9 - -#endif - -HCI_API extern BOOLEAN btsnd_hcic_read_page_scan_per (void); /* Read Page Scan Period Mode */ -HCI_API extern BOOLEAN btsnd_hcic_write_page_scan_per (UINT8 mode); /* Write Page Scan Period Mode */ -HCI_API extern BOOLEAN btsnd_hcic_read_page_scan_mode (void); /* Read Page Scan Mode */ -HCI_API extern BOOLEAN btsnd_hcic_write_page_scan_mode (UINT8 mode); /* Write Page Scan Mode */ -HCI_API extern BOOLEAN btsnd_hcic_read_local_ver (UINT8 local_controller_id); /* Read Local Version Info */ -HCI_API extern BOOLEAN btsnd_hcic_read_local_supported_cmds (UINT8 local_controller_id); /* Read Local Supported Commands */ -HCI_API extern BOOLEAN btsnd_hcic_read_local_features (void); /* Read Local Supported Features */ -HCI_API extern BOOLEAN btsnd_hcic_read_buffer_size (void); /* Read Local buffer sizes */ -HCI_API extern BOOLEAN btsnd_hcic_read_country_code (void); /* Read Country Code */ -HCI_API extern BOOLEAN btsnd_hcic_read_bd_addr (void); /* Read Local BD_ADDR */ -HCI_API extern BOOLEAN btsnd_hcic_read_fail_contact_count (UINT8 local_controller_id, UINT16 handle); /* Read Failed Contact Counter */ -HCI_API extern BOOLEAN btsnd_hcic_reset_fail_contact_count (UINT8 local_controller_id, UINT16 handle);/* Reset Failed Contact Counter */ -HCI_API extern BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle); /* Get Link Quality */ -HCI_API extern BOOLEAN btsnd_hcic_read_rssi (UINT16 handle); /* Read RSSI */ -HCI_API extern BOOLEAN btsnd_hcic_read_loopback_mode (void); /* Read Loopback Mode */ -HCI_API extern BOOLEAN btsnd_hcic_write_loopback_mode (UINT8 mode); /* Write Loopback Mode */ -HCI_API extern BOOLEAN btsnd_hcic_enable_test_mode (void); /* Enable Device Under Test Mode */ -HCI_API extern BOOLEAN btsnd_hcic_write_pagescan_type(UINT8 type); /* Write Page Scan Type */ -HCI_API extern BOOLEAN btsnd_hcic_read_pagescan_type(void); /* Read Page Scan Type */ -HCI_API extern BOOLEAN btsnd_hcic_write_inqscan_type(UINT8 type); /* Write Inquiry Scan Type */ -HCI_API extern BOOLEAN btsnd_hcic_read_inqscan_type(void); /* Read Inquiry Scan Type */ -HCI_API extern BOOLEAN btsnd_hcic_write_inquiry_mode(UINT8 type); /* Write Inquiry Mode */ -HCI_API extern BOOLEAN btsnd_hcic_read_inquiry_mode(void); /* Read Inquiry Mode */ -HCI_API extern BOOLEAN btsnd_hcic_set_afh_channels (UINT8 first, UINT8 last); -HCI_API extern BOOLEAN btsnd_hcic_write_afh_channel_assessment_mode (UINT8 mode); -HCI_API extern BOOLEAN btsnd_hcic_set_afh_host_channel_class (UINT8 *p_afhchannelmap); -HCI_API extern BOOLEAN btsnd_hcic_read_afh_channel_assessment_mode(void); -HCI_API extern BOOLEAN btsnd_hcic_read_afh_channel_map (UINT16 handle); -HCI_API extern BOOLEAN btsnd_hcic_nop(void); /* NOP */ - - /* Send HCI Data */ -HCI_API extern void btsnd_hcic_data (BT_HDR *p_buf, UINT16 len, UINT16 handle, UINT8 boundary, UINT8 broadcast); +extern BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle); /* Get Link Quality */ +extern BOOLEAN btsnd_hcic_read_rssi (UINT16 handle); /* Read RSSI */ +extern BOOLEAN btsnd_hcic_enable_test_mode (void); /* Enable Device Under Test Mode */ +extern BOOLEAN btsnd_hcic_write_pagescan_type(UINT8 type); /* Write Page Scan Type */ +extern BOOLEAN btsnd_hcic_write_inqscan_type(UINT8 type); /* Write Inquiry Scan Type */ +extern BOOLEAN btsnd_hcic_write_inquiry_mode(UINT8 type); /* Write Inquiry Mode */ #define HCI_DATA_HANDLE_MASK 0x0FFF @@ -919,304 +627,12 @@ HCI_API extern void btsnd_hcic_data (BT_HDR *p_buf, UINT16 len, UINT16 handle, U (*((UINT8 *)((p) + 1) + p->offset + 3) << 8))) #define HCID_HEADER_SIZE 4 - /* Send HCI Data */ #define HCID_GET_SCO_LEN(p) (*((UINT8 *)((p) + 1) + p->offset + 2)) -HCI_API extern void btsnd_hcic_vendor_spec_cmd ( - void *buffer, UINT16 opcode, - UINT8 len, UINT8 *p_data, - void *p_cmd_cplt_cback); - - -/********************************************************************************* -** ** -** H C I E V E N T S ** -** ** -*********************************************************************************/ - -/* Inquiry Complete Event */ -HCI_API extern void btsnd_hcie_inq_comp(void *buffer, UINT8 status); - -#define HCIE_PARAM_SIZE_INQ_COMP 1 - -/* Inquiry Response Event */ -HCI_API extern void btsnd_hcie_inq_res(void *buffer, UINT8 num_resp, UINT8 **bd_addr, - UINT8 *page_scan_rep_mode, UINT8 *page_scan_per_mode, - UINT8 *page_scan_mode, UINT8 **dev_class, - UINT16 *clock_offset); - -/* Connection Complete Event */ -HCI_API extern void btsnd_hcie_connection_comp(void *buffer, UINT8 status, UINT16 handle, - BD_ADDR bd_addr, UINT8 link_type, UINT8 encr_mode); - -#define HCIE_PARAM_SIZE_CONNECTION_COMP 11 - - -#define HCI_LINK_TYPE_SCO 0x00 -#define HCI_LINK_TYPE_ACL 0x01 - -#define HCI_ENCRYPT_MODE_DISABLED 0x00 -#define HCI_ENCRYPT_MODE_POINT_TO_POINT 0x01 -#define HCI_ENCRYPT_MODE_ALL 0x02 - - -/* Connection Request Event */ -HCI_API extern void btsnd_hcie_connection_req(void *buffer, BD_ADDR bd_addr, DEV_CLASS dev_class, UINT8 link_type); - -#define HCIE_PARAM_SIZE_CONNECTION_REQ 10 - -#define HCI_LINK_TYPE_SCO 0x00 -#define HCI_LINK_TYPE_ACL 0x01 - - -/* Disonnection Complete Event */ -HCI_API extern void btsnd_hcie_disc_comp(void *buffer, UINT8 status, UINT16 handle, UINT8 reason); - -#define HCIE_PARAM_SIZE_DISC_COMP 4 - - -/* Authentication Complete Event */ -HCI_API extern void btsnd_hcie_auth_comp (void *buffer, UINT8 status, UINT16 handle); - -#define HCIE_PARAM_SIZE_AUTH_COMP 3 - - -/* Remote Name Request Complete Event */ -HCI_API extern void btsnd_hcie_rmt_name_req_comp(void *buffer, UINT8 status, BD_ADDR bd_addr, BD_NAME name); - -#define HCIE_PARAM_SIZE_RMT_NAME_REQ_COMP (1 + BD_ADDR_LEN + BD_NAME_LEN) - - -/* Encryption Change Event */ -HCI_API extern void btsnd_hcie_encryption_change (void *buffer, UINT8 status, UINT16 handle, BOOLEAN enable); - -#define HCIE_PARAM_SIZE_ENCR_CHANGE 4 - - -/* Connection Link Key Change Event */ -HCI_API extern void btsnd_hcie_conn_link_key_change (void *buffer, UINT8 status, UINT16 handle); - -#define HCIE_PARAM_SIZE_LINK_KEY_CHANGE 3 - - -/* Encryption Key Refresh Complete Event */ -HCI_API extern void btsnd_hcie_encrypt_key_refresh (void *buffer, UINT8 status, UINT16 handle); - -#define HCIE_PARAM_SIZE_ENCRYPT_KEY_REFRESH 3 - - -/* Master Link Key Complete Event */ -HCI_API extern void btsnd_hcie_master_link_key (void *buffer, UINT8 status, UINT16 handle, UINT8 flag); - -#define HCIE_PARAM_SIZE_MASTER_LINK_KEY 4 - - -/* Read Remote Supported Features Complete Event */ -HCI_API extern void btsnd_hcie_read_rmt_features (void *buffer, UINT8 status, UINT16 handle, UINT8 *features); - -#define LMP_FEATURES_SIZE 8 -#define HCIE_PARAM_SIZE_READ_RMT_FEATURES 11 - - -/* Read Remote Extended Features Complete Event */ -HCI_API extern void btsnd_hcie_read_rmt_ext_features (void *buffer, UINT8 status, UINT16 handle, UINT8 page_num, - UINT8 max_page_num, UINT8 *features); - -#define EXT_LMP_FEATURES_SIZE 8 -#define HCIE_PARAM_SIZE_READ_RMT_EXT_FEATURES 13 - - -/* Read Remote Version Complete Event */ -HCI_API extern void btsnd_hcie_read_rmt_version (void *buffer, UINT8 status, UINT16 handle, UINT8 version, - UINT16 comp_name, UINT16 sub_version); - -#define HCIE_PARAM_SIZE_READ_RMT_VERSION 8 - - -/* QOS setup complete */ -HCI_API extern void btsnd_hcie_qos_setup_compl (void *buffer, UINT8 status, UINT16 handle, UINT8 flags, - UINT8 service_type, UINT32 token_rate, UINT32 peak, - UINT32 latency, UINT32 delay_var); - -#define HCIE_PARAM_SIZE_QOS_SETUP_COMP 21 - - -/* Flow Specification complete */ -HCI_API extern void btsnd_hcie_flow_spec_compl (void *buffer, UINT8 status, UINT16 handle, UINT8 flags, - UINT8 flow_direction, UINT8 service_type, UINT32 token_rate, UINT32 token_bucket_size, - UINT32 peak, UINT32 latency); - -#define HCIE_PARAM_SIZE_FLOW_SPEC_COMP 22 - - -/* Command Complete Event */ -HCI_API extern void btsnd_hcie_cmd_comp(void *buffer, UINT8 max_host_cmds, UINT16 opcode, UINT8 status); - -#define HCIE_PARAM_SIZE_CMD_COMP 4 - - -/* Command Complete with pre-filled in parameters */ -HCI_API extern void btsnd_hcie_cmd_comp_params (void *buffer, UINT8 max_host_cmds, UINT16 cmd_opcode, UINT8 status); - -#define HCI_CMD_COMPL_PARAM_OFFSET 4 - - -/* Command Complete Event with 1-byte param */ -HCI_API extern void btsnd_hcie_cmd_comp_param1(void *buffer, UINT8 max_host_cmds, UINT16 opcode, - UINT8 status, UINT8 param1); - -#define HCIE_PARAM_SIZE_CMD_COMP_PARAM1 5 - -/* Command Complete Event with 2-byte param */ -HCI_API extern void btsnd_hcie_cmd_comp_param2(void *buffer, UINT8 max_host_cmds, UINT16 opcode, - UINT8 status, UINT16 param2); - -#define HCIE_PARAM_SIZE_CMD_COMP_PARAM2 6 - - -/* Command Complete Event with BD-addr as param */ -HCI_API extern void btsnd_hcie_cmd_comp_bd_addr(void *buffer, UINT8 max_host_cmds, UINT16 opcode, - UINT8 status, BD_ADDR bd_addr); - -#define HCIE_PARAM_SIZE_CMD_COMP_BD_ADDR 10 - - -/* Command Pending Event */ -HCI_API extern void btsnd_hcie_cmd_status (void *buffer, UINT8 status, UINT8 max_host_cmds, UINT16 opcode); - -#define HCIE_PARAM_SIZE_CMD_STATUS 4 - - -/* HW failure Event */ -HCI_API extern void btsnd_hcie_hw_failure (void *buffer, UINT8 code); - -#define HCIE_PARAM_SIZE_HW_FAILURE 1 - - -/* Flush Occured Event */ -HCI_API extern void btsnd_hcie_flush_occured (void *buffer, UINT16 handle); - -#define HCIE_PARAM_SIZE_FLUSH_OCCURED 2 - - -/* Role Changed Event */ -HCI_API extern void btsnd_hcie_role_change (void *buffer, UINT8 status, BD_ADDR bd_addr, UINT8 role); - -#define HCIE_PARAM_SIZE_ROLE_CHANGE 8 - - -/* Ready for Data Packets Event */ -HCI_API extern void btsnd_hcie_num_compl_pkts (void *buffer, UINT8 num_handles, UINT16 *p_handle, UINT16 *num_pkts); - -#define MAX_DATA_HANDLES 10 - - -/* Mode Change Event */ -HCI_API extern void btsnd_hcie_mode_change (void *buffer, UINT8 status, UINT16 handle, - UINT8 mode, UINT16 interval); - -#define HCIE_PARAM_SIZE_MODE_CHANGE 6 -#define MAX_DATA_HANDLES 10 - - - -/* Return Link Keys Event */ -HCI_API extern void btsnd_hcie_return_link_keys (void *buffer, UINT8 num_keys, BD_ADDR *bd_addr, LINK_KEY *link_key); - -/* This should not be more than 0x0b */ -#define MAX_LINK_KEYS 10 - - - -/* PIN Code Request Event */ -HCI_API extern void btsnd_hcie_pin_code_req (void *buffer, BD_ADDR bd_addr); - -#define HCIE_PARAM_SIZE_PIN_CODE_REQ 6 - - - -/* Link Key Request Event */ -HCI_API extern void btsnd_hcie_link_key_req (void *buffer, BD_ADDR bd_addr); - -#define HCIE_PARAM_SIZE_LINK_KEY_REQ 6 - - - -/* Link Key Notification Event */ -HCI_API extern void btsnd_hcie_link_key_notify (void *buffer, BD_ADDR bd_addr, LINK_KEY link_key, UINT8 key_type); - -#define HCIE_PARAM_SIZE_LINK_KEY_NOTIFY 23 - - - -/* Loopback Command Event */ -HCI_API extern void btsnd_hcie_loopback_command (void *buffer, UINT8 data_len, UINT8 *data); - -#define HCIE_PARAM_SIZE_LOOPBACK_COMMAND sizeof(btmsg_hcie_loopback_cmd_t) - - - -/* Data Buffer Overflow Event */ -HCI_API extern void btsnd_hcie_data_buf_overflow (void *buffer, UINT8 link_type); - -#define HCIE_PARAM_SIZE_DATA_BUF_OVERFLOW 1 - - - -/* Max Slots Change Event */ -HCI_API extern void btsnd_hcie_max_slots_change(void *buffer, UINT16 handle, UINT8 max_slots); - -#define HCIE_PARAM_SIZE_MAX_SLOTS_CHANGE 3 - - -/* Read Clock Offset Complet Event */ -HCI_API extern void btsnd_hcie_read_clock_off_comp(void *buffer, UINT8 status, UINT16 handle, - UINT16 clock_offset); - -#define HCIE_PARAM_SIZE_READ_CLOCK_OFF_COMP 5 - - - -/* Connection Packet Type Change Event */ -HCI_API extern void btsnd_hcie_pkt_type_change (void *buffer, UINT8 status, UINT16 handle, UINT16 pkt_type); - -#define HCIE_PARAM_SIZE_PKT_TYPE_CHANGE 5 - - - -/* QOS violation Event */ -HCI_API extern void btsnd_hcie_qos_violation (void *buffer, UINT16 handle); - -#define HCIE_PARAM_SIZE_QOS_VIOLATION 2 - - - -/* Page Scan Mode Change Event */ -HCI_API extern void btsnd_hcie_pagescan_mode_chng (void *buffer, BD_ADDR bd_addr, UINT8 mode); - -#define HCIE_PARAM_SIZE_PAGE_SCAN_MODE_CHNG 7 - - -/* Page Scan Repetition Mode Change Event */ -HCI_API extern void btsnd_hcie_pagescan_rep_mode_chng (void *buffer, BD_ADDR bd_addr, UINT8 mode); - -#define HCIE_PARAM_SIZE_PAGE_SCAN_REP_MODE_CHNG 7 - - -/* Sniff Sub Rate Event */ -HCI_API extern void btsnd_hcie_sniff_sub_rate(void *buffer, UINT8 status, UINT16 handle, UINT16 max_tx_lat, UINT16 max_rx_lat, - UINT16 min_remote_timeout, UINT16 min_local_timeout); - -#define HCIE_PARAM_SIZE_SNIFF_SUB_RATE 11 - - - -/* Extended Inquiry Result Event */ -HCI_API extern void btsnd_hcie_ext_inquiry_result(void *buffer, UINT8 num_resp, UINT8 **bd_addr, - UINT8 *page_scan_rep_mode, UINT8 *reserved, - UINT8 **dev_class, UINT16 *clock_offset, UINT8 *rssi, UINT8 *p_data); - +extern void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, + UINT8 len, UINT8 *p_data, + void *p_cmd_cplt_cback); #if (BLE_INCLUDED == TRUE) /******************************************************************************** @@ -1252,102 +668,97 @@ HCI_API extern void btsnd_hcie_ext_inquiry_result(void *buffer, UINT8 num_resp, #define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA 31 /* ULP HCI command */ -HCI_API extern BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask); +extern BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask); -HCI_API extern BOOLEAN btsnd_hcic_ble_read_buffer_size (void); +extern BOOLEAN btsnd_hcic_ble_read_buffer_size (void); -HCI_API extern BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void); +extern BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void); -HCI_API extern BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]); +extern BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]); -HCI_API extern BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_addr); +extern BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_addr); -HCI_API extern BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max, - UINT8 adv_type, UINT8 addr_type_own, - UINT8 addr_type_dir, BD_ADDR direct_bda, - UINT8 channel_map, UINT8 scan_filter_policy); +extern BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max, + UINT8 adv_type, UINT8 addr_type_own, + UINT8 addr_type_dir, BD_ADDR direct_bda, + UINT8 channel_map, UINT8 scan_filter_policy); -HCI_API extern BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void); +extern BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void); -HCI_API extern BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data); +extern BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data); -HCI_API extern BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp); +extern BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp); -HCI_API extern BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable); +extern BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable); -HCI_API extern BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type, - UINT16 scan_int, UINT16 scan_win, - UINT8 addr_type, UINT8 scan_filter_policy); +extern BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type, + UINT16 scan_int, UINT16 scan_win, + UINT8 addr_type, UINT8 scan_filter_policy); -HCI_API extern BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate); +extern BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate); -HCI_API extern BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win, - UINT8 init_filter_policy, UINT8 addr_type_peer, BD_ADDR bda_peer, UINT8 addr_type_own, - UINT16 conn_int_min, UINT16 conn_int_max, UINT16 conn_latency, UINT16 conn_timeout, - UINT16 min_ce_len, UINT16 max_ce_len); +extern BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win, + UINT8 init_filter_policy, UINT8 addr_type_peer, BD_ADDR bda_peer, UINT8 addr_type_own, + UINT16 conn_int_min, UINT16 conn_int_max, UINT16 conn_latency, UINT16 conn_timeout, + UINT16 min_ce_len, UINT16 max_ce_len); -HCI_API extern BOOLEAN btsnd_hcic_ble_create_conn_cancel (void); +extern BOOLEAN btsnd_hcic_ble_create_conn_cancel (void); -HCI_API extern BOOLEAN btsnd_hcic_ble_read_white_list_size (void); +extern BOOLEAN btsnd_hcic_ble_read_white_list_size (void); -HCI_API extern BOOLEAN btsnd_hcic_ble_clear_white_list (void); +extern BOOLEAN btsnd_hcic_ble_clear_white_list (void); -HCI_API extern BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda); +extern BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda); -HCI_API extern BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda); +extern BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda); -HCI_API extern BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle, UINT16 conn_int_min, UINT16 conn_int_max, - UINT16 conn_latency, UINT16 conn_timeout, UINT16 min_len, UINT16 max_len); +extern BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle, UINT16 conn_int_min, UINT16 conn_int_max, + UINT16 conn_latency, UINT16 conn_timeout, UINT16 min_len, UINT16 max_len); -HCI_API extern BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE]); +extern BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE]); -HCI_API extern BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle); +extern BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle); -HCI_API extern BOOLEAN btsnd_hcic_ble_read_remote_feat ( UINT16 handle); +extern BOOLEAN btsnd_hcic_ble_read_remote_feat ( UINT16 handle); -HCI_API extern BOOLEAN btsnd_hcic_ble_encrypt (UINT8* key, UINT8 key_len, UINT8* plain_text, UINT8 pt_len, void *p_cmd_cplt_cback); +extern BOOLEAN btsnd_hcic_ble_encrypt (UINT8* key, UINT8 key_len, UINT8* plain_text, UINT8 pt_len, void *p_cmd_cplt_cback); -HCI_API extern BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback); +extern BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback); -HCI_API extern BOOLEAN btsnd_hcic_ble_start_enc ( UINT16 handle, - UINT8 rand[HCIC_BLE_RAND_DI_SIZE], - UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]); +extern BOOLEAN btsnd_hcic_ble_start_enc ( UINT16 handle, + UINT8 rand[HCIC_BLE_RAND_DI_SIZE], + UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]); -HCI_API extern BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]); +extern BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]); -HCI_API extern BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle); +extern BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle); -HCI_API extern BOOLEAN btsnd_hcic_ble_read_supported_states (void); +extern BOOLEAN btsnd_hcic_ble_read_supported_states (void); -HCI_API extern BOOLEAN btsnd_hcic_ble_write_host_supported (UINT8 le_host_spt, UINT8 simul_le_host_spt); +extern BOOLEAN btsnd_hcic_ble_write_host_supported (UINT8 le_host_spt, UINT8 simul_le_host_spt); -HCI_API extern BOOLEAN btsnd_hcic_ble_read_host_supported (void); +extern BOOLEAN btsnd_hcic_ble_read_host_supported (void); -HCI_API extern BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq); +extern BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq); -HCI_API extern BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len, - UINT8 payload); -HCI_API extern BOOLEAN btsnd_hcic_ble_test_end(void); +extern BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len, + UINT8 payload); +extern BOOLEAN btsnd_hcic_ble_test_end(void); #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE) #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14 -HCI_API extern BOOLEAN btsnd_hcic_ble_rc_param_req_reply(UINT16 handle, - UINT16 conn_int_min, UINT16 conn_int_max, - UINT16 conn_latency, UINT16 conn_timeout, - UINT16 min_ce_len, UINT16 max_ce_len); +extern BOOLEAN btsnd_hcic_ble_rc_param_req_reply(UINT16 handle, + UINT16 conn_int_min, UINT16 conn_int_max, + UINT16 conn_latency, UINT16 conn_timeout, + UINT16 min_ce_len, UINT16 max_ce_len); #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3 -HCI_API extern BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason); +extern BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason); #endif /* BLE_LLT_INCLUDED */ #endif /* BLE_INCLUDED */ -#ifdef __cplusplus -} #endif - -#endif - diff --git a/stack/include/hidh_api.h b/stack/include/hidh_api.h index 27e8ac5de..00b8fde6f 100644 --- a/stack/include/hidh_api.h +++ b/stack/include/hidh_api.h @@ -100,10 +100,10 @@ extern "C" ** Returns tHID_STATUS ** *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostGetSDPRecord (BD_ADDR addr, - tSDP_DISCOVERY_DB *p_db, - UINT32 db_len, - tHID_HOST_SDP_CALLBACK *sdp_cback ); +extern tHID_STATUS HID_HostGetSDPRecord (BD_ADDR addr, + tSDP_DISCOVERY_DB *p_db, + UINT32 db_len, + tHID_HOST_SDP_CALLBACK *sdp_cback ); /******************************************************************************* ** @@ -114,7 +114,7 @@ HID_API extern tHID_STATUS HID_HostGetSDPRecord (BD_ADDR addr, ** Returns tHID_STATUS ** *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostRegister (tHID_HOST_DEV_CALLBACK *dev_cback); +extern tHID_STATUS HID_HostRegister (tHID_HOST_DEV_CALLBACK *dev_cback); /******************************************************************************* ** @@ -125,7 +125,7 @@ HID_API extern tHID_STATUS HID_HostRegister (tHID_HOST_DEV_CALLBACK *dev_cback); ** Returns tHID_STATUS ** *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostDeregister(void); +extern tHID_STATUS HID_HostDeregister(void); /******************************************************************************* ** @@ -136,8 +136,8 @@ HID_API extern tHID_STATUS HID_HostDeregister(void); ** Returns tHID_STATUS ** *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostAddDev (BD_ADDR addr, UINT16 attr_mask, - UINT8 *handle ); +extern tHID_STATUS HID_HostAddDev (BD_ADDR addr, UINT16 attr_mask, + UINT8 *handle ); /******************************************************************************* ** @@ -148,7 +148,7 @@ HID_API extern tHID_STATUS HID_HostAddDev (BD_ADDR addr, UINT16 attr_mask, ** Returns tHID_STATUS ** *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostRemoveDev (UINT8 dev_handle ); +extern tHID_STATUS HID_HostRemoveDev (UINT8 dev_handle ); /******************************************************************************* ** @@ -160,7 +160,7 @@ HID_API extern tHID_STATUS HID_HostRemoveDev (UINT8 dev_handle ); ** Returns void ** *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostOpenDev (UINT8 dev_handle ); +extern tHID_STATUS HID_HostOpenDev (UINT8 dev_handle ); /******************************************************************************* ** @@ -171,9 +171,9 @@ HID_API extern tHID_STATUS HID_HostOpenDev (UINT8 dev_handle ); ** Returns void ** *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostWriteDev(UINT8 dev_handle, UINT8 t_type, - UINT8 param, UINT16 data, - UINT8 report_id, BT_HDR *pbuf); +extern tHID_STATUS HID_HostWriteDev(UINT8 dev_handle, UINT8 t_type, + UINT8 param, UINT16 data, + UINT8 report_id, BT_HDR *pbuf); /******************************************************************************* ** @@ -184,7 +184,7 @@ HID_API extern tHID_STATUS HID_HostWriteDev(UINT8 dev_handle, UINT8 t_type, ** Returns void ** *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle ); +extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle ); /******************************************************************************* ** Function HID_HostInit @@ -193,7 +193,7 @@ HID_API extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle ); ** ** Returns void *******************************************************************************/ -HID_API extern void HID_HostInit(void); +extern void HID_HostInit(void); /******************************************************************************* ** Function HID_HostSetSecurityLevel @@ -203,7 +203,7 @@ HID_API extern void HID_HostInit(void); ** ** Returns tHID_STATUS *******************************************************************************/ -HID_API extern tHID_STATUS HID_HostSetSecurityLevel( char serv_name[], UINT8 sec_lvl ); +extern tHID_STATUS HID_HostSetSecurityLevel( char serv_name[], UINT8 sec_lvl ); /******************************************************************************* ** @@ -227,7 +227,7 @@ BOOLEAN hid_known_hid_device (BD_ADDR bd_addr); ** Returns the new (current) trace level ** *******************************************************************************/ -HID_API extern UINT8 HID_HostSetTraceLevel (UINT8 new_level); +extern UINT8 HID_HostSetTraceLevel (UINT8 new_level); #ifdef __cplusplus } diff --git a/stack/include/l2c_api.h b/stack/include/l2c_api.h index c85d76b65..010161428 100644 --- a/stack/include/l2c_api.h +++ b/stack/include/l2c_api.h @@ -24,6 +24,8 @@ #ifndef L2C_API_H #define L2C_API_H +#include <stdbool.h> + #include "bt_target.h" #include "l2cdefs.h" #include "hcidefs.h" @@ -347,7 +349,7 @@ extern "C" ** BTM_SetSecurityLevel(). ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_Register (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info); +extern UINT16 L2CA_Register (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info); /******************************************************************************* ** @@ -359,7 +361,7 @@ L2C_API extern UINT16 L2CA_Register (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info); ** Returns void ** *******************************************************************************/ -L2C_API extern void L2CA_Deregister (UINT16 psm); +extern void L2CA_Deregister (UINT16 psm); /******************************************************************************* ** @@ -371,7 +373,7 @@ L2C_API extern void L2CA_Deregister (UINT16 psm); ** Returns PSM to use. ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_AllocatePSM(void); +extern UINT16 L2CA_AllocatePSM(void); /******************************************************************************* ** @@ -385,7 +387,7 @@ L2C_API extern UINT16 L2CA_AllocatePSM(void); ** Returns the CID of the connection, or 0 if it failed to start ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr); +extern UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr); /******************************************************************************* ** @@ -398,7 +400,7 @@ L2C_API extern UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr); ** Returns TRUE for success, FALSE for failure ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_ConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, +extern BOOLEAN L2CA_ConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result, UINT16 status); /******************************************************************************* @@ -414,9 +416,16 @@ L2C_API extern BOOLEAN L2CA_ConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid ** Returns the CID of the connection, or 0 if it failed to start ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, +extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_ERTM_INFO *p_ertm_info); +// This function sets the callback routines for the L2CAP connection referred to by +// |local_cid|. The callback routines can only be modified for outgoing connections +// established by |L2CA_ConnectReq| or accepted incoming connections. |callbacks| +// must not be NULL. This function returns true if the callbacks could be updated, +// false if not (e.g. |local_cid| was not found). +bool L2CA_SetConnectionCallbacks(uint16_t local_cid, const tL2CAP_APPL_INFO *callbacks); + /******************************************************************************* ** ** Function L2CA_ErtmConnectRsp @@ -429,7 +438,7 @@ L2C_API extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, ** Returns TRUE for success, FALSE for failure ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, +extern BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result, UINT16 status, tL2CAP_ERTM_INFO *p_ertm_info); @@ -442,7 +451,7 @@ L2C_API extern BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 ** Returns TRUE if configuration sent, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg); +extern BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg); /******************************************************************************* ** @@ -454,7 +463,7 @@ L2C_API extern BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg); ** Returns TRUE if configuration response sent, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg); +extern BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg); /******************************************************************************* ** @@ -465,7 +474,7 @@ L2C_API extern BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg); ** Returns TRUE if disconnect sent, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_DisconnectReq (UINT16 cid); +extern BOOLEAN L2CA_DisconnectReq (UINT16 cid); /******************************************************************************* ** @@ -477,7 +486,7 @@ L2C_API extern BOOLEAN L2CA_DisconnectReq (UINT16 cid); ** Returns void ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid); +extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid); /******************************************************************************* ** @@ -490,7 +499,7 @@ L2C_API extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid); ** L2CAP_DW_FAILED, if error ** *******************************************************************************/ -L2C_API extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data); +extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data); /******************************************************************************* ** @@ -501,7 +510,7 @@ L2C_API extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data); ** Returns TRUE if echo request sent, else FALSE. ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb); +extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb); /******************************************************************************* ** @@ -513,7 +522,13 @@ L2C_API extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb); ** Returns TRUE if echo request sent, else FALSE. ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback); +extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback); + +// Given a local channel identifier, |lcid|, this function returns the bound remote +// channel identifier, |rcid|, and the ACL link handle, |handle|. If |lcid| is not +// known or is invalid, this function returns false and does not modify the values +// pointed at by |rcid| and |handle|. |rcid| and |handle| may be NULL. +bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t *rcid, uint16_t *handle); /******************************************************************************* ** @@ -530,7 +545,7 @@ L2C_API extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO ** Returns TRUE if command succeeded, FALSE if failed ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout, +extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout, BOOLEAN is_global); /******************************************************************************* @@ -552,7 +567,7 @@ L2C_API extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout, ** NOTE This timeout applies to all logical channels active on the ** ACL link. *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout); +extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout); /******************************************************************************* ** @@ -564,7 +579,7 @@ L2C_API extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeo ** Returns the new (current) trace level ** *******************************************************************************/ -L2C_API extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level); +extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level); /******************************************************************************* ** @@ -582,7 +597,7 @@ L2C_API extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level); ** Returns the new (current) role ** *******************************************************************************/ -L2C_API extern UINT8 L2CA_SetDesireRole (UINT8 new_role); +extern UINT8 L2CA_SetDesireRole (UINT8 new_role); /******************************************************************************* ** @@ -593,7 +608,7 @@ L2C_API extern UINT8 L2CA_SetDesireRole (UINT8 new_role); ** Returns CID of 0 if none. ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_LocalLoopbackReq (UINT16 psm, UINT16 handle, BD_ADDR p_bd_addr); +extern UINT16 L2CA_LocalLoopbackReq (UINT16 psm, UINT16 handle, BD_ADDR p_bd_addr); /******************************************************************************* ** @@ -609,7 +624,7 @@ L2C_API extern UINT16 L2CA_LocalLoopbackReq (UINT16 psm, UINT16 handle, BD_ADDR ** Returns Number of buffers left queued for that CID ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush); +extern UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush); /******************************************************************************* @@ -623,7 +638,7 @@ L2C_API extern UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush); ** Returns TRUE if a valid channel, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SetAclPriority (BD_ADDR bd_addr, UINT8 priority); +extern BOOLEAN L2CA_SetAclPriority (BD_ADDR bd_addr, UINT8 priority); /******************************************************************************* ** @@ -636,7 +651,7 @@ L2C_API extern BOOLEAN L2CA_SetAclPriority (BD_ADDR bd_addr, UINT8 priority); ** Returns TRUE if valid channel, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_FlowControl (UINT16 cid, BOOLEAN data_enabled); +extern BOOLEAN L2CA_FlowControl (UINT16 cid, BOOLEAN data_enabled); /******************************************************************************* ** @@ -647,7 +662,7 @@ L2C_API extern BOOLEAN L2CA_FlowControl (UINT16 cid, BOOLEAN data_enabled); ** Returns TRUE if valid Channel, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, UINT8 sup_type, +extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, UINT8 sup_type, UINT8 back_track); /******************************************************************************* @@ -659,7 +674,7 @@ L2C_API extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, UINT8 sup_type, ** Returns TRUE if a valid channel, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SetTxPriority (UINT16 cid, tL2CAP_CHNL_PRIORITY priority); +extern BOOLEAN L2CA_SetTxPriority (UINT16 cid, tL2CAP_CHNL_PRIORITY priority); /******************************************************************************* ** @@ -673,7 +688,7 @@ L2C_API extern BOOLEAN L2CA_SetTxPriority (UINT16 cid, tL2CAP_CHNL_PRIORITY prio ** Returns ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda); +extern BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda); /******************************************************************************* ** @@ -684,7 +699,7 @@ L2C_API extern BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda); ** Returns TRUE if a valid channel, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SetChnlDataRate (UINT16 cid, tL2CAP_CHNL_DATA_RATE tx, tL2CAP_CHNL_DATA_RATE rx); +extern BOOLEAN L2CA_SetChnlDataRate (UINT16 cid, tL2CAP_CHNL_DATA_RATE tx, tL2CAP_CHNL_DATA_RATE rx); typedef void (tL2CA_RESERVE_CMPL_CBACK) (void); @@ -709,7 +724,7 @@ typedef void (tL2CA_RESERVE_CMPL_CBACK) (void); ** NOTE This flush timeout applies to all logical channels active on the ** ACL link. *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout); +extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout); /******************************************************************************* ** @@ -726,7 +741,7 @@ L2C_API extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout) ** L2CAP_DW_FAILED, if error ** *******************************************************************************/ -L2C_API extern UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags); +extern UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags); /******************************************************************************* ** @@ -738,7 +753,7 @@ L2C_API extern UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags) ** Returns TRUE if CID found, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable); +extern BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable); /******************************************************************************* ** @@ -752,7 +767,7 @@ L2C_API extern BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushabl ** Return value: TRUE if peer is connected ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8 *p_chnl_mask); +extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8 *p_chnl_mask); /******************************************************************************* ** @@ -766,7 +781,7 @@ L2C_API extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat ** Return value: TRUE if found lcb for the given handle, FALSE otherwise ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr); +extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr); /******************************************************************************* ** @@ -779,7 +794,7 @@ L2C_API extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr); ** Return value: Channel mode ** *******************************************************************************/ -L2C_API extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid); +extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid); /******************************************************************************* @@ -832,7 +847,7 @@ typedef struct ** Return value: TRUE if successs ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info ); +extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info ); /******************************************************************************* ** @@ -845,7 +860,7 @@ L2C_API extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_i ** Return value: TRUE if successs ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm ); +extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm ); /******************************************************************************* ** @@ -862,7 +877,7 @@ L2C_API extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm ); ** Return value: TRUE if successs ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type ); +extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type ); /******************************************************************************* ** @@ -881,7 +896,7 @@ L2C_API extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 inf ** L2CAP_DW_FAILED, if error ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 flags); +extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 flags); /******************************************************************************* ** @@ -895,7 +910,7 @@ L2C_API extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_ ** Return value: TRUE if successs ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout ); +extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout ); /******************************************************************************* ** @@ -906,7 +921,7 @@ L2C_API extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout ** Returns TRUE if a valid channel, else FALSE ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_UCDSetTxPriority ( BD_ADDR rem_bda, tL2CAP_CHNL_PRIORITY priority ); +extern BOOLEAN L2CA_UCDSetTxPriority ( BD_ADDR rem_bda, tL2CAP_CHNL_PRIORITY priority ); /******************************************************************************* @@ -963,7 +978,7 @@ typedef struct ** Return value: TRUE if registered OK ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_freg); +extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_freg); /******************************************************************************* ** @@ -977,7 +992,7 @@ L2C_API extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXE ** Return value: TRUE if connection started ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr); +extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr); /******************************************************************************* ** @@ -993,7 +1008,7 @@ L2C_API extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr) ** L2CAP_DW_FAILED, if error ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf); +extern UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf); /******************************************************************************* ** @@ -1008,7 +1023,7 @@ L2C_API extern UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, ** Return value: TRUE if channel removed ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda); +extern BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda); /******************************************************************************* ** @@ -1027,7 +1042,7 @@ L2C_API extern BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda); ** Returns TRUE if command succeeded, FALSE if failed ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle_tout); +extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle_tout); #endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */ @@ -1044,74 +1059,9 @@ L2C_API extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_c ** Returns TRUE if successful ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid, - tL2CAP_CFG_INFO **pp_our_cfg, tL2CAP_CH_CFG_BITS *p_our_cfg_bits, - tL2CAP_CFG_INFO **pp_peer_cfg, tL2CAP_CH_CFG_BITS *p_peer_cfg_bits); - -#if (L2CAP_CORRUPT_ERTM_PKTS == TRUE) -/******************************************************************************* -** -** Function L2CA_SetupErtmTest -** -** Description This function is used for testing purposes only. -** It corrupts or drops one or more packets used with ERTM channels. -** -** Parameters -** cid - channel ID (0 uses RFCOMM PSM's CID) -** -** type - type of test to run (L2CAP_FCR_TTYPE_CORR_IFRAMES -** L2CAP_FCR_TTYPE_CORR_SFRAME -** L2CAP_FCR_TTYPE_STOP_TEST -** L2CAP_FCR_TTYPE_GET_CID - returns rfcomm cid only) -** -** is_rx - TRUE to corrupt Rx packet, FALSE for Tx packet) -** -** freq - L2CAP_FCR_FREQ_RANDOM (turns on random corruptions/drops) -** L2CAP_FCR_FREQ_NORMAL (turns on test with "count" corruptions/drops) -** -** count - number of packets in a row to drop or corrupt -** -** Returns CID of channel running test -** -*******************************************************************************/ -L2C_API extern UINT16 L2CA_SetupErtmTest (UINT16 cid, UINT8 type, BOOLEAN is_rx, UINT8 freq, UINT16 count); - -/******************************************************************************* -** -** Function L2CA_SendPolledSFrame -** -** Description This function is used for testing purposes only. -** It Sends a Polled RR or RNR to the peer -** -** Parameters -** cid - channel ID -** -** sup_type - (L2CAP_FCR_SUP_RR or L2CAP_FCR_SUP_RNR) -** -** Returns void -** -*******************************************************************************/ -L2C_API extern void L2CA_SendPolledSFrame (UINT16 cid, UINT16 sup_type); - -/******************************************************************************* -** -** Function L2CA_BypassSFrame -** -** Description This function is used for testing purposes only. -** It skips sending 'count' S-Frames. -** -** Parameters -** cid - channel ID -** -** count - Number of S-Frames to skip sending -** -** Returns void -** -*******************************************************************************/ -L2C_API extern void L2CA_BypassSFrame (UINT16 cid, UINT8 count); - -#endif /* (L2CAP_CORRUPT_ERTM_PKTS == TRUE) */ - +extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid, + tL2CAP_CFG_INFO **pp_our_cfg, tL2CAP_CH_CFG_BITS *p_our_cfg_bits, + tL2CAP_CFG_INFO **pp_peer_cfg, tL2CAP_CH_CFG_BITS *p_peer_cfg_bits); #if (BLE_INCLUDED == TRUE) /******************************************************************************* @@ -1125,7 +1075,7 @@ L2C_API extern void L2CA_BypassSFrame (UINT16 cid, UINT8 count); ** Return value: TRUE if connection was cancelled ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda); +extern BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda); /******************************************************************************* ** @@ -1138,8 +1088,8 @@ L2C_API extern BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda); ** Return value: TRUE if update started ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bdRa, UINT16 min_int, - UINT16 max_int, UINT16 latency, UINT16 timeout); +extern BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bdRa, UINT16 min_int, + UINT16 max_int, UINT16 latency, UINT16 timeout); /******************************************************************************* ** @@ -1153,7 +1103,7 @@ L2C_API extern BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bdRa, UINT16 min_in ** Return value: TRUE if update started ** *******************************************************************************/ -L2C_API extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable); +extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable); /******************************************************************************* ** @@ -1164,7 +1114,7 @@ L2C_API extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN ** Returns link role. ** *******************************************************************************/ -L2C_API extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr); +extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr); /******************************************************************************* ** @@ -1178,7 +1128,7 @@ L2C_API extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr); ** Returns disconnect reason ** *******************************************************************************/ -L2C_API extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport); +extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport); #endif /* (BLE_INCLUDED == TRUE) */ diff --git a/stack/include/l2cap_client.h b/stack/include/l2cap_client.h new file mode 100644 index 000000000..b995d5e68 --- /dev/null +++ b/stack/include/l2cap_client.h @@ -0,0 +1,74 @@ +/****************************************************************************** + * + * Copyright (C) 2014 Google, Inc. + * + * 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. + * + ******************************************************************************/ + +#pragma once + +#include <hardware/bluetooth.h> +#include <stdbool.h> +#include <stdint.h> + +typedef struct buffer_t buffer_t; +typedef struct l2cap_client_t l2cap_client_t; + +typedef struct { + void (*connected)(l2cap_client_t *client, void *context); + void (*disconnected)(l2cap_client_t *client, void *context); + void (*read_ready)(l2cap_client_t *client, buffer_t *packet, void *context); + void (*write_ready)(l2cap_client_t *client, void *context); +} l2cap_client_callbacks_t; + +// Returns a new buffer with enough space for |size| bytes of L2CAP payload. +// |size| must be greater than zero. This function returns NULL if the buffer +// could not be allocated. The returned buffer must be freed with |buffer_free| +// when it is no longer needed. +buffer_t *l2cap_buffer_new(size_t size); + +// Creates and returns a new L2CAP client object. |callbacks| must not be NULL and +// must specify a set of functions that should be called back when events occur +// on the L2CAP connection. |context| may be NULL and will be passed as the argument +// to all callbacks in |l2cap_client_callbacks_t|. The returned object must be freed +// with |l2cap_client_free|. +l2cap_client_t *l2cap_client_new(const l2cap_client_callbacks_t *callbacks, void *context); + +// Frees the L2CAP client object allocated with |l2cap_client_new|. |client| may be NULL. +void l2cap_client_free(l2cap_client_t *client); + +// Attempts to connect the |client| to a peer device specified by |remote_bdaddr| +// using the |psm| protocol specifier. This function returns true if the connect +// operation could be started and will indicate completion with either a 'connected' +// callback (success) or a 'disconnected' callback (failure). +// +// This function must not be called while a connect operation is in progress or +// while |l2cap_client_is_connected|. |client| and |remote_bdaddr| must not be NULL. +// |psm| must be greater than zero. +bool l2cap_client_connect(l2cap_client_t *client, const bt_bdaddr_t *remote_bdaddr, uint16_t psm); + +// Disconnects a connected |client|. This function is asynchronous and idempotent. It +// will indicate completion with a 'disconnected' callback. |client| must not be NULL. +void l2cap_client_disconnect(l2cap_client_t *client); + +// Returns true if |client| is connected and is ready to accept data written to it. +// |client| must not be NULL. +bool l2cap_client_is_connected(const l2cap_client_t *client); + +// Writes data contained in |packet| to a connected |client|. This function returns +// true if the packet was successfully queued for delivery, false if the client cannot +// accept more data at this time. If this function returns false, the caller must wait +// for the 'write_ready' callback to write additional data to the client. Neither +// |client| nor |packet| may be NULL. +bool l2cap_client_write(l2cap_client_t *client, buffer_t *packet); diff --git a/stack/include/l2cdefs.h b/stack/include/l2cdefs.h index fe414760d..1063749dd 100644 --- a/stack/include/l2cdefs.h +++ b/stack/include/l2cdefs.h @@ -293,17 +293,4 @@ #define L2CAP_FCR_INIT_CRC 0 /* Initial state of the CRC register */ #define L2CAP_FCR_SEQ_MODULO 0x3F /* Mask for sequence numbers (range 0 - 63) */ -/************************************************************************************************* -** The following definitions are only used for internal testing of ERTM at the application level -*************************************************************************************************/ -/* L2CA_SetupErtmTest() corruption test types */ -#define L2CAP_FCR_TTYPE_CORR_IFRAME 0 /* Corrupt one or more I-frames, based on count */ -#define L2CAP_FCR_TTYPE_CORR_SFRAME 1 /* Corrupt an S-frame, (acknowledgement) */ -#define L2CAP_FCR_TTYPE_STOP_TEST 2 /* Used when turning off a test */ -#define L2CAP_FCR_TTYPE_GET_CID 3 /* Returns RFCOMM cid when '0' is passed in cid argument */ - -/* L2CA_SetupErtmTest() Freq */ -#define L2CAP_FCR_FREQ_NORMAL 0 /* A single test is run */ -#define L2CAP_FCR_FREQ_RANDOM 1 /* Randomly loses or corrupts a packet */ - #endif diff --git a/stack/include/mca_api.h b/stack/include/mca_api.h index d455e5b35..57e8f8be2 100644 --- a/stack/include/mca_api.h +++ b/stack/include/mca_api.h @@ -224,7 +224,7 @@ typedef void (tMCA_CTRL_CBACK)(tMCA_HANDLE handle, tMCA_CL mcl, UINT8 event, ** Returns void ** *******************************************************************************/ -MCA_API extern void MCA_Init(void); +extern void MCA_Init(void); /******************************************************************************* ** @@ -247,7 +247,7 @@ MCA_API extern void MCA_Init(void); ** the input parameter is 0xff. ** *******************************************************************************/ -MCA_API extern UINT8 MCA_SetTraceLevel (UINT8 level); +extern UINT8 MCA_SetTraceLevel (UINT8 level); /******************************************************************************* ** @@ -261,7 +261,7 @@ MCA_API extern UINT8 MCA_SetTraceLevel (UINT8 level); ** Returns 0, if failed. Otherwise, the MCA handle. ** *******************************************************************************/ -MCA_API extern tMCA_HANDLE MCA_Register(tMCA_REG *p_reg, tMCA_CTRL_CBACK *p_cback); +extern tMCA_HANDLE MCA_Register(tMCA_REG *p_reg, tMCA_CTRL_CBACK *p_cback); /******************************************************************************* ** @@ -274,7 +274,7 @@ MCA_API extern tMCA_HANDLE MCA_Register(tMCA_REG *p_reg, tMCA_CTRL_CBACK *p_cbac ** Returns void ** *******************************************************************************/ -MCA_API extern void MCA_Deregister(tMCA_HANDLE handle); +extern void MCA_Deregister(tMCA_HANDLE handle); /******************************************************************************* ** @@ -288,7 +288,7 @@ MCA_API extern void MCA_Deregister(tMCA_HANDLE handle); ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_CreateDep(tMCA_HANDLE handle, tMCA_DEP *p_dep, tMCA_CS *p_cs); +extern tMCA_RESULT MCA_CreateDep(tMCA_HANDLE handle, tMCA_DEP *p_dep, tMCA_CS *p_cs); /******************************************************************************* ** @@ -303,7 +303,7 @@ MCA_API extern tMCA_RESULT MCA_CreateDep(tMCA_HANDLE handle, tMCA_DEP *p_dep, tM ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_DeleteDep(tMCA_HANDLE handle, tMCA_DEP dep); +extern tMCA_RESULT MCA_DeleteDep(tMCA_HANDLE handle, tMCA_DEP dep); /******************************************************************************* ** @@ -321,9 +321,9 @@ MCA_API extern tMCA_RESULT MCA_DeleteDep(tMCA_HANDLE handle, tMCA_DEP dep); ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_ConnectReq(tMCA_HANDLE handle, BD_ADDR bd_addr, - UINT16 ctrl_psm, - UINT16 sec_mask); +extern tMCA_RESULT MCA_ConnectReq(tMCA_HANDLE handle, BD_ADDR bd_addr, + UINT16 ctrl_psm, + UINT16 sec_mask); /******************************************************************************* ** @@ -338,7 +338,7 @@ MCA_API extern tMCA_RESULT MCA_ConnectReq(tMCA_HANDLE handle, BD_ADDR bd_addr, ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_DisconnectReq(tMCA_CL mcl); +extern tMCA_RESULT MCA_DisconnectReq(tMCA_CL mcl); /******************************************************************************* ** @@ -355,9 +355,9 @@ MCA_API extern tMCA_RESULT MCA_DisconnectReq(tMCA_CL mcl); ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_CreateMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm, - UINT16 mdl_id, UINT8 peer_dep_id, - UINT8 cfg, const tMCA_CHNL_CFG *p_chnl_cfg); +extern tMCA_RESULT MCA_CreateMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm, + UINT16 mdl_id, UINT8 peer_dep_id, + UINT8 cfg, const tMCA_CHNL_CFG *p_chnl_cfg); /******************************************************************************* ** @@ -373,9 +373,9 @@ MCA_API extern tMCA_RESULT MCA_CreateMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_ ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_CreateMdlRsp(tMCA_CL mcl, tMCA_DEP dep, - UINT16 mdl_id, UINT8 cfg, UINT8 rsp_code, - const tMCA_CHNL_CFG *p_chnl_cfg); +extern tMCA_RESULT MCA_CreateMdlRsp(tMCA_CL mcl, tMCA_DEP dep, + UINT16 mdl_id, UINT8 cfg, UINT8 rsp_code, + const tMCA_CHNL_CFG *p_chnl_cfg); /******************************************************************************* ** @@ -388,7 +388,7 @@ MCA_API extern tMCA_RESULT MCA_CreateMdlRsp(tMCA_CL mcl, tMCA_DEP dep, ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_CloseReq(tMCA_DL mdl); +extern tMCA_RESULT MCA_CloseReq(tMCA_DL mdl); /******************************************************************************* ** @@ -403,8 +403,8 @@ MCA_API extern tMCA_RESULT MCA_CloseReq(tMCA_DL mdl); ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_ReconnectMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm, - UINT16 mdl_id, const tMCA_CHNL_CFG *p_chnl_cfg); +extern tMCA_RESULT MCA_ReconnectMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm, + UINT16 mdl_id, const tMCA_CHNL_CFG *p_chnl_cfg); /******************************************************************************* ** @@ -419,9 +419,9 @@ MCA_API extern tMCA_RESULT MCA_ReconnectMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 da ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_ReconnectMdlRsp(tMCA_CL mcl, tMCA_DEP dep, - UINT16 mdl_id, UINT8 rsp_code, - const tMCA_CHNL_CFG *p_chnl_cfg); +extern tMCA_RESULT MCA_ReconnectMdlRsp(tMCA_CL mcl, tMCA_DEP dep, + UINT16 mdl_id, UINT8 rsp_code, + const tMCA_CHNL_CFG *p_chnl_cfg); /******************************************************************************* ** @@ -435,7 +435,7 @@ MCA_API extern tMCA_RESULT MCA_ReconnectMdlRsp(tMCA_CL mcl, tMCA_DEP dep, ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_DataChnlCfg(tMCA_CL mcl, const tMCA_CHNL_CFG *p_chnl_cfg); +extern tMCA_RESULT MCA_DataChnlCfg(tMCA_CL mcl, const tMCA_CHNL_CFG *p_chnl_cfg); /******************************************************************************* ** @@ -447,7 +447,7 @@ MCA_API extern tMCA_RESULT MCA_DataChnlCfg(tMCA_CL mcl, const tMCA_CHNL_CFG *p_c ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_Abort(tMCA_CL mcl); +extern tMCA_RESULT MCA_Abort(tMCA_CL mcl); /******************************************************************************* ** @@ -459,7 +459,7 @@ MCA_API extern tMCA_RESULT MCA_Abort(tMCA_CL mcl); ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_Delete(tMCA_CL mcl, UINT16 mdl_id); +extern tMCA_RESULT MCA_Delete(tMCA_CL mcl, UINT16 mdl_id); /******************************************************************************* ** @@ -479,7 +479,7 @@ MCA_API extern tMCA_RESULT MCA_Delete(tMCA_CL mcl, UINT16 mdl_id); ** Returns MCA_SUCCESS if successful, otherwise error. ** *******************************************************************************/ -MCA_API extern tMCA_RESULT MCA_WriteReq(tMCA_DL mdl, BT_HDR *p_pkt); +extern tMCA_RESULT MCA_WriteReq(tMCA_DL mdl, BT_HDR *p_pkt); /******************************************************************************* ** @@ -490,6 +490,6 @@ MCA_API extern tMCA_RESULT MCA_WriteReq(tMCA_DL mdl, BT_HDR *p_pkt); ** Returns L2CAP channel ID if successful, otherwise 0. ** *******************************************************************************/ -MCA_API extern UINT16 MCA_GetL2CapChannel (tMCA_DL mdl); +extern UINT16 MCA_GetL2CapChannel (tMCA_DL mdl); #endif /* MCA_API_H */ diff --git a/stack/include/obx_api.h b/stack/include/obx_api.h deleted file mode 100644 index 472eeb047..000000000 --- a/stack/include/obx_api.h +++ /dev/null @@ -1,1704 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2003-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. - * - ******************************************************************************/ -#ifndef OBX_API_H -#define OBX_API_H -#include "bt_target.h" -#include "bt_types.h" -#include "l2c_api.h" - -/* 18 is 7/OBX_CONN_HDRS_OFFSET + 5/conn id, 2/ssn, 2/srm 2/srm_param */ -#define OBX_HDR_OFFSET (18 + L2CAP_MIN_OFFSET) -#define OBX_MAX_TRIPLET 3 - -#define OBX_MIN_MTU 255 /* per IrOBEX spec */ -#define OBX_MAX_MTU (OBX_LRG_DATA_POOL_SIZE - BT_HDR_SIZE - OBX_HDR_OFFSET) - -#define OBX_CONN_ID_SIZE 4 -#define OBX_PKT_LEN_SIZE 2 - -#define OBX_CONN_HDRS_OFFSET 7 -#define OBX_SESS_HDRS_OFFSET 3 -#define OBX_DISCON_HDRS_OFFSET 3 -#define OBX_PUT_HDRS_OFFSET 3 -#define OBX_GET_HDRS_OFFSET 3 -#define OBX_SETPATH_REQ_HDRS_OFFSET 5 -#define OBX_ABORT_HDRS_OFFSET 3 -#define OBX_ACTION_HDRS_OFFSET 3 -#define OBX_RESPONSE_HDRS_OFFSET 3 - -/* this is not needed if OBX_HDR_OFFSET is 18+ */ -#define OBX_MAX_CONN_HDR_EXTRA 8 /* 5/conn id, 2/ssn, 2/srm 2/srm_param - (5/setpath + 5/conn_id - 7/conn) */ - -/* offset for header functions to access fields */ -#define OBX_CONNECT_MTU_OFFSET 5 -#define OBX_SETPATH_FLAG_OFFSET 3 - -#define OBX_MAX_NUM_AUTH_TRIPLET 3 -#define OBX_UNICODE_SIZE 2 /* sizeof(UINT16) */ - -#define OBX_INVALID_HDR_LEN 0xFFFF - -#define OBX_MIN_NONCE_SIZE 4 /* fixed size per IrOBEX spec */ -#define OBX_NONCE_SIZE 16 /* fixed size per IrOBEX spec */ -#define OBX_DIGEST_SIZE 16 /* fixed size per IrOBEX spec */ -#define OBX_MAX_AUTH_KEY_SIZE 16 -#define OBX_MAX_AUTH_USER_SIZE 20 -#define OBX_SESSION_ID_SIZE 16 /* fixed size per IrOBEX spec */ -#define OBX_SESSION_INFO_SIZE 32 /* OBX_SESSION_ID_SIZE + 4(local nonce) + 4 (connection id) + 4 (timeout) + 2(mtu) + 1(state) + 1(srm) */ -#define OBX_SESSION_INFO_NONCE_IDX 16 /* The index to the (local nonce) in session info */ -#define OBX_SESSION_INFO_ID_IDX 20 /* The index to the (connection id) in session info */ -#define OBX_SESSION_INFO_TO_IDX 24 /* The index to the (timeout) in session info */ -#define OBX_SESSION_INFO_MTU_IDX 28 /* The index to peer MTU in session info */ -#define OBX_SESSION_INFO_ST_IDX 30 /* The index to sr/cl state in session info */ -#define OBX_SESSION_INFO_SRM_IDX 31 /* The index to srm in session info */ -#define OBX_TIMEOUT_SIZE 4 - -/* handle related definitions */ -#define OBX_SESS_SHIFT 8 -#define OBX_ENC_SESS_HANDLE(oh, os) (((os)<<OBX_SESS_SHIFT)|(oh)) -#define OBX_HANDLE_MASK 0xFF -#define OBX_SESS_MASK 0x7F00 -#define OBX_DEC_HANDLE(os) ((os) & OBX_HANDLE_MASK) -#define OBX_DEC_SESS_IND(os) ((os & OBX_SESS_MASK)>>OBX_SESS_SHIFT) - -/* Return values for API functions */ -enum -{ - OBX_SUCCESS, /* Status is successful. */ - OBX_BAD_PARAMS, /* Bad parameter(s). */ - OBX_NO_RESOURCES, /* No resources (GKI buffers, control block) */ - OBX_BAD_HANDLE /* The OBEX handle is not valid. */ -}; -typedef UINT8 tOBX_STATUS; - - -typedef UINT16 tOBX_HANDLE; - -#define OBX_HANDLE_NULL 0 - -enum -{ - OBX_PT_PUT, /* Regular Put request */ - OBX_PT_DELETE, /* Delete request - a Put request with NO Body or End-of-Body header. */ - OBX_PT_CREATE /* Create-Empty request - a Put request with an empty End-of-Body header. */ -}; -typedef UINT8 tOBX_PUT_TYPE; - -/* SetPath Request Flags - the following definitions can be ORed if both flags are wanted */ -#define OBX_SPF_BACKUP 0x01 /* Backup a level before applying name(equivalent to ../) */ -#define OBX_SPF_NO_CREATE 0x02 /* Don't create directory if it does not exist, return an error instead. */ -typedef UINT8 tOBX_SETPATH_FLAG; - -/* Authentication Challenge Options */ -#define OBX_AO_NONE 0x00 /* If this is used in OBX_StartServer and the authenticate - * flag is TRUE, the optional Challenge Information (tag 0x01) - * will not be sent. */ -#define OBX_AO_USR_ID 0x01 /* Set this bit to make the client respond with the user ID. */ -typedef UINT8 tOBX_AUTH_OPT; - -/* CHARSET definition for Authentication Challenge Realm */ -#define OBX_RCS_ASCII 0x00 /* ASCII */ -#define OBX_RCS_8859_1 0x01 /* ISO-8859-1 */ -#define OBX_RCS_8859_2 0x02 /* ISO-8859-2 */ -#define OBX_RCS_8859_3 0x03 /* ISO-8859-3 */ -#define OBX_RCS_8859_4 0x04 /* ISO-8859-4 */ -#define OBX_RCS_8859_5 0x05 /* ISO-8859-5 */ -#define OBX_RCS_8859_6 0x06 /* ISO-8859-6 */ -#define OBX_RCS_8859_7 0x07 /* ISO-8859-7 */ -#define OBX_RCS_8859_8 0x08 /* ISO-8859-8 */ -#define OBX_RCS_8859_9 0x09 /* ISO-8859-9 */ -#define OBX_RCS_UNICODE 0xFF /* Unicode */ -typedef UINT8 tOBX_CHARSET; - -typedef struct -{ - UINT8 ssn; /* session sequence number */ - BOOLEAN final; /* TRUE, if this is the final packet of this PUT transaction. */ - tOBX_PUT_TYPE type; /* The type of PUT request. */ -} tOBX_PUT_EVT; - -typedef struct -{ - UINT8 ssn; /* session sequence number */ - BOOLEAN final; /* TRUE, if this is the final packet of this GET transaction. */ -} tOBX_GET_EVT; - -typedef struct -{ - UINT8 ssn; /* session sequence number */ - BD_ADDR peer_addr; /* The peer Bluetooth Address. */ - UINT16 mtu; /* The peer MTU. This element is associated with OBX_CONNECT_REQ_EVT and OBX_CONNECT_RSP_EVT. */ - tOBX_HANDLE handle; /* the OBX handle returned by OBX_StartServer(), OBX_CreateSession() and OBX_ConnectReq() */ - BOOLEAN no_rsp; /* TRUE, when the event is generated as a part of RESUME SESSION */ -} tOBX_CONN_EVT; - -/* Session Opcode Definitions: */ -#define OBX_SESS_OP_CREATE 0x00 /* Create Session */ -#define OBX_SESS_OP_CLOSE 0x01 /* Close Session */ -#define OBX_SESS_OP_SUSPEND 0x02 /* Suspend Session */ -#define OBX_SESS_OP_RESUME 0x03 /* Resume Session */ -#define OBX_SESS_OP_SET_TIME 0x04 /* Set Timeout */ -#define OBX_SESS_OP_TRANSPORT 0xFF /* transport dropped */ -typedef UINT8 tOBX_SESS_OP; - -/* Session States Definitions for external use: */ -enum -{ - OBX_SESS_NONE, /* 0x00 session is not engaged/closed */ - OBX_SESS_ACTIVE, /* 0x01 session is active. */ - OBX_SESS_SUSPENDED, /* 0x02 session is suspended. */ - OBX_SESS_EXT_MAX -}; -typedef UINT8 tOBX_SESS_ST; - - -typedef struct -{ - UINT8 ssn; /* session sequence number */ - tOBX_SESS_OP sess_op; /* the session op code */ - tOBX_SESS_ST sess_st; /* the session state */ - BD_ADDR peer_addr; /* The peer Bluetooth Address. */ - UINT8 *p_sess_info; /* The session ID and the local nonce for a reliable session, a reference to the location in OBEX control block or NULL */ - UINT32 timeout; /* The number of seconds remaining in suspend. 0xffff if infinite. */ - UINT32 obj_offset; /* The object offset for resume session. */ - UINT8 nssn; /* tne next session sequence number the server expects */ -} tOBX_SESS_EVT; - -#define OBX_ACT_COPY 0x00 /* Copy object */ -#define OBX_ACT_MOVE 0x01 /* Move/rename object */ -#define OBX_ACT_PERMISSION 0x02 /* Set object permission */ -typedef UINT8 tOBX_ACTION; - -typedef struct -{ - UINT8 ssn; /* session sequence number */ - tOBX_ACTION action; /* The action opcode. */ -} tOBX_ACT_EVT; - -typedef struct -{ - UINT8 ssn; /* session sequence number */ - tOBX_SETPATH_FLAG flag; /* The set path flags. */ -} tOBX_SETPATH_EVT; - -/* permission flags */ -#define OBX_PERMISSION_READ 0x01 -#define OBX_PERMISSION_WRITE 0x02 -#define OBX_PERMISSION_DELETE 0x04 -#define OBX_PERMISSION_MODIFY 0x80 - -typedef union -{ - UINT8 ssn; /* session sequence number */ - tOBX_CONN_EVT conn; /* This element is associated with OBX_CONNECT_REQ_EVT and OBX_CONNECT_RSP_EVT. */ - tOBX_SESS_EVT sess; /* This element is associated with OBX_SESSION_RSP_EVT and OBX_SESSION_REQ_EVT. */ - tOBX_PUT_EVT put; /* This element is associated with OBX_PUT_REQ_EVT. */ - tOBX_SETPATH_EVT sp; /* This element is associated with OBX_SETPATH_REQ_EVT. */ - tOBX_ACT_EVT action; /* This element is associated with OBX_ACTION_REQ_EVT */ - tOBX_GET_EVT get; /* This element is associated with OBX_GET_REQ_EVT. TRUE, if this is the final packet that contains the OBEX headers for this GET request. */ -} tOBX_EVT_PARAM; - - -enum -{ - OBX_NULL_EVT, - /* server events */ - OBX_CONNECT_REQ_EVT, /* param = packet MTU */ - OBX_SESSION_REQ_EVT, /* A Crease Session or Resume Session request is received by the server. Call OBX_SessionRsp(). */ - OBX_DISCONNECT_REQ_EVT, - OBX_PUT_REQ_EVT, /* could have param indicate delete or create? */ - OBX_GET_REQ_EVT, - OBX_SETPATH_REQ_EVT, /* param = flags */ - OBX_ABORT_REQ_EVT, - OBX_ACTION_REQ_EVT, /* An Action request is received by the server. Call OBX_ActionRsp(). */ - - /* client events */ - OBX_CONNECT_RSP_EVT, /* param = packet MTU */ - OBX_SESSION_RSP_EVT, /* A response for Create Session or Resume Session is received by the client. The client needs to remember the session id. The session id is to be used in calling OBX_ResumeSession, if the current session is terminated prematurely. */ - OBX_DISCONNECT_RSP_EVT, - OBX_PUT_RSP_EVT, - OBX_GET_RSP_EVT, - OBX_SETPATH_RSP_EVT, - OBX_ABORT_RSP_EVT, - OBX_ACTION_RSP_EVT, /* An Action response is received by the client. */ - - /* common events */ - OBX_SESSION_INFO_EVT, /* the session information event to resume the session. */ - OBX_CLOSE_IND_EVT, /* when transport goes down; p_pkt = NULL; no response needed */ - OBX_TIMEOUT_EVT, /* param = tOBX_EVENT */ - OBX_PASSWORD_EVT -}; -typedef UINT8 tOBX_EVENT; - -/* this is used by the protocol display function only*/ -enum -{ - OBX_NULL_DISP, - /* server events */ - OBX_CONNECT_REQ_DISP, - OBX_SESSION_REQ_DISP, - OBX_DISCONNECT_REQ_DISP, - OBX_PUT_REQ_DISP, - OBX_GET_REQ_DISP, - OBX_SETPATH_REQ_DISP, - OBX_ABORT_REQ_DISP, - OBX_ACTION_REQ_DISP, - /* client events */ - OBX_CONNECT_RSP_DISP, - OBX_SESSION_RSP_DISP, - OBX_DISCONNECT_RSP_DISP, - OBX_PUT_RSP_DISP, - OBX_GET_RSP_DISP, - OBX_SETPATH_RSP_DISP, - OBX_ABORT_RSP_DISP, - OBX_ACTION_RSP_DISP, - /* common events */ - OBX_CLOSE_IND_DISP, - OBX_TIMEOUT_DISP, - OBX_PASSWORD_DISP -}; -#define OBX_DISP_IS_RECV 0x80 -#define OBX_DISP_TYPE_MASK 0x7F - -#define OBX_MAX_EVT OBX_PASSWORD_EVT -#define OBX_MAX_OFFSET_IND OBX_ABORT_RSP_EVT /* This is used to access obx_hdr_start_offset */ - -/* -** Define Miscellaneous Constants -*/ -#define OBX_VERSION 0x10 /* Version 1.0 */ -#define OBX_CONN_FLAGS 0 /* Connect flags per IrOBEX spec */ -#define OBX_SETPATH_CONST 0 /* SetPath Request constants per IrOBEX spec */ -#define OBX_INVALID_CONN_ID 0xFFFFFFFF /* invalid connection ID per IrOBEX spec */ -#define OBX_INFINITE_TIMEOUT 0xFFFFFFFF - -/* Header Identifier Data Type Constants */ -#define OBX_HI_TYPE_MASK 0xC0 /* This mask get the encoding (data type) of the header ID. */ -#define OBX_HI_ID_MASK 0x3F /* This mask gets the meaning of the header ID. */ -#define OBX_HI_TYPE_UNIC 0x00 /* Null terminated Unicode text */ -#define OBX_HI_TYPE_ARRAY 0x40 /* Unstructured octet array (byte sequence) */ -#define OBX_HI_TYPE_BYTE 0x80 /* 8-bit integer */ -#define OBX_HI_TYPE_INT 0xC0 /* 32-bit integer */ - -/* -** Define OBEX Header Identifiers -*/ -#define OBX_HI_NULL 0 -#define OBX_HI_COUNT 0xC0 -#define OBX_HI_NAME 0x01 -#define OBX_HI_TYPE 0x42 -#define OBX_HI_LENGTH 0xC3 -#define OBX_HI_TIME 0x44 -#define OBX_HI_DESCRIPTION 0x05 -#define OBX_HI_TARGET 0x46 -#define OBX_HI_HTTP 0x47 -#define OBX_HI_BODY 0x48 -#define OBX_HI_BODY_END 0x49 -#define OBX_HI_WHO 0x4A -#define OBX_HI_CONN_ID 0xCB -#define OBX_HI_APP_PARMS 0x4C -#define OBX_HI_CHALLENGE 0x4D -#define OBX_HI_AUTH_RSP 0x4E -#define OBX_HI_CREATOR_ID 0xCF -#define OBX_HI_WAN_UUID 0x50 -#define OBX_HI_OBJ_CLASS 0x51 -#define OBX_HI_SESSION_PARAM 0x52 -#define OBX_HI_SESSION_SN 0x93 -#define OBX_HI_ACTION_ID 0x94 -#define OBX_HI_DEST_NAME 0x15 -#define OBX_HI_PERMISSION 0xD6 -#define OBX_HI_SRM 0x97 -#define OBX_HI_SRM_PARAM 0x98 -#define OBX_HI_LO_USER 0x30 -#define OBX_HI_HI_USER 0x3F - -/* Obex Header Values for the SRM header */ -#define OBX_HV_SRM_DISABLE 0x00 /* SRM header value - disable */ -#define OBX_HV_SRM_ENABLE 0x01 /* SRM header value - enable */ -#define OBX_HV_SRM_IND 0x02 /* SRM header value - indicate support */ - -/* Obex Header Values for the SRM Parameter header */ -#define OBX_HV_SRM_PARAM_MORE 0x00 /* SRM Param header value - request additional packet */ -#define OBX_HV_SRM_PARAM_WAIT 0x01 /* SRM Param header value - wait for next req/rsp */ -#define OBX_HV_SRM_PARAM_COMBO 0x02 /* SRM Param header value - next and wait */ - -#define OBX_TAG_SESS_PARAM_ADDR 0x00 -#define OBX_TAG_SESS_PARAM_NONCE 0x01 -#define OBX_TAG_SESS_PARAM_SESS_ID 0x02 -#define OBX_TAG_SESS_PARAM_NSEQNUM 0x03 -#define OBX_TAG_SESS_PARAM_TOUT 0x04 -#define OBX_TAG_SESS_PARAM_SESS_OP 0x05 -#define OBX_TAG_SESS_PARAM_OBJ_OFF 0x06 -#define OBX_MAX_SESS_PARAM_TRIP 7 /* max number of TLV for session operations */ - -#define OBX_LEN_SESS_PARAM_SESS_OP 1 -#define OBX_LEN_SESS_PARAM_OBJ_OFF 4 /* this value varies, so it needs to be verified on the receiving side */ - -/* -** Define OBEX Request Codes -*/ -#define OBX_REQ_CONNECT 0x00 /* need to set final bit */ -#define OBX_REQ_DISCONNECT 0x01 /* need to set final bit */ -#define OBX_REQ_PUT 0x02 -#define OBX_REQ_GET 0x03 -#define OBX_REQ_SETPATH 0x05 /* need to set final bit */ -#define OBX_REQ_ACTION 0x06 -#define OBX_REQ_SESSION 0x07 /* need to set final bit */ -#define OBX_REQ_ABORT 0x7F /* need to set final bit */ -#define OBX_FINAL 0x80 - -/* OBEX response code as defined in IrOBEX spec. version 1.2 */ -#define OBX_RSP_DEFAULT 0x00 -#define OBX_RSP_FAILED 0x08 /* OBEX failed - not from spec */ -#define OBX_RSP_CONTINUE 0x10 /* Continue */ -#define OBX_RSP_OK 0x20 /* OK, Success */ -#define OBX_RSP_CREATED 0x21 /* Created */ -#define OBX_RSP_ACCEPTED 0x22 /* Accepted */ -#define OBX_RSP_NON_AUTH_INFO 0x23 /* Non-Authoritative Information */ -#define OBX_RSP_NO_CONTENT 0x24 /* No Content */ -#define OBX_RSP_RESET_CONTENT 0x25 /* Reset Content */ -#define OBX_RSP_PART_CONTENT 0x26 /* Partial Content */ -#define OBX_RSP_MULTI_CHOICES 0x30 /* Multiple Choices */ -#define OBX_RSP_MVD_PERM 0x31 /* Moved Permanently */ -#define OBX_RSP_MVD_TEMP 0x32 /* Moved temporarily */ -#define OBX_RSP_SEE_OTHER 0x33 /* See Other */ -#define OBX_RSP_NOT_MODIFIED 0x34 /* Not modified */ -#define OBX_RSP_USE_PROXY 0x35 /* Use Proxy */ -#define OBX_RSP_BAD_REQUEST 0x40 /* Bad Request - server couldn't understand request */ -#define OBX_RSP_UNAUTHORIZED 0x41 /* Unauthorized */ -#define OBX_RSP_PAYMENT_REQD 0x42 /* Payment required */ -#define OBX_RSP_FORBIDDEN 0x43 /* Forbidden - operation is understood but refused */ -#define OBX_RSP_NOT_FOUND 0x44 /* Not Found */ -#define OBX_RSP_NOT_ALLOWED 0x45 /* Method not allowed */ -#define OBX_RSP_NOT_ACCEPTABLE 0x46 /* Not Acceptable */ -#define OBX_RSP_PROXY_AUTH_REQD 0x47 /* Proxy Authentication required */ -#define OBX_RSP_REQUEST_TIMEOUT 0x48 /* Request Time Out */ -#define OBX_RSP_CONFLICT 0x49 /* Conflict */ -#define OBX_RSP_GONE 0x4A /* Gone */ -#define OBX_RSP_LENGTH_REQD 0x4B /* Length Required */ -#define OBX_RSP_PRECONDTN_FAILED 0x4C /* Precondition failed */ -#define OBX_RSP_REQ_ENT_2_LARGE 0x4D /* Requested entity too large */ -#define OBX_RSP_REQ_URL_2_LARGE 0x4E /* Request URL too large */ -#define OBX_RSP_UNSUPTD_TYPE 0x4F /* Unsupported media type */ -#define OBX_RSP_INTRNL_SRVR_ERR 0x50 /* Internal Server Error */ -#define OBX_RSP_NOT_IMPLEMENTED 0x51 /* Not Implemented */ -#define OBX_RSP_BAD_GATEWAY 0x52 /* Bad Gateway */ -#define OBX_RSP_SERVICE_UNAVL 0x53 /* Service Unavailable */ -#define OBX_RSP_GATEWAY_TIMEOUT 0x54 /* Gateway Timeout */ -#define OBX_RSP_HTTP_VER_NOT_SUPTD 0x55 /* HTTP version not supported */ -#define OBX_RSP_DATABASE_FULL 0x60 /* Database Full */ -#define OBX_RSP_DATABASE_LOCKED 0x61 /* Database Locked */ - -#define OBX_MAX_OK_RSP OBX_RSP_PART_CONTENT - -typedef UINT8 tOBX_RSP_CODE; - -/* tags for authentication triplet */ -#define OBX_NONCE_CHLNG_TAG 0 -#define OBX_OPTIONS_CHLNG_TAG 1 -#define OBX_REALM_CHLNG_TAG 2 - -#define OBX_DIGEST_RSP_TAG 0 -#define OBX_USERID_RSP_TAG 1 -#define OBX_NONCE_RSP_TAG 2 - -typedef struct -{ - UINT8 tag; - UINT8 len; - UINT8 *p_array; -} tOBX_TRIPLET; - -/* Server Callback type: */ -typedef void (tOBX_SR_CBACK) (tOBX_HANDLE shandle, tOBX_EVENT event, tOBX_EVT_PARAM param, BT_HDR *p_pkt); -/* Client Callback type: */ -typedef void (tOBX_CL_CBACK) (tOBX_HANDLE handle, tOBX_EVENT event, UINT8 rsp_code, tOBX_EVT_PARAM param, BT_HDR *p_pkt); - - -typedef struct -{ - UINT16 len; /* Length of target header. */ - UINT8 target[OBX_MAX_TARGET_LEN]; /* The byte sequence that describes the target header. */ -} tOBX_TARGET; - - -typedef struct -{ - tOBX_TARGET *p_target; - tOBX_SR_CBACK *p_cback; - UINT16 mtu; - UINT8 scn; /* The RFCOMM SCN number that this server listens for incoming requests. 0, if do not wish to listen to connection from RFCOMM. */ - BOOLEAN authenticate; - UINT8 auth_option; - UINT8 realm_charset; - UINT8 *p_realm; - UINT8 realm_len; - UINT8 max_sessions; - BOOLEAN get_nonf; /* report GET non-final request event. If FALSE, GET response is sent automatically */ - UINT16 psm; /* The L2CAP PSM number that this server listens for incoming requests. 0, if do not wish to listen to connection from L2CAP. */ - UINT32 nonce; /* This is converted to UINT8[16] internally before adding to the OBEX header. This value is copied to the server control block and is increased after each use. 0, if only legacy OBEX (unreliable) session is desired. */ - BOOLEAN srm; /* TRUE, to support single response mode. */ - UINT8 max_suspend; /* Max number of suspended session. must be less than OBX_MAX_SUSPEND_SESSIONS. ignored, if nonce is 0 */ -} tOBX_StartParams; - - - - - -/***************************************************************************** -** External Function Declarations -*****************************************************************************/ -#ifdef __cplusplus -extern "C" -{ -#endif - -/******************************************************************************* -** -** Function OBX_Init -** -** Description This function is called to initialize the control block for this -** layer. It must be called before accessing any other of its API -** functions. It is typically called once during the start up of -** the stack. -** -** Returns void. -** -*******************************************************************************/ -OBX_API extern void OBX_Init(void); - -/******************************************************************************* -** -** Function OBX_SetTraceLevel -** -** Description This function sets the debug trace level for OBX. -** If 0xff is passed, the current trace level is returned. -** -** Input Parameters: -** level: The level to set the OBX tracing to: -** 0xff-returns the current setting. -** 0-turns off tracing. -** >= 1-Errors. -** >= 2-Warnings. -** >= 3-APIs. -** >= 4-Events. -** >= 5-Debug. -** -** Returns The new trace level or current trace level if -** the input parameter is 0xff. -** -*******************************************************************************/ -OBX_API extern UINT8 OBX_SetTraceLevel (UINT8 level); - -/******************************************************************************* -** Function OBX_HandleToMtu -** -** Description Given an OBEX handle, return the associated peer MTU. -** -** Returns MTU. -** -*******************************************************************************/ -OBX_API extern UINT16 OBX_HandleToMtu(tOBX_HANDLE handle); - -/* Server API's: */ -/******************************************************************************* -** -** Function OBX_StartServer -** -** Description This function is to register a server entity to OBEX. -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if OBX does not have resources. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_StartServer(tOBX_StartParams *p_params, tOBX_HANDLE *p_handle); - -/******************************************************************************* -** -** Function OBX_StopServer -** -** Description This function is to stop this OBEX server from receiving any -** more incoming requests. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_StopServer(tOBX_HANDLE handle); - -/******************************************************************************* -** -** Function OBX_AddSuspendedSession -** -** Description This function is to add the session information for a previously -** suspended reliable session to the server control block -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_AddSuspendedSession(tOBX_HANDLE shandle, BD_ADDR peer_addr, UINT8 *p_sess_info, - UINT32 timeout, UINT8 ssn, UINT32 offset); - -/******************************************************************************* -** -** Function OBX_ConnectRsp -** -** Description This function is called to send the response to a Connect -** Request from an OBEX client. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_ConnectRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_SessionRsp -** -** Description This function is called to respond to a request to create a reliable session. -** -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_SessionRsp(tOBX_HANDLE shandle, UINT8 rsp_code, - UINT8 ssn, UINT32 offset, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_SetPathRsp -** -** Description This function is called to send the response to a Set Path -** Request from an OBEX client. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_SetPathRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_PutRsp -** -** Description This function is called to send the response to a Put -** Request from an OBEX client. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_PutRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_GetRsp -** -** Description This function is called to send the response to a Get -** Request from an OBEX client. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_GetRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_AbortRsp -** -** Description This function is called to send the response to an Abort -** Request from an OBEX client. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_AbortRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_ActionRsp -** -** Description This function is called to respond to an Action command Request -** from an OBEX client. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_ActionRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_DisconnectRsp -** -** Description This function is called to send the response to a Disconnect -** Request from an OBEX client. -** This function can also be used to force close the transport -** to a connected client. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_DisconnectRsp(tOBX_HANDLE shandle, UINT8 rsp_code, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_Password -** -** Description This function is called to respond to an OBX_PASSWORD_EVT event. -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if OBX does not resources -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_Password(tOBX_HANDLE shandle, UINT8 *p_password, UINT8 password_len, - UINT8 *p_userid, UINT8 userid_len); - -/******************************************************************************* -** -** Function OBX_GetPeerAddr -** -** Description This function is called to learn the Bluetooth address of the -** connected device. -** -** Returns L2CAP channel ID. -** -*******************************************************************************/ -OBX_API extern UINT16 OBX_GetPeerAddr(tOBX_HANDLE shandle, BD_ADDR bd_addr); - -/******************************************************************************* -** -** Function OBX_GetPortHandle -** -** Description This function is called to get the RFCOMM port handle for the obex connection. -** -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if no existing connection. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_GetPortHandle(tOBX_HANDLE handle, UINT16 *port_handle); - -/* Client API's: */ -/******************************************************************************* -** -** Function OBX_ConnectReq -** -** Description This function registers a client entity to OBEX and sends a -** CONNECT request to the server specified by the API parameters. -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if OBX does not resources -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_ConnectReq(BD_ADDR bd_addr, UINT8 scn, UINT16 mtu, - tOBX_CL_CBACK *p_cback, tOBX_HANDLE *p_handle, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_AllocSession -** -** Description This function registers a client entity to OBEX. -** If p_session_id is not NULL, it tries to find an suspended session -** with matching session_id. -** If scn is not 0, it allocates a control block for this new session. -** Otherwise, it allocates a control block for the given PSM. -** The associated virtual PSM assigned by L2CAP is returned in p_psm -** The allocated OBEX handle is returned in p_handle. -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if OBX does not resources -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_AllocSession (UINT8 *p_session_info, UINT8 scn, UINT16 *p_psm, - tOBX_CL_CBACK *p_cback, tOBX_HANDLE *p_handle); - -/******************************************************************************* -** -** Function OBX_CreateSession -** -** Description This function registers a client entity to OBEX. -** It may send a CreateSession request and wait for CreateSession response. -** It sends a CONNECT request to the server specified by the API parameters. -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if OBX does not resources -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_CreateSession (BD_ADDR bd_addr, UINT16 mtu, BOOLEAN srm, UINT32 nonce, - tOBX_HANDLE handle, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_ResumeSession -** -** Description This function registers a client entity to OBEX and resumes -** a previously interrupted reliable session. -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if OBX does not resources -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_ResumeSession (BD_ADDR bd_addr, UINT8 ssn, UINT32 offset, tOBX_HANDLE handle); - -/******************************************************************************* -** -** Function OBX_SessionReq -** -** Description This function is used to Suspend, Resume, or Close a session. -** For Resume: this function registers a client entity to OBEX and resumes -** a previously interrupted reliable session. -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if OBX does not resources -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_SessionReq (tOBX_HANDLE handle, tOBX_SESS_OP opcode, UINT32 timeout); - -/******************************************************************************* -** -** Function OBX_SetPathReq -** -** Description This function sends a Set Path request to the connected server. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_SetPathReq(tOBX_HANDLE handle, UINT8 flags, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_PutReq -** -** Description This function sends a Put request to the connected server. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_PutReq(tOBX_HANDLE handle, BOOLEAN final, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_GetReq -** -** Description This function sends a Get request to the connected server. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_GetReq(tOBX_HANDLE handle, BOOLEAN final, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_AbortReq -** -** Description This function sends an Abort request to the connected server. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_AbortReq(tOBX_HANDLE handle, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_DisconnectReq -** -** Description This function sends a Disconnect request to the connected server. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_DisconnectReq(tOBX_HANDLE handle, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_ActionReq -** -** Description This function sends a Action request to the connected server. -** The Name Header and DestName Header must be in p_pkt for -** the Copy and Move Object action. -** The Name header and Permission Header must be in p_pkt for -** the Set Object Permission action. -** -** Returns OBX_SUCCESS, if successful. -** OBX_BAD_HANDLE, if the handle is not valid. -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_ActionReq(tOBX_HANDLE handle, tOBX_ACTION action_id, BT_HDR *p_pkt); - -/******************************************************************************* -** -** Function OBX_AuthResponse -** -** Description This function is called to respond to an OBX_PASSWORD_EVT event. -** -** Returns OBX_SUCCESS, if successful. -** OBX_NO_RESOURCES, if OBX does not resources -** -*******************************************************************************/ -OBX_API extern tOBX_STATUS OBX_AuthResponse(tOBX_HANDLE handle, - UINT8 *p_password, UINT8 password_len, - UINT8 *p_userid, UINT8 userid_len, - BOOLEAN authenticate); - - -/******************************************************************************* -** -** Function OBX_HdrInit -** -** Description This function is called to initialize an OBEX packet. This -** function takes a GKI buffer and sets the offset in BT_HDR as -** OBEX_HDR_OFFSET, the len as 0. The layer_specific is set to the -** length still available. This function compares the given -** (pkt_size - sizeof(BT_HDR)) with the peer MTU to get the lesser -** of the two and set the layer_specific to -** (lesser_size - OBEX_HDR_OFFSET). -** If composing a header for the CONNECT request (there is no -** client handle yet), use OBX_HANDLE_NULL as the handle. -** -** Returns BT_HDR *. -** -*******************************************************************************/ -OBX_API extern BT_HDR * OBX_HdrInit(tOBX_HANDLE handle, UINT16 pkt_size); - -/******************************************************************************* -** -** Function OBX_AddNameHdr -** -** Description This function is called to add an OBEX Name header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddNameHdr(BT_HDR *p_pkt, UINT16 *p_name, UINT16 len); - -/******************************************************************************* -** -** Function OBX_CharToWchar -** -** Description This function is called to convert ASCII to Unicode (UINT16). -** -** Returns the length. -** -*******************************************************************************/ -OBX_API extern UINT16 OBX_CharToWchar (UINT16 *w_str, char* a_str, UINT16 w_size); - -/******************************************************************************* -** -** Function OBX_AddAsciiNameHdr -** -** Description This function is called to add an OBEX Name header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddAsciiNameHdr(BT_HDR *p_pkt, char *p_name); - -/******************************************************************************* -** -** Function OBX_AddTypeHdr -** -** Description This function is called to add an OBEX Type header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddTypeHdr(BT_HDR *p_pkt, char *p_type); - -/******************************************************************************* -** -** Function OBX_AddLengthHdr -** -** Description This function is called to add an OBEX Length header to an OBEX -** packet. The Length header describes the total length in bytes of -** the object. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddLengthHdr(BT_HDR *p_pkt, UINT32 len); - -/******************************************************************************* -** -** Function OBX_AddTimeHdr -** -** Description This function is called to add an OBEX Time header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddTimeHdr(BT_HDR *p_pkt, char *p_time); - -/******************************************************************************* -** -** Function OBX_AddDescrHdr -** -** Description This function is called to add an OBEX Description header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddDescrHdr(BT_HDR *p_pkt, UINT16 *p_descr, UINT16 len); - -/******************************************************************************* -** -** Function OBX_AddAsciiDescrHdr -** -** Description This function is called to add an OBEX Description header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddAsciiDescrHdr(BT_HDR *p_pkt, char *p_descr); - -/******************************************************************************* -** -** Function OBX_AddTargetHdr -** -** Description This function is called to add an OBEX Target header to an OBEX -** packet. This header is most commonly used in Connect packets. -** -** NOTE: The target header must be the first header in an OBEX message. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddTargetHdr(BT_HDR *p_pkt, UINT8 *p_target, UINT16 len); - -/******************************************************************************* -** -** Function OBX_AddHttpHdr -** -** Description This function is called to add an OBEX HTTP header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddHttpHdr(BT_HDR *p_pkt, UINT8 *p_http, UINT16 len); - -/******************************************************************************* -** -** Function OBX_AddBodyHdr -** -** Description This function is called to add an OBEX body header -** to an OBEX packet. -** -** NOTE: The body header must be the last header in an OBEX message. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddBodyHdr(BT_HDR *p_pkt, UINT8 *p_body, UINT16 len, BOOLEAN end); - -/* Alternate Body header functions: for non-blocking scenario */ -/******************************************************************************* -** -** Function OBX_AddBodyStart -** -** Description This function is called to get the address to the beginning of -** the byte sequence for an OBEX body header in an OBEX packet. -** -** Returns The address to add body content. -** -*******************************************************************************/ -OBX_API extern UINT8 *OBX_AddBodyStart(BT_HDR *p_pkt, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_AddBodyEnd -** -** Description This function is called to add the HI and the length of HV of an -** OBEX body header to an OBEX packet. If end is TRUE, HI is -** OBX_HI_BODY_END. If FALSE, HI is OBX_HI_BODY. It is assumed that -** the actual value of the body has been copied into the OBEX packet. -** -** Returns void -** -*******************************************************************************/ -OBX_API extern void OBX_AddBodyEnd(BT_HDR *p_pkt, UINT8 *p, UINT16 len, BOOLEAN end); - -/******************************************************************************* -** -** Function OBX_AddWhoHdr -** -** Description This function is called to add an OBEX Who header to an OBEX -** packet. -** -** Note: Who header is typically used in an OBEX CONNECT response packet -** to indicate the UUID of the service that has accepted the -** directed connection. If the server calls OBX_StartServer() with -** specified target header, this OBEX implementation automatically -** adds this WHO header to the CONNECT response packet. If -** OBX_StartServer() is called with target header length as 0, the -** OBEX API user is responsible to add the WHO header. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddWhoHdr(BT_HDR *p_pkt, UINT8 *p_who, UINT16 len); - -/******************************************************************************* -** -** Function OBX_AddAppParamHdr -** -** Description This function is called to add an OBEX Application Parameter -** header to an OBEX packet. This header is used by the application -** layer above OBEX to convey application specific information. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddAppParamHdr(BT_HDR *p_pkt, tOBX_TRIPLET *p_triplet, UINT8 num); - -/******************************************************************************* -** -** Function OBX_AddDestNameHdr -** -** Description This function is called to add an OBEX DestName header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddDestNameHdr(BT_HDR *p_pkt, UINT16 *p_dest, UINT16 len); - -/******************************************************************************* -** -** Function OBX_AddAsciiDestNameHdr -** -** Description This function is called to add an OBEX DestName header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddAsciiDestNameHdr(BT_HDR *p_pkt, char *p_descr); - -/******************************************************************************* -** -** Function OBX_AddPermissionHdr -** -** Description This function is called to add an OBEX Permission header to an OBEX -** packet. -** bit 0 is set for read permission -** bit 1 is set for write permission -** bit 2 is set for delete permission -** bit 7 is set for modify permission -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddPermissionHdr(BT_HDR *p_pkt, UINT8 user, UINT8 group, UINT8 other); - -/******************************************************************************* -** -** Function OBX_Add1ByteHdr -** -** Description This function is called to add a header with type as UINT8 -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_Add1ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT8 data); - -/******************************************************************************* -** -** Function OBX_Add4ByteHdr -** -** Description This function is called to add a header with type as UINT32 -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_Add4ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT32 data); - -/******************************************************************************* -** -** Function OBX_AddByteStrStart -** -** Description This function is called to get the address to the beginning of -** the byte sequence for an OBEX header in an OBEX packet. -** -** Returns The address to add the byte sequence. -** -*******************************************************************************/ -OBX_API extern UINT8 *OBX_AddByteStrStart(BT_HDR *p_pkt, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_AddByteStrHdr -** -** Description This function is called to add a header with type as byte sequence -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddByteStrHdr(BT_HDR *p_pkt, UINT8 id, UINT8 *p_data, UINT16 len); - -/******************************************************************************* -** -** Function OBX_AddUnicodeHdr -** -** Description This function is called to add a header with type as Unicode string -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddUnicodeHdr(BT_HDR *p_pkt, UINT8 id, UINT16 *p_data, UINT16 len); - -/******************************************************************************* -** -** Function OBX_AddTriplet -** -** Description This function is called to add a header with type as byte sequence -** to an OBEX packet. -** -** Note: The byte sequence uses a Tag-Length-Value encoding scheme -** These headers include: Application Parameters header -** Authenticate Challenge header -** Authenticate Response header -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddTriplet(BT_HDR *p_pkt, UINT8 id, tOBX_TRIPLET *p_triplet, UINT8 num); - -/******************************************************************************* -** -** Function OBX_CheckHdr -** -** Description This function is called to check if the given OBEX packet -** contains the specified header. -** -** Returns NULL, if the header is not in the OBEX packet. -** The pointer to the specified header beginning from HI. -** -*******************************************************************************/ -OBX_API extern UINT8 * OBX_CheckHdr(BT_HDR *p_pkt, UINT8 id); - -/******************************************************************************* -** -** Function OBX_ReadNumHdrs -** -** Description This function is called to check the number of headers in the -** given OBEX packet -** -** Returns number of headers. -** -*******************************************************************************/ -OBX_API extern UINT8 OBX_ReadNumHdrs(BT_HDR *p_pkt, UINT8 *p_num_body); - -/******************************************************************************* -** -** Function OBX_ReadHdrLen -** -** Description This function is called to check the length of the specified -** header in the given OBEX packet. -** -** Returns OBX_INVALID_HDR_LEN, if the header is not in the OBEX packet. -** Otherwise the actual length of the header. -** -*******************************************************************************/ -OBX_API extern UINT16 OBX_ReadHdrLen(BT_HDR *p_pkt, UINT8 id); - -/******************************************************************************* -** -** Function OBX_ReadNameHdr -** -** Description This function is called to get the Name Header in the given -** OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadNameHdr(BT_HDR *p_pkt, UINT16 *p_name, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_WcharToChar -** -** Description This function is called to convert Unicode (UINT16) to ASCII. -** -** Returns void. -** -*******************************************************************************/ -OBX_API extern void OBX_WcharToChar (char *a_str, UINT16* w_str, UINT16 a_size) ; - -/******************************************************************************* -** -** Function OBX_ReadAsciiNameHdr -** -** Description This function is called to get the Name Header in the given -** OBEX packet. If Name header exists in the given OBEX packet, -** it is converted to ASCII format and copied into p_name. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadAsciiNameHdr(BT_HDR *p_pkt, char *p_name, UINT16 max_len); - -/******************************************************************************* -** -** Function OBX_ReadTypeHdr -** -** Description This function is called to get the Type Header in the given -** OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadTypeHdr(BT_HDR *p_pkt, UINT8 **p_type, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_ReadLengthHdr -** -** Description This function is called to get the Length Header in the given -** OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadLengthHdr(BT_HDR *p_pkt, UINT32 *p_len); - -/******************************************************************************* -** -** Function OBX_ReadTimeHdr -** -** Description This function is called to get the Time Header in the given -** OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadTimeHdr(BT_HDR *p_pkt, UINT8 **p_time, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_ReadDescrHdr -** -** Description This function is called to get the Description Header in the -** given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadDescrHdr(BT_HDR *p_pkt, UINT16 *p_descr, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_ReadDestNameHdr -** -** Description This function is called to get the DestName Header in the -** given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadDestNameHdr(BT_HDR *p_pkt, UINT16 *p_dest, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_ReadAsciiDescrHdr -** -** Description This function is called to get the Description Header in the -** given OBEX packet. If Description header exists in the given -** OBEX packet, it is converted to ASCII format and copied into -** p_descr. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadAsciiDescrHdr(BT_HDR *p_pkt, char *p_descr, UINT16 max_len); - -/******************************************************************************* -** -** Function OBX_ReadAsciiDestNameHdr -** -** Description This function is called to get the DestName Header in the -** given OBEX packet. If DestName header exists in the given -** OBEX packet, it is converted to ASCII format and copied into -** p_descr. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadAsciiDestNameHdr(BT_HDR *p_pkt, char *p_dest, UINT16 max_len); - -/******************************************************************************* -** -** Function OBX_ReadTargetHdr -** -** Description This function is called to get the Target Header in the -** given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadTargetHdr(BT_HDR *p_pkt, UINT8 **p_target, UINT16 *p_len, UINT8 next); - -/******************************************************************************* -** -** Function OBX_ReadHttpHdr -** -** Description This function is called to get the HTTP Header in the -** given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadHttpHdr(BT_HDR *p_pkt, UINT8 **p_http, UINT16 *p_len, UINT8 next); - -/******************************************************************************* -** -** Function OBX_ReadBodyHdr -** -** Description This function is called to get the Body Header in the -** given OBEX packet. -** -** Returns 1, if a single header is in the OBEX packet. -** 2, if a end of body header is in the OBEX packet. -** 0, (FALSE) otherwise. -** -*******************************************************************************/ -OBX_API extern UINT8 OBX_ReadBodyHdr(BT_HDR *p_pkt, UINT8 **p_body, UINT16 *p_len, BOOLEAN *p_end); - -/******************************************************************************* -** -** Function OBX_ReadWhoHdr -** -** Description This function is called to get the Who Header in the -** given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadWhoHdr(BT_HDR *p_pkt, UINT8 **p_who, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_ReadAppParamHdr -** -** Description This function is called to get the Application Parameter Header -** in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadAppParamHdr(BT_HDR *p_pkt, UINT8 *p_tag, UINT8 **p_app_param, UINT8 *p_len, UINT8 next); - -/******************************************************************************* -** -** Function OBX_ReadPermissionHdr -** -** Description This function is called to get the Application Parameter Header -** in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadPermissionHdr(BT_HDR *p_pkt, UINT8 *p_user, UINT8 *p_group, UINT8 *p_other); - -/******************************************************************************* -** -** Function OBX_Read1ByteHdr -** -** Description This function is called to get the UINT8 HV of the given HI -** in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_Read1ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT8 *p_data); - -/******************************************************************************* -** -** Function OBX_Read4ByteHdr -** -** Description This function is called to get the UINT32 HV of the given HI -** in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_Read4ByteHdr(BT_HDR *p_pkt, UINT8 id, UINT32 *p_data); - -/******************************************************************************* -** -** Function OBX_ReadByteStrHdr -** -** Description This function is called to get the byte sequence HV of the given -** HI in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadByteStrHdr(BT_HDR *p_pkt, UINT8 id, UINT8 **p_data, UINT16 *p_len, UINT8 next); - -/******************************************************************************* -** -** Function OBX_ReadUnicodeHdr -** -** Description This function is called to get the Unicode HV of the given -** HI in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadUnicodeHdr(BT_HDR *p_pkt, UINT8 id, UINT16 *p_data, UINT16 *p_len); - -/******************************************************************************* -** -** Function OBX_ReadTriplet -** -** Description This function is called to get the Triplet HV of the given -** HI in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadTriplet(BT_HDR *p_pkt, UINT8 id, tOBX_TRIPLET *p_triplet, UINT8 *p_num); - -/******************************************************************************* -** -** Function OBX_ReadActionIdHdr -** -** Description This function is called to get the HV of the Action ID header -** in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadActionIdHdr(BT_HDR *p_pkt, UINT8 *p_data); - -/******************************************************************************* -** -** Function OBX_ReadChallenge -** -** Description This function is called to read the Realm and options of the -** Authentication Challenge Header in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadChallenge(BT_HDR *p_pkt, tOBX_CHARSET *p_charset, - UINT8 **p_realm, UINT8 *p_len, - tOBX_AUTH_OPT *p_option); - -/******************************************************************************* -** -** Function OBX_ReadAuthParams -** -** Description This function is called to read the User ID of the -** Authentication Response Header in the given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadAuthParams(BT_HDR *p_pkt, UINT8 **p_userid, UINT8 *p_len, - BOOLEAN *is_challenged, tOBX_AUTH_OPT *p_option); - - -/******************************************************************************* -** -** Function utfc_16_to_8 -** -** Description Convert a UTF-16 array to a null-terminated UTF-8 string. -** Illegal characters are skipped. -** -** Returns Length of UTF-8 string in bytes. -** -*******************************************************************************/ -OBX_API extern UINT16 utfc_16_to_8(UINT8 *p_utf8, UINT16 utf8_len, UINT16 *p_utf16, UINT16 utf16_len); - -/******************************************************************************* -** -** Function utfc_8_to_16 -** -** Description Convert a null-terminated UTF-8 string to a UTF-16 array. -** Illegal characters are skipped. -** -** Returns Length of UTF-16 array. -** -*******************************************************************************/ -OBX_API extern UINT16 utfc_8_to_16(UINT16 *p_utf16, UINT16 utf16_len, UINT8 *p_utf8); - -/******************************************************************************* -** -** Function OBX_AddUtf8NameHdr -** -** Description This function is called to add an OBEX Name header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddUtf8NameHdr(BT_HDR *p_pkt, UINT8 *p_name); - -/******************************************************************************* -** -** Function OBX_AddUtf8DescrHdr -** -** Description This function is called to add an OBEX Description header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddUtf8DescrHdr(BT_HDR *p_pkt, UINT8 *p_descr); - -/******************************************************************************* -** -** Function OBX_AddUtf8DestNameHdr -** -** Description This function is called to add an OBEX DestName header -** to an OBEX packet. -** -** Returns TRUE, if the header is added successfully. -** FALSE, if the operation failed. p_pkt is not altered. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_AddUtf8DestNameHdr(BT_HDR *p_pkt, UINT8 *p_dest); - -/******************************************************************************* -** -** Function OBX_ReadUtf8NameHdr -** -** Description This function is called to get the Name Header in the given -** OBEX packet. If Name header exists in the given OBEX packet, -** it is converted to UTF8 format and copied into p_name. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadUtf8NameHdr(BT_HDR *p_pkt, UINT8 *p_name, UINT16 max_len); - -/******************************************************************************* -** -** Function OBX_ReadUtf8DescrHdr -** -** Description This function is called to get the Description Header in the -** given OBEX packet. If Description header exists in the given -** OBEX packet, it is converted to UTF8 format and copied into -** p_descr. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadUtf8DescrHdr(BT_HDR *p_pkt, UINT8 *p_descr, UINT16 max_len); - -/******************************************************************************* -** -** Function OBX_ReadUtf8DestNameHdr -** -** Description This function is called to get the DestName Header in the -** given OBEX packet. -** -** Returns TRUE, if the header is in the OBEX packet. -** FALSE, otherwise. -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_ReadUtf8DestNameHdr(BT_HDR *p_pkt, UINT8 *p_dest, UINT16 max_len); - -/******************************************************************************* -** -** Function OBX_VerifyResponse -** -** Description This function is called by the client to verify the challenge -** response. -** -** Returns TRUE, if successful. -** FALSE, if authentication failed -** -*******************************************************************************/ -OBX_API extern BOOLEAN OBX_VerifyResponse(UINT32 nonce_u32, UINT8 *p_password, UINT8 password_len, UINT8 *p_response); - -#ifdef __cplusplus -} -#endif - -#endif /* OBX_API_H */ diff --git a/stack/include/pan_api.h b/stack/include/pan_api.h index a604463e6..17826b503 100644 --- a/stack/include/pan_api.h +++ b/stack/include/pan_api.h @@ -236,7 +236,7 @@ extern "C" ** Returns none ** *******************************************************************************/ -PAN_API extern void PAN_Register (tPAN_REGISTER *p_register); +extern void PAN_Register (tPAN_REGISTER *p_register); /******************************************************************************* @@ -251,7 +251,7 @@ PAN_API extern void PAN_Register (tPAN_REGISTER *p_register); ** Returns none ** *******************************************************************************/ -PAN_API extern void PAN_Deregister (void); +extern void PAN_Deregister (void); /******************************************************************************* ** @@ -277,11 +277,11 @@ PAN_API extern void PAN_Deregister (void); ** PAN_FAILURE - if the role is not valid ** *******************************************************************************/ -PAN_API extern tPAN_RESULT PAN_SetRole (UINT8 role, - UINT8 *sec_mask, - char *p_user_name, - char *p_gn_name, - char *p_nap_name); +extern tPAN_RESULT PAN_SetRole (UINT8 role, + UINT8 *sec_mask, + char *p_user_name, + char *p_gn_name, + char *p_nap_name); /******************************************************************************* ** @@ -306,7 +306,7 @@ PAN_API extern tPAN_RESULT PAN_SetRole (UINT8 role, ** allowed at that point of time ** *******************************************************************************/ -PAN_API extern tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 dst_role, UINT16 *handle); +extern tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 dst_role, UINT16 *handle); /******************************************************************************* ** @@ -321,7 +321,7 @@ PAN_API extern tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 d ** there is an error in disconnecting ** *******************************************************************************/ -PAN_API extern tPAN_RESULT PAN_Disconnect (UINT16 handle); +extern tPAN_RESULT PAN_Disconnect (UINT16 handle); /******************************************************************************* ** @@ -346,13 +346,13 @@ PAN_API extern tPAN_RESULT PAN_Disconnect (UINT16 handle); ** there is an error in sending data ** *******************************************************************************/ -PAN_API extern tPAN_RESULT PAN_Write (UINT16 handle, - BD_ADDR dst, - BD_ADDR src, - UINT16 protocol, - UINT8 *p_data, - UINT16 len, - BOOLEAN ext); +extern tPAN_RESULT PAN_Write (UINT16 handle, + BD_ADDR dst, + BD_ADDR src, + UINT16 protocol, + UINT8 *p_data, + UINT16 len, + BOOLEAN ext); /******************************************************************************* ** @@ -376,12 +376,12 @@ PAN_API extern tPAN_RESULT PAN_Write (UINT16 handle, ** there is an error in sending data ** *******************************************************************************/ -PAN_API extern tPAN_RESULT PAN_WriteBuf (UINT16 handle, - BD_ADDR dst, - BD_ADDR src, - UINT16 protocol, - BT_HDR *p_buf, - BOOLEAN ext); +extern tPAN_RESULT PAN_WriteBuf (UINT16 handle, + BD_ADDR dst, + BD_ADDR src, + UINT16 protocol, + BT_HDR *p_buf, + BOOLEAN ext); /******************************************************************************* ** @@ -399,10 +399,10 @@ PAN_API extern tPAN_RESULT PAN_WriteBuf (UINT16 handle, ** PAN_FAILURE if connection not found or error in setting ** *******************************************************************************/ -PAN_API extern tPAN_RESULT PAN_SetProtocolFilters (UINT16 handle, - UINT16 num_filters, - UINT16 *p_start_array, - UINT16 *p_end_array); +extern tPAN_RESULT PAN_SetProtocolFilters (UINT16 handle, + UINT16 num_filters, + UINT16 *p_start_array, + UINT16 *p_end_array); /******************************************************************************* ** @@ -422,10 +422,10 @@ PAN_API extern tPAN_RESULT PAN_SetProtocolFilters (UINT16 handle, ** PAN_FAILURE if connection not found or error in setting ** *******************************************************************************/ -PAN_API extern tBNEP_RESULT PAN_SetMulticastFilters (UINT16 handle, - UINT16 num_mcast_filters, - UINT8 *p_start_array, - UINT8 *p_end_array); +extern tBNEP_RESULT PAN_SetMulticastFilters (UINT16 handle, + UINT16 num_mcast_filters, + UINT8 *p_start_array, + UINT8 *p_end_array); /******************************************************************************* ** @@ -437,7 +437,7 @@ PAN_API extern tBNEP_RESULT PAN_SetMulticastFilters (UINT16 handle, ** Returns the new (current) trace level ** *******************************************************************************/ -PAN_API extern UINT8 PAN_SetTraceLevel (UINT8 new_level); +extern UINT8 PAN_SetTraceLevel (UINT8 new_level); /******************************************************************************* ** @@ -450,7 +450,7 @@ PAN_API extern UINT8 PAN_SetTraceLevel (UINT8 new_level); ** Returns void ** *******************************************************************************/ -PAN_API extern void PAN_Init (void); +extern void PAN_Init (void); #ifdef __cplusplus } diff --git a/stack/include/port_api.h b/stack/include/port_api.h index 050ee52de..f24887b57 100644 --- a/stack/include/port_api.h +++ b/stack/include/port_api.h @@ -175,6 +175,7 @@ typedef void (tPORT_CALLBACK) (UINT32 code, UINT16 port_handle); #define PORT_PAGE_TIMEOUT (PORT_ERR_BASE + 24) #define PORT_INVALID_SCN (PORT_ERR_BASE + 25) +#define PORT_ERR_MAX (PORT_ERR_BASE + 26) /***************************************************************************** ** External Function Declarations @@ -215,7 +216,7 @@ extern "C" ** (scn * 2 + 1) dlci. ** *******************************************************************************/ -RFC_API extern int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn, +extern int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn, BOOLEAN is_server, UINT16 mtu, BD_ADDR bd_addr, UINT16 *p_handle, tPORT_CALLBACK *p_mgmt_cb); @@ -230,7 +231,7 @@ RFC_API extern int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn, ** Parameters: handle - Handle of the port returned in the Open ** *******************************************************************************/ -RFC_API extern int RFCOMM_RemoveConnection (UINT16 handle); +extern int RFCOMM_RemoveConnection (UINT16 handle); /******************************************************************************* @@ -242,7 +243,7 @@ RFC_API extern int RFCOMM_RemoveConnection (UINT16 handle); ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection ** *******************************************************************************/ -RFC_API extern int RFCOMM_RemoveServer (UINT16 handle); +extern int RFCOMM_RemoveServer (UINT16 handle); /******************************************************************************* @@ -257,8 +258,8 @@ RFC_API extern int RFCOMM_RemoveServer (UINT16 handle); ** specified in the mask occurs. ** *******************************************************************************/ -RFC_API extern int PORT_SetEventCallback (UINT16 port_handle, - tPORT_CALLBACK *p_port_cb); +extern int PORT_SetEventCallback (UINT16 port_handle, + tPORT_CALLBACK *p_port_cb); /******************************************************************************* ** @@ -283,10 +284,10 @@ int PORT_ClearKeepHandleFlag (UINT16 port_handle); ** packet is received. ** *******************************************************************************/ -RFC_API extern int PORT_SetDataCallback (UINT16 port_handle, - tPORT_DATA_CALLBACK *p_cb); +extern int PORT_SetDataCallback (UINT16 port_handle, + tPORT_DATA_CALLBACK *p_cb); -RFC_API extern int PORT_SetDataCOCallback (UINT16 port_handle, tPORT_DATA_CO_CALLBACK *p_port_cb); +extern int PORT_SetDataCOCallback (UINT16 port_handle, tPORT_DATA_CO_CALLBACK *p_port_cb); /******************************************************************************* ** ** Function PORT_SetEventMask @@ -298,7 +299,7 @@ RFC_API extern int PORT_SetDataCOCallback (UINT16 port_handle, tPORT_DATA_CO_CAL ** of zero disables all events. ** *******************************************************************************/ -RFC_API extern int PORT_SetEventMask (UINT16 port_handle, UINT32 mask); +extern int PORT_SetEventMask (UINT16 port_handle, UINT32 mask); /******************************************************************************* @@ -313,8 +314,8 @@ RFC_API extern int PORT_SetEventMask (UINT16 port_handle, UINT32 mask); ** p_lcid - OUT L2CAP's LCID ** *******************************************************************************/ -RFC_API extern int PORT_CheckConnection (UINT16 handle, BD_ADDR bd_addr, - UINT16 *p_lcid); +extern int PORT_CheckConnection (UINT16 handle, BD_ADDR bd_addr, + UINT16 *p_lcid); /******************************************************************************* ** @@ -327,7 +328,7 @@ RFC_API extern int PORT_CheckConnection (UINT16 handle, BD_ADDR bd_addr, ** bd_addr - bd_addr of the peer ** *******************************************************************************/ -RFC_API extern BOOLEAN PORT_IsOpening (BD_ADDR bd_addr); +extern BOOLEAN PORT_IsOpening (BD_ADDR bd_addr); /******************************************************************************* ** @@ -341,7 +342,7 @@ RFC_API extern BOOLEAN PORT_IsOpening (BD_ADDR bd_addr); ** configuration information for the connection. ** *******************************************************************************/ -RFC_API extern int PORT_SetState (UINT16 handle, tPORT_STATE *p_settings); +extern int PORT_SetState (UINT16 handle, tPORT_STATE *p_settings); /******************************************************************************* ** @@ -353,7 +354,7 @@ RFC_API extern int PORT_SetState (UINT16 handle, tPORT_STATE *p_settings); ** p_rx_queue_count - Pointer to return queue count in. ** *******************************************************************************/ -RFC_API extern int PORT_GetRxQueueCnt (UINT16 handle, UINT16 *p_rx_queue_count); +extern int PORT_GetRxQueueCnt (UINT16 handle, UINT16 *p_rx_queue_count); /******************************************************************************* ** @@ -367,7 +368,7 @@ RFC_API extern int PORT_GetRxQueueCnt (UINT16 handle, UINT16 *p_rx_queue_count); ** configuration information is returned. ** *******************************************************************************/ -RFC_API extern int PORT_GetState (UINT16 handle, tPORT_STATE *p_settings); +extern int PORT_GetState (UINT16 handle, tPORT_STATE *p_settings); /******************************************************************************* @@ -391,7 +392,7 @@ RFC_API extern int PORT_GetState (UINT16 handle, tPORT_STATE *p_settings); #define PORT_CLR_DCD 0x08 /* DCE only */ #define PORT_BREAK 0x09 /* Break event */ -RFC_API extern int PORT_Control (UINT16 handle, UINT8 signal); +extern int PORT_Control (UINT16 handle, UINT8 signal); /******************************************************************************* @@ -406,7 +407,7 @@ RFC_API extern int PORT_Control (UINT16 handle, UINT8 signal); ** enable - enables data flow ** *******************************************************************************/ -RFC_API extern int PORT_FlowControl (UINT16 handle, BOOLEAN enable); +extern int PORT_FlowControl (UINT16 handle, BOOLEAN enable); /******************************************************************************* @@ -436,7 +437,7 @@ RFC_API extern int PORT_FlowControl (UINT16 handle, BOOLEAN enable); #define PORT_PPP_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON) #define PORT_DUN_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON) -RFC_API extern int PORT_GetModemStatus (UINT16 handle, UINT8 *p_control_signal); +extern int PORT_GetModemStatus (UINT16 handle, UINT8 *p_control_signal); /******************************************************************************* @@ -475,8 +476,8 @@ typedef struct } tPORT_STATUS; -RFC_API extern int PORT_ClearError (UINT16 handle, UINT16 *p_errors, - tPORT_STATUS *p_status); +extern int PORT_ClearError (UINT16 handle, UINT16 *p_errors, + tPORT_STATUS *p_status); /******************************************************************************* @@ -489,7 +490,7 @@ RFC_API extern int PORT_ClearError (UINT16 handle, UINT16 *p_errors, ** errors - receive error codes ** *******************************************************************************/ -RFC_API extern int PORT_SendError (UINT16 handle, UINT8 errors); +extern int PORT_SendError (UINT16 handle, UINT8 errors); /******************************************************************************* @@ -503,7 +504,7 @@ RFC_API extern int PORT_SendError (UINT16 handle, UINT8 errors); ** connection status ** *******************************************************************************/ -RFC_API extern int PORT_GetQueueStatus (UINT16 handle, tPORT_STATUS *p_status); +extern int PORT_GetQueueStatus (UINT16 handle, tPORT_STATUS *p_status); /******************************************************************************* @@ -520,7 +521,7 @@ RFC_API extern int PORT_GetQueueStatus (UINT16 handle, tPORT_STATUS *p_status); #define PORT_PURGE_TXCLEAR 0x01 #define PORT_PURGE_RXCLEAR 0x02 -RFC_API extern int PORT_Purge (UINT16 handle, UINT8 purge_flags); +extern int PORT_Purge (UINT16 handle, UINT8 purge_flags); /******************************************************************************* @@ -538,7 +539,7 @@ RFC_API extern int PORT_Purge (UINT16 handle, UINT8 purge_flags); ** pp_buf - pointer to address of buffer with data, ** *******************************************************************************/ -RFC_API extern int PORT_Read (UINT16 handle, BT_HDR **pp_buf); +extern int PORT_Read (UINT16 handle, BT_HDR **pp_buf); /******************************************************************************* @@ -555,8 +556,8 @@ RFC_API extern int PORT_Read (UINT16 handle, BT_HDR **pp_buf); ** p_len - Byte count received ** *******************************************************************************/ -RFC_API extern int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len, - UINT16 *p_len); +extern int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len, + UINT16 *p_len); /******************************************************************************* @@ -570,7 +571,7 @@ RFC_API extern int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len, ** p_buf - pointer to the buffer with data, ** *******************************************************************************/ -RFC_API extern int PORT_Write (UINT16 handle, BT_HDR *p_buf); +extern int PORT_Write (UINT16 handle, BT_HDR *p_buf); /******************************************************************************* @@ -586,8 +587,8 @@ RFC_API extern int PORT_Write (UINT16 handle, BT_HDR *p_buf); ** p_len - Bytes written ** *******************************************************************************/ -RFC_API extern int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, - UINT16 *p_len); +extern int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, + UINT16 *p_len); /******************************************************************************* ** @@ -599,7 +600,7 @@ RFC_API extern int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection ** *******************************************************************************/ -RFC_API extern int PORT_WriteDataCO (UINT16 handle, int* p_len); +extern int PORT_WriteDataCO (UINT16 handle, int* p_len); /******************************************************************************* ** @@ -612,7 +613,7 @@ RFC_API extern int PORT_WriteDataCO (UINT16 handle, int* p_len); ** max_len - Byte count requested ** *******************************************************************************/ -RFC_API extern int PORT_Test (UINT16 handle, UINT8 *p_data, UINT16 len); +extern int PORT_Test (UINT16 handle, UINT8 *p_data, UINT16 len); /******************************************************************************* @@ -622,7 +623,7 @@ RFC_API extern int PORT_Test (UINT16 handle, UINT8 *p_data, UINT16 len); ** Description This function is called to initialize RFCOMM layer ** *******************************************************************************/ -RFC_API extern void RFCOMM_Init (void); +extern void RFCOMM_Init (void); /******************************************************************************* @@ -635,9 +636,22 @@ RFC_API extern void RFCOMM_Init (void); ** Returns the new (current) trace level ** *******************************************************************************/ -RFC_API extern UINT8 PORT_SetTraceLevel (UINT8 new_level); +extern UINT8 PORT_SetTraceLevel (UINT8 new_level); +/******************************************************************************* +** +** Function PORT_GetResultString +** +** Description This function returns the human-readable string for a given +** result code. +** +** Returns a pointer to the human-readable string for the given +** result. Note that the string returned must not be freed. +** +*******************************************************************************/ +extern const char *PORT_GetResultString (const uint8_t result_code); + #ifdef __cplusplus } #endif diff --git a/stack/include/sdp_api.h b/stack/include/sdp_api.h index dcc813e97..ff44bf5f6 100644 --- a/stack/include/sdp_api.h +++ b/stack/include/sdp_api.h @@ -49,11 +49,6 @@ #define SDP_CONN_REJECTED 0xFFF7 #define SDP_CANCEL 0xFFF8 -/* these result codes are used only when SDP_FOR_JV_INCLUDED==TRUE */ -#define SDP_EVT_OPEN 0x00F0 /* connected */ -#define SDP_EVT_DATA_IND 0x00F1 /* data ind */ -#define SDP_EVT_CLOSE 0x00F2 /* disconnected */ - /* Define the PSM that SDP uses */ #define SDP_PSM 0x0001 @@ -201,11 +196,11 @@ extern "C" ** Returns TRUE if successful, FALSE if one or more parameters are bad ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_InitDiscoveryDb (tSDP_DISCOVERY_DB *p_db, UINT32 len, - UINT16 num_uuid, - tSDP_UUID *p_uuid_list, - UINT16 num_attr, - UINT16 *p_attr_list); +extern BOOLEAN SDP_InitDiscoveryDb (tSDP_DISCOVERY_DB *p_db, UINT32 len, + UINT16 num_uuid, + tSDP_UUID *p_uuid_list, + UINT16 num_attr, + UINT16 *p_attr_list); /******************************************************************************* ** @@ -216,7 +211,7 @@ SDP_API extern BOOLEAN SDP_InitDiscoveryDb (tSDP_DISCOVERY_DB *p_db, UINT32 len, ** Returns TRUE if discovery cancelled, FALSE if a matching activity is not found. ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_CancelServiceSearch (tSDP_DISCOVERY_DB *p_db); +extern BOOLEAN SDP_CancelServiceSearch (tSDP_DISCOVERY_DB *p_db); /******************************************************************************* ** @@ -227,9 +222,9 @@ SDP_API extern BOOLEAN SDP_CancelServiceSearch (tSDP_DISCOVERY_DB *p_db); ** Returns TRUE if discovery started, FALSE if failed. ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr, - tSDP_DISCOVERY_DB *p_db, - tSDP_DISC_CMPL_CB *p_cb); +extern BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr, + tSDP_DISCOVERY_DB *p_db, + tSDP_DISC_CMPL_CB *p_cb); /******************************************************************************* @@ -245,9 +240,9 @@ SDP_API extern BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr, ** Returns TRUE if discovery started, FALSE if failed. ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_ServiceSearchAttributeRequest (UINT8 *p_bd_addr, - tSDP_DISCOVERY_DB *p_db, - tSDP_DISC_CMPL_CB *p_cb); +extern BOOLEAN SDP_ServiceSearchAttributeRequest (UINT8 *p_bd_addr, + tSDP_DISCOVERY_DB *p_db, + tSDP_DISC_CMPL_CB *p_cb); /******************************************************************************* ** @@ -263,9 +258,9 @@ SDP_API extern BOOLEAN SDP_ServiceSearchAttributeRequest (UINT8 *p_bd_addr, ** Returns TRUE if discovery started, FALSE if failed. ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_ServiceSearchAttributeRequest2 (UINT8 *p_bd_addr, - tSDP_DISCOVERY_DB *p_db, - tSDP_DISC_CMPL_CB2 *p_cb, void * user_data); +extern BOOLEAN SDP_ServiceSearchAttributeRequest2 (UINT8 *p_bd_addr, + tSDP_DISCOVERY_DB *p_db, + tSDP_DISC_CMPL_CB2 *p_cb, void * user_data); /* API of utilities to find data in the local discovery database */ @@ -281,9 +276,9 @@ SDP_API extern BOOLEAN SDP_ServiceSearchAttributeRequest2 (UINT8 *p_bd_addr, ** Returns Pointer to matching record, or NULL ** *******************************************************************************/ -SDP_API extern tSDP_DISC_REC *SDP_FindAttributeInDb (tSDP_DISCOVERY_DB *p_db, - UINT16 attr_id, - tSDP_DISC_REC *p_start_rec); +extern tSDP_DISC_REC *SDP_FindAttributeInDb (tSDP_DISCOVERY_DB *p_db, + UINT16 attr_id, + tSDP_DISC_REC *p_start_rec); /******************************************************************************* @@ -296,8 +291,8 @@ SDP_API extern tSDP_DISC_REC *SDP_FindAttributeInDb (tSDP_DISCOVERY_DB *p_db, ** Returns Pointer to matching attribute entry, or NULL ** *******************************************************************************/ -SDP_API extern tSDP_DISC_ATTR *SDP_FindAttributeInRec (tSDP_DISC_REC *p_rec, - UINT16 attr_id); +extern tSDP_DISC_ATTR *SDP_FindAttributeInRec (tSDP_DISC_REC *p_rec, + UINT16 attr_id); /******************************************************************************* @@ -312,9 +307,9 @@ SDP_API extern tSDP_DISC_ATTR *SDP_FindAttributeInRec (tSDP_DISC_REC *p_rec, ** Returns Pointer to record containing service class, or NULL ** *******************************************************************************/ -SDP_API extern tSDP_DISC_REC *SDP_FindServiceInDb (tSDP_DISCOVERY_DB *p_db, - UINT16 service_uuid, - tSDP_DISC_REC *p_start_rec); +extern tSDP_DISC_REC *SDP_FindServiceInDb (tSDP_DISCOVERY_DB *p_db, + UINT16 service_uuid, + tSDP_DISC_REC *p_start_rec); /******************************************************************************* @@ -333,9 +328,9 @@ SDP_API extern tSDP_DISC_REC *SDP_FindServiceInDb (tSDP_DISCOVERY_DB *p_db, ** Returns Pointer to record containing service class, or NULL ** *******************************************************************************/ -SDP_API extern tSDP_DISC_REC *SDP_FindServiceUUIDInDb (tSDP_DISCOVERY_DB *p_db, - tBT_UUID *p_uuid, - tSDP_DISC_REC *p_start_rec); +extern tSDP_DISC_REC *SDP_FindServiceUUIDInDb (tSDP_DISCOVERY_DB *p_db, + tBT_UUID *p_uuid, + tSDP_DISC_REC *p_start_rec); /******************************************************************************* ** @@ -350,7 +345,7 @@ SDP_API extern tSDP_DISC_REC *SDP_FindServiceUUIDInDb (tSDP_DISCOVERY_DB *p_db, ** Returns TRUE if found, otherwise FALSE. ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid); +extern BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid); /******************************************************************************* ** @@ -364,8 +359,8 @@ SDP_API extern BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT ** Returns Pointer to record containing service class, or NULL ** *******************************************************************************/ -SDP_API extern tSDP_DISC_REC *SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB *p_db, - tSDP_DISC_REC *p_start_rec); +extern tSDP_DISC_REC *SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB *p_db, + tSDP_DISC_REC *p_start_rec); /******************************************************************************* ** @@ -378,9 +373,9 @@ SDP_API extern tSDP_DISC_REC *SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB *p_db ** If found, the passed protocol list element is filled in. ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_FindProtocolListElemInRec (tSDP_DISC_REC *p_rec, - UINT16 layer_uuid, - tSDP_PROTOCOL_ELEM *p_elem); +extern BOOLEAN SDP_FindProtocolListElemInRec (tSDP_DISC_REC *p_rec, + UINT16 layer_uuid, + tSDP_PROTOCOL_ELEM *p_elem); /******************************************************************************* @@ -394,9 +389,9 @@ SDP_API extern BOOLEAN SDP_FindProtocolListElemInRec (tSDP_DISC_REC *p_rec, ** If found, the passed protocol list element is filled in. ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_FindAddProtoListsElemInRec (tSDP_DISC_REC *p_rec, - UINT16 layer_uuid, - tSDP_PROTOCOL_ELEM *p_elem); +extern BOOLEAN SDP_FindAddProtoListsElemInRec (tSDP_DISC_REC *p_rec, + UINT16 layer_uuid, + tSDP_PROTOCOL_ELEM *p_elem); /******************************************************************************* @@ -413,9 +408,9 @@ SDP_API extern BOOLEAN SDP_FindAddProtoListsElemInRec (tSDP_DISC_REC *p_rec, ** in are filled in. ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_FindProfileVersionInRec (tSDP_DISC_REC *p_rec, - UINT16 profile_uuid, - UINT16 *p_version); +extern BOOLEAN SDP_FindProfileVersionInRec (tSDP_DISC_REC *p_rec, + UINT16 profile_uuid, + UINT16 *p_version); /* API into SDP for local service database updates */ @@ -432,7 +427,7 @@ SDP_API extern BOOLEAN SDP_FindProfileVersionInRec (tSDP_DISC_REC *p_rec, ** Returns Record handle if OK, else 0. ** *******************************************************************************/ -SDP_API extern UINT32 SDP_CreateRecord (void); +extern UINT32 SDP_CreateRecord (void); /******************************************************************************* @@ -448,7 +443,7 @@ SDP_API extern UINT32 SDP_CreateRecord (void); ** Returns TRUE if succeeded, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_DeleteRecord (UINT32 handle); +extern BOOLEAN SDP_DeleteRecord (UINT32 handle); /******************************************************************************* @@ -464,7 +459,7 @@ SDP_API extern BOOLEAN SDP_DeleteRecord (UINT32 handle); ** The size of data copied into p_data is in *p_data_len. ** *******************************************************************************/ -SDP_API extern INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_len); +extern INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_len); /******************************************************************************* ** @@ -480,9 +475,9 @@ SDP_API extern INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_ ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_AddAttribute (UINT32 handle, UINT16 attr_id, - UINT8 attr_type, UINT32 attr_len, - UINT8 *p_val); +extern BOOLEAN SDP_AddAttribute (UINT32 handle, UINT16 attr_id, + UINT8 attr_type, UINT32 attr_len, + UINT8 *p_val); /******************************************************************************* @@ -499,9 +494,9 @@ SDP_API extern BOOLEAN SDP_AddAttribute (UINT32 handle, UINT16 attr_id, ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_AddSequence (UINT32 handle, UINT16 attr_id, - UINT16 num_elem, UINT8 type[], - UINT8 len[], UINT8 *p_val[]); +extern BOOLEAN SDP_AddSequence (UINT32 handle, UINT16 attr_id, + UINT16 num_elem, UINT8 type[], + UINT8 len[], UINT8 *p_val[]); /******************************************************************************* @@ -516,8 +511,8 @@ SDP_API extern BOOLEAN SDP_AddSequence (UINT32 handle, UINT16 attr_id, ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_AddUuidSequence (UINT32 handle, UINT16 attr_id, - UINT16 num_uuids, UINT16 *p_uuids); +extern BOOLEAN SDP_AddUuidSequence (UINT32 handle, UINT16 attr_id, + UINT16 num_uuids, UINT16 *p_uuids); /******************************************************************************* @@ -532,8 +527,8 @@ SDP_API extern BOOLEAN SDP_AddUuidSequence (UINT32 handle, UINT16 attr_id, ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_AddProtocolList (UINT32 handle, UINT16 num_elem, - tSDP_PROTOCOL_ELEM *p_elem_list); +extern BOOLEAN SDP_AddProtocolList (UINT32 handle, UINT16 num_elem, + tSDP_PROTOCOL_ELEM *p_elem_list); /******************************************************************************* @@ -548,8 +543,8 @@ SDP_API extern BOOLEAN SDP_AddProtocolList (UINT32 handle, UINT16 num_elem, ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem, - tSDP_PROTO_LIST_ELEM *p_proto_list); +extern BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem, + tSDP_PROTO_LIST_ELEM *p_proto_list); /******************************************************************************* @@ -564,9 +559,9 @@ SDP_API extern BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle, - UINT16 profile_uuid, - UINT16 version); +extern BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle, + UINT16 profile_uuid, + UINT16 version); /******************************************************************************* @@ -581,9 +576,9 @@ SDP_API extern BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle, ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle, - UINT16 lang, UINT16 char_enc, - UINT16 base_id); +extern BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle, + UINT16 lang, UINT16 char_enc, + UINT16 base_id); /******************************************************************************* @@ -598,9 +593,9 @@ SDP_API extern BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle, ** Returns TRUE if added OK, else FALSE ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_AddServiceClassIdList (UINT32 handle, - UINT16 num_services, - UINT16 *p_service_uuids); +extern BOOLEAN SDP_AddServiceClassIdList (UINT32 handle, + UINT16 num_services, + UINT16 *p_service_uuids); /******************************************************************************* @@ -613,7 +608,7 @@ SDP_API extern BOOLEAN SDP_AddServiceClassIdList (UINT32 handle, ** Returns TRUE if deleted OK, else FALSE if not found ** *******************************************************************************/ -SDP_API extern BOOLEAN SDP_DeleteAttribute (UINT32 handle, UINT16 attr_id); +extern BOOLEAN SDP_DeleteAttribute (UINT32 handle, UINT16 attr_id); /* Device Identification APIs */ @@ -627,23 +622,8 @@ SDP_API extern BOOLEAN SDP_DeleteAttribute (UINT32 handle, UINT16 attr_id); ** Returns Returns SDP_SUCCESS if record added successfully, else error ** *******************************************************************************/ -SDP_API extern UINT16 SDP_SetLocalDiRecord (tSDP_DI_RECORD *device_info, - UINT32 *p_handle); - -/******************************************************************************* -** -** Function SDP_GetLocalDiRecord -** -** Description This function adds a DI record to the local SDP database. -** -** Fills in the device information of the record -** p_handle - if p_handle == NULL, the primary record is returned -** -** Returns Returns SDP_SUCCESS if record exists, else error -** -*******************************************************************************/ -SDP_API extern UINT16 SDP_GetLocalDiRecord(tSDP_DI_GET_RECORD *p_device_info, - UINT32 *p_handle ); +extern UINT16 SDP_SetLocalDiRecord (tSDP_DI_RECORD *device_info, + UINT32 *p_handle); /******************************************************************************* ** @@ -654,9 +634,9 @@ SDP_API extern UINT16 SDP_GetLocalDiRecord(tSDP_DI_GET_RECORD *p_device_info, ** Returns SDP_SUCCESS if query started successfully, else error ** *******************************************************************************/ -SDP_API extern UINT16 SDP_DiDiscover (BD_ADDR remote_device, - tSDP_DISCOVERY_DB *p_db, UINT32 len, - tSDP_DISC_CMPL_CB *p_cb); +extern UINT16 SDP_DiDiscover (BD_ADDR remote_device, + tSDP_DISCOVERY_DB *p_db, UINT32 len, + tSDP_DISC_CMPL_CB *p_cb); /******************************************************************************* @@ -668,7 +648,7 @@ SDP_API extern UINT16 SDP_DiDiscover (BD_ADDR remote_device, ** Returns number of DI records found ** *******************************************************************************/ -SDP_API extern UINT8 SDP_GetNumDiRecords (tSDP_DISCOVERY_DB *p_db); +extern UINT8 SDP_GetNumDiRecords (tSDP_DISCOVERY_DB *p_db); /******************************************************************************* @@ -681,9 +661,9 @@ SDP_API extern UINT8 SDP_GetNumDiRecords (tSDP_DISCOVERY_DB *p_db); ** Returns SDP_SUCCESS if record retrieved, else error ** *******************************************************************************/ -SDP_API extern UINT16 SDP_GetDiRecord (UINT8 getRecordIndex, - tSDP_DI_GET_RECORD *device_info, - tSDP_DISCOVERY_DB *p_db); +extern UINT16 SDP_GetDiRecord (UINT8 getRecordIndex, + tSDP_DI_GET_RECORD *device_info, + tSDP_DISCOVERY_DB *p_db); /******************************************************************************* @@ -696,7 +676,7 @@ SDP_API extern UINT16 SDP_GetDiRecord (UINT8 getRecordIndex, ** Returns the new (current) trace level ** *******************************************************************************/ -SDP_API extern UINT8 SDP_SetTraceLevel (UINT8 new_level); +extern UINT8 SDP_SetTraceLevel (UINT8 new_level); /******************************************************************************* ** @@ -708,8 +688,8 @@ SDP_API extern UINT8 SDP_SetTraceLevel (UINT8 new_level); ** Returns 0, if failed to initiate connection. Otherwise, the handle. ** *******************************************************************************/ -SDP_API UINT32 SDP_ConnOpen (UINT8 *p_bd_addr, tSDP_DISC_RES_CB *p_rcb, - tSDP_DISC_CMPL_CB *p_cb); +UINT32 SDP_ConnOpen (UINT8 *p_bd_addr, tSDP_DISC_RES_CB *p_rcb, + tSDP_DISC_CMPL_CB *p_cb); /******************************************************************************* ** @@ -720,7 +700,7 @@ SDP_API UINT32 SDP_ConnOpen (UINT8 *p_bd_addr, tSDP_DISC_RES_CB *p_rcb, ** Returns TRUE if data is sent, FALSE if failed. ** *******************************************************************************/ -SDP_API BOOLEAN SDP_WriteData (UINT32 handle, BT_HDR *p_msg); +BOOLEAN SDP_WriteData (UINT32 handle, BT_HDR *p_msg); /******************************************************************************* ** @@ -733,7 +713,7 @@ SDP_API BOOLEAN SDP_WriteData (UINT32 handle, BT_HDR *p_msg); ** Returns TRUE if connection is closed, FALSE if failed to find the handle. ** *******************************************************************************/ -SDP_API BOOLEAN SDP_ConnClose (UINT32 handle); +BOOLEAN SDP_ConnClose (UINT32 handle); /******************************************************************************* ** @@ -747,7 +727,7 @@ SDP_API BOOLEAN SDP_ConnClose (UINT32 handle); ** Returns TRUE if found, otherwise FALSE. ** *******************************************************************************/ -SDP_API BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID *p_uuid); +BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID *p_uuid); #ifdef __cplusplus } diff --git a/stack/include/sdpdefs.h b/stack/include/sdpdefs.h index fcd4a5e6f..22d87c1ad 100644 --- a/stack/include/sdpdefs.h +++ b/stack/include/sdpdefs.h @@ -146,12 +146,6 @@ #define ATTR_ID_HDP_DATA_EXCH_SPEC 0x0301 /* Data exchange specification */ #define ATTR_ID_HDP_MCAP_SUP_PROC 0x0302 /* MCAP supported procedures */ -/* a temporary value for IOP */ -#ifndef ATTR_ID_OBX_OVR_L2CAP_PSM -#define ATTR_ID_OBX_OVR_L2CAP_PSM 0x0200 -#endif - - /* Define common 16-bit protocol UUIDs */ #define UUID_PROTOCOL_SDP 0x0001 diff --git a/stack/include/smp_api.h b/stack/include/smp_api.h index e47cce321..79d1d6fa8 100644 --- a/stack/include/smp_api.h +++ b/stack/include/smp_api.h @@ -184,7 +184,7 @@ extern "C" ** Returns void ** *******************************************************************************/ - SMP_API extern void SMP_Init(void); +extern void SMP_Init(void); /******************************************************************************* ** @@ -196,7 +196,7 @@ extern "C" ** Returns The new or current trace level ** *******************************************************************************/ - SMP_API extern UINT8 SMP_SetTraceLevel (UINT8 new_level); +extern UINT8 SMP_SetTraceLevel (UINT8 new_level); /******************************************************************************* ** @@ -207,7 +207,7 @@ extern "C" ** Returns void ** *******************************************************************************/ - SMP_API extern BOOLEAN SMP_Register (tSMP_CALLBACK *p_cback); +extern BOOLEAN SMP_Register (tSMP_CALLBACK *p_cback); /******************************************************************************* ** @@ -218,7 +218,7 @@ extern "C" ** Returns SMP_STARTED if bond started, else otherwise exception. ** *******************************************************************************/ - SMP_API extern tSMP_STATUS SMP_Pair (BD_ADDR bd_addr); +extern tSMP_STATUS SMP_Pair (BD_ADDR bd_addr); /******************************************************************************* ** ** Function SMP_PairCancel @@ -228,7 +228,7 @@ extern "C" ** Returns TRUE - pairing cancelled ** *******************************************************************************/ - SMP_API extern BOOLEAN SMP_PairCancel (BD_ADDR bd_addr); +extern BOOLEAN SMP_PairCancel (BD_ADDR bd_addr); /******************************************************************************* ** @@ -243,7 +243,7 @@ extern "C" ** Returns None ** *******************************************************************************/ - SMP_API extern void SMP_SecurityGrant(BD_ADDR bd_addr, UINT8 res); +extern void SMP_SecurityGrant(BD_ADDR bd_addr, UINT8 res); /******************************************************************************* ** @@ -258,7 +258,7 @@ extern "C" ** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)). ** *******************************************************************************/ - SMP_API extern void SMP_PasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey); +extern void SMP_PasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey); /******************************************************************************* ** @@ -272,8 +272,8 @@ extern "C" ** p_data - simple pairing Randomizer C. ** *******************************************************************************/ - SMP_API extern void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, UINT8 len, - UINT8 *p_data); +extern void SMP_OobDataReply(BD_ADDR bd_addr, tSMP_STATUS res, UINT8 len, + UINT8 *p_data); /******************************************************************************* ** @@ -291,9 +291,9 @@ extern "C" ** ** Returns Boolean - TRUE: encryption is successful *******************************************************************************/ - SMP_API extern BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len, - UINT8 *plain_text, UINT8 pt_len, - tSMP_ENC *p_out); +extern BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len, + UINT8 *plain_text, UINT8 pt_len, + tSMP_ENC *p_out); #ifdef __cplusplus } diff --git a/stack/include/srvc_api.h b/stack/include/srvc_api.h index d04964ad9..09c5b3e4b 100644 --- a/stack/include/srvc_api.h +++ b/stack/include/srvc_api.h @@ -141,7 +141,7 @@ extern "C" ** as for a central service management. ** *******************************************************************************/ - GATT_API extern tGATT_STATUS srvc_eng_init (void); +extern tGATT_STATUS srvc_eng_init (void); /***************************************************************************** @@ -155,7 +155,7 @@ extern "C" ** Description Initializa the Device Information Service Server. ** *******************************************************************************/ - GATT_API extern tDIS_STATUS DIS_SrInit (tDIS_ATTR_MASK dis_attr_mask); +extern tDIS_STATUS DIS_SrInit (tDIS_ATTR_MASK dis_attr_mask); /******************************************************************************* ** ** Function DIS_SrUpdate @@ -163,7 +163,7 @@ extern "C" ** Description Update the DIS server attribute values ** *******************************************************************************/ - GATT_API extern tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info); +extern tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info); /***************************************************************************** ** DIS Client Function *****************************************************************************/ @@ -176,8 +176,8 @@ extern "C" ** Returns void ** *******************************************************************************/ - GATT_API extern BOOLEAN DIS_ReadDISInfo(BD_ADDR peer_bda, tDIS_READ_CBACK *p_cback, - tDIS_ATTR_MASK mask); +extern BOOLEAN DIS_ReadDISInfo(BD_ADDR peer_bda, tDIS_READ_CBACK *p_cback, + tDIS_ATTR_MASK mask); /******************************************************************************* ** BATTERY SERVICE API @@ -189,7 +189,7 @@ extern "C" ** Description Instantiate a Battery service ** *******************************************************************************/ - GATT_API extern UINT16 Battery_Instantiate (UINT8 app_id, tBA_REG_INFO *p_reg_info); +extern UINT16 Battery_Instantiate (UINT8 app_id, tBA_REG_INFO *p_reg_info); /******************************************************************************* ** @@ -198,7 +198,7 @@ extern "C" ** Description Respond to a battery service request ** *******************************************************************************/ - GATT_API extern void Battery_Rsp (UINT8 app_id, tGATT_STATUS st, UINT8 event, tBA_RSP_DATA *p_rsp); +extern void Battery_Rsp (UINT8 app_id, tGATT_STATUS st, UINT8 event, tBA_RSP_DATA *p_rsp); /******************************************************************************* ** ** Function Battery_Notify @@ -206,7 +206,7 @@ extern "C" ** Description Send battery level notification ** *******************************************************************************/ - GATT_API extern void Battery_Notify (UINT8 app_id, BD_ADDR remote_bda, UINT8 battery_level); +extern void Battery_Notify (UINT8 app_id, BD_ADDR remote_bda, UINT8 battery_level); #ifdef __cplusplus @@ -215,5 +215,3 @@ extern "C" #endif #endif - - diff --git a/stack/include/utfc.h b/stack/include/utfc.h deleted file mode 100644 index 787efe824..000000000 --- a/stack/include/utfc.h +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2003-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. - * - ******************************************************************************/ - -/****************************************************************************** - * - * UTF conversion utilities. - * - ******************************************************************************/ -#ifndef UTFC_H -#define UTFC_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/******************************************************************************* -** -** Function utfc_16_to_8 -** -** Description Convert a UTF-16 array to a null-terminated UTF-8 string. -** Illegal characters are skipped. -** -** Returns Length of UTF-8 string in bytes. -** -*******************************************************************************/ -extern UINT16 utfc_16_to_8(UINT8 *p_utf8, UINT16 utf8_len, UINT16 *p_utf16, UINT16 utf16_len); - -/******************************************************************************* -** -** Function utfc_8_to_16 -** -** Description Convert a null-terminated UTF-8 string to a UTF-16 array. -** Illegal characters are skipped. The UTF-16 array is -** appended with a zero (null) character. -** -** Returns Length of UTF-16 array including null character. -** -*******************************************************************************/ -extern UINT16 utfc_8_to_16(UINT16 *p_utf16, UINT16 utf16_len, UINT8 *p_utf8); - -#ifdef __cplusplus -} -#endif - -#endif /* UTFC_H */ diff --git a/stack/include/wbt_api.h b/stack/include/wbt_api.h deleted file mode 100644 index 8bfb77265..000000000 --- a/stack/include/wbt_api.h +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2003-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 definitions and constants used by the Broadcom - * Bluetooth Extensions API software. - * - ******************************************************************************/ -#ifndef WBT_API_H -#define WBT_API_H - -#include "bt_target.h" - -/***************************************************************************** -** Constants and Types -*****************************************************************************/ - -/************************** -* SDP Attribute IDs * -***************************/ -#define ATTR_ID_EXT_BRCM_VERSION 0x8001 /* UINT16 (0xmmnn - major, minor [0x0001]) mandatory */ -#define ATTR_ID_EXT_PIN_CODE 0x8002 /* UINT32 4 - digit pin */ - -/************************** -* SDP Attribute ID Values * -***************************/ -/* Version Attribute Value */ -#define BRCM_EXT_VERSION 0x0001 /* UINT16 (0xmmnn - major, minor [0x0001]) mandatory */ - -/* Pin Code Attribute Value */ -#define BRCM_EXT_PIN_CODE 0x00000000 /* UINT32 ('0000') */ - -/***************************************************************************** -** External Function Declarations -*****************************************************************************/ -#ifdef __cplusplus -extern "C" -{ -#endif - -BT_API extern BOOLEAN WBT_ExtCreateRecord(void); - -/*** Features ***/ -BT_API extern BOOLEAN WBT_ExtAddPinCode(void); - - -BT_API extern UINT32 wbt_sdp_show_ext(UINT8 scn, char *service_name, - UINT8 pin_code_ext, - UINT8 active_sync_ext); - -#ifdef __cplusplus -} -#endif - -#endif /* WBT_API_H */ diff --git a/stack/include/wcassert.h b/stack/include/wcassert.h deleted file mode 100644 index a1d7b47d0..000000000 --- a/stack/include/wcassert.h +++ /dev/null @@ -1,65 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 1999-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. - * - ******************************************************************************/ -#ifndef WC_ASSERT_H -#define WC_ASSERT_H - - -#ifdef _DEBUG - -#include "bt_target.h" - - - -/* debug settings*/ -#ifndef WC_DEBUG_LEVEL -#define WC_DEBUG_LEVEL 0 -#endif - -#if WC_DEBUG_LEVEL == 0 - -#include "stdio.h" /* for printf()*/ - -#ifdef __cplusplus -extern "C" wc_assert(char *message, char *file, UINT32 line); -#else -void wc_assert(char *message, char *file, UINT32 line); -#endif - -#define WC_ASSERT(_x) if ( !(_x) ) wc_assert("ASSERT at %s line %d\n", __FILE__, __LINE__); -#define WC_ASSERT_ALWAYS() wc_assert("ASSERT! at %s line %d\n", __FILE__, __LINE__); - -#elif WC_DEBUG_LEVEL == 1 - -#include "assert.h" - -#define WC_ASSERT(_x) assert(_x); -#define WC_ASSERT_ALWAYS() assert(0); -#endif /* WC_DEBUG_LEVEL*/ - -#else /* _DEBUG*/ - -#ifndef WC_ASSERT -#define WC_ASSERT(_x) ; -#endif - -#ifndef WC_ASSERT_ALWAYS -#define WC_ASSERT_ALWAYS() ; -#endif - -#endif /* _DEBUG*/ -#endif /* WC_ASSERT_H*/ diff --git a/stack/l2cap/l2c_api.c b/stack/l2cap/l2c_api.c index b53eff0ca..667f717f3 100644 --- a/stack/l2cap/l2c_api.c +++ b/stack/l2cap/l2c_api.c @@ -22,18 +22,24 @@ * ******************************************************************************/ +#define LOG_TAG "bt_l2cap" + +#include <assert.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include "gki.h" #include "bt_types.h" +#include "btcore/include/counter.h" #include "hcidefs.h" #include "hcimsgs.h" #include "l2cdefs.h" #include "l2c_int.h" #include "btu.h" #include "btm_api.h" +#include "osi/include/allocator.h" +#include "osi/include/log.h" /******************************************************************************* ** @@ -236,6 +242,7 @@ UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_ERTM_INFO *p_e tL2C_CCB *p_ccb; tL2C_RCB *p_rcb; + counter_add("l2cap.conn.req", 1); L2CAP_TRACE_API ("L2CA_ErtmConnectReq() PSM: 0x%04x BDA: %08x%04x p_ertm_info: 0x%08x allowed:0x%x preferred:%d", psm, (p_bd_addr[0]<<24)+(p_bd_addr[1]<<16)+(p_bd_addr[2]<<8)+p_bd_addr[3], (p_bd_addr[4]<<8)+p_bd_addr[5], p_ertm_info, @@ -326,6 +333,44 @@ UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_ERTM_INFO *p_e return (p_ccb->local_cid); } +bool L2CA_SetConnectionCallbacks(uint16_t local_cid, const tL2CAP_APPL_INFO *callbacks) { + assert(callbacks != NULL); + assert(callbacks->pL2CA_ConnectInd_Cb == NULL); + assert(callbacks->pL2CA_ConnectCfm_Cb != NULL); + assert(callbacks->pL2CA_ConfigInd_Cb != NULL); + assert(callbacks->pL2CA_ConfigCfm_Cb != NULL); + assert(callbacks->pL2CA_DisconnectInd_Cb != NULL); + assert(callbacks->pL2CA_DisconnectCfm_Cb != NULL); + assert(callbacks->pL2CA_CongestionStatus_Cb != NULL); + assert(callbacks->pL2CA_DataInd_Cb != NULL); + assert(callbacks->pL2CA_TxComplete_Cb != NULL); + + tL2C_CCB *channel_control_block = l2cu_find_ccb_by_cid(NULL, local_cid); + if (!channel_control_block) { + LOG_ERROR("%s no channel control block found for L2CAP LCID=0x%04x.", __func__, local_cid); + return false; + } + + // We're making a connection-specific registration control block so we check if + // we already have a private one allocated to us on the heap. If not, we make a + // new allocation, mark it as heap-allocated, and inherit the fields from the old + // control block. + tL2C_RCB *registration_control_block = channel_control_block->p_rcb; + if (!channel_control_block->should_free_rcb) { + registration_control_block = (tL2C_RCB *)osi_calloc(sizeof(tL2C_RCB)); + if (!registration_control_block) { + LOG_ERROR("%s unable to allocate registration control block.", __func__); + return false; + } + + *registration_control_block = *channel_control_block->p_rcb; + channel_control_block->p_rcb = registration_control_block; + channel_control_block->should_free_rcb = true; + } + + registration_control_block->api = *callbacks; + return true; +} /******************************************************************************* ** @@ -362,6 +407,7 @@ BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 re tL2C_LCB *p_lcb; tL2C_CCB *p_ccb; + counter_add("l2cap.conn.rsp", 1); L2CAP_TRACE_API ("L2CA_ErtmConnectRsp() CID: 0x%04x Result: %d Status: %d BDA: %08x%04x p_ertm_info:0x%08x", lcid, result, status, (p_bd_addr[0]<<24)+(p_bd_addr[1]<<16)+(p_bd_addr[2]<<8)+p_bd_addr[3], @@ -445,6 +491,7 @@ BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg) { tL2C_CCB *p_ccb; + counter_add("l2cap.cfg.req", 1); L2CAP_TRACE_API ("L2CA_ConfigReq() CID 0x%04x: fcr_present:%d (mode %d) mtu_present:%d (%d)", cid, p_cfg->fcr_present, p_cfg->fcr.mode, p_cfg->mtu_present, p_cfg->mtu); @@ -496,6 +543,7 @@ BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg) { tL2C_CCB *p_ccb; + counter_add("l2cap.cfg.rsp", 1); L2CAP_TRACE_API ("L2CA_ConfigRsp() CID: 0x%04x Result: %d MTU present:%d Flush TO:%d FCR:%d FCS:%d", cid, p_cfg->result, p_cfg->mtu_present, p_cfg->flush_to_present, p_cfg->fcr_present, p_cfg->fcs_present); @@ -540,6 +588,7 @@ BOOLEAN L2CA_DisconnectReq (UINT16 cid) { tL2C_CCB *p_ccb; + counter_add("l2cap.disconn.req", 1); L2CAP_TRACE_API ("L2CA_DisconnectReq() CID: 0x%04x", cid); /* Find the channel control block. We don't know the link it is on. */ @@ -568,6 +617,7 @@ BOOLEAN L2CA_DisconnectRsp (UINT16 cid) { tL2C_CCB *p_ccb; + counter_add("l2cap.disconn.rsp", 1); L2CAP_TRACE_API ("L2CA_DisconnectRsp() CID: 0x%04x", cid); /* Find the channel control block. We don't know the link it is on. */ @@ -703,6 +753,19 @@ BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_cal } +bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t *rcid, uint16_t *handle) { + tL2C_CCB *control_block = l2cu_find_ccb_by_cid(NULL, lcid); + if (!control_block) + return false; + + if (rcid) + *rcid = control_block->remote_cid; + if (handle) + *handle = control_block->p_lcb->handle; + + return true; +} + /******************************************************************************* ** ** Function L2CA_SetIdleTimeout @@ -1483,7 +1546,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf) { L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested \ xmit_hold_q.count: %u buff_quota: %u", fixed_cid, - p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q.count, + GKI_queue_length(&p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q), p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota); GKI_freebuf (p_buf); return (L2CAP_DW_FAILED); @@ -1796,7 +1859,6 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush) UINT16 num_left = 0, num_flushed1 = 0, num_flushed2 = 0; - BT_HDR *p_buf1, *p_buf; p_ccb = l2cu_find_ccb_by_cid(NULL, lcid); @@ -1809,7 +1871,7 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush) if (num_to_flush != L2CAP_FLUSH_CHANS_GET) { L2CAP_TRACE_API ("L2CA_FlushChannel (FLUSH) CID: 0x%04x NumToFlush: %d QC: %u pFirst: 0x%08x", - lcid, num_to_flush, p_ccb->xmit_hold_q.count, p_ccb->xmit_hold_q.p_first); + lcid, num_to_flush, GKI_queue_length(&p_ccb->xmit_hold_q), GKI_getfirst(&p_ccb->xmit_hold_q)); } else { @@ -1837,31 +1899,26 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush) } #endif - p_buf = (BT_HDR *)p_lcb->link_xmit_data_q.p_first; - - /* First flush the number we are asked to flush */ - while ((p_buf != NULL) && (num_to_flush != 0)) - { - /* Do not flush other CIDs or partial segments */ - if ( (p_buf->layer_specific == 0) && (p_buf->event == lcid) ) - { - p_buf1 = p_buf; - p_buf = (BT_HDR *)GKI_getnext (p_buf); - num_to_flush--; - num_flushed1++; - - GKI_remove_from_queue (&p_lcb->link_xmit_data_q, p_buf1); - GKI_freebuf (p_buf1); - } - else - p_buf = (BT_HDR *)GKI_getnext (p_buf); + // Iterate though list and flush the amount requested from + // the transmit data queue that satisfy the layer and event conditions. + for (const list_node_t *node = list_begin(p_lcb->link_xmit_data_q); + (num_to_flush > 0) && node != list_end(p_lcb->link_xmit_data_q);) { + BT_HDR *p_buf = (BT_HDR *)list_node(node); + node = list_next(node); + if ((p_buf->layer_specific == 0) && (p_buf->event == lcid)) { + num_to_flush--; + num_flushed1++; + + list_remove(p_lcb->link_xmit_data_q, p_buf); + GKI_freebuf(p_buf); + } } } /* If needed, flush buffers in the CCB xmit hold queue */ - while ( (num_to_flush != 0) && (p_ccb->xmit_hold_q.count != 0) ) + while ( (num_to_flush != 0) && (!GKI_queue_is_empty(&p_ccb->xmit_hold_q))) { - p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q); + BT_HDR *p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q); if (p_buf) GKI_freebuf (p_buf); num_to_flush--; @@ -1873,18 +1930,17 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush) (*p_ccb->p_rcb->api.pL2CA_TxComplete_Cb)(p_ccb->local_cid, num_flushed2); /* Now count how many are left */ - p_buf = (BT_HDR *)p_lcb->link_xmit_data_q.p_first; - - while (p_buf != NULL) - { - if (p_buf->event == lcid) - num_left++; + for (const list_node_t *node = list_begin(p_lcb->link_xmit_data_q); + node != list_end(p_lcb->link_xmit_data_q); + node = list_next(node)) { - p_buf = (BT_HDR *)GKI_getnext (p_buf); + BT_HDR *p_buf = (BT_HDR *)list_node(node); + if (p_buf->event == lcid) + num_left++; } /* Add in the number in the CCB xmit queue */ - num_left += p_ccb->xmit_hold_q.count; + num_left += GKI_queue_length(&p_ccb->xmit_hold_q); /* Return the local number of buffers left for the CID */ L2CAP_TRACE_DEBUG ("L2CA_FlushChannel() flushed: %u + %u, num_left: %u", num_flushed1, num_flushed2, num_left); diff --git a/stack/l2cap/l2c_ble.c b/stack/l2cap/l2c_ble.c index d3ba6e229..61bc72a7a 100644 --- a/stack/l2cap/l2c_ble.c +++ b/stack/l2cap/l2c_ble.c @@ -30,6 +30,7 @@ #include "btu.h" #include "btm_int.h" #include "hcimsgs.h" +#include "device/include/controller.h" #if (BLE_INCLUDED == TRUE) static void l2cble_start_conn_update (tL2C_LCB *p_lcb); @@ -416,7 +417,7 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT; - if (!HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(btm_cb.devcb.local_le_features)) + if (!HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array)) { p_lcb->link_state = LST_CONNECTED; l2cu_process_fixed_chnl_resp (p_lcb); @@ -488,7 +489,7 @@ static void l2cble_start_conn_update (tL2C_LCB *p_lcb) /* if both side 4.1, or we are master device, send HCI command */ if (p_lcb->link_role == HCI_ROLE_MASTER #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE) - || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(btm_cb.devcb.local_le_features) && + || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) && HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl_cb->peer_le_features)) #endif ) @@ -513,7 +514,7 @@ static void l2cble_start_conn_update (tL2C_LCB *p_lcb) /* if both side 4.1, or we are master device, send HCI command */ if (p_lcb->link_role == HCI_ROLE_MASTER #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE) - || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(btm_cb.devcb.local_le_features) && + || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) && HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl_cb->peer_le_features)) #endif ) @@ -582,8 +583,7 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) { UINT8 *p_pkt_end; UINT8 cmd_code, id; - UINT16 cmd_len, rej_reason; - UINT16 result; + UINT16 cmd_len; UINT16 min_interval, max_interval, latency, timeout; p_pkt_end = p + pkt_len; @@ -604,7 +604,7 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) case L2CAP_CMD_REJECT: case L2CAP_CMD_ECHO_RSP: case L2CAP_CMD_INFO_RSP: - STREAM_TO_UINT16 (rej_reason, p); + p += 2; break; case L2CAP_CMD_ECHO_REQ: case L2CAP_CMD_INFO_REQ: @@ -647,7 +647,7 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) break; case L2CAP_CMD_BLE_UPDATE_RSP: - STREAM_TO_UINT16 (result, p); + p += 2; break; default: @@ -915,7 +915,7 @@ void l2c_ble_link_adjust_allocation (void) /* this link may have sent anything but some other link sent packets so */ /* so we may need a timer to kick off this link's transmissions. */ if ( (p_lcb->link_state == LST_CONNECTED) - && (p_lcb->link_xmit_data_q.count) + && (!list_is_empty(p_lcb->link_xmit_data_q)) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota) ) btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_FLOW_CONTROL_TOUT); } diff --git a/stack/l2cap/l2c_csm.c b/stack/l2cap/l2c_csm.c index fa261b211..325f72039 100644 --- a/stack/l2cap/l2c_csm.c +++ b/stack/l2cap/l2c_csm.c @@ -183,7 +183,6 @@ static void l2c_csm_closed (tL2C_CCB *p_ccb, UINT16 event, void *p_data) case L2CEVT_L2CA_CONNECT_REQ: /* API connect request */ /* Cancel sniff mode if needed */ -#if BTM_PWR_MGR_INCLUDED == TRUE { tBTM_PM_PWR_MD settings; // btla-specific ++ @@ -199,9 +198,6 @@ Event uninit_use_in_call: Using uninitialized value "settings.min" in call to fu */ BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, &settings); } -#else - BTM_CancelSniffMode (p_ccb->p_lcb->remote_bd_addr); -#endif /* If sec access does not result in started SEC_COM or COMP_NEG are already processed */ if (btm_sec_l2cap_access_req (p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, @@ -240,7 +236,6 @@ Event uninit_use_in_call: Using uninitialized value "settings.min" in call to fu btu_stop_timer (&p_ccb->p_lcb->timer_entry); /* Cancel sniff mode if needed */ -#if BTM_PWR_MGR_INCLUDED == TRUE { tBTM_PM_PWR_MD settings; // btla-specific ++ @@ -256,9 +251,6 @@ Event uninit_use_in_call: Using uninitialized value "settings.min" in call to fu */ BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, &settings); } -#else - BTM_CancelSniffMode (p_ccb->p_lcb->remote_bd_addr); -#endif p_ccb->chnl_state = CST_TERM_W4_SEC_COMP; if (btm_sec_l2cap_access_req (p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, @@ -789,7 +781,7 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data) p_ccb->fcrb.connect_tick_count = GKI_get_os_tick_count(); #endif /* See if we can forward anything on the hold queue */ - if (p_ccb->xmit_hold_q.count) + if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)) { l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL); } @@ -872,7 +864,7 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data) #endif /* See if we can forward anything on the hold queue */ - if ( (p_ccb->chnl_state == CST_OPEN) && (p_ccb->xmit_hold_q.count) ) + if ( (p_ccb->chnl_state == CST_OPEN) && (!GKI_queue_is_empty(&p_ccb->xmit_hold_q))) { l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL); } @@ -1012,16 +1004,12 @@ static void l2c_csm_open (tL2C_CCB *p_ccb, UINT16 event, void *p_data) case L2CEVT_L2CAP_DISCONNECT_REQ: /* Peer disconnected request */ // btla-specific ++ /* Make sure we are not in sniff mode */ -#if BTM_PWR_MGR_INCLUDED == TRUE { tBTM_PM_PWR_MD settings; memset((void*)&settings, 0, sizeof(settings)); settings.mode = BTM_PM_MD_ACTIVE; BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, &settings); } -#else - BTM_CancelSniffMode (p_ccb->p_lcb->remote_bd_addr); -#endif // btla-specific -- p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP; @@ -1036,16 +1024,12 @@ static void l2c_csm_open (tL2C_CCB *p_ccb, UINT16 event, void *p_data) case L2CEVT_L2CA_DISCONNECT_REQ: /* Upper wants to disconnect */ /* Make sure we are not in sniff mode */ -#if BTM_PWR_MGR_INCLUDED == TRUE { tBTM_PM_PWR_MD settings; memset((void*)&settings, 0, sizeof(settings)); settings.mode = BTM_PM_MD_ACTIVE; BTM_SetPowerMode (BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, &settings); } -#else - BTM_CancelSniffMode (p_ccb->p_lcb->remote_bd_addr); -#endif l2cu_send_peer_disc_req (p_ccb); p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; diff --git a/stack/l2cap/l2c_fcr.c b/stack/l2cap/l2c_fcr.c index 6e12607cd..ec9a4ef88 100644 --- a/stack/l2cap/l2c_fcr.c +++ b/stack/l2cap/l2c_fcr.c @@ -23,20 +23,20 @@ * ******************************************************************************/ +#include <assert.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdio.h> -#include "gki.h" #include "bt_types.h" +#include "gki.h" #include "hcimsgs.h" -#include "l2cdefs.h" -#include "l2c_int.h" #include "l2c_api.h" -#include "btu.h" +#include "l2c_int.h" +#include "l2cdefs.h" #include "btm_api.h" #include "btm_int.h" - +#include "btu.h" /* Flag passed to retransmit_i_frames() when all packets should be retransmitted */ #define L2C_FCR_RETX_ALL_PKTS 0xFF @@ -94,12 +94,6 @@ static void prepare_I_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, BOOLEAN is_retra static void process_stream_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf); static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word); -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE -static BOOLEAN l2c_corrupt_the_fcr_packet (tL2C_CCB *p_ccb, BT_HDR *p_buf, - BOOLEAN is_rx, UINT16 ctrl_word); -static BOOLEAN l2c_bypass_sframe_packet (tL2C_CCB *p_ccb); -#endif - #if (L2CAP_ERTM_STATS == TRUE) static void l2c_fcr_collect_ack_delay (tL2C_CCB *p_ccb, UINT8 num_bufs_acked); #endif @@ -113,7 +107,7 @@ static void l2c_fcr_collect_ack_delay (tL2C_CCB *p_ccb, UINT8 num_bufs_acked); ** Returns CRC ** *******************************************************************************/ -unsigned short l2c_fcr_updcrc(unsigned short icrc, unsigned char *icp, int icnt) +static unsigned short l2c_fcr_updcrc(unsigned short icrc, unsigned char *icp, int icnt) { register unsigned short crc = icrc; register unsigned char *cp = icp; @@ -137,7 +131,7 @@ unsigned short l2c_fcr_updcrc(unsigned short icrc, unsigned char *icp, int icnt) ** Returns CRC ** *******************************************************************************/ -UINT16 l2c_fcr_tx_get_fcs (BT_HDR *p_buf) +static UINT16 l2c_fcr_tx_get_fcs (BT_HDR *p_buf) { UINT8 *p = ((UINT8 *) (p_buf + 1)) + p_buf->offset; @@ -153,7 +147,7 @@ UINT16 l2c_fcr_tx_get_fcs (BT_HDR *p_buf) ** Returns CRC ** *******************************************************************************/ -UINT16 l2c_fcr_rx_get_fcs (BT_HDR *p_buf) +static UINT16 l2c_fcr_rx_get_fcs (BT_HDR *p_buf) { UINT8 *p = ((UINT8 *) (p_buf + 1)) + p_buf->offset; @@ -174,6 +168,7 @@ UINT16 l2c_fcr_rx_get_fcs (BT_HDR *p_buf) *******************************************************************************/ void l2c_fcr_start_timer (tL2C_CCB *p_ccb) { + assert(p_ccb != NULL); UINT32 tout; /* The timers which are in milliseconds */ @@ -185,10 +180,7 @@ void l2c_fcr_start_timer (tL2C_CCB *p_ccb) { tout = (UINT32)p_ccb->our_cfg.fcr.rtrans_tout; } -/* - L2CAP_TRACE_DEBUG ("l2c_fcr_start_timer Tout: %u Already Running: %u wait_ack: %u ack_q_count: %u", - tout, p_ccb->timer_entry.in_use, p_ccb->fcrb.wait_ack, p_ccb->fcrb.waiting_for_ack_q.count); -*/ + /* Only start a timer that was not started */ if (p_ccb->fcrb.mon_retrans_timer.in_use == 0) btu_start_quick_timer (&p_ccb->fcrb.mon_retrans_timer, BTU_TTYPE_L2CAP_CHNL, tout*QUICK_TIMER_TICKS_PER_SEC/1000); @@ -205,12 +197,9 @@ void l2c_fcr_start_timer (tL2C_CCB *p_ccb) *******************************************************************************/ void l2c_fcr_stop_timer (tL2C_CCB *p_ccb) { + assert(p_ccb != NULL); if (p_ccb->fcrb.mon_retrans_timer.in_use) { -/* - L2CAP_TRACE_DEBUG ("l2c_fcr_stop_timer wait_ack: %u ack_q_count: %u", - p_ccb->fcrb.wait_ack, p_ccb->fcrb.waiting_for_ack_q.count); -*/ btu_stop_quick_timer (&p_ccb->fcrb.mon_retrans_timer); } } @@ -226,6 +215,7 @@ void l2c_fcr_stop_timer (tL2C_CCB *p_ccb) *******************************************************************************/ void l2c_fcr_cleanup (tL2C_CCB *p_ccb) { + assert(p_ccb != NULL); tL2C_FCRB *p_fcrb = &p_ccb->fcrb; l2c_fcr_stop_timer (p_ccb); @@ -233,13 +223,13 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb) if (p_fcrb->p_rx_sdu) GKI_freebuf (p_fcrb->p_rx_sdu); - while (p_fcrb->waiting_for_ack_q.p_first) + while (!GKI_queue_is_empty(&p_fcrb->waiting_for_ack_q)) GKI_freebuf (GKI_dequeue (&p_fcrb->waiting_for_ack_q)); - while (p_fcrb->srej_rcv_hold_q.p_first) + while (!GKI_queue_is_empty(&p_fcrb->srej_rcv_hold_q)) GKI_freebuf (GKI_dequeue (&p_fcrb->srej_rcv_hold_q)); - while (p_fcrb->retrans_q.p_first) + while (!GKI_queue_is_empty(&p_fcrb->retrans_q)) GKI_freebuf (GKI_dequeue (&p_fcrb->retrans_q)); btu_stop_quick_timer (&p_fcrb->ack_timer); @@ -253,7 +243,6 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb) UINT16 i; UINT32 throughput_avg, ack_delay_avg, ack_q_count_avg; - dur = GKI_OS_TICKS_TO_MS(dur); BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, "--- L2CAP ERTM Stats for CID: 0x%04x Duration: %08ums", p_ccb->local_cid, dur); BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC, @@ -335,6 +324,7 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb) *******************************************************************************/ BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes, UINT8 pool) { + assert(p_buf != NULL); BT_HDR *p_buf2; /* If using the common pool, should be at least 10% free. */ @@ -386,14 +376,15 @@ BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes, *******************************************************************************/ BOOLEAN l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb) { + assert(p_ccb != NULL); if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { /* Check if remote side flowed us off or the transmit window is full */ if ( (p_ccb->fcrb.remote_busy == TRUE) - || (p_ccb->fcrb.waiting_for_ack_q.count >= p_ccb->peer_cfg.fcr.tx_win_sz) ) + || (GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q) >= p_ccb->peer_cfg.fcr.tx_win_sz) ) { #if (L2CAP_ERTM_STATS == TRUE) - if (p_ccb->xmit_hold_q.count != 0) + if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)) { p_ccb->fcrb.xmit_window_closed++; @@ -420,6 +411,8 @@ BOOLEAN l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb) *******************************************************************************/ static void prepare_I_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, BOOLEAN is_retransmission) { + assert(p_ccb != NULL); + assert(p_buf != NULL); tL2C_FCRB *p_fcrb = &p_ccb->fcrb; UINT8 *p; UINT16 fcs; @@ -519,17 +512,12 @@ static void prepare_I_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, BOOLEAN is_retransm *******************************************************************************/ void l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit) { + assert(p_ccb != NULL); BT_HDR *p_buf; UINT8 *p; UINT16 ctrl_word; UINT16 fcs; -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE - /* Only used for conformance testing */ - if (l2c_bypass_sframe_packet (p_ccb)) - return; -#endif - if ((!p_ccb->in_use) || (p_ccb->chnl_state != CST_OPEN)) return; @@ -577,11 +565,6 @@ void l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit) UINT16_TO_STREAM (p, L2CAP_FCR_OVERHEAD); } -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE - /* Get out if packet was dropped */ - if (l2c_corrupt_the_fcr_packet (p_ccb, p_buf, FALSE, ctrl_word)) - return; -#endif /* Now, the HCI transport header */ p_buf->layer_specific = L2CAP_NON_FLUSHABLE_PKT; l2cu_set_acl_hci_header (p_buf, p_ccb); @@ -637,6 +620,8 @@ void l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit) *******************************************************************************/ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf) { + assert(p_ccb != NULL); + assert(p_buf != NULL); UINT8 *p; UINT16 fcs; UINT16 min_pdu_len; @@ -699,19 +684,10 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf) L2CAP_TRACE_EVENT (" eRTM Rx Nxt_tx_seq %u, Lst_rx_ack %u, Nxt_seq_exp %u, Lst_ack_snt %u, wt_q.cnt %u, tries %u", p_ccb->fcrb.next_tx_seq, p_ccb->fcrb.last_rx_ack, p_ccb->fcrb.next_seq_expected, - p_ccb->fcrb.last_ack_sent, p_ccb->fcrb.waiting_for_ack_q.count, p_ccb->fcrb.num_tries); + p_ccb->fcrb.last_ack_sent, GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q), p_ccb->fcrb.num_tries); #endif /* BT_TRACE_VERBOSE */ -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE - p = ((UINT8 *)(p_buf+1)) + p_buf->offset; - STREAM_TO_UINT16 (ctrl_word, p); - - /* Get out if packet was dropped */ - if (l2c_corrupt_the_fcr_packet (p_ccb, p_buf, TRUE, ctrl_word)) - return; -#endif /* L2CAP_CORRUPT_ERTM_PKTS */ - /* Verify FCS if using */ if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS) { @@ -768,7 +744,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf) if (ctrl_word & L2CAP_FCR_S_FRAME_BIT) ctrl_word &= ~L2CAP_FCR_P_BIT; - if (p_ccb->fcrb.waiting_for_ack_q.count == 0) + if (GKI_queue_is_empty(&p_ccb->fcrb.waiting_for_ack_q)) p_ccb->fcrb.num_tries = 0; l2c_fcr_stop_timer (p_ccb); @@ -797,7 +773,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf) return; /* If we have some buffers held while doing SREJ, and SREJ has cleared, process them now */ - if ( (!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.srej_sent) && (p_ccb->fcrb.srej_rcv_hold_q.count > 0) ) + if ( (!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.srej_sent) && (!GKI_queue_is_empty(&p_ccb->fcrb.srej_rcv_hold_q))) { BUFFER_Q temp_q = p_ccb->fcrb.srej_rcv_hold_q; @@ -845,7 +821,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf) } /* If a window has opened, check if we can send any more packets */ - if ( (p_ccb->fcrb.retrans_q.count || p_ccb->xmit_hold_q.count) + if ( (!GKI_queue_is_empty(&p_ccb->fcrb.retrans_q) || !GKI_queue_is_empty(&p_ccb->xmit_hold_q)) && (p_ccb->fcrb.wait_ack == FALSE) && (l2c_fcr_is_flow_controlled (p_ccb) == FALSE) ) { @@ -864,9 +840,10 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf) *******************************************************************************/ void l2c_fcr_proc_tout (tL2C_CCB *p_ccb) { + assert(p_ccb != NULL); L2CAP_TRACE_DEBUG ("l2c_fcr_proc_tout: CID: 0x%04x num_tries: %u (max: %u) wait_ack: %u ack_q_count: %u", p_ccb->local_cid, p_ccb->fcrb.num_tries, p_ccb->peer_cfg.fcr.max_transmit, - p_ccb->fcrb.wait_ack, p_ccb->fcrb.waiting_for_ack_q.count); + p_ccb->fcrb.wait_ack, GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q)); #if (L2CAP_ERTM_STATS == TRUE) p_ccb->fcrb.retrans_touts++; @@ -900,6 +877,7 @@ void l2c_fcr_proc_tout (tL2C_CCB *p_ccb) *******************************************************************************/ void l2c_fcr_proc_ack_tout (tL2C_CCB *p_ccb) { + assert(p_ccb != NULL); L2CAP_TRACE_DEBUG ("l2c_fcr_proc_ack_tout: CID: 0x%04x State: %u Wack:%u Rq:%d Acked:%d", p_ccb->local_cid, p_ccb->chnl_state, p_ccb->fcrb.wait_ack, p_ccb->fcrb.next_seq_expected, p_ccb->fcrb.last_ack_sent); @@ -928,6 +906,7 @@ void l2c_fcr_proc_ack_tout (tL2C_CCB *p_ccb) *******************************************************************************/ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word) { + assert(p_ccb != NULL); tL2C_FCRB *p_fcrb = &p_ccb->fcrb; UINT8 req_seq, num_bufs_acked, xx; UINT16 ls; @@ -939,7 +918,7 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word) && ((ctrl_word & L2CAP_FCR_P_BIT) == 0) ) { /* If anything still waiting for ack, restart the timer if it was stopped */ - if (p_fcrb->waiting_for_ack_q.count) + if (!GKI_queue_is_empty(&p_fcrb->waiting_for_ack_q)) l2c_fcr_start_timer (p_ccb); return (TRUE); @@ -951,20 +930,16 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word) num_bufs_acked = (req_seq - p_fcrb->last_rx_ack) & L2CAP_FCR_SEQ_MODULO; /* Verify the request sequence is in range before proceeding */ - if (num_bufs_acked > p_fcrb->waiting_for_ack_q.count) + if (num_bufs_acked > GKI_queue_length(&p_fcrb->waiting_for_ack_q)) { /* The channel is closed if ReqSeq is not in range */ L2CAP_TRACE_WARNING ("L2CAP eRTM Frame BAD Req_Seq - ctrl_word: 0x%04x req_seq 0x%02x last_rx_ack: 0x%02x QCount: %u", - ctrl_word, req_seq, p_fcrb->last_rx_ack, p_fcrb->waiting_for_ack_q.count); + ctrl_word, req_seq, p_fcrb->last_rx_ack, GKI_queue_length(&p_fcrb->waiting_for_ack_q)); l2cu_disconnect_chnl (p_ccb); return (FALSE); } -/* - L2CAP_TRACE_DEBUG ("L2CAP process_reqseq 0x%02x last_rx_ack: 0x%02x QCount: %u", - req_seq, p_fcrb->last_rx_ack, p_fcrb->waiting_for_ack_q.count); -*/ p_fcrb->last_rx_ack = req_seq; /* Now we can release all acknowledged frames, and restart the retransmission timer if needed */ @@ -979,7 +954,7 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word) for (xx = 0; xx < num_bufs_acked; xx++) { - ls = ((BT_HDR *)(p_fcrb->waiting_for_ack_q.p_first))->layer_specific & L2CAP_FCR_SAR_BITS; + ls = ((BT_HDR *)(GKI_getfirst(&p_fcrb->waiting_for_ack_q)))->layer_specific & L2CAP_FCR_SAR_BITS; if ( (ls == L2CAP_FCR_UNSEG_SDU) || (ls == L2CAP_FCR_END_SDU) ) full_sdus_xmitted++; @@ -995,7 +970,7 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word) if ( (p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_TxComplete_Cb) && (full_sdus_xmitted) ) { /* Special case for eRTM, if all packets sent, send 0xFFFF */ - if ( (p_fcrb->waiting_for_ack_q.count == 0) && (p_ccb->xmit_hold_q.count == 0) ) + if (GKI_queue_is_empty(&p_fcrb->waiting_for_ack_q) && (GKI_queue_is_empty(&p_ccb->xmit_hold_q))) full_sdus_xmitted = 0xFFFF; (*p_ccb->p_rcb->api.pL2CA_TxComplete_Cb)(p_ccb->local_cid, full_sdus_xmitted); @@ -1003,7 +978,7 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word) } /* If anything still waiting for ack, restart the timer if it was stopped */ - if (p_fcrb->waiting_for_ack_q.count) + if (!GKI_queue_is_empty(&p_fcrb->waiting_for_ack_q)) l2c_fcr_start_timer (p_ccb); return (TRUE); @@ -1021,6 +996,9 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word) *******************************************************************************/ static void process_s_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word) { + assert(p_ccb != NULL); + assert(p_buf != NULL); + tL2C_FCRB *p_fcrb = &p_ccb->fcrb; UINT16 s_frame_type = (ctrl_word & L2CAP_FCR_SUP_BITS) >> L2CAP_FCR_SUP_SHIFT; BOOLEAN remote_was_busy; @@ -1104,6 +1082,9 @@ static void process_s_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word) *******************************************************************************/ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, BOOLEAN delay_ack) { + assert(p_ccb != NULL); + assert(p_buf != NULL); + tL2C_FCRB *p_fcrb = &p_ccb->fcrb; UINT8 tx_seq, num_lost, num_to_ack, next_srej; @@ -1165,9 +1146,9 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B if (p_fcrb->srej_sent) { /* If SREJ sent, save the frame for later processing as long as it is in sequence */ - next_srej = (((BT_HDR *)p_fcrb->srej_rcv_hold_q.p_last)->layer_specific + 1) & L2CAP_FCR_SEQ_MODULO; + next_srej = (((BT_HDR *)GKI_getlast(&p_fcrb->srej_rcv_hold_q))->layer_specific + 1) & L2CAP_FCR_SEQ_MODULO; - if ( (tx_seq == next_srej) && (p_fcrb->srej_rcv_hold_q.count < p_ccb->our_cfg.fcr.tx_win_sz) ) + if ( (tx_seq == next_srej) && (GKI_queue_length(&p_fcrb->srej_rcv_hold_q) < p_ccb->our_cfg.fcr.tx_win_sz) ) { /* If user gave us a pool for held rx buffers, use that */ if (p_ccb->ertm_info.fcr_rx_pool_id != HCI_ACL_POOL_ID) @@ -1197,7 +1178,7 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B else { L2CAP_TRACE_WARNING ("process_i_frame() CID: 0x%04x frame dropped in Srej Sent next_srej:%u hold_q.count:%u win_sz:%u", - p_ccb->local_cid, next_srej, p_fcrb->srej_rcv_hold_q.count, p_ccb->our_cfg.fcr.tx_win_sz); + p_ccb->local_cid, next_srej, GKI_queue_length(&p_fcrb->srej_rcv_hold_q), p_ccb->our_cfg.fcr.tx_win_sz); p_fcrb->rej_after_srej = TRUE; GKI_freebuf (p_buf); @@ -1225,10 +1206,10 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B } else { - if (p_fcrb->srej_rcv_hold_q.count != 0) + if (!GKI_queue_is_empty(&p_fcrb->srej_rcv_hold_q)) { L2CAP_TRACE_ERROR ("process_i_frame() CID: 0x%04x sending SREJ tx_seq:%d hold_q.count:%u", - p_ccb->local_cid, tx_seq, p_fcrb->srej_rcv_hold_q.count); + p_ccb->local_cid, tx_seq, GKI_queue_length(&p_fcrb->srej_rcv_hold_q)); } p_buf->layer_specific = tx_seq; GKI_enqueue (&p_fcrb->srej_rcv_hold_q, p_buf); @@ -1275,8 +1256,8 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B (L2CAP_FCR_ACK_TOUT*QUICK_TIMER_TICKS_PER_SEC)/1000); } } - else if ( ((p_ccb->xmit_hold_q.count == 0) || (l2c_fcr_is_flow_controlled (p_ccb))) - && (p_ccb->fcrb.srej_rcv_hold_q.count == 0) ) + else if ( ((GKI_queue_is_empty(&p_ccb->xmit_hold_q)) || (l2c_fcr_is_flow_controlled (p_ccb))) + && (GKI_queue_is_empty(&p_ccb->fcrb.srej_rcv_hold_q))) { if (p_fcrb->local_busy) l2c_fcr_send_S_frame (p_ccb, L2CAP_FCR_SUP_RNR, 0); @@ -1298,6 +1279,9 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B *******************************************************************************/ static void process_stream_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf) { + assert(p_ccb != NULL); + assert(p_buf != NULL); + UINT16 ctrl_word; UINT16 fcs; UINT8 *p; @@ -1387,6 +1371,9 @@ static void process_stream_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf) *******************************************************************************/ static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word) { + assert(p_ccb != NULL); + assert(p_buf != NULL); + tL2C_FCRB *p_fcrb = &p_ccb->fcrb; UINT16 sar_type = ctrl_word & L2CAP_FCR_SEG_BITS; BOOLEAN packet_ok = TRUE; @@ -1512,18 +1499,20 @@ static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_wo *******************************************************************************/ static BOOLEAN retransmit_i_frames (tL2C_CCB *p_ccb, UINT8 tx_seq) { + assert(p_ccb != NULL); + BT_HDR *p_buf, *p_buf2; UINT8 *p; UINT8 buf_seq; UINT16 ctrl_word; - if ( (p_ccb->fcrb.waiting_for_ack_q.p_first) + if ( (GKI_getfirst(&p_ccb->fcrb.waiting_for_ack_q)) && (p_ccb->peer_cfg.fcr.max_transmit != 0) && (p_ccb->fcrb.num_tries >= p_ccb->peer_cfg.fcr.max_transmit) ) { L2CAP_TRACE_EVENT ("Max Tries Exceeded: (last_acq: %d CID: 0x%04x num_tries: %u (max: %u) ack_q_count: %u", p_ccb->fcrb.last_rx_ack, p_ccb->local_cid, p_ccb->fcrb.num_tries, p_ccb->peer_cfg.fcr.max_transmit, - p_ccb->fcrb.waiting_for_ack_q.count); + GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q)); l2cu_disconnect_chnl (p_ccb); return (FALSE); @@ -1534,7 +1523,7 @@ static BOOLEAN retransmit_i_frames (tL2C_CCB *p_ccb, UINT8 tx_seq) { /* If sending only one, the sequence number tells us which one. Look for it. */ - for (p_buf = (BT_HDR *)p_ccb->fcrb.waiting_for_ack_q.p_first; p_buf; p_buf = (BT_HDR *)GKI_getnext (p_buf)) + for (p_buf = (BT_HDR *)GKI_getfirst(&p_ccb->fcrb.waiting_for_ack_q); p_buf; p_buf = (BT_HDR *)GKI_getnext (p_buf)) { /* Get the old control word */ p = ((UINT8 *) (p_buf+1)) + p_buf->offset + L2CAP_PKT_OVERHEAD; @@ -1551,36 +1540,31 @@ static BOOLEAN retransmit_i_frames (tL2C_CCB *p_ccb, UINT8 tx_seq) if (!p_buf) { - L2CAP_TRACE_ERROR ("retransmit_i_frames() UNKNOWN seq: %u q_count: %u", tx_seq, p_ccb->fcrb.waiting_for_ack_q.count); + L2CAP_TRACE_ERROR ("retransmit_i_frames() UNKNOWN seq: %u q_count: %u", tx_seq, GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q)); return (TRUE); } } else { - /* Retransmitting everything. Flush buffers we already put in the link xmit queue. - */ - p_buf = (BT_HDR *)p_ccb->p_lcb->link_xmit_data_q.p_first; + // Iterate though list and flush the amount requested from + // the transmit data queue that satisfy the layer and event conditions. + for (const list_node_t *node = list_begin(p_ccb->p_lcb->link_xmit_data_q); + node != list_end(p_ccb->p_lcb->link_xmit_data_q);) { + BT_HDR *p_buf = (BT_HDR *)list_node(node); + node = list_next(node); - while (p_buf != NULL) - { /* Do not flush other CIDs or partial segments */ - if ( (p_buf->layer_specific == 0) && (p_buf->event == p_ccb->local_cid) ) - { - p_buf2 = p_buf; - p_buf = (BT_HDR *)GKI_getnext (p_buf); - - GKI_remove_from_queue (&p_ccb->p_lcb->link_xmit_data_q, p_buf2); - GKI_freebuf (p_buf2); - } - else - p_buf = (BT_HDR *)GKI_getnext (p_buf); + if ((p_buf->layer_specific == 0) && (p_buf->event == p_ccb->local_cid)) { + list_remove(p_ccb->p_lcb->link_xmit_data_q, p_buf); + GKI_freebuf(p_buf); + } } /* Also flush our retransmission queue */ - while (p_ccb->fcrb.retrans_q.p_first) + while (!GKI_queue_is_empty(&p_ccb->fcrb.retrans_q)) GKI_freebuf (GKI_dequeue (&p_ccb->fcrb.retrans_q)); - p_buf = (BT_HDR *)p_ccb->fcrb.waiting_for_ack_q.p_first; + p_buf = (BT_HDR *)GKI_getfirst(&p_ccb->fcrb.waiting_for_ack_q); } while (p_buf != NULL) @@ -1602,7 +1586,7 @@ static BOOLEAN retransmit_i_frames (tL2C_CCB *p_ccb, UINT8 tx_seq) l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL); - if (p_ccb->fcrb.waiting_for_ack_q.count) + if (GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q)) { p_ccb->fcrb.num_tries++; l2c_fcr_start_timer (p_ccb); @@ -1623,6 +1607,8 @@ static BOOLEAN retransmit_i_frames (tL2C_CCB *p_ccb, UINT8 tx_seq) *******************************************************************************/ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length) { + assert(p_ccb != NULL); + BOOLEAN first_seg = FALSE, /* The segment is the first part of data */ mid_seg = FALSE, /* The segment is the middle part of data */ last_seg = FALSE; /* The segment is the last part of data */ @@ -1633,7 +1619,7 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length /* If there is anything in the retransmit queue, that goes first */ - if (p_ccb->fcrb.retrans_q.p_first) + if (GKI_getfirst(&p_ccb->fcrb.retrans_q)) { p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->fcrb.retrans_q); @@ -1642,16 +1628,6 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length p_buf->event = p_ccb->local_cid; -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE - /* Use sdu_len to hold the control word */ - p = ((UINT8 *) (p_buf+1)) + p_buf->offset + L2CAP_PKT_OVERHEAD; - STREAM_TO_UINT16 (sdu_len, p); - - /* Get out if packet was dropped; just pretend it went out */ - if (l2c_corrupt_the_fcr_packet (p_ccb, p_buf, FALSE, sdu_len)) - return (NULL); -#endif /* L2CAP_CORRUPT_ERTM_PKTS */ - #if (L2CAP_ERTM_STATS == TRUE) p_ccb->fcrb.pkts_retransmitted++; p_ccb->fcrb.ertm_pkt_counts[0]++; @@ -1668,7 +1644,7 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length max_pdu = max_packet_length - L2CAP_MAX_HEADER_FCS; } - p_buf = (BT_HDR *)p_ccb->xmit_hold_q.p_first; + p_buf = (BT_HDR *)GKI_getfirst(&p_ccb->xmit_hold_q); /* If there is more data than the MPS, it requires segmentation */ if (p_buf->len > max_pdu) @@ -1786,17 +1762,6 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length GKI_enqueue (&p_ccb->fcrb.waiting_for_ack_q, p_wack); } -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE - { - UINT16 ctrl_word; - p = ((UINT8 *) (p_xmit+1)) + p_xmit->offset + L2CAP_PKT_OVERHEAD; - STREAM_TO_UINT16 (ctrl_word, p); - - /* Get out if packet was dropped; pretend it was sent */ - if (l2c_corrupt_the_fcr_packet (p_ccb, p_xmit, FALSE, ctrl_word)) - return (NULL); - } -#endif #if (L2CAP_ERTM_STATS == TRUE) p_ccb->fcrb.ertm_pkt_counts[0]++; p_ccb->fcrb.ertm_byte_counts[0] += (p_xmit->len - 8); @@ -1830,6 +1795,8 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length *******************************************************************************/ UINT8 l2c_fcr_chk_chan_modes (tL2C_CCB *p_ccb) { + assert(p_ccb != NULL); + /* Remove nonbasic options that the peer does not support */ if (!(p_ccb->p_lcb->peer_ext_fea & L2CAP_EXTFEA_ENH_RETRANS)) p_ccb->ertm_info.allowed_modes &= ~L2CAP_FCR_CHAN_OPT_ERTM; @@ -1858,6 +1825,9 @@ UINT8 l2c_fcr_chk_chan_modes (tL2C_CCB *p_ccb) *******************************************************************************/ BOOLEAN l2c_fcr_adj_our_req_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) { + assert(p_ccb != NULL); + assert(p_cfg != NULL); + tL2CAP_FCR_OPTS *p_fcr = &p_cfg->fcr; if (p_fcr->mode != p_ccb->ertm_info.preferred_mode) @@ -1974,6 +1944,8 @@ BOOLEAN l2c_fcr_adj_our_req_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) *******************************************************************************/ void l2c_fcr_adj_monitor_retran_timeout (tL2C_CCB *p_ccb) { + assert(p_ccb != NULL); + /* adjust our monitor/retran timeout */ if (p_ccb->out_cfg_fcr_present) { @@ -2011,6 +1983,9 @@ void l2c_fcr_adj_monitor_retran_timeout (tL2C_CCB *p_ccb) *******************************************************************************/ void l2c_fcr_adj_our_rsp_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) { + assert(p_ccb != NULL); + assert(p_cfg != NULL); + /* adjust our monitor/retran timeout */ l2c_fcr_adj_monitor_retran_timeout(p_ccb); @@ -2052,6 +2027,9 @@ void l2c_fcr_adj_our_rsp_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) *******************************************************************************/ BOOLEAN l2c_fcr_renegotiate_chan(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) { + assert(p_ccb != NULL); + assert(p_cfg != NULL); + UINT8 peer_mode = p_ccb->our_cfg.fcr.mode; BOOLEAN can_renegotiate; @@ -2156,6 +2134,9 @@ BOOLEAN l2c_fcr_renegotiate_chan(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) *******************************************************************************/ UINT8 l2c_fcr_process_peer_cfg_req(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) { + assert(p_ccb != NULL); + assert(p_cfg != NULL); + UINT16 max_retrans_size; UINT8 fcr_ok = L2CAP_PEER_CFG_OK; @@ -2271,341 +2252,6 @@ UINT8 l2c_fcr_process_peer_cfg_req(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg) return (fcr_ok); } - -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE -/******************************************************************************* -** Functions used for testing ERTM mode -*/ -/* If FALSE, will also corrupt cid, length, control word, etc. */ -#ifndef L2CAP_CORR_FCS_ONLY -#define L2CAP_CORR_FCS_ONLY TRUE -#endif - -#define L2C_DISP_FRAME_SIZE 16 -/******************************************************************************* -** -** Function l2c_corrupt_the_fcr_packet -** -** Description This function is used for testing purposes only. -** It systematically or randomly corrupts packets used with -** ERTM channels. -** -** Returns BOOLEAN TRUE if packet was dropped, -** FALSE if fcs corrupted or no corruption -** -*******************************************************************************/ -static BOOLEAN l2c_corrupt_the_fcr_packet (tL2C_CCB *p_ccb, BT_HDR *p_buf, - BOOLEAN is_rx, UINT16 ctrl_word) -{ - tL2C_FCR_TEST_CFG *p_cfg; - UINT32 tc; - UINT8 *p; - UINT32 xx; - char buf[L2C_DISP_FRAME_SIZE]; - - if (!p_ccb || !p_ccb->fcrb.test_cb.cfg.in_use) - return FALSE; - - /* Prepare bad FCS */ - p = ((UINT8 *) (p_buf + 1)) + p_buf->offset; - tc = GKI_get_os_tick_count(); - tc ^= p[p_buf->len - 1]; - xx = tc % 47; - - p_cfg = &p_ccb->fcrb.test_cb.cfg; -#if 0 - L2CAP_TRACE_DEBUG ("testcfg: type: %d, freq: %d (NRM-0, RDM-1), is_rx: %d, count: %d", - p_cfg->type, p_cfg->freq, p_cfg->is_rx, p_cfg->count); -#endif - /* If not time to corrupt get out */ - if (p_cfg->freq == L2CAP_FCR_FREQ_RANDOM) - { - if (xx != 0) - return FALSE; - } - else /* check test criteria before corrupting */ - { - if ( (p_cfg->count == 0) - || (p_cfg->is_rx != is_rx) - || ((UINT8)(ctrl_word & L2CAP_FCR_S_FRAME_BIT) != p_cfg->type) ) - { - return FALSE; - } - - /* Turn off if done */ - if (--(p_cfg->count) == 0) - { - p_ccb->fcrb.test_cb.cfg.in_use = FALSE; - } - } - -#if L2CAP_CORR_FCS_ONLY == TRUE - /* Corrupt the FCS check */ - p[p_buf->len - 1] = p[p_buf->len - 2] = 0; -#else - /* If made it this far packet needs to be corrupted */ - xx = tc % p_buf->len; - - /* Make sure the value was changed */ - if (p[xx + 1] == 0) - p[xx + 1] = 0x5A; - - p[xx] = p[xx] ^ p[xx + 1]; - -#if 1 /* Enable if not wishing to corrupting frame type */ - { - UINT8 *p_temp = ((UINT8 *) (p_buf + 1)) + p_buf->offset; - p_temp += L2CAP_PKT_OVERHEAD; - if ((UINT16)((*p_temp) & 0x01) != (ctrl_word & 0x0001)) - { - (*p_temp) |= (UINT8)(ctrl_word & 0x0001); - } - } -#endif -#endif - - if (is_rx) - { - if (ctrl_word & L2CAP_FCR_S_FRAME_BIT) - BCM_STRCPY_S(buf, L2C_DISP_FRAME_SIZE, "Rx S-Frame"); - else - BCM_STRCPY_S(buf, L2C_DISP_FRAME_SIZE, "Rx I-Frame"); - } - else - { - if (ctrl_word & L2CAP_FCR_S_FRAME_BIT) - BCM_STRCPY_S(buf, L2C_DISP_FRAME_SIZE, "Tx S-Frame"); - else - BCM_STRCPY_S(buf, L2C_DISP_FRAME_SIZE, "Tx I-Frame"); - } - - /* Lastly, just drop packet if FCS is not being used or if Tx */ - if (!is_rx || p_ccb->bypass_fcs == L2CAP_BYPASS_FCS) - { - L2CAP_TRACE_ERROR ("-=-=-=-=-=-=-=- Dropping %s packet (0x%04x) tc: %u Buf Len: %u xx: %u count: %d", - buf, (UINT32)p_buf, tc, p_buf->len, xx, p_cfg->count); - GKI_freebuf(p_buf); - return TRUE; - } - else - { - L2CAP_TRACE_ERROR ("-=-=-=-=-=-=-=- Corrupting %s packet (0x%04x) tc: %u Buf Len: %u xx: %u count: %d", - buf, (UINT32)p_buf, tc, p_buf->len, xx, p_cfg->count); - } - - return FALSE; -} - - -/******************************************************************************* -** -** Function L2CA_SetupErtmTest -** -** Description This function is used for testing purposes only. -** It corrupts or drops one or more packets used with ERTM channels. -** -** Parameters -** cid - channel ID (0 uses RFCOMM PSM's CID) -** -** type - type of test to run (L2CAP_FCR_TTYPE_CORR_IFRAMES -** L2CAP_FCR_TTYPE_CORR_SFRAME -** L2CAP_FCR_TTYPE_STOP_TEST -** L2CAP_FCR_TTYPE_GET_CID - returns rfcomm cid only) -** -** is_rx - TRUE to corrupt Rx packet, FALSE for Tx packet) -** -** freq - L2CAP_FCR_FREQ_RANDOM (turns on random corruptions/drops) -** L2CAP_FCR_FREQ_NORMAL (turns on test with "count" corruptions/drops) -** -** count - number of packets in a row to drop or corrupt -** -** Returns CID of channel running test -** -*******************************************************************************/ -UINT16 L2CA_SetupErtmTest (UINT16 cid, UINT8 type, BOOLEAN is_rx, UINT8 freq, UINT16 count) -{ - tL2C_CCB *p_ccb = NULL; - tL2C_CCB *p_temp_ccb; - tL2C_FCR_TEST_CB *p_test_cb; - UINT16 xx; - - /* If '0' tests run on top of RFCOMM CID if active */ - if (cid == 0) - { - p_temp_ccb = l2cb.ccb_pool; - for (xx = 0; xx < MAX_L2CAP_CHANNELS; xx++, p_temp_ccb++) - { - /* Fixed channels don't have p_rcb's */ - if (p_temp_ccb->in_use && p_temp_ccb->p_rcb && p_temp_ccb->p_rcb->psm == BT_PSM_RFCOMM) - { - p_ccb = p_temp_ccb; - cid = L2CAP_BASE_APPL_CID + xx; - break; - } - } - } - else - p_ccb = l2cu_find_ccb_by_cid (NULL, cid); - - if (!p_ccb || type == L2CAP_FCR_TTYPE_GET_CID) - { - if (type == L2CAP_FCR_TTYPE_GET_CID) - { - L2CAP_TRACE_API ("L2CA_SetupErtmTest (GET_CID): cid = 0x%04x", cid); - } - return (cid); - } - - p_test_cb = &p_ccb->fcrb.test_cb; - - /* Turn off the current test */ - if (type == L2CAP_FCR_TTYPE_STOP_TEST) - { - if (p_test_cb->cfg.in_use) - { - L2CAP_TRACE_ERROR ("L2CA_SetupErtmTest (OFF): cid 0x%04x", cid); - } - p_test_cb->cfg.in_use = FALSE; - p_test_cb->cfg.count = 0; - } - - /* Process the new request */ - else if (!p_test_cb->cfg.in_use) - { - /* count must be positive unless random is used */ - if (!count && freq != L2CAP_FCR_FREQ_RANDOM) - { - L2CAP_TRACE_ERROR ("L2CA_SetupErtmTest (FAIL): Count = 0, freq = %d", freq); - return (cid); - } - - L2CAP_TRACE_ERROR ("L2CA_SetupErtmTest (START): cid 0x%04x, type %d, is_rx %d, freq %d, count %d", - cid, type, is_rx, freq, count); - - p_test_cb->cfg.in_use = TRUE; - p_test_cb->cfg.freq = freq; - p_test_cb->cfg.type = type; - p_test_cb->cfg.is_rx = is_rx; - p_test_cb->cfg.count = count; - } - else /* Test already in progress so ignore */ - { - L2CAP_TRACE_ERROR ("L2CA_SetupErtmTest (ignoring): cid 0x%04x, type %d, is_rx %d, freq %d, count %d", - cid, type, is_rx, freq, count); - } - - return (cid); -} - - -/******************************************************************************* -** The following routines are only used in conjunction with Conformance testing -********************************************************************************/ - -/******************************************************************************* -** -** Function L2CA_SendPolledSFrame -** -** Description This function is used for testing purposes only. -** It Sends a Polled RR or RNR to the peer -** -** Parameters -** cid - channel ID -** -** sup_type - (L2CAP_FCR_SUP_RR or L2CAP_FCR_SUP_RNR) -** -** Returns void -** -*******************************************************************************/ -void L2CA_SendPolledSFrame (UINT16 cid, UINT16 sup_type) -{ - tL2C_CCB *p_ccb = l2cu_find_ccb_by_cid (NULL, cid); - - if (p_ccb && (sup_type == L2CAP_FCR_SUP_RR || sup_type == L2CAP_FCR_SUP_RNR)) - { - l2c_fcr_send_S_frame (p_ccb, sup_type, L2CAP_FCR_P_BIT); - } - else - { - L2CAP_TRACE_ERROR ("L2CA_SendPolledSFrame(ERROR): sup_type %u, p_ccb 0x%07x", - sup_type, (UINT32)p_ccb); - } -} - -/******************************************************************************* -** -** Function l2c_bypass_sframe_packet -** -** Description This function is used for testing purposes only. -** It returns TRUE if S-Frame should be bypassed. -** -** Returns void -** -*******************************************************************************/ -static BOOLEAN l2c_bypass_sframe_packet (tL2C_CCB *p_ccb) -{ - if (p_ccb && p_ccb->fcrb.test_cb.cfm.in_use) - { - if (p_ccb->fcrb.test_cb.cfm.skip_sframe_count > 0) - { - L2CAP_TRACE_ERROR ("l2c_bypass_sframe_packet (count %d)", - p_ccb->fcrb.test_cb.cfm.skip_sframe_count); - - if (--p_ccb->fcrb.test_cb.cfm.skip_sframe_count == 0) - p_ccb->fcrb.test_cb.cfm.in_use = FALSE; - - /* Bypass sending S-Frame */ - return TRUE; - } - else - p_ccb->fcrb.test_cb.cfm.in_use = FALSE; - } - - return FALSE; -} - -/******************************************************************************* -** -** Function L2CA_BypassSFrame -** -** Description This function is used for testing purposes only. -** It skips sending 'count' S-Frames. -** -** Parameters -** cid - channel ID -** -** count - Number of S-Frames to skip sending -** -** Returns void -** -*******************************************************************************/ -void L2CA_BypassSFrame (UINT16 cid, UINT8 count) -{ - tL2C_CCB *p_ccb = l2cu_find_ccb_by_cid (NULL, cid); - tL2C_FCR_CFM_TEST_CB *p_test_cb; - - if (!p_ccb) - { - L2CAP_TRACE_WARNING ("L2CA_BypassSFrame(ERROR): no p_ccb (0x%07x)", (UINT32)p_ccb); - return; - } - - p_test_cb = &p_ccb->fcrb.test_cb.cfm; - - /* Initiate test if not active */ - if (!p_test_cb->in_use) - { - p_test_cb->in_use = TRUE; - p_test_cb->skip_sframe_count = count; - } - else - { - L2CAP_TRACE_WARNING ("L2CA_BypassSFrame(ERROR): already in use (ignoring...)"); - } -} - -#endif /* L2CAP_CORRUPT_ERTM_PKTS == TRUE */ - #if (L2CAP_ERTM_STATS == TRUE) /******************************************************************************* ** @@ -2708,6 +2354,3 @@ static void l2c_fcr_collect_ack_delay (tL2C_CCB *p_ccb, UINT8 num_bufs_acked) } } #endif - - - diff --git a/stack/l2cap/l2c_int.h b/stack/l2cap/l2c_int.h index b1d0c4668..9cf79a93d 100644 --- a/stack/l2cap/l2c_int.h +++ b/stack/l2cap/l2c_int.h @@ -24,10 +24,13 @@ #ifndef L2C_INT_H #define L2C_INT_H +#include <stdbool.h> + +#include "btm_api.h" +#include "gki.h" #include "l2c_api.h" #include "l2cdefs.h" -#include "gki.h" -#include "btm_api.h" +#include "list.h" #define L2CAP_MIN_MTU 48 /* Minimum acceptable MTU is 48 bytes */ @@ -152,34 +155,6 @@ typedef enum #define L2CAP_MAX_FCR_CFG_TRIES 2 /* Config attempts before disconnecting */ -/* Only compiled in when in test mode. Production devices must not include -*/ -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE - -/* These are used for conformance and corruption testing only */ -typedef struct -{ - BOOLEAN in_use; /* TRUE if test in progress */ - UINT8 type; /* Type of test to run or turns off random test */ - UINT8 freq; /* One-shot or random */ - BOOLEAN is_rx; /* TRUE if incoming packets */ - UINT16 count; /* How many I-frames to drop in a row; used only with one-shot tests */ -} tL2C_FCR_TEST_CFG; - -typedef struct -{ - BOOLEAN in_use; /* TRUE if test in progress */ - UINT8 skip_sframe_count; /* Number of S-Frames to skip sending */ -} tL2C_FCR_CFM_TEST_CB; - -typedef struct -{ - tL2C_FCR_TEST_CFG cfg; /* Current corruption test configuration */ - tL2C_FCR_CFM_TEST_CB cfm; /* Conformance test structure */ -} tL2C_FCR_TEST_CB; - -#endif /* L2CAP_CORRUPT_ERTM_PKTS == TRUE */ - typedef struct { UINT8 next_tx_seq; /* Next sequence number to be Tx'ed */ @@ -234,11 +209,6 @@ typedef struct UINT32 ack_q_count_min[L2CAP_ERTM_STATS_NUM_AVG]; UINT32 ack_q_count_max[L2CAP_ERTM_STATS_NUM_AVG]; #endif - -#if L2CAP_CORRUPT_ERTM_PKTS == TRUE - tL2C_FCR_TEST_CB test_cb; /* Used for SVT and UPF testing */ -#endif - } tL2C_FCRB; @@ -293,6 +263,7 @@ typedef struct t_l2c_ccb TIMER_LIST_ENT timer_entry; /* CCB Timer List Entry */ tL2C_RCB *p_rcb; /* Registration CB for this Channel */ + bool should_free_rcb; /* True if RCB was allocated on the heap */ #define IB_CFG_DONE 0x01 #define OB_CFG_DONE 0x02 @@ -312,7 +283,6 @@ typedef struct t_l2c_ccb tL2CAP_CFG_INFO peer_cfg; /* Peer's saved configuration options */ BUFFER_Q xmit_hold_q; /* Transmit data hold queue */ - BOOLEAN cong_sent; /* Set when congested status sent */ UINT16 buff_quota; /* Buffer quota before sending congestion */ @@ -409,7 +379,7 @@ typedef struct t_l2c_linkcb BOOLEAN w4_info_rsp; /* TRUE when info request is active */ UINT8 info_rx_bits; /* set 1 if received info type */ UINT32 peer_ext_fea; /* Peer's extended features mask */ - BUFFER_Q link_xmit_data_q; /* Transmit data buffer queue */ + list_t *link_xmit_data_q; /* Link transmit data buffer queue */ UINT8 peer_chnl_mask[L2CAP_FIXED_CHNL_ARRAY_SIZE]; #if (L2CAP_UCD_INCLUDED == TRUE) @@ -418,11 +388,6 @@ typedef struct t_l2c_linkcb BUFFER_Q ucd_in_sec_pending_q; /* Security pending incoming UCD packet */ #endif -#if (L2CAP_HOST_FLOW_CTRL == TRUE) - UINT16 link_pkts_unacked; /* Packets received but not acked */ - UINT16 link_ack_thresh; /* Threshold at which to ack pkts */ -#endif - BT_HDR *p_hcit_rcv_acl; /* Current HCIT ACL buf being rcvd */ UINT16 idle_timeout_sv; /* Save current Idle timeout */ UINT8 acl_priority; /* L2C_PRIORITY_NORMAL or L2C_PRIORITY_HIGH */ @@ -484,7 +449,7 @@ typedef struct UINT16 num_lm_acl_bufs; /* # of ACL buffers on controller */ UINT16 idle_timeout; /* Idle timeout */ - BUFFER_Q rcv_hold_q; /* Recv pending queue */ + list_t *rcv_pending_q; /* Recv pending queue */ TIMER_LIST_ENT rcv_hold_tle; /* Timer list entry for rcv hold */ tL2C_LCB *p_cur_hcit_lcb; /* Current HCI Transport buffer */ @@ -565,9 +530,9 @@ extern "C" { ************************************ */ #if (!defined L2C_DYNAMIC_MEMORY) || (L2C_DYNAMIC_MEMORY == FALSE) -L2C_API extern tL2C_CB l2cb; +extern tL2C_CB l2cb; #else -L2C_API extern tL2C_CB *l2c_cb_ptr; +extern tL2C_CB *l2c_cb_ptr; #define l2cb (*l2c_cb_ptr) #endif @@ -575,7 +540,9 @@ L2C_API extern tL2C_CB *l2c_cb_ptr; /* Functions provided by l2c_main.c ************************************ */ -extern void l2c_init (void); +void l2c_init(void); +void l2c_free(void); + extern void l2c_process_timeout (TIMER_LIST_ENT *p_tle); extern UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flag); extern void l2c_rcv_acl_data (BT_HDR *p_msg); @@ -715,16 +682,16 @@ extern void l2c_link_adjust_chnl_allocation (void); extern void l2c_link_processs_ble_num_bufs (UINT16 num_lm_acl_bufs); #endif -#if ((BTM_PWR_MGR_INCLUDED == TRUE) && L2CAP_WAKE_PARKED_LINK == TRUE) +#if L2CAP_WAKE_PARKED_LINK == TRUE extern BOOLEAN l2c_link_check_power_mode ( tL2C_LCB *p_lcb ); #define L2C_LINK_CHECK_POWER_MODE(x) l2c_link_check_power_mode ((x)) -#else +#else // L2CAP_WAKE_PARKED_LINK #define L2C_LINK_CHECK_POWER_MODE(x) (FALSE) -#endif +#endif // L2CAP_WAKE_PARKED_LINK #if L2CAP_CONFORMANCE_TESTING == TRUE /* Used only for conformance testing */ -L2C_API extern void l2cu_set_info_rsp_mask (UINT32 mask); +extern void l2cu_set_info_rsp_mask (UINT32 mask); #endif /* Functions provided by l2c_csm.c @@ -732,10 +699,7 @@ L2C_API extern void l2cu_set_info_rsp_mask (UINT32 mask); */ extern void l2c_csm_execute (tL2C_CCB *p_ccb, UINT16 event, void *p_data); -L2C_API extern BT_HDR *l2cap_link_chk_pkt_start(BT_HDR *); /* Called at start of rcv to check L2CAP segmentation */ -L2C_API extern BOOLEAN l2cap_link_chk_pkt_end (void); /* Called at end of rcv to check L2CAP segmentation */ - -L2C_API extern void l2c_enqueue_peer_data (tL2C_CCB *p_ccb, BT_HDR *p_buf); +extern void l2c_enqueue_peer_data (tL2C_CCB *p_ccb, BT_HDR *p_buf); /* Functions provided by l2c_fcr.c diff --git a/stack/l2cap/l2c_link.c b/stack/l2cap/l2c_link.c index 5ee5faaa0..98d6803d9 100644 --- a/stack/l2cap/l2c_link.c +++ b/stack/l2cap/l2c_link.c @@ -28,6 +28,8 @@ #include <string.h> #include <stdio.h> +#include "device/include/controller.h" +#include "btcore/include/counter.h" #include "gki.h" #include "bt_types.h" #include "bt_utils.h" @@ -41,12 +43,6 @@ static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf); -#define L2C_LINK_SEND_ACL_DATA(x) HCI_ACL_DATA_TO_LOWER((x)) - -#if (BLE_INCLUDED == TRUE) -#define L2C_LINK_SEND_BLE_ACL_DATA(x) HCI_BLE_ACL_DATA_TO_LOWER((x)) -#endif - /******************************************************************************* ** ** Function l2c_link_hci_conn_req @@ -102,6 +98,8 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr) p_lcb->link_role = l2cu_get_conn_role(p_lcb); } + counter_add("l2cap.conn.accept", 1); + /* Tell the other side we accept the connection */ btsnd_hcic_accept_conn (bd_addr, p_lcb->link_role); @@ -122,6 +120,7 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr) else p_lcb->link_role = l2cu_get_conn_role(p_lcb); + counter_add("l2cap.conn.accept", 1); btsnd_hcic_accept_conn (bd_addr, p_lcb->link_role); p_lcb->link_state = LST_CONNECTING; @@ -130,6 +129,7 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr) else if (p_lcb->link_state == LST_DISCONNECTING) { /* In disconnecting state, reject the connection. */ + counter_add("l2cap.conn.reject.disconn", 1); btsnd_hcic_reject_conn (bd_addr, HCI_ERR_HOST_REJECT_DEVICE); } else @@ -137,6 +137,7 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr) L2CAP_TRACE_ERROR("L2CAP got conn_req while connected (state:%d). Reject it", p_lcb->link_state); /* Reject the connection with ACL Connection Already exist reason */ + counter_add("l2cap.conn.reject.exists", 1); btsnd_hcic_reject_conn (bd_addr, HCI_ERR_CONNECTION_EXISTS); } return (FALSE); @@ -159,9 +160,7 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda) tL2C_CCB *p_ccb; tBTM_SEC_DEV_REC *p_dev_info = NULL; -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) btm_acl_update_busy_level (BTM_BLI_PAGE_DONE_EVT); -#endif /* Save the parameters */ ci.status = status; @@ -194,6 +193,7 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda) { /* Connected OK. Change state to connected */ p_lcb->link_state = LST_CONNECTED; + counter_add("l2cap.conn.ok", 1); /* Get the peer information if the l2cap flow-control/rtrans is supported */ l2cu_send_peer_info_req (p_lcb, L2CAP_EXTENDED_FEATURES_INFO_TYPE); @@ -790,9 +790,6 @@ void l2c_link_adjust_allocation (void) } } -#if L2CAP_HOST_FLOW_CTRL - p_lcb->link_ack_thresh = L2CAP_HOST_FC_ACL_BUFS / l2cb.num_links_active; -#endif L2CAP_TRACE_EVENT ("l2c_link_adjust_allocation LCB %d Priority: %d XmitQuota: %d", yy, p_lcb->acl_priority, p_lcb->link_xmit_quota); @@ -803,7 +800,7 @@ void l2c_link_adjust_allocation (void) /* this link may have sent anything but some other link sent packets so */ /* so we may need a timer to kick off this link's transmissions. */ if ( (p_lcb->link_state == LST_CONNECTED) - && (p_lcb->link_xmit_data_q.count) + && (!list_is_empty(p_lcb->link_xmit_data_q)) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota) ) btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_FLOW_CONTROL_TOUT); } @@ -960,25 +957,8 @@ UINT8 l2c_link_pkts_rcvd (UINT16 *num_pkts, UINT16 *handles) { UINT8 num_found = 0; -#if (L2CAP_HOST_FLOW_CTRL == TRUE) - - int xx; - tL2C_LCB *p_lcb = &l2cb.lcb_pool[0]; - - for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) - { - if ((p_lcb->in_use) && (p_lcb->link_pkts_unacked)) - { - num_pkts[num_found] = p_lcb->link_pkts_unacked; - handles[num_found] = p_lcb->handle; - p_lcb->link_pkts_unacked = 0; - num_found++; - } - } -#else UNUSED(num_pkts); UNUSED(handles); -#endif return (num_found); } @@ -1046,7 +1026,7 @@ void l2c_pin_code_request (BD_ADDR bd_addr) } } -#if ((BTM_PWR_MGR_INCLUDED == TRUE) && L2CAP_WAKE_PARKED_LINK == TRUE) +#if L2CAP_WAKE_PARKED_LINK == TRUE /******************************************************************************* ** ** Function l2c_link_check_power_mode @@ -1066,11 +1046,11 @@ BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb) /* * We only switch park to active only if we have unsent packets */ - if ( p_lcb->link_xmit_data_q.count == 0 ) + if (list_is_empty(p_lcb->link_xmit_data_q)) { for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) { - if (p_ccb->xmit_hold_q.count != 0) + if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)) { need_to_active = TRUE; break; @@ -1096,7 +1076,7 @@ BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb) } return FALSE; } -#endif /* ((BTM_PWR_MGR_INCLUDED == TRUE) && L2CAP_WAKE_PARKED_LINK == TRUE) */ +#endif /* L2CAP_WAKE_PARKED_LINK == TRUE) */ /******************************************************************************* ** @@ -1126,7 +1106,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) p_buf->event = 0; p_buf->layer_specific = 0; - GKI_enqueue (&p_lcb->link_xmit_data_q, p_buf); + list_append(p_lcb->link_xmit_data_q, p_buf); if (p_lcb->link_xmit_quota == 0) { @@ -1182,8 +1162,9 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) continue; /* See if we can send anything from the Link Queue */ - if ((p_buf = (BT_HDR *)GKI_dequeue (&p_lcb->link_xmit_data_q)) != NULL) - { + if (!list_is_empty(p_lcb->link_xmit_data_q)) { + p_buf = (BT_HDR *)list_front(p_lcb->link_xmit_data_q); + list_remove(p_lcb->link_xmit_data_q, p_buf); l2c_link_send_to_lower (p_lcb, p_buf); } else if (single_write) @@ -1232,9 +1213,11 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota)) #endif { - if ((p_buf = (BT_HDR *)GKI_dequeue (&p_lcb->link_xmit_data_q)) == NULL) + if (list_is_empty(p_lcb->link_xmit_data_q)) break; + p_buf = (BT_HDR *)list_front(p_lcb->link_xmit_data_q); + list_remove(p_lcb->link_xmit_data_q, p_buf); if (!l2c_link_send_to_lower (p_lcb, p_buf)) break; } @@ -1261,7 +1244,7 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf) /* There is a special case where we have readjusted the link quotas and */ /* this link may have sent anything but some other link sent packets so */ /* so we may need a timer to kick off this link's transmissions. */ - if ( (p_lcb->link_xmit_data_q.count) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota) ) + if ( (!list_is_empty(p_lcb->link_xmit_data_q)) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota) ) btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_FLOW_CONTROL_TOUT); } @@ -1280,11 +1263,12 @@ static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf) { UINT16 num_segs; UINT16 xmit_window, acl_data_size; + const controller_t *controller = controller_get_interface(); - if ((p_buf->len <= btu_cb.hcit_acl_pkt_size + if ((p_buf->len <= controller->get_acl_packet_size_classic() #if (BLE_INCLUDED == TRUE) && (p_lcb->transport == BT_TRANSPORT_BR_EDR)) || - ((p_lcb->transport == BT_TRANSPORT_LE) && (p_buf->len <= btu_cb.hcit_ble_acl_pkt_size)) + ((p_lcb->transport == BT_TRANSPORT_LE) && (p_buf->len <= controller->get_acl_packet_size_ble())) #else ) #endif @@ -1306,13 +1290,13 @@ static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf) if (p_lcb->transport == BT_TRANSPORT_LE) { l2cb.controller_le_xmit_window--; - L2C_LINK_SEND_BLE_ACL_DATA (p_buf); + bte_main_hci_send(p_buf, (UINT16)(BT_EVT_TO_LM_HCI_ACL|LOCAL_BLE_CONTROLLER_ID)); } else #endif { l2cb.controller_xmit_window--; - L2C_LINK_SEND_ACL_DATA (p_buf); + bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL); } } else @@ -1320,14 +1304,14 @@ static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf) #if BLE_INCLUDED == TRUE if (p_lcb->transport == BT_TRANSPORT_LE) { - acl_data_size = btu_cb.hcit_ble_acl_data_size; + acl_data_size = controller->get_acl_data_size_ble(); xmit_window = l2cb.controller_le_xmit_window; } else #endif { - acl_data_size = btu_cb.hcit_acl_data_size; + acl_data_size = controller->get_acl_data_size_classic(); xmit_window = l2cb.controller_xmit_window; } num_segs = (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_data_size - 1) / acl_data_size; @@ -1376,12 +1360,12 @@ static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf) #if BLE_INCLUDED == TRUE if (p_lcb->transport == BT_TRANSPORT_LE) { - L2C_LINK_SEND_BLE_ACL_DATA(p_buf); + bte_main_hci_send(p_buf, (UINT16)(BT_EVT_TO_LM_HCI_ACL|LOCAL_BLE_CONTROLLER_ID)); } else #endif { - L2C_LINK_SEND_ACL_DATA (p_buf); + bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL); } } @@ -1551,188 +1535,6 @@ void l2c_link_process_num_completed_pkts (UINT8 *p) /******************************************************************************* ** -** Function l2cap_link_chk_pkt_start -** -** Description This function is called from the HCI transport when the first -** 4 bytes of an HCI ACL packet have been received. It checks if the -** packet is the next segment of a fragmented L2CAP message. If it -** is, and the length is OK, it returns the address of the -** starting L2CAP message segment buffer. -** -** Returns the address of the receive buffer HCIT should use -** (CR419: Modified to return NULL in case of error.) -** -** NOTE This assumes that the L2CAP MTU size is less than the size -** of an HCI ACL buffer, so the maximum L2CAP message will fit -** into one buffer. -** -*******************************************************************************/ -BT_HDR *l2cap_link_chk_pkt_start (BT_HDR *p_cur_buf) -{ - UINT8 *p; - UINT16 handle; - UINT16 hci_len; - UINT16 pkt_type; - tL2C_LCB *p_lcb; - BT_HDR * p_return_buf; /* CR419: To avoid returning from too many places */ - - - if (p_cur_buf) - { - p = (UINT8 *)(p_cur_buf + 1) + p_cur_buf->offset; - } - else - { - return (NULL); - } - - /* L2CAP expects all rcvd packets to have a layer-specific value of 0 */ - p_cur_buf->layer_specific = 0; - - STREAM_TO_UINT16 (handle, p); - STREAM_TO_UINT16 (hci_len, p); - - pkt_type = HCID_GET_EVENT (handle); - handle = HCID_GET_HANDLE (handle); - - l2cb.p_cur_hcit_lcb = NULL; - - /* Find the link that is associated with this handle */ - p_lcb = l2cu_find_lcb_by_handle (handle); - - /* If no link for this handle, nothing to do. */ - if (!p_lcb) - return (p_cur_buf) ; - - if (pkt_type == L2CAP_PKT_START) /*** START PACKET ***/ - { - /* Start of packet. If we were in the middle of receiving */ - /* a packet, it is incomplete. Drop it. */ - if (p_lcb->p_hcit_rcv_acl) - { - L2CAP_TRACE_WARNING ("L2CAP - dropping incomplete pkt"); - GKI_freebuf (p_lcb->p_hcit_rcv_acl); - p_lcb->p_hcit_rcv_acl = NULL; - } - - /* Save the active buffer address in the LCB */ - if ((p_return_buf = p_cur_buf) != NULL) - { - p_lcb->p_hcit_rcv_acl = p_return_buf; - l2cb.p_cur_hcit_lcb = p_lcb; - } - } - else /*** CONTINUATION PACKET ***/ - { - /* Packet continuation. Check if we were expecting it */ - if (p_lcb->p_hcit_rcv_acl) - { - UINT16 total_len; - BT_HDR *p_base_buf = p_lcb->p_hcit_rcv_acl; - UINT8 *p_f = (UINT8 *)(p_base_buf + 1) + p_base_buf->offset + 2; - - STREAM_TO_UINT16 (total_len, p_f); - - /* We were expecting the CONTINUATION packet. If length fits, it can go in the */ - /* current buffer. */ - if ((total_len + hci_len) <= (L2CAP_MTU_SIZE + HCI_DATA_PREAMBLE_SIZE)) - { - /* GKI_freebuf (p_cur_buf); CR419:Do not free it yet */ - p_return_buf = p_lcb->p_hcit_rcv_acl; /* CR419: return base buffer */ - l2cb.p_cur_hcit_lcb = p_lcb; - - if ((p_cur_buf->len > HCI_DATA_PREAMBLE_SIZE)) - { - UINT8 * p = (UINT8 *)(p_cur_buf + 1) - + p_cur_buf->offset - + HCI_DATA_PREAMBLE_SIZE; - UINT8 * p1 = (UINT8 *)(p_return_buf + 1) - + p_return_buf->offset - + p_return_buf->len; - - /* Copy data from new buffer into base buffer then update the data */ - /* count in the base buffer accordingly. */ - memcpy (p1, p, p_cur_buf->len - HCI_DATA_PREAMBLE_SIZE); - p_return_buf->len += (p_cur_buf->len - HCI_DATA_PREAMBLE_SIZE); - } - - GKI_freebuf (p_cur_buf); - p_cur_buf = NULL; - - /* Update HCI header of first segment (base buffer) with new length */ - total_len += hci_len; - p_f = (UINT8 *)(p_base_buf + 1) + p_base_buf->offset + 2; - UINT16_TO_STREAM (p_f, total_len); - } - else - { - /* Packet too long. Drop the base packet */ - L2CAP_TRACE_WARNING ("L2CAP - dropping too long pkt BufLen: %d total_len: %d hci_len: %d", - p_lcb->p_hcit_rcv_acl->len, total_len, hci_len); - - GKI_freebuf (p_lcb->p_hcit_rcv_acl); - p_lcb->p_hcit_rcv_acl = NULL; - p_return_buf = NULL ; /* Can't hold onto it any more */ - } - } - else /*** NEITHER START OR CONTINUATION PACKET ***/ - { - p_return_buf = NULL ; - } - } - - if (p_return_buf == NULL) /* if error is indicated.. */ - { - if (p_cur_buf != NULL) /* ..drop input buffer */ - GKI_freebuf(p_cur_buf); /* (if present) */ - } - - return (p_return_buf); -} - -/******************************************************************************* -** -** Function l2cap_link_chk_pkt_end -** -** Description This function is called from the HCI transport when the last -** byte of an HCI ACL packet has been received. It checks if the -** L2CAP message is complete, i.e. no more continuation packets -** are expected. -** -** Returns TRUE if message complete, FALSE if continuation expected -** -*******************************************************************************/ -BOOLEAN l2cap_link_chk_pkt_end (void) -{ - UINT8 *p; - BT_HDR *p_buf; - UINT16 l2cap_len; - tL2C_LCB *p_lcb; - - /* If link or buffer pointer not set up, let main line handle it */ - if (((p_lcb = l2cb.p_cur_hcit_lcb) == NULL) || ((p_buf = p_lcb->p_hcit_rcv_acl) == NULL)) - return (TRUE); - - /* Point to the L2CAP length */ - p = (UINT8 *)(p_buf + 1) + p_buf->offset + HCI_DATA_PREAMBLE_SIZE; - - STREAM_TO_UINT16 (l2cap_len, p); - - /* If the L2CAP length has not been reached, tell HCIT not to send this buffer to BTU */ - if (l2cap_len > (p_buf->len - (HCI_DATA_PREAMBLE_SIZE + L2CAP_PKT_OVERHEAD))) - { - return (FALSE); - } - else - { - p_lcb->p_hcit_rcv_acl = NULL; - return (TRUE); - } -} - - -/******************************************************************************* -** ** Function l2c_link_segments_xmitted ** ** Description This function is called from the HCI Interface when an ACL @@ -1763,7 +1565,7 @@ void l2c_link_segments_xmitted (BT_HDR *p_msg) { /* Enqueue the buffer to the head of the transmit queue, and see */ /* if we can transmit anything more. */ - GKI_enqueue_head (&p_lcb->link_xmit_data_q, p_msg); + list_prepend(p_lcb->link_xmit_data_q, p_msg); p_lcb->partial_segment_being_sent = FALSE; diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index c2531a72d..8da881c3d 100755 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -22,18 +22,21 @@ * ******************************************************************************/ -#include "bt_target.h" #include <stdlib.h> #include <string.h> #include <stdio.h> +#include "device/include/controller.h" +#include "btcore/include/counter.h" +#include "bt_target.h" +#include "btm_int.h" +#include "btu.h" #include "gki.h" #include "hcimsgs.h" -#include "l2cdefs.h" -#include "l2c_int.h" #include "l2c_api.h" -#include "btu.h" -#include "btm_int.h" +#include "l2c_int.h" +#include "l2cdefs.h" +#include "osi/include/log.h" /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ @@ -47,10 +50,6 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len); tL2C_CB l2cb; #endif -/* Temporary - until l2cap implements group management */ -#if (TCS_BCST_SETUP_INCLUDED == TRUE && TCS_INCLUDED == TRUE) -extern void tcs_proc_bcst_msg( BD_ADDR addr, BT_HDR *p_msg ) ; -#endif /******************************************************************************* ** ** Function l2c_bcst_msg @@ -82,10 +81,11 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm ) /* First, the HCI transport header */ UINT16_TO_STREAM (p, 0x0050 | (L2CAP_PKT_START << 12) | (2 << 14)); + uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_classic(); /* The HCI transport will segment the buffers. */ - if (p_buf->len > btu_cb.hcit_acl_data_size) + if (p_buf->len > acl_data_size) { - UINT16_TO_STREAM (p, btu_cb.hcit_acl_data_size); + UINT16_TO_STREAM (p, acl_data_size); } else { @@ -99,9 +99,12 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm ) p_buf->len += HCI_DATA_PREAMBLE_SIZE; - if (p_buf->len <= btu_cb.hcit_acl_pkt_size) + if (p_buf->len <= controller_get_interface()->get_acl_packet_size_classic()) { - HCI_ACL_DATA_TO_LOWER (p_buf); + counter_add("l2cap.ch2.tx.bytes", p_buf->len); + counter_add("l2cap.ch2.tx.pkts", 1); + + bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL); } } @@ -148,23 +151,21 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) STREAM_TO_UINT8 (cmd_code, p); if ((p_msg->layer_specific == 0) && (rcv_cid == L2CAP_SIGNALLING_CID) - && (cmd_code == L2CAP_CMD_INFO_REQ || cmd_code == L2CAP_CMD_CONN_REQ)) - { - L2CAP_TRACE_WARNING ("L2CAP - holding ACL for unknown handle:%d ls:%d cid:%d opcode:%d cur count:%d", - handle, p_msg->layer_specific, rcv_cid, cmd_code, - l2cb.rcv_hold_q.count); + && (cmd_code == L2CAP_CMD_INFO_REQ || cmd_code == L2CAP_CMD_CONN_REQ)) { + L2CAP_TRACE_WARNING ("L2CAP - holding ACL for unknown handle:%d ls:%d" + " cid:%d opcode:%d cur count:%d", handle, p_msg->layer_specific, + rcv_cid, cmd_code, list_length(l2cb.rcv_pending_q)); p_msg->layer_specific = 2; - GKI_enqueue (&l2cb.rcv_hold_q, p_msg); + list_append(l2cb.rcv_pending_q, p_msg); - if (l2cb.rcv_hold_q.count == 1) + if (list_length(l2cb.rcv_pending_q) == 1) btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT); return; - } - else - { - L2CAP_TRACE_ERROR ("L2CAP - rcvd ACL for unknown handle:%d ls:%d cid:%d opcode:%d cur count:%d", - handle, p_msg->layer_specific, rcv_cid, cmd_code, l2cb.rcv_hold_q.count); + } else { + L2CAP_TRACE_ERROR ("L2CAP - rcvd ACL for unknown handle:%d ls:%d cid:%d" + " opcode:%d cur count:%d", handle, p_msg->layer_specific, rcv_cid, + cmd_code, list_length(l2cb.rcv_pending_q)); } GKI_freebuf (p_msg); return; @@ -181,12 +182,6 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) STREAM_TO_UINT16 (hci_len, p); p_msg->offset += 4; -#if (L2CAP_HOST_FLOW_CTRL == TRUE) - /* Send ack if we hit the threshold */ - if (++p_lcb->link_pkts_unacked >= p_lcb->link_ack_thresh) - btu_hcif_send_host_rdy_for_data(); -#endif - /* Extract the length and CID */ STREAM_TO_UINT16 (l2cap_len, p); STREAM_TO_UINT16 (rcv_cid, p); @@ -226,24 +221,18 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) /* Send the data through the channel state machine */ if (rcv_cid == L2CAP_SIGNALLING_CID) { + counter_add("l2cap.sig.rx.bytes", l2cap_len); + counter_add("l2cap.sig.rx.pkts", 1); process_l2cap_cmd (p_lcb, p, l2cap_len); GKI_freebuf (p_msg); } else if (rcv_cid == L2CAP_CONNECTIONLESS_CID) { + counter_add("l2cap.ch2.rx.bytes", l2cap_len); + counter_add("l2cap.ch2.rx.pkts", 1); /* process_connectionless_data (p_lcb); */ STREAM_TO_UINT16 (psm, p); L2CAP_TRACE_DEBUG( "GOT CONNECTIONLESS DATA PSM:%d", psm ) ; -#if (TCS_BCST_SETUP_INCLUDED == TRUE && TCS_INCLUDED == TRUE) - if (psm == TCS_PSM_INTERCOM || psm == TCS_PSM_CORDLESS) - { - p_msg->offset += L2CAP_BCST_OVERHEAD; - p_msg->len -= L2CAP_BCST_OVERHEAD; - tcs_proc_bcst_msg( p_lcb->remote_bd_addr, p_msg ) ; - GKI_freebuf (p_msg); - } - else -#endif #if (L2CAP_UCD_INCLUDED == TRUE) /* if it is not broadcast, check UCD registration */ @@ -258,6 +247,8 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) #if (BLE_INCLUDED == TRUE) else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID) { + counter_add("l2cap.ble.rx.bytes", l2cap_len); + counter_add("l2cap.ble.rx.pkts", 1); l2cble_process_sig_cmd (p_lcb, p, l2cap_len); GKI_freebuf (p_msg); } @@ -266,6 +257,8 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) else if ((rcv_cid >= L2CAP_FIRST_FIXED_CHNL) && (rcv_cid <= L2CAP_LAST_FIXED_CHNL) && (l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb != NULL) ) { + counter_add("l2cap.fix.rx.bytes", l2cap_len); + counter_add("l2cap.fix.rx.pkts", 1); /* If no CCB for this channel, allocate one */ if (p_lcb && /* discard fixed channel data when link is disconnecting */ @@ -290,6 +283,8 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) else { + counter_add("l2cap.dyn.rx.bytes", l2cap_len); + counter_add("l2cap.dyn.rx.pkts", 1); if (p_ccb == NULL) GKI_freebuf (p_msg); else @@ -811,38 +806,30 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) ** Returns void ** *******************************************************************************/ -void l2c_process_held_packets (BOOLEAN timed_out) -{ - BT_HDR *p_buf, *p_buf1; - BUFFER_Q *p_rcv_hold_q = &l2cb.rcv_hold_q; - - if (!p_rcv_hold_q->count) +void l2c_process_held_packets(BOOLEAN timed_out) { + if (list_is_empty(l2cb.rcv_pending_q)) return; - if (!timed_out) - { + if (!timed_out) { btu_stop_timer(&l2cb.rcv_hold_tle); L2CAP_TRACE_WARNING("L2CAP HOLD CONTINUE"); - } - else - { + } else { L2CAP_TRACE_WARNING("L2CAP HOLD TIMEOUT"); } - /* Update the timeouts in the hold queue */ - for (p_buf = (BT_HDR *)GKI_getfirst (p_rcv_hold_q); p_buf; p_buf = p_buf1) - { - p_buf1 = (BT_HDR *)GKI_getnext (p_buf); - if (!timed_out || (!p_buf->layer_specific) || (--p_buf->layer_specific == 0)) - { - GKI_remove_from_queue (p_rcv_hold_q, p_buf); + for (const list_node_t *node = list_begin(l2cb.rcv_pending_q); + node != list_end(l2cb.rcv_pending_q);) { + BT_HDR *p_buf = list_node(node); + node = list_next(node); + if (!timed_out || (!p_buf->layer_specific) || (--p_buf->layer_specific == 0)) { + list_remove(l2cb.rcv_pending_q, p_buf); p_buf->layer_specific = 0xFFFF; - l2c_rcv_acl_data (p_buf); + l2c_rcv_acl_data(p_buf); } } /* If anyone still in the queue, restart the timeout */ - if (p_rcv_hold_q->count) + if (!list_is_empty(l2cb.rcv_pending_q)) btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT); } @@ -905,6 +892,13 @@ void l2c_init (void) l2cb.high_pri_min_xmit_quota = L2CAP_HIGH_PRI_MIN_XMIT_QUOTA; #endif + l2cb.rcv_pending_q = list_new(NULL); + if (l2cb.rcv_pending_q == NULL) + LOG_ERROR("%s unable to allocate memory for link layer control block", __func__); +} + +void l2c_free(void) { + list_free(l2cb.rcv_pending_q); } /******************************************************************************* @@ -984,12 +978,15 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags) if (p_ccb->cong_sent) { L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested xmit_hold_q.count: %u buff_quota: %u", - p_ccb->local_cid, p_ccb->xmit_hold_q.count, p_ccb->buff_quota); + p_ccb->local_cid, GKI_queue_length(&p_ccb->xmit_hold_q), p_ccb->buff_quota); GKI_freebuf (p_data); return (L2CAP_DW_FAILED); } + counter_add("l2cap.dyn.tx.bytes", p_data->len); + counter_add("l2cap.dyn.tx.pkts", 1); + l2c_csm_execute (p_ccb, L2CEVT_L2CA_DATA_WRITE, p_data); if (p_ccb->cong_sent) diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c index 77849ac12..a4267a55f 100644 --- a/stack/l2cap/l2c_utils.c +++ b/stack/l2cap/l2c_utils.c @@ -26,6 +26,8 @@ #include <string.h> #include <stdio.h> +#include "device/include/controller.h" +#include "btcore/include/counter.h" #include "gki.h" #include "bt_types.h" #include "hcimsgs.h" @@ -36,8 +38,8 @@ #include "btm_api.h" #include "btm_int.h" #include "hcidefs.h" -#include "bd.h" #include "bt_utils.h" +#include "osi/include/allocator.h" /******************************************************************************* ** @@ -84,6 +86,7 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR l2cb.num_links_active++; l2c_link_adjust_allocation(); } + p_lcb->link_xmit_data_q = list_new(NULL); return (p_lcb); } } @@ -174,7 +177,9 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb) } #if (BLE_INCLUDED == TRUE) - l2cb.is_ble_connecting = FALSE; + // Reset BLE connecting flag only if the address matches + if (!memcmp(l2cb.ble_connecting_bda, p_lcb->remote_bd_addr, BD_ADDR_LEN)) + l2cb.is_ble_connecting = FALSE; #endif #if (L2CAP_NUM_FIXED_CHNLS > 0) @@ -210,8 +215,13 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb) btm_acl_removed (p_lcb->remote_bd_addr, BT_TRANSPORT_BR_EDR); #endif /* Release any held buffers */ - while (p_lcb->link_xmit_data_q.p_first) - GKI_freebuf (GKI_dequeue (&p_lcb->link_xmit_data_q)); + while (!list_is_empty(p_lcb->link_xmit_data_q)) { + BT_HDR *p_buf = list_front(p_lcb->link_xmit_data_q); + list_remove(p_lcb->link_xmit_data_q, p_buf); + GKI_freebuf(p_buf); + } + list_free(p_lcb->link_xmit_data_q); + p_lcb->link_xmit_data_q = NULL; #if (L2CAP_UCD_INCLUDED == TRUE) /* clean up any security pending UCD */ @@ -376,11 +386,16 @@ BT_HDR *l2cu_build_header (tL2C_LCB *p_lcb, UINT16 len, UINT8 cmd, UINT8 id) #if (BLE_INCLUDED == TRUE) if (p_lcb->transport == BT_TRANSPORT_LE) { + counter_add("l2cap.ble.tx.bytes", p_buf->len); + counter_add("l2cap.ble.tx.pkts", 1); + UINT16_TO_STREAM (p, L2CAP_BLE_SIGNALLING_CID); } else #endif { + counter_add("l2cap.sig.tx.bytes", p_buf->len); + counter_add("l2cap.sig.tx.pkts", 1); UINT16_TO_STREAM (p, L2CAP_SIGNALLING_CID); } @@ -934,7 +949,7 @@ void l2cu_send_peer_disc_req (tL2C_CCB *p_ccb) */ if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_BASIC_MODE) { - while (p_ccb->xmit_hold_q.p_first) + while (GKI_getfirst(&p_ccb->xmit_hold_q)) { p_buf2 = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q); l2cu_set_acl_hci_header (p_buf2, p_ccb); @@ -1048,9 +1063,11 @@ void l2cu_send_peer_echo_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 d return; } + uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_classic(); + uint16_t acl_packet_size = controller_get_interface()->get_acl_packet_size_classic(); /* Don't return data if it does not fit in ACL and L2CAP MTU */ - maxlen = (GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID) > btu_cb.hcit_acl_pkt_size) ? - btu_cb.hcit_acl_data_size : (UINT16)GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID); + maxlen = (GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID) > acl_packet_size) ? + acl_data_size : (UINT16)GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID); maxlen -= (UINT16)(BT_HDR_SIZE + HCI_DATA_PREAMBLE_SIZE + L2CAP_PKT_OVERHEAD + L2CAP_CMD_OVERHEAD + L2CAP_ECHO_RSP_LEN); @@ -1514,6 +1531,7 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid) p_ccb->p_lcb = p_lcb; p_ccb->p_rcb = NULL; + p_ccb->should_free_rcb = false; /* Set priority then insert ccb into LCB queue (if we have an LCB) */ p_ccb->ccb_priority = L2CAP_CHNL_PRIORITY_LOW; @@ -1680,12 +1698,19 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb) btm_sec_clr_service_by_psm(p_rcb->psm); } + if (p_ccb->should_free_rcb) + { + osi_free(p_rcb); + p_ccb->p_rcb = NULL; + p_ccb->should_free_rcb = false; + } + btm_sec_clr_temp_auth_service (p_lcb->remote_bd_addr); /* Stop the timer */ btu_stop_timer (&p_ccb->timer_entry); - while (p_ccb->xmit_hold_q.p_first) + while (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)) GKI_freebuf (GKI_dequeue (&p_ccb->xmit_hold_q)); l2c_fcr_cleanup (p_ccb); @@ -2197,10 +2222,6 @@ void l2cu_device_reset (void) #endif } -#if (TCS_WUG_MEMBER_INCLUDED == TRUE && TCS_INCLUDED == TRUE) -extern UINT16 tcs_wug_get_clk_offset( BD_ADDR addr ) ; -#endif - /******************************************************************************* ** ** Function l2cu_create_conn @@ -2227,7 +2248,7 @@ BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport) if (transport == BT_TRANSPORT_LE) { - if (!HCI_LE_HOST_SUPPORTED(btm_cb.devcb.local_lmp_features[HCI_EXT_FEATURES_PAGE_1])) + if (!controller_get_interface()->supports_ble()) return FALSE; p_lcb->ble_addr_type = addr_type; @@ -2347,35 +2368,21 @@ BOOLEAN l2cu_create_conn_after_switch (tL2C_LCB *p_lcb) p_lcb->link_state = LST_CONNECTING; - -#if (TCS_WUG_MEMBER_INCLUDED == TRUE && TCS_INCLUDED == TRUE) - if ( (clock_offset = tcs_wug_get_clk_offset( p_lcb->remote_bd_addr )) != 0 ) + /* Check with the BT manager if details about remote device are known */ + if ((p_inq_info = BTM_InqDbRead(p_lcb->remote_bd_addr)) != NULL) { - page_scan_rep_mode = HCI_PAGE_SCAN_REP_MODE_R0; - page_scan_mode = HCI_MANDATARY_PAGE_SCAN_MODE; + page_scan_rep_mode = p_inq_info->results.page_scan_rep_mode; + page_scan_mode = p_inq_info->results.page_scan_mode; + clock_offset = (UINT16)(p_inq_info->results.clock_offset); } else { -#endif - - /* Check with the BT manager if details about remote device are known */ - if ((p_inq_info = BTM_InqDbRead(p_lcb->remote_bd_addr)) != NULL) - { - page_scan_rep_mode = p_inq_info->results.page_scan_rep_mode; - page_scan_mode = p_inq_info->results.page_scan_mode; - clock_offset = (UINT16)(p_inq_info->results.clock_offset); - } - else - { - /* No info known. Use default settings */ - page_scan_rep_mode = HCI_PAGE_SCAN_REP_MODE_R1; - page_scan_mode = HCI_MANDATARY_PAGE_SCAN_MODE; + /* No info known. Use default settings */ + page_scan_rep_mode = HCI_PAGE_SCAN_REP_MODE_R1; + page_scan_mode = HCI_MANDATARY_PAGE_SCAN_MODE; - clock_offset = (p_dev_rec) ? p_dev_rec->clock_offset : 0; - } -#if (TCS_WUG_MEMBER_INCLUDED == TRUE && TCS_INCLUDED == TRUE) + clock_offset = (p_dev_rec) ? p_dev_rec->clock_offset : 0; } -#endif if (!btsnd_hcic_create_conn (p_lcb->remote_bd_addr, ( HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1 @@ -2392,9 +2399,7 @@ BOOLEAN l2cu_create_conn_after_switch (tL2C_LCB *p_lcb) return (FALSE); } -#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE) btm_acl_update_busy_level (BTM_BLI_PAGE_EVT); -#endif btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_CONNECT_TOUT); @@ -3108,7 +3113,7 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb) } L2CAP_TRACE_DEBUG("RR scan pri=%d, lcid=0x%04x, q_cout=%d", - p_ccb->ccb_priority, p_ccb->local_cid, p_ccb->xmit_hold_q.count ); + p_ccb->ccb_priority, p_ccb->local_cid, GKI_queue_length(&p_ccb->xmit_hold_q)); /* store the next serving channel */ /* this channel is the last channel of its priority group */ @@ -3133,9 +3138,9 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb) if (p_ccb->fcrb.wait_ack || p_ccb->fcrb.remote_busy) continue; - if ( p_ccb->fcrb.retrans_q.count == 0 ) + if ( GKI_queue_is_empty(&p_ccb->fcrb.retrans_q)) { - if ( p_ccb->xmit_hold_q.count == 0 ) + if ( GKI_queue_is_empty(&p_ccb->xmit_hold_q)) continue; /* If using the common pool, should be at least 10% free. */ @@ -3149,7 +3154,7 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb) } else { - if (p_ccb->xmit_hold_q.count == 0) + if (GKI_queue_is_empty(&p_ccb->xmit_hold_q)) continue; } @@ -3259,9 +3264,9 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb) continue; /* No more checks needed if sending from the reatransmit queue */ - if (p_ccb->fcrb.retrans_q.count == 0) + if (GKI_queue_is_empty(&p_ccb->fcrb.retrans_q)) { - if (p_ccb->xmit_hold_q.count == 0) + if (GKI_queue_is_empty(&p_ccb->xmit_hold_q)) continue; /* If using the common pool, should be at least 10% free. */ @@ -3282,7 +3287,7 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb) } else { - if (p_ccb->xmit_hold_q.count != 0) + if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)) { p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q); if(NULL == p_buf) @@ -3356,10 +3361,11 @@ void l2cu_set_acl_hci_header (BT_HDR *p_buf, tL2C_CCB *p_ccb) { UINT16_TO_STREAM (p, p_ccb->p_lcb->handle | (L2CAP_PKT_START_NON_FLUSHABLE << L2CAP_PKT_TYPE_SHIFT)); + uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_ble(); /* The HCI transport will segment the buffers. */ - if (p_buf->len > btu_cb.hcit_ble_acl_data_size) + if (p_buf->len > acl_data_size) { - UINT16_TO_STREAM (p, btu_cb.hcit_ble_acl_data_size); + UINT16_TO_STREAM (p, acl_data_size); } else { @@ -3383,10 +3389,11 @@ void l2cu_set_acl_hci_header (BT_HDR *p_buf, tL2C_CCB *p_ccb) UINT16_TO_STREAM (p, p_ccb->p_lcb->handle | (L2CAP_PKT_START << L2CAP_PKT_TYPE_SHIFT)); #endif + uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_classic(); /* The HCI transport will segment the buffers. */ - if (p_buf->len > btu_cb.hcit_acl_data_size) + if (p_buf->len > acl_data_size) { - UINT16_TO_STREAM (p, btu_cb.hcit_acl_data_size); + UINT16_TO_STREAM (p, acl_data_size); } else { @@ -3408,7 +3415,7 @@ void l2cu_set_acl_hci_header (BT_HDR *p_buf, tL2C_CCB *p_ccb) *******************************************************************************/ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb) { - UINT16 q_count = p_ccb->xmit_hold_q.count; + UINT16 q_count = GKI_queue_length(&p_ccb->xmit_hold_q); #if (L2CAP_UCD_INCLUDED == TRUE) if ( p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID ) diff --git a/stack/l2cap/l2cap_client.c b/stack/l2cap/l2cap_client.c new file mode 100644 index 000000000..6e671fcf2 --- /dev/null +++ b/stack/l2cap/l2cap_client.c @@ -0,0 +1,434 @@ +/****************************************************************************** + * + * Copyright (C) 2014 Google, Inc. + * + * 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. + * + ******************************************************************************/ + +#define LOG_TAG "bt_l2cap_client" + +#include <assert.h> + +#include "btcore/include/bdaddr.h" +#include "gki/common/gki.h" +#include "osi/include/allocator.h" +#include "osi/include/buffer.h" +#include "osi/include/list.h" +#include "osi/include/log.h" +#include "osi/include/osi.h" +#include "stack/include/l2cap_client.h" +#include "stack/include/l2c_api.h" + +struct l2cap_client_t { + l2cap_client_callbacks_t callbacks; + void *context; + + uint16_t local_channel_id; + uint16_t remote_mtu; + bool configured_self; + bool configured_peer; + bool is_congested; + list_t *outbound_fragments; +}; + +static void connect_completed_cb(uint16_t local_channel_id, uint16_t error_code); +static void config_request_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *requested_parameters); +static void config_completed_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *negotiated_parameters); +static void disconnect_request_cb(uint16_t local_channel_id, bool ack_required); +static void disconnect_completed_cb(uint16_t local_channel_id, uint16_t error_code); +static void congestion_cb(uint16_t local_channel_id, bool is_congested); +static void read_ready_cb(uint16_t local_channel_id, BT_HDR *packet); +static void write_completed_cb(uint16_t local_channel_id, uint16_t packets_completed); + +static void fragment_packet(l2cap_client_t *client, buffer_t *packet); +static void dispatch_fragments(l2cap_client_t *client); +static l2cap_client_t *find(uint16_t local_channel_id); + +// From the Bluetooth Core specification. +static const uint16_t L2CAP_MTU_DEFAULT = 672; +static const uint16_t L2CAP_MTU_MINIMUM = 48; + +static const tL2CAP_APPL_INFO l2cap_callbacks = { + .pL2CA_ConnectCfm_Cb = connect_completed_cb, + .pL2CA_ConfigInd_Cb = config_request_cb, + .pL2CA_ConfigCfm_Cb = config_completed_cb, + .pL2CA_DisconnectInd_Cb = disconnect_request_cb, + .pL2CA_DisconnectCfm_Cb = disconnect_completed_cb, + .pL2CA_CongestionStatus_Cb = congestion_cb, + .pL2CA_DataInd_Cb = read_ready_cb, + .pL2CA_TxComplete_Cb = write_completed_cb, +}; + +static list_t *l2cap_clients; // A list of l2cap_client_t. Container does not own objects. + +buffer_t *l2cap_buffer_new(size_t size) { + buffer_t *buf = buffer_new(size + L2CAP_MIN_OFFSET); + buffer_t *slice = NULL; + if (buf) + slice = buffer_new_slice(buf, size); + buffer_free(buf); + return slice; +} + +l2cap_client_t *l2cap_client_new(const l2cap_client_callbacks_t *callbacks, void *context) { + assert(callbacks != NULL); + assert(callbacks->connected != NULL); + assert(callbacks->disconnected != NULL); + assert(callbacks->read_ready != NULL); + assert(callbacks->write_ready != NULL); + + if (!l2cap_clients) { + l2cap_clients = list_new(NULL); + if (!l2cap_clients) { + LOG_ERROR("%s unable to allocate space for L2CAP client list.", __func__); + return NULL; + } + } + + l2cap_client_t *ret = (l2cap_client_t *)osi_calloc(sizeof(l2cap_client_t)); + if (!ret) { + LOG_ERROR("%s unable to allocate L2CAP client.", __func__); + goto error; + } + + ret->callbacks = *callbacks; + ret->context = context; + + ret->remote_mtu = L2CAP_MTU_DEFAULT; + ret->outbound_fragments = list_new(NULL); + if (!ret) { + LOG_ERROR("%s unable to allocate outbound L2CAP fragment list.", __func__); + goto error; + } + + list_append(l2cap_clients, ret); + + return ret; + +error:; + osi_free(ret); + return NULL; +} + +void l2cap_client_free(l2cap_client_t *client) { + if (!client) + return; + + list_remove(l2cap_clients, client); + l2cap_client_disconnect(client); + list_free(client->outbound_fragments); + osi_free(client); +} + +bool l2cap_client_connect(l2cap_client_t *client, const bt_bdaddr_t *remote_bdaddr, uint16_t psm) { + assert(client != NULL); + assert(remote_bdaddr != NULL); + assert(psm != 0); + assert(!bdaddr_is_empty(remote_bdaddr)); + assert(client->local_channel_id == 0); + assert(!client->configured_self); + assert(!client->configured_peer); + assert(!L2C_INVALID_PSM(psm)); + + client->local_channel_id = L2CA_ConnectReq(psm, (uint8_t *)remote_bdaddr); + if (!client->local_channel_id) { + LOG_ERROR("%s unable to create L2CAP connection.", __func__); + return false; + } + + L2CA_SetConnectionCallbacks(client->local_channel_id, &l2cap_callbacks); + return true; +} + +void l2cap_client_disconnect(l2cap_client_t *client) { + assert(client != NULL); + + if (client->local_channel_id && !L2CA_DisconnectReq(client->local_channel_id)) + LOG_ERROR("%s unable to send disconnect message for LCID 0x%04x.", __func__, client->local_channel_id); + + client->local_channel_id = 0; + client->remote_mtu = L2CAP_MTU_DEFAULT; + client->configured_self = false; + client->configured_peer = false; + client->is_congested = false; + + for (const list_node_t *node = list_begin(client->outbound_fragments); node != list_end(client->outbound_fragments); node = list_next(node)) + GKI_freebuf(list_node(node)); + + list_clear(client->outbound_fragments); +} + +bool l2cap_client_is_connected(const l2cap_client_t *client) { + assert(client != NULL); + + return client->local_channel_id != 0 && client->configured_self && client->configured_peer; +} + +bool l2cap_client_write(l2cap_client_t *client, buffer_t *packet) { + assert(client != NULL); + assert(packet != NULL); + assert(l2cap_client_is_connected(client)); + + if (client->is_congested) + return false; + + fragment_packet(client, packet); + dispatch_fragments(client); + return true; +} + +static void connect_completed_cb(uint16_t local_channel_id, uint16_t error_code) { + assert(local_channel_id != 0); + + l2cap_client_t *client = find(local_channel_id); + if (!client) { + LOG_ERROR("%s unable to find L2CAP client for LCID 0x%04x.", __func__, local_channel_id); + return; + } + + if (error_code != L2CAP_CONN_OK) { + LOG_ERROR("%s error connecting L2CAP channel: %d.", __func__, error_code); + client->callbacks.disconnected(client, client->context); + return; + } + + // Use default L2CAP parameters. + tL2CAP_CFG_INFO desired_parameters = { 0 }; + if (!L2CA_ConfigReq(local_channel_id, &desired_parameters)) { + LOG_ERROR("%s error sending L2CAP config parameters.", __func__); + client->callbacks.disconnected(client, client->context); + } +} + +static void config_request_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *requested_parameters) { + tL2CAP_CFG_INFO response = { 0 }; + l2cap_client_t *client = find(local_channel_id); + + if (!client) { + LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); + return; + } + + response.result = L2CAP_CFG_OK; + + if (requested_parameters->mtu_present) { + // Make sure the peer chose an MTU at least as large as the minimum L2CAP MTU defined + // by the Bluetooth Core spec. + if (requested_parameters->mtu < L2CAP_MTU_MINIMUM) { + response.mtu = L2CAP_MTU_MINIMUM; + response.mtu_present = true; + response.result = L2CAP_CFG_UNACCEPTABLE_PARAMS; + } else { + client->remote_mtu = requested_parameters->mtu; + } + } + + if (requested_parameters->fcr_present) { + if (requested_parameters->fcr.mode != L2CAP_FCR_BASIC_MODE) { + response.fcr_present = true; + response.fcr = requested_parameters->fcr; + response.fcr.mode = L2CAP_FCR_BASIC_MODE; + response.result = L2CAP_CFG_UNACCEPTABLE_PARAMS; + } + } + + if (!L2CA_ConfigRsp(local_channel_id, &response)) { + LOG_ERROR("%s unable to send config response for LCID 0x%04x.", __func__, local_channel_id); + l2cap_client_disconnect(client); + return; + } + + // If we've configured both endpoints, let the listener know we've connected. + client->configured_peer = true; + if (l2cap_client_is_connected(client)) + client->callbacks.connected(client, client->context); +} + +static void config_completed_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *negotiated_parameters) { + l2cap_client_t *client = find(local_channel_id); + + if (!client) { + LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); + return; + } + + switch (negotiated_parameters->result) { + // We'll get another configuration response later. + case L2CAP_CFG_PENDING: + break; + + case L2CAP_CFG_UNACCEPTABLE_PARAMS: + // TODO: see if we can renegotiate parameters instead of dropping the connection. + LOG_WARN("%s dropping L2CAP connection due to unacceptable config parameters.", __func__); + l2cap_client_disconnect(client); + break; + + case L2CAP_CFG_OK: + // If we've configured both endpoints, let the listener know we've connected. + client->configured_self = true; + if (l2cap_client_is_connected(client)) + client->callbacks.connected(client, client->context); + break; + + // Failure, no further parameter negotiation possible. + default: + LOG_WARN("%s L2CAP parameter negotiation failed with error code %d.", __func__, negotiated_parameters->result); + l2cap_client_disconnect(client); + break; + } +} + +static void disconnect_request_cb(uint16_t local_channel_id, bool ack_required) { + l2cap_client_t *client = find(local_channel_id); + if (!client) { + LOG_ERROR("%s unable to find L2CAP client with LCID 0x%04x.", __func__, local_channel_id); + return; + } + + if (ack_required) + L2CA_DisconnectRsp(local_channel_id); + + // We already sent a disconnect response so this LCID is now invalid. + client->local_channel_id = 0; + l2cap_client_disconnect(client); + + client->callbacks.disconnected(client, client->context); +} + +static void disconnect_completed_cb(uint16_t local_channel_id, UNUSED_ATTR uint16_t error_code) { + assert(local_channel_id != 0); + + l2cap_client_t *client = find(local_channel_id); + if (!client) { + LOG_ERROR("%s unable to find L2CAP client with LCID 0x%04x.", __func__, local_channel_id); + return; + } + + client->local_channel_id = 0; + l2cap_client_disconnect(client); + + client->callbacks.disconnected(client, client->context); +} + +static void congestion_cb(uint16_t local_channel_id, bool is_congested) { + assert(local_channel_id != 0); + + l2cap_client_t *client = find(local_channel_id); + if (!client) { + LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); + return; + } + + client->is_congested = is_congested; + + if (!is_congested) { + // If we just decongested, dispatch whatever we have left over in our queue. + // Once that's done, if we're still decongested, notify the listener so it + // can start writing again. + dispatch_fragments(client); + if (!client->is_congested) + client->callbacks.write_ready(client, client->context); + } +} + +static void read_ready_cb(uint16_t local_channel_id, BT_HDR *packet) { + assert(local_channel_id != 0); + + l2cap_client_t *client = find(local_channel_id); + if (!client) { + LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); + return; + } + + // TODO(sharvil): eliminate copy from BT_HDR. + buffer_t *buffer = buffer_new(packet->len); + memcpy(buffer_ptr(buffer), packet->data + packet->offset, packet->len); + GKI_freebuf(packet); + + client->callbacks.read_ready(client, buffer, client->context); + buffer_free(buffer); +} + +static void write_completed_cb(UNUSED_ATTR uint16_t local_channel_id, UNUSED_ATTR uint16_t packets_completed) { + // Do nothing. We update congestion state based on the congestion callback + // and we've already removed items from outbound_fragments list so we don't + // really care how many packets were successfully dispatched. +} + +static void fragment_packet(l2cap_client_t *client, buffer_t *packet) { + assert(client != NULL); + assert(packet != NULL); + + // TODO(sharvil): eliminate copy into BT_HDR. + BT_HDR *bt_packet = GKI_getbuf(buffer_length(packet) + L2CAP_MIN_OFFSET); + bt_packet->offset = L2CAP_MIN_OFFSET; + bt_packet->len = buffer_length(packet); + memcpy(bt_packet->data + bt_packet->offset, buffer_ptr(packet), buffer_length(packet)); + + for (;;) { + if (bt_packet->len <= client->remote_mtu) { + if (bt_packet->len > 0) + list_append(client->outbound_fragments, bt_packet); + else + GKI_freebuf(bt_packet); + break; + } + + BT_HDR *fragment = GKI_getbuf(client->remote_mtu + L2CAP_MIN_OFFSET); + fragment->offset = L2CAP_MIN_OFFSET; + fragment->len = client->remote_mtu; + memcpy(fragment->data + fragment->offset, bt_packet->data + bt_packet->offset, client->remote_mtu); + + list_append(client->outbound_fragments, fragment); + + bt_packet->offset += client->remote_mtu; + bt_packet->len -= client->remote_mtu; + } +} + +static void dispatch_fragments(l2cap_client_t *client) { + assert(client != NULL); + assert(!client->is_congested); + + while (!list_is_empty(client->outbound_fragments)) { + BT_HDR *packet = (BT_HDR *)list_front(client->outbound_fragments); + list_remove(client->outbound_fragments, packet); + + switch (L2CA_DataWrite(client->local_channel_id, packet)) { + case L2CAP_DW_CONGESTED: + client->is_congested = true; + return; + + case L2CAP_DW_FAILED: + LOG_ERROR("%s error writing data to L2CAP connection LCID 0x%04x; disconnecting.", __func__, client->local_channel_id); + l2cap_client_disconnect(client); + return; + + case L2CAP_DW_SUCCESS: + break; + } + } +} + +static l2cap_client_t *find(uint16_t local_channel_id) { + assert(local_channel_id != 0); + + for (const list_node_t *node = list_begin(l2cap_clients); node != list_end(l2cap_clients); node = list_next(node)) { + l2cap_client_t *client = (l2cap_client_t *)list_node(node); + if (client->local_channel_id == local_channel_id) + return client; + } + + return NULL; +} diff --git a/stack/mcap/mca_api.c b/stack/mcap/mca_api.c index 2a2ff8ca1..ae4cdb22b 100644 --- a/stack/mcap/mca_api.c +++ b/stack/mcap/mca_api.c @@ -22,6 +22,7 @@ * Protocol (MCAP). * ******************************************************************************/ +#include <assert.h> #include <string.h> #include "bt_target.h" @@ -31,7 +32,6 @@ #include "mca_defs.h" #include "mca_int.h" -#include "wcassert.h" #include "btu.h" @@ -125,8 +125,8 @@ tMCA_HANDLE MCA_Register(tMCA_REG *p_reg, tMCA_CTRL_CBACK *p_cback) tL2CAP_APPL_INFO l2c_cacp_appl; tL2CAP_APPL_INFO l2c_dacp_appl; - WC_ASSERT(p_reg != NULL ); - WC_ASSERT(p_cback != NULL ); + assert(p_reg != NULL ); + assert(p_cback != NULL ); MCA_TRACE_API ("MCA_Register: ctrl_psm:0x%x, data_psm:0x%x", p_reg->ctrl_psm, p_reg->data_psm); @@ -221,9 +221,9 @@ tMCA_RESULT MCA_CreateDep(tMCA_HANDLE handle, tMCA_DEP *p_dep, tMCA_CS *p_cs) tMCA_RCB *p_rcb = mca_rcb_by_handle(handle); tMCA_CS *p_depcs; - WC_ASSERT(p_dep != NULL ); - WC_ASSERT(p_cs != NULL ); - WC_ASSERT(p_cs->p_data_cback != NULL ); + assert(p_dep != NULL ); + assert(p_cs != NULL ); + assert(p_cs->p_data_cback != NULL ); MCA_TRACE_API ("MCA_CreateDep: %d", handle); if (p_rcb) @@ -508,7 +508,7 @@ tMCA_RESULT MCA_CreateMdlRsp(tMCA_CL mcl, tMCA_DEP dep, tMCA_DCB *p_dcb; MCA_TRACE_API ("MCA_CreateMdlRsp: %d dep=%d mdl_id=%d cfg=%d rsp_code=%d", mcl, dep, mdl_id, cfg, rsp_code); - WC_ASSERT(p_chnl_cfg != NULL ); + assert(p_chnl_cfg != NULL ); if (p_ccb) { if (p_ccb->cong) @@ -605,7 +605,7 @@ tMCA_RESULT MCA_ReconnectMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm, tMCA_DCB *p_dcb; MCA_TRACE_API ("MCA_ReconnectMdl: %d ", mcl); - WC_ASSERT(p_chnl_cfg != NULL ); + assert(p_chnl_cfg != NULL ); if (p_ccb) { if (p_ccb->p_tx_req || p_ccb->p_rx_msg || p_ccb->cong) @@ -674,7 +674,7 @@ tMCA_RESULT MCA_ReconnectMdlRsp(tMCA_CL mcl, tMCA_DEP dep, tMCA_DCB *p_dcb; MCA_TRACE_API ("MCA_ReconnectMdlRsp: %d ", mcl); - WC_ASSERT(p_chnl_cfg != NULL ); + assert(p_chnl_cfg != NULL ); if (p_ccb) { if (p_ccb->cong) @@ -739,7 +739,7 @@ tMCA_RESULT MCA_DataChnlCfg(tMCA_CL mcl, const tMCA_CHNL_CFG *p_chnl_cfg) tMCA_TC_TBL *p_tbl; MCA_TRACE_API ("MCA_DataChnlCfg: %d ", mcl); - WC_ASSERT(p_chnl_cfg != NULL ); + assert(p_chnl_cfg != NULL ); if (p_ccb) { result = MCA_NO_RESOURCES; diff --git a/stack/mcap/mca_cact.c b/stack/mcap/mca_cact.c index bab3c76db..7ac0efb0d 100644 --- a/stack/mcap/mca_cact.c +++ b/stack/mcap/mca_cact.c @@ -165,7 +165,6 @@ void mca_ccb_snd_rsp(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data) BT_HDR *p_pkt; UINT8 *p, *p_start; BOOLEAN chk_mdl = FALSE; - tMCA_DCB *p_dcb; MCA_TRACE_DEBUG ("mca_ccb_snd_rsp cong=%d req=%d", p_ccb->cong, p_msg->op_code); /* assume that API functions verified the parameters */ @@ -187,7 +186,7 @@ void mca_ccb_snd_rsp(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data) if (chk_mdl && p_msg->rsp_code == MCA_RSP_SUCCESS) { - p_dcb = mca_dcb_by_hdl(p_msg->dcb_idx); + mca_dcb_by_hdl(p_msg->dcb_idx); BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_MCAP_DATA, p_ccb->sec_mask, p_ccb->p_rcb->reg.data_psm, BTM_SEC_PROTO_MCA, p_msg->dcb_idx); p_ccb->status = MCA_CCB_STAT_PENDING; diff --git a/stack/mcap/mca_int.h b/stack/mcap/mca_int.h index 54ff0c039..9a7d0fdf0 100644 --- a/stack/mcap/mca_int.h +++ b/stack/mcap/mca_int.h @@ -347,9 +347,9 @@ extern "C" ** Main Control Block *******************************************************************************/ #if MCA_DYNAMIC_MEMORY == FALSE -MCA_API extern tMCA_CB mca_cb; +extern tMCA_CB mca_cb; #else -MCA_API extern tMCA_CB *mca_cb_ptr; +extern tMCA_CB *mca_cb_ptr; #define mca_cb (*mca_cb_ptr) #endif diff --git a/stack/mcap/mca_main.c b/stack/mcap/mca_main.c index 60b99d9da..44307d24a 100644 --- a/stack/mcap/mca_main.c +++ b/stack/mcap/mca_main.c @@ -22,6 +22,7 @@ * Utility functions. * ******************************************************************************/ +#include <assert.h> #include <string.h> #include "bt_target.h" @@ -29,7 +30,6 @@ #include "mca_api.h" #include "mca_defs.h" #include "mca_int.h" -#include "wcassert.h" #include "l2c_api.h" /* Main Control block for MCA */ @@ -134,7 +134,7 @@ tMCA_TC_TBL * mca_tc_tbl_calloc(tMCA_CCB *p_ccb) } /* sanity check */ - WC_ASSERT(i != MCA_NUM_TC_TBL); + assert(i != MCA_NUM_TC_TBL); /* initialize entry */ p_tbl->peer_mtu = L2CAP_DEFAULT_MTU; @@ -175,7 +175,7 @@ tMCA_TC_TBL * mca_tc_tbl_dalloc(tMCA_DCB *p_dcb) } /* sanity check */ - WC_ASSERT(i != MCA_NUM_TC_TBL); + assert(i != MCA_NUM_TC_TBL); /* initialize entry */ p_tbl->peer_mtu = L2CAP_DEFAULT_MTU; diff --git a/stack/pan/pan_api.c b/stack/pan/pan_api.c index 6ba97b2b9..583f1d236 100644 --- a/stack/pan/pan_api.c +++ b/stack/pan/pan_api.c @@ -299,7 +299,6 @@ tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 dst_role, UINT16 tPAN_CONN *pcb; tBNEP_RESULT result; tBT_UUID src_uuid, dst_uuid; - UINT8 service_id; UINT32 mx_chan_id; /* @@ -343,17 +342,14 @@ tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 dst_role, UINT16 src_uuid.uu.uuid16 = UUID_SERVCLASS_PANU; if (dst_role == PAN_ROLE_CLIENT) { - service_id = BTM_SEC_SERVICE_BNEP_PANU; dst_uuid.uu.uuid16 = UUID_SERVCLASS_PANU; } else if (dst_role == PAN_ROLE_GN_SERVER) { - service_id = BTM_SEC_SERVICE_BNEP_GN; dst_uuid.uu.uuid16 = UUID_SERVCLASS_GN; } else { - service_id = BTM_SEC_SERVICE_BNEP_NAP; dst_uuid.uu.uuid16 = UUID_SERVCLASS_NAP; } mx_chan_id = dst_uuid.uu.uuid16; @@ -370,12 +366,10 @@ tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 dst_role, UINT16 dst_uuid.uu.uuid16 = UUID_SERVCLASS_PANU; if (src_role == PAN_ROLE_GN_SERVER) { - service_id = BTM_SEC_SERVICE_BNEP_GN; src_uuid.uu.uuid16 = UUID_SERVCLASS_GN; } else { - service_id = BTM_SEC_SERVICE_BNEP_NAP; src_uuid.uu.uuid16 = UUID_SERVCLASS_NAP; } mx_chan_id = src_uuid.uu.uuid16; @@ -679,7 +673,6 @@ tPAN_RESULT PAN_SetProtocolFilters (UINT16 handle, UINT16 *p_start_array, UINT16 *p_end_array) { -#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE) tPAN_CONN *pcb; tPAN_RESULT result; @@ -700,9 +693,6 @@ tPAN_RESULT PAN_SetProtocolFilters (UINT16 handle, PAN_TRACE_API ("PAN successfully sent protocol filters for handle %d", handle); return PAN_SUCCESS; -#else - return PAN_FAILURE; -#endif } @@ -728,7 +718,6 @@ tBNEP_RESULT PAN_SetMulticastFilters (UINT16 handle, UINT8 *p_start_array, UINT8 *p_end_array) { -#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE) tPAN_CONN *pcb; tPAN_RESULT result; @@ -750,9 +739,6 @@ tBNEP_RESULT PAN_SetMulticastFilters (UINT16 handle, PAN_TRACE_API ("PAN successfully sent multicast filters for handle %d", handle); return PAN_SUCCESS; -#else - return PAN_FAILURE; -#endif } diff --git a/stack/pan/pan_int.h b/stack/pan/pan_int.h index 4e0223645..4e463e668 100644 --- a/stack/pan/pan_int.h +++ b/stack/pan/pan_int.h @@ -82,7 +82,6 @@ typedef struct tPAN_MFILTER_IND_CB *pan_mfilt_ind_cb; /* multicast filter indication callback */ tPAN_TX_DATA_FLOW_CB *pan_tx_data_flow_cb; - BD_ADDR my_bda; /* BD Address of this device */ char *user_service_name; char *gn_service_name; char *nap_service_name; @@ -101,9 +100,9 @@ extern "C" { /* Global PAN data */ #if PAN_DYNAMIC_MEMORY == FALSE -PAN_API extern tPAN_CB pan_cb; +extern tPAN_CB pan_cb; #else -PAN_API extern tPAN_CB *pan_cb_ptr; +extern tPAN_CB *pan_cb_ptr; #define pan_cb (*pan_cb_ptr) #endif @@ -155,4 +154,3 @@ extern void pan_dump_status (void); #endif #endif - diff --git a/stack/pan/pan_main.c b/stack/pan/pan_main.c index 8306df302..56a8f12cf 100644 --- a/stack/pan/pan_main.c +++ b/stack/pan/pan_main.c @@ -112,7 +112,6 @@ void pan_conn_ind_cb (UINT16 handle, ** is for NAP */ wrong_uuid = FALSE; -#if (defined (BNEP_SUPPORTS_ALL_UUID_LENGTHS) && BNEP_SUPPORTS_ALL_UUID_LENGTHS == TRUE) if (remote_uuid->len == 16) { /* @@ -189,7 +188,6 @@ void pan_conn_ind_cb (UINT16 handle, BNEP_ConnectResp (handle, BNEP_CONN_FAILED_UUID_SIZE); return; } -#endif /* Check if the source UUID is a valid one */ if (remote_uuid->uu.uuid16 != UUID_SERVCLASS_PANU && @@ -681,15 +679,11 @@ void pan_proto_filt_ind_cb (UINT16 handle, UINT16 num_filters, UINT8 *p_filters) { -#if (defined (BNEP_SUPPORTS_PROT_FILTERS) && BNEP_SUPPORTS_PROT_FILTERS == TRUE) PAN_TRACE_EVENT ("pan_proto_filt_ind_cb - called for handle %d with ind %d, result %d, num %d", handle, indication, result, num_filters); if (pan_cb.pan_pfilt_ind_cb) (*pan_cb.pan_pfilt_ind_cb) (handle, indication, result, num_filters, p_filters); -#endif - - return; } @@ -719,14 +713,9 @@ void pan_mcast_filt_ind_cb (UINT16 handle, UINT16 num_filters, UINT8 *p_filters) { -#if (defined (BNEP_SUPPORTS_MULTI_FILTERS) && BNEP_SUPPORTS_MULTI_FILTERS == TRUE) PAN_TRACE_EVENT ("pan_mcast_filt_ind_cb - called for handle %d with ind %d, result %d, num %d", handle, indication, result, num_filters); if (pan_cb.pan_mfilt_ind_cb) (*pan_cb.pan_mfilt_ind_cb) (handle, indication, result, num_filters, p_filters); -#endif - - return; } - diff --git a/stack/rfcomm/port_api.c b/stack/rfcomm/port_api.c index 0cbae96fe..3f38a71be 100644 --- a/stack/rfcomm/port_api.c +++ b/stack/rfcomm/port_api.c @@ -24,6 +24,7 @@ #include <string.h> #include "bt_target.h" +#include "btcore/include/counter.h" #include "gki.h" #include "rfcdefs.h" #include "port_api.h" @@ -33,15 +34,46 @@ #include "rfc_int.h" #include "l2c_api.h" #include "sdp_api.h" +#include "osi/include/log.h" /* duration of break in 200ms units */ #define PORT_BREAK_DURATION 1 -#include <cutils/log.h> -#define info(fmt, ...) ALOGI ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__) -#define debug(fmt, ...) ALOGD ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__) -#define error(fmt, ...) ALOGE ("## ERROR : %s: " fmt "##",__FUNCTION__, ## __VA_ARGS__) -#define asrt(s) if(!(s)) ALOGE ("## %s assert %s failed at line:%d ##",__FUNCTION__, #s, __LINE__) +#define info(fmt, ...) LOG_INFO ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__) +#define debug(fmt, ...) LOG_DEBUG ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__) +#define error(fmt, ...) LOG_ERROR ("## ERROR : %s: " fmt "##",__FUNCTION__, ## __VA_ARGS__) +#define asrt(s) if(!(s)) LOG_ERROR ("## %s assert %s failed at line:%d ##",__FUNCTION__, #s, __LINE__) + +/* Mapping from PORT_* result codes to human readable strings. */ +static const char *result_code_strings[] = { + "Success", + "Unknown error", + "Already opened", + "Command pending", + "App not registered", + "No memory", + "No resources", + "Bad BD address", + "Unspecified error", + "Bad handle", + "Not opened", + "Line error", + "Start failed", + "Parameter negotiation failed", + "Port negotiation failed", + "Sec failed", + "Peer connection failed", + "Peer failed", + "Peer timeout", + "Closed", + "TX full", + "Local closed", + "Local timeout", + "TX queue disabled", + "Page timeout", + "Invalid SCN", + "Unknown result code" +}; /******************************************************************************* ** @@ -84,6 +116,8 @@ int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn, BOOLEAN is_server, tRFC_MCB *p_mcb = port_find_mcb (bd_addr); UINT16 rfcomm_mtu; + counter_add("rfcomm.conn.created", 1); + RFCOMM_TRACE_API ("RFCOMM_CreateConnection() BDA: %02x-%02x-%02x-%02x-%02x-%02x", bd_addr[0], bd_addr[1], bd_addr[2], bd_addr[3], bd_addr[4], bd_addr[5]); @@ -209,6 +243,8 @@ int RFCOMM_RemoveConnection (UINT16 handle) { tPORT *p_port; + counter_add("rfcomm.conn.destroyed", 1); + RFCOMM_TRACE_API ("RFCOMM_RemoveConnection() handle:%d", handle); /* Check if handle is valid to avoid crashing */ @@ -1132,7 +1168,7 @@ int PORT_Purge (UINT16 handle, UINT8 purge_flags) { PORT_SCHEDULE_LOCK; /* to prevent missing credit */ - count = p_port->rx.queue.count; + count = GKI_queue_length(&p_port->rx.queue); while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->rx.queue)) != NULL) GKI_freebuf (p_buf); @@ -1368,7 +1404,7 @@ static int port_write (tPORT *p_port, BT_HDR *p_buf) (PORT_CTRL_REQ_SENT | PORT_CTRL_IND_RECEIVED))) { if ((p_port->tx.queue_size > PORT_TX_CRITICAL_WM) - || (p_port->tx.queue.count > PORT_TX_BUF_CRITICAL_WM)) + || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_CRITICAL_WM)) { RFCOMM_TRACE_WARNING ("PORT_Write: Queue size: %d", p_port->tx.queue_size); @@ -1525,7 +1561,7 @@ int PORT_WriteDataCO (UINT16 handle, int* p_len) /* data fits into the end of the queue */ PORT_SCHEDULE_LOCK; - if (((p_buf = (BT_HDR *)p_port->tx.queue.p_last) != NULL) + if (((p_buf = (BT_HDR *)GKI_getlast(&p_port->tx.queue)) != NULL) && (((int)p_buf->len + available) <= (int)p_port->peer_mtu) && (((int)p_buf->len + available) <= (int)length)) { @@ -1559,12 +1595,12 @@ int PORT_WriteDataCO (UINT16 handle, int* p_len) { /* if we're over buffer high water mark, we're done */ if ((p_port->tx.queue_size > PORT_TX_HIGH_WM) - || (p_port->tx.queue.count > PORT_TX_BUF_HIGH_WM)) + || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM)) { port_flow_control_user(p_port); event |= PORT_EV_FC; debug("tx queue is full,tx.queue_size:%d,tx.queue.count:%d,available:%d", - p_port->tx.queue_size, p_port->tx.queue.count, available); + p_port->tx.queue_size, GKI_queue_length(&p_port->tx.queue), available); break; } @@ -1676,7 +1712,7 @@ int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len) /* data fits into the end of the queue */ PORT_SCHEDULE_LOCK; - if (((p_buf = (BT_HDR *)p_port->tx.queue.p_last) != NULL) + if (((p_buf = (BT_HDR *)GKI_getlast(&p_port->tx.queue)) != NULL) && ((p_buf->len + max_len) <= p_port->peer_mtu) && ((p_buf->len + max_len) <= length)) { @@ -1697,7 +1733,7 @@ int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len) { /* if we're over buffer high water mark, we're done */ if ((p_port->tx.queue_size > PORT_TX_HIGH_WM) - || (p_port->tx.queue.count > PORT_TX_BUF_HIGH_WM)) + || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM)) break; /* continue with rfcomm data write */ @@ -1840,3 +1876,20 @@ UINT8 PORT_SetTraceLevel (UINT8 new_level) return (rfc_cb.trace_level); } +/******************************************************************************* +** +** Function PORT_GetResultString +** +** Description This function returns the human-readable string for a given +** result code. +** +** Returns a pointer to the human-readable string for the given result. +** +*******************************************************************************/ +const char *PORT_GetResultString (const uint8_t result_code) { + if (result_code > PORT_ERR_MAX) { + return result_code_strings[PORT_ERR_MAX]; + } + + return result_code_strings[result_code]; +} diff --git a/stack/rfcomm/port_rfc.c b/stack/rfcomm/port_rfc.c index 5704c017c..2a01395fe 100644 --- a/stack/rfcomm/port_rfc.c +++ b/stack/rfcomm/port_rfc.c @@ -865,7 +865,7 @@ void PORT_DataInd (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf) /* Check if rx queue exceeds the limit */ if ((p_port->rx.queue_size + p_buf->len > PORT_RX_CRITICAL_WM) - || (p_port->rx.queue.count + 1 > p_port->rx_buf_critical)) + || (GKI_queue_length(&p_port->rx.queue) + 1 > p_port->rx_buf_critical)) { RFCOMM_TRACE_EVENT ("PORT_DataInd. Buffer over run. Dropping the buffer"); GKI_freebuf (p_buf); @@ -1095,6 +1095,9 @@ void port_rfc_closed (tPORT *p_port, UINT8 res) p_port->rfc.state = RFC_STATE_CLOSED; + RFCOMM_TRACE_WARNING ("%s RFCOMM connection in state %d closed: %s (res: %d)", + __func__, p_port->state, PORT_GetResultString(res), res); + port_release_port (p_port); } @@ -1115,6 +1118,3 @@ void port_get_credits (tPORT *p_port, UINT8 k) if (p_port->credit_tx == 0) p_port->tx.peer_fc = TRUE; } - - - diff --git a/stack/rfcomm/port_utils.c b/stack/rfcomm/port_utils.c index 642ddb88f..7d29336dd 100644 --- a/stack/rfcomm/port_utils.c +++ b/stack/rfcomm/port_utils.c @@ -420,7 +420,7 @@ UINT32 port_flow_control_user (tPORT *p_port) || !p_port->rfc.p_mcb || !p_port->rfc.p_mcb->peer_ready || (p_port->tx.queue_size > PORT_TX_HIGH_WM) - || (p_port->tx.queue.count > PORT_TX_BUF_HIGH_WM); + || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM); if (p_port->tx.user_fc == fc) return (0); @@ -536,7 +536,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) p_port->rx.peer_fc = TRUE; } /* if queue count reached credit rx max, set peer fc */ - else if (p_port->rx.queue.count >= p_port->credit_rx_max) + else if (GKI_queue_length(&p_port->rx.queue) >= p_port->credit_rx_max) { p_port->rx.peer_fc = TRUE; } @@ -552,7 +552,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) /* check if it can be resumed now */ if (p_port->rx.peer_fc && (p_port->rx.queue_size < PORT_RX_LOW_WM) - && (p_port->rx.queue.count < PORT_RX_BUF_LOW_WM)) + && (GKI_queue_length(&p_port->rx.queue) < PORT_RX_BUF_LOW_WM)) { p_port->rx.peer_fc = FALSE; @@ -573,7 +573,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) /* Check the size of the rx queue. If it exceeds certain */ /* level and flow control has not been sent to the peer do it now */ else if ( ((p_port->rx.queue_size > PORT_RX_HIGH_WM) - || (p_port->rx.queue.count > PORT_RX_BUF_HIGH_WM)) + || (GKI_queue_length(&p_port->rx.queue) > PORT_RX_BUF_HIGH_WM)) && !p_port->rx.peer_fc) { RFCOMM_TRACE_EVENT ("PORT_DataInd Data reached HW. Sending FC set."); diff --git a/stack/rfcomm/rfc_int.h b/stack/rfcomm/rfc_int.h index 302a8af6c..719a99df8 100644 --- a/stack/rfcomm/rfc_int.h +++ b/stack/rfcomm/rfc_int.h @@ -235,9 +235,9 @@ typedef struct #if RFC_DYNAMIC_MEMORY == FALSE -RFC_API extern tRFC_CB rfc_cb; +extern tRFC_CB rfc_cb; #else -RFC_API extern tRFC_CB *rfc_cb_ptr; +extern tRFC_CB *rfc_cb_ptr; #define rfc_cb (*rfc_cb_ptr) #endif @@ -384,4 +384,3 @@ extern void PORT_LineStatusInd (tRFC_MCB *p_mcb, UINT8 dlci, UINT8 line_status); #endif #endif - diff --git a/stack/rfcomm/rfc_l2cap_if.c b/stack/rfcomm/rfc_l2cap_if.c index 9e3ad69d4..087e73a13 100644 --- a/stack/rfcomm/rfc_l2cap_if.c +++ b/stack/rfcomm/rfc_l2cap_if.c @@ -25,6 +25,7 @@ #include <stddef.h> #include "bt_target.h" +#include "btcore/include/counter.h" #include "gki.h" #include "rfcdefs.h" @@ -106,7 +107,7 @@ void RFCOMM_ConnectInd (BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id) RFCOMM_TRACE_DEBUG ("RFCOMM_ConnectInd start timer for collision, initiator's LCID(0x%x), acceptor's LCID(0x%x)", p_mcb->lcid, p_mcb->pending_lcid); - rfc_timer_start(p_mcb, (UINT16)(GKI_get_tick_count()%10 + 2)); + rfc_timer_start(p_mcb, (UINT16)(GKI_get_os_tick_count()%10 + 2)); return; } else @@ -366,6 +367,9 @@ void RFCOMM_BufDataInd (UINT16 lcid, BT_HDR *p_buf) if (event == RFC_EVENT_UIH) { + counter_add("rfcomm.rx.frames", 1); + counter_add("rfcomm.rx.bytes", p_buf->len); + if (p_buf->len > 0) rfc_port_sm_execute (p_port, event, p_buf); else diff --git a/stack/rfcomm/rfc_port_fsm.c b/stack/rfcomm/rfc_port_fsm.c index a998b6ec9..c0d7fbc35 100644 --- a/stack/rfcomm/rfc_port_fsm.c +++ b/stack/rfcomm/rfc_port_fsm.c @@ -431,7 +431,7 @@ void rfc_port_sm_opened (tPORT *p_port, UINT16 event, void *p_data) case RFC_EVENT_DISC: p_port->rfc.state = RFC_STATE_CLOSED; rfc_send_ua (p_port->rfc.p_mcb, p_port->dlci); - if(p_port->rx.queue.count) + if(!GKI_queue_is_empty(&p_port->rx.queue)) { /* give a chance to upper stack to close port properly */ RFCOMM_TRACE_DEBUG("port queue is not empty"); diff --git a/stack/rfcomm/rfc_port_if.c b/stack/rfcomm/rfc_port_if.c index 741df201e..18be81c6c 100644 --- a/stack/rfcomm/rfc_port_if.c +++ b/stack/rfcomm/rfc_port_if.c @@ -81,15 +81,20 @@ void RFCOMM_StartRsp (tRFC_MCB *p_mcb, UINT16 result) *******************************************************************************/ void RFCOMM_DlcEstablishReq (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu) { - tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci); UNUSED(mtu); - if (p_mcb->state != RFC_MX_STATE_CONNECTED) { PORT_DlcEstablishCnf (p_mcb, dlci, 0, RFCOMM_ERROR); return; } + tPORT *p_port = port_find_mcb_dlci_port(p_mcb, dlci); + if (p_port == NULL) { + RFCOMM_TRACE_WARNING("%s Unable to find DLCI port dlci:%d", __func__, + dlci); + return; + } + rfc_port_sm_execute(p_port, RFC_EVENT_OPEN, NULL); } @@ -104,15 +109,19 @@ void RFCOMM_DlcEstablishReq (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu) *******************************************************************************/ void RFCOMM_DlcEstablishRsp (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT16 result) { - tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci); UNUSED(mtu); - if ((p_mcb->state != RFC_MX_STATE_CONNECTED) && (result == RFCOMM_SUCCESS)) { PORT_DlcReleaseInd (p_mcb, dlci); return; } + tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci); + if (p_port == NULL) { + RFCOMM_TRACE_WARNING("%s Unable to find DLCI port dlci:%d", __func__, + dlci); + return; + } rfc_port_sm_execute(p_port, RFC_EVENT_ESTABLISH_RSP, &result); } @@ -130,11 +139,17 @@ void RFCOMM_DlcEstablishRsp (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT16 res *******************************************************************************/ void RFCOMM_ParNegReq (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu) { - tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci); UINT8 flow; UINT8 cl; UINT8 k; + tPORT *p_port = port_find_mcb_dlci_port(p_mcb, dlci); + if (p_port == NULL) { + RFCOMM_TRACE_WARNING("%s Unable to find DLCI port dlci:%d", __func__, + dlci); + return; + } + if (p_mcb->state != RFC_MX_STATE_CONNECTED) { p_port->error = PORT_PAR_NEG_FAILED; @@ -199,14 +214,19 @@ void RFCOMM_ParNegRsp (tRFC_MCB *p_mcb, UINT8 dlci, UINT16 mtu, UINT8 cl, UINT8 *******************************************************************************/ void RFCOMM_PortNegReq (tRFC_MCB *p_mcb, UINT8 dlci, tPORT_STATE *p_pars) { - tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci); - if (p_mcb->state != RFC_MX_STATE_CONNECTED) { PORT_PortNegCnf (p_mcb, dlci, NULL, RFCOMM_ERROR); return; } + tPORT *p_port = port_find_mcb_dlci_port(p_mcb, dlci); + if (p_port == NULL) { + RFCOMM_TRACE_WARNING("%s Unable to find DLCI port dlci:%d", __func__, + dlci); + return; + } + /* Send Parameter Negotiation Command UIH frame */ if (!p_pars) p_port->rfc.expected_rsp |= RFC_RSP_RPN_REPLY; @@ -247,7 +267,12 @@ void RFCOMM_PortNegRsp (tRFC_MCB *p_mcb, UINT8 dlci, tPORT_STATE *p_pars, *******************************************************************************/ void RFCOMM_ControlReq (tRFC_MCB *p_mcb, UINT8 dlci, tPORT_CTRL *p_pars) { - tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci); + tPORT *p_port = port_find_mcb_dlci_port(p_mcb, dlci); + if (p_port == NULL) { + RFCOMM_TRACE_WARNING("%s Unable to find DLCI port dlci:%d", __func__, + dlci); + return; + } if ((p_port->state != PORT_STATE_OPENED) || (p_port->rfc.state != RFC_STATE_OPENED)) @@ -274,7 +299,12 @@ void RFCOMM_ControlReq (tRFC_MCB *p_mcb, UINT8 dlci, tPORT_CTRL *p_pars) *******************************************************************************/ void RFCOMM_FlowReq (tRFC_MCB *p_mcb, UINT8 dlci, UINT8 enable) { - tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci); + tPORT *p_port = port_find_mcb_dlci_port(p_mcb, dlci); + if (p_port == NULL) { + RFCOMM_TRACE_WARNING("%s Unable to find DLCI port dlci:%d", __func__, + dlci); + return; + } if ((p_port->state != PORT_STATE_OPENED) || (p_port->rfc.state != RFC_STATE_OPENED)) @@ -300,7 +330,12 @@ void RFCOMM_FlowReq (tRFC_MCB *p_mcb, UINT8 dlci, UINT8 enable) *******************************************************************************/ void RFCOMM_LineStatusReq (tRFC_MCB *p_mcb, UINT8 dlci, UINT8 status) { - tPORT *p_port = port_find_mcb_dlci_port (p_mcb, dlci); + tPORT *p_port = port_find_mcb_dlci_port(p_mcb, dlci); + if (p_port == NULL) { + RFCOMM_TRACE_WARNING("%s Unable to find DLCI port dlci:%d", __func__, + dlci); + return; + } if ((p_port->state != PORT_STATE_OPENED) || (p_port->rfc.state != RFC_STATE_OPENED)) diff --git a/stack/rfcomm/rfc_ts_frames.c b/stack/rfcomm/rfc_ts_frames.c index 3831ab5eb..9b3cdca84 100644 --- a/stack/rfcomm/rfc_ts_frames.c +++ b/stack/rfcomm/rfc_ts_frames.c @@ -25,6 +25,7 @@ #include <stddef.h> #include "bt_target.h" +#include "btcore/include/counter.h" #include "gki.h" #include "rfcdefs.h" #include "port_api.h" @@ -218,7 +219,8 @@ void rfc_send_buf_uih (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf) } else { - + counter_add("rfcomm.tx.frames", 1); + counter_add("rfcomm.tx.bytes", p_buf->len); L2CA_DataWrite (p_mcb->lcid, p_buf); } } diff --git a/stack/sdp/sdp_api.c b/stack/sdp/sdp_api.c index 558bd8b69..6e84ded80 100644 --- a/stack/sdp/sdp_api.c +++ b/stack/sdp/sdp_api.c @@ -37,13 +37,6 @@ #include "sdpint.h" #include "btu.h" -#include <cutils/log.h> -#define info(fmt, ...) LOGI ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__) -#define debug(fmt, ...) LOGD ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__) -#define error(fmt, ...) LOGE ("## ERROR : %s: " fmt "##",__FUNCTION__, ## __VA_ARGS__) -#define asrt(s) if(!(s)) LOGE ("## %s assert %s failed at line:%d ##",__FUNCTION__, #s, __LINE__) - - /********************************************************************** ** C L I E N T F U N C T I O N P R O T O T Y P E S * ***********************************************************************/ @@ -686,17 +679,6 @@ tSDP_DISC_REC *SDP_FindServiceUUIDInDb (tSDP_DISCOVERY_DB *p_db, tBT_UUID *p_uui { if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) { - - SDP_TRACE_DEBUG("uuid len=%d ", p_uuid->len); - if (p_uuid->len == 2) - { - SDP_TRACE_DEBUG("uuid=0x%x \n", p_uuid->uu.uuid16); - } - else - { - SDP_TRACE_DEBUG("\n"); - } - if (sdpu_compare_uuid_with_attr (p_uuid, p_sattr)) return(p_rec); } @@ -1273,119 +1255,6 @@ UINT16 SDP_SetLocalDiRecord( tSDP_DI_RECORD *p_device_info, UINT32 *p_handle ) /******************************************************************************* ** -** Function SDP_GetLocalDiRecord -** -** Description This function adds a DI record to the local SDP database. -** -** Fills in the device information of the record -** p_handle - if p_handle == 0, the primary record is returned -** -** Returns Returns SDP_SUCCESS if record exists, else error -** -*******************************************************************************/ -UINT16 SDP_GetLocalDiRecord(tSDP_DI_GET_RECORD *p_device_info, UINT32 *p_handle ) -{ - UINT16 result = SDP_NO_DI_RECORD_FOUND; - -#if SDP_SERVER_ENABLED == TRUE - tSDP_RECORD *p_rec; - tSDP_ATTRIBUTE *p_attr; - UINT8 *p_temp; - INT32 templen; - - if (*p_handle == 0) - *p_handle = sdp_cb.server_db.di_primary_handle; - - if ((p_rec = sdp_db_find_record(*p_handle)) != NULL) - { - memset(p_device_info, 0, sizeof(tSDP_DI_RECORD)); - - result = SDP_SUCCESS; - - /* Retrieve the Specification ID */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_SPECIFICATION_ID, - ATTR_ID_SPECIFICATION_ID)) != NULL) - { - p_temp = p_attr->value_ptr; - BE_STREAM_TO_UINT16 (p_device_info->spec_id, p_temp); - } - - /* Retrieve the Vendor ID */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_VENDOR_ID, - ATTR_ID_VENDOR_ID)) != NULL) - { - p_temp = p_attr->value_ptr; - BE_STREAM_TO_UINT16 (p_device_info->rec.vendor, p_temp); - } - - /* Retrieve the Product ID */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_PRODUCT_ID, - ATTR_ID_PRODUCT_ID)) != NULL) - { - p_temp = p_attr->value_ptr; - BE_STREAM_TO_UINT16 (p_device_info->rec.product, p_temp); - } - - /* Retrieve the Version ID */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_PRODUCT_VERSION, - ATTR_ID_PRODUCT_VERSION)) != NULL) - { - p_temp = p_attr->value_ptr; - BE_STREAM_TO_UINT16 (p_device_info->rec.version, p_temp); - } - - /* Retrieve the Vendor ID Source ID */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_VENDOR_ID_SOURCE, - ATTR_ID_VENDOR_ID_SOURCE)) != NULL) - { - p_temp = p_attr->value_ptr; - BE_STREAM_TO_UINT16 (p_device_info->rec.vendor_id_source, p_temp); - } - - /* Retrieve the Primary Record */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_PRIMARY_RECORD, - ATTR_ID_PRIMARY_RECORD)) != NULL) - { - p_device_info->rec.primary_record = *p_attr->value_ptr; - } - - /* Retrieve the Client Executable URL */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_CLIENT_EXE_URL, - ATTR_ID_CLIENT_EXE_URL)) != NULL) - { - templen = (INT32)((p_attr->len < SDP_MAX_ATTR_LEN) ? p_attr->len : SDP_MAX_ATTR_LEN); - p_temp = p_attr->value_ptr; - BE_STREAM_TO_ARRAY (p_temp, p_device_info->rec.client_executable_url, templen); - } - - /* Retrieve the Service Description */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_SERVICE_DESCRIPTION, - ATTR_ID_SERVICE_DESCRIPTION)) != NULL) - { - templen = (INT32)((p_attr->len < SDP_MAX_ATTR_LEN) ? p_attr->len : SDP_MAX_ATTR_LEN); - p_temp = p_attr->value_ptr; - BE_STREAM_TO_ARRAY (p_temp, p_device_info->rec.service_description, templen); - } - - /* Retrieve the Documentation URL */ - if ((p_attr = sdp_db_find_attr_in_rec(p_rec, ATTR_ID_DOCUMENTATION_URL, - ATTR_ID_DOCUMENTATION_URL)) != NULL) - { - templen = (INT32)((p_attr->len < SDP_MAX_ATTR_LEN) ? p_attr->len : SDP_MAX_ATTR_LEN); - p_temp = p_attr->value_ptr; - BE_STREAM_TO_ARRAY (p_temp, p_device_info->rec.documentation_url, templen); - } - } - else - *p_handle = 0; -#endif - - return result; -} - - -/******************************************************************************* -** ** Function SDP_SetTraceLevel ** ** Description This function sets the trace level for SDP. If called with @@ -1401,100 +1270,3 @@ UINT8 SDP_SetTraceLevel (UINT8 new_level) return(sdp_cb.trace_level); } - -#if SDP_FOR_JV_INCLUDED == TRUE -/******************************************************************************* -** -** Function SDP_ConnOpen -** -** Description This function creates a connection to the SDP server on the -** given device. -** -** Returns 0, if failed to initiate connection. Otherwise, the handle. -** -*******************************************************************************/ -UINT32 SDP_ConnOpen (UINT8 *p_bd_addr, tSDP_DISC_RES_CB *p_rcb, - tSDP_DISC_CMPL_CB *p_cb) -{ -#if SDP_CLIENT_ENABLED == TRUE - tCONN_CB *p_ccb; - UINT32 idx = 0; - - if (!p_cb || !p_rcb) - return(idx); - - /* Specific BD address */ - p_ccb = sdp_conn_originate (p_bd_addr); - - if (!p_ccb) - return(idx); - - p_ccb->disc_state = SDP_DISC_WAIT_CONN; - p_ccb->p_db = (tSDP_DISCOVERY_DB *)p_rcb; - p_ccb->p_cb = p_cb; - - p_ccb->is_attr_search = SDP_IS_PASS_THRU; - - idx = (UINT32)(p_ccb - sdp_cb.ccb); - return(UINT32)(idx + 1); -#else - return(0); -#endif -} - -/******************************************************************************* -** -** Function SDP_WriteData -** -** Description This function sends data to the connected SDP server. -** -** Returns TRUE if data is sent, FALSE if failed. -** -*******************************************************************************/ -BOOLEAN SDP_WriteData (UINT32 handle, BT_HDR *p_msg) -{ -#if SDP_CLIENT_ENABLED == TRUE - tCONN_CB *p_ccb = NULL; - - if (p_msg && (handle > 0) && (handle <= SDP_MAX_CONNECTIONS) ) - { - p_ccb = &sdp_cb.ccb[handle - 1]; - if ( (p_ccb->con_state == SDP_STATE_CONNECTED) && - (p_ccb->con_flags & SDP_FLAGS_IS_ORIG) ) - { - /* Start inactivity timer */ - btu_start_timer (&p_ccb->timer_entry, BTU_TTYPE_SDP, SDP_INACT_TIMEOUT); - L2CA_DataWrite (p_ccb->connection_id, p_msg); - return TRUE; - } - } -#endif - return FALSE; -} - -/******************************************************************************* -** -** Function SDP_ConnClose -** -** Description This function is called to close a SDP connection. -** -** Parameters: handle - Handle of the connection returned by SDP_ConnOpen -** -** Returns TRUE if connection is closed, FALSE if failed to find the handle. -** -*******************************************************************************/ -BOOLEAN SDP_ConnClose (UINT32 handle) -{ -#if SDP_CLIENT_ENABLED == TRUE - tCONN_CB *p_ccb = NULL; - - if (handle > 0 && handle <= SDP_MAX_CONNECTIONS) - { - p_ccb = &sdp_cb.ccb[handle - 1]; - sdp_disconnect (p_ccb, SDP_SUCCESS); - return TRUE; - } -#endif - return FALSE; -} -#endif diff --git a/stack/sdp/sdp_db.c b/stack/sdp/sdp_db.c index 322e27dcf..ea8fa8756 100644 --- a/stack/sdp/sdp_db.c +++ b/stack/sdp/sdp_db.c @@ -36,7 +36,6 @@ #include "sdp_api.h" #include "sdpint.h" -#include "wbt_api.h" #if SDP_SERVER_ENABLED == TRUE /********************************************************************************/ @@ -340,7 +339,6 @@ BOOLEAN SDP_DeleteRecord (UINT32 handle) /* require new DI record to be created in SDP_SetLocalDiRecord */ sdp_cb.server_db.di_primary_handle = 0; - sdp_cb.server_db.brcm_di_registered = 0; return (TRUE); } @@ -369,7 +367,6 @@ BOOLEAN SDP_DeleteRecord (UINT32 handle) if( sdp_cb.server_db.di_primary_handle == handle ) { sdp_cb.server_db.di_primary_handle = 0; - sdp_cb.server_db.brcm_di_registered = 0; } return (TRUE); @@ -505,12 +502,6 @@ BOOLEAN SDP_AddAttribute (UINT32 handle, UINT16 attr_id, UINT8 attr_type, return (FALSE); } p_rec->num_attributes++; - - /*** Mark DI record as used by Broadcom ***/ - if (handle == sdp_cb.server_db.di_primary_handle && - attr_id == ATTR_ID_EXT_BRCM_VERSION) - sdp_cb.server_db.brcm_di_registered = TRUE; - return (TRUE); } } @@ -1023,6 +1014,3 @@ INT32 SDP_ReadRecord(UINT32 handle, UINT8 *p_data, INT32 *p_data_len) return (offset); } #endif - - - diff --git a/stack/sdp/sdp_discovery.c b/stack/sdp/sdp_discovery.c index caeeccf98..646a62dd3 100644 --- a/stack/sdp/sdp_discovery.c +++ b/stack/sdp/sdp_discovery.c @@ -194,23 +194,6 @@ static void sdp_snd_service_search_req(tCONN_CB *p_ccb, UINT8 cont_len, UINT8 * *******************************************************************************/ void sdp_disc_connected (tCONN_CB *p_ccb) { - -#if SDP_FOR_JV_INCLUDED == TRUE - if (SDP_IS_PASS_THRU == p_ccb->is_attr_search) - { - tSDP_DISC_RES_CB *p_rcb = (tSDP_DISC_RES_CB *) p_ccb->p_db; - tSDP_DR_OPEN evt_data; - /* report connected */ - p_ccb->disc_state = SDP_DISC_WAIT_PASS_THRU; - if (p_rcb) - { - memcpy(evt_data.peer_addr, p_ccb->device_address, BD_ADDR_LEN); - evt_data.peer_mtu = p_ccb->rem_mtu_size; - (*p_rcb)(SDP_EVT_OPEN, (void *)&evt_data); - } - } - else -#endif if (p_ccb->is_attr_search) { p_ccb->disc_state = SDP_DISC_WAIT_SEARCH_ATTR; @@ -251,21 +234,6 @@ void sdp_disc_server_rsp (tCONN_CB *p_ccb, BT_HDR *p_msg) /* stop inactivity timer when we receive a response */ btu_stop_timer (&p_ccb->timer_entry); -#if SDP_FOR_JV_INCLUDED == TRUE - if(SDP_IS_PASS_THRU == p_ccb->is_attr_search) - { - tSDP_DISC_RES_CB *p_rcb = (tSDP_DISC_RES_CB *) p_ccb->p_db; - tSDP_DR_DATA data; - if (p_rcb) - { - data.p_data = (UINT8 *)(p_msg + 1) + p_msg->offset; - data.data_len = p_msg->len; - (*p_rcb)(SDP_EVT_DATA_IND, (void *)&data); - } - return; - } -#endif - /* Got a reply!! Check what we got back */ p = (UINT8 *)(p_msg + 1) + p_msg->offset; @@ -383,7 +351,6 @@ static void sdp_copy_raw_data (tCONN_CB *p_ccb, BOOLEAN offset) unsigned int cpy_len; UINT32 list_len; UINT8 *p; - UINT8 * p_temp; UINT8 type; #if (SDP_DEBUG_RAW == TRUE) @@ -401,7 +368,7 @@ static void sdp_copy_raw_data (tCONN_CB *p_ccb, BOOLEAN offset) { cpy_len = p_ccb->p_db->raw_size - p_ccb->p_db->raw_used; list_len = p_ccb->list_len; - p_temp = p = &p_ccb->rsp_list[0]; + p = &p_ccb->rsp_list[0]; if(offset) { diff --git a/stack/sdp/sdp_main.c b/stack/sdp/sdp_main.c index 1e0c22a3c..86f16fbeb 100644 --- a/stack/sdp/sdp_main.c +++ b/stack/sdp/sdp_main.c @@ -563,12 +563,6 @@ tCONN_CB* sdp_conn_originate (UINT8 *p_bd_addr) /* Transition to the next appropriate state, waiting for connection confirm. */ p_ccb->con_state = SDP_STATE_CONN_SETUP; -// btla-specific ++ -#ifndef ANDROID_APP_INCLUDED /* Skip for Android: Do not need to set out_service for sdp, since sdp does not use sec. Prevents over-writing service_rec of a connection already in progress */ - BTM_SetOutService(p_bd_addr, BTM_SEC_SERVICE_SDP_SERVER, 0); -#endif -// btla-specific -- - cid = L2CA_ConnectReq (SDP_PSM, p_bd_addr); /* Check if L2CAP started the connection process */ diff --git a/stack/sdp/sdp_server.c b/stack/sdp/sdp_server.c index de420976a..5f6923a2b 100644 --- a/stack/sdp/sdp_server.c +++ b/stack/sdp/sdp_server.c @@ -786,6 +786,27 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num, len_to_send = (UINT16) (p_rsp - &p_ccb->rsp_list[0]); cont_offset = 0; + // The current SDP server design has a critical flaw where it can run into an infinite + // request/response loop with the client. Here's the scenario: + // - client makes SDP request + // - server returns the first fragment of the response with a continuation token + // - an SDP record is deleted from the server + // - client issues another request with previous continuation token + // - server has nothing to send back because the record is unavailable but in the + // first fragment, it had specified more response bytes than are now available + // - server sends back no additional response bytes and returns the same continuation token + // - client issues another request with the continuation token, and the process repeats + // + // We work around this design flaw here by checking if we will make forward progress + // (i.e. we will send > 0 response bytes) on a continued request. If not, we must have + // run into the above situation and we tell the peer an error occurred. + // + // TODO(sharvil): rewrite SDP server. + if (is_cont && len_to_send == 0) { + sdpu_build_n_send_error(p_ccb, trans_num, SDP_INVALID_CONT_STATE, NULL); + return; + } + /* If first response, insert sequence header */ if (!is_cont) { diff --git a/stack/sdp/sdpint.h b/stack/sdp/sdpint.h index b3006640c..262ac89f0 100644 --- a/stack/sdp/sdpint.h +++ b/stack/sdp/sdpint.h @@ -141,7 +141,6 @@ typedef struct typedef struct { UINT32 di_primary_handle; /* Device ID Primary record or NULL if nonexistent */ - BOOLEAN brcm_di_registered; UINT16 num_records; tSDP_RECORD record[SDP_MAX_RECORDS]; } tSDP_DB; @@ -150,7 +149,6 @@ enum { SDP_IS_SEARCH, SDP_IS_ATTR_SEARCH, - SDP_IS_PASS_THRU /* only when SDP_FOR_JV_INCLUDED == TRUE */ }; #if SDP_SERVER_ENABLED == TRUE @@ -204,7 +202,6 @@ typedef struct #define SDP_DISC_WAIT_HANDLES 1 #define SDP_DISC_WAIT_ATTR 2 #define SDP_DISC_WAIT_SEARCH_ATTR 3 -#define SDP_DISC_WAIT_PASS_THRU 4 /* only when SDP_FOR_JV_INCLUDED == TRUE */ #define SDP_DISC_WAIT_CANCEL 5 UINT8 disc_state; @@ -238,9 +235,9 @@ extern "C" { #endif /* Global SDP data */ #if SDP_DYNAMIC_MEMORY == FALSE -SDP_API extern tSDP_CB sdp_cb; +extern tSDP_CB sdp_cb; #else -SDP_API extern tSDP_CB *sdp_cb_ptr; +extern tSDP_CB *sdp_cb_ptr; #define sdp_cb (*sdp_cb_ptr) #endif @@ -249,11 +246,11 @@ SDP_API extern tSDP_CB *sdp_cb_ptr; #endif /* Functions provided by sdp_main.c */ -SDP_API extern void sdp_init (void); +extern void sdp_init (void); extern void sdp_disconnect (tCONN_CB*p_ccb, UINT16 reason); #if (defined(SDP_DEBUG) && SDP_DEBUG == TRUE) -SDP_API extern UINT16 sdp_set_max_attr_list_size (UINT16 max_size); +extern UINT16 sdp_set_max_attr_list_size (UINT16 max_size); #endif /* Functions provided by sdp_conn.c @@ -285,10 +282,10 @@ extern void sdpu_build_n_send_error (tCONN_CB *p_ccb, UINT16 trans_num, UIN extern UINT8 *sdpu_extract_attr_seq (UINT8 *p, UINT16 param_len, tSDP_ATTR_SEQ *p_seq); extern UINT8 *sdpu_extract_uid_seq (UINT8 *p, UINT16 param_len, tSDP_UUID_SEQ *p_seq); -SDP_API extern UINT8 *sdpu_get_len_from_type (UINT8 *p, UINT8 type, UINT32 *p_len); +extern UINT8 *sdpu_get_len_from_type (UINT8 *p, UINT8 type, UINT32 *p_len); extern BOOLEAN sdpu_is_base_uuid (UINT8 *p_uuid); extern BOOLEAN sdpu_compare_uuid_arrays (UINT8 *p_uuid1, UINT32 len1, UINT8 *p_uuid2, UINT16 len2); -SDP_API extern BOOLEAN sdpu_compare_bt_uuids (tBT_UUID *p_uuid1, tBT_UUID *p_uuid2); +extern BOOLEAN sdpu_compare_bt_uuids (tBT_UUID *p_uuid1, tBT_UUID *p_uuid2); extern BOOLEAN sdpu_compare_uuid_with_attr (tBT_UUID *p_btuuid, tSDP_DISC_ATTR *p_attr); extern void sdpu_sort_attr_list( UINT16 num_attr, tSDP_DISCOVERY_DB *p_db ); @@ -326,4 +323,3 @@ extern void sdp_disc_server_rsp (tCONN_CB *p_ccb, BT_HDR *p_msg); #endif - diff --git a/stack/smp/smp_api.c b/stack/smp/smp_api.c index 85d1054f4..2ebf9538a 100644 --- a/stack/smp/smp_api.c +++ b/stack/smp/smp_api.c @@ -82,7 +82,7 @@ void SMP_Init(void) ** Returns The new or current trace level ** *******************************************************************************/ -SMP_API extern UINT8 SMP_SetTraceLevel (UINT8 new_level) +extern UINT8 SMP_SetTraceLevel (UINT8 new_level) { if (new_level != 0xFF) smp_cb.trace_level = new_level; @@ -338,5 +338,3 @@ BOOLEAN SMP_Encrypt (UINT8 *key, UINT8 key_len, return status; } #endif /* SMP_INCLUDED */ - - diff --git a/stack/smp/smp_int.h b/stack/smp/smp_int.h index 70c09a5ef..af5102d23 100644 --- a/stack/smp/smp_int.h +++ b/stack/smp/smp_int.h @@ -227,9 +227,9 @@ extern "C" #endif #if SMP_DYNAMIC_MEMORY == FALSE - SMP_API extern tSMP_CB smp_cb; +extern tSMP_CB smp_cb; #else - SMP_API extern tSMP_CB *smp_cb_ptr; +extern tSMP_CB *smp_cb_ptr; #define smp_cb (*smp_cb_ptr) #endif @@ -238,15 +238,15 @@ extern "C" #endif /* Functions provided by att_main.c */ -SMP_API extern void smp_init (void); +extern void smp_init (void); #if SMP_CONFORMANCE_TESTING == TRUE /* Used only for conformance testing */ -SMP_API extern void smp_set_test_confirm_value (BOOLEAN enable, UINT8 *p_c_value); -SMP_API extern void smp_set_test_rand_value (BOOLEAN enable, UINT8 *p_c_value); -SMP_API extern void smp_set_test_pair_fail_status (BOOLEAN enable, UINT8 status); -SMP_API extern void smp_remove_fixed_channel_disable (BOOLEAN disable); -SMP_API extern void smp_skip_compare_check (BOOLEAN enable); +extern void smp_set_test_confirm_value (BOOLEAN enable, UINT8 *p_c_value); +extern void smp_set_test_rand_value (BOOLEAN enable, UINT8 *p_c_value); +extern void smp_set_test_pair_fail_status (BOOLEAN enable, UINT8 status); +extern void smp_remove_fixed_channel_disable (BOOLEAN disable); +extern void smp_skip_compare_check (BOOLEAN enable); #endif /* smp main */ extern void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data); @@ -321,4 +321,3 @@ extern tSMP_STATE smp_get_state(void); extern void smp_reject_unexp_pair_req(BD_ADDR bd_addr); #endif /* SMP_INT_H */ - diff --git a/stack/smp/smp_utils.c b/stack/smp/smp_utils.c index 21d93f889..ead44fc6f 100644 --- a/stack/smp/smp_utils.c +++ b/stack/smp/smp_utils.c @@ -34,6 +34,7 @@ #include "l2c_api.h" #include "l2c_int.h" #include "smp_int.h" +#include "device/include/controller.h" #define SMP_PAIRING_REQ_SIZE 7 @@ -349,7 +350,6 @@ static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb) { BT_HDR *p_buf = NULL ; UINT8 *p; - BD_ADDR static_addr; UNUSED(cmd_code); UNUSED(p_cb); @@ -360,8 +360,7 @@ static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb) UINT8_TO_STREAM (p, SMP_OPCODE_ID_ADDR); UINT8_TO_STREAM (p, 0); /* TODO: update with local address type */ - BTM_GetLocalDeviceAddr(static_addr); - BDADDR_TO_STREAM (p, static_addr); + BDADDR_TO_STREAM (p, controller_get_interface()->get_address()->address); p_buf->offset = L2CAP_MIN_OFFSET; p_buf->len = SMP_ID_ADDR_SIZE; diff --git a/stack/srvc/srvc_battery_int.h b/stack/srvc/srvc_battery_int.h index 8369bdd67..a9f81ae2e 100644 --- a/stack/srvc/srvc_battery_int.h +++ b/stack/srvc/srvc_battery_int.h @@ -60,9 +60,9 @@ extern "C" { /* Global GATT data */ #if GATT_DYNAMIC_MEMORY == FALSE -GATT_API extern tBATTERY_CB battery_cb; +extern tBATTERY_CB battery_cb; #else -GATT_API extern tBATTERY_CB *battery_cb_ptr; +extern tBATTERY_CB *battery_cb_ptr; #define battery_cb (*battery_cb_ptr) #endif diff --git a/stack/srvc/srvc_dis.c b/stack/srvc/srvc_dis.c index e29221282..4a1e1bbf6 100644 --- a/stack/srvc/srvc_dis.c +++ b/stack/srvc/srvc_dis.c @@ -23,6 +23,9 @@ #include "srvc_eng_int.h" #include "srvc_dis_int.h" +#define LOG_TAG "bt_srvc" +#include "osi/include/log.h" + #if BLE_INCLUDED == TRUE #define DIS_MAX_NUM_INC_SVR 0 @@ -197,9 +200,9 @@ UINT8 dis_read_attr_value (UINT8 clcb_idx, UINT16 handle, tGATT_VALUE *p_value, ** Returns void ** *******************************************************************************/ -void dis_gatt_c_read_dis_value_cmpl(UINT16 conn_id) +static void dis_gatt_c_read_dis_value_cmpl(UINT16 conn_id) { - tSRVC_CLCB *p_clcb = srvc_eng_find_clcb_by_conn_id(conn_id); + tSRVC_CLCB *p_clcb = srvc_eng_find_clcb_by_conn_id(conn_id); dis_cb.dis_read_uuid_idx = 0xff; @@ -207,13 +210,12 @@ void dis_gatt_c_read_dis_value_cmpl(UINT16 conn_id) if (dis_cb.p_read_dis_cback && p_clcb) { - GATT_TRACE_ERROR("dis_gatt_c_read_dis_value_cmpl: attr_mask = 0x%04x", p_clcb->dis_value.attr_mask); - GATT_TRACE_EVENT("calling p_read_dis_cbackd"); + LOG_INFO("%s conn_id:%d attr_mask = 0x%04x", __func__, conn_id, + p_clcb->dis_value.attr_mask); (*dis_cb.p_read_dis_cback)(p_clcb->bda, &p_clcb->dis_value); - dis_cb.p_read_dis_cback=NULL; + dis_cb.p_read_dis_cback = NULL; } - } /******************************************************************************* diff --git a/stack/srvc/srvc_dis_int.h b/stack/srvc/srvc_dis_int.h index f9f4dcdaa..74573195d 100644 --- a/stack/srvc/srvc_dis_int.h +++ b/stack/srvc/srvc_dis_int.h @@ -62,9 +62,9 @@ extern "C" { /* Global GATT data */ #if GATT_DYNAMIC_MEMORY == FALSE -GATT_API extern tDIS_CB dis_cb; +extern tDIS_CB dis_cb; #else -GATT_API extern tDIS_CB *dis_cb_ptr; +extern tDIS_CB *dis_cb_ptr; #define dis_cb (*dis_cb_ptr) #endif diff --git a/stack/srvc/srvc_eng_int.h b/stack/srvc/srvc_eng_int.h index 140d4e295..edd976399 100644 --- a/stack/srvc/srvc_eng_int.h +++ b/stack/srvc/srvc_eng_int.h @@ -64,9 +64,9 @@ extern "C" { /* Global GATT data */ #if GATT_DYNAMIC_MEMORY == FALSE -GATT_API extern tSRVC_ENG_CB srvc_eng_cb; +extern tSRVC_ENG_CB srvc_eng_cb; #else -GATT_API extern tSRVC_ENG_CB srvc_eng_cb_ptr; +extern tSRVC_ENG_CB srvc_eng_cb_ptr; #define srvc_eng_cb (*srvc_eng_cb_ptr) #endif |