Skip to content

Commit

Permalink
hog-lib: Fix not handling BT_ATT_OP_HANDLE_NFY_MULT
Browse files Browse the repository at this point in the history
This is a temporary fix for not handling BT_ATT_OP_HANDLE_NFY_MULT in
GAttr so the code will use g_attrib_attach_client to attach the
bt_gatt_client instance which is then used to register notifications
including those sent with BT_ATT_OP_HANDLE_NFY_MULT.

Fixes: bluez#71
  • Loading branch information
Vudentz committed Jan 5, 2023
1 parent 47b6cfe commit 2f4c576
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions profiles/input/hog-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,15 @@ static void report_value_cb(const guint8 *pdu, guint16 len, gpointer user_data)
error("bt_uhid_send: %s (%d)", strerror(-err), -err);
}

static void report_notify_destroy(void *user_data)
{
struct report *report = user_data;

DBG("");

report->notifyid = 0;
}

static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
guint16 plen, gpointer user_data)
{
Expand All @@ -393,7 +402,13 @@ static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
report->notifyid = g_attrib_register(hog->attrib,
ATT_OP_HANDLE_NOTIFY,
report->value_handle,
report_value_cb, report, NULL);
report_value_cb, report,
report_notify_destroy);
if (!report->notifyid) {
error("Unable to register report notification: handle 0x%04x",
report->value_handle);
goto remove;
}

DBG("Report characteristic descriptor written: notifications enabled");

Expand Down Expand Up @@ -1798,7 +1813,11 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)
r->notifyid = g_attrib_register(hog->attrib,
ATT_OP_HANDLE_NOTIFY,
r->value_handle,
report_value_cb, r, NULL);
report_value_cb, r,
report_notify_destroy);
if (!r->notifyid)
error("Unable to register report notification: "
"handle 0x%04x", r->value_handle);
}

return true;
Expand Down
1 change: 1 addition & 0 deletions src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -5152,6 +5152,7 @@ static void gatt_client_init(struct btd_device *device)
}

bt_gatt_client_set_debug(device->client, gatt_debug, NULL, NULL);
g_attrib_attach_client(device->attrib, device->client);

/*
* Notify notify existing service about the new connection so they can
Expand Down

0 comments on commit 2f4c576

Please sign in to comment.