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

Commit 9a7382d0 authored by Henri Chataing's avatar Henri Chataing
Browse files

system/stack/eatt: Migrate to libbluetooth_log

Test: m com.android.btservices
Bug: 305066880
Flag: EXEMPT, mechanical refactor
Change-Id: I60617a1445cff06b6da6cf9b36becd8330a8ea78
parent 024c4b1d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1454,6 +1454,7 @@ cc_test {
        "libcutils",
    ],
    static_libs: [
        "libbase",
        "libbluetooth-types",
        "libbluetooth_gd",
        "libbluetooth_log",
+4 −4
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 * limitations under the License.
 */

#include <base/logging.h>
#include <bluetooth/log.h>

#include "eatt_impl.h"
#include "stack/include/bt_hdr.h"
@@ -33,7 +33,7 @@ struct EattExtension::impl {

  void Start() {
    if (eatt_impl_) {
      LOG(ERROR) << "Eatt already started";
      log::error("Eatt already started");
      return;
    };

@@ -48,7 +48,7 @@ struct EattExtension::impl {
    reg_info_.pL2CA_CreditBasedCollisionInd_Cb = eatt_collision_ind;

    if (L2CA_RegisterLECoc(BT_PSM_EATT, reg_info_, BTM_SEC_NONE, {}) == 0) {
      LOG(ERROR) << __func__ << " cannot register EATT";
      log::error("cannot register EATT");
    } else {
      eatt_impl_ = std::make_unique<eatt_impl>();
    }
@@ -56,7 +56,7 @@ struct EattExtension::impl {

  void Stop() {
    if (!eatt_impl_) {
      LOG(ERROR) << "Eatt not started";
      log::error("Eatt not started");
      return;
    }
    eatt_impl_.reset(nullptr);
+118 −123
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
 */

#include <base/logging.h>
#include <bluetooth/log.h>

#include <map>
#include <vector>
@@ -114,8 +115,8 @@ struct eatt_impl {
  void remove_channel_by_cid(eatt_device* eatt_dev, uint16_t lcid) {
    auto channel = eatt_dev->eatt_channels[lcid];
    if (!channel->cl_cmd_q_.empty()) {
      LOG_WARN("Channel %c, for device %s is not empty on disconnection.", lcid,
               channel->bda_.ToString().c_str());
      log::warn("Channel {:c}, for device {} is not empty on disconnection.",
                lcid, ADDRESS_TO_LOGGABLE_STR(channel->bda_));
      channel->cl_cmd_q_.clear();
    }

@@ -144,8 +145,8 @@ struct eatt_impl {
       * for LE case it is not necessary to read it before establish connection.
       * Therefore assume, device supports EATT since we got request to create
       * EATT channels. Just create device here. */
      LOG(INFO) << __func__ << " Adding device: " << bda
                << " on incoming EATT creation request";
      log::info("Adding device: {} on incoming EATT creation request",
                ADDRESS_TO_LOGGABLE_STR(bda));
      eatt_dev = add_eatt_device(bda);
    }

@@ -178,7 +179,7 @@ struct eatt_impl {
      chan->EattChannelSetState(EattChannelState::EATT_CHANNEL_OPENED);
      eatt_dev->eatt_tcb_->eatt++;

      LOG(INFO) << __func__ << " Channel connected CID " << loghex(cid);
      log::info("Channel connected CID {}", loghex(cid));
    }

    return true;
@@ -190,7 +191,7 @@ struct eatt_impl {
    eatt_device* eatt_dev = find_device_by_address(bda);
    auto num_of_sdu =
        stack_config_get_interface()->get_pts_l2cap_ecoc_send_num_of_sdu();
    LOG_INFO(" device %s, num: %d", ADDRESS_TO_LOGGABLE_CSTR(eatt_dev->bda_),
    log::info("device {}, num: {}", ADDRESS_TO_LOGGABLE_CSTR(eatt_dev->bda_),
              num_of_sdu);

    if (num_of_sdu <= 0) {
@@ -213,7 +214,7 @@ struct eatt_impl {
    }

    if (cid == 0 || mtu == 0) {
      LOG_ERROR("There is no OPEN cid or MTU is 0");
      log::error("There is no OPEN cid or MTU is 0");
      return;
    }

@@ -223,16 +224,17 @@ struct eatt_impl {
      p_buf->len = mtu;

      auto status = L2CA_DataWrite(cid, p_buf);
      LOG_INFO("Data num: %d sent with status %d", i, static_cast<int>(status));
      log::info("Data num: {} sent with status {}", i,
                static_cast<int>(status));
    }
  }

  /* This is for the L2CAP ECoC Testing. */
  void upper_tester_delay_connect_cb(const RawAddress& bda) {
    LOG_INFO("device %s", ADDRESS_TO_LOGGABLE_CSTR(bda));
    log::info("device {}", ADDRESS_TO_LOGGABLE_CSTR(bda));
    eatt_device* eatt_dev = find_device_by_address(bda);
    if (eatt_dev == nullptr) {
      LOG_ERROR(" device is not available");
      log::error("device is not available");
      return;
    }

@@ -246,7 +248,7 @@ struct eatt_impl {
                       weak_factory_.GetWeakPtr(), bda),
        std::chrono::milliseconds(timeout_ms));

    LOG_INFO("Scheduled peripheral connect eatt for device with status: %d",
    log::info("Scheduled peripheral connect eatt for device with status: {}",
              (int)status);
  }

@@ -261,7 +263,7 @@ struct eatt_impl {
      auto key_size = btm_ble_read_sec_key_size(bda);
      if (key_size < min_key_size) {
        std::vector<uint16_t> empty;
        LOG_ERROR("Insufficient key size (%d<%d) for device %s", key_size,
        log::error("Insufficient key size ({}<{}) for device {}", key_size,
                   min_key_size, ADDRESS_TO_LOGGABLE_CSTR(bda));
        L2CA_ConnectCreditBasedRsp(bda, identifier, empty,
                                   L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP_KEY_SIZE,
@@ -271,7 +273,7 @@ struct eatt_impl {
    }

    if (!eatt_l2cap_connect_ind_common(bda, lcids, psm, peer_mtu, identifier)) {
      LOG_DEBUG("Reject L2CAP Connection request.");
      log::debug("Reject L2CAP Connection request.");
      return;
    }

@@ -292,16 +294,16 @@ struct eatt_impl {
          base::BindOnce(&eatt_impl::reconfigure_all,
                         weak_factory_.GetWeakPtr(), bda, 300),
          std::chrono::seconds(4));
      LOG_INFO("Scheduled ECOC reconfiguration with status: %d", (int)status);
      log::info("Scheduled ECOC reconfiguration with status: {}", (int)status);
    }
  }

  void eatt_l2cap_connect_ind(const RawAddress& bda,
                              std::vector<uint16_t>& lcids, uint16_t psm,
                              uint16_t peer_mtu, uint8_t identifier) {
    LOG_INFO("Device %s, num of cids: %d, psm 0x%04x, peer_mtu %d",
             ADDRESS_TO_LOGGABLE_CSTR(bda), static_cast<int>(lcids.size()), psm,
             peer_mtu);
    log::info("Device {}, num of cids: {}, psm 0x{:04x}, peer_mtu {}",
              ADDRESS_TO_LOGGABLE_CSTR(bda), static_cast<int>(lcids.size()),
              psm, peer_mtu);

    if (!stack_config_get_interface()
             ->get_pts_connect_eatt_before_encryption() &&
@@ -312,14 +314,14 @@ struct eatt_impl {
      if (BTM_IsLinkKeyKnown(bda, BT_TRANSPORT_LE)) {
        result = L2CAP_LE_RESULT_INSUFFICIENT_ENCRYP;
      }
      LOG_ERROR("ACL to device %s is unencrypted.",
      log::error("ACL to device {} is unencrypted.",
                 ADDRESS_TO_LOGGABLE_CSTR(bda));
      L2CA_ConnectCreditBasedRsp(bda, identifier, empty, result, nullptr);
      return;
    }

    if (stack_config_get_interface()->get_pts_l2cap_ecoc_upper_tester()) {
      LOG_INFO(" Upper tester for the L2CAP ECoC enabled");
      log::info("Upper tester for the L2CAP ECoC enabled");
      return upper_tester_l2cap_connect_ind(bda, lcids, psm, peer_mtu,
                                            identifier);
    }
@@ -329,21 +331,20 @@ struct eatt_impl {

  void eatt_retry_after_collision_if_needed(eatt_device* eatt_dev) {
    if (!eatt_dev->collision) {
      LOG_DEBUG("No collision.");
      log::debug("No collision.");
      return;
    }
    /* We are here, because remote device wanted to create channels when
     * Android proceed its own EATT creation. How to handle it is described
     * here: BT Core 5.3, Volume 3, Part G, 5.4
     */
    LOG_INFO(
        "EATT collision detected. If we are Central we will retry right "
        "away");
    log::info(
        "EATT collision detected. If we are Central we will retry right away");

    eatt_dev->collision = false;
    uint8_t role = L2CA_GetBleConnRole(eatt_dev->bda_);
    if (role == HCI_ROLE_CENTRAL) {
      LOG_INFO("Retrying EATT setup due to previous collision for device %s",
      log::info("Retrying EATT setup due to previous collision for device {}",
                ADDRESS_TO_LOGGABLE_CSTR(eatt_dev->bda_));
      connect_eatt_wrap(eatt_dev);
    } else if (stack_config_get_interface()
@@ -357,17 +358,17 @@ struct eatt_impl {

  /* This is for the L2CAP ECoC Testing. */
  void upper_tester_l2cap_connect_cfm(eatt_device* eatt_dev) {
    LOG_INFO("Upper tester for L2CAP Ecoc %s",
    log::info("Upper tester for L2CAP Ecoc {}",
              ADDRESS_TO_LOGGABLE_CSTR(eatt_dev->bda_));
    if (is_channel_connection_pending(eatt_dev)) {
      LOG_INFO(" Waiting for all channels to be connected");
      log::info("Waiting for all channels to be connected");
      return;
    }

    if (stack_config_get_interface()->get_pts_l2cap_ecoc_connect_remaining() &&
        (static_cast<int>(eatt_dev->eatt_channels.size()) <
         L2CAP_CREDIT_BASED_MAX_CIDS)) {
      LOG_INFO("Connecting remaining channels %d",
      log::info("Connecting remaining channels {}",
                L2CAP_CREDIT_BASED_MAX_CIDS -
                    static_cast<int>(eatt_dev->eatt_channels.size()));
      upper_tester_delay_connect(eatt_dev->bda_, 1000);
@@ -378,24 +379,23 @@ struct eatt_impl {

  void eatt_l2cap_connect_cfm(const RawAddress& bda, uint16_t lcid,
                              uint16_t peer_mtu, uint16_t result) {
    LOG(INFO) << __func__ << " bda: " << bda << " cid: " << +lcid
              << "peer mtu: " << +peer_mtu << " result " << +result;
    log::info("bda: {} cid: {}peer mtu: {} result {}",
              ADDRESS_TO_LOGGABLE_STR(bda), +lcid, +peer_mtu, +result);

    eatt_device* eatt_dev = find_device_by_address(bda);
    if (!eatt_dev) {
      LOG(ERROR) << __func__ << " unknown device";
      log::error("unknown device");
      return;
    }

    EattChannel* channel = this->find_channel_by_cid(bda, lcid);
    if (!channel) {
      LOG(ERROR) << __func__ << " unknown cid: " << loghex(lcid);
      log::error("unknown cid: {}", loghex(lcid));
      return;
    }

    if (result != L2CAP_CONN_OK) {
      LOG(ERROR) << __func__
                 << " Could not connect CoC result: " << loghex(result);
      log::error("Could not connect CoC result: {}", loghex(result));
      remove_channel_by_cid(eatt_dev, lcid);

      /* If there is no channels connected, check if there was collision */
@@ -412,7 +412,7 @@ struct eatt_impl {
    CHECK(eatt_dev->bda_ == channel->bda_);
    eatt_dev->eatt_tcb_->eatt++;

    LOG_INFO("Channel connected CID 0x%04x", lcid);
    log::info("Channel connected CID 0x{:04x}", lcid);

    if (stack_config_get_interface()->get_pts_l2cap_ecoc_upper_tester()) {
      upper_tester_l2cap_connect_cfm(eatt_dev);
@@ -422,8 +422,7 @@ struct eatt_impl {
  void eatt_l2cap_reconfig_completed(const RawAddress& bda, uint16_t lcid,
                                     bool is_local_cfg,
                                     tL2CAP_LE_CFG_INFO* p_cfg) {
    LOG(INFO) << __func__ << "lcid: " << loghex(lcid)
              << " local cfg?: " << is_local_cfg;
    log::info("lcid: {} local cfg?: {}", loghex(lcid), is_local_cfg);

    EattChannel* channel = find_channel_by_cid(bda, lcid);
    if (!channel) return;
@@ -432,8 +431,8 @@ struct eatt_impl {
    channel->EattChannelSetState(EattChannelState::EATT_CHANNEL_OPENED);

    if (p_cfg->result != L2CAP_CFG_OK) {
      LOG(INFO) << __func__ << " reconfig failed lcid: " << loghex(lcid)
                << " result: " << loghex(p_cfg->result);
      log::info("reconfig failed lcid: {} result: {}", loghex(lcid),
                loghex(p_cfg->result));
      return;
    }

@@ -457,7 +456,7 @@ struct eatt_impl {
  void eatt_l2cap_collision_ind(const RawAddress& bda) {
    eatt_device* eatt_dev = find_device_by_address(bda);
    if (!eatt_dev) {
      LOG_ERROR("Device %s not available anymore:",
      log::error("Device {} not available anymore:",
                 ADDRESS_TO_LOGGABLE_CSTR(bda));
      return;
    }
@@ -467,14 +466,13 @@ struct eatt_impl {
  }

  void eatt_l2cap_error_cb(uint16_t lcid, uint16_t reason) {
    LOG(INFO) << __func__ << " cid: " << loghex(lcid) << " reason "
              << loghex(reason);
    log::info("cid: {} reason {}", loghex(lcid), loghex(reason));

    /*TODO: provide address in the L2CAP callback */

    EattChannel* channel = find_channel_by_cid(lcid);
    if (!channel) {
      LOG(ERROR) << __func__ << "Unknown lcid";
      log::error("Unknown lcid");
      return;
    }

@@ -482,17 +480,16 @@ struct eatt_impl {

    switch (channel->state_) {
      case EattChannelState::EATT_CHANNEL_PENDING:
        LOG(ERROR) << "Connecting failed";
        log::error("Connecting failed");
        remove_channel_by_cid(eatt_dev, lcid);
        break;
      case EattChannelState::EATT_CHANNEL_RECONFIGURING:
        /* Just go back to open state */
        LOG(ERROR) << "Reconfig failed";
        log::error("Reconfig failed");
        channel->EattChannelSetState(EattChannelState::EATT_CHANNEL_OPENED);
        break;
      default:
        LOG(ERROR) << __func__ << "Invalid state: "
                   << static_cast<uint8_t>(channel->state_);
        log::error("Invalid state: {}", static_cast<uint8_t>(channel->state_));
        break;
    }

@@ -502,10 +499,10 @@ struct eatt_impl {
  }

  void eatt_l2cap_disconnect_ind(uint16_t lcid, bool please_confirm) {
    LOG(INFO) << __func__ << " cid: " << loghex(lcid);
    log::info("cid: {}", loghex(lcid));
    eatt_device* eatt_dev = find_device_by_cid(lcid);
    if (!eatt_dev) {
      LOG(ERROR) << __func__ << " unknown cid: " << loghex(lcid);
      log::error("unknown cid: {}", loghex(lcid));
      return;
    }

@@ -514,17 +511,16 @@ struct eatt_impl {
  }

  void eatt_l2cap_data_ind(uint16_t lcid, BT_HDR* data_p) {
    LOG(INFO) << __func__ << " cid: " << loghex(lcid);
    log::info("cid: {}", loghex(lcid));
    eatt_device* eatt_dev = find_device_by_cid(lcid);
    if (!eatt_dev) {
      LOG(ERROR) << __func__ << " unknown cid: " << loghex(lcid);
      log::error("unknown cid: {}", loghex(lcid));
      return;
    }

    EattChannel* channel = find_channel_by_cid(eatt_dev->bda_, lcid);
    if (!channel) {
      LOG(ERROR) << __func__ << "Received data on closed channel "
                 << loghex(lcid);
      log::error("Received data on closed channel {}", loghex(lcid));
      return;
    }

@@ -554,7 +550,7 @@ struct eatt_impl {
    if (stack_config_get_interface()
            ->get_pts_eatt_peripheral_collision_support()) {
      /* For PTS case, lets assume we support only 5 channels */
      LOG_INFO("Number of existing channels %d",
      log::info("Number of existing channels {}",
                (int)eatt_dev->eatt_channels.size());
      connect_eatt(eatt_dev, L2CAP_CREDIT_BASED_MAX_CIDS -
                                 (int)eatt_dev->eatt_channels.size());
@@ -577,7 +573,7 @@ struct eatt_impl {
        .number_of_channels = num_of_channels,
    };

    LOG_INFO("Connecting device %s, cnt count %d",
    log::info("Connecting device {}, cnt count {}",
              ADDRESS_TO_LOGGABLE_CSTR(eatt_dev->bda_), num_of_channels);

    /* Warning! CIDs in Android are unique across the ACL connections */
@@ -585,16 +581,15 @@ struct eatt_impl {
        L2CA_ConnectCreditBasedReq(psm_, eatt_dev->bda_, &local_coc_cfg);

    if (connecting_cids.size() == 0) {
      LOG(ERROR) << "Unable to get cid";
      log::error("Unable to get cid");
      return;
    }

    LOG(INFO) << __func__
              << "Successfully sent CoC request, number of channel: "
              << +connecting_cids.size();
    log::info("Successfully sent CoC request, number of channel: {}",
              +connecting_cids.size());

    for (uint16_t cid : connecting_cids) {
      LOG(INFO) << " \t cid: " << loghex(cid);
      log::info(" \t cid: {}", loghex(cid));

      auto chan = std::make_shared<EattChannel>(eatt_dev->bda_, cid, 0,
                                                eatt_dev->rx_mtu_);
@@ -602,7 +597,7 @@ struct eatt_impl {
    }

    if (eatt_dev->eatt_tcb_) {
      LOG(INFO) << __func__ << " has tcb ? " << eatt_dev->eatt_tcb_;
      log::info("has tcb ? {}", eatt_dev->eatt_tcb_ == nullptr);
      return;
    }

@@ -733,7 +728,7 @@ struct eatt_impl {
    EattChannel* channel = (EattChannel*)data;
    tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(channel->bda_, BT_TRANSPORT_LE);

    LOG(WARNING) << __func__ << ": send ack now";
    log::warn("send ack now");
    attp_send_cl_confirmation_msg(*p_tcb, channel->cid_);
  }

@@ -741,15 +736,15 @@ struct eatt_impl {
    EattChannel* channel = (EattChannel*)data;
    tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(channel->bda_, BT_TRANSPORT_LE);

    LOG(WARNING) << __func__ << " disconnecting...";
    log::warn("disconnecting...");
    gatt_disconnect(p_tcb);
  }

  void start_indication_confirm_timer(const RawAddress& bd_addr, uint16_t cid) {
    EattChannel* channel = find_eatt_channel_by_cid(bd_addr, cid);
    if (!channel) {
      LOG(ERROR) << __func__ << "Unknown cid: " << loghex(cid) << " or device "
                 << bd_addr;
      log::error("Unknown cid: {} or device {}", loghex(cid),
                 ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

@@ -761,8 +756,8 @@ struct eatt_impl {
  void stop_indication_confirm_timer(const RawAddress& bd_addr, uint16_t cid) {
    EattChannel* channel = find_eatt_channel_by_cid(bd_addr, cid);
    if (!channel) {
      LOG(ERROR) << __func__ << "Unknown cid: " << loghex(cid) << " or device "
                 << bd_addr;
      log::error("Unknown cid: {} or device {}", loghex(cid),
                 ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

@@ -772,8 +767,8 @@ struct eatt_impl {
  void start_app_indication_timer(const RawAddress& bd_addr, uint16_t cid) {
    EattChannel* channel = find_eatt_channel_by_cid(bd_addr, cid);
    if (!channel) {
      LOG(ERROR) << __func__ << "Unknown cid: " << loghex(cid) << " or device "
                 << bd_addr;
      log::error("Unknown cid: {} or device {}", loghex(cid),
                 ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

@@ -784,8 +779,8 @@ struct eatt_impl {
  void stop_app_indication_timer(const RawAddress& bd_addr, uint16_t cid) {
    EattChannel* channel = find_eatt_channel_by_cid(bd_addr, cid);
    if (!channel) {
      LOG(ERROR) << __func__ << "Unknown cid: " << loghex(cid) << " or device "
                 << bd_addr;
      log::error("Unknown cid: {} or device {}", loghex(cid),
                 ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

@@ -795,19 +790,19 @@ struct eatt_impl {
  void reconfigure(const RawAddress& bd_addr, uint16_t cid, uint16_t new_mtu) {
    eatt_device* eatt_dev = find_device_by_address(bd_addr);
    if (!eatt_dev) {
      LOG(ERROR) << __func__ << "Unknown device " << bd_addr;
      log::error("Unknown device {}", ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

    EattChannel* channel = find_eatt_channel_by_cid(bd_addr, cid);
    if (!channel) {
      LOG(ERROR) << __func__ << "Unknown cid: " << loghex(cid) << " or device "
                 << bd_addr;
      log::error("Unknown cid: {} or device {}", loghex(cid),
                 ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

    if (new_mtu <= channel->rx_mtu_) {
      LOG(ERROR) << __func__ << "Invalid mtu: " << loghex(new_mtu);
      log::error("Invalid mtu: {}", loghex(new_mtu));
      return;
    }

@@ -816,8 +811,8 @@ struct eatt_impl {
    tL2CAP_LE_CFG_INFO cfg = {.mtu = new_mtu, .mps = eatt_dev->rx_mps_};

    if (!L2CA_ReconfigCreditBasedConnsReq(eatt_dev->bda_, cids, &cfg)) {
      LOG(ERROR) << __func__ << "Could not start reconfig cid: " << loghex(cid)
                 << " or device " << bd_addr;
      log::error("Could not start reconfig cid: {} or device {}", loghex(cid),
                 ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

@@ -825,17 +820,17 @@ struct eatt_impl {
  }

  void reconfigure_all(const RawAddress& bd_addr, uint16_t new_mtu) {
    LOG_INFO(" Device %s, new mtu %d", ADDRESS_TO_LOGGABLE_CSTR(bd_addr),
    log::info("Device {}, new mtu {}", ADDRESS_TO_LOGGABLE_STR(bd_addr),
              new_mtu);
    eatt_device* eatt_dev = find_device_by_address(bd_addr);
    if (!eatt_dev) {
      LOG(ERROR) << __func__ << "Unknown device " << bd_addr;
      log::error("Unknown device {}", ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

    uint8_t num_of_channels = eatt_dev->eatt_channels.size();
    if (num_of_channels == 0) {
      LOG(ERROR) << __func__ << "No channels for device " << bd_addr;
      log::error("No channels for device {}", ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

@@ -849,15 +844,15 @@ struct eatt_impl {
    }

    if (new_mtu <= EATT_MIN_MTU_MPS) {
      LOG(ERROR) << __func__ << "Invalid mtu: " << loghex(new_mtu);
      log::error("Invalid mtu: {}", loghex(new_mtu));
      return;
    }

    tL2CAP_LE_CFG_INFO cfg = {.mtu = new_mtu, .mps = eatt_dev->rx_mps_};

    if (!L2CA_ReconfigCreditBasedConnsReq(eatt_dev->bda_, cids, &cfg)) {
      LOG(ERROR) << __func__ << "Could not start reconfig for device "
                 << bd_addr;
      log::error("Could not start reconfig for device {}",
                 ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

@@ -871,22 +866,21 @@ struct eatt_impl {
                             uint8_t features) {
    bool is_eatt_supported = features & BLE_GATT_SVR_SUP_FEAT_EATT_BITMASK;

    LOG(INFO) << __func__ << " " << bd_addr
              << " is_eatt_supported = " << int(is_eatt_supported);
    log::info("{} is_eatt_supported = {}", ADDRESS_TO_LOGGABLE_STR(bd_addr),
              int(is_eatt_supported));
    if (!is_eatt_supported) return;

    eatt_device* eatt_dev = this->find_device_by_address(bd_addr);
    if (!eatt_dev) {
      LOG(INFO) << __func__ << " Adding device: " << bd_addr
                << " on supported features callback.";
      log::info("Adding device: {} on supported features callback.",
                ADDRESS_TO_LOGGABLE_STR(bd_addr));
      eatt_dev = add_eatt_device(bd_addr);
    }

    if (role != HCI_ROLE_CENTRAL) {
      /* TODO For now do nothing, we could run a timer here and start EATT if
       * not started by central */
      LOG(INFO)
          << " EATT Should be connected by the central. Let's wait for it.";
      log::info(" EATT Should be connected by the central. Let's wait for it.");
      return;
    }

@@ -896,29 +890,29 @@ struct eatt_impl {
  void disconnect_channel(uint16_t cid) { L2CA_DisconnectReq(cid); }

  void disconnect(const RawAddress& bd_addr, uint16_t cid) {
    LOG_INFO(" Device: %s, cid: 0x%04x", ADDRESS_TO_LOGGABLE_CSTR(bd_addr),
    log::info("Device: {}, cid: 0x{:04x}", ADDRESS_TO_LOGGABLE_STR(bd_addr),
              cid);

    eatt_device* eatt_dev = find_device_by_address(bd_addr);
    if (!eatt_dev) {
      LOG(WARNING) << __func__ << " no eatt device found";
      log::warn("no eatt device found");
      return;
    }

    if (!eatt_dev->eatt_tcb_) {
      LOG_ASSERT(eatt_dev->eatt_channels.size() == 0);
      LOG(WARNING) << __func__ << " no eatt channels found";
      log::warn("no eatt channels found");
      return;
    }

    if (cid != EATT_ALL_CIDS) {
      auto chan = find_channel_by_cid(cid);
      if (!chan) {
        LOG_WARN("Cid %d not found for device %s", cid,
        log::warn("Cid {} not found for device {}", cid,
                  ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
        return;
      }
      LOG_INFO("Disconnecting cid %d", cid);
      log::info("Disconnecting cid {}", cid);
      disconnect_channel(cid);
      remove_channel_by_cid(cid);
      return;
@@ -940,9 +934,9 @@ struct eatt_impl {

  void upper_tester_connect(const RawAddress& bd_addr, eatt_device* eatt_dev,
                            uint8_t role) {
    LOG_INFO(
        "L2CAP Upper tester enabled, %s (%p), role: %s(%d)",
        ADDRESS_TO_LOGGABLE_CSTR(bd_addr), eatt_dev,
    log::info(
        "L2CAP Upper tester enabled, {} ({}), role: {}({})",
        ADDRESS_TO_LOGGABLE_STR(bd_addr), fmt::ptr(eatt_dev),
        role == HCI_ROLE_CENTRAL ? "HCI_ROLE_CENTRAL" : "HCI_ROLE_PERIPHERAL",
        role);

@@ -972,7 +966,7 @@ struct eatt_impl {
            bd_addr, base::BindOnce(&eatt_impl::supported_features_cb,
                                    weak_factory_.GetWeakPtr(), role)) ==
        false) {
      LOG_INFO("Read server supported features failed for device %s",
      log::info("Read server supported features failed for device {}",
                ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
    }
  }
@@ -982,7 +976,8 @@ struct eatt_impl {

    uint8_t role = L2CA_GetBleConnRole(bd_addr);
    if (role == HCI_ROLE_UNKNOWN) {
      LOG(ERROR) << __func__ << "Could not get device role" << bd_addr;
      log::error("Could not get device role{}",
                 ADDRESS_TO_LOGGABLE_STR(bd_addr));
      return;
    }

@@ -991,18 +986,18 @@ struct eatt_impl {
      return;
    }

    LOG_INFO("Device %s, role %s", ADDRESS_TO_LOGGABLE_CSTR(bd_addr),
    log::info("Device {}, role {}", ADDRESS_TO_LOGGABLE_CSTR(bd_addr),
              (role == HCI_ROLE_CENTRAL ? "central" : "peripheral"));

    if (eatt_dev) {
      /* We are reconnecting device we know that support EATT.
       * Just connect CoC
       */
      LOG(INFO) << __func__ << " Known device, connect eCoC";
      log::info("Known device, connect eCoC");

      if (role != HCI_ROLE_CENTRAL) {
        LOG(INFO)
            << " EATT Should be connected by the central. Let's wait for it.";
        log::info(
            " EATT Should be connected by the central. Let's wait for it.");
        return;
      }

@@ -1013,7 +1008,7 @@ struct eatt_impl {
    if (role != HCI_ROLE_CENTRAL) return;

    if (gatt_profile_get_eatt_support(bd_addr)) {
      LOG_DEBUG("Eatt is supported for device %s",
      log::debug("Eatt is supported for device {}",
                 ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
      supported_features_cb(role, bd_addr, BLE_GATT_SVR_SUP_FEAT_EATT_BITMASK);
      return;
@@ -1024,7 +1019,7 @@ struct eatt_impl {
            bd_addr, base::BindOnce(&eatt_impl::supported_features_cb,
                                    weak_factory_.GetWeakPtr(), role)) ==
        false) {
      LOG_INFO("Read server supported features failed for device %s",
      log::info("Read server supported features failed for device {}",
                ADDRESS_TO_LOGGABLE_CSTR(bd_addr));
    }
  }
@@ -1032,7 +1027,7 @@ struct eatt_impl {
  void add_from_storage(const RawAddress& bd_addr) {
    eatt_device* eatt_dev = find_device_by_address(bd_addr);

    LOG(INFO) << __func__ << ", restoring: " << bd_addr;
    log::info("restoring: {}", ADDRESS_TO_LOGGABLE_STR(bd_addr));

    if (!eatt_dev) add_eatt_device(bd_addr);
  }