All of lore.kernel.org
 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 v2 6/7] tools/btgatt-client: Add "unregister-notify" command.
Date: Wed, 10 Sep 2014 09:36:26 -0700	[thread overview]
Message-ID: <1410366987-8128-7-git-send-email-armansito@chromium.org> (raw)
In-Reply-To: <1410366987-8128-1-git-send-email-armansito@chromium.org>

This patch adds the "unregister-notify" command which can be used to test the
bt_gatt_client_unregister_notify function.
---
 tools/btgatt-client.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c
index a51c7c0..f628bbb 100644
--- a/tools/btgatt-client.c
+++ b/tools/btgatt-client.c
@@ -770,6 +770,42 @@ static void cmd_register_notify(struct client *cli, char *cmd_str)
 	printf("\n");
 }
 
+static void unregister_notify_usage(void)
+{
+	printf("Usage: unregister-notify <notify id>\n");
+}
+
+static void cmd_unregister_notify(struct client *cli, char *cmd_str)
+{
+	char *argv[2];
+	int argc = 0;
+	unsigned int id;
+	char *endptr = NULL;
+
+	if (!bt_gatt_client_is_ready(cli->gatt)) {
+		printf("GATT client not initialized\n");
+		return;
+	}
+
+	if (!parse_args(cmd_str, 1, argv, &argc) || argc != 1) {
+		unregister_notify_usage();
+		return;
+	}
+
+	id = strtol(argv[0], &endptr, 10);
+	if (!endptr || *endptr != '\0' || !id) {
+		printf("Invalid notify id: %s\n", argv[0]);
+		return;
+	}
+
+	if (!bt_gatt_client_unregister_notify(cli->gatt, id)) {
+		printf("Failed to unregister notify handler with id: %u\n", id);
+		return;
+	}
+
+	printf("Unregistered notify handler with id: %u\n", id);
+}
+
 static void cmd_help(struct client *cli, char *cmd_str);
 
 typedef void (*command_func_t)(struct client *cli, char *cmd_str);
@@ -791,6 +827,8 @@ static struct {
 			"Write long characteristic or descriptor value" },
 	{ "register-notify", cmd_register_notify,
 			"\tSubscribe to not/ind from a characteristic" },
+	{ "unregister-notify", cmd_unregister_notify,
+						"Unregister a not/ind session"},
 	{ }
 };
 
-- 
2.1.0.rc2.206.gedb03e5


  parent reply	other threads:[~2014-09-10 16:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 16:36 [PATCH BlueZ v2 0/7] shared/gatt-client: Handle notifications Arman Uguray
2014-09-10 16:36 ` [PATCH BlueZ v2 1/7] shared/gatt-client: Introduce struct bt_gatt_characteristic_iter Arman Uguray
2014-09-10 16:36 ` [PATCH BlueZ v2 2/7] shared/gatt-client: Implement bt_gatt_client_register_notify Arman Uguray
2014-09-10 16:36 ` [PATCH BlueZ v2 3/7] shared/gatt-client: Implement bt_gatt_client_unregister_notify Arman Uguray
2014-09-10 16:36 ` [PATCH BlueZ v2 4/7] shared/gatt-client: Handle incoming not/ind PDUs Arman Uguray
2014-09-10 16:36 ` [PATCH BlueZ v2 5/7] tools/btgatt-client: Add the "register-notify" command Arman Uguray
2014-09-10 16:36 ` Arman Uguray [this message]
2014-09-10 16:36 ` [PATCH BlueZ v2 7/7] TODO: Reference counted notify functions implemented Arman Uguray
2014-09-11  0:58 ` [PATCH BlueZ v2 0/7] shared/gatt-client: Handle notifications Marcel Holtmann

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=1410366987-8128-7-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 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.