[PATCH 08/21] hog: Enable "Report" characteristic notifications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

diff --git a/input/hog_device.c b/input/hog_device.c
index fdf76cd..1883728 100644
--- a/input/hog_device.c
+++ b/input/hog_device.c
@@ -67,10 +67,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: notifications 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;
@@ -89,13 +109,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.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux