aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Paulo Rechi Vita <jprvita@openbossa.org>2012-03-22 20:58:49 -0300
committerJoão Paulo Rechi Vita <jprvita@openbossa.org>2012-06-20 20:31:02 -0300
commit1e96772ba9af5af7d9c3da2a2b400171c09ccddc (patch)
tree76d35e64228e27d09026ea923d1c4198a4f56f30
parente05b12bf0ddd879b3253b15f8ea4cad277584a7e (diff)
downloadbluez-1e96772ba9af5af7d9c3da2a2b400171c09ccddc.tar.gz
bluez-1e96772ba9af5af7d9c3da2a2b400171c09ccddc.tar.xz
bluez-1e96772ba9af5af7d9c3da2a2b400171c09ccddc.zip
hog: Add report notification handler
-rw-r--r--input/hog_device.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/input/hog_device.c b/input/hog_device.c
index d1b8bb8c..1dd3e85a 100644
--- a/input/hog_device.c
+++ b/input/hog_device.c
@@ -61,12 +61,26 @@ struct hog_device {
struct btd_device *device;
GAttrib *attrib;
guint attioid;
+ guint report_cb_id;
struct gatt_primary *hog_primary;
GSList *reports;
};
static GSList *devices = NULL;
+static void report_value_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
+{
+ uint16_t handle;
+
+ if (len < 3) { /* 1-byte opcode + 2-byte handle */
+ error("Malformed ATT notification");
+ return;
+ }
+
+ handle = att_get_u16(&pdu[1]);
+ DBG("Report notification on handle 0x%04x", handle);
+}
+
static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
guint16 plen, gpointer user_data)
{
@@ -216,12 +230,19 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
gatt_discover_char(hogdev->attrib, prim->range.start, prim->range.end,
NULL, char_discovered_cb, hogdev);
+
+ hogdev->report_cb_id = g_attrib_register(hogdev->attrib,
+ ATT_OP_HANDLE_NOTIFY, report_value_cb,
+ hogdev, NULL);
}
static void attio_disconnected_cb(gpointer user_data)
{
struct hog_device *hogdev = user_data;
+ g_attrib_unregister(hogdev->attrib, hogdev->report_cb_id);
+ hogdev->report_cb_id = 0;
+
g_attrib_unref(hogdev->attrib);
hogdev->attrib = NULL;
}