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

Commit 37efc9bf authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Merge "GATT discovery refactor"

am: f7ba8aa6

Change-Id: Idbf9d442d70b5a4676a9bdc313b1c48ba5d0d648
parents 1724e247 f7ba8aa6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -700,9 +700,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB* p_clcb,
    /* used to reset cache in application */
    bta_gattc_cache_reset(p_clcb->p_srcb->server_bda);
  }
  if (p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_list) {
  if (p_clcb->p_srcb) {
    /* release pending attribute list buffer */
    osi_free_and_reset((void**)&p_clcb->p_srcb->p_srvc_list);
    p_clcb->p_srcb->pending_discovery.clear();
  }

  if (p_clcb->auto_update == BTA_GATTC_DISC_WAITING) {
+114 −283

File changed.

Preview size limit exceeded, changes collapsed.

+3 −29
Original line number Diff line number Diff line
@@ -185,26 +185,6 @@ typedef union {
  tBTA_GATTC_INT_CONN int_conn;
} tBTA_GATTC_DATA;

/* GATT server cache on the client */

typedef struct {
  bluetooth::Uuid uuid;
  uint16_t s_handle;
  uint16_t e_handle;
  // this field is set only for characteristic
  uint16_t char_decl_handle;
  bool is_primary;
  tGATT_CHAR_PROP property;
} tBTA_GATTC_ATTR_REC;

#define BTA_GATTC_MAX_CACHE_CHAR 40
#define BTA_GATTC_ATTR_LIST_SIZE \
  (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))

#ifndef BTA_GATTC_CACHE_SRVR_SIZE
#define BTA_GATTC_CACHE_SRVR_SIZE 600
#endif

enum {
  BTA_GATTC_IDLE_ST = 0, /* Idle  */
  BTA_GATTC_W4_CONN_ST,  /* Wait for connection -  (optional) */
@@ -230,12 +210,9 @@ typedef struct {
  uint8_t update_count; /* indication received */
  uint8_t num_clcb;     /* number of associated CLCB */

  tBTA_GATTC_ATTR_REC* p_srvc_list;
  uint8_t cur_srvc_idx;
  uint8_t cur_char_idx;
  uint8_t next_avail_idx;
  uint8_t total_srvc;
  uint8_t total_char;
  std::vector<tBTA_GATTC_SERVICE> pending_discovery;
  std::vector<tBTA_GATTC_SERVICE>::iterator pending_service;
  std::vector<tBTA_GATTC_CHARACTERISTIC>::iterator pending_char;

  uint8_t srvc_hdl_chg; /* service handle change indication pending */
  uint16_t attr_index;  /* cahce NV saving/loading attribute index */
@@ -445,9 +422,6 @@ extern void bta_gattc_disc_res_cback(uint16_t conn_id,
extern void bta_gattc_disc_cmpl_cback(uint16_t conn_id,
                                      tGATT_DISC_TYPE disc_type,
                                      tGATT_STATUS status);
extern tGATT_STATUS bta_gattc_discover_procedure(uint16_t conn_id,
                                                 tBTA_GATTC_SERV* p_server_cb,
                                                 uint8_t disc_type);
extern tGATT_STATUS bta_gattc_discover_pri_service(uint16_t conn_id,
                                                   tBTA_GATTC_SERV* p_server_cb,
                                                   uint8_t disc_type);
+2 −3
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ tBTA_GATTC_CLCB* bta_gattc_clcb_alloc(tGATT_IF client_if,
  for (i_clcb = 0; i_clcb < BTA_GATTC_CLCB_MAX; i_clcb++) {
    if (!bta_gattc_cb.clcb[i_clcb].in_use) {
#if (BTA_GATT_DEBUG == TRUE)
      VLOG(1) << __func__ << ": found clcb:" << +i_clcb << " available", ;
      VLOG(1) << __func__ << ": found clcb:" << +i_clcb << " available";
#endif
      p_clcb = &bta_gattc_cb.clcb[i_clcb];
      p_clcb->in_use = true;
@@ -297,8 +297,7 @@ tBTA_GATTC_SERV* bta_gattc_srcb_alloc(const RawAddress& bda) {
  if (p_tcb != NULL) {
    // clear reallocating
    std::vector<tBTA_GATTC_SERVICE>().swap(p_tcb->srvc_cache);

    osi_free_and_reset((void**)&p_tcb->p_srvc_list);
    std::vector<tBTA_GATTC_SERVICE>().swap(p_tcb->pending_discovery);
    *p_tcb = tBTA_GATTC_SERV();

    p_tcb->in_use = true;
+2 −0
Original line number Diff line number Diff line
@@ -390,6 +390,8 @@ typedef struct {

struct tBTA_GATTC_CHARACTERISTIC {
  bluetooth::Uuid uuid;
  // this is used only during discovery, and not persisted in cache
  uint16_t declaration_handle;
  uint16_t value_handle;
  tGATT_CHAR_PROP properties;
  tBTA_GATTC_SERVICE* service; /* owning service*/