* [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate
@ 2026-11-13 16:53 Marian Poltak via B4 Relay
2026-11-13 16:53 ` [PATCH bluez v2 1/2] " Marian Poltak via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Marian Poltak via B4 Relay @ 2026-11-13 16:53 UTC (permalink / raw)
To: Linux Bluetooth
Some devices, e.g. the Aqara Presence Sensor P2 in Matter commissioning
mode, declare the Service Changed characteristic as Read | Notify only.
The client initialization then fails because indications are requested
explicitly, so no services are exported although ServicesResolved is
set.
Patch 1 requests indications only when the characteristic supports
them. Patch 2 adds unit tests for both cases.
---
Changes in v2:
- unit/test-gatt: keep the new tests running until the Service Changed
CCC write is exchanged; they previously ended as "Not Run" once the
client reported ready (reported by Copilot review).
- Link to v1: https://patch.msgid.link/20261112-svc-chngd-notify-only-v1-0-c7db7ac47acf@gmail.com
---
Marian Poltak (2):
shared/gatt-client: Fix init when Service Changed lacks Indicate
unit/test-gatt: Add Service Changed registration tests
src/shared/gatt-client.c | 15 +++++++++++++-
unit/test-gatt.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
---
base-commit: 9659adb6819d7e0284d0d2ba226a3894423d8db4
change-id: 20261112-svc-chngd-notify-only-f1d1d99d3f34
Best regards,
--
Marian Poltak <marianpoltak@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH bluez v2 1/2] shared/gatt-client: Fix init when Service Changed lacks Indicate
2026-11-13 16:53 [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate Marian Poltak via B4 Relay
@ 2026-11-13 16:53 ` Marian Poltak via B4 Relay
2026-11-13 16:53 ` [PATCH bluez v2 2/2] unit/test-gatt: Add Service Changed registration tests Marian Poltak via B4 Relay
2026-11-18 19:20 ` [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Marian Poltak via B4 Relay @ 2026-11-13 16:53 UTC (permalink / raw)
To: Linux Bluetooth
From: Marian Poltak <marianpoltak@gmail.com>
register_service_changed() requests indications explicitly and
register_notify() rejects this when the characteristic does not declare
the Indicate property. Some devices, e.g. the Aqara Presence Sensor P2
in Matter commissioning mode, declare Service Changed as Read | Notify
only, so the client initialization fails and no services are exported,
although ServicesResolved is set.
Request indications only when they are supported, and otherwise pick
the CCC value from the properties as before.
Fixes: 52fdca35b8e7 ("shared/gatt-client: Allow registering notify with explicit CCC value")
Assisted-by: Claude:claude-opus-5-5
---
src/shared/gatt-client.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 7bebc50dc..ea9f7167c 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1887,6 +1887,8 @@ static bool register_service_changed(struct bt_gatt_client *client)
{
bt_uuid_t uuid;
struct gatt_db_attribute *attr = NULL;
+ uint8_t properties;
+ uint16_t ccc_value = 0;
bt_uuid16_create(&uuid, SVC_CHNGD_UUID);
@@ -1898,6 +1900,17 @@ static bool register_service_changed(struct bt_gatt_client *client)
if (!attr)
return true;
+ /*
+ * "Service Changed" shall be indicated, but some devices only
+ * declare the notify property. Request indications only when they
+ * are supported, otherwise let register_notify() pick the CCC value
+ * from the properties.
+ */
+ if (gatt_db_attribute_get_char_data(attr, NULL, NULL, &properties,
+ NULL, NULL) &&
+ (properties & BT_GATT_CHRC_PROP_INDICATE))
+ ccc_value = 0x0002;
+
/*
* Register an indication handler for the "Service Changed"
* characteristic and report ready only if the handler is registered
@@ -1905,7 +1918,7 @@ static bool register_service_changed(struct bt_gatt_client *client)
*/
client->svc_chngd_ind_id = register_notify(client,
gatt_db_attribute_get_handle(attr),
- 0x0002,
+ ccc_value,
service_changed_register_cb,
service_changed_cb,
client, NULL);
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH bluez v2 2/2] unit/test-gatt: Add Service Changed registration tests
2026-11-13 16:53 [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate Marian Poltak via B4 Relay
2026-11-13 16:53 ` [PATCH bluez v2 1/2] " Marian Poltak via B4 Relay
@ 2026-11-13 16:53 ` Marian Poltak via B4 Relay
2026-11-18 19:20 ` [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Marian Poltak via B4 Relay @ 2026-11-13 16:53 UTC (permalink / raw)
To: Linux Bluetooth
From: Marian Poltak <marianpoltak@gmail.com>
Add client tests enabling Service Changed when the characteristic
declares Indicate, and when it declares Notify only.
Assisted-by: Claude:claude-opus-5-5
---
unit/test-gatt.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index bf6074107..06c9505fd 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -303,6 +303,25 @@ struct context {
DESCRIPTOR_DISC_SMALL_DB
+/*
+ * GATT service (0x0001-0x0004) with a Service Changed characteristic
+ * declaring the given properties, value handle 0x0003 and a CCC at 0x0004.
+ */
+#define SVC_CHNGD_DISCOVERY_PDUS(props) \
+ raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28), \
+ raw_pdu(0x11, 0x06, 0x01, 0x00, 0x04, 0x00, 0x01, 0x18),\
+ raw_pdu(0x10, 0x05, 0x00, 0xff, 0xff, 0x00, 0x28), \
+ raw_pdu(0x01, 0x10, 0x05, 0x00, 0x0a), \
+ raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x01, 0x28), \
+ raw_pdu(0x01, 0x10, 0x01, 0x00, 0x0a), \
+ raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x02, 0x28), \
+ raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a), \
+ raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x03, 0x28), \
+ raw_pdu(0x09, 0x07, 0x02, 0x00, props, 0x03, 0x00, 0x05,\
+ 0x2a), \
+ raw_pdu(0x08, 0x03, 0x00, 0x04, 0x00, 0x03, 0x28), \
+ raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a)
+
#define SERVER_MTU_EXCHANGE_PDU raw_pdu(0x02, 0x17, 0x00)
static bt_uuid_t uuid_16 = {
@@ -2507,6 +2526,18 @@ static const struct test_step test_notification_1 = {
.length = 0x03,
};
+static void test_svc_chngd_register(struct context *context)
+{
+ /*
+ * The client is reported ready once the "Service Changed" CCC write
+ * is queued, keep the context running until the PDUs are exchanged.
+ */
+}
+
+static const struct test_step test_svc_chngd_register_1 = {
+ .func = test_svc_chngd_register,
+};
+
static void notification_short_cb(uint16_t value_handle,
const uint8_t *value, uint16_t length,
void *user_data)
@@ -3736,6 +3767,28 @@ int main(int argc, char *argv[])
raw_pdu(),
raw_pdu(0x1B, 0x03, 0x00, 0x01, 0x02, 0x03));
+ /* Service Changed with Indicate: indications are enabled */
+ define_test_client("/robustness/svc-chngd-indicate", test_client,
+ NULL, &test_svc_chngd_register_1,
+ CLIENT_INIT_PDUS,
+ SVC_CHNGD_DISCOVERY_PDUS(0x22),
+ raw_pdu(0x12, 0x04, 0x00, 0x02, 0x00),
+ raw_pdu(0x13),
+ raw_pdu());
+
+ /*
+ * Service Changed declaring Notify only (not compliant, seen on
+ * real devices): notifications are enabled instead of failing the
+ * client initialization.
+ */
+ define_test_client("/robustness/svc-chngd-notify-only", test_client,
+ NULL, &test_svc_chngd_register_1,
+ CLIENT_INIT_PDUS,
+ SVC_CHNGD_DISCOVERY_PDUS(0x12),
+ raw_pdu(0x12, 0x04, 0x00, 0x01, 0x00),
+ raw_pdu(0x13),
+ raw_pdu());
+
define_test_server("/TP/GAN/SR/BV-01-C", test_server, ts_small_db,
&test_notification_server_1,
raw_pdu(0x03, 0x00, 0x02),
--
2.56.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate
2026-11-13 16:53 [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate Marian Poltak via B4 Relay
2026-11-13 16:53 ` [PATCH bluez v2 1/2] " Marian Poltak via B4 Relay
2026-11-13 16:53 ` [PATCH bluez v2 2/2] unit/test-gatt: Add Service Changed registration tests Marian Poltak via B4 Relay
@ 2026-11-18 19:20 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2026-11-18 19:20 UTC (permalink / raw)
To: =?utf-8?b?TWFyacOhbiBQb2zFpcOhayA8bWFyaWFucG9sdGFrQGdtYWlsLmNvbT4=?=
Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Fri, 13 Nov 2026 17:53:39 +0100 you wrote:
> Some devices, e.g. the Aqara Presence Sensor P2 in Matter commissioning
> mode, declare the Service Changed characteristic as Read | Notify only.
> The client initialization then fails because indications are requested
> explicitly, so no services are exported although ServicesResolved is
> set.
>
> Patch 1 requests indications only when the characteristic supports
> them. Patch 2 adds unit tests for both cases.
>
> [...]
Here is the summary with links:
- [bluez,v2,1/2] shared/gatt-client: Fix init when Service Changed lacks Indicate
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=0f08061cb4d3
- [bluez,v2,2/2] unit/test-gatt: Add Service Changed registration tests
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e12013a9bcb1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-18 19:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 16:53 [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate Marian Poltak via B4 Relay
2026-11-13 16:53 ` [PATCH bluez v2 1/2] " Marian Poltak via B4 Relay
2026-11-13 16:53 ` [PATCH bluez v2 2/2] unit/test-gatt: Add Service Changed registration tests Marian Poltak via B4 Relay
2026-11-18 19:20 ` [PATCH bluez v2 0/2] shared/gatt-client: Fix init when Service Changed lacks Indicate patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox