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

Commit 30dfe042 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Gerrit Code Review
Browse files

Merge "bta_gattc: Fix number of max gatt connection client control blocks" into main

parents e5b34d16 b6e2ac00
Loading
Loading
Loading
Loading
+4 −6
Original line number Original line Diff line number Diff line
@@ -248,7 +248,7 @@ void bta_gattc_deregister(tBTA_GATTC_RCB* p_clreg) {
  }
  }


  /* close all CLCB related to this app */
  /* close all CLCB related to this app */
  for (uint8_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) {
  for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) {
    if (!bta_gattc_cb.clcb[i].in_use || (bta_gattc_cb.clcb[i].p_rcb != p_clreg))
    if (!bta_gattc_cb.clcb[i].in_use || (bta_gattc_cb.clcb[i].p_rcb != p_clreg))
      continue;
      continue;


@@ -698,7 +698,7 @@ void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) {


/** when a SRCB finished discovery, tell all related clcb */
/** when a SRCB finished discovery, tell all related clcb */
void bta_gattc_reset_discover_st(tBTA_GATTC_SERV* p_srcb, tGATT_STATUS status) {
void bta_gattc_reset_discover_st(tBTA_GATTC_SERV* p_srcb, tGATT_STATUS status) {
  for (uint8_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) {
  for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) {
    if (bta_gattc_cb.clcb[i].p_srcb == p_srcb) {
    if (bta_gattc_cb.clcb[i].p_srcb == p_srcb) {
      bta_gattc_cb.clcb[i].status = status;
      bta_gattc_cb.clcb[i].status = status;
      bta_gattc_sm_execute(&bta_gattc_cb.clcb[i], BTA_GATTC_DISCOVER_CMPL_EVT,
      bta_gattc_sm_execute(&bta_gattc_cb.clcb[i], BTA_GATTC_DISCOVER_CMPL_EVT,
@@ -729,9 +729,7 @@ void bta_gattc_disc_close(tBTA_GATTC_CLCB* p_clcb,


/** when a SRCB start discovery, tell all related clcb and set the state */
/** when a SRCB start discovery, tell all related clcb and set the state */
static void bta_gattc_set_discover_st(tBTA_GATTC_SERV* p_srcb) {
static void bta_gattc_set_discover_st(tBTA_GATTC_SERV* p_srcb) {
  uint8_t i;
  for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) {

  for (i = 0; i < BTA_GATTC_CLCB_MAX; i++) {
    if (bta_gattc_cb.clcb[i].p_srcb == p_srcb) {
    if (bta_gattc_cb.clcb[i].p_srcb == p_srcb) {
      bta_gattc_cb.clcb[i].status = GATT_SUCCESS;
      bta_gattc_cb.clcb[i].status = GATT_SUCCESS;
      bta_gattc_cb.clcb[i].state = BTA_GATTC_DISCOVER_ST;
      bta_gattc_cb.clcb[i].state = BTA_GATTC_DISCOVER_ST;
@@ -1450,7 +1448,7 @@ void bta_gattc_process_api_refresh(const RawAddress& remote_bda) {
    if (p_srvc_cb->connected && p_srvc_cb->num_clcb != 0) {
    if (p_srvc_cb->connected && p_srvc_cb->num_clcb != 0) {
      bool found = false;
      bool found = false;
      tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0];
      tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0];
      for (uint8_t i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) {
      for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) {
        if (p_clcb->in_use && p_clcb->p_srcb == p_srvc_cb) {
        if (p_clcb->in_use && p_clcb->p_srcb == p_srvc_cb) {
          found = true;
          found = true;
          break;
          break;
+6 −2
Original line number Original line Diff line number Diff line
@@ -70,7 +70,7 @@ typedef uint16_t tBTA_GATTC_INT_EVT;


#define BTA_GATTC_SERVICE_CHANGED_LEN 4
#define BTA_GATTC_SERVICE_CHANGED_LEN 4


/* max client application GATTC can support */
/* Max client application GATTC can support */
#ifndef BTA_GATTC_CL_MAX
#ifndef BTA_GATTC_CL_MAX
#define BTA_GATTC_CL_MAX 32
#define BTA_GATTC_CL_MAX 32
#endif
#endif
@@ -80,8 +80,12 @@ typedef uint16_t tBTA_GATTC_INT_EVT;
#define BTA_GATTC_KNOWN_SR_MAX 255
#define BTA_GATTC_KNOWN_SR_MAX 255
#endif
#endif


/* This represents number of gatt client control blocks per connection.
 *  Because of that this value shall depends on the number of possible GATT
 *  connections  GATT_MAX_PHY_CHANNEL
 */
#ifndef BTA_GATTC_CLCB_MAX
#ifndef BTA_GATTC_CLCB_MAX
#define BTA_GATTC_CLCB_MAX GATT_CL_MAX_LCB
#define BTA_GATTC_CLCB_MAX ((GATT_MAX_PHY_CHANNEL) * (BTA_GATTC_CL_MAX))
#endif
#endif


#define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE
#define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE
+4 −7
Original line number Original line Diff line number Diff line
@@ -98,9 +98,8 @@ tBTA_GATTC_CLCB* bta_gattc_find_clcb_by_cif(uint8_t client_if,
                                            const RawAddress& remote_bda,
                                            const RawAddress& remote_bda,
                                            tBT_TRANSPORT transport) {
                                            tBT_TRANSPORT transport) {
  tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0];
  tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0];
  uint8_t i;


  for (i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) {
  for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) {
    if (p_clcb->in_use && p_clcb->p_rcb->client_if == client_if &&
    if (p_clcb->in_use && p_clcb->p_rcb->client_if == client_if &&
        p_clcb->transport == transport && p_clcb->bda == remote_bda)
        p_clcb->transport == transport && p_clcb->bda == remote_bda)
      return p_clcb;
      return p_clcb;
@@ -118,9 +117,8 @@ tBTA_GATTC_CLCB* bta_gattc_find_clcb_by_cif(uint8_t client_if,
 ******************************************************************************/
 ******************************************************************************/
tBTA_GATTC_CLCB* bta_gattc_find_clcb_by_conn_id(uint16_t conn_id) {
tBTA_GATTC_CLCB* bta_gattc_find_clcb_by_conn_id(uint16_t conn_id) {
  tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0];
  tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[0];
  uint8_t i;


  for (i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) {
  for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++, p_clcb++) {
    if (p_clcb->in_use && p_clcb->bta_conn_id == conn_id) return p_clcb;
    if (p_clcb->in_use && p_clcb->bta_conn_id == conn_id) return p_clcb;
  }
  }
  return NULL;
  return NULL;
@@ -138,10 +136,9 @@ tBTA_GATTC_CLCB* bta_gattc_find_clcb_by_conn_id(uint16_t conn_id) {
tBTA_GATTC_CLCB* bta_gattc_clcb_alloc(tGATT_IF client_if,
tBTA_GATTC_CLCB* bta_gattc_clcb_alloc(tGATT_IF client_if,
                                      const RawAddress& remote_bda,
                                      const RawAddress& remote_bda,
                                      tBT_TRANSPORT transport) {
                                      tBT_TRANSPORT transport) {
  uint8_t i_clcb = 0;
  tBTA_GATTC_CLCB* p_clcb = NULL;
  tBTA_GATTC_CLCB* p_clcb = NULL;


  for (i_clcb = 0; i_clcb < BTA_GATTC_CLCB_MAX; i_clcb++) {
  for (int i_clcb = 0; i_clcb < BTA_GATTC_CLCB_MAX; i_clcb++) {
    if (!bta_gattc_cb.clcb[i_clcb].in_use) {
    if (!bta_gattc_cb.clcb[i_clcb].in_use) {
#if (BTA_GATT_DEBUG == TRUE)
#if (BTA_GATT_DEBUG == TRUE)
      log::verbose("found clcb:{} available", i_clcb);
      log::verbose("found clcb:{} available", i_clcb);
@@ -864,7 +861,7 @@ void bta_gatt_client_dump(int fd) {
  stream << "  -- used: " << entry_count << "\n";
  stream << "  -- used: " << entry_count << "\n";
  entry_count = 0;
  entry_count = 0;
  stream << " ->clcb (BTA_GATTC_CLCB_MAX=" << BTA_GATTC_CLCB_MAX << ")\n";
  stream << " ->clcb (BTA_GATTC_CLCB_MAX=" << BTA_GATTC_CLCB_MAX << ")\n";
  for (int i = 0; i < BTA_GATTC_CLCB_MAX; i++) {
  for (size_t i = 0; i < BTA_GATTC_CLCB_MAX; i++) {
    tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[i];
    tBTA_GATTC_CLCB* p_clcb = &bta_gattc_cb.clcb[i];
    if (!p_clcb->in_use) {
    if (!p_clcb->in_use) {
      continue;
      continue;