From 4e972d8c24ecfb808757ef5c81eb3877ebc93027 Mon Sep 17 00:00:00 2001 From: Srinu Jella Date: Tue, 16 Feb 2016 20:22:16 +0530 Subject: [PATCH] Track TX empty event to manage sniff timer Use case: OPP TX while inquiry is in progress. Steps: 1. Send any file from DUT to remote using BT. 2. Accept file on remote. 3. During file transfer, start inquiry on DUT and observe behaviour. Failure: DUT sends sniff command in the middle of the transfer though it is not required. eventually OPP Tx over L2CAP file transfer fail. Root Cause: As per the current implementation, for tx it will immediately starts idle timer without checking for the completion status of tx. Fix: Handled the tx complete event from L2CAP properly to start the idle timer to manage the sniff properly. Change-Id: I298075590042e82a2f33837f6df6af0b2fd8179a --- bta/jv/bta_jv_act.c | 9 ++++++++- stack/gap/gap_conn.c | 25 ++++++++++++++++++++++++- stack/include/gap_api.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.c index 0d19b76a6..52c548119 100644 --- a/bta/jv/bta_jv_act.c +++ b/bta/jv/bta_jv_act.c @@ -1021,6 +1021,10 @@ static void bta_jv_l2cap_client_cback(UINT16 gap_handle, UINT16 event) bta_jv_pm_conn_idle(p_cb->p_pm_cb); break; + case GAP_EVT_TX_EMPTY: + bta_jv_pm_conn_idle(p_cb->p_pm_cb); + break; + case GAP_EVT_CONN_CONGESTED: case GAP_EVT_CONN_UNCONGESTED: p_cb->cong = (event == GAP_EVT_CONN_CONGESTED) ? TRUE : FALSE; @@ -1186,6 +1190,10 @@ static void bta_jv_l2cap_server_cback(UINT16 gap_handle, UINT16 event) bta_jv_pm_conn_idle(p_cb->p_pm_cb); break; + case GAP_EVT_TX_EMPTY: + bta_jv_pm_conn_idle(p_cb->p_pm_cb); + break; + case GAP_EVT_CONN_CONGESTED: case GAP_EVT_CONN_UNCONGESTED: p_cb->cong = (event == GAP_EVT_CONN_CONGESTED) ? TRUE : FALSE; @@ -1375,7 +1383,6 @@ void bta_jv_l2cap_write(tBTA_JV_MSG *p_data) evt_data.status = BTA_JV_SUCCESS; } ls->p_cb->p_cback(BTA_JV_L2CAP_WRITE_EVT, (tBTA_JV *)&evt_data, ls->user_data); - bta_jv_set_pm_conn_state(ls->p_cb->p_pm_cb, BTA_JV_CONN_IDLE); } else { /* As this pointer is checked in the API function, this occurs only when the channel is * disconnected after the API function is called, but before the message is handled. */ diff --git a/stack/gap/gap_conn.c b/stack/gap/gap_conn.c index 5be381020..6f537c051 100644 --- a/stack/gap/gap_conn.c +++ b/stack/gap/gap_conn.c @@ -38,6 +38,7 @@ 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 void gap_tx_complete_ind (UINT16 l2cap_cid, UINT16 sdu_sent); static tGAP_CCB *gap_find_ccb_by_cid (UINT16 cid); static tGAP_CCB *gap_find_ccb_by_handle (UINT16 handle); @@ -83,7 +84,7 @@ void gap_conn_init (void) 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; + gap_cb.conn.reg_info.pL2CA_TxComplete_Cb = gap_tx_complete_ind; #endif } @@ -712,6 +713,28 @@ UINT16 GAP_ConnGetL2CAPCid (UINT16 gap_handle) return (p_ccb->connection_id); } +/******************************************************************************* +** +** Function gap_tx_connect_ind +** +** Description Sends out GAP_EVT_TX_EMPTY when transmission has been +** completed. +** +** Returns void +** +*******************************************************************************/ +void gap_tx_complete_ind (UINT16 l2cap_cid, UINT16 sdu_sent) +{ + tGAP_CCB *p_ccb = gap_find_ccb_by_cid (l2cap_cid); + if (p_ccb == NULL) + return; + + if ((p_ccb->con_state == GAP_CCB_STATE_CONNECTED) && (sdu_sent == 0xFFFF)) + { + GAP_TRACE_EVENT("%s: GAP_EVT_TX_EMPTY", __func__); + p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_TX_EMPTY); + } +} /******************************************************************************* ** diff --git a/stack/include/gap_api.h b/stack/include/gap_api.h index 755c49c0b..a758b6167 100644 --- a/stack/include/gap_api.h +++ b/stack/include/gap_api.h @@ -55,6 +55,8 @@ #define GAP_EVT_CONN_DATA_AVAIL 0x0102 #define GAP_EVT_CONN_CONGESTED 0x0103 #define GAP_EVT_CONN_UNCONGESTED 0x0104 +#define GAP_EVT_TX_EMPTY 0x0105 + /* Values for 'chan_mode_mask' field */ /* GAP_ConnOpen() - optional channels to negotiate */ #define GAP_FCR_CHAN_OPT_BASIC L2CAP_FCR_CHAN_OPT_BASIC -- 2.11.0