aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Paulo Rechi Vita <jprvita@openbossa.org>2012-03-22 18:07:16 -0300
committerJoão Paulo Rechi Vita <jprvita@openbossa.org>2012-06-20 20:30:53 -0300
commite05b12bf0ddd879b3253b15f8ea4cad277584a7e (patch)
tree77c026c42847370a799f68bca6cd221eec3f8ca8
parent3674422aa5d2fbb5358bb13a44cfc1403dbdbaed (diff)
downloadbluez-e05b12bf0ddd879b3253b15f8ea4cad277584a7e.tar.gz
bluez-e05b12bf0ddd879b3253b15f8ea4cad277584a7e.tar.xz
bluez-e05b12bf0ddd879b3253b15f8ea4cad277584a7e.zip
hog: Enable "Report" characteristic notifications
-rw-r--r--input/hog_device.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/input/hog_device.c b/input/hog_device.c
index 574e6f39..d1b8bb8c 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: