Skip to contentSkip to conversation

asha: Notify connection interval changes

RFC PATCH Superseded Kyle Pepper 2 participants 4 messages Oct 29 – Nov 7

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/1 asha: Notify connection interval changes

Omitting the connection-update STATUS notification causes repeated N8 supervision timeouts even with a negotiated 20 ms interval. Restoring the notification alone prevents the reported link failures.

Observe successful LE connection and update events per adapter, associate them with the ATT socket's handle, and announce the observed interval before START and on subsequent successful updates. Clear the observation on disconnect so a reused handle cannot inherit another link's interval. Notify the attached HiSyncId peer as well, matching Android's connection-update STATUS handling, without truncating the interval byte.

Reuse the verified socket handle when delivering a live update.

Add tests for event delivery, controller isolation, disconnect/reuse, pre-START ordering, failed updates and peer notification. Use source-level mocks so the tests remain valid with link-time optimization enabled.

Fixes c26389c466a0 ("profiles/audio: Add an ASHA plugin")
Assisted-by OpenCode:gpt-6.1-sol

---
Resending unchanged v2 after inactivity closure of the prior CI PR (closure reported October 28). Original source and attribution retained. Prior v2 CI passed as reported; not independently reverified. No new hardware or remote CI result is claimed.

Changes since v1: fix sanitizer-retained daemon references with fail-fast test stubs. Declare socket wrappers in a test header. Refreshed to BlueZ 9dc7e40962f11d1d9a5568f8a7633a695288329c. Strict non-LTO ASan/UBSan build and make check pass; ordinary LTO build and make check pass. Strict LTO has an unchanged upstream peripheral/btsensor warning failure, reproduced without this topic. No new hardware trial or remote functional-lab result is claimed.

Submission review notes (not part of the commit message):
Removing interval STATUS previously caused N8 timeouts; the tested combined package restores it. The observer sends completed values, not requested constants. Raw-HCI access, missed events, startup coordination and observer/connection lifecycle need review. A link predating observer creation remains unknown until a later successful update.

 .gitignore                |   4 +
 Makefile.am               |  17 ++
 profiles/audio/asha.c     | 237 +++++++++++++++++++
 src/shared/asha.c         |  28 +++
 src/shared/asha.h         |   1 +
 unit/test-asha-conn.c     | 469 ++++++++++++++++++++++++++++++++++++++
 unit/test-asha-conn.h     |  11 +
 unit/test-asha-interval.c | 104 +++++++++
 8 files changed, 871 insertions(+)
 create mode 100644 unit/test-asha-conn.c
 create mode 100644 unit/test-asha-conn.h
 create mode 100644 unit/test-asha-interval.c
.gitignore +4 -0
index 06b24735df..3543bd815b 100644
@@ -99,6 +99,8 @@ unit/test-tester
 unit/test-mainloop
 unit/test-ringbuf
 unit/test-queue
+unit/test-asha-conn
+unit/test-asha-interval
 unit/test-util
 unit/test-eir
 unit/test-uuid
@@ -112,6 +114,8 @@ unit/test-lib
 unit/test-mgmt
 unit/test-uhid
 unit/test-hfp
+unit/test-asha-interval
+unit/test-asha-conn
 unit/test-crypto
 unit/test-ecc
 unit/test-hog
Makefile.am +17 -0
index f742458d11..9ba8b93625 100644
@@ -706,6 +706,23 @@ unit_test_avrcp_LDADD = lib/libbluetooth-internal.la \
 
 unit_tests += unit/test-hfp
 
+unit_tests += unit/test-asha-interval
+
+unit_test_asha_interval_SOURCES = unit/test-asha-interval.c
+unit_test_asha_interval_LDADD = src/libshared-glib.la \
+	lib/libbluetooth-internal.la $(GLIB_LIBS)
+
+unit_tests += unit/test-asha-conn
+
+unit_test_asha_conn_SOURCES = unit/test-asha-conn.c unit/test-asha-conn.h
+unit_test_asha_conn_CFLAGS = $(AM_CFLAGS) -DBLUETOOTH_PLUGIN_BUILTIN \
+	-ffunction-sections -fdata-sections
+unit_test_asha_conn_LDADD = src/libshared-glib.la \
+	lib/libbluetooth-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
+unit_test_asha_conn_LDFLAGS = -Wl,--gc-sections \
+	-Wl,--wrap=socket -Wl,--wrap=bind -Wl,--wrap=setsockopt \
+	-Wl,--wrap=getsockopt
+
 unit_test_hfp_SOURCES = unit/test-hfp.c
 unit_test_hfp_LDADD = src/libshared-glib.la $(GLIB_LIBS)
 
profiles/audio/asha.c +237 -0

279 lines not on this page · raw message

src/shared/asha.c +28 -0
index 79bb29bf9a..6d0323fb24 100644
@@ -244,6 +244,34 @@ static int asha_send_acp_without_response(struct bt_asha *asha,
 	return 0;
 }
 
+bool bt_asha_set_connection_interval(struct bt_asha *asha, uint16_t interval)
+{
+	struct bt_asha_set *set;
+	struct bt_asha *other = NULL;
+	uint8_t cmd[] = { 0x03, 0x02, 0x00 };
+	bool success;
+
+	/* The connection-update STATUS encodes 1.25 ms units in one byte. */
+	if (!asha || !asha->client || !asha->acp_handle ||
+				interval < 0x0006 || interval > UINT8_MAX)
+		return false;
+
+	cmd[2] = interval;
+	success = asha_send_acp_without_response(asha, cmd, sizeof(cmd)) == 0;
+	set = find_asha_set(asha);
+
+	if (set)
+		other = asha->right_side ? set->left : set->right;
+
+	/* Notify an attached peer even if it has not started streaming yet. */
+	if (other && other != asha && other->client && other->acp_handle) {
+		if (asha_send_acp_without_response(other, cmd, sizeof(cmd)) < 0)
+			success = false;
+	}
+
+	return success;
+}
+
 unsigned int bt_asha_start(struct bt_asha *asha, bt_asha_cb_t cb,
 								void *user_data)
 {
src/shared/asha.h +1 -0
index 9e62fcde89..e6b2e7a0d2 100644
@@ -66,6 +66,7 @@ unsigned int bt_asha_start(struct bt_asha *asha, bt_asha_cb_t cb,
 unsigned int bt_asha_stop(struct bt_asha *asha);
 
 bool bt_asha_set_volume(struct bt_asha *asha, int8_t volume);
+bool bt_asha_set_connection_interval(struct bt_asha *asha, uint16_t interval);
 
 bool bt_asha_attach(struct bt_asha *asha, struct gatt_db *db,
 		struct bt_gatt_client *client, bt_asha_attach_cb_t probe_cb,
unit/test-asha-conn.c new file +469 -0

469 lines not on this page · raw message

unit/test-asha-conn.h new file +11 -0
new file mode 100644
index 0000000000..5e88aed490
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <sys/socket.h>
+
+int __wrap_socket(int domain, int type, int protocol);
+int __wrap_bind(int fd, const struct sockaddr *addr, socklen_t length);
+int __wrap_setsockopt(int fd, int level, int opt, const void *value,
+							socklen_t length);
+int __wrap_getsockopt(int fd, int level, int opt, void *value,
+							socklen_t *length);
+int __real_setsockopt(int fd, int level, int opt, const void *value,
+							socklen_t length);
unit/test-asha-interval.c new file +104 -0

104 lines not on this page · raw message

base-commit: 9dc7e40962f11d1d9a5568f8a7633a695288329c

Signature · 1 line
2.56.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1195805/

---Test result---

Test Summary:

CheckPatch                    PASS      0.87 seconds
GitLint                       PASS      0.23 seconds
BuildEll                      PASS      16.24 seconds
BluezMake                     PASS      232.23 seconds
MakeCheck                     PASS      13.77 seconds
MakeDistcheck                 PASS      121.26 seconds
CheckValgrind                 PASS      191.06 seconds
CheckSmatch                   PASS      224.01 seconds
bluezmakeextell               PASS      76.37 seconds
TestFunctional                PASS      952.36 seconds
IncrementalBuild              PASS      234.42 seconds
ScanBuild                     PASS      829.04 seconds

https://github.com/bluez/bluez/pull/2733

---
Regards,
Linux Bluetooth

#2 lore raw

RFC PATCH v3 1/1 asha: Notify connection interval changes

In reply to Kyle Pepper

Omitting the connection-update STATUS notification causes repeated N8 supervision timeouts even with a negotiated 20 ms interval. Restoring the notification alone prevents the reported link failures.

Observe successful LE connection and update events per adapter, associate them with the ATT socket's handle, and announce the observed interval before START and on subsequent successful updates. Clear the observation on disconnect so a reused handle cannot inherit another link's interval. Notify the attached HiSyncId peer as well, matching Android's connection-update STATUS handling, without truncating the interval byte.

Reuse the verified socket handle when delivering a live update.

Add tests for event delivery, controller isolation, disconnect/reuse, pre-START ordering, failed updates and peer notification. Use source-level mocks so the tests remain valid with link-time optimization enabled.

Fixes c26389c466a0 ("profiles/audio: Add an ASHA plugin")
Assisted-by OpenCode:gpt-6.1-sol
Assisted-by Codex:gpt-6

---
Small cleanup.

Previous version:
https://lore.kernel.org/r/[email protected]

 .gitignore                |   2 +
 Makefile.am               |  17 ++
 profiles/audio/asha.c     | 237 +++++++++++++++++++
 src/shared/asha.c         |  28 +++
 src/shared/asha.h         |   1 +
 unit/test-asha-conn.c     | 469 ++++++++++++++++++++++++++++++++++++++
 unit/test-asha-conn.h     |  11 +
 unit/test-asha-interval.c | 104 +++++++++
 8 files changed, 869 insertions(+)
 create mode 100644 unit/test-asha-conn.c
 create mode 100644 unit/test-asha-conn.h
 create mode 100644 unit/test-asha-interval.c
.gitignore +2 -0
index 06b24735df..21b3bbe351 100644
@@ -99,6 +99,8 @@ unit/test-tester
 unit/test-mainloop
 unit/test-ringbuf
 unit/test-queue
+unit/test-asha-conn
+unit/test-asha-interval
 unit/test-util
 unit/test-eir
 unit/test-uuid
Makefile.am +17 -0
index 37302ed475..c7cb6eaf26 100644
@@ -709,6 +709,23 @@ unit_test_avrcp_LDADD = lib/libbluetooth-internal.la \
 
 unit_tests += unit/test-hfp
 
+unit_tests += unit/test-asha-interval
+
+unit_test_asha_interval_SOURCES = unit/test-asha-interval.c
+unit_test_asha_interval_LDADD = src/libshared-glib.la \
+	lib/libbluetooth-internal.la $(GLIB_LIBS)
+
+unit_tests += unit/test-asha-conn
+
+unit_test_asha_conn_SOURCES = unit/test-asha-conn.c unit/test-asha-conn.h
+unit_test_asha_conn_CFLAGS = $(AM_CFLAGS) -DBLUETOOTH_PLUGIN_BUILTIN \
+	-ffunction-sections -fdata-sections
+unit_test_asha_conn_LDADD = src/libshared-glib.la \
+	lib/libbluetooth-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
+unit_test_asha_conn_LDFLAGS = -Wl,--gc-sections \
+	-Wl,--wrap=socket -Wl,--wrap=bind -Wl,--wrap=setsockopt \
+	-Wl,--wrap=getsockopt
+
 unit_test_hfp_SOURCES = unit/test-hfp.c
 unit_test_hfp_LDADD = src/libshared-glib.la $(GLIB_LIBS)
 
profiles/audio/asha.c +237 -0

279 lines not on this page · raw message

src/shared/asha.c +28 -0
index 79bb29bf9a..6d0323fb24 100644
@@ -244,6 +244,34 @@ static int asha_send_acp_without_response(struct bt_asha *asha,
 	return 0;
 }
 
+bool bt_asha_set_connection_interval(struct bt_asha *asha, uint16_t interval)
+{
+	struct bt_asha_set *set;
+	struct bt_asha *other = NULL;
+	uint8_t cmd[] = { 0x03, 0x02, 0x00 };
+	bool success;
+
+	/* The connection-update STATUS encodes 1.25 ms units in one byte. */
+	if (!asha || !asha->client || !asha->acp_handle ||
+				interval < 0x0006 || interval > UINT8_MAX)
+		return false;
+
+	cmd[2] = interval;
+	success = asha_send_acp_without_response(asha, cmd, sizeof(cmd)) == 0;
+	set = find_asha_set(asha);
+
+	if (set)
+		other = asha->right_side ? set->left : set->right;
+
+	/* Notify an attached peer even if it has not started streaming yet. */
+	if (other && other != asha && other->client && other->acp_handle) {
+		if (asha_send_acp_without_response(other, cmd, sizeof(cmd)) < 0)
+			success = false;
+	}
+
+	return success;
+}
+
 unsigned int bt_asha_start(struct bt_asha *asha, bt_asha_cb_t cb,
 								void *user_data)
 {
src/shared/asha.h +1 -0
index 9e62fcde89..e6b2e7a0d2 100644
@@ -66,6 +66,7 @@ unsigned int bt_asha_start(struct bt_asha *asha, bt_asha_cb_t cb,
 unsigned int bt_asha_stop(struct bt_asha *asha);
 
 bool bt_asha_set_volume(struct bt_asha *asha, int8_t volume);
+bool bt_asha_set_connection_interval(struct bt_asha *asha, uint16_t interval);
 
 bool bt_asha_attach(struct bt_asha *asha, struct gatt_db *db,
 		struct bt_gatt_client *client, bt_asha_attach_cb_t probe_cb,
unit/test-asha-conn.c new file +469 -0

469 lines not on this page · raw message

unit/test-asha-conn.h new file +11 -0
new file mode 100644
index 0000000000..5e88aed490
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <sys/socket.h>
+
+int __wrap_socket(int domain, int type, int protocol);
+int __wrap_bind(int fd, const struct sockaddr *addr, socklen_t length);
+int __wrap_setsockopt(int fd, int level, int opt, const void *value,
+							socklen_t length);
+int __wrap_getsockopt(int fd, int level, int opt, void *value,
+							socklen_t *length);
+int __real_setsockopt(int fd, int level, int opt, const void *value,
+							socklen_t length);
unit/test-asha-interval.c new file +104 -0

104 lines not on this page · raw message

base-commit: 34b6f8e0e998728ce9e8e64e280d9d390c511804

Signature · 1 line
2.56.0
#3 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1204623/

---Test result---

Test Summary:

CheckPatch                    PASS      1.23 seconds
GitLint                       PASS      0.35 seconds
BuildEll                      PASS      20.73 seconds
BluezMake                     PASS      313.38 seconds
MakeCheck                     PASS      14.75 seconds
MakeDistcheck                 PASS      148.35 seconds
CheckValgrind                 PASS      346.96 seconds
CheckSmatch                   PASS      303.05 seconds
bluezmakeextell               PASS      99.18 seconds
TestFunctional                PASS      1177.42 seconds
IncrementalBuild              PASS      306.77 seconds
ScanBuild                     PASS      1157.23 seconds

https://github.com/bluez/bluez/pull/2773

---
Regards,
Linux Bluetooth