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

Commit e6cd07eb authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

eatt: Fix getting channel with the queue data to send

When GATT is asking about channel with a non empty data queue to send,
EATT shall check also if the outstanding command is scheduled to send or
maybe is already waiting for the response.
Otherwise, we might end up with having channel not beeing used.

Bug: 249992170
Test: atest BluetoothInstrumentationTests
Test: atest --host net_test_eatt
Tag: #feature
Merged-In: Idceaf76847851cc8e256da4a3c4069c9e5cc93fd
Change-Id: Idceaf76847851cc8e256da4a3c4069c9e5cc93fd
(cherry picked from commit e84baf9c)
parent a41e6a01
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ bool EattExtension::IsOutstandingMsgInSendQueue(const RawAddress& bd_addr) {
  return pimpl_->eatt_impl_->is_outstanding_msg_in_send_queue(bd_addr);
}

EattChannel* EattExtension::GetChannelWithQueuedData(
EattChannel* EattExtension::GetChannelWithQueuedDataToSend(
    const RawAddress& bd_addr) {
  return pimpl_->eatt_impl_->get_channel_with_queued_data(bd_addr);
}
+2 −1
Original line number Diff line number Diff line
@@ -224,7 +224,8 @@ class EattExtension {
   *
   * @return pointer to EATT channel.
   */
  virtual EattChannel* GetChannelWithQueuedData(const RawAddress& bd_addr);
  virtual EattChannel* GetChannelWithQueuedDataToSend(
      const RawAddress& bd_addr);

  /**
   * Get EATT channel available to send GATT request.
+8 −2
Original line number Diff line number Diff line
@@ -709,7 +709,10 @@ struct eatt_impl {
    auto iter = find_if(
        eatt_dev->eatt_channels.begin(), eatt_dev->eatt_channels.end(),
        [](const std::pair<uint16_t, std::shared_ptr<EattChannel>>& el) {
          return !el.second->cl_cmd_q_.empty();
          if (el.second->cl_cmd_q_.empty()) return false;

          tGATT_CMD_Q& cmd = el.second->cl_cmd_q_.front();
          return cmd.to_send;
        });
    return (iter != eatt_dev->eatt_channels.end());
  }
@@ -721,7 +724,10 @@ struct eatt_impl {
    auto iter = find_if(
        eatt_dev->eatt_channels.begin(), eatt_dev->eatt_channels.end(),
        [](const std::pair<uint16_t, std::shared_ptr<EattChannel>>& el) {
          return !el.second->cl_cmd_q_.empty();
          if (el.second->cl_cmd_q_.empty()) return false;

          tGATT_CMD_Q& cmd = el.second->cl_cmd_q_.front();
          return cmd.to_send;
        });
    return (iter == eatt_dev->eatt_channels.end()) ? nullptr
                                                   : iter->second.get();
+2 −1
Original line number Diff line number Diff line
@@ -1138,7 +1138,8 @@ bool gatt_cl_send_next_cmd_inq(tGATT_TCB& tcb) {
      cl_cmd_q = &tcb.cl_cmd_q;
    } else {
      EattChannel* channel =
          EattExtension::GetInstance()->GetChannelWithQueuedData(tcb.peer_bda);
          EattExtension::GetInstance()->GetChannelWithQueuedDataToSend(
              tcb.peer_bda);
      cl_cmd_q = &channel->cl_cmd_q_;
    }

+2 −2
Original line number Diff line number Diff line
@@ -86,9 +86,9 @@ bool EattExtension::IsOutstandingMsgInSendQueue(const RawAddress& bd_addr) {
  return pimpl_->IsOutstandingMsgInSendQueue(bd_addr);
}

EattChannel* EattExtension::GetChannelWithQueuedData(
EattChannel* EattExtension::GetChannelWithQueuedDataToSend(
    const RawAddress& bd_addr) {
  return pimpl_->GetChannelWithQueuedData(bd_addr);
  return pimpl_->GetChannelWithQueuedDataToSend(bd_addr);
}

EattChannel* EattExtension::GetChannelAvailableForClientRequest(
Loading