diff --git a/android/hog.c b/android/hog.c
index ef5690c..85a6982 100644
--- a/android/hog.c
+++ b/android/hog.c
uint16_t ccc_handle;
guint notifyid;
struct gatt_char *decl;
+ uint16_t len;
+ uint8_t *value;
};
static void report_value_cb(const guint8 *pdu, guint16 len, gpointer user_data)
static void report_read_cb(guint8 status, const guint8 *pdu, guint16 len,
gpointer user_data)
{
- if (status != 0)
+ struct report *report = user_data;
+
+ if (status != 0) {
error("Error reading Report value: %s", att_ecode2str(status));
+ return;
+ }
+
+ if (report->value)
+ g_free(report->value);
+
+ report->value = g_memdup(pdu, len);
+ report->len = len;
}
static struct report *report_new(struct bt_hog *hog, struct gatt_char *chr)
{
struct report *report = data;
+ g_free(report->value);
g_free(report->decl);
g_free(report);
}