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

Commit bb2ed405 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Simplify BTA_GATTC_Listen"

parents 8adf9308 fcea15e8
Loading
Loading
Loading
Loading
+0 −53
Original line number Diff line number Diff line
@@ -1895,57 +1895,4 @@ static void bta_gattc_cong_cback (uint16_t conn_id, bool congested)
        }
    }
}

#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
**
** Function         bta_gattc_listen
**
** Description      Start or stop a listen for connection
**
** Returns          void
**
********************************************************************************/
void bta_gattc_listen(tBTA_GATTC_DATA * p_msg)
{
    tBTA_GATTC_RCB      *p_clreg = bta_gattc_cl_get_regcb(p_msg->api_listen.client_if);
    tBTA_GATTC          cb_data;

    cb_data.reg_oper.status = BTA_GATT_ERROR;
    cb_data.reg_oper.client_if = p_msg->api_listen.client_if;

    if (p_clreg == NULL)
    {
        APPL_TRACE_ERROR("bta_gattc_listen failed, unknown client_if: %d",
                            p_msg->api_listen.client_if);
        return;
    }
    /* mark bg conn record */
    GATT_Listen(p_msg->api_listen.start);
    cb_data.status = BTA_GATT_OK;

    (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data);
}

/*******************************************************************************
**
** Function         bta_gattc_broadcast
**
** Description      Start or stop broadcasting
**
** Returns          void
**
********************************************************************************/
void bta_gattc_broadcast(tBTA_GATTC_DATA * p_msg)
{
    tBTA_GATTC_RCB      *p_clreg = bta_gattc_cl_get_regcb(p_msg->api_listen.client_if);
    tBTA_GATTC          cb_data;

    cb_data.reg_oper.client_if = p_msg->api_listen.client_if;
    cb_data.reg_oper.status = BTM_BleBroadcast(p_msg->api_listen.start);

    if (p_clreg && p_clreg->p_cback)
        (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data);
}
#endif // BLE_INCLUDED
#endif // BTA_GATT_INCLUDED == TRUE && BLE_INCLUDED == TRUE
+8 −20
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@

#if (BTA_GATT_INCLUDED == TRUE)

#include <base/callback.h>
#include <string.h>
#include "bt_common.h"
#include "bta_sys.h"
@@ -724,22 +725,15 @@ void BTA_GATTC_Refresh(const BD_ADDR remote_bda)
** Description      Start advertisement to listen for connection request for a GATT
**                  client application.
**
** Parameters       client_if: server interface.
**                  start: to start or stop listening for connection
** Parameters       start: to start or stop listening for connection
**
** Returns          void
**
*******************************************************************************/
void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start)
void BTA_GATTC_Listen(bool start, base::Callback<void(uint8_t /* status */)> cb)
{
    tBTA_GATTC_API_LISTEN *p_buf =
        (tBTA_GATTC_API_LISTEN *)osi_malloc(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN);

    p_buf->hdr.event = BTA_GATTC_API_LISTEN_EVT;
    p_buf->client_if = client_if;
    p_buf->start = start;

    bta_sys_sendmsg(p_buf);
    GATT_Listen(start);
    cb.Run(BTA_GATT_OK);
}

/*******************************************************************************
@@ -754,16 +748,10 @@ void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start)
** Returns          void
**
*******************************************************************************/
void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, bool start)
void BTA_GATTC_Broadcast(bool start, base::Callback<void(uint8_t /* status */)> cb)
{
    tBTA_GATTC_API_LISTEN *p_buf =
        (tBTA_GATTC_API_LISTEN *)osi_malloc(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN);

    p_buf->hdr.event = BTA_GATTC_API_BROADCAST_EVT;
    p_buf->client_if = client_if;
    p_buf->start = start;

    bta_sys_sendmsg(p_buf);
    uint8_t status = BTM_BleBroadcast(start);
    cb.Run(status);
}

#endif /* BTA_GATT_INCLUDED */
+0 −12
Original line number Diff line number Diff line
@@ -63,8 +63,6 @@ enum
    BTA_GATTC_INT_START_IF_EVT,
    BTA_GATTC_API_REG_EVT,
    BTA_GATTC_API_DEREG_EVT,
    BTA_GATTC_API_LISTEN_EVT,
    BTA_GATTC_API_BROADCAST_EVT,
    BTA_GATTC_API_DISABLE_EVT,
    BTA_GATTC_ENC_CMPL_EVT
};
@@ -178,14 +176,6 @@ typedef struct
    uint16_t                  handles[GATT_MAX_READ_MULTI_HANDLES];
}tBTA_GATTC_API_READ_MULTI;

typedef struct
{
    BT_HDR                  hdr;
    tBTA_GATTC_IF           client_if;
    bool                 start;
} tBTA_GATTC_API_LISTEN;


typedef struct
{
    BT_HDR              hdr;
@@ -229,8 +219,6 @@ typedef union

    tBTA_GATTC_INT_START_IF     int_start_if;
    tBTA_GATTC_INT_DEREG        int_dereg;
    /* if peripheral role is supported */
    tBTA_GATTC_API_LISTEN       api_listen;

} tBTA_GATTC_DATA;

+0 −11
Original line number Diff line number Diff line
@@ -365,15 +365,6 @@ bool bta_gattc_hdl_event(BT_HDR *p_msg)
            bta_gattc_process_api_refresh((tBTA_GATTC_DATA *) p_msg);
            break;

#if (BLE_INCLUDED == TRUE)
        case BTA_GATTC_API_LISTEN_EVT:
            bta_gattc_listen((tBTA_GATTC_DATA *) p_msg);
            break;
        case BTA_GATTC_API_BROADCAST_EVT:
            bta_gattc_broadcast((tBTA_GATTC_DATA *) p_msg);
            break;
#endif

        case BTA_GATTC_ENC_CMPL_EVT:
            bta_gattc_process_enc_cmpl((tBTA_GATTC_DATA *) p_msg);
            break;
@@ -461,8 +452,6 @@ static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)
            return "BTA_GATTC_API_DEREG_EVT";
        case BTA_GATTC_API_REFRESH_EVT:
            return "BTA_GATTC_API_REFRESH_EVT";
        case BTA_GATTC_API_LISTEN_EVT:
            return "BTA_GATTC_API_LISTEN_EVT";
        case BTA_GATTC_API_DISABLE_EVT:
            return "BTA_GATTC_API_DISABLE_EVT";
        case BTA_GATTC_API_CFG_MTU_EVT:
+3 −4
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "gatt_api.h"
#include "osi/include/list.h"

#include <base/callback_forward.h>
#include <vector>

using std::vector;
@@ -126,7 +127,6 @@ typedef uint8_t tBTA_GATT_STATUS;
#define BTA_GATTC_ACL_EVT           13  /* ACL up event */
#define BTA_GATTC_CANCEL_OPEN_EVT   14  /* cancel open event */
#define BTA_GATTC_SRVC_CHG_EVT      15  /* service change event */
#define BTA_GATTC_LISTEN_EVT        16  /* listen event */
#define BTA_GATTC_ENC_CMPL_CB_EVT   17  /* encryption complete callback event */
#define BTA_GATTC_CFG_MTU_EVT       18  /* configure MTU complete event */
#define BTA_GATTC_CONGEST_EVT       24  /* Congestion event */
@@ -368,7 +368,6 @@ typedef void (tBTA_GATTC_CBACK)(tBTA_GATTC_EVT event, tBTA_GATTC *p_data);
#define BTA_GATTS_OPEN_EVT                              16
#define BTA_GATTS_CANCEL_OPEN_EVT                       17
#define BTA_GATTS_CLOSE_EVT                             18
#define BTA_GATTS_LISTEN_EVT                            19
#define BTA_GATTS_CONGEST_EVT                           20

typedef uint8_t  tBTA_GATTS_EVT;
@@ -936,7 +935,7 @@ extern void BTA_GATTC_Refresh(const BD_ADDR remote_bda);
** Returns          void
**
*******************************************************************************/
extern void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start);
extern void BTA_GATTC_Listen(bool start, base::Callback<void(uint8_t /* status */)> cb);

/*******************************************************************************
**
@@ -950,7 +949,7 @@ extern void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, bool start);
** Returns          void
**
*******************************************************************************/
extern void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, bool start);
extern void BTA_GATTC_Broadcast(bool start, base::Callback<void(uint8_t /* status */)> cb);


/*******************************************************************************
Loading