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

Commit 2f283223 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Remove bta_gattc_id2handle

Now that the instance id is equal to handle, we no longer need this
mapping function.

Bug: 27455533
Change-Id: I6760f8fc81460df8520d4ebf1899ed256ce5ad1e
parent 3ad93bf4
Loading
Loading
Loading
Loading
+55 −90
Original line number Original line Diff line number Diff line
@@ -1083,28 +1083,24 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
*******************************************************************************/
*******************************************************************************/
void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
{
    if (!bta_gattc_enqueue(p_clcb, p_data))
        return;

    UINT16 handle = 0;
    UINT16 handle = 0;
    tGATT_READ_PARAM    read_param;
    tGATT_READ_PARAM    read_param;
    tBTA_GATT_STATUS    status;
    tBTA_GATT_STATUS    status;


    memset (&read_param, 0 ,sizeof(tGATT_READ_PARAM));
    memset (&read_param, 0 ,sizeof(tGATT_READ_PARAM));


    if (bta_gattc_enqueue(p_clcb, p_data))
    if (p_data->api_write.p_descr_type == NULL)
    {
        handle = p_data->api_write.char_id.inst_id;
        if ((handle = bta_gattc_id2handle(p_clcb->p_srcb,
                                          &p_data->api_read.srvc_id,
                                          &p_data->api_read.char_id,
                                          p_data->api_read.p_descr_type)) == 0)
        {
            status = BTA_GATT_ERROR;
        }
    else
    else
        {
        handle = p_data->api_write.p_descr_type->inst_id;

    read_param.by_handle.handle = handle;
    read_param.by_handle.handle = handle;
    read_param.by_handle.auth_req = p_data->api_read.auth_req;
    read_param.by_handle.auth_req = p_data->api_read.auth_req;


    status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_HANDLE, &read_param);
    status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_HANDLE, &read_param);
        }


    /* read fail */
    /* read fail */
    if (status != BTA_GATT_OK)
    if (status != BTA_GATT_OK)
@@ -1116,7 +1112,6 @@ void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
        bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_READ, status, NULL);
        bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_READ, status, NULL);
    }
    }
}
}
}
/*******************************************************************************
/*******************************************************************************
**
**
** Function         bta_gattc_read_multi
** Function         bta_gattc_read_multi
@@ -1142,22 +1137,11 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
        {
        {
            handle = 0;
            handle = 0;


            if (p_id->id_type == BTA_GATT_TYPE_CHAR)
            if (p_id->id_type == BTA_GATT_TYPE_CHAR) {
            {
                handle = p_id->id_value.char_id.char_id.inst_id;
                handle = bta_gattc_id2handle(p_clcb->p_srcb,
            } else if (p_id->id_type == BTA_GATT_TYPE_CHAR_DESCR) {
                                     &p_id->id_value.char_id.srvc_id,
                handle = p_id->id_value.char_descr_id.descr_id.inst_id;
                                     &p_id->id_value.char_id.char_id,
            } else {
                                     NULL);
            }
            else if (p_id->id_type == BTA_GATT_TYPE_CHAR_DESCR)
            {
                handle = bta_gattc_id2handle(p_clcb->p_srcb,
                                     &p_id->id_value.char_descr_id.char_id.srvc_id,
                                     &p_id->id_value.char_descr_id.char_id.char_id,
                                     &p_id->id_value.char_descr_id.descr_id);
            }
            else
            {
                APPL_TRACE_ERROR("invalud ID type: %d", p_id->id_type);
                APPL_TRACE_ERROR("invalud ID type: %d", p_id->id_type);
            }
            }


@@ -1197,20 +1181,17 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
*******************************************************************************/
*******************************************************************************/
void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
{
    if (!bta_gattc_enqueue(p_clcb, p_data))
        return;

    UINT16              handle = 0;
    UINT16              handle = 0;
    tBTA_GATT_STATUS    status = BTA_GATT_OK;
    tBTA_GATT_STATUS    status = BTA_GATT_OK;


    if (bta_gattc_enqueue(p_clcb, p_data))
    if (p_data->api_write.p_descr_type == NULL)
    {
        handle = p_data->api_write.char_id.inst_id;
        if ((handle = bta_gattc_id2handle(p_clcb->p_srcb,
                                          &p_data->api_write.srvc_id,
                                          &p_data->api_write.char_id,
                                          p_data->api_write.p_descr_type)) == 0)
        {
            status = BTA_GATT_ERROR;
        }
    else
    else
        {
        handle = p_data->api_write.p_descr_type->inst_id;

    tGATT_VALUE attr;
    tGATT_VALUE attr;


    attr.conn_id = p_clcb->bta_conn_id;
    attr.conn_id = p_clcb->bta_conn_id;
@@ -1223,7 +1204,6 @@ void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
        memcpy(attr.value, p_data->api_write.p_value, p_data->api_write.len);
        memcpy(attr.value, p_data->api_write.p_value, p_data->api_write.len);


    status = GATTC_Write(p_clcb->bta_conn_id, p_data->api_write.write_type, &attr);
    status = GATTC_Write(p_clcb->bta_conn_id, p_data->api_write.write_type, &attr);
        }


    /* write fail */
    /* write fail */
    if (status != BTA_GATT_OK)
    if (status != BTA_GATT_OK)
@@ -1235,7 +1215,6 @@ void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
        bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_WRITE, status, NULL);
        bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_WRITE, status, NULL);
    }
    }
}
}
}
/*******************************************************************************
/*******************************************************************************
**
**
** Function         bta_gattc_execute
** Function         bta_gattc_execute
@@ -1273,33 +1252,19 @@ void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
*******************************************************************************/
*******************************************************************************/
void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
{
    UINT16 handle;
    UINT16 handle = p_data->api_confirm.char_id.inst_id;


    if ((handle = bta_gattc_id2handle(p_clcb->p_srcb,
                                      &p_data->api_confirm.srvc_id,
                                      &p_data->api_confirm.char_id,
                                      NULL)) == 0)
    {
        APPL_TRACE_ERROR("Can not map service/char ID into valid handle");
    }
    else
    {
    if (GATTC_SendHandleValueConfirm(p_data->api_confirm.hdr.layer_specific, handle)
    if (GATTC_SendHandleValueConfirm(p_data->api_confirm.hdr.layer_specific, handle)
            != GATT_SUCCESS)
        != GATT_SUCCESS) {
        {
            APPL_TRACE_ERROR("bta_gattc_confirm to handle [0x%04x] failed", handle);
            APPL_TRACE_ERROR("bta_gattc_confirm to handle [0x%04x] failed", handle);
        }
    } else {
        else
        {
        /* if over BR_EDR, inform PM for mode change */
        /* if over BR_EDR, inform PM for mode change */
            if (p_clcb->transport == BTA_TRANSPORT_BR_EDR)
        if (p_clcb->transport == BTA_TRANSPORT_BR_EDR) {
            {
            bta_sys_busy(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
            bta_sys_busy(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
            bta_sys_idle(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
            bta_sys_idle(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
        }
        }
    }
    }
}
}
}
/*******************************************************************************
/*******************************************************************************
**
**
** Function         bta_gattc_read_cmpl
** Function         bta_gattc_read_cmpl
+2 −0
Original line number Original line Diff line number Diff line
@@ -571,6 +571,7 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,


    memcpy(&p_buf->srvc_id, &p_char_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
    memcpy(&p_buf->srvc_id, &p_char_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
    memcpy(&p_buf->char_id, &p_char_id->char_id, sizeof(tBTA_GATT_ID));
    memcpy(&p_buf->char_id, &p_char_id->char_id, sizeof(tBTA_GATT_ID));
    p_buf->p_descr_type = NULL;


    p_buf->write_type = write_type;
    p_buf->write_type = write_type;
    p_buf->len = len;
    p_buf->len = len;
@@ -657,6 +658,7 @@ void BTA_GATTC_PrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,


    memcpy(&p_buf->srvc_id, &p_char_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
    memcpy(&p_buf->srvc_id, &p_char_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
    memcpy(&p_buf->char_id, &p_char_id->char_id, sizeof(tBTA_GATT_ID));
    memcpy(&p_buf->char_id, &p_char_id->char_id, sizeof(tBTA_GATT_ID));
    p_buf->p_descr_type = NULL;


    p_buf->write_type = BTA_GATTC_WRITE_PREPARE;
    p_buf->write_type = BTA_GATTC_WRITE_PREPARE;
    p_buf->offset   = offset;
    p_buf->offset   = offset;
+0 −19
Original line number Original line Diff line number Diff line
@@ -903,26 +903,7 @@ void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT
        }
        }
    }
    }
}
}
/*******************************************************************************
**
** Function         bta_gattc_id2handle
**
** Description      map GATT ID to handle in a given cache.
**
** Returns          the handle mapped. 0 if not found.
**
*******************************************************************************/
UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id,
                           tBTA_GATT_ID *p_char_id, tBTA_GATT_ID *p_descr_uuid)
{
    if (!p_service_id || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache))
        return 0;


    if (p_descr_uuid == NULL)
        return p_char_id->inst_id;

    return p_descr_uuid->inst_id;
}
/*******************************************************************************
/*******************************************************************************
**
**
** Function         bta_gattc_handle2id
** Function         bta_gattc_handle2id
+0 −1
Original line number Original line Diff line number Diff line
@@ -489,7 +489,6 @@ extern tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg)


extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);


extern UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id, tBTA_GATT_ID *p_char_id, tBTA_GATT_ID *p_descr_uuid);
extern BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SRVC_ID *service_id, tBTA_GATT_ID *char_id, tBTA_GATT_ID *p_type);
extern BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SRVC_ID *service_id, tBTA_GATT_ID *char_id, tBTA_GATT_ID *p_type);
extern BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_precise);
extern BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_precise);
extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB  *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY  *p_notify);
extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB  *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY  *p_notify);
+1 −2
Original line number Original line Diff line number Diff line
@@ -581,8 +581,7 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id,
                    /* It's enough to get service or characteristic handle, as
                    /* It's enough to get service or characteristic handle, as
                     * clear boundaries are always around service.
                     * clear boundaries are always around service.
                     */
                     */
                    handle = bta_gattc_id2handle(p_srcb, &p_clrcb->notif_reg[i].char_id.srvc_id,
                    handle = p_clrcb->notif_reg[i].char_id.char_id.inst_id;
                                                 &p_clrcb->notif_reg[i].char_id.char_id, NULL);
                    if (handle >= start_handle && handle <= end_handle)
                    if (handle >= start_handle && handle <= end_handle)
                        memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
                        memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
            }
            }