All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Kraglak <marcin.kraglak@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC 04/16] gatt: Remove service functionality
Date: Wed,  9 Apr 2014 09:07:02 +0200	[thread overview]
Message-ID: <1397027234-12003-5-git-send-email-marcin.kraglak@tieto.com> (raw)
In-Reply-To: <1397027234-12003-1-git-send-email-marcin.kraglak@tieto.com>

This will remove service with given handle and its attributes.
---
 src/shared/gatt-db.c | 21 +++++++++++++++++++++
 src/shared/gatt-db.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 15e2f95..3ff017c 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -51,6 +51,13 @@ struct gatt_db_service {
 	struct gatt_db_attribute **attributes;
 };
 
+static bool match_service_by_handle(const void *data, const void *user_data)
+{
+	const struct gatt_db_service *service = data;
+
+	return service->attributes[0]->handle == PTR_TO_INT(user_data);
+}
+
 struct gatt_db *gatt_db_new(void)
 {
 	struct gatt_db *db;
@@ -169,3 +176,17 @@ uint16_t gatt_db_new_service(struct gatt_db *db, const bt_uuid_t *uuid,
 
 	return service->attributes[0]->handle;
 }
+
+bool gatt_db_remove_service(struct gatt_db *db, uint16_t handle)
+{
+	struct gatt_db_service *service;
+
+	service = queue_remove_if(db->services, match_service_by_handle,
+							INT_TO_PTR(handle));
+	if (!service)
+		return false;
+
+	gatt_db_service_destroy(service);
+
+	return true;
+}
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index 7c03013..f543a87 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
@@ -34,3 +34,5 @@ void gatt_db_destroy(struct gatt_db *db);
 uint16_t gatt_db_new_service(struct gatt_db *db, const bt_uuid_t *uuid,
 					enum gatt_db_service_type service_type,
 					uint16_t num_handles);
+
+bool gatt_db_remove_service(struct gatt_db *db, uint16_t handle);
-- 
1.8.5.3


  parent reply	other threads:[~2014-04-09  7:07 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-09  7:06 [RFC 00/16] Gatt database initial implementation Marcin Kraglak
2014-04-09  7:06 ` [RFC 01/16] gatt: Add skeleton of gatt-db Marcin Kraglak
2014-04-14 14:12   ` Claudio Takahasi
2014-04-14 19:15     ` Marcin Kraglak
2014-04-16 12:25       ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 02/16] gatt: Add services list to gatt_db struct Marcin Kraglak
2014-04-14 14:11   ` Claudio Takahasi
2014-04-14 19:57     ` Marcin Kraglak
2014-04-09  7:07 ` [RFC 03/16] gatt: Add method for creating services in gatt_db Marcin Kraglak
2014-04-14 14:14   ` Claudio Takahasi
2014-04-09  7:07 ` Marcin Kraglak [this message]
2014-04-09  7:07 ` [RFC 05/16] gatt: Add new sharacteristic functionality Marcin Kraglak
2014-04-15 12:50   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 06/16] gatt: Add characteristic descriptor method Marcin Kraglak
2014-04-15 12:51   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 07/16] gatt: Add included service functionality Marcin Kraglak
2014-04-15 12:53   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 08/16] android/gatt: Add " Marcin Kraglak
2014-04-15 12:54   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 09/16] android/gatt: Add implementation of delete service Marcin Kraglak
2014-04-15 12:55   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 10/16] android/gatt: Add included service implementation Marcin Kraglak
2014-04-15 12:55   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 11/16] android/gatt: Add characteristic implementation Marcin Kraglak
2014-04-15 12:57   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 12/16] android/gatt: Add descriptor implementation Marcin Kraglak
2014-04-15 12:58   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 13/16] gatt: Add start/stop service functionality Marcin Kraglak
2014-04-09  7:07 ` [RFC 14/16] android/gatt: Add handling of start service command Marcin Kraglak
2014-04-15 12:59   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 15/16] android/gatt: Add stop service command handling Marcin Kraglak
2014-04-15 12:59   ` Claudio Takahasi
2014-04-09  7:07 ` [RFC 16/16] android/gatt: Fix typo in event handlers array Marcin Kraglak
2014-04-14 14:10 ` [RFC 00/16] Gatt database initial implementation Claudio Takahasi

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=1397027234-12003-5-git-send-email-marcin.kraglak@tieto.com \
    --to=marcin.kraglak@tieto.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.