All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 4/4] gatt: Fix assuming service changed has been subscribed
Date: Fri,  8 Jan 2021 13:15:13 -0800	[thread overview]
Message-ID: <20210108211513.5180-4-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20210108211513.5180-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Unfortunately assuming service changed has been subscribed may cause
indication to time out in some peripherals (Logitech M720 Triathlon, Mx
Anywhere 2, Lenovo Mice N700, RAPOO BleMouse and Microsoft Designer
Mouse) even though the expect actually mandates that the client responds
with confirmation these peripherals just ignores it completely which
leads them to be disconnected whenever bluetoothd is restarted or the
system reboots.
---
 src/device.c        | 11 ++---------
 src/gatt-database.c |  2 +-
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/device.c b/src/device.c
index fe885aa64..af13badfc 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5831,18 +5831,11 @@ void device_load_svc_chng_ccc(struct btd_device *device, uint16_t *ccc_le,
 	key_file = g_key_file_new();
 	g_key_file_load_from_file(key_file, filename, 0, NULL);
 
-	/*
-	 * If there is no "ServiceChanged" section we may be loading data from
-	 * old version which did not persist Service Changed CCC values. Let's
-	 * check if we are bonded and assume indications were enabled by peer
-	 * in such case - it should have done this anyway.
-	 */
 	if (!g_key_file_has_group(key_file, "ServiceChanged")) {
 		if (ccc_le)
-			*ccc_le = device->le_state.bonded ? 0x0002 : 0x0000;
+			*ccc_le = 0x0000;
 		if (ccc_bredr)
-			*ccc_bredr = device->bredr_state.bonded ?
-							0x0002 : 0x0000;
+			*ccc_bredr = 0x0000;
 		g_key_file_free(key_file);
 		return;
 	}
diff --git a/src/gatt-database.c b/src/gatt-database.c
index b7d2bea1d..d99604826 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -333,7 +333,7 @@ static void att_disconnected(int err, void *user_data)
 		handle = gatt_db_attribute_get_handle(state->db->svc_chngd_ccc);
 
 		ccc = find_ccc_state(state, handle);
-		if (ccc)
+		if (ccc && ccc->value)
 			device_store_svc_chng_ccc(device, state->bdaddr_type,
 								ccc->value);
 
-- 
2.26.2


  parent reply	other threads:[~2021-01-08 21:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 21:15 [PATCH BlueZ 1/4] util: Introduce util_debug_va Luiz Augusto von Dentz
2021-01-08 21:15 ` [PATCH BlueZ 2/4] shared/att: Add debug level to bt_att_set_debug Luiz Augusto von Dentz
2021-01-08 21:15 ` [PATCH BlueZ 3/4] device: Enable ATT layer debugging Luiz Augusto von Dentz
2021-01-08 21:15 ` Luiz Augusto von Dentz [this message]
2021-01-20  9:29   ` [PATCH BlueZ 4/4] gatt: Fix assuming service changed has been subscribed Sathish Narasimman
2021-01-20 15:35     ` Luiz Augusto von Dentz
2021-01-08 21:40 ` [BlueZ,1/4] util: Introduce util_debug_va bluez.test.bot
2021-01-11 16:46   ` 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=20210108211513.5180-4-luiz.dentz@gmail.com \
    --to=luiz.dentz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.