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

Commit 4be293a3 authored by Subramanian Srinivasan's avatar Subramanian Srinivasan Committed by Jakub Pawlowski
Browse files

Dequeues direct connection request during cancel conn operation

When cancel connection request for a device is sent
from an app and if the current pending connection
request's BD address does not match with this device,
the entries of the connection request pending queue
are also checked. If BD address match occurs with an
entry in the connection request queue, the entry is
removed from the queue.

Change-Id: I1bf50a424d86ac53a5201fff742c822f4c8d1c0b
parent eae6d92f
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -680,6 +680,37 @@ void btm_ble_enqueue_direct_conn_req(void *p_param)
}
/*******************************************************************************
**
** 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)
{
    if (fixed_queue_is_empty(btm_cb.ble_ctr_cb.conn_pending_q))
        return;

    list_t *list = fixed_queue_get_list(btm_cb.ble_ctr_cb.conn_pending_q);
    for (const list_node_t *node = list_begin(list); node != list_end(list);
            node = list_next(node)) {
        tBTM_BLE_CONN_REQ *p_req = (tBTM_BLE_CONN_REQ *)list_node(node);
        tL2C_LCB *p_lcb = (tL2C_LCB *)p_req->p_param;
        if ((p_lcb == NULL) || (!p_lcb->in_use)) {
            continue;
        }
        //If BD address matches
        if (!memcmp (rem_bda, p_lcb->remote_bd_addr, BD_ADDR_LEN)) {
            fixed_queue_try_remove_from_queue(btm_cb.ble_ctr_cb.conn_pending_q, p_req);
            l2cu_release_lcb((tL2C_LCB *)p_req->p_param);
            osi_free((void *)p_req);
            break;
        }
    }
}
/*******************************************************************************
**
** Function         btm_send_pending_direct_conn
**
** Description      This function send the pending direct connection request in queue
+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ extern void btm_ble_update_link_topology_mask(uint8_t role, bool increase);
/* direct connection utility */
extern bool    btm_send_pending_direct_conn(void);
extern void btm_ble_enqueue_direct_conn_req(void *p_param);
extern void btm_ble_dequeue_direct_conn_req(BD_ADDR rem_bda);

/* BLE address management */
extern void btm_gen_resolvable_private_addr (void *p_cmd_cplt_cback);
+2 −0
Original line number Diff line number Diff line
@@ -243,6 +243,8 @@ bool gatt_disconnect (tGATT_TCB *p_tcb)
                else
                {
                    ret = L2CA_CancelBleConnectReq (p_tcb->peer_bda);
                    if (!ret)
                        gatt_set_ch_state(p_tcb, GATT_CH_CLOSE);
                }
                gatt_set_ch_state(p_tcb, GATT_CH_CLOSING);
            }
+3 −3
Original line number Diff line number Diff line
@@ -57,17 +57,17 @@ bool L2CA_CancelBleConnectReq (BD_ADDR rem_bda)
    /* There can be only one BLE connection request outstanding at a time */
    if (btm_ble_get_conn_st() == BLE_CONN_IDLE)
    {
        L2CAP_TRACE_WARNING ("L2CA_CancelBleConnectReq - no connection pending");
        L2CAP_TRACE_WARNING ("%s - no connection pending", __func__);
        return(false);
    }

    if (memcmp (rem_bda, l2cb.ble_connecting_bda, BD_ADDR_LEN))
    {
        L2CAP_TRACE_WARNING ("L2CA_CancelBleConnectReq - different  BDA Connecting: %08x%04x  Cancel: %08x%04x",
        L2CAP_TRACE_WARNING ("%s - different  BDA Connecting: %08x%04x  Cancel: %08x%04x", __func__,
                              (l2cb.ble_connecting_bda[0]<<24)+(l2cb.ble_connecting_bda[1]<<16)+(l2cb.ble_connecting_bda[2]<<8)+l2cb.ble_connecting_bda[3],
                              (l2cb.ble_connecting_bda[4]<<8)+l2cb.ble_connecting_bda[5],
                              (rem_bda[0]<<24)+(rem_bda[1]<<16)+(rem_bda[2]<<8)+rem_bda[3], (rem_bda[4]<<8)+rem_bda[5]);

        btm_ble_dequeue_direct_conn_req(rem_bda);
        return(false);
    }