Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8217431pxb; Fri, 19 Feb 2021 10:11:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjVutGXzBfMlWTg5Mb7/MQAEvAJTXhtSqCSi/vvCwbZnjQnuqQxXCYU0D5RJlyJAs0dD8+ X-Received: by 2002:a17:906:5604:: with SMTP id f4mr8436402ejq.474.1613758312029; Fri, 19 Feb 2021 10:11:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1613758312; cv=pass; d=google.com; s=arc-20160816; b=rm/J+CmqVfAE98mNyb+8168jSrbNfLTOdF2FcL56r2wbCevzar8JTy1a7aFvgemPZH Zs0NKMv5jUNKu/esHtKcwr0EWrHlF91o28OZlMuTIwAq7+RGuab11CzFSIodX8cA6yQv 2o1WZSTL6gskUqMxk8n/KWNtuEchmgJ2LB+FeDvRQnxLGxwQS3SzVk3EbyO99uF/5/gd 30PbBbIFgIete6RmkMr3TehYfqE2PG/XijUWW3tuqmMa6dy+YuMHBZldhpkaUOQagRQS axuOU6ZyErhhO+Ry7IcGo7gc8NDrdvJzA4twrDri6GhgWKeIadfsLpm9VtzekBtTCa9o 51Ew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:date :subject:message-id:cc:to:from:dkim-signature; bh=8G/SnBL4KTdVBuYbYXFvYdWJaUwHYKER4M4yy6KxfD0=; b=vONdFB+wJ8tprrH5hyVdh2gIZwBiIYJCRAVXLLD3BnY3T/NRdkbCTThO75iHy7TBrN 71p9gLKy5Cw69o4TSHBSMBl8jbHL9zIZ227crX51iMYKDyYTm85MZKOK30Vjv6mqxQfL 2jeePq1YWWz0raHHp1BdrAHG8PW8FtrUfDa2JlhQotJRLjhIGqiFNMx0GbGYT0oED6zU FDzwKvVo5SWz4iim4eNA0jjZTDEaisyxhoX3+mZkxs17GKkZY3F0ll6NWVXRc/i6suSp 5SuR6nowmX7iRNknuL2Lp21bHaMyIsFrdJhm7KUo2s8g7GV6S4CNVWiQ33uMp0Lu+LRz SyfQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@maves.io header.s=dkim header.b=Pkt2X5ov; arc=pass (i=1 spf=pass spfdomain=maves.io dkim=pass dkdomain=maves.io dmarc=pass fromdomain=maves.io>); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si3629979eds.150.2021.02.19.10.11.09; Fri, 19 Feb 2021 10:11:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@maves.io header.s=dkim header.b=Pkt2X5ov; arc=pass (i=1 spf=pass spfdomain=maves.io dkim=pass dkdomain=maves.io dmarc=pass fromdomain=maves.io>); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229796AbhBSSHm (ORCPT + 99 others); Fri, 19 Feb 2021 13:07:42 -0500 Received: from sender4-op-o18.zoho.com ([136.143.188.18]:17847 "EHLO sender4-op-o18.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbhBSSHi (ORCPT ); Fri, 19 Feb 2021 13:07:38 -0500 X-Greylist: delayed 992 seconds by postgrey-1.27 at vger.kernel.org; Fri, 19 Feb 2021 13:07:38 EST ARC-Seal: i=1; a=rsa-sha256; t=1613757019; cv=none; d=zohomail.com; s=zohoarc; b=JaT6a5WDladEi+mz4ROxnwGR5X12xcg5c5x1KcpKBHTt9JKic9JQEEpgaD6diDfh5O3UW7j/hV1MHfzAmCf4BBSV47X//qYNFM/meiVYpaRpsaY69EnP4iHfbVo24w60OinCY7wSGCPbEYJjKmCtWTl4jOwaqir2NYrrC63o1zQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613757019; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=8G/SnBL4KTdVBuYbYXFvYdWJaUwHYKER4M4yy6KxfD0=; b=k+bP8clvUmkqkgQWr3/W+bJiDlvkxEAtlqHQmUJ0uGoXEMHeg17UMxgPMYnwA0M1X2W9TgkES0v9uWysLbK3oMARh2yBTsB54R3NP27+Bnnc5F6hQCz5JULFhvlfgKCQNzQl2vfSbJuJy6yOrVguEGhV6wkpQ0AYSA+W5EAFTq0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=maves.io; spf=pass smtp.mailfrom=curtis@maves.io; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1613757019; s=dkim; d=maves.io; i=curtis@maves.io; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=8G/SnBL4KTdVBuYbYXFvYdWJaUwHYKER4M4yy6KxfD0=; b=Pkt2X5ovg1sGKSJBkQEZH/2Z42uVJzzIkp9pmoZmxwHfdW7HZT7VprnBYBZwbPgh URf/GS2ZeQNRlrZxnW7fto+xMmXaerQ0Dm7l8ptp1PZQiKl4n6wMKkZA2G3gDIJwR+I +Gl95bdo2nQ5s45vD1Un9w3uqiwC/SVWvhPy90RA= Received: from localhost.localdomain (87.101.92.171 [87.101.92.171]) by mx.zohomail.com with SMTPS id 1613757016499791.914327155336; Fri, 19 Feb 2021 09:50:16 -0800 (PST) From: Curtis To: linux-bluetooth@vger.kernel.org Cc: Curtis Message-ID: <20210219174946.599144-1-curtis@maves.io> Subject: [PATCH BlueZ] gatt-database: Fix notifying on indicatable attr Date: Fri, 19 Feb 2021 12:49:46 -0500 X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset=utf8 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When a local GATT characteristic has both the indicate and notify properties, notifications will not be send to clients requesting them. This change fixes this, allowing for notifications to be sent. Also simplifies logic about when notifications/indications should be sent. --- src/gatt-database.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gatt-database.c b/src/gatt-database.c index d635c3214..bd5864bcd 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -1344,10 +1344,7 @@ static void send_notification_to_device(void *data, = void *user_data) =09} =20 =09ccc =3D find_ccc_state(device_state, notify->ccc_handle); -=09if (!ccc) -=09=09return; - -=09if (!ccc->value || (notify->conf && !(ccc->value & 0x0002))) +=09if (!ccc || !(ccc->value & 0x0003)) =09=09return; =20 =09device =3D btd_adapter_find_device(notify->database->adapter, @@ -1374,7 +1371,7 @@ static void send_notification_to_device(void *data, v= oid *user_data) =09 * TODO: If the device is not connected but bonded, send the =09 * notification/indication when it becomes connected. =09 */ -=09if (!notify->conf) { +=09if (!(ccc->value & 0x0002)) { =09=09DBG("GATT server sending notification"); =09=09bt_gatt_server_send_notification(server, =09=09=09=09=09notify->handle, notify->value, @@ -2415,8 +2412,8 @@ static bool sock_io_read(struct io *io, void *user_da= ta) =09=09=09=09gatt_db_attribute_get_handle(chrc->attrib), =09=09=09=09buf, bytes_read, =09=09=09=09gatt_db_attribute_get_handle(chrc->ccc), -=09=09=09=09chrc->props & BT_GATT_CHRC_PROP_INDICATE ? -=09=09=09=09conf_cb : NULL, chrc->proxy); +=09=09=09=09conf_cb, +=09=09=09=09chrc->proxy); =20 =09return true; } @@ -2725,8 +2722,8 @@ static void property_changed_cb(GDBusProxy *proxy, co= nst char *name, =09=09=09=09gatt_db_attribute_get_handle(chrc->attrib), =09=09=09=09value, len, =09=09=09=09gatt_db_attribute_get_handle(chrc->ccc), -=09=09=09=09chrc->props & BT_GATT_CHRC_PROP_INDICATE ? -=09=09=09=09conf_cb : NULL, proxy); +=09=09=09=09conf_cb, +=09=09=09=09proxy); } =20 static bool database_add_ccc(struct external_service *service, --=20 2.30.1