Linux bluetooth development
 help / color / mirror / Atom feed
From: Mikhail Krivtsov <mikhail.krivtsov@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: gatt client clones break indication/confirmation
Date: Mon, 23 May 2016 12:57:30 +0300	[thread overview]
Message-ID: <5742D40A.4080903@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 821 bytes --]

When bt_gatt_client receives 'indication' it sends 'confirmation'.
'confirmation' sending was broken after adding support for 'clones' of
bt_gatt_client. In addition to first bt_gatt_client each clone also
sends 'confirmation'.

# > ACL Data RX: Handle 69 flags 0x02 dlen 27
#       ATT: Handle Value Indication (0x1d) len 22
#         Handle: 0x001f
#           Data: 68656c6c6f2027302e302e302e303a3532353332
# < ACL Data TX: Handle 69 flags 0x00 dlen 5
#       ATT: Handle Value Confirmation (0x1e) len 0
# < ACL Data TX: Handle 69 flags 0x00 dlen 5
#       ATT: Handle Value Confirmation (0x1e) len 0

Extra confirmation sent by clone confuses remote side. When bluetooth
daemon receives extra confirmation it breaks connection.

Attached patch fixes the issue limiting confirmation sending to single
bt_gatt_client.


[-- Attachment #2: 0001-shared-gatt-client_Fix_sending_confirmation.patch --]
[-- Type: text/x-patch, Size: 1312 bytes --]

>>From e470089b4b5788ab5d2ec9af21bffee4f9240c97 Mon Sep 17 00:00:00 2001
From: "Mikhail I. Krivtsov" <mikhail.krivtsov@gmail.com>
Date: Sat, 14 May 2016 11:37:30 +0300
Subject: [PATCH] shared/gatt-client: Fix sending confirmation

Confirmation shall be sent from topmost parent only.
Extra confirmation sent by clone confuses remote side.

> ACL Data RX: Handle 69 flags 0x02 dlen 27
      ATT: Handle Value Indication (0x1d) len 22
        Handle: 0x001f
          Data: 68656c6c6f2027302e302e302e303a3532353332
< ACL Data TX: Handle 69 flags 0x00 dlen 5
      ATT: Handle Value Confirmation (0x1e) len 0
< ACL Data TX: Handle 69 flags 0x00 dlen 5
      ATT: Handle Value Confirmation (0x1e) len 0
---
 src/shared/gatt-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 84689f6..adabfe3 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1745,7 +1745,7 @@ static void notify_cb(uint8_t opcode, const void *pdu, uint16_t length,
 
 	queue_foreach(client->notify_list, notify_handler, &pdu_data);
 
-	if (opcode == BT_ATT_OP_HANDLE_VAL_IND)
+	if (opcode == BT_ATT_OP_HANDLE_VAL_IND && !client->parent)
 		bt_att_send(client->att, BT_ATT_OP_HANDLE_VAL_CONF, NULL, 0,
 							NULL, NULL, NULL);
 
-- 
2.7.3



             reply	other threads:[~2016-05-23  9:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23  9:57 Mikhail Krivtsov [this message]
2016-05-23 12:24 ` gatt client clones break indication/confirmation Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5742D40A.4080903@gmail.com \
    --to=mikhail.krivtsov@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox