Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1468887rwl; Thu, 5 Jan 2023 14:11:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXtKzVDhtgJKtgi1djhs3b9Z70k+C4KctH/QYPhIyBKCtEfXLF6+efCkVAzT5pTS6Ce84yzk X-Received: by 2002:a17:90a:6503:b0:226:d23b:8037 with SMTP id i3-20020a17090a650300b00226d23b8037mr2951310pjj.33.1672956674349; Thu, 05 Jan 2023 14:11:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672956674; cv=none; d=google.com; s=arc-20160816; b=RdCyyjz2XJGGtSDsA6YRGsEUQov92Q+Bja+Ho6CSKnUYe22nF2SEXukKimJKa3jO/W VgDvygEyZYoS8ZVskIUDJ0fGTGwxBEP3koHZNSuyk3+7Qw6qEEYGufT934Go5DJid+jh 7Y/J9hBEjzk7N9IGwecGS2rG2PX689JPBzimWzaHk59rpX8AoKY5XpkjxiZr/nDxX+ls EdORss6CzAKLMqRmX1q6aVR9KQaFO/hvZIjpEuIuyfjND1dq7xXti5+IqsFi0Uqb+fWY EeIeUQvJuQW/0H+HpaziL4R2vdpuzdhvn1nEANnMNnoDBemmrB+DyZ192lbqnG+5MTr1 B+1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cNud4kWdkw52+hXAnumbx8Ikmuw+BRe/Pf1t1Z/q3Y8=; b=Tqdulv0jsbMk4oksYrPnVjTaY8bM++JSM5ckz0Sv379fmLYDkKVpxqoEyR/o7SnDUw VyGPT9IIMr8hESOU/hAilMPOQDp9n1e7AYw16kAXaZU2XbO9GCP78CXH7cJMFAt/ZCw2 TIKhsZrhj3CzxQsFqarujwsUzmFRt4GTKWD7JI7HMHMSAcUoihFXWV/sWi63EBStsC5e V+kNH5g3AEqy+EfUFvvH3hDgANymdrlP4ZgczxUvZyp87N+9Da/VPW5L4makSRdQd6pt oZ6c4t5gE5remwRftfTSr4t/n6vGhj4GdLHuDhszLsC8355Zs+ydZ4AP27eiGy1zV+y/ +bwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QOvEbBJ6; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a17090ab29400b0022638d96fccsi2964566pjr.11.2023.01.05.14.10.55; Thu, 05 Jan 2023 14:11:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QOvEbBJ6; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235715AbjAEWKL (ORCPT + 99 others); Thu, 5 Jan 2023 17:10:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235623AbjAEWJw (ORCPT ); Thu, 5 Jan 2023 17:09:52 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F30367BE4 for ; Thu, 5 Jan 2023 14:09:52 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id cl14so4846579pjb.2 for ; Thu, 05 Jan 2023 14:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cNud4kWdkw52+hXAnumbx8Ikmuw+BRe/Pf1t1Z/q3Y8=; b=QOvEbBJ6Pz0b7wJvrbxCCq88bebfI8kMwj31mnJ1IkhpwRY+xbW4RwogMOM/uc90KK h07gzh0+83sDvk19FB091QxdWESboAEzMoW/PxF1Q/q3h2t2favLsXUuMKgLDNzRnkge l05gV0kCYJ5/RNaKgQoWsTm5M1rReUuPQKhKPY8McLsPx+7033AHoEVRS17YWp1P9Y8X jc9Nl7G5uSBeHTqp/TKEldlTnXK3eCA1/a5Okez6Cf4l7p88c6zprnWCkY5JkiBvgqa7 60g7ORKbe/9XUghUtkSEtCuuN/SBz08DR0aRtFWvkvJKLaxQHc1eiJdP+f5O1aMO7iwa p4jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cNud4kWdkw52+hXAnumbx8Ikmuw+BRe/Pf1t1Z/q3Y8=; b=5U3/Z34S6tAsuoue0Mb35CKafc9E26c9srW6ZjHt5d3mzbUZGBc1mDgqGGltgeKi4n p8aWuJldRG/p9i6U6klIANAlQkI+K4Oe18/7fyJwXUYGQYTwrJk/0cwdJzimQqYDVl/u 5lenusYosRwoDtmW3KuWBEosSEILJTgxNA9b98QZ9oq+rPDTyvgUWQ40adpFqg9hYu8L zpcdOiO0TApwVvX0sJ9jE9Q5Sz44ODUWctZb64z7LVUIH47QUS9jmhulc6U8c/619ucW QPcSDOjDgfITRjJcZFA/izWmcmpdpafvwLyYjqZd/T0KCwSWAKsi140MCn8bUDdWcQZ4 yeKA== X-Gm-Message-State: AFqh2koMnpS9g1mj+WR0NS/LjyeeTije3N27TMZ0FT6IUGbb0a/lcs1G vV2ebi9BuIElQ2FlOT/l5rmo7ntu52s= X-Received: by 2002:a17:902:f145:b0:191:10e0:b912 with SMTP id d5-20020a170902f14500b0019110e0b912mr52494033plb.41.1672956591194; Thu, 05 Jan 2023 14:09:51 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id jg21-20020a17090326d500b001929827731esm16744861plb.201.2023.01.05.14.09.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 14:09:50 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/4] hog-lib: Fix not handling BT_ATT_OP_HANDLE_NFY_MULT Date: Thu, 5 Jan 2023 14:09:44 -0800 Message-Id: <20230105220944.2373424-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230105220944.2373424-1-luiz.dentz@gmail.com> References: <20230105220944.2373424-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz 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: https://github.com/bluez/bluez/issues/71 --- profiles/input/hog-lib.c | 23 +++++++++++++++++++++-- src/device.c | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index 021db386f3b7..7ff1ede3db35 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -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) { @@ -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"); @@ -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; diff --git a/src/device.c b/src/device.c index 995d39f2ccee..28b93eb9ac38 100644 --- a/src/device.c +++ b/src/device.c @@ -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 -- 2.37.3