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

Commit 144f22f7 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Use gap_on_l2cap_error for error handling

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I8faaa5f586e3133d1a5c7ff890ad27a87ee9433a
parent 58f8601d
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -683,6 +683,16 @@ static void gap_sec_check_complete(const RawAddress*, tBT_TRANSPORT,
  }
}

static void gap_on_l2cap_error(uint16_t l2cap_cid, uint16_t result) {
  tGAP_CCB* p_ccb = gap_find_ccb_by_cid(l2cap_cid);

  /* Tell the user if there is a callback */
  if (p_ccb->p_callback)
    (*p_ccb->p_callback)(p_ccb->gap_handle, GAP_EVT_CONN_CLOSED, nullptr);

  gap_release_ccb(p_ccb);
}

/*******************************************************************************
 *
 * Function         gap_connect_cfm
@@ -728,11 +738,7 @@ static void gap_connect_cfm(uint16_t l2cap_cid, uint16_t result) {
      gap_checks_con_flags(p_ccb);
    }
  } else {
    /* Tell the user if there is a callback */
    if (p_ccb->p_callback)
      (*p_ccb->p_callback)(p_ccb->gap_handle, GAP_EVT_CONN_CLOSED, nullptr);

    gap_release_ccb(p_ccb);
    gap_on_l2cap_error(l2cap_cid, result);
  }
}

@@ -789,8 +795,7 @@ static void gap_config_cfm(uint16_t l2cap_cid, uint16_t result) {
    p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE;
    gap_checks_con_flags(p_ccb);
  } else {
    p_ccb->p_callback(p_ccb->gap_handle, GAP_EVT_CONN_CLOSED, nullptr);
    gap_release_ccb(p_ccb);
    gap_on_l2cap_error(l2cap_cid, result);
  }
}