Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp34076pxb; Fri, 19 Feb 2021 17:01:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2AnPVnLVk+FiU+Hi0vyS8xoizExiLWROmCvHGV+0iRKdtNVsmCFonR8oGZLmWMxUXrLuv X-Received: by 2002:a17:907:c27:: with SMTP id ga39mr11441897ejc.68.1613782904257; Fri, 19 Feb 2021 17:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613782904; cv=none; d=google.com; s=arc-20160816; b=WWWLaiWD7CMm7qwa+9DO71fCbHnE4NU8MDRow2+r/u8W9aGEtw2Pa4JP2+5sgDzNAo pNRMxFhfG9HWupW4kwE2j7e8vPtbPEg4dYpjxYKPucoEUTs+tK/lamzJOO6LrN9Ytp4L LHp/JB2YIREHvsERqDJanMle5j8TeZLykIPhkM7cdiUYPpGUiZVlAK3K/yWpm6yygXMH G18bHC8k/jentJllJxn94hc06hzG7ZoRtQqGTNfT37HLvDs54HfBCDVZjSAGUhS8NU5u O3y7tD3tVsiPA01P3xgo/5lyrxMDVDsggckwAa2UGwMjj4XWk6OEd1ro4BDl98Nem8G0 gnMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=91KdcJL+lyGhRpAHzqCrWweWKfPWy6lKqdSxpOudc20=; b=WxwIEYQWXBZPYDF+r6O0di8/oPQdIM72BlyBA7k/5EOGS7XtCsM8EhNN+8/GFywyRd 3njDeK2HDzi9zEnMQ5Wa8mbQqtJDqXrJSsKyKGRKz20qW8GaKGyaoJsV/9mqBf2bbTXm TSF8Q4yAYnsQdNVmG7arVhaLMwH4+fa35gZYP3tFQpdJavf5ptiF7rmUfzZoYBAl4zlR zmvvQlaCNLJ0ZXg003vuRlIM1NFACTCOJWhRlPz0saA512zwMLhQNnaAxU469+7RQoc5 6gt1ov8+UC9r6UNCrGZCGDBblwuZMgKq6emzY9Fn2Ea8eW8TojwWh8tpwJikjgkpPqcj w4WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uS1RtHHo; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si6793517edu.474.2021.02.19.17.00.32; Fri, 19 Feb 2021 17:01:44 -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=@gmail.com header.s=20161025 header.b=uS1RtHHo; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbhBTAz7 (ORCPT + 99 others); Fri, 19 Feb 2021 19:55:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbhBTAz5 (ORCPT ); Fri, 19 Feb 2021 19:55:57 -0500 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADC12C06178A for ; Fri, 19 Feb 2021 16:55:17 -0800 (PST) Received: by mail-oi1-x236.google.com with SMTP id y199so7806465oia.4 for ; Fri, 19 Feb 2021 16:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=91KdcJL+lyGhRpAHzqCrWweWKfPWy6lKqdSxpOudc20=; b=uS1RtHHoCoR2rw4pWl6miNADyHzk+WFDXAi40tiy8w1PNdLKtLSMZirmqqGf8zeDo6 pvJGEEu6azNgZQjs6Cqwhx9xhSSWjExRjevslInxCh5K2aWmqkQ04wAl9aaSal4ELyyh De1y5y4TcDaQrf74sS1OfdOL1ko7re591MLTHlmtVi1TTjHllRGtuU7zC60VakLxOQcO s1FTEEJpUlnr+Ba4AZ/ejkYtoueR6UQdmiVddyMY24JaeEm/ot85uMKfIDnyTPOR7479 +hk4tVW7wVhGkXhmqh5C29LNaV4e2qpMYt0Gt3P709wCRhJaWiDZtqoVk2yfszAYLnpB y8lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=91KdcJL+lyGhRpAHzqCrWweWKfPWy6lKqdSxpOudc20=; b=RttsfSEDJzCvxTwLmDw7ziYy0exUlaF8iw6k5vk2Ho+dyouowH+XBgDGtANMuse/mW 0ZQDe7Xw8zN462jXwLFf3qu7o4m1sPWFawEvozXg17/ERMMY+3wquq0wxNngK5FNFuPd B9m3EyD8C46X1z3rvbXX8SxGhyQsZFeTIQlbti//ijVyBwmE9ynrpjzXhuI72ShFvETt PGCfHiqxHcCIqM3s8ySqdkpOkr5jgXoGg2p7kGTY1rGM1crc/y1462jLfsojSZCeE/sN C6eUFcd5G3OGqdJozDMMoTOJFkiraKo27gx+cTGEw6TOHfvcac/lngRz0kOO/caiZk43 phzg== X-Gm-Message-State: AOAM533E9i8xDe/KXq5RzWt/0JYo0EhF/2YXDAE50IIdZKKXqZyiQsZK C6x0sojLb948I5g5Fl479J65K56W1QaVOWXnIhjmL+5LI38= X-Received: by 2002:aca:c109:: with SMTP id r9mr8421592oif.64.1613782516964; Fri, 19 Feb 2021 16:55:16 -0800 (PST) MIME-Version: 1.0 References: <20210219174946.599144-1-curtis@maves.io> In-Reply-To: <20210219174946.599144-1-curtis@maves.io> From: Luiz Augusto von Dentz Date: Fri, 19 Feb 2021 16:55:06 -0800 Message-ID: Subject: Re: [PATCH BlueZ] gatt-database: Fix notifying on indicatable attr To: Curtis Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Curtis, On Fri, Feb 19, 2021 at 10:11 AM Curtis wrote: > > 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) > } > > ccc = find_ccc_state(device_state, notify->ccc_handle); > - if (!ccc) > - return; > - > - if (!ccc->value || (notify->conf && !(ccc->value & 0x0002))) > + if (!ccc || !(ccc->value & 0x0003)) > return; > > device = btd_adapter_find_device(notify->database->adapter, > @@ -1374,7 +1371,7 @@ static void send_notification_to_device(void *data, void *user_data) > * TODO: If the device is not connected but bonded, send the > * notification/indication when it becomes connected. > */ > - if (!notify->conf) { > + if (!(ccc->value & 0x0002)) { > DBG("GATT server sending notification"); > bt_gatt_server_send_notification(server, > notify->handle, notify->value, > @@ -2415,8 +2412,8 @@ static bool sock_io_read(struct io *io, void *user_data) > gatt_db_attribute_get_handle(chrc->attrib), > buf, bytes_read, > gatt_db_attribute_get_handle(chrc->ccc), > - chrc->props & BT_GATT_CHRC_PROP_INDICATE ? > - conf_cb : NULL, chrc->proxy); > + conf_cb, > + chrc->proxy); Not why are you changing this code to always set the conf_cb? This would then always send indication rather then notifications: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/gatt-database.c#n1387 We might need to check what value it stored in the ccc state if both indication and notification is supported. > > return true; > } > @@ -2725,8 +2722,8 @@ static void property_changed_cb(GDBusProxy *proxy, const char *name, > gatt_db_attribute_get_handle(chrc->attrib), > value, len, > gatt_db_attribute_get_handle(chrc->ccc), > - chrc->props & BT_GATT_CHRC_PROP_INDICATE ? > - conf_cb : NULL, proxy); > + conf_cb, > + proxy); > } > > static bool database_add_ccc(struct external_service *service, > -- > 2.30.1 > > -- Luiz Augusto von Dentz