Exemplo n.º 1
0
static bool background_connections_pending_cb(hash_map_entry_t *hash_entry, void *context) {
  bool *pending_connections = context;
  background_connection_t *connection = hash_entry->data;
  const bool connected = BTM_IsAclConnectionUp(connection->address.address, BT_TRANSPORT_LE);
  if (!connected) {
    *pending_connections = true;
    return false;
  }
  return true;
}
/*******************************************************************************
**
** Function         btm_ble_count_unconn_dev_in_whitelist
**
** Description      This function find the number of un-connected background device
*******************************************************************************/
UINT8 btm_ble_count_unconn_dev_in_whitelist(void)
{
    tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
    UINT8 i, count = 0;

    for (i = 0; i < BTM_BLE_MAX_BG_CONN_DEV_NUM; i ++)
    {
        if (p_cb->bg_dev_list[i].in_use &&
            !BTM_IsAclConnectionUp(p_cb->bg_dev_list[i].bd_addr, BT_TRANSPORT_LE))
        {
            count ++;
        }
    }
    return count;

}
Exemplo n.º 3
0
/*******************************************************************************
**
** Function         btm_ble_count_unconn_dev_in_whitelist
**
** Description      This function check the number of unconnected device in white list.
*******************************************************************************/
UINT8 btm_ble_count_unconn_dev_in_whitelist(void)
{
    tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
    UINT8 count = 0, i;
    BD_ADDR dummy_bda ={0};

    BTM_TRACE_EVENT0 ("btm_ble_find_dev_in_whitelist");

    for (i = 0; i < BTM_BLE_MAX_BG_CONN_DEV_NUM && i < p_cb->max_filter_entries; i ++)
    {
        if (memcmp(p_cb->bg_conn_dev_list[i], dummy_bda, BD_ADDR_LEN) != 0 &&
            !BTM_IsAclConnectionUp(p_cb->bg_conn_dev_list[i]))
        {
            count ++;
        }
    }
    return count;
}
/*******************************************************************************
**
** Function         btm_ble_count_unconn_dev_in_wl_irk
**
** Description      This function find the number of un-connected background device
*******************************************************************************/
UINT8 btm_ble_count_unconn_dev_in_wl_irk(void)
{
    tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
    UINT8 i, count = 0;

    for (i = 0; i < BTM_BLE_MAX_BG_CONN_DEV_NUM; i ++)
    {
        if (p_cb->bg_dev_list[i].in_use &&
            !BTM_IsAclConnectionUp(p_cb->bg_dev_list[i].bd_addr, BT_TRANSPORT_LE))
        {
            if(btm_ble_vendor_find_irk_entry_by_psuedo_addr(p_cb->bg_dev_list[i].bd_addr))
            {
                count ++;
            }
        }
    }
    return count;
}
/*******************************************************************************
**
** Function         BTM_SecDeleteDevice
**
** Description      Free resources associated with the device.
**
** Parameters:      bd_addr          - BD address of the peer
**
** Returns          TRUE if removed OK, FALSE if not found or ACL link is active
**
*******************************************************************************/
BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr)
{
    tBTM_SEC_DEV_REC  *p_dev_rec;

    if (BTM_IsAclConnectionUp(bd_addr))
    {
        BTM_TRACE_WARNING0("BTM_SecDeleteDevice FAILED: Cannot Delete when connection is active");
        return(FALSE);
    }

    if ((p_dev_rec = btm_find_dev (bd_addr)) == NULL)
        return(FALSE);

    btm_sec_free_dev (p_dev_rec);

    /* Tell controller to get rid of the link key if it has one stored */
    BTM_DeleteStoredLinkKey (bd_addr, NULL);

    return(TRUE);
}
Exemplo n.º 6
0
/*******************************************************************************
**
** Function         hidh_conn_snd_data
**
** Description      This function is sends out data.
**
** Returns          tHID_STATUS
**
*******************************************************************************/
tHID_STATUS hidh_conn_snd_data (UINT8 dhandle, UINT8 trans_type, UINT8 param,
                                UINT16 data, UINT8 report_id, BT_HDR *buf)
{
    tHID_CONN   *p_hcon = &hh_cb.devices[dhandle].conn;
    BT_HDR      *p_buf;
    UINT8       *p_out;
    UINT16      bytes_copied;
    BOOLEAN     seg_req = FALSE;
    UINT16      data_size;
    UINT16      cid;
    UINT8       pool_id;
    UINT8       use_data = 0 ;
    BOOLEAN     blank_datc = FALSE;

    if (!BTM_IsAclConnectionUp(hh_cb.devices[dhandle].addr, BT_TRANSPORT_BR_EDR))
    {
        if (buf)
            GKI_freebuf ((void *)buf);
        return( HID_ERR_NO_CONNECTION );
    }

    if (p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED)
    {
        if (buf)
            GKI_freebuf ((void *)buf);
        return( HID_ERR_CONGESTED );
    }

    switch( trans_type )
    {
    case HID_TRANS_CONTROL:
    case HID_TRANS_GET_REPORT:
    case HID_TRANS_SET_REPORT:
    case HID_TRANS_GET_PROTOCOL:
    case HID_TRANS_SET_PROTOCOL:
    case HID_TRANS_GET_IDLE:
    case HID_TRANS_SET_IDLE:
        cid = p_hcon->ctrl_cid;
        pool_id = HID_CONTROL_POOL_ID;
        break;
    case HID_TRANS_DATA:
        cid = p_hcon->intr_cid;
        pool_id = HID_INTERRUPT_POOL_ID;
        break;
    default:
        return (HID_ERR_INVALID_PARAM) ;
    }

    if( trans_type == HID_TRANS_SET_IDLE )
        use_data = 1;
    else if( (trans_type == HID_TRANS_GET_REPORT) && (param & 0x08) )
        use_data = 2;

    do
    {
        if ( buf == NULL || blank_datc )
        {
            if((p_buf = (BT_HDR *)GKI_getpoolbuf (pool_id)) == NULL)
                return (HID_ERR_NO_RESOURCES);

            p_buf->offset = L2CAP_MIN_OFFSET;
            seg_req = FALSE;
            data_size = 0;
            bytes_copied = 0;
            blank_datc = FALSE;
        }
        else if ( (buf->len > (p_hcon->rem_mtu_size - 1)))
        {
            if((p_buf = (BT_HDR *)GKI_getpoolbuf (pool_id)) == NULL)
                return (HID_ERR_NO_RESOURCES);

            p_buf->offset = L2CAP_MIN_OFFSET;
            seg_req = TRUE;
            data_size = buf->len;
            bytes_copied = p_hcon->rem_mtu_size - 1;
        }
        else
        {
            p_buf = buf ;
            p_buf->offset -= 1;
            seg_req = FALSE;
            data_size = buf->len;
            bytes_copied = buf->len;
        }

        p_out         = (UINT8 *)(p_buf + 1) + p_buf->offset;
        *p_out++      = HID_BUILD_HDR(trans_type, param);

        /* If report ID required for this device */
        if( (trans_type == HID_TRANS_GET_REPORT) && (report_id != 0) )
        {
            *p_out = report_id;
            data_size = bytes_copied = 1;
        }


        if (seg_req)
        {
            memcpy (p_out, (((UINT8 *)(buf+1)) + buf->offset), bytes_copied);
            buf->offset += bytes_copied;
            buf->len -= bytes_copied;
        }
        else if( use_data == 1)
        {
            *(p_out+bytes_copied) = data & 0xff;
        }
        else if( use_data == 2 )
        {
            *(p_out+bytes_copied) = data & 0xff;
            *(p_out+bytes_copied+1) = (data >> 8) & 0xff ;
        }

        p_buf->len   = bytes_copied + 1 + use_data;
        data_size    -= bytes_copied;

        /* Send the buffer through L2CAP */
        if ((p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED) || (!L2CA_DataWrite (cid, p_buf)))
            return (HID_ERR_CONGESTED);

        if (data_size)
            trans_type = HID_TRANS_DATAC;
        else if( bytes_copied == (p_hcon->rem_mtu_size - 1) )
        {
            trans_type = HID_TRANS_DATAC;
            blank_datc = TRUE;
        }

    } while ((data_size != 0) || blank_datc ) ;