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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 --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);
-- 
2.39.2





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux