shared/bass: Add API to set PA sync state
authorIulia Tanasescu <iulia.tanasescu@nxp.com>
Thu, 29 Aug 2024 12:49:11 +0000 (15:49 +0300)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 20 Feb 2025 07:43:22 +0000 (16:43 +0900)
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.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
src/shared/bass.c
src/shared/bass.h

index 70e7477001cbebfdc370701da5567724f8bc73cc..958b6f7883f9d6f263aec3249a77a38b441b2243 100644 (file)
@@ -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;
+}
index 2ca659cca4157e62120350bc689c2ae6bbb85d91..a82d8f573970f295e87616370f70d54f953d1376 100644 (file)
@@ -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);