gatt client clones break indication/confirmation
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.
Quoted 1 line
Quoted 1 line
From
e470089b4b5788ab5d2ec9af21bffee4f9240c97Mon Sep 17 00:00:00 2001
From: "Mikhail I. Krivtsov" <[email protected]>
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.
Quoted 1 line
ACL Data RX: Handle 69 flags
0x02dlen 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(-)src/shared/gatt-client.c +1 -1
@@ -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 );
Signature · 1 line
2.7.3
Luiz Augusto von Dentz
maintainerHi Mikhail,
Quoted 14 lines · Mikhail Krivtsov
When
bt_gatt_clientreceives 'indication' it sends 'confirmation'. 'confirmation' sending was broken after adding support for 'clones' ofbt_gatt_client. In addition to firstbt_gatt_clienteach clone also sends 'confirmation'.# > ACL Data RX: Handle 69 flags
0x02dlen 27
# ATT: Handle Value Indication (0x1d) len 22
# Handle:0x001f
# Data:68656c6c6f2027302e302e302e303a3532353332
# < ACL Data TX: Handle 69 flags0x00dlen 5
# ATT: Handle Value Confirmation (0x1e) len 0
# < ACL Data TX: Handle 69 flags0x00dlen 5
# ATT: Handle Value Confirmation (0x1e) len 0
Quoted 5 lines
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.
I went ahead and applied this fix, thanks for the contribution.
*Next time please do follow the instruction under HACKING and send as a proper patch.
Signature · 1 line
Luiz Augusto von Dentz