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

Commit 935446da authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "eatt: Disconnect EATT channel on GATT timeout" into tm-d1-dev

parents cb8c44b5 15abef1a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -129,8 +129,8 @@ void EattExtension::Connect(const RawAddress& bd_addr) {
  pimpl_->eatt_impl_->connect(bd_addr);
}

void EattExtension::Disconnect(const RawAddress& bd_addr) {
  pimpl_->eatt_impl_->disconnect(bd_addr);
void EattExtension::Disconnect(const RawAddress& bd_addr, uint16_t cid) {
  pimpl_->eatt_impl_->disconnect(bd_addr, cid);
}

void EattExtension::Reconfigure(const RawAddress& bd_addr, uint16_t cid,
+4 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#define EATT_MIN_MTU_MPS (64)
#define EATT_DEFAULT_MTU (256)
#define EATT_ALL_CIDS (0xFFFF)

namespace bluetooth {
namespace eatt {
@@ -129,8 +130,10 @@ class EattExtension {
   * Disconnect all EATT channels to peer device.
   *
   * @param bd_addr peer device address
   * @param cid remote channel id (EATT_ALL_CIDS for all)
   */
  virtual void Disconnect(const RawAddress& bd_addr);
  virtual void Disconnect(const RawAddress& bd_addr,
                          uint16_t cid = EATT_ALL_CIDS);

  /**
   * Reconfigure EATT channel for give CID
+15 −2
Original line number Diff line number Diff line
@@ -619,8 +619,8 @@ struct eatt_impl {

  void disconnect_channel(uint16_t cid) { L2CA_DisconnectReq(cid); }

  void disconnect(const RawAddress& bd_addr) {
    LOG(INFO) << __func__ << " " << bd_addr;
  void disconnect(const RawAddress& bd_addr, uint16_t cid) {
    LOG_INFO(" Device: %s, cid: 0x%04x", bd_addr.ToString().c_str(), cid);

    eatt_device* eatt_dev = find_device_by_address(bd_addr);
    if (!eatt_dev) {
@@ -634,6 +634,19 @@ struct eatt_impl {
      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,
                 bd_addr.ToString().c_str());
        return;
      }
      LOG_INFO("Disconnecting cid %d", cid);
      disconnect_channel(cid);
      remove_channel_by_cid(cid);
      return;
    }

    auto iter = eatt_dev->eatt_channels.begin();
    while (iter != eatt_dev->eatt_channels.end()) {
      uint16_t cid = iter->first;
+10 −2
Original line number Diff line number Diff line
@@ -664,9 +664,17 @@ void gatt_rsp_timeout(void* data) {
    }
  }

  LOG(WARNING) << __func__ << " disconnecting...";
  auto eatt_channel = EattExtension::GetInstance()->FindEattChannelByCid(
      p_clcb->p_tcb->peer_bda, p_clcb->cid);
  if (eatt_channel) {
    LOG_WARN("disconnecting EATT cid: %d", p_clcb->cid);
    EattExtension::GetInstance()->Disconnect(p_clcb->p_tcb->peer_bda,
                                             p_clcb->cid);
  } else {
    LOG_WARN("disconnecting GATT...");
    gatt_disconnect(p_clcb->p_tcb);
  }
}

extern void gatts_proc_srv_chg_ind_ack(tGATT_TCB tcb);

+2 −2
Original line number Diff line number Diff line
@@ -46,8 +46,8 @@ void EattExtension::Connect(const RawAddress& bd_addr) {
  pimpl_->Connect(bd_addr);
}

void EattExtension::Disconnect(const RawAddress& bd_addr) {
  pimpl_->Disconnect(bd_addr);
void EattExtension::Disconnect(const RawAddress& bd_addr, uint16_t cid) {
  pimpl_->Disconnect(bd_addr, cid);
}

void EattExtension::Reconfigure(const RawAddress& bd_addr, uint16_t cid,
Loading