diff mbox series

[BlueZ,2/7] shared/bass: Add API to set BIG enc state

Message ID 20241008080126.48703-3-iulia.tanasescu@nxp.com (mailing list archive)
State Accepted
Commit f5c0fe68539fbfa7eefcc6088c5bbcc9f369a0e8
Headers show
Series Add Scan Delegator support for Set Broadcast Code 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
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Iulia Tanasescu Oct. 8, 2024, 8:01 a.m. UTC
This adds a shared/bass API to set the BIG encryption state field inside
a Broadcast Receive State characteristic. Notifications are then sent to
inform all peers about the update.
---
 src/shared/bass.c | 24 ++++++++++++++++++++++++
 src/shared/bass.h |  1 +
 2 files changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/bass.c b/src/shared/bass.c
index 76287cfbc..9ee13bf4a 100644
--- a/src/shared/bass.c
+++ b/src/shared/bass.c
@@ -1832,3 +1832,27 @@  bool bt_bass_check_bis(struct bt_bcast_src *bcast_src, uint8_t bis)
 
 	return false;
 }
+
+int bt_bass_set_enc(struct bt_bcast_src *bcast_src, uint8_t enc)
+{
+	struct iovec *iov;
+
+	if (!bcast_src)
+		return -EINVAL;
+
+	if (bcast_src->enc == enc)
+		return 0;
+
+	bcast_src->enc = enc;
+
+	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 b21256efd..d256b920d 100644
--- a/src/shared/bass.h
+++ b/src/shared/bass.h
@@ -133,3 +133,4 @@  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);
 bool bt_bass_check_bis(struct bt_bcast_src *bcast_src, uint8_t bis);
+int bt_bass_set_enc(struct bt_bcast_src *bcast_src, uint8_t enc);