Return-Path: From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= To: linux-bluetooth@vger.kernel.org Cc: Claudio Takahasi Subject: [BlueZ 12/15] HoG: Add read Report Reference descriptor Date: Thu, 26 Apr 2012 16:45:42 -0300 Message-Id: <1335469545-1007-12-git-send-email-jprvita@openbossa.org> In-Reply-To: <1335469545-1007-1-git-send-email-jprvita@openbossa.org> References: <1335469545-1007-1-git-send-email-jprvita@openbossa.org> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: From: Claudio Takahasi This patch adds the GATT operation to read the value of the Report Reference descriptor of the Report characteristic. --- input/hog_device.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-) diff --git a/input/hog_device.c b/input/hog_device.c index 6a7cda2..99de25c 100644 --- a/input/hog_device.c +++ b/input/hog_device.c @@ -120,9 +120,27 @@ static void write_ccc(uint16_t handle, gpointer user_data) report_ccc_written_cb, hogdev); } +static void report_reference_cb(guint8 status, const guint8 *pdu, + guint16 plen, gpointer user_data) +{ + if (status != 0) { + error("Read Report Reference descriptor failed: %s", + att_ecode2str(status)); + return; + } + + if (plen != 3) { + error("Malformed ATT read response"); + return; + } + + DBG("Report ID: 0x%02x Report type: 0x%02x", pdu[1], pdu[2]); +} + static void discover_descriptor_cb(guint8 status, const guint8 *pdu, guint16 len, gpointer user_data) { + struct hog_device *hogdev = user_data; struct att_data_list *list; uint8_t format; int i; @@ -148,10 +166,11 @@ static void discover_descriptor_cb(guint8 status, const guint8 *pdu, handle = att_get_u16(value); uuid16 = att_get_u16(&value[2]); - if (uuid16 != GATT_CLIENT_CHARAC_CFG_UUID) - continue; - - write_ccc(handle, user_data); + if (uuid16 == GATT_CLIENT_CHARAC_CFG_UUID) + write_ccc(handle, user_data); + else if (uuid16 == GATT_REPORT_REFERENCE) + gatt_read_char(hogdev->attrib, handle, 0, + report_reference_cb, hogdev); } done: -- 1.7.7.6