All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 10/10] client: Add release-notify command
Date: Tue,  4 Jul 2017 18:09:37 +0300	[thread overview]
Message-ID: <20170704150937.11701-11-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20170704150937.11701-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds release-notify command which closes an existing fd unlocking
the attribute:

[Test peripheral:/service001f/char0020]# release-notify
[CHG] Attribute /org/bluez/hci1/dev_69_16_5B_9A_06_CD/service001f/char0020 NotifyAcquired: no
---
 client/gatt.c | 10 ++++++++++
 client/gatt.h |  1 +
 client/main.c | 12 ++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/client/gatt.c b/client/gatt.c
index 0533854..33e8936 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -842,6 +842,16 @@ void gatt_acquire_notify(GDBusProxy *proxy, const char *arg)
 	notify_proxy = proxy;
 }
 
+void gatt_release_notify(GDBusProxy *proxy, const char *arg)
+{
+	if (proxy != notify_proxy || !notify_io) {
+		rl_printf("Write not acquired\n");
+		return;
+	}
+
+	notify_io_destroy();
+}
+
 static void notify_reply(DBusMessage *message, void *user_data)
 {
 	bool enable = GPOINTER_TO_UINT(user_data);
diff --git a/client/gatt.h b/client/gatt.h
index 5dba26b..9bab429 100644
--- a/client/gatt.h
+++ b/client/gatt.h
@@ -42,6 +42,7 @@ void gatt_acquire_write(GDBusProxy *proxy, const char *arg);
 void gatt_release_write(GDBusProxy *proxy, const char *arg);
 
 void gatt_acquire_notify(GDBusProxy *proxy, const char *arg);
+void gatt_release_notify(GDBusProxy *proxy, const char *arg);
 
 void gatt_add_manager(GDBusProxy *proxy);
 void gatt_remove_manager(GDBusProxy *proxy);
diff --git a/client/main.c b/client/main.c
index e0a265d..8f75f0e 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1829,6 +1829,16 @@ static void cmd_acquire_notify(const char *arg)
 	gatt_acquire_notify(default_attr, arg);
 }
 
+static void cmd_release_notify(const char *arg)
+{
+	if (!default_attr) {
+		rl_printf("No attribute selected\n");
+		return;
+	}
+
+	gatt_release_notify(default_attr, arg);
+}
+
 static void cmd_notify(const char *arg)
 {
 	dbus_bool_t enable;
@@ -2310,6 +2320,8 @@ static const struct {
 					"Release Write file descriptor" },
 	{ "acquire-notify", NULL, cmd_acquire_notify,
 					"Acquire Notify file descriptor" },
+	{ "release-notify", NULL, cmd_release_notify,
+					"Release Notify file descriptor" },
 	{ "notify",       "<on/off>", cmd_notify, "Notify attribute value" },
 	{ "register-application", "[UUID ...]", cmd_register_app,
 						"Register profile to connect" },
-- 
2.9.4


  parent reply	other threads:[~2017-07-04 15:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-04 15:09 [PATCH v2 00/10] gatt: Add AcquireWrite and AcquireNotify Luiz Augusto von Dentz
2017-07-04 15:09 ` [PATCH v2 01/10] doc/gatt-api: " Luiz Augusto von Dentz
2017-07-04 16:01   ` Marcel Holtmann
2017-07-04 15:09 ` [PATCH v2 02/10] shared/gatt-client: Allow multiple ready callbacks Luiz Augusto von Dentz
2017-07-04 15:09 ` [PATCH v2 03/10] gatt: Add implementation of AcquireWrite Luiz Augusto von Dentz
2017-07-04 15:09 ` [PATCH v2 04/10] gatt: Add implementation of WriteAcquired Luiz Augusto von Dentz
2017-07-04 15:09 ` [PATCH v2 05/10] client: Add acquire-write command Luiz Augusto von Dentz
2017-07-04 15:09 ` [PATCH v2 06/10] client: Add release-write command Luiz Augusto von Dentz
2017-07-04 15:09 ` [PATCH v2 07/10] gatt: Add implementation of AcquireNotify Luiz Augusto von Dentz
2017-07-04 15:09 ` [PATCH v2 08/10] gatt: Add implementation of NotifyAcquired Luiz Augusto von Dentz
2017-07-04 15:09 ` [PATCH v2 09/10] client: Add acquire-notify command Luiz Augusto von Dentz
2017-07-04 15:09 ` Luiz Augusto von Dentz [this message]
2017-07-05 11:34 ` [PATCH v2 00/10] gatt: Add AcquireWrite and AcquireNotify 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=20170704150937.11701-11-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.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.