}
}
-/** start an application interface */
-void bta_gattc_start_if(uint8_t client_if) {
- if (!bta_gattc_cl_get_regcb(client_if)) {
- LOG(ERROR) << "Unable to start app.: Unknown client_if=" << +client_if;
- return;
- }
-
- GATT_StartIf(client_if);
-}
-
/** Register a GATT client application with BTA */
void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback,
BtaAppRegisterCallback cb) {
/* BTA use the same client interface as BTE GATT statck */
client_if = bta_gattc_cb.cl_rcb[i].client_if;
-
- do_in_main_thread(FROM_HERE,
- base::Bind(&bta_gattc_start_if, client_if));
-
status = GATT_SUCCESS;
break;
}
GATT_Register(p_msg->api_reg.app_uuid, &bta_gatts_cback);
if (!p_cb->rcb[first_unuse].gatt_if) {
status = GATT_NO_RESOURCES;
- } else {
- tBTA_GATTS_INT_START_IF* p_buf = (tBTA_GATTS_INT_START_IF*)osi_malloc(
- sizeof(tBTA_GATTS_INT_START_IF));
- p_buf->hdr.event = BTA_GATTS_INT_START_IF_EVT;
- p_buf->server_if = p_cb->rcb[first_unuse].gatt_if;
-
- bta_sys_sendmsg(p_buf);
}
} else {
status = GATT_NO_RESOURCES;
/*******************************************************************************
*
- * Function bta_gatts_start_if
- *
- * Description start an application interface.
- *
- * Returns none.
- *
- ******************************************************************************/
-void bta_gatts_start_if(UNUSED_ATTR tBTA_GATTS_CB* p_cb,
- tBTA_GATTS_DATA* p_msg) {
- if (bta_gatts_find_app_rcb_by_app_if(p_msg->int_start_if.server_if)) {
- GATT_StartIf(p_msg->int_start_if.server_if);
- } else {
- LOG(ERROR) << "Unable to start app.: Unknown interface="
- << +p_msg->int_start_if.server_if;
- }
-}
-/*******************************************************************************
- *
* Function bta_gatts_deregister
*
* Description deregister an application.
****************************************************************************/
enum {
BTA_GATTS_API_REG_EVT = BTA_SYS_EVT_START(BTA_ID_GATTS),
- BTA_GATTS_INT_START_IF_EVT,
BTA_GATTS_API_DEREG_EVT,
BTA_GATTS_API_INDICATION_EVT,
typedef struct {
BT_HDR hdr;
tGATT_IF server_if;
-} tBTA_GATTS_INT_START_IF;
-
-typedef tBTA_GATTS_INT_START_IF tBTA_GATTS_API_DEREG;
+} tBTA_GATTS_API_DEREG;
typedef struct {
BT_HDR hdr;
tBTA_GATTS_API_RSP api_rsp;
tBTA_GATTS_API_OPEN api_open;
tBTA_GATTS_API_CANCEL_OPEN api_cancel_open;
-
- tBTA_GATTS_INT_START_IF int_start_if;
} tBTA_GATTS_DATA;
/* application registration control block */
extern void bta_gatts_api_disable(tBTA_GATTS_CB* p_cb);
extern void bta_gatts_api_enable(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_data);
extern void bta_gatts_register(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg);
-extern void bta_gatts_start_if(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg);
extern void bta_gatts_deregister(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg);
extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB* p_srvc_cb,
tBTA_GATTS_DATA* p_msg);
bta_gatts_register(p_cb, (tBTA_GATTS_DATA*)p_msg);
break;
- case BTA_GATTS_INT_START_IF_EVT:
- bta_gatts_start_if(p_cb, (tBTA_GATTS_DATA*)p_msg);
- break;
-
case BTA_GATTS_API_DEREG_EVT:
bta_gatts_deregister(p_cb, (tBTA_GATTS_DATA*)p_msg);
break;
tmp.fill(0xAE);
test_cb.gatt_if = GATT_Register(bluetooth::Uuid::From128BitBE(tmp),
&btif_test_callbacks);
- GATT_StartIf(test_cb.gatt_if);
} else {
GATT_Deregister(test_cb.gatt_if);
test_cb.gatt_if = 0;
gatt_if = GATT_Register(app_uuid, &gap_cback);
- GATT_StartIf(gatt_if);
-
Uuid svc_uuid = Uuid::From16Bit(UUID_SERVCLASS_GAP_SERVER);
Uuid name_uuid = Uuid::From16Bit(GATT_UUID_GAP_DEVICE_NAME);
Uuid icon_uuid = Uuid::From16Bit(GATT_UUID_GAP_ICON);
/*******************************************************************************
*
- * Function GATT_StartIf
- *
- * Description This function is called after registration to start
- * receiving callbacks for registered interface. Function may
- * call back with connection status and queued notifications
- *
- * Parameter gatt_if: applicaiton interface.
- *
- * Returns None.
- *
- ******************************************************************************/
-void GATT_StartIf(tGATT_IF gatt_if) {
- tGATT_REG* p_reg;
- tGATT_TCB* p_tcb;
- RawAddress bda;
- uint8_t start_idx, found_idx;
- uint16_t conn_id;
- tGATT_TRANSPORT transport;
-
- VLOG(1) << __func__ << " gatt_if=" << +gatt_if;
- p_reg = gatt_get_regcb(gatt_if);
- if (p_reg != NULL) {
- start_idx = 0;
- while (
- gatt_find_the_connected_bda(start_idx, bda, &found_idx, &transport)) {
- p_tcb = gatt_find_tcb_by_addr(bda, transport);
- if (p_reg->app_cb.p_conn_cb && p_tcb) {
- conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
- (*p_reg->app_cb.p_conn_cb)(gatt_if, bda, conn_id, true, 0, transport);
- }
- start_idx = ++found_idx;
- }
- }
-}
-
-/*******************************************************************************
- *
* Function GATT_Connect
*
* Description This function initiate a connecttion to a remote device on
/* Create a GATT profile service */
gatt_cb.gatt_if = GATT_Register(Uuid::From128BitBE(tmp), &gatt_profile_cback);
- GATT_StartIf(gatt_cb.gatt_if);
Uuid service_uuid = Uuid::From16Bit(UUID_SERVCLASS_GATT_SERVER);
/*******************************************************************************
*
- * Function GATT_StartIf
- *
- * Description This function is called after registration to start
- * receiving callbacks for registered interface. Function may
- * call back with connection status and queued notifications
- *
- * Parameter gatt_if: applicaiton interface.
- *
- * Returns None
- *
- ******************************************************************************/
-extern void GATT_StartIf(tGATT_IF gatt_if);
-
-/*******************************************************************************
- *
* Function GATT_Connect
*
* Description This function initiate a connecttion to a remote device on
bluetooth::Uuid app_uuid =
bluetooth::Uuid::From16Bit(UUID_SERVCLASS_DEVICE_INFO);
srvc_eng_cb.gatt_if = GATT_Register(app_uuid, &srvc_gatt_cback);
- GATT_StartIf(srvc_eng_cb.gatt_if);
VLOG(1) << "Srvc_Init: gatt_if=" << +srvc_eng_cb.gatt_if;