diff mbox series

[BlueZ,07/14] shared/bass: Add API to set PA sync state

Message ID 20240821145602.92083-8-iulia.tanasescu@nxp.com (mailing list archive)
State Superseded
Headers show
Series Add Scan Delegator support for Add Source op | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS

Commit Message

Iulia Tanasescu Aug. 21, 2024, 2:55 p.m. UTC
This adds a shared/bass API to set the PA sync state field inside
a Broadcast Receive State characteristic. Notifications are then
sent, to inform all peers about the update.
---
 src/shared/bass.c | 34 ++++++++++++++++++++++++++++++++++
 src/shared/bass.h |  1 +
 2 files changed, 35 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/bass.c b/src/shared/bass.c
index 70e747700..958b6f788 100644
--- a/src/shared/bass.c
+++ b/src/shared/bass.c
@@ -1732,3 +1732,37 @@  done:
 
 	return err;
 }
+
+static void bt_bass_notify_all(struct gatt_db_attribute *attr,
+						struct iovec *iov)
+{
+	const struct queue_entry *entry;
+
+	for (entry = queue_get_entries(sessions); entry; entry = entry->next) {
+		struct bt_bass *bass = entry->data;
+
+		gatt_db_attribute_notify(attr, iov->iov_base,
+			iov->iov_len, bt_bass_get_att(bass));
+	}
+}
+
+int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state)
+{
+	struct iovec *iov;
+
+	if (!bcast_src)
+		return -EINVAL;
+
+	bcast_src->sync_state = sync_state;
+
+	iov = bass_parse_bcast_src(bcast_src);
+	if (!iov)
+		return -ENOMEM;
+
+	bt_bass_notify_all(bcast_src->attr, iov);
+
+	free(iov->iov_base);
+	free(iov);
+
+	return 0;
+}
diff --git a/src/shared/bass.h b/src/shared/bass.h
index 2ca659cca..a82d8f573 100644
--- a/src/shared/bass.h
+++ b/src/shared/bass.h
@@ -129,3 +129,4 @@  unsigned int bt_bass_cp_handler_register(struct bt_bass *bass,
 				void *user_data);
 bool bt_bass_cp_handler_unregister(struct bt_bass *bass,
 				unsigned int id);
+int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state);