/******************************************************************************* ** ** 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); } }
/******************************************************************************* ** ** 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); }