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

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

Merge changes I1bfb4c54,I1d3351eb into tm-qpr-dev

* changes:
  gatt: Remove reduntant `in_use` flag
  gatt: Improve send queued request from tGATT_TCB
parents bd60a4ec 642e554c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1170,7 +1170,7 @@ void GATT_Deregister(tGATT_IF gatt_if) {

    for (auto clcb_it = gatt_cb.clcb_queue.begin();
         clcb_it != gatt_cb.clcb_queue.end();) {
      if (clcb_it->in_use && (clcb_it->p_reg->gatt_if == gatt_if) &&
      if ((clcb_it->p_reg->gatt_if == gatt_if) &&
          (clcb_it->p_tcb->tcb_idx == p_tcb->tcb_idx)) {
        alarm_cancel(clcb_it->gatt_rsp_timer_ent);
        gatt_clcb_invalidate(p_tcb, &(*clcb_it));
+10 −9
Original line number Diff line number Diff line
@@ -1132,9 +1132,10 @@ uint8_t gatt_cmd_to_rsp_code(uint8_t cmd_code) {
bool gatt_cl_send_next_cmd_inq(tGATT_TCB& tcb) {
  std::deque<tGATT_CMD_Q>* cl_cmd_q = nullptr;

  while (!tcb.cl_cmd_q.empty() ||
  while (
      gatt_is_outstanding_msg_in_att_send_queue(tcb) ||
      EattExtension::GetInstance()->IsOutstandingMsgInSendQueue(tcb.peer_bda)) {
    if (!tcb.cl_cmd_q.empty()) {
    if (gatt_is_outstanding_msg_in_att_send_queue(tcb)) {
      cl_cmd_q = &tcb.cl_cmd_q;
    } else {
      EattChannel* channel =
@@ -1204,6 +1205,12 @@ void gatt_client_handle_server_rsp(tGATT_TCB& tcb, uint16_t cid,

  uint8_t cmd_code = 0;
  tGATT_CLCB* p_clcb = gatt_cmd_dequeue(tcb, cid, &cmd_code);
  if (!p_clcb) {
    LOG_WARN("ATT - clcb already not in use, ignoring response");
    gatt_cl_send_next_cmd_inq(tcb);
    return;
  }

  uint8_t rsp_code = gatt_cmd_to_rsp_code(cmd_code);
  if (!p_clcb) {
    LOG_WARN("ATT - clcb already not in use, ignoring response");
@@ -1218,12 +1225,6 @@ void gatt_client_handle_server_rsp(tGATT_TCB& tcb, uint16_t cid,
    return;
  }

  if (!p_clcb->in_use) {
    LOG(WARNING) << "ATT - clcb already not in use, ignoring response";
    gatt_cl_send_next_cmd_inq(tcb);
    return;
  }

  gatt_stop_rsp_timer(p_clcb);
  p_clcb->retry_count = 0;

+1 −1
Original line number Diff line number Diff line
@@ -370,7 +370,6 @@ struct tGATT_CLCB {
  tGATT_STATUS status;     /* operation status */
  bool first_read_blob_after_read;
  tGATT_READ_INC_UUID128 read_uuid128;
  bool in_use;
  alarm_t* gatt_rsp_timer_ent; /* peer response timer */
  uint8_t retry_count;
  uint16_t read_req_current_mtu; /* This is the MTU value that the read was
@@ -646,6 +645,7 @@ extern void gatt_client_handle_server_rsp(tGATT_TCB& tcb, uint16_t cid,
                                          uint8_t* p_data);
extern void gatt_send_queue_write_cancel(tGATT_TCB& tcb, tGATT_CLCB* p_clcb,
                                         tGATT_EXEC_FLAG flag);
extern bool gatt_is_outstanding_msg_in_att_send_queue(const tGATT_TCB& tcb);

/* gatt_auth.cc */
extern bool gatt_security_check_start(tGATT_CLCB* p_clcb);
+14 −3
Original line number Diff line number Diff line
@@ -983,7 +983,6 @@ tGATT_CLCB* gatt_clcb_alloc(uint16_t conn_id) {
  tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(tcb_idx);
  tGATT_REG* p_reg = gatt_get_regcb(gatt_if);

  clcb.in_use = true;
  clcb.conn_id = conn_id;
  clcb.p_reg = p_reg;
  clcb.p_tcb = p_tcb;
@@ -1137,7 +1136,7 @@ uint16_t gatt_tcb_get_payload_size_rx(tGATT_TCB& tcb, uint16_t cid) {
 *
 ******************************************************************************/
void gatt_clcb_dealloc(tGATT_CLCB* p_clcb) {
  if (p_clcb && p_clcb->in_use) {
  if (p_clcb) {
    alarm_free(p_clcb->gatt_rsp_timer_ent);
    for (auto clcb_it = gatt_cb.clcb_queue.begin();
         clcb_it != gatt_cb.clcb_queue.end(); clcb_it++) {
@@ -1232,7 +1231,7 @@ uint8_t gatt_num_clcb_by_bd_addr(const RawAddress& bda) {
  uint8_t num = 0;

  for (auto const& clcb : gatt_cb.clcb_queue) {
    if (clcb.in_use && clcb.p_tcb->peer_bda == bda) num++;
    if (clcb.p_tcb->peer_bda == bda) num++;
  }
  return num;
}
@@ -1525,6 +1524,18 @@ tGATT_STATUS gatt_send_write_msg(tGATT_TCB& tcb, tGATT_CLCB* p_clcb,
  return attp_send_cl_msg(tcb, p_clcb, op_code, &msg);
}

/*******************************************************************************
 *
 * Function         gatt_is_outstanding_msg_in_att_send_queue
 *
 * Description      checks if there is message on the ATT fixed channel to send
 *
 * Returns          true: on success; false otherwise
 *
 ******************************************************************************/
bool gatt_is_outstanding_msg_in_att_send_queue(const tGATT_TCB& tcb) {
  return (!tcb.cl_cmd_q.empty() && (tcb.cl_cmd_q.front()).to_send);
}
/*******************************************************************************
 *
 * Function         gatt_end_operation