Linux bluetooth development
 help / color / mirror / Atom feed
From: Arman Uguray <armansito@chromium.org>
To: linux-bluetooth@vger.kernel.org
Cc: Arman Uguray <armansito@chromium.org>
Subject: [PATCH BlueZ 8/8] shared/gatt-client: Remove GATT structs and iterators
Date: Fri, 28 Nov 2014 09:49:22 -0800	[thread overview]
Message-ID: <1417196962-3876-9-git-send-email-armansito@chromium.org> (raw)
In-Reply-To: <1417196962-3876-1-git-send-email-armansito@chromium.org>

This patch removes the high-level structs and iterators used by
shared/gatt-client in favor of gatt-db.
---
 src/shared/gatt-client.c | 88 ------------------------------------------------
 src/shared/gatt-client.h | 73 +++------------------------------------
 2 files changed, 5 insertions(+), 156 deletions(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index a26f43a..4b1b90e 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1641,94 +1641,6 @@ struct gatt_db *bt_gatt_client_get_db(struct bt_gatt_client *client)
 	return client->db;
 }
 
-bool bt_gatt_service_iter_init(struct bt_gatt_service_iter *iter,
-						struct bt_gatt_client *client)
-{
-	if (!iter || !client)
-		return false;
-
-	if (client->in_init || client->in_svc_chngd)
-		return false;
-
-	memset(iter, 0, sizeof(*iter));
-	iter->client = client;
-	iter->ptr = NULL;
-
-	return true;
-}
-
-bool bt_gatt_service_iter_next(struct bt_gatt_service_iter *iter,
-					const bt_gatt_service_t **service)
-{
-	/* TODO: Remove iterator functions */
-
-	return false;
-}
-
-bool bt_gatt_service_iter_next_by_handle(struct bt_gatt_service_iter *iter,
-					uint16_t start_handle,
-					const bt_gatt_service_t **service)
-{
-	while (bt_gatt_service_iter_next(iter, service)) {
-		if ((*service)->start_handle == start_handle)
-			return true;
-	}
-
-	return false;
-}
-
-bool bt_gatt_service_iter_next_by_uuid(struct bt_gatt_service_iter *iter,
-					const uint8_t uuid[BT_GATT_UUID_SIZE],
-					const bt_gatt_service_t **service)
-{
-	while (bt_gatt_service_iter_next(iter, service)) {
-		if (memcmp((*service)->uuid, uuid, UUID_BYTES) == 0)
-			return true;
-	}
-
-	return false;
-}
-
-bool bt_gatt_characteristic_iter_init(struct bt_gatt_characteristic_iter *iter,
-					const bt_gatt_service_t *service)
-{
-	if (!iter || !service)
-		return false;
-
-	memset(iter, 0, sizeof(*iter));
-	iter->service = (void *) service;
-
-	return true;
-}
-
-bool bt_gatt_characteristic_iter_next(struct bt_gatt_characteristic_iter *iter,
-					const bt_gatt_characteristic_t **chrc)
-{
-	/* TODO: Remove iterator functions */
-
-	return false;
-}
-
-bool bt_gatt_include_service_iter_init(struct bt_gatt_incl_service_iter *iter,
-					const bt_gatt_service_t *service)
-{
-	if (!iter || !service)
-		return false;
-
-	memset(iter, 0, sizeof(*iter));
-	iter->service = (void *) service;
-
-	return true;
-}
-
-bool bt_gatt_include_service_iter_next(struct bt_gatt_incl_service_iter *iter,
-					const bt_gatt_included_service_t **incl)
-{
-	/* TODO: Remove iterator functions */
-
-	return false;
-}
-
 struct read_op {
 	bt_gatt_client_read_callback_t callback;
 	void *user_data;
diff --git a/src/shared/gatt-client.h b/src/shared/gatt-client.h
index 0309e5e..235b9cb 100644
--- a/src/shared/gatt-client.h
+++ b/src/shared/gatt-client.h
@@ -38,6 +38,10 @@ typedef void (*bt_gatt_client_destroy_func_t)(void *user_data);
 typedef void (*bt_gatt_client_callback_t)(bool success, uint8_t att_ecode,
 							void *user_data);
 typedef void (*bt_gatt_client_debug_func_t)(const char *str, void *user_data);
+typedef void (*bt_gatt_client_read_callback_t)(bool success, uint8_t att_ecode,
+					const uint8_t *value, uint16_t length,
+					void *user_data);
+
 typedef void (*bt_gatt_client_write_long_callback_t)(bool success,
 					bool reliable_error, uint8_t att_ecode,
 					void *user_data);
@@ -51,6 +55,7 @@ typedef void (*bt_gatt_client_service_changed_callback_t)(uint16_t start_handle,
 							uint16_t end_handle,
 							void *user_data);
 
+
 bool bt_gatt_client_is_ready(struct bt_gatt_client *client);
 bool bt_gatt_client_set_ready_handler(struct bt_gatt_client *client,
 					bt_gatt_client_callback_t callback,
@@ -67,74 +72,6 @@ bool bt_gatt_client_set_debug(struct bt_gatt_client *client,
 
 struct gatt_db *bt_gatt_client_get_db(struct bt_gatt_client *client);
 
-typedef struct {
-	bool primary;
-	uint16_t start_handle;
-	uint16_t end_handle;
-	uint8_t uuid[BT_GATT_UUID_SIZE];
-} bt_gatt_service_t;
-
-typedef struct {
-	uint16_t handle;
-	uint8_t uuid[BT_GATT_UUID_SIZE];
-} bt_gatt_descriptor_t;
-
-typedef struct {
-	uint16_t start_handle;
-	uint16_t end_handle;
-	uint16_t value_handle;
-	uint8_t properties;
-	uint8_t uuid[BT_GATT_UUID_SIZE];
-	const bt_gatt_descriptor_t *descs;
-	size_t num_descs;
-} bt_gatt_characteristic_t;
-
-typedef struct {
-	uint16_t handle;
-	uint16_t start_handle;
-	uint16_t end_handle;
-	uint8_t uuid[BT_GATT_UUID_SIZE];
-} bt_gatt_included_service_t;
-
-struct bt_gatt_service_iter {
-	struct bt_gatt_client *client;
-	void *ptr;
-};
-
-struct bt_gatt_characteristic_iter {
-	void *service;
-	size_t pos;
-};
-
-struct bt_gatt_incl_service_iter {
-	void *service;
-	size_t pos;
-};
-
-bool bt_gatt_service_iter_init(struct bt_gatt_service_iter *iter,
-						struct bt_gatt_client *client);
-bool bt_gatt_service_iter_next(struct bt_gatt_service_iter *iter,
-					const bt_gatt_service_t **service);
-bool bt_gatt_service_iter_next_by_handle(struct bt_gatt_service_iter *iter,
-					uint16_t start_handle,
-					const bt_gatt_service_t **service);
-bool bt_gatt_service_iter_next_by_uuid(struct bt_gatt_service_iter *iter,
-					const uint8_t uuid[BT_GATT_UUID_SIZE],
-					const bt_gatt_service_t **service);
-
-bool bt_gatt_characteristic_iter_init(struct bt_gatt_characteristic_iter *iter,
-					const bt_gatt_service_t *service);
-bool bt_gatt_characteristic_iter_next(struct bt_gatt_characteristic_iter *iter,
-					const bt_gatt_characteristic_t **chrc);
-
-bool bt_gatt_include_service_iter_init(struct bt_gatt_incl_service_iter *iter,
-					const bt_gatt_service_t *service);
-bool bt_gatt_include_service_iter_next(struct bt_gatt_incl_service_iter *iter,
-					const bt_gatt_included_service_t **inc);
-
-typedef void (*bt_gatt_client_read_callback_t)(bool success, uint8_t att_ecode,
-					const uint8_t *value, uint16_t length,
-					void *user_data);
 
 bool bt_gatt_client_read_value(struct bt_gatt_client *client,
 					uint16_t value_handle,
-- 
2.2.0.rc0.207.ga3a616c


  parent reply	other threads:[~2014-11-28 17:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-28 17:49 [PATCH BlueZ 0/8] shared/gatt: Use gatt-db for client role Arman Uguray
2014-11-28 17:49 ` [PATCH BlueZ 1/8] shared/gatt-db: Fix bug in maximum handle check Arman Uguray
2014-11-28 17:49 ` [PATCH BlueZ 2/8] shared/gatt-db: Add helper to get service handles Arman Uguray
2014-11-28 17:49 ` [PATCH BlueZ 3/8] shared/gatt-client: Store services in gatt_db Arman Uguray
2014-12-01  9:45   ` Luiz Augusto von Dentz
2014-12-01 14:50     ` Arman Uguray
2014-12-01 16:02       ` Luiz Augusto von Dentz
2014-12-01 16:37         ` Arman Uguray
2014-12-01 17:19           ` Marcel Holtmann
2014-12-01 17:57             ` Arman Uguray
2014-12-02 10:46               ` Luiz Augusto von Dentz
2014-12-02 15:12                 ` Luiz Augusto von Dentz
2014-12-02 19:35                   ` Arman Uguray
2014-12-03  0:15                     ` Arman Uguray
2014-11-28 17:49 ` [PATCH BlueZ 4/8] shared/gatt-client: Use gatt_db in bt_gatt_register_notify Arman Uguray
2014-11-28 17:49 ` [PATCH BlueZ 5/8] tools/btgatt-server: Add the "services" command Arman Uguray
2014-11-28 17:49 ` [PATCH BlueZ 6/8] tools/btgatt-client: Use gatt-db instead of iterators Arman Uguray
2014-11-28 17:49 ` [PATCH BlueZ 7/8] unit/test-gatt: Use gatt-db for CLIENT tests Arman Uguray
2014-11-28 17:49 ` Arman Uguray [this message]
2014-12-01  9:49 ` [PATCH BlueZ 0/8] shared/gatt: Use gatt-db for client role Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417196962-3876-9-git-send-email-armansito@chromium.org \
    --to=armansito@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox