Skip to content

Commit e8db417

Browse files
ChangNicehenrikbrixandersen
authored andcommitted
LE Audio: add conn parameter for bt_vcp_vol_rend_cb
Add conn parameter to status/flags callbacks of bt_vcp_vol_rend_cb to differentiate between remote and local changes. Signed-off-by: Chang An <[email protected]>
1 parent 44c070f commit e8db417

File tree

9 files changed

+28
-20
lines changed

9 files changed

+28
-20
lines changed

doc/releases/migration-guide-4.0.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ Bluetooth Mesh
150150
Bluetooth Audio
151151
===============
152152

153+
* The Volume Renderer callback functions :code:`bt_vcp_vol_rend_cb.state` and
154+
:code:`bt_vcp_vol_rend_cb.flags` for VCP now contain an additional parameter for
155+
the connection.
156+
This needs to be added to all instances of VCP Volume Renderer callback functions defined.
157+
(:github:`76992`)
158+
153159
Bluetooth Classic
154160
=================
155161

include/zephyr/bluetooth/audio/vcp.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ struct bt_vcp_vol_rend_cb {
163163
* bt_vcp_vol_rend_get_state(), or if the state is changed by either
164164
* the Volume Renderer or a remote Volume Controller.
165165
*
166+
* @param conn Pointer to the connection to a remote device if
167+
* the change was caused by it, otherwise NULL.
166168
* @param err Error value. 0 on success, GATT error on positive value
167169
* or errno on negative value.
168170
* @param volume The volume of the Volume Control Service server.
169171
* @param mute The mute setting of the Volume Control Service server.
170172
*/
171-
void (*state)(int err, uint8_t volume, uint8_t mute);
173+
void (*state)(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute);
172174

173175
/**
174176
* @brief Callback function for Volume Control Service flags.
@@ -177,11 +179,13 @@ struct bt_vcp_vol_rend_cb {
177179
* Called when the value is remotely read as the client.
178180
* Called if the value is changed by either the server or client.
179181
*
182+
* @param conn Pointer to the connection to a remote device if
183+
* the change was caused by it, otherwise NULL.
180184
* @param err Error value. 0 on success, GATT error on positive value
181185
* or errno on negative value.
182186
* @param flags The flags of the Volume Control Service server.
183187
*/
184-
void (*flags)(int err, uint8_t flags);
188+
void (*flags)(struct bt_conn *conn, int err, uint8_t flags);
185189
};
186190

187191
/**

samples/bluetooth/hap_ha/src/vcp_vol_renderer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
static struct bt_vcp_included vcp_included;
2020

21-
static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
21+
static void vcs_state_cb(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute)
2222
{
2323
if (err) {
2424
printk("VCS state get failed (%d)\n", err);
@@ -27,7 +27,7 @@ static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
2727
}
2828
}
2929

30-
static void vcs_flags_cb(int err, uint8_t flags)
30+
static void vcs_flags_cb(struct bt_conn *conn, int err, uint8_t flags)
3131
{
3232
if (err) {
3333
printk("VCS flags get failed (%d)\n", err);

samples/bluetooth/tmap_bmr/src/vcp_vol_renderer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
static struct bt_vcp_included vcp_included;
2121

22-
static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
22+
static void vcs_state_cb(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute)
2323
{
2424
if (err) {
2525
printk("VCS state get failed (%d)\n", err);
@@ -28,7 +28,7 @@ static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
2828
}
2929
}
3030

31-
static void vcs_flags_cb(int err, uint8_t flags)
31+
static void vcs_flags_cb(struct bt_conn *conn, int err, uint8_t flags)
3232
{
3333
if (err) {
3434
printk("VCS flags get failed (%d)\n", err);

samples/bluetooth/tmap_peripheral/src/vcp_vol_renderer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
static struct bt_vcp_included vcp_included;
2121

22-
static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
22+
static void vcs_state_cb(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute)
2323
{
2424
if (err) {
2525
printk("VCS state get failed (%d)\n", err);
@@ -28,7 +28,7 @@ static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
2828
}
2929
}
3030

31-
static void vcs_flags_cb(int err, uint8_t flags)
31+
static void vcs_flags_cb(struct bt_conn *conn, int err, uint8_t flags)
3232
{
3333
if (err) {
3434
printk("VCS flags get failed (%d)\n", err);

subsys/bluetooth/audio/shell/vcp_vol_rend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
static struct bt_vcp_included vcp_included;
3030

31-
static void vcp_vol_rend_state_cb(int err, uint8_t volume, uint8_t mute)
31+
static void vcp_vol_rend_state_cb(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute)
3232
{
3333
if (err) {
3434
shell_error(ctx_shell, "VCP state get failed (%d)", err);
@@ -37,7 +37,7 @@ static void vcp_vol_rend_state_cb(int err, uint8_t volume, uint8_t mute)
3737
}
3838
}
3939

40-
static void vcp_vol_rend_flags_cb(int err, uint8_t flags)
40+
static void vcp_vol_rend_flags_cb(struct bt_conn *conn, int err, uint8_t flags)
4141
{
4242
if (err) {
4343
shell_error(ctx_shell, "VCP flags get failed (%d)", err);

subsys/bluetooth/audio/vcp_vol_rend.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn,
269269
value_changed(&vol_rend, NOTIFY_STATE);
270270

271271
if (vol_rend.cb && vol_rend.cb->state) {
272-
vol_rend.cb->state(0, vol_rend.state.volume,
273-
vol_rend.state.mute);
272+
vol_rend.cb->state(conn, 0, vol_rend.state.volume, vol_rend.state.mute);
274273
}
275274
}
276275

@@ -282,7 +281,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn,
282281
}
283282

284283
if (vol_rend.cb && vol_rend.cb->flags) {
285-
vol_rend.cb->flags(0, vol_rend.flags);
284+
vol_rend.cb->flags(conn, 0, vol_rend.flags);
286285
}
287286
}
288287
return len;
@@ -524,8 +523,7 @@ int bt_vcp_vol_rend_set_step(uint8_t volume_step)
524523
int bt_vcp_vol_rend_get_state(void)
525524
{
526525
if (vol_rend.cb && vol_rend.cb->state) {
527-
vol_rend.cb->state(0, vol_rend.state.volume,
528-
vol_rend.state.mute);
526+
vol_rend.cb->state(NULL, 0, vol_rend.state.volume, vol_rend.state.mute);
529527
}
530528

531529
return 0;
@@ -534,7 +532,7 @@ int bt_vcp_vol_rend_get_state(void)
534532
int bt_vcp_vol_rend_get_flags(void)
535533
{
536534
if (vol_rend.cb && vol_rend.cb->flags) {
537-
vol_rend.cb->flags(0, vol_rend.flags);
535+
vol_rend.cb->flags(NULL, 0, vol_rend.flags);
538536
}
539537

540538
return 0;

tests/bluetooth/tester/src/audio/btp_vcp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ static uint8_t unmute(const void *cmd, uint16_t cmd_len,
144144
return BTP_STATUS_SUCCESS;
145145
}
146146

147-
static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
147+
static void vcs_state_cb(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute)
148148
{
149149
LOG_DBG("VCP state cb err (%d)", err);
150150
}
151151

152-
static void vcs_flags_cb(int err, uint8_t flags)
152+
static void vcs_flags_cb(struct bt_conn *conn, int err, uint8_t flags)
153153
{
154154
LOG_DBG("VCP flags cb err (%d)", err);
155155
}

tests/bsim/bluetooth/audio/src/vcp_vol_rend_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static volatile bool g_aics_active = 1;
5454
static char g_aics_desc[AICS_DESC_SIZE];
5555
static volatile bool g_cb;
5656

57-
static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
57+
static void vcs_state_cb(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute)
5858
{
5959
if (err != 0) {
6060
FAIL("VCP state cb err (%d)", err);
@@ -66,7 +66,7 @@ static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
6666
g_cb = true;
6767
}
6868

69-
static void vcs_flags_cb(int err, uint8_t flags)
69+
static void vcs_flags_cb(struct bt_conn *conn, int err, uint8_t flags)
7070
{
7171
if (err != 0) {
7272
FAIL("VCP flags cb err (%d)", err);

0 commit comments

Comments
 (0)