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

Commit 9fb22b98 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Use std::list in GATT related code

Bug: 67057055
Test: sl4a Gatt* tests
Change-Id: I8201ebdad5ba4c3d5d0a2fd3d0fe9dc900b51d60
parent ccf2e479
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ static void bta_gattc_enable() {

  if (bta_gattc_cb.state == BTA_GATTC_STATE_DISABLED) {
    /* initialize control block */
    memset(&bta_gattc_cb, 0, sizeof(tBTA_GATTC_CB));
    bta_gattc_cb = tBTA_GATTC_CB();
    bta_gattc_cb.state = BTA_GATTC_STATE_ENABLED;
  } else {
    APPL_TRACE_DEBUG("GATTC is already enabled");
@@ -167,7 +167,7 @@ void bta_gattc_disable() {

  /* no registered apps, indicate disable completed */
  if (bta_gattc_cb.state != BTA_GATTC_STATE_DISABLING) {
    memset(&bta_gattc_cb, 0, sizeof(tBTA_GATTC_CB));
    bta_gattc_cb = tBTA_GATTC_CB();
    bta_gattc_cb.state = BTA_GATTC_STATE_DISABLED;
  }
}
@@ -587,7 +587,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) {
  if (p_clcb->p_srcb->mtu == 0) p_clcb->p_srcb->mtu = GATT_DEF_BLE_MTU_SIZE;

  /* start database cache if needed */
  if (p_clcb->p_srcb->p_srvc_cache == NULL ||
  if (p_clcb->p_srcb->srvc_cache.empty() ||
      p_clcb->p_srcb->state != BTA_GATTC_SERV_IDLE) {
    if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE) {
      p_clcb->p_srcb->state = BTA_GATTC_SERV_LOAD;
@@ -877,10 +877,7 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB* p_clcb,

  if (p_clcb->status != GATT_SUCCESS) {
    /* clean up cache */
    if (p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_cache) {
      list_free(p_clcb->p_srcb->p_srvc_cache);
      p_clcb->p_srcb->p_srvc_cache = NULL;
    }
    if (p_clcb->p_srcb) p_clcb->p_srcb->srvc_cache.clear();

    /* used to reset cache in application */
    bta_gattc_cache_reset(p_clcb->p_srcb->server_bda);
@@ -1252,7 +1249,7 @@ void bta_gattc_search(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) {
  tGATT_STATUS status = GATT_INTERNAL_ERROR;
  tBTA_GATTC cb_data;
  APPL_TRACE_DEBUG("%s: conn_id=%d", __func__, p_clcb->bta_conn_id);
  if (p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_cache) {
  if (p_clcb->p_srcb && !p_clcb->p_srcb->srvc_cache.empty()) {
    status = GATT_SUCCESS;
    /* search the local cache of a server device */
    bta_gattc_search_service(p_clcb, p_data->api_search.p_srvc_uuid);
@@ -1423,10 +1420,7 @@ void bta_gattc_process_api_refresh(const RawAddress& remote_bda) {
      }
    }
    /* in all other cases, mark it and delete the cache */
    if (p_srvc_cb->p_srvc_cache != NULL) {
      list_free(p_srvc_cb->p_srvc_cache);
      p_srvc_cb->p_srvc_cache = NULL;
    }
    p_srvc_cb->srvc_cache.clear();
  }
  /* used to reset cache in application */
  bta_gattc_cache_reset(remote_bda);
+2 −2
Original line number Diff line number Diff line
@@ -266,10 +266,10 @@ void BTA_GATTC_DiscoverServiceByUuid(uint16_t conn_id,
 *
 * Parameters       conn_id: connection ID which identify the server.
 *
 * Returns          returns list_t of tBTA_GATTC_SERVICE or NULL.
 * Returns          returns list of tBTA_GATTC_SERVICE or NULL.
 *
 ******************************************************************************/
const list_t* BTA_GATTC_GetServices(uint16_t conn_id) {
const std::list<tBTA_GATTC_SERVICE>* BTA_GATTC_GetServices(uint16_t conn_id) {
  return bta_gattc_get_services(conn_id);
}

Loading