Example #1
0
/*******************************************************************************
**
** Function         l2c_process_held_packets
**
** Description      This function processes any L2CAP packets that arrived before
**                  the HCI connection complete arrived. It is a work around for
**                  badly behaved controllers.
**
** 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)
        return;

    if (!timed_out)
    {
        btu_stop_timer(&l2cb.rcv_hold_tle);
        L2CAP_TRACE_WARNING0("L2CAP HOLD CONTINUE");
    }
    else
    {
        L2CAP_TRACE_WARNING0("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);
            p_buf->layer_specific = 0xFFFF;
            l2c_rcv_acl_data (p_buf);
        }
    }

    /* If anyone still in the queue, restart the timeout */
    if (p_rcv_hold_q->count)
        btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT);
}
/*******************************************************************************
**
** Function         btm_ble_dequeue_direct_conn_req
**
** Description      This function dequeues the direct connection request
**
** Returns          None.
**
*******************************************************************************/
void btm_ble_dequeue_direct_conn_req(BD_ADDR rem_bda)
{
    tBTM_BLE_CONN_REQ   *p_req = NULL;
    tL2C_LCB *p_lcb;
    if(btm_cb.ble_ctr_cb.conn_pending_q.count)
    {
        p_req = (tBTM_BLE_CONN_REQ*)GKI_getfirst(&btm_cb.ble_ctr_cb.conn_pending_q);
    }
    while(p_req != NULL)
    {
        p_lcb = (tL2C_LCB *)p_req->p_param;
        if((p_lcb != NULL) && (p_lcb->in_use))
        {
            //If BD address matches
            if(!memcmp (rem_bda, p_lcb->remote_bd_addr, BD_ADDR_LEN))
            {
                GKI_remove_from_queue(&btm_cb.ble_ctr_cb.conn_pending_q, p_req);
                l2cu_release_lcb ((tL2C_LCB *)p_req->p_param);
                GKI_freebuf((void *)p_req);
                break;
            }
        }
        p_req = (tBTM_BLE_CONN_REQ*)GKI_getnext(p_req);
    }
}