From: Marian Poltak via B4 Relay <devnull+marianpoltak.gmail.com@kernel.org>
To: Linux Bluetooth <linux-bluetooth@vger.kernel.org>
Subject: [PATCH bluez v2 2/2] unit/test-gatt: Add Service Changed registration tests
Date: Fri, 13 Nov 2026 17:53:41 +0100 [thread overview]
Message-ID: <20261113-svc-chngd-notify-only-v2-2-e07cc198f32b@gmail.com> (raw)
In-Reply-To: <20261113-svc-chngd-notify-only-v2-0-e07cc198f32b@gmail.com>
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
next prev parent reply other threads:[~2026-11-13 16:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-11-18 19:20 ` [PATCH bluez v2 0/2] " patchwork-bot+bluetooth
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=20261113-svc-chngd-notify-only-v2-2-e07cc198f32b@gmail.com \
--to=devnull+marianpoltak.gmail.com@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marianpoltak@gmail.com \
/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