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

Commit 06ab8bd9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "GATT: Add more debug logs to help with debugging" am: 734c7848

parents 617d94b7 734c7848
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -727,7 +727,7 @@ class GdAndroidDevice(GdDeviceBase):
            push_timeout: How long to wait for the push to finish in seconds
        """
        if not overwrite_existing and self.adb.path_exists(dst_file_path):
            logging.info("Skip pushing {} to {} as it already exists on device".format(src_file_path, dst_file_path))
            logging.debug("Skip pushing {} to {} as it already exists on device".format(src_file_path, dst_file_path))
            return
        out = self.adb.push([src_file_path, dst_file_path], timeout=push_timeout).decode(UTF_8).rstrip()
        if 'error' in out:
+27 −10
Original line number Diff line number Diff line
@@ -158,8 +158,9 @@ void bta_gattc_disable() {

/** start an application interface */
static void bta_gattc_start_if(uint8_t client_if) {
  LOG_DEBUG("client_if=%d", +client_if);
  if (!bta_gattc_cl_get_regcb(client_if)) {
    LOG(ERROR) << "Unable to start app.: Unknown client_if=" << +client_if;
    LOG_ERROR("Unable to start app.: Unknown client_if=%d", +client_if);
    return;
  }

@@ -168,22 +169,26 @@ static void bta_gattc_start_if(uint8_t client_if) {

/** Register a GATT client application with BTA */
void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback,
                        BtaAppRegisterCallback cb, bool eatt_suppport) {
                        BtaAppRegisterCallback cb, bool eatt_support) {
  tGATT_STATUS status = GATT_NO_RESOURCES;
  uint8_t client_if = 0;
  VLOG(1) << __func__ << ": state:" << +bta_gattc_cb.state;
  LOG_DEBUG("state: %d, uuid=%s", +bta_gattc_cb.state,
            app_uuid.ToString().c_str());

  /* check if  GATTC module is already enabled . Else enable */
  if (bta_gattc_cb.state == BTA_GATTC_STATE_DISABLED) {
    LOG_DEBUG("GATTC module not enabled, enabling it");
    bta_gattc_enable();
  }
  /* todo need to check duplicate uuid */
  for (uint8_t i = 0; i < BTA_GATTC_CL_MAX; i++) {
    if (!bta_gattc_cb.cl_rcb[i].in_use) {
      if ((bta_gattc_cb.cl_rcb[i].client_if = GATT_Register(
               app_uuid, "GattClient", &bta_gattc_cl_cback, eatt_suppport)) ==
          0) {
        LOG(ERROR) << "Register with GATT stack failed.";
      bta_gattc_cb.cl_rcb[i].client_if = GATT_Register(
          app_uuid, "GattClient", &bta_gattc_cl_cback, eatt_support);
      if (bta_gattc_cb.cl_rcb[i].client_if == 0) {
        LOG_ERROR(
            "Register with GATT stack failed with index %d, trying next index",
            +i);
        status = GATT_ERROR;
      } else {
        bta_gattc_cb.cl_rcb[i].in_use = true;
@@ -193,6 +198,11 @@ void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback,
        /* BTA use the same client interface as BTE GATT statck */
        client_if = bta_gattc_cb.cl_rcb[i].client_if;

        LOG_DEBUG(
            "Registered GATT client interface %d with uuid=%s, starting it on "
            "main thread",
            +client_if, app_uuid.ToString().c_str());

        do_in_main_thread(FROM_HERE,
                          base::Bind(&bta_gattc_start_if, client_if));

@@ -202,7 +212,12 @@ void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback,
    }
  }

  if (!cb.is_null()) cb.Run(client_if, status);
  if (!cb.is_null()) {
    cb.Run(client_if, status);
  } else {
    LOG_WARN("No GATT callback available, client_if=%d, status=%d", +client_if,
             +status);
  }
}

/** De-Register a GATT client application with BTA */
@@ -1142,12 +1157,14 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, const RawAddress& bdaddr,
                                 tGATT_DISCONN_REASON reason,
                                 tBT_TRANSPORT transport) {
  if (connected) {
    LOG_INFO("Connected att_id:%hhu transport:%s reason:%s", gattc_if,
    LOG_INFO("Connected client_if:%hhu addr:%s, transport:%s reason:%s",
             gattc_if, PRIVATE_ADDRESS(bdaddr),
             bt_transport_text(transport).c_str(),
             gatt_disconnection_reason_text(reason).c_str());
    btif_debug_conn_state(bdaddr, BTIF_DEBUG_CONNECTED, GATT_CONN_OK);
  } else {
    LOG_INFO("Disconnected att_id:%hhu transport:%s reason:%s", gattc_if,
    LOG_INFO("Disconnected att_id:%hhu addr:%s, transport:%s reason:%s",
             gattc_if, PRIVATE_ADDRESS(bdaddr),
             bt_transport_text(transport).c_str(),
             gatt_disconnection_reason_text(reason).c_str());
    btif_debug_conn_state(bdaddr, BTIF_DEBUG_DISCONNECTED, GATT_CONN_OK);
+7 −1
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@
 *
 ******************************************************************************/

#define LOG_TAG "bta_gattc_api"

#include <base/bind.h>
#include <base/logging.h>

@@ -34,6 +36,7 @@
#include "bta/gatt/bta_gattc_int.h"
#include "device/include/controller.h"
#include "osi/include/allocator.h"
#include "osi/include/log.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btu.h"  // do_in_main_thread
#include "types/bluetooth/uuid.h"
@@ -77,8 +80,11 @@ void BTA_GATTC_Disable(void) {
 */
void BTA_GATTC_AppRegister(tBTA_GATTC_CBACK* p_client_cb,
                           BtaAppRegisterCallback cb, bool eatt_support) {
  if (!bta_sys_is_register(BTA_ID_GATTC))
  LOG_DEBUG("eatt_support=%d", eatt_support);
  if (!bta_sys_is_register(BTA_ID_GATTC)) {
    LOG_DEBUG("BTA_ID_GATTC not registered in BTA, registering it");
    bta_sys_register(BTA_ID_GATTC, &bta_gattc_reg);
  }

  do_in_main_thread(
      FROM_HERE, base::Bind(&bta_gattc_register, Uuid::GetRandom(), p_client_cb,
+4 −2
Original line number Diff line number Diff line
@@ -21,12 +21,14 @@
 *  This file contains the GATT client main functions and state machine.
 *
 ******************************************************************************/
#define LOG_TAG "bta_gattc_main"

#include <base/logging.h>
#include <base/strings/stringprintf.h>

#include "bt_target.h"  // Must be first to define build configuration"
#include "bta/gatt/bta_gattc_int.h"
#include "osi/include/log.h"
#include "stack/include/bt_hdr.h"

using base::StringPrintf;
@@ -386,11 +388,11 @@ bool bta_gattc_hdl_event(BT_HDR_RIGID* p_msg) {
      else
        p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific);

      if (p_clcb != NULL) {
      if (p_clcb != nullptr) {
        rt = bta_gattc_sm_execute(p_clcb, p_msg->event,
                                  (const tBTA_GATTC_DATA*)p_msg);
      } else {
        VLOG(1) << "Ignore unknown conn ID: " << +p_msg->layer_specific;
        LOG_ERROR("Ignore unknown conn ID: %d", +p_msg->layer_specific);
      }

      break;
+3 −2
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ extern const btgatt_callbacks_t* bt_gatt_callbacks;
      LOG_WARN("%s: BTGATT not initialized", __func__); \
      return BT_STATUS_NOT_READY;                       \
    } else {                                            \
      LOG_VERBOSE("%s", __func__);                      \
      LOG_DEBUG("%s", __func__);                        \
    }                                                   \
  } while (0)

@@ -173,7 +173,8 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param) {
    }

    case BTA_GATTC_OPEN_EVT: {
      DVLOG(1) << "BTA_GATTC_OPEN_EVT " << p_data->open.remote_bda;
      LOG_DEBUG("BTA_GATTC_OPEN_EVT %s",
                p_data->open.remote_bda.ToString().c_str());
      HAL_CBACK(bt_gatt_callbacks, client->open_cb, p_data->open.conn_id,
                p_data->open.status, p_data->open.client_if,
                p_data->open.remote_bda);
Loading