From 2647452211f7beaee19610fe79442828ab2b0ee6 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Wed, 4 Oct 2017 12:22:10 -0700 Subject: [PATCH] Use LOG() macros in BTA GATT logging Test: compilation test Change-Id: If7676af5bf915df57ab6e876d2f27500ebf5c07d --- bta/gatt/bta_gattc_act.cc | 135 ++++++++++++++++++------------------- bta/gatt/bta_gattc_api.cc | 23 ++++--- bta/gatt/bta_gattc_cache.cc | 159 +++++++++++++++++++++----------------------- bta/gatt/bta_gattc_int.h | 3 + bta/gatt/bta_gattc_main.cc | 29 ++++---- bta/gatt/bta_gattc_utils.cc | 27 ++++---- bta/gatt/bta_gatts_act.cc | 70 +++++++++---------- bta/gatt/bta_gatts_api.cc | 6 +- bta/gatt/bta_gatts_int.h | 1 + bta/gatt/bta_gatts_main.cc | 5 +- bta/gatt/bta_gatts_utils.cc | 6 +- include/bt_trace.h | 19 ++++++ 12 files changed, 248 insertions(+), 235 deletions(-) diff --git a/bta/gatt/bta_gattc_act.cc b/bta/gatt/bta_gattc_act.cc index 30bd3dcaa..540715a94 100644 --- a/bta/gatt/bta_gattc_act.cc +++ b/bta/gatt/bta_gattc_act.cc @@ -44,6 +44,7 @@ #include "bta_hh_int.h" #endif +using base::StringPrintf; using bluetooth::Uuid; /***************************************************************************** @@ -119,14 +120,14 @@ void bta_gattc_reset_discover_st(tBTA_GATTC_SERV* p_srcb, tGATT_STATUS status); * ******************************************************************************/ static void bta_gattc_enable() { - APPL_TRACE_DEBUG("%s", __func__); + VLOG(1) << __func__; if (bta_gattc_cb.state == BTA_GATTC_STATE_DISABLED) { /* initialize control block */ bta_gattc_cb = tBTA_GATTC_CB(); bta_gattc_cb.state = BTA_GATTC_STATE_ENABLED; } else { - APPL_TRACE_DEBUG("GATTC is already enabled"); + VLOG(1) << "GATTC is already enabled"; } } @@ -143,10 +144,10 @@ static void bta_gattc_enable() { void bta_gattc_disable() { uint8_t i; - APPL_TRACE_DEBUG("%s", __func__); + VLOG(1) << __func__; if (bta_gattc_cb.state != BTA_GATTC_STATE_ENABLED) { - APPL_TRACE_ERROR("not enabled, or disabled in progress"); + LOG(ERROR) << "not enabled, or disabled in progress"; return; } @@ -175,7 +176,7 @@ void bta_gattc_disable() { /** start an application interface */ void bta_gattc_start_if(uint8_t client_if) { if (!bta_gattc_cl_get_regcb(client_if)) { - APPL_TRACE_ERROR("Unable to start app.: Unknown interface =%d", client_if); + LOG(ERROR) << "Unable to start app.: Unknown client_if=" << +client_if; return; } @@ -187,7 +188,7 @@ void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback, BtaAppRegisterCallback cb) { tGATT_STATUS status = GATT_NO_RESOURCES; uint8_t client_if = 0; - APPL_TRACE_DEBUG("%s: state %d", __func__, bta_gattc_cb.state); + VLOG(1) << __func__ << ": state:" << +bta_gattc_cb.state; /* check if GATTC module is already enabled . Else enable */ if (bta_gattc_cb.state == BTA_GATTC_STATE_DISABLED) { @@ -198,7 +199,7 @@ void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback, if (!bta_gattc_cb.cl_rcb[i].in_use) { if ((bta_gattc_cb.cl_rcb[i].client_if = GATT_Register(app_uuid, &bta_gattc_cl_cback)) == 0) { - APPL_TRACE_ERROR("Register with GATT stack failed."); + LOG(ERROR) << "Register with GATT stack failed."; status = GATT_ERROR; } else { bta_gattc_cb.cl_rcb[i].in_use = true; @@ -261,7 +262,7 @@ void bta_gattc_deregister(tBTA_GATTC_RCB* p_clreg) { } else bta_gattc_deregister_cmpl(p_clreg); } else { - APPL_TRACE_ERROR("%s: Deregister Failed unknown client cif", __func__); + LOG(ERROR) << __func__ << ": Deregister Failed unknown client cif"; bta_hh_cleanup_disable(BTA_HH_OK); } } @@ -287,7 +288,7 @@ void bta_gattc_process_api_open(tBTA_GATTC_DATA* p_msg) { if (p_clcb != NULL) { bta_gattc_sm_execute(p_clcb, event, p_msg); } else { - APPL_TRACE_ERROR("No resources to open a new connection."); + LOG(ERROR) << "No resources to open a new connection."; bta_gattc_send_open_cback( p_clreg, GATT_NO_RESOURCES, p_msg->api_conn.remote_bda, @@ -297,8 +298,8 @@ void bta_gattc_process_api_open(tBTA_GATTC_DATA* p_msg) { bta_gattc_init_bk_conn(&p_msg->api_conn, p_clreg); } } else { - APPL_TRACE_ERROR("%s: Failed, unknown client_if: %d", __func__, - p_msg->api_conn.client_if); + LOG(ERROR) << __func__ + << ": Failed, unknown client_if=" << p_msg->api_conn.client_if; } } /******************************************************************************* @@ -323,7 +324,7 @@ void bta_gattc_process_api_open_cancel(tBTA_GATTC_DATA* p_msg) { if (p_clcb != NULL) { bta_gattc_sm_execute(p_clcb, event, p_msg); } else { - APPL_TRACE_ERROR("No such connection need to be cancelled"); + LOG(ERROR) << "No such connection need to be cancelled"; p_clreg = bta_gattc_cl_get_regcb(p_msg->api_cancel_conn.client_if); @@ -384,7 +385,7 @@ void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB* p_clcb, ******************************************************************************/ void bta_gattc_open_error(tBTA_GATTC_CLCB* p_clcb, UNUSED_ATTR tBTA_GATTC_DATA* p_data) { - APPL_TRACE_ERROR("Connection already opened. wrong state"); + LOG(ERROR) << "Connection already opened. wrong state"; bta_gattc_send_open_cback(p_clcb->p_rcb, GATT_SUCCESS, p_clcb->bda, p_clcb->bta_conn_id, p_clcb->transport, 0); @@ -400,9 +401,9 @@ void bta_gattc_open_error(tBTA_GATTC_CLCB* p_clcb, ******************************************************************************/ void bta_gattc_open_fail(tBTA_GATTC_CLCB* p_clcb, UNUSED_ATTR tBTA_GATTC_DATA* p_data) { - APPL_TRACE_WARNING( - "%s: Cannot establish Connection. conn_id=%d. Return GATT_ERROR(%d).", - __func__, p_clcb->bta_conn_id, GATT_ERROR); + LOG(WARNING) << __func__ << ": Cannot establish Connection. conn_id=" + << +p_clcb->bta_conn_id << ". Return GATT_ERROR(" << +GATT_ERROR + << ")"; bta_gattc_send_open_cback(p_clcb->p_rcb, GATT_ERROR, p_clcb->bda, p_clcb->bta_conn_id, p_clcb->transport, 0); @@ -426,7 +427,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, true, p_data->api_conn.transport, p_data->api_conn.opportunistic, p_data->api_conn.initiating_phys)) { - APPL_TRACE_ERROR("Connection open failure"); + LOG(ERROR) << "Connection open failure"; bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_OPEN_FAIL_EVT, p_data); } else { @@ -462,7 +463,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN* p_data, if (!GATT_Connect(p_data->client_if, p_data->remote_bda, false, p_data->transport, false)) { status = GATT_ERROR; - LOG(ERROR) << __func__ << " unable to connect to remote bd_addr:" + LOG(ERROR) << __func__ << " unable to connect to remote bd_addr=" << p_data->remote_bda; } else { @@ -509,7 +510,7 @@ void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN* p_data) { if (GATT_CancelConnect(p_data->client_if, p_data->remote_bda, false)) { cb_data.status = GATT_SUCCESS; } else { - APPL_TRACE_ERROR("%s: failed", __func__); + LOG(ERROR) << __func__ << ": failed"; } } p_clreg = bta_gattc_cl_get_regcb(p_data->client_if); @@ -571,11 +572,10 @@ void bta_gattc_cancel_open(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { ******************************************************************************/ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { tGATT_IF gatt_if; - APPL_TRACE_DEBUG("%s: server cache state=%d", __func__, - p_clcb->p_srcb->state); + VLOG(1) << __func__ << ": server cache state=" << +p_clcb->p_srcb->state; if (p_data != NULL) { - APPL_TRACE_DEBUG("%s: conn_id=%d", __func__, p_data->hdr.layer_specific); + VLOG(1) << __func__ << ": conn_id=" << +p_data->hdr.layer_specific; p_clcb->bta_conn_id = p_data->int_conn.hdr.layer_specific; GATT_GetConnectionInfor(p_data->hdr.layer_specific, &gatt_if, p_clcb->bda, @@ -642,8 +642,8 @@ void bta_gattc_close_fail(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { cb_data.close.status = GATT_ERROR; cb_data.close.reason = BTA_GATT_CONN_NONE; - APPL_TRACE_WARNING("%s: conn_id=%d. Returns GATT_ERROR (%d).", __func__, - cb_data.close.conn_id, GATT_ERROR); + LOG(WARNING) << __func__ << ": conn_id=" << loghex(cb_data.close.conn_id) + << ". Returns GATT_ERROR(" << +GATT_ERROR << ")."; (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CLOSE_EVT, &cb_data); } @@ -662,7 +662,7 @@ void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { tBTA_GATTC_RCB* p_clreg = p_clcb->p_rcb; tBTA_GATTC cb_data; - APPL_TRACE_DEBUG("%s: conn_id=%d", __func__, p_clcb->bta_conn_id); + VLOG(1) << __func__ << ": conn_id=" << +p_clcb->bta_conn_id; cb_data.close.client_if = p_clcb->p_rcb->client_if; cb_data.close.conn_id = p_clcb->bta_conn_id; @@ -718,8 +718,7 @@ void bta_gattc_reset_discover_st(tBTA_GATTC_SERV* p_srcb, tGATT_STATUS status) { * ******************************************************************************/ void bta_gattc_disc_close(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { - APPL_TRACE_DEBUG("%s: Discovery cancel conn_id=%d", __func__, - p_clcb->bta_conn_id); + VLOG(1) << __func__ << ": Discovery cancel conn_id=" << +p_clcb->bta_conn_id; if (p_clcb->disc_active) bta_gattc_reset_discover_st(p_clcb->p_srcb, GATT_ERROR); @@ -730,9 +729,7 @@ void bta_gattc_disc_close(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { // while in the BTA_GATTC_DISCOVER_ST state. Once the state changes, the // connection itself still needs to be closed to resolve the original event. if (p_clcb->state == BTA_GATTC_CONN_ST) { - APPL_TRACE_DEBUG( - "State is back to BTA_GATTC_CONN_ST. " - "Trigger connection close"); + VLOG(1) << "State is back to BTA_GATTC_CONN_ST. Trigger connection close"; bta_gattc_close(p_clcb, p_data); } } @@ -810,8 +807,8 @@ void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { ******************************************************************************/ void bta_gattc_start_discover(tBTA_GATTC_CLCB* p_clcb, UNUSED_ATTR tBTA_GATTC_DATA* p_data) { - APPL_TRACE_DEBUG("%s: conn_id=%d p_clcb->p_srcb->state = %d ", __func__, - p_clcb->bta_conn_id, p_clcb->p_srcb->state); + VLOG(1) << __func__ << ": conn_id:" << +p_clcb->bta_conn_id + << " p_clcb->p_srcb->state:" << +p_clcb->p_srcb->state; if (((p_clcb->p_q_cmd == NULL || p_clcb->auto_update == BTA_GATTC_REQ_WAITING) && @@ -839,12 +836,12 @@ void bta_gattc_start_discover(tBTA_GATTC_CLCB* p_clcb, p_clcb->bta_conn_id, p_clcb->p_srcb, GATT_DISC_SRVC_ALL); } if (p_clcb->status != GATT_SUCCESS) { - APPL_TRACE_ERROR("discovery on server failed"); + LOG(ERROR) << "discovery on server failed"; bta_gattc_reset_discover_st(p_clcb->p_srcb, p_clcb->status); } else p_clcb->disc_active = true; } else { - APPL_TRACE_ERROR("unknown device, can not start discovery"); + LOG(ERROR) << "unknown device, can not start discovery"; } } /* pending operation, wait until it finishes */ @@ -868,7 +865,7 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB* p_clcb, UNUSED_ATTR tBTA_GATTC_DATA* p_data) { tBTA_GATTC_DATA* p_q_cmd = p_clcb->p_q_cmd; - APPL_TRACE_DEBUG("%s: conn_id=%d", __func__, p_clcb->bta_conn_id); + VLOG(1) << __func__ << ": conn_id=" << +p_clcb->bta_conn_id; if (p_clcb->transport == BTA_TRANSPORT_LE) L2CA_EnableUpdateBleConnParams(p_clcb->p_srcb->server_bda, true); @@ -1053,7 +1050,7 @@ void bta_gattc_confirm(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { if (GATTC_SendHandleValueConfirm(p_data->api_confirm.hdr.layer_specific, handle) != GATT_SUCCESS) { - APPL_TRACE_ERROR("%s: to handle [0x%04x] failed", __func__, handle); + LOG(ERROR) << __func__ << ": to handle=" << loghex(handle) << " failed"; } else { /* if over BR_EDR, inform PM for mode change */ if (p_clcb->transport == BTA_TRANSPORT_BR_EDR) { @@ -1170,13 +1167,13 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { uint8_t op = (uint8_t)p_data->op_cmpl.op_code; uint8_t mapped_op = 0; - APPL_TRACE_DEBUG("%s: op = %d", __func__, op); + VLOG(1) << __func__ << ": op:" << +op; if (op == GATTC_OPTYPE_INDICATION || op == GATTC_OPTYPE_NOTIFICATION) { - APPL_TRACE_ERROR("unexpected operation, ignored"); + LOG(ERROR) << "unexpected operation, ignored"; } else if (op >= GATTC_OPTYPE_READ) { if (p_clcb->p_q_cmd == NULL) { - APPL_TRACE_ERROR("No pending command"); + LOG(ERROR) << "No pending command"; return; } if (p_clcb->p_q_cmd->hdr.event != @@ -1185,7 +1182,7 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { GATTC_OPTYPE_READ; if (mapped_op > GATTC_OPTYPE_INDICATION) mapped_op = 0; - APPL_TRACE_ERROR( + LOG(ERROR) << StringPrintf( "expect op:(%s :0x%04x), receive unexpected operation (%s).", bta_gattc_op_code_name[mapped_op], p_clcb->p_q_cmd->hdr.event, bta_gattc_op_code_name[op]); @@ -1197,8 +1194,8 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { */ if (p_clcb->auto_update == BTA_GATTC_DISC_WAITING && p_clcb->p_srcb->srvc_hdl_chg && op != GATTC_OPTYPE_CONFIG) { - APPL_TRACE_DEBUG( - "Discard all responses when service change indication is received."); + VLOG(1) << "Discard all responses when service change indication is " + "received."; p_data->op_cmpl.status = GATT_ERROR; } @@ -1234,7 +1231,7 @@ void bta_gattc_ignore_op_cmpl(UNUSED_ATTR tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { /* receive op complete when discovery is started, ignore the response, and wait for discovery finish and resent */ - APPL_TRACE_DEBUG("%s: op = %d", __func__, p_data->hdr.layer_specific); + VLOG(1) << __func__ << ": op = " << +p_data->hdr.layer_specific; } /******************************************************************************* * @@ -1248,7 +1245,7 @@ void bta_gattc_ignore_op_cmpl(UNUSED_ATTR tBTA_GATTC_CLCB* p_clcb, void bta_gattc_search(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { tGATT_STATUS status = GATT_INTERNAL_ERROR; tBTA_GATTC cb_data; - APPL_TRACE_DEBUG("%s: conn_id=%d", __func__, p_clcb->bta_conn_id); + VLOG(1) << __func__ << ": conn_id=" << +p_clcb->bta_conn_id; if (p_clcb->p_srcb && !p_clcb->p_srcb->srvc_cache.empty()) { status = GATT_SUCCESS; /* search the local cache of a server device */ @@ -1286,8 +1283,7 @@ void bta_gattc_q_cmd(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { void bta_gattc_fail(tBTA_GATTC_CLCB* p_clcb, UNUSED_ATTR tBTA_GATTC_DATA* p_data) { if (p_clcb->status == GATT_SUCCESS) { - APPL_TRACE_ERROR("operation not supported at current state [%d]", - p_clcb->state); + LOG(ERROR) << "operation not supported at current state " << +p_clcb->state; } } @@ -1335,8 +1331,9 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, const RawAddress& bdaddr, tGATT_DISCONN_REASON reason, tBT_TRANSPORT transport) { if (reason != 0) { - APPL_TRACE_WARNING("%s() - cif=%d connected=%d conn_id=%d reason=0x%04x", - __func__, gattc_if, connected, conn_id, reason); + LOG(WARNING) << __func__ << ": cif=" << +gattc_if + << " connected=" << connected << " conn_id=" << loghex(conn_id) + << " reason=" << loghex(reason); } if (connected) @@ -1383,7 +1380,7 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, const RawAddress& bda) { } #endif - APPL_TRACE_DEBUG("%s: cif = %d", __func__, gattc_if); + VLOG(1) << __func__ << ": cif:" << +gattc_if; do_in_bta_thread(FROM_HERE, base::Bind(&bta_gattc_process_enc_cmpl, gattc_if, bda)); @@ -1449,9 +1446,8 @@ bool bta_gattc_process_srvc_chg_ind(uint16_t conn_id, tBTA_GATTC_RCB* p_clrcb, if (p_char && p_char->service->uuid == gattp_uuid && p_char->uuid == srvc_chg_uuid) { if (att_value->len != BTA_GATTC_SERVICE_CHANGED_LEN) { - APPL_TRACE_ERROR( - "%s: received malformed service changed indication, skipping", - __func__); + LOG(ERROR) << __func__ + << ": received malformed service changed indication, skipping"; return false; } @@ -1459,8 +1455,8 @@ bool bta_gattc_process_srvc_chg_ind(uint16_t conn_id, tBTA_GATTC_RCB* p_clrcb, uint16_t s_handle = ((uint16_t)(*(p)) + (((uint16_t)(*(p + 1))) << 8)); uint16_t e_handle = ((uint16_t)(*(p + 2)) + (((uint16_t)(*(p + 3))) << 8)); - APPL_TRACE_ERROR("%s: service changed s_handle:0x%04x e_handle:0x%04x", - __func__, s_handle, e_handle); + LOG(ERROR) << __func__ << ": service changed s_handle=" << loghex(s_handle) + << ", e_handle=" << loghex(e_handle); processed = true; /* mark service handle change pending */ @@ -1510,9 +1506,11 @@ bool bta_gattc_process_srvc_chg_ind(uint16_t conn_id, tBTA_GATTC_RCB* p_clrcb, void bta_gattc_proc_other_indication(tBTA_GATTC_CLCB* p_clcb, uint8_t op, tGATT_CL_COMPLETE* p_data, tBTA_GATTC_NOTIFY* p_notify) { - APPL_TRACE_DEBUG("%s: check p_data->att_value.handle=%d p_data->handle=%d", - __func__, p_data->att_value.handle, p_data->handle); - APPL_TRACE_DEBUG("is_notify", p_notify->is_notify); + VLOG(1) << __func__ + << StringPrintf( + ": check p_data->att_value.handle=%d p_data->handle=%d", + p_data->att_value.handle, p_data->handle); + VLOG(1) << "is_notify", p_notify->is_notify; p_notify->is_notify = (op == GATTC_OPTYPE_INDICATION) ? false : true; p_notify->len = p_data->att_value.len; @@ -1547,7 +1545,7 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op, tBTA_TRANSPORT transport; if (!GATT_GetConnectionInfor(conn_id, &gatt_if, remote_bda, &transport)) { - APPL_TRACE_ERROR("%s indication/notif for unknown app", __func__); + LOG(ERROR) << __func__ << ": indication/notif for unknown app"; if (op == GATTC_OPTYPE_INDICATION) GATTC_SendHandleValueConfirm(conn_id, handle); return; @@ -1555,7 +1553,7 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op, p_clrcb = bta_gattc_cl_get_regcb(gatt_if); if (p_clrcb == NULL) { - APPL_TRACE_ERROR("%s indication/notif for unregistered app", __func__); + LOG(ERROR) << __func__ << ": indication/notif for unregistered app"; if (op == GATTC_OPTYPE_INDICATION) GATTC_SendHandleValueConfirm(conn_id, handle); return; @@ -1563,8 +1561,7 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op, p_srcb = bta_gattc_find_srcb(remote_bda); if (p_srcb == NULL) { - APPL_TRACE_ERROR("%s indication/notif for unknown device, ignore", - __func__); + LOG(ERROR) << __func__ << ": indication/notif for unknown device, ignore"; if (op == GATTC_OPTYPE_INDICATION) GATTC_SendHandleValueConfirm(conn_id, handle); return; @@ -1583,7 +1580,7 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op, p_clcb = bta_gattc_clcb_alloc(gatt_if, remote_bda, transport); if (p_clcb == NULL) { - APPL_TRACE_ERROR("No resources"); + LOG(ERROR) << "No resources"; return; } @@ -1598,7 +1595,7 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op, } /* no one intersted and need ack? */ else if (op == GATTC_OPTYPE_INDICATION) { - APPL_TRACE_DEBUG("%s no one interested, ack now", __func__); + VLOG(1) << __func__ << " no one interested, ack now"; GATTC_SendHandleValueConfirm(conn_id, handle); } } @@ -1616,8 +1613,8 @@ static void bta_gattc_cmpl_cback(uint16_t conn_id, tGATTC_OPTYPE op, tGATT_STATUS status, tGATT_CL_COMPLETE* p_data) { tBTA_GATTC_CLCB* p_clcb; - APPL_TRACE_DEBUG("bta_gattc_cmpl_cback: conn_id = %d op = %d status = %d", - conn_id, op, status); + VLOG(1) << __func__ << ": conn_id:" << +conn_id << " op:" << +op + << " status:" << +status; /* notification and indication processed right away */ if (op == GATTC_OPTYPE_NOTIFICATION || op == GATTC_OPTYPE_INDICATION) { @@ -1628,8 +1625,8 @@ static void bta_gattc_cmpl_cback(uint16_t conn_id, tGATTC_OPTYPE op, else { p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); if (p_clcb == NULL) { - APPL_TRACE_ERROR("%s: unknown conn_id = %d, ignore data", __func__, - conn_id); + LOG(ERROR) << __func__ << ": unknown conn_id=" << loghex(conn_id) + << " ignore data"; return; } } @@ -1701,7 +1698,7 @@ static void bta_gattc_phy_update_cback(tGATT_IF gatt_if, uint16_t conn_id, tBTA_GATTC_RCB* p_clreg = bta_gattc_cl_get_regcb(gatt_if); if (!p_clreg || !p_clreg->p_cback) { - APPL_TRACE_ERROR("%s: client_if=%d not found", __func__, gatt_if); + LOG(ERROR) << __func__ << ": client_if=" << +gatt_if << " not found"; return; } @@ -1720,7 +1717,7 @@ static void bta_gattc_conn_update_cback(tGATT_IF gatt_if, uint16_t conn_id, tBTA_GATTC_RCB* p_clreg = bta_gattc_cl_get_regcb(gatt_if); if (!p_clreg || !p_clreg->p_cback) { - APPL_TRACE_ERROR("%s: client_if=%d not found", __func__, gatt_if); + LOG(ERROR) << __func__ << ": client_if=" << gatt_if << " not found"; return; } diff --git a/bta/gatt/bta_gattc_api.cc b/bta/gatt/bta_gattc_api.cc index 2fe9eb46e..a9991f524 100644 --- a/bta/gatt/bta_gattc_api.cc +++ b/bta/gatt/bta_gattc_api.cc @@ -58,7 +58,7 @@ static const tBTA_SYS_REG bta_gattc_reg = {bta_gattc_hdl_event, ******************************************************************************/ void BTA_GATTC_Disable(void) { if (!bta_sys_is_register(BTA_ID_GATTC)) { - APPL_TRACE_WARNING("GATTC Module not enabled/already disabled"); + LOG(WARNING) << "GATTC Module not enabled/already disabled"; return; } @@ -593,7 +593,8 @@ void BTA_GATTC_SendIndConfirm(uint16_t conn_id, uint16_t handle) { tBTA_GATTC_API_CONFIRM* p_buf = (tBTA_GATTC_API_CONFIRM*)osi_calloc(sizeof(tBTA_GATTC_API_CONFIRM)); - APPL_TRACE_API("%s conn_id=%d handle=0x%04x", __func__, conn_id, handle); + VLOG(1) << __func__ << ": conn_id=" << +conn_id << " handle=0x" << std::hex + << +handle; p_buf->hdr.event = BTA_GATTC_API_CONFIRM_EVT; p_buf->hdr.layer_specific = conn_id; @@ -624,7 +625,7 @@ tGATT_STATUS BTA_GATTC_RegisterForNotifications(tGATT_IF client_if, uint8_t i; if (!handle) { - APPL_TRACE_ERROR("deregistration failed, handle is 0"); + LOG(ERROR) << "deregistration failed, handle is 0"; return status; } @@ -634,7 +635,7 @@ tGATT_STATUS BTA_GATTC_RegisterForNotifications(tGATT_IF client_if, if (p_clreg->notif_reg[i].in_use && p_clreg->notif_reg[i].remote_bda == bda && p_clreg->notif_reg[i].handle == handle) { - APPL_TRACE_WARNING("notification already registered"); + LOG(WARNING) << "notification already registered"; status = GATT_SUCCESS; break; } @@ -655,11 +656,11 @@ tGATT_STATUS BTA_GATTC_RegisterForNotifications(tGATT_IF client_if, } if (i == BTA_GATTC_NOTIF_REG_MAX) { status = GATT_NO_RESOURCES; - APPL_TRACE_ERROR("Max Notification Reached, registration failed."); + LOG(ERROR) << "Max Notification Reached, registration failed."; } } } else { - APPL_TRACE_ERROR("Client_if: %d Not Registered", client_if); + LOG(ERROR) << "client_if=" << +client_if << " Not Registered"; } return status; @@ -683,14 +684,14 @@ tGATT_STATUS BTA_GATTC_DeregisterForNotifications(tGATT_IF client_if, const RawAddress& bda, uint16_t handle) { if (!handle) { - APPL_TRACE_ERROR("%s: deregistration failed, handle is 0", __func__); + LOG(ERROR) << __func__ << ": deregistration failed, handle is 0"; return GATT_ILLEGAL_PARAMETER; } tBTA_GATTC_RCB* p_clreg = bta_gattc_cl_get_regcb(client_if); if (p_clreg == NULL) { - LOG(ERROR) << __func__ << " client_if: " << +client_if - << " not registered bd_addr:" << bda; + LOG(ERROR) << __func__ << " client_if=" << +client_if + << " not registered bd_addr=" << bda; return GATT_ILLEGAL_PARAMETER; } @@ -698,13 +699,13 @@ tGATT_STATUS BTA_GATTC_DeregisterForNotifications(tGATT_IF client_if, if (p_clreg->notif_reg[i].in_use && p_clreg->notif_reg[i].remote_bda == bda && p_clreg->notif_reg[i].handle == handle) { - VLOG(1) << __func__ << " deregistered bd_addr:" << bda; + VLOG(1) << __func__ << " deregistered bd_addr=" << bda; memset(&p_clreg->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG)); return GATT_SUCCESS; } } - LOG(ERROR) << __func__ << " registration not found bd_addr:" << bda; + LOG(ERROR) << __func__ << " registration not found bd_addr=" << bda; return GATT_ERROR; } diff --git a/bta/gatt/bta_gattc_cache.cc b/bta/gatt/bta_gattc_cache.cc index fae164a3d..0e098775e 100644 --- a/bta/gatt/bta_gattc_cache.cc +++ b/bta/gatt/bta_gattc_cache.cc @@ -45,6 +45,7 @@ #include "utl.h" using bluetooth::Uuid; +using base::StringPrintf; static void bta_gattc_cache_write(const RawAddress& server_bda, uint16_t num_attr, tBTA_GATTC_NV_ATTR* attr); @@ -91,36 +92,37 @@ static const char* bta_gattc_attr_type[] = { /* debug function to display the server cache */ static void bta_gattc_display_cache_server( const std::list& cache) { - APPL_TRACE_ERROR("<================Start Server Cache =============>"); + LOG(ERROR) << "<================Start Server Cache =============>"; for (const tBTA_GATTC_SERVICE& service : cache) { - APPL_TRACE_ERROR("Service: handle[%d ~ %d] %s inst[%d]", service.s_handle, - service.e_handle, service.uuid.ToString().c_str(), - service.handle); + LOG(ERROR) << "Service: s_handle=" << loghex(service.s_handle) + << ", e_handle=" << loghex(service.e_handle) + << ", inst=" << loghex(service.handle) + << ", uuid=" << service.uuid; if (service.characteristics.empty()) { - APPL_TRACE_ERROR("\t No characteristics"); + LOG(ERROR) << "\t No characteristics"; continue; } for (const tBTA_GATTC_CHARACTERISTIC& c : service.characteristics) { - APPL_TRACE_ERROR("\t Characteristic handle[%d] uuid[%s] prop[0x%1x]", - c.handle, c.uuid.ToString().c_str(), c.properties); + LOG(ERROR) << "\t Characteristic handle=" << loghex(c.handle) + << ", uuid=" << c.uuid << ", prop=" << loghex(c.properties); if (c.descriptors.empty()) { - APPL_TRACE_ERROR("\t\t No descriptors"); + LOG(ERROR) << "\t\t No descriptors"; continue; } for (const tBTA_GATTC_DESCRIPTOR& d : c.descriptors) { - APPL_TRACE_ERROR("\t\t Descriptor handle[%d] uuid[%s]", d.handle, - d.uuid.ToString().c_str()); + LOG(ERROR) << "\t\t Descriptor handle=" << loghex(d.handle) + << ", uuid=" : << d.uuid; } } } - APPL_TRACE_ERROR("<================End Server Cache =============>"); - APPL_TRACE_ERROR(" "); + LOG(ERROR) << "<================End Server Cache =============>"; + LOG(ERROR) << " "; } /******************************************************************************* @@ -137,15 +139,15 @@ static void bta_gattc_display_explore_record(tBTA_GATTC_ATTR_REC* p_rec, uint8_t i; tBTA_GATTC_ATTR_REC* pp = p_rec; - APPL_TRACE_ERROR("<================Start Explore Queue =============>"); + LOG(ERROR) << "<================Start Explore Queue =============>"; for (i = 0; i < num_rec; i++, pp++) { - APPL_TRACE_ERROR( + LOG(ERROR) << StringPrintf( "\t rec[%d] uuid[%s] s_handle[%d] e_handle[%d] is_primary[%d]", i + 1, pp->uuid.ToString().c_str(), pp->s_handle, pp->e_handle, pp->is_primary); } - APPL_TRACE_ERROR("<================ End Explore Queue =============>"); - APPL_TRACE_ERROR(" "); + LOG(ERROR) << "<================ End Explore Queue =============>"; + LOG(ERROR) << " "; } #endif /* BTA_GATT_DEBUG == TRUE */ @@ -178,7 +180,7 @@ static void bta_gattc_add_srvc_to_cache(tBTA_GATTC_SERV* p_srvc_cb, uint16_t s_handle, uint16_t e_handle, const Uuid& uuid, bool is_primary) { #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("Add a service into Service"); + VLOG(1) << "Add a service into Service"; #endif p_srvc_cb->srvc_cache.emplace_back(tBTA_GATTC_SERVICE{ @@ -195,16 +197,16 @@ static void bta_gattc_add_char_to_cache(tBTA_GATTC_SERV* p_srvc_cb, uint16_t value_handle, const Uuid& uuid, uint8_t property) { #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("%s: Add a characteristic into Service", __func__); - APPL_TRACE_DEBUG("handle=%d uuid16=%s property=0x%x", value_handle, - uuid.ToString().c_str(), property); + VLOG(1) << __func__ + << ": Add a characteristic into service. handle:" << +value_handle + << " uuid:" << uuid << " property=0x" << std::hex << +property; #endif tBTA_GATTC_SERVICE* service = bta_gattc_find_matching_service(p_srvc_cb->srvc_cache, attr_handle); if (!service) { - APPL_TRACE_ERROR( - "Illegal action to add char/descr/incl srvc for non-existing service!"); + LOG(ERROR) << "Illegal action to add char/descr/incl srvc for non-existing " + "service!"; return; } @@ -229,17 +231,16 @@ static void bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV* p_srvc_cb, uint16_t incl_srvc_s_handle, tBTA_GATTC_ATTR_TYPE type) { #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("%s: Add a [%s] into Service", __func__, - bta_gattc_attr_type[type]); - APPL_TRACE_DEBUG("handle=%d uuid=%s property=0x%x type=%d", handle, - uuid.ToString().c_str(), property, type); + VLOG(1) << __func__ << ": Add a " << bta_gattc_attr_type[type] + << " into Service, handle=" << +handle << " uuid=" << uuid + << " property=0x" << std::hex << property << " type=" << +type; #endif tBTA_GATTC_SERVICE* service = bta_gattc_find_matching_service(p_srvc_cb->srvc_cache, handle); if (!service) { - APPL_TRACE_ERROR( - "Illegal action to add char/descr/incl srvc for non-existing service!"); + LOG(ERROR) << "Illegal action to add char/descr/incl srvc for non-existing " + "service!"; return; } @@ -247,8 +248,8 @@ static void bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV* p_srvc_cb, tBTA_GATTC_SERVICE* included_service = bta_gattc_find_matching_service( p_srvc_cb->srvc_cache, incl_srvc_s_handle); if (!included_service) { - APPL_TRACE_ERROR( - "%s: Illegal action to add non-existing included service!", __func__); + LOG(ERROR) << __func__ + << ": Illegal action to add non-existing included service!"; return; } @@ -260,10 +261,9 @@ static void bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV* p_srvc_cb, }); } else if (type == BTA_GATTC_ATTR_TYPE_CHAR_DESCR) { if (service->characteristics.empty()) { - APPL_TRACE_ERROR( - "%s: Illegal action to add descriptor before adding a " - "characteristic!", - __func__); + LOG(ERROR) << __func__ + << ": Illegal action to add descriptor before adding a " + "characteristic!"; return; } @@ -297,8 +297,8 @@ void bta_gattc_get_disc_range(tBTA_GATTC_SERV* p_srvc_cb, uint16_t* p_s_hdl, *p_e_hdl = p_rec->e_handle; #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("discover range [%d ~ %d]", p_rec->s_handle, - p_rec->e_handle); + VLOG(1) << StringPrintf("discover range [%d ~ %d]", p_rec->s_handle, + p_rec->e_handle); #endif return; } @@ -397,7 +397,7 @@ tGATT_STATUS bta_gattc_start_disc_char(uint16_t conn_id, ******************************************************************************/ void bta_gattc_start_disc_char_dscp(uint16_t conn_id, tBTA_GATTC_SERV* p_srvc_cb) { - APPL_TRACE_DEBUG("starting discover characteristics descriptor"); + VLOG(1) << "starting discover characteristics descriptor"; if (bta_gattc_discover_procedure(conn_id, p_srvc_cb, GATT_DISC_CHAR_DSCPT) != 0) @@ -417,13 +417,12 @@ static void bta_gattc_explore_srvc(uint16_t conn_id, tBTA_GATTC_ATTR_REC* p_rec = p_srvc_cb->p_srvc_list + p_srvc_cb->cur_srvc_idx; tBTA_GATTC_CLCB* p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); - APPL_TRACE_DEBUG("Start service discovery: srvc_idx = %d", - p_srvc_cb->cur_srvc_idx); + VLOG(1) << "Start service discovery: srvc_idx:" << +p_srvc_cb->cur_srvc_idx; p_srvc_cb->cur_char_idx = p_srvc_cb->next_avail_idx = p_srvc_cb->total_srvc; if (p_clcb == NULL) { - APPL_TRACE_ERROR("unknown connection ID"); + LOG(ERROR) << "unknown connection ID"; return; } /* start expore a service if there is service not been explored */ @@ -521,7 +520,7 @@ static void bta_gattc_char_dscpt_disc_cmpl(uint16_t conn_id, /* all characteristic has been explored, start with next service if any */ { #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_ERROR("all char has been explored"); + LOG(ERROR) << "all char has been explored"; #endif p_srvc_cb->cur_srvc_idx++; bta_gattc_explore_srvc(conn_id, p_srvc_cb); @@ -535,8 +534,8 @@ static bool bta_gattc_srvc_in_list(tBTA_GATTC_SERV* p_srvc_cb, bool exist_srvc = false; if (!GATT_HANDLE_IS_VALID(s_handle) || !GATT_HANDLE_IS_VALID(e_handle)) { - APPL_TRACE_ERROR("invalid included service handle: [0x%04x ~ 0x%04x]", - s_handle, e_handle); + LOG(ERROR) << "invalid included service s_handle=" << loghex(s_handle) + << ", e_handle=" << loghex(e_handle); exist_srvc = true; } else { for (i = 0; i < p_srvc_cb->next_avail_idx; i++) { @@ -573,8 +572,8 @@ static tGATT_STATUS bta_gattc_add_srvc_to_list(tBTA_GATTC_SERV* p_srvc_cb, p_srvc_cb->next_avail_idx < BTA_GATTC_MAX_CACHE_CHAR) { p_rec = p_srvc_cb->p_srvc_list + p_srvc_cb->next_avail_idx; - APPL_TRACE_DEBUG("%s handle=%d, service type=%s", __func__, s_handle, - uuid.ToString().c_str()); + VLOG(1) << __func__ << "handle:" << loghex(s_handle) + << " service type=" << uuid; p_rec->s_handle = s_handle; p_rec->e_handle = e_handle; @@ -586,7 +585,7 @@ static tGATT_STATUS bta_gattc_add_srvc_to_list(tBTA_GATTC_SERV* p_srvc_cb, } else { /* allocate bigger buffer ?? */ status = GATT_DB_FULL; - APPL_TRACE_ERROR("service not added, no resources or wrong state"); + LOG(ERROR) << "service not added, no resources or wrong state"; } return status; } @@ -608,7 +607,7 @@ static tGATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV* p_srvc_cb, tGATT_STATUS status = GATT_SUCCESS; if (p_srvc_cb->p_srvc_list == NULL) { - APPL_TRACE_ERROR("No service available, unexpected char discovery result"); + LOG(ERROR) << "No service available, unexpected char discovery result"; status = GATT_INTERNAL_ERROR; } else if (p_srvc_cb->next_avail_idx < BTA_GATTC_MAX_CACHE_CHAR) { p_rec = p_srvc_cb->p_srvc_list + p_srvc_cb->next_avail_idx; @@ -629,7 +628,7 @@ static tGATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV* p_srvc_cb, } p_srvc_cb->next_avail_idx++; } else { - APPL_TRACE_ERROR("char not added, no resources"); + LOG(ERROR) << "char not added, no resources"; /* allocate bigger buffer ?? */ status = GATT_DB_FULL; } @@ -665,9 +664,9 @@ void bta_gattc_sdp_callback(uint16_t sdp_status, void* user_data) { uint16_t end_handle = (uint16_t)pe.params[1]; #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_EVENT("Found ATT service [%s] handle[0x%04x ~ 0x%04x]", - service_uuid.ToString().c_str(), start_handle, - end_handle); + VLOG(1) << "Found ATT service uuid=" << service_uuid + << ", s_handle=" << loghex(start_handle) + << ", e_handle=" << loghex(end_handle); #endif if (GATT_HANDLE_IS_VALID(start_handle) && @@ -676,8 +675,8 @@ void bta_gattc_sdp_callback(uint16_t sdp_status, void* user_data) { bta_gattc_add_srvc_to_list(p_srvc_cb, start_handle, end_handle, service_uuid, true); } else { - APPL_TRACE_ERROR("invalid start_handle = %d end_handle = %d", - start_handle, end_handle); + LOG(ERROR) << "invalid start_handle=" << loghex(start_handle) + << ", end_handle=" << loghex(end_handle); } } } @@ -689,7 +688,7 @@ void bta_gattc_sdp_callback(uint16_t sdp_status, void* user_data) { /* start discover primary service */ bta_gattc_explore_srvc(cb_data->sdp_conn_id, p_srvc_cb); } else { - APPL_TRACE_ERROR("GATT service discovery is done on unknown connection"); + LOG(ERROR) << "GATT service discovery is done on unknown connection"; } /* both were allocated in bta_gattc_sdp_service_disc */ @@ -863,9 +862,8 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB* p_clcb, Uuid* p_uuid) { if (p_uuid && *p_uuid != service.uuid) continue; #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("found service %s, inst[%d] handle [%d]", - service.uuid.ToString().c_str(), service.handle, - service.s_handle); + VLOG(1) << __func__ << "found service " << service.uuid + << ", inst:" << +service.handle << " handle:" << +service.s_handle; #endif if (!p_clcb->p_rcb->p_cback) continue; @@ -1048,8 +1046,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV* p_srvc_cb, uint16_t start_handle, uint16_t end_handle, btgatt_db_element_t** db, int* count) { - APPL_TRACE_DEBUG("%s: start_handle 0x%04x, end_handle 0x%04x", __func__, - start_handle, end_handle); + VLOG(1) << __func__ + << StringPrintf(": start_handle 0x%04x, end_handle 0x%04x", + start_handle, end_handle); if (p_srvc_cb->srvc_cache.empty()) { *count = 0; @@ -1125,20 +1124,19 @@ void bta_gattc_get_gatt_db(uint16_t conn_id, uint16_t start_handle, LOG_DEBUG(LOG_TAG, "%s", __func__); if (p_clcb == NULL) { - APPL_TRACE_ERROR("Unknown conn ID: %d", conn_id); + LOG(ERROR) << "Unknown conn_id=" << loghex(conn_id); return; } if (p_clcb->state != BTA_GATTC_CONN_ST) { - APPL_TRACE_ERROR("server cache not available, CLCB state = %d", - p_clcb->state); + LOG(ERROR) << "server cache not available, CLCB state=" << +p_clcb->state; return; } if (!p_clcb->p_srcb || p_clcb->p_srcb->p_srvc_list || /* no active discovery */ p_clcb->p_srcb->srvc_cache.empty()) { - APPL_TRACE_ERROR("No server cache available"); + LOG(ERROR) << "No server cache available"; return; } @@ -1160,7 +1158,7 @@ void bta_gattc_get_gatt_db(uint16_t conn_id, uint16_t start_handle, void bta_gattc_rebuild_cache(tBTA_GATTC_SERV* p_srvc_cb, uint16_t num_attr, tBTA_GATTC_NV_ATTR* p_attr) { /* first attribute loading, initialize buffer */ - APPL_TRACE_ERROR("%s: bta_gattc_rebuild_cache", __func__); + LOG(ERROR) << __func__; p_srvc_cb->srvc_cache.clear(); @@ -1280,8 +1278,8 @@ bool bta_gattc_cache_load(tBTA_GATTC_CLCB* p_clcb) { FILE* fd = fopen(fname, "rb"); if (!fd) { - APPL_TRACE_ERROR("%s: can't open GATT cache file %s for reading, error: %s", - __func__, fname, strerror(errno)); + LOG(ERROR) << __func__ << ": can't open GATT cache file " << fname + << " for reading, error: " << strerror(errno); return false; } @@ -1291,32 +1289,30 @@ bool bta_gattc_cache_load(tBTA_GATTC_CLCB* p_clcb) { uint16_t num_attr = 0; if (fread(&cache_ver, sizeof(uint16_t), 1, fd) != 1) { - APPL_TRACE_ERROR("%s: can't read GATT cache version from: %s", __func__, - fname); + LOG(ERROR) << __func__ << ": can't read GATT cache version from: " << fname; goto done; } if (cache_ver != GATT_CACHE_VERSION) { - APPL_TRACE_ERROR("%s: wrong GATT cache version: %s", __func__, fname); + LOG(ERROR) << __func__ << ": wrong GATT cache version: " << fname; goto done; } if (fread(&num_attr, sizeof(uint16_t), 1, fd) != 1) { - APPL_TRACE_ERROR("%s: can't read number of GATT attributes: %s", __func__, - fname); + LOG(ERROR) << __func__ + << ": can't read number of GATT attributes: " << fname; goto done; } if (num_attr > 0xFFFF) { - APPL_TRACE_ERROR("%s: more than 0xFFFF GATT attributes: %s", __func__, - fname); + LOG(ERROR) << __func__ << ": more than 0xFFFF GATT attributes: " << fname; goto done; } attr = (tBTA_GATTC_NV_ATTR*)osi_malloc(sizeof(tBTA_GATTC_NV_ATTR) * num_attr); if (fread(attr, sizeof(tBTA_GATTC_NV_ATTR), num_attr, fd) != num_attr) { - APPL_TRACE_ERROR("%s: can't read GATT attributes: %s", __func__, fname); + LOG(ERROR) << __func__ << "s: can't read GATT attributes: " << fname; goto done; } @@ -1350,28 +1346,27 @@ static void bta_gattc_cache_write(const RawAddress& server_bda, FILE* fd = fopen(fname, "wb"); if (!fd) { - APPL_TRACE_ERROR("%s: can't open GATT cache file for writing: %s", __func__, - fname); + LOG(ERROR) << __func__ + << ": can't open GATT cache file for writing: " << fname; return; } uint16_t cache_ver = GATT_CACHE_VERSION; if (fwrite(&cache_ver, sizeof(uint16_t), 1, fd) != 1) { - APPL_TRACE_ERROR("%s: can't write GATT cache version: %s", __func__, fname); + LOG(ERROR) << __func__ << ": can't write GATT cache version: " << fname; fclose(fd); return; } if (fwrite(&num_attr, sizeof(uint16_t), 1, fd) != 1) { - APPL_TRACE_ERROR("%s: can't write GATT cache attribute count: %s", __func__, - fname); + LOG(ERROR) << __func__ + << ": can't write GATT cache attribute count: " << fname; fclose(fd); return; } if (fwrite(attr, sizeof(tBTA_GATTC_NV_ATTR), num_attr, fd) != num_attr) { - APPL_TRACE_ERROR("%s: can't write GATT cache attributes: %s", __func__, - fname); + LOG(ERROR) << __func__ << ": can't write GATT cache attributes: " << fname; fclose(fd); return; } @@ -1392,7 +1387,7 @@ static void bta_gattc_cache_write(const RawAddress& server_bda, * ******************************************************************************/ void bta_gattc_cache_reset(const RawAddress& server_bda) { - BTIF_TRACE_DEBUG("%s", __func__); + VLOG(1) << __func__; char fname[255] = {0}; bta_gattc_generate_cache_file_name(fname, sizeof(fname), server_bda); unlink(fname); diff --git a/bta/gatt/bta_gattc_int.h b/bta/gatt/bta_gattc_int.h index 4b4521c54..fd8470209 100644 --- a/bta/gatt/bta_gattc_int.h +++ b/bta/gatt/bta_gattc_int.h @@ -32,6 +32,9 @@ #include "bt_common.h" +#include +#include + /***************************************************************************** * Constants and data types ****************************************************************************/ diff --git a/bta/gatt/bta_gattc_main.cc b/bta/gatt/bta_gattc_main.cc index 68effe0d0..04d91f21b 100644 --- a/bta/gatt/bta_gattc_main.cc +++ b/bta/gatt/bta_gattc_main.cc @@ -29,6 +29,8 @@ #include "bt_common.h" #include "bta_gattc_int.h" +using base::StringPrintf; + /***************************************************************************** * Constants and types ****************************************************************************/ @@ -303,12 +305,12 @@ bool bta_gattc_sm_execute(tBTA_GATTC_CLCB* p_clcb, uint16_t event, tBTA_GATTC_STATE in_state = p_clcb->state; uint16_t in_event = event; #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("%s: State 0x%02x [%s], Event 0x%x[%s]", __func__, in_state, - gattc_state_code(in_state), in_event, - gattc_evt_code(in_event)); + VLOG(1) << StringPrintf("%s: State 0x%02x [%s], Event 0x%x[%s]", __func__, + in_state, gattc_state_code(in_state), in_event, + gattc_evt_code(in_event)); #else - APPL_TRACE_VERBOSE("%s: State 0x%02x, Event 0x%x", __func__, in_state, - in_event); + VLOG(1) << StringPrintf("%s: State 0x%02x, Event 0x%x", __func__, in_state, + in_event); #endif /* look up the state table for the current state */ @@ -337,13 +339,15 @@ bool bta_gattc_sm_execute(tBTA_GATTC_CLCB* p_clcb, uint16_t event, #if (BTA_GATT_DEBUG == TRUE) if (in_state != p_clcb->state) { - APPL_TRACE_DEBUG("GATTC State Change: [%s] -> [%s] after Event [%s]", - gattc_state_code(in_state), - gattc_state_code(p_clcb->state), gattc_evt_code(in_event)); + VLOG(1) << StringPrintf("GATTC State Change: [%s] -> [%s] after Event [%s]", + gattc_state_code(in_state), + gattc_state_code(p_clcb->state), + gattc_evt_code(in_event)); } #else - APPL_TRACE_DEBUG("%s: GATTC State Change: 0x%02x -> 0x%02x after Event 0x%x", - __func__, in_state, p_clcb->state, in_event); + VLOG(1) << StringPrintf( + "%s: GATTC State Change: 0x%02x -> 0x%02x after Event 0x%x", __func__, + in_state, p_clcb->state, in_event); #endif return rt; } @@ -362,8 +366,7 @@ bool bta_gattc_hdl_event(BT_HDR* p_msg) { tBTA_GATTC_CLCB* p_clcb = NULL; bool rt = true; #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("bta_gattc_hdl_event: Event [%s]", - gattc_evt_code(p_msg->event)); + VLOG(1) << __func__ << ": Event:" << gattc_evt_code(p_msg->event); #endif switch (p_msg->event) { @@ -387,7 +390,7 @@ bool bta_gattc_hdl_event(BT_HDR* p_msg) { rt = bta_gattc_sm_execute(p_clcb, p_msg->event, (tBTA_GATTC_DATA*)p_msg); } else { - APPL_TRACE_DEBUG("Ignore unknown conn ID: %d", p_msg->layer_specific); + VLOG(1) << "Ignore unknown conn ID: " << +p_msg->layer_specific; } break; diff --git a/bta/gatt/bta_gattc_utils.cc b/bta/gatt/bta_gattc_utils.cc index 249e4806f..419da90c4 100644 --- a/bta/gatt/bta_gattc_utils.cc +++ b/bta/gatt/bta_gattc_utils.cc @@ -129,8 +129,7 @@ tBTA_GATTC_CLCB* bta_gattc_clcb_alloc(tGATT_IF client_if, for (i_clcb = 0; i_clcb < BTA_GATTC_CLCB_MAX; i_clcb++) { if (!bta_gattc_cb.clcb[i_clcb].in_use) { #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("bta_gattc_clcb_alloc: found clcb[%d] available", - i_clcb); + VLOG(1) << __func__ << ": found clcb:" << +i_clcb << " available", ; #endif p_clcb = &bta_gattc_cb.clcb[i_clcb]; p_clcb->in_use = true; @@ -209,7 +208,7 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB* p_clcb) { osi_free_and_reset((void**)&p_clcb->p_q_cmd); memset(p_clcb, 0, sizeof(tBTA_GATTC_CLCB)); } else { - APPL_TRACE_ERROR("bta_gattc_clcb_dealloc p_clcb=NULL"); + LOG(ERROR) << __func__ << " p_clcb=NULL"; } } @@ -322,7 +321,7 @@ bool bta_gattc_enqueue(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { return true; } - APPL_TRACE_ERROR("%s: already has a pending command!!", __func__); + LOG(ERROR) << __func__ << ": already has a pending command"; /* skip the callback now. ----- need to send callback ? */ return false; } @@ -345,7 +344,7 @@ bool bta_gattc_check_notif_registry(tBTA_GATTC_RCB* p_clreg, if (p_clreg->notif_reg[i].in_use && p_clreg->notif_reg[i].remote_bda == p_srcb->server_bda && p_clreg->notif_reg[i].handle == p_notify->handle) { - APPL_TRACE_DEBUG("Notification registered!"); + VLOG(1) << "Notification registered!"; return true; } } @@ -390,8 +389,7 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV* p_srcb, } } } else { - APPL_TRACE_ERROR( - "can not clear indication/notif registration for unknown app"); + LOG(ERROR) << "can not clear indication/notif registration for unknown app"; } return; } @@ -433,7 +431,8 @@ bool bta_gattc_mark_bg_conn(tGATT_IF client_if, } } if (!add) { - LOG(ERROR) << __func__ << " unable to find the bg connection mask for: " + LOG(ERROR) << __func__ + << " unable to find the bg connection mask for bd_addr=" << remote_bda_ptr; return false; } else /* adding a new device mask */ @@ -450,7 +449,7 @@ bool bta_gattc_mark_bg_conn(tGATT_IF client_if, return true; } } - APPL_TRACE_ERROR("no available space to mark the bg connection status"); + LOG(ERROR) << "no available space to mark the bg connection status"; return false; } } @@ -523,8 +522,7 @@ tBTA_GATTC_CONN* bta_gattc_conn_alloc(const RawAddress& remote_bda) { for (i_conn = 0; i_conn < BTA_GATTC_CONN_MAX; i_conn++, p_conn++) { if (!p_conn->in_use) { #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("bta_gattc_conn_alloc: found conn_track[%d] available", - i_conn); + VLOG(1) << __func__ << ": found conn_track:" << +i_conn << " available"; #endif p_conn->in_use = true; p_conn->remote_bda = remote_bda; @@ -550,8 +548,7 @@ tBTA_GATTC_CONN* bta_gattc_conn_find(const RawAddress& remote_bda) { for (i_conn = 0; i_conn < BTA_GATTC_CONN_MAX; i_conn++, p_conn++) { if (p_conn->in_use && remote_bda == p_conn->remote_bda) { #if (BTA_GATT_DEBUG == TRUE) - APPL_TRACE_DEBUG("bta_gattc_conn_find: found conn_track[%d] matched", - i_conn); + VLOG(1) << __func__ << ": found conn_track:" << +i_conn << " matched"; #endif return p_conn; } @@ -654,8 +651,8 @@ tBTA_GATTC_CLCB* bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA* p_msg) { p_msg->int_conn.transport); } if (p_clcb == NULL) { - APPL_TRACE_DEBUG(" disconnection ID: [%d] not used by BTA", - p_msg->int_conn.hdr.layer_specific); + VLOG(1) << " disconnection ID:" << +p_msg->int_conn.hdr.layer_specific + << " not used by BTA"; } return p_clcb; } diff --git a/bta/gatt/bta_gatts_act.cc b/bta/gatt/bta_gatts_act.cc index 75ca6e405..7eafe989a 100644 --- a/bta/gatt/bta_gatts_act.cc +++ b/bta/gatt/bta_gatts_act.cc @@ -36,6 +36,8 @@ #include "osi/include/osi.h" #include "utl.h" +using base::StringPrintf; + static void bta_gatts_nv_save_cback(bool is_saved, tGATTS_HNDL_RANGE* p_hndl_range); static bool bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, @@ -120,7 +122,7 @@ void bta_gatts_enable(tBTA_GATTS_CB* p_cb) { tBTA_GATTS_HNDL_RANGE handle_range; if (p_cb->enabled) { - APPL_TRACE_DEBUG("GATTS already enabled."); + VLOG(1) << "GATTS already enabled."; } else { memset(p_cb, 0, sizeof(tBTA_GATTS_CB)); @@ -132,10 +134,10 @@ void bta_gatts_enable(tBTA_GATTS_CB* p_cb) { index++; } - APPL_TRACE_DEBUG("bta_gatts_enable: num of handle range added=%d", index); + VLOG(1) << __func__ << ": num of handle range added:" << +index; if (!GATTS_NVRegister(&bta_gatts_nv_cback)) { - APPL_TRACE_ERROR("BTA GATTS NV register failed."); + LOG(ERROR) << "BTA GATTS NV register failed."; } } } @@ -160,7 +162,7 @@ void bta_gatts_api_disable(tBTA_GATTS_CB* p_cb) { } memset(p_cb, 0, sizeof(tBTA_GATTS_CB)); } else { - APPL_TRACE_ERROR("GATTS not enabled"); + LOG(ERROR) << "GATTS not enabled"; } } @@ -185,7 +187,7 @@ void bta_gatts_register(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) { for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i++) { if (p_cb->rcb[i].in_use) { if (p_cb->rcb[i].app_uuid == p_msg->api_reg.app_uuid) { - APPL_TRACE_ERROR("application already registered."); + LOG(ERROR) << "application already registered."; status = GATT_DUP_REG; break; } @@ -203,8 +205,7 @@ void bta_gatts_register(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) { cb_data.reg_oper.server_if = BTA_GATTS_INVALID_IF; cb_data.reg_oper.uuid = p_msg->api_reg.app_uuid; if (first_unuse != 0xff) { - APPL_TRACE_ERROR("register application first_unuse rcb_idx = %d", - first_unuse); + LOG(ERROR) << "register application first_unuse rcb_idx=" << +first_unuse; p_cb->rcb[first_unuse].in_use = true; p_cb->rcb[first_unuse].p_cback = p_msg->api_reg.p_cback; @@ -244,8 +245,8 @@ void bta_gatts_start_if(UNUSED_ATTR tBTA_GATTS_CB* p_cb, 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 { - APPL_TRACE_ERROR("Unable to start app.: Unknown interface =%d", - p_msg->int_start_if.server_if); + LOG(ERROR) << "Unable to start app.: Unknown interface=" + << +p_msg->int_start_if.server_if; } } /******************************************************************************* @@ -285,7 +286,7 @@ void bta_gatts_deregister(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) { if (p_cback) { (*p_cback)(BTA_GATTS_DEREG_EVT, &cb_data); } else { - APPL_TRACE_ERROR("application not registered."); + LOG(ERROR) << "application not registered."; } } @@ -335,8 +336,7 @@ void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB* p_srvc_cb, cb_data.srvc_oper.server_if = p_rcb->gatt_if; cb_data.srvc_oper.service_id = p_srvc_cb->service_id; cb_data.srvc_oper.status = GATT_SUCCESS; - APPL_TRACE_ERROR("bta_gatts_stop_service service_id= %d", - p_srvc_cb->service_id); + LOG(ERROR) << __func__ << " service_id=" << +p_srvc_cb->service_id; if (p_rcb->p_cback) (*p_rcb->p_cback)(BTA_GATTS_STOP_EVT, &cb_data); } @@ -354,7 +354,7 @@ void bta_gatts_send_rsp(UNUSED_ATTR tBTA_GATTS_CB* p_cb, if (GATTS_SendRsp(p_msg->api_rsp.hdr.layer_specific, p_msg->api_rsp.trans_id, p_msg->api_rsp.status, (tGATTS_RSP*)p_msg->api_rsp.p_rsp) != GATT_SUCCESS) { - APPL_TRACE_ERROR("Sending response failed"); + LOG(ERROR) << "Sending response failed"; } } /******************************************************************************* @@ -399,8 +399,9 @@ void bta_gatts_indicate_handle(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) { bta_sys_idle(BTA_ID_GATTS, BTA_ALL_APP_ID, remote_bda); } } else { - APPL_TRACE_ERROR("Unknown connection ID: %d fail sending notification", - p_msg->api_indicate.hdr.layer_specific); + LOG(ERROR) << "Unknown connection_id=" + << loghex(p_msg->api_indicate.hdr.layer_specific) + << " fail sending notification"; } if ((status != GATT_SUCCESS || !p_msg->api_indicate.need_confirm) && @@ -411,8 +412,8 @@ void bta_gatts_indicate_handle(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) { (*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data); } } else { - APPL_TRACE_ERROR("Not an registered servce attribute ID: 0x%04x", - p_msg->api_indicate.attr_id); + LOG(ERROR) << "Not an registered servce attribute ID: " + << loghex(p_msg->api_indicate.attr_id); } } @@ -444,7 +445,7 @@ void bta_gatts_open(UNUSED_ATTR tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) { } } } else { - APPL_TRACE_ERROR("Inavlide server_if=%d", p_msg->api_open.server_if); + LOG(ERROR) << "Inavlid server_if=" << p_msg->api_open.server_if; } if (p_rcb && p_rcb->p_cback) @@ -468,12 +469,12 @@ void bta_gatts_cancel_open(UNUSED_ATTR tBTA_GATTS_CB* p_cb, if (p_rcb != NULL) { if (!GATT_CancelConnect(p_rcb->gatt_if, p_msg->api_cancel_open.remote_bda, p_msg->api_cancel_open.is_direct)) { - APPL_TRACE_ERROR("bta_gatts_cancel_open failed for open request"); + LOG(ERROR) << __func__ << ": failed for open request"; } else { status = GATT_SUCCESS; } } else { - APPL_TRACE_ERROR("Inavlide server_if=%d", p_msg->api_cancel_open.server_if); + LOG(ERROR) << "Inavlid server_if=" << +p_msg->api_cancel_open.server_if; } if (p_rcb && p_rcb->p_cback) @@ -498,8 +499,8 @@ void bta_gatts_close(UNUSED_ATTR tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) { if (GATT_GetConnectionInfor(p_msg->hdr.layer_specific, &gatt_if, remote_bda, &transport)) { if (GATT_Disconnect(p_msg->hdr.layer_specific) != GATT_SUCCESS) { - APPL_TRACE_ERROR("bta_gatts_close fail conn_id=%d", - p_msg->hdr.layer_specific); + LOG(ERROR) << __func__ + << ": fail conn_id=" << loghex(p_msg->hdr.layer_specific); } else { status = GATT_SUCCESS; } @@ -513,7 +514,7 @@ void bta_gatts_close(UNUSED_ATTR tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) { (*p_rcb->p_cback)(BTA_GATTS_CLOSE_EVT, (tBTA_GATTS*)&status); } } else { - APPL_TRACE_ERROR("Unknown connection ID: %d", p_msg->hdr.layer_specific); + LOG(ERROR) << "Unknown connection_id=" << loghex(p_msg->hdr.layer_specific); } } @@ -540,8 +541,8 @@ static void bta_gatts_send_request_cback(uint16_t conn_id, uint32_t trans_id, &transport)) { p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if); - APPL_TRACE_DEBUG("%s: conn_id=%d trans_id=%d req_type=%d", __func__, - conn_id, trans_id, req_type); + VLOG(1) << __func__ << ": conn_id=" << loghex(conn_id) + << ", trans_id=" << +trans_id << ", req_type=" << +req_type; if (p_rcb && p_rcb->p_cback) { /* if over BR_EDR, inform PM for mode change */ @@ -556,11 +557,11 @@ static void bta_gatts_send_request_cback(uint16_t conn_id, uint32_t trans_id, (*p_rcb->p_cback)(req_type, &cb_data); } else { - APPL_TRACE_ERROR("connection request on gatt_if[%d] is not interested", - gatt_if); + LOG(ERROR) << "connection request on gatt_if=" << +gatt_if + << " is not interested"; } } else { - APPL_TRACE_ERROR("request received on unknown connectino ID: %d", conn_id); + LOG(ERROR) << "request received on unknown conn_id=" << loghex(conn_id); } } @@ -581,10 +582,9 @@ static void bta_gatts_conn_cback(tGATT_IF gatt_if, const RawAddress& bdaddr, uint8_t evt = connected ? BTA_GATTS_CONNECT_EVT : BTA_GATTS_DISCONNECT_EVT; tBTA_GATTS_RCB* p_reg; - APPL_TRACE_DEBUG( - "bta_gatts_conn_cback gatt_if=%d conn_id=%d connected=%d reason = 0x%04d", - gatt_if, conn_id, connected, reason); - VLOG(1) << __func__ << " bda :" << bdaddr; + VLOG(1) << __func__ << " bda=" << bdaddr << " gatt_if= " << gatt_if + << ", conn_id=" << loghex(conn_id) << " connected=" << connected + << ", reason=" << loghex(reason); if (connected) btif_debug_conn_state(bdaddr, BTIF_DEBUG_CONNECTED, GATT_CONN_UNKNOWN); @@ -609,7 +609,7 @@ static void bta_gatts_conn_cback(tGATT_IF gatt_if, const RawAddress& bdaddr, cb_data.conn.remote_bda = bdaddr; (*p_reg->p_cback)(evt, &cb_data); } else { - APPL_TRACE_ERROR("bta_gatts_conn_cback server_if=%d not found", gatt_if); + LOG(ERROR) << __func__ << " server_if=" << +gatt_if << " not found"; } } @@ -618,7 +618,7 @@ static void bta_gatts_phy_update_cback(tGATT_IF gatt_if, uint16_t conn_id, uint8_t status) { tBTA_GATTS_RCB* p_reg = bta_gatts_find_app_rcb_by_app_if(gatt_if); if (!p_reg || !p_reg->p_cback) { - APPL_TRACE_ERROR("%s: server_if=%d not found", __func__, gatt_if); + LOG(ERROR) << __func__ << ": server_if=" << +gatt_if << " not found"; return; } @@ -636,7 +636,7 @@ static void bta_gatts_conn_update_cback(tGATT_IF gatt_if, uint16_t conn_id, uint16_t timeout, uint8_t status) { tBTA_GATTS_RCB* p_reg = bta_gatts_find_app_rcb_by_app_if(gatt_if); if (!p_reg || !p_reg->p_cback) { - APPL_TRACE_ERROR("%s: server_if=%d not found", __func__, gatt_if); + LOG(ERROR) << __func__ << ": server_if=" << +gatt_if << " not found"; return; } diff --git a/bta/gatt/bta_gatts_api.cc b/bta/gatt/bta_gatts_api.cc index a2d203caf..71f654571 100644 --- a/bta/gatt/bta_gatts_api.cc +++ b/bta/gatt/bta_gatts_api.cc @@ -51,7 +51,7 @@ static const tBTA_SYS_REG bta_gatts_reg = {bta_gatts_hdl_event, ******************************************************************************/ void BTA_GATTS_Disable(void) { if (!bta_sys_is_register(BTA_ID_GATTS)) { - APPL_TRACE_WARNING("GATTS Module not enabled/already disabled"); + LOG(WARNING) << "GATTS Module not enabled/already disabled"; return; } @@ -131,7 +131,7 @@ extern uint16_t BTA_GATTS_AddService(tGATT_IF server_if, uint8_t rcb_idx = bta_gatts_find_app_rcb_idx_by_app_if(&bta_gatts_cb, server_if); - APPL_TRACE_ERROR("%s: rcb_idx = %d", __func__, rcb_idx); + LOG(ERROR) << __func__ << ": rcb_idx=" << +rcb_idx; if (rcb_idx == BTA_GATTS_INVALID_APP) return GATT_ERROR; @@ -150,7 +150,7 @@ extern uint16_t BTA_GATTS_AddService(tGATT_IF server_if, return GATT_SUCCESS; } else { memset(&bta_gatts_cb.srvc_cb[srvc_idx], 0, sizeof(tBTA_GATTS_SRVC_CB)); - APPL_TRACE_ERROR("%s: service creation failed.", __func__); + LOG(ERROR) << __func__ << ": service creation failed."; return GATT_ERROR; } } diff --git a/bta/gatt/bta_gatts_int.h b/bta/gatt/bta_gatts_int.h index fc42e15f1..04602faa5 100644 --- a/bta/gatt/bta_gatts_int.h +++ b/bta/gatt/bta_gatts_int.h @@ -29,6 +29,7 @@ #include "bta_sys.h" #include "gatt_api.h" +#include #include "bt_common.h" /***************************************************************************** diff --git a/bta/gatt/bta_gatts_main.cc b/bta/gatt/bta_gatts_main.cc index ac828781e..0faf4a793 100644 --- a/bta/gatt/bta_gatts_main.cc +++ b/bta/gatt/bta_gatts_main.cc @@ -89,8 +89,7 @@ bool bta_gatts_hdl_event(BT_HDR* p_msg) { if (p_srvc_cb != NULL) bta_gatts_delete_service(p_srvc_cb, (tBTA_GATTS_DATA*)p_msg); else - APPL_TRACE_ERROR("%s: can't delete service - no srvc_cb found", - __func__); + LOG(ERROR) << __func__ << ": can't delete service - no srvc_cb found"; break; } @@ -102,7 +101,7 @@ bool bta_gatts_hdl_event(BT_HDR* p_msg) { if (p_srvc_cb != NULL) bta_gatts_stop_service(p_srvc_cb, (tBTA_GATTS_DATA*)p_msg); else - APPL_TRACE_ERROR("%s: can't stop service - no srvc_cb found", __func__); + LOG(ERROR) << __func__ << ": can't stop service - no srvc_cb found"; break; } diff --git a/bta/gatt/bta_gatts_utils.cc b/bta/gatt/bta_gatts_utils.cc index 315b22738..47e456224 100644 --- a/bta/gatt/bta_gatts_utils.cc +++ b/bta/gatt/bta_gatts_utils.cc @@ -105,12 +105,10 @@ uint8_t bta_gatts_find_app_rcb_idx_by_app_if(tBTA_GATTS_CB* p_cb, tBTA_GATTS_SRVC_CB* bta_gatts_find_srvc_cb_by_srvc_id(tBTA_GATTS_CB* p_cb, uint16_t service_id) { uint8_t i; - APPL_TRACE_DEBUG("bta_gatts_find_srvc_cb_by_srvc_id service_id=%d", - service_id); + VLOG(1) << __func__ << ": service_id=" << +service_id; for (i = 0; i < BTA_GATTS_MAX_SRVC_NUM; i++) { if (p_cb->srvc_cb[i].in_use && p_cb->srvc_cb[i].service_id == service_id) { - APPL_TRACE_DEBUG( - "bta_gatts_find_srvc_cb_by_srvc_id found service cb index =%d", i); + VLOG(1) << __func__ << ": found service cb index=" << +i; return &p_cb->srvc_cb[i]; } } diff --git a/include/bt_trace.h b/include/bt_trace.h index 44ff2ffe5..bad06578d 100644 --- a/include/bt_trace.h +++ b/include/bt_trace.h @@ -720,3 +720,22 @@ void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...); #ifdef __cplusplus } #endif + +#ifdef __cplusplus + +#include +#include +#include + +/* Prints intergral parameter x as hex string, with '0' fill */ +template +std::string loghex(T x) { + static_assert(std::is_integral::value, + "loghex parameter must be integral."); + std::stringstream tmp; + tmp << std::showbase << std::internal << std::hex << std::setfill('0') + << std::setw(sizeof(T) / 4 + 2) << x; + return tmp.str(); +} + +#endif -- 2.11.0