From a4611ac05f07360785adcff8640da01a3894e4c5 Mon Sep 17 00:00:00 2001 From: Andre Eisenbach Date: Wed, 5 Mar 2014 15:41:53 -0800 Subject: [PATCH] DO NOT MERGE: cherrypick from master to fix b/13289050 LE: Add status callback function for LE broadcasts Change-Id: If4342050ce1141a9c2111286e7b3cccdc012a91e --- bta/gatt/bta_gattc_act.c | 22 ++++++++++++++++++++++ bta/gatt/bta_gattc_api.c | 26 ++++++++++++++++++++++++++ bta/gatt/bta_gattc_int.h | 2 ++ bta/gatt/bta_gattc_main.c | 3 +++ bta/include/bta_gatt_api.h | 15 +++++++++++++++ btif/src/btif_gatt_client.c | 2 +- 6 files changed, 69 insertions(+), 1 deletion(-) diff --git a/bta/gatt/bta_gattc_act.c b/bta/gatt/bta_gattc_act.c index 444c357a7..7563ec350 100644 --- a/bta/gatt/bta_gattc_act.c +++ b/bta/gatt/bta_gattc_act.c @@ -2128,5 +2128,27 @@ void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg) } } } + +/******************************************************************************* +** +** Function bta_gattc_broadcast +** +** Description Start or stop broadcasting +** +** Returns void +** +********************************************************************************/ +void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, 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; + (void)(p_cb); + + 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 #endif diff --git a/bta/gatt/bta_gattc_api.c b/bta/gatt/bta_gattc_api.c index fff1a55ad..d264458e0 100644 --- a/bta/gatt/bta_gattc_api.c +++ b/bta/gatt/bta_gattc_api.c @@ -1056,5 +1056,31 @@ void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target return; } +/******************************************************************************* +** +** Function BTA_GATTC_Broadcast +** +** Description Start broadcasting (non-connectable advertisements) +** +** Parameters client_if: client interface. +** start: to start or stop listening for connection +** +** Returns void +** +*******************************************************************************/ +void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start) +{ + tBTA_GATTC_API_LISTEN *p_buf; + + if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL) + { + p_buf->hdr.event = BTA_GATTC_API_BROADCAST_EVT; + p_buf->client_if = client_if; + p_buf->start = start; + bta_sys_sendmsg(p_buf); + } + return; +} + #endif /* BTA_GATT_INCLUDED */ diff --git a/bta/gatt/bta_gattc_int.h b/bta/gatt/bta_gattc_int.h index 1ff8f79f2..255090da7 100644 --- a/bta/gatt/bta_gattc_int.h +++ b/bta/gatt/bta_gattc_int.h @@ -69,6 +69,7 @@ enum 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 }; @@ -484,6 +485,7 @@ extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg); #if BLE_INCLUDED == TRUE extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg); +extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg); #endif /* utility functions */ extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda); diff --git a/bta/gatt/bta_gattc_main.c b/bta/gatt/bta_gattc_main.c index 650cf5ee5..638f2f906 100644 --- a/bta/gatt/bta_gattc_main.c +++ b/bta/gatt/bta_gattc_main.c @@ -385,6 +385,9 @@ BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg) case BTA_GATTC_API_LISTEN_EVT: bta_gattc_listen(p_cb, (tBTA_GATTC_DATA *) p_msg); break; + case BTA_GATTC_API_BROADCAST_EVT: + bta_gattc_broadcast(p_cb, (tBTA_GATTC_DATA *) p_msg); + break; #endif case BTA_GATTC_ENC_CMPL_EVT: diff --git a/bta/include/bta_gatt_api.h b/bta/include/bta_gatt_api.h index bf0d98c50..7c974c51d 100644 --- a/bta/include/bta_gatt_api.h +++ b/bta/include/bta_gatt_api.h @@ -1031,6 +1031,21 @@ BTA_API extern void BTA_GATTC_Refresh(BD_ADDR remote_bda); BTA_API extern void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target_bda); /******************************************************************************* +** +** Function BTA_GATTC_Broadcast +** +** Description Start broadcasting (non-connectable advertisements) +** +** Parameters client_if: client interface. +** start: to start or stop listening for connection +** +** Returns void +** +*******************************************************************************/ +BTA_API extern void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start); + + +/******************************************************************************* ** BTA GATT Server API ********************************************************************************/ diff --git a/btif/src/btif_gatt_client.c b/btif/src/btif_gatt_client.c index 524052f0c..6aab9867a 100644 --- a/btif/src/btif_gatt_client.c +++ b/btif/src/btif_gatt_client.c @@ -843,7 +843,7 @@ static void btgattc_handle_event(uint16_t event, char* p_param) #ifdef BLE_PERIPHERAL_MODE_SUPPORT BTA_GATTC_Listen(p_cb->client_if, p_cb->start, NULL); #else - BTA_DmBleBroadcast(p_cb->start); + BTA_GATTC_Broadcast(p_cb->client_if, p_cb->start); #endif break; -- 2.11.0