shared/bass: Add APIs to set/clear BIS sync bits
authorIulia Tanasescu <iulia.tanasescu@nxp.com>
Thu, 29 Aug 2024 12:49:14 +0000 (15:49 +0300)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 20 Feb 2025 07:43:22 +0000 (16:43 +0900)
This adds shared/bass APIs to set/clear bits inside the BIS sync bitmask
of Broadcast Receive State characteristics. Notifications are sent to the
peers each time the characteristic is updated.

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

index 958b6f7883f9d6f263aec3249a77a38b441b2243..8f02086a1c780f837fbf0c87f221b981ebc3cedf 100644 (file)
@@ -1766,3 +1766,55 @@ int bt_bass_set_pa_sync(struct bt_bcast_src *bcast_src, uint8_t sync_state)
 
        return 0;
 }
+
+int bt_bass_set_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis)
+{
+       struct iovec *iov;
+
+       for (uint8_t i = 0; i < bcast_src->num_subgroups; i++) {
+               struct bt_bass_subgroup_data *sgrp =
+                               &bcast_src->subgroup_data[i];
+               uint32_t bitmask = 1 << (bis - 1);
+
+               if (sgrp->pending_bis_sync & bitmask) {
+                       sgrp->bis_sync |= bitmask;
+
+                       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;
+}
+
+int bt_bass_clear_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis)
+{
+       struct iovec *iov;
+
+       for (uint8_t i = 0; i < bcast_src->num_subgroups; i++) {
+               struct bt_bass_subgroup_data *sgrp =
+                               &bcast_src->subgroup_data[i];
+               uint32_t bitmask = 1 << (bis - 1);
+
+               if (sgrp->pending_bis_sync & bitmask) {
+                       sgrp->bis_sync &= ~bitmask;
+
+                       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 a82d8f573970f295e87616370f70d54f953d1376..f3f7082461e3357c73717ac429af3aa17c196539 100644 (file)
@@ -130,3 +130,5 @@ unsigned int bt_bass_cp_handler_register(struct bt_bass *bass,
 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);
+int bt_bass_set_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis);
+int bt_bass_clear_bis_sync(struct bt_bcast_src *bcast_src, uint8_t bis);