Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp153483pxb; Fri, 19 Feb 2021 22:12:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGho65pPU33+538oxfwvfvFuT19Zu+VrWl1lpuTp+RdF315CKI0mxvBGT4mCBeJepXj5op X-Received: by 2002:a05:6402:3133:: with SMTP id dd19mr12471671edb.337.1613801536119; Fri, 19 Feb 2021 22:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613801536; cv=none; d=google.com; s=arc-20160816; b=cKQVAQn5aAHgYyBtzpqIvLagbJ8K509ZhskjZvmBdiq/We5UtMwan40zjxfIJSISfI XL6Ea2lU29kM6udlrKFaNab0Eki3DBJffe+L2x0NaKigM3jp0WhGT3k/aIBedDFJk9Oq yYZQ9DcXXA7SXTXalkCLWu4F0E9AzOoFIOrb4qRocLplJTn45IIYRRU3BBMIiaeGCIe8 p9R8TiGD4rLHsVKHvp0OZoi1S+pH2JMYV3dF5e/HiT9eJfVVNLHCmIfUtocIZCBOntXf eUXS06NXCgFrCO/5eY8jKGDlkdTIM1/0KY5LgRzEAO2me07eA6VL20UlwmEC53WXh3lm Ll3w== 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=NYIAeeAlfZJENqCblqDXX3/qVLsMgX2I6CU0945qboI=; b=KGj5LbL/eWOzYhD52dI7Yqjeb9gV50yq9kITfcCm2PqW7KciRZf3WDENFvLupGIddw dlRx8uU2/cpDjtaK74JH4Ok/szjYM54evU6nhf3BagMznQvZ8gZ1E8UD2T/7MO4GaBJx JHIeAea27JIi5C4o64MOU3NleeA1P8p4tIsgbMwLdi2sCr7BAphUgZoUuH3ztUpsG29n FszXgWD3KMfWRsxzrRGtbNd5k225FdX5+s+WkjRiSY5aXbEKgqVrDQaN11pXIT1OWPi7 jqFhXYVBNikSyu3DFtQSo8LwN2CRhgUksjXS2RbMz+lJRTNia3nqoX+JkkcS7eDHXQ4f KNTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ioQAoJ6a; 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 k10si7203930ejg.374.2021.02.19.22.11.27; Fri, 19 Feb 2021 22:12:16 -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=ioQAoJ6a; 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 S229542AbhBTGIu (ORCPT + 99 others); Sat, 20 Feb 2021 01:08:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbhBTGIt (ORCPT ); Sat, 20 Feb 2021 01:08:49 -0500 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D95B7C061574 for ; Fri, 19 Feb 2021 22:08:08 -0800 (PST) Received: by mail-ot1-x334.google.com with SMTP id s107so7176710otb.8 for ; Fri, 19 Feb 2021 22:08:08 -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=NYIAeeAlfZJENqCblqDXX3/qVLsMgX2I6CU0945qboI=; b=ioQAoJ6aLh2qQgTTtlH8NCILun6NhyGC1Refd6hJNj5dyjICiQCnv2V98q0Xj03Mx1 6RnpyY9+ly5zNaHHTFy8Tc3L5q2sflMc/4Z8P6TN0xBHjc163AtSU3RTd8kRKUB8+u/m VQiRCrsxvE8Yr8MBosXm0UriM2sS9i4XbnItKiycKbcCe8l+O3W5PpQXHAV1DIgmWuqo ztlOcsRuKCZb1qFym3S2Q2/8Xf+Pcg5UYPmEMWLJv49VXv4MXoIYNQzwla5E8jykcKsP /pVQuI3URts0KfKF1gCkgRu/APlYXKHptFZDI0JoeJ+gOHSUV/BFoPgIhNwNOdwmkyj7 tVOA== 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=NYIAeeAlfZJENqCblqDXX3/qVLsMgX2I6CU0945qboI=; b=pXp4s/5Dnjn4koj8fRlJpTfjTOmwNybOi/7C5TlzlWnQEYuxuNokR+uKK4e22vIT9r NjKURDKmGqW10q5/fhyzyCGObvF3klQDfRWYMrYmQILf7dT/1u9AcLUOQdj5MaejH7Z3 Od8MOcQQgSwSU6w8QFEjHfwpnNX87tbM8xXVPG4GLE349L8864D8zwftMpdzH7A1unba Qx4oGFIw3ZTcZaQ8AimiD1h0db5LORiG09rroQmfUFIBnI2q4q7wVaZDscy7efBeOBxo EiYJvhGcGlLK6QPLv6k3g0R3uFgfPnNJpx2feyjXkLJyUFiSdEpACYKH2oQETQr1NesE MTtw== X-Gm-Message-State: AOAM530KbSdEZ6/QHLEau2kTVEjgKNmmlxU5ZCbGr2ZUoU846BpJret6 wur1cy9xm5XL8mbhJ1a3ZGfr+ClsboWZAI7RylJx34sedzw= X-Received: by 2002:a9d:6c7:: with SMTP id 65mr10086289otx.240.1613801288105; Fri, 19 Feb 2021 22:08:08 -0800 (PST) MIME-Version: 1.0 References: <20210219174946.599144-1-curtis@maves.io> <177bd04559f.d1a7c05c116102.319856870975137121@maves.io> In-Reply-To: <177bd04559f.d1a7c05c116102.319856870975137121@maves.io> From: Luiz Augusto von Dentz Date: Fri, 19 Feb 2021 22:07:57 -0800 Message-ID: Subject: Re: [PATCH BlueZ] gatt-database: Fix notifying on indicatable attr To: Curtis Maves 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 5:18 PM Curtis Maves wrote: > > Hi Luiz, > ---- On Fri, 19 Feb 2021 19:55:06 -0500 Luiz Augusto von Dentz wrote ---- > > > 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 > > > > This patch changes the if-statement around sending notifications to check that the > ccc->value is not indicating rather than checking if conf_cb (notify->conf) is null. > This change makes unnecessary to conditionally pass the conf_cb. It's now simpler to always pass it. What Im saying is that we can't do this: if (!notify->conf) { DBG("GATT server sending notification"); conf callback will always be set so instead we need to change that to: if (ccc->value != 0x02) > -- > Curtis Maves -- Luiz Augusto von Dentz