Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc18a270 authored by Srinu Jella's avatar Srinu Jella Committed by Andre Eisenbach
Browse files

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
parent 4b777e99
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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. */
+24 −1
Original line number Diff line number Diff line
@@ -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);
    }
}

/*******************************************************************************
**
+2 −0
Original line number Diff line number Diff line
@@ -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