All of lore.kernel.org
 help / color / mirror / Atom feed
From: "João Paulo Rechi Vita" <jprvita@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: "João Paulo Rechi Vita" <jprvita@openbossa.org>
Subject: [BlueZ 07/15] HoG: enable "Report" characteristic notification
Date: Thu, 26 Apr 2012 16:45:37 -0300	[thread overview]
Message-ID: <1335469545-1007-7-git-send-email-jprvita@openbossa.org> (raw)
In-Reply-To: <1335469545-1007-1-git-send-email-jprvita@openbossa.org>

---
 input/hog_device.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/input/hog_device.c b/input/hog_device.c
index c28d337..28e7cad 100644
--- a/input/hog_device.c
+++ b/input/hog_device.c
@@ -65,10 +65,30 @@ struct hog_device {
 
 static GSList *devices = NULL;
 
+static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
+					guint16 plen, gpointer user_data)
+{
+	if (status != 0) {
+		error("Write report characteristic descriptor failed: %s",
+							att_ecode2str(status));
+		return;
+	}
+
+	DBG("Report characteristic descriptor written: notification enabled");
+}
+
+static void write_ccc(uint16_t handle, gpointer user_data)
+{
+	struct hog_device *hogdev = user_data;
+	uint8_t value[] = { 0x01, 0x00 };
+
+	gatt_write_char(hogdev->attrib, handle, value, sizeof(value),
+					report_ccc_written_cb, hogdev);
+}
+
 static void discover_descriptor_cb(guint8 status, const guint8 *pdu,
 					guint16 len, gpointer user_data)
 {
-	struct report *report = user_data;
 	struct att_data_list *list;
 	uint8_t format;
 	int i;
@@ -87,13 +107,17 @@ static void discover_descriptor_cb(guint8 status, const guint8 *pdu,
 		goto done;
 
 	for (i = 0; i < list->num; i++) {
-		uint16_t uuid16;
+		uint16_t uuid16, handle;
 		uint8_t *value;
 
 		value = list->data[i];
+		handle = att_get_u16(value);
 		uuid16 = att_get_u16(&value[2]);
 
-		DBG("%s descriptor: 0x%04x", report->decl->uuid, uuid16);
+		if (uuid16 != GATT_CLIENT_CHARAC_CFG_UUID)
+			continue;
+
+		write_ccc(handle, user_data);
 	}
 
 done:
-- 
1.7.7.6


  parent reply	other threads:[~2012-04-26 19:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 19:45 [BlueZ 01/15] HoG: Register HID over GATT device driver João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 02/15] HoG: register ATTIO callbacks João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 03/15] HoG: load primary service handle João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 04/15] HoG: discover all characteristics declaration João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 05/15] HoG: discover descriptors for all characteristics João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 06/15] HoG: discover the "Report Map" characteristic João Paulo Rechi Vita
2012-04-26 19:45 ` João Paulo Rechi Vita [this message]
2012-04-26 19:45 ` [BlueZ 08/15] HoG: add report notification handler João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 09/15] HoG: HID I/O driver João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 10/15] HoG: Use real values for vendor and product IDs João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 11/15] GATT: Add Report Reference Descriptor declaration João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 12/15] HoG: Add read Report Reference descriptor João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 13/15] GATT: Rename Characteristic Configuration constants João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 14/15] GATT: Move GATT assigned numbers to GATT header João Paulo Rechi Vita
2012-04-26 19:45 ` [BlueZ 15/15] HoG: Prepend report id to the HID report João Paulo Rechi Vita

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=1335469545-1007-7-git-send-email-jprvita@openbossa.org \
    --to=jprvita@openbossa.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.