2021-03-26 12:44:25

by Alexander Haas

[permalink] [raw]
Subject: [PATCH BlueZ] gatt: allow 'notify' and 'indicate' flags

It is possible that some characteristics use the Notify as well as Indicate property.
In this case the CCC value is 3 and BlueZ returns BT_ERROR_CCC_IMPROPERLY_CONFIGURED.
This should be the behavior for values > 3.
---
src/gatt-database.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gatt-database.c b/src/gatt-database.c
index be6dfb265..8e16c1d79 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2648,9 +2648,9 @@ static uint8_t ccc_write_cb(struct pending_op *op, void *user_data)
return BT_ATT_ERROR_INSUFFICIENT_RESOURCES;

/* Don't support undefined CCC values yet */
- if (value > 2 ||
- (value == 1 && !(chrc->props & BT_GATT_CHRC_PROP_NOTIFY)) ||
- (value == 2 && !(chrc->props & BT_GATT_CHRC_PROP_INDICATE)))
+ if (value > 3 ||
+ (value & 0x1 && !(chrc->props & BT_GATT_CHRC_PROP_NOTIFY)) ||
+ (value & 0x2 && !(chrc->props & BT_GATT_CHRC_PROP_INDICATE)))
return BT_ERROR_CCC_IMPROPERLY_CONFIGURED;

if (chrc->notify_io) {
--
2.31.0
_____________________________________________________________________________________

Expleo Germany GmbH
Sitz der Gesellschaft | Corporate Headquarters: München
Handelsregister | Commercial Register: Amtsgericht München HRB 83252
Geschäftsführung | Management: Ralph Gillessen, Marcus Ganguin

This message contains information that may be privileged or confidential. It is intended only for the person to whom it is addressed.
If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof.
If you receive this message in error, please notify the sender immediately and delete all copies of this message.
_________________________________________________________

EMAIL LEGAL MENTION / DISCLAIMER

This message contains information that may be privileged or confidential and is the property of the Expleo Services SAS, RCS Versailles 831 178 348, located, 3 avenue des Prés, 78180 Montigny Le Bretonneux - France. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

Ce message contient des informations qui peuvent être privilégiées ou confidentielles et elles sont de la propriété d'Expleo Services SAS, RCS Versailles 831 178 348, situé, 3 avenue des Prés, 78180 Montigny le Bretonneux-France. Il est destiné uniquement à la personne à qui est adressé. Si vous n'êtes pas le destinataire visé, vous n'êtes pas autorisé à lire, imprimer, conserver, copier, diffuser, distribuer ou utiliser ce message ou toute partie de celui-ci. Si vous recevez ce message par erreur, veuillez en avertir immédiatement l'expéditeur et supprimer toutes les copies de ce message.


2021-03-26 21:46:29

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ] gatt: allow 'notify' and 'indicate' flags

Hi Alexander,

On Fri, Mar 26, 2021 at 5:44 AM Alexander Haas
<[email protected]> wrote:
>
> It is possible that some characteristics use the Notify as well as Indicate property.
> In this case the CCC value is 3 and BlueZ returns BT_ERROR_CCC_IMPROPERLY_CONFIGURED.
> This should be the behavior for values > 3.
> ---
> src/gatt-database.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/gatt-database.c b/src/gatt-database.c
> index be6dfb265..8e16c1d79 100644
> --- a/src/gatt-database.c
> +++ b/src/gatt-database.c
> @@ -2648,9 +2648,9 @@ static uint8_t ccc_write_cb(struct pending_op *op, void *user_data)
> return BT_ATT_ERROR_INSUFFICIENT_RESOURCES;
>
> /* Don't support undefined CCC values yet */
> - if (value > 2 ||
> - (value == 1 && !(chrc->props & BT_GATT_CHRC_PROP_NOTIFY)) ||
> - (value == 2 && !(chrc->props & BT_GATT_CHRC_PROP_INDICATE)))
> + if (value > 3 ||
> + (value & 0x1 && !(chrc->props & BT_GATT_CHRC_PROP_NOTIFY)) ||
> + (value & 0x2 && !(chrc->props & BT_GATT_CHRC_PROP_INDICATE)))
> return BT_ERROR_CCC_IMPROPERLY_CONFIGURED;
>
> if (chrc->notify_io) {
> --
> 2.31.0

Looks like your email client has mangled your patch:

Applying: gatt: allow 'notify' and 'indicate' flags
error: corrupt patch at line 11
Patch failed at 0001 gatt: allow 'notify' and 'indicate' flags

I'm also curious about what client does require subscribing to
notification and indication at same time? This would lead to
duplicated data being sent as both notification and indication, also
since indication are queued until a confirmation is received
subscribing to both simultaneously may cause races:

PropertiesChanged: Value: 0xaa
ATT: Notify 0xaa
ATT: Indicate 0xaa

PropertiesChanged: Value: 0xbb
ATT: Notify 0xbb
(queued)[ATT: Indicate 0xaa]

PropertiesChanged: Value: 0xcc
ATT: Notify 0xcc
(queued)[ATT: Indicate 0xcc]

ATT: Confirm
ATT: Indicate 0xbb

ATT: Confirm
ATT: Indicate 0xcc

So the client may perceive the indication as rollbacks, so while this
may be valid according to the spec this can cause issues if not
handled correctly. If this is due different applications having
different subscription types, one wants to be notified and the other
indicated, then only indication shall be used.

> _____________________________________________________________________________________
>
> Expleo Germany GmbH
> Sitz der Gesellschaft | Corporate Headquarters: München
> Handelsregister | Commercial Register: Amtsgericht München HRB 83252
> Geschäftsführung | Management: Ralph Gillessen, Marcus Ganguin
>
> This message contains information that may be privileged or confidential. It is intended only for the person to whom it is addressed.
> If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof.
> If you receive this message in error, please notify the sender immediately and delete all copies of this message.
> _________________________________________________________
>
> EMAIL LEGAL MENTION / DISCLAIMER
>
> This message contains information that may be privileged or confidential and is the property of the Expleo Services SAS, RCS Versailles 831 178 348, located, 3 avenue des Prés, 78180 Montigny Le Bretonneux - France. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
>
> Ce message contient des informations qui peuvent être privilégiées ou confidentielles et elles sont de la propriété d'Expleo Services SAS, RCS Versailles 831 178 348, situé, 3 avenue des Prés, 78180 Montigny le Bretonneux-France. Il est destiné uniquement à la personne à qui est adressé. Si vous n'êtes pas le destinataire visé, vous n'êtes pas autorisé à lire, imprimer, conserver, copier, diffuser, distribuer ou utiliser ce message ou toute partie de celui-ci. Si vous recevez ce message par erreur, veuillez en avertir immédiatement l'expéditeur et supprimer toutes les copies de ce message.

You probably don't want to include this disclaimer if you are
contributing to a project license under GPL.

--
Luiz Augusto von Dentz