Bluetooth: Audio: Remove bt_vcp from vol rend API
Remove the struct bt_vcp pointer from the volume renderer API, as there is only ever a single Volume Renderer instance on a device. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
c82af2885e
commit
ae11b5879b
5 changed files with 76 additions and 161 deletions
|
@ -94,13 +94,11 @@ struct bt_vcp_included {
|
|||
* Volume Offset Control Service (Volume Offset Control Service) or
|
||||
* Audio Input Control Service (AICS) instances.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
* @param[out] included Pointer to store the result in.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_included_get(struct bt_vcp *vcp,
|
||||
struct bt_vcp_included *included);
|
||||
int bt_vcp_vol_rend_included_get(struct bt_vcp_included *included);
|
||||
|
||||
/**
|
||||
* @brief Register the Volume Control Service.
|
||||
|
@ -109,13 +107,10 @@ int bt_vcp_vol_rend_included_get(struct bt_vcp *vcp,
|
|||
* clients.
|
||||
*
|
||||
* @param param Volume Control Service register parameters.
|
||||
* @param[out] vcp Pointer to the registered Volume Control Service.
|
||||
* This will still be valid if the return value is -EALREADY.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_register(struct bt_vcp_vol_rend_register_param *param,
|
||||
struct bt_vcp **vcp);
|
||||
int bt_vcp_vol_rend_register(struct bt_vcp_vol_rend_register_param *param);
|
||||
|
||||
struct bt_vcp_vol_rend_cb {
|
||||
/**
|
||||
|
@ -125,14 +120,12 @@ struct bt_vcp_vol_rend_cb {
|
|||
* bt_vcp_vol_rend_get_state(), or if the state is changed by either
|
||||
* the Volume Renderer or a remote Volume Controller.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
* @param err Error value. 0 on success, GATT error on positive value
|
||||
* or errno on negative value.
|
||||
* @param volume The volume of the Volume Control Service server.
|
||||
* @param mute The mute setting of the Volume Control Service server.
|
||||
*/
|
||||
void (*state)(struct bt_vcp *vcp, int err, uint8_t volume,
|
||||
uint8_t mute);
|
||||
void (*state)(int err, uint8_t volume, uint8_t mute);
|
||||
|
||||
/**
|
||||
* @brief Callback function for Volume Control Service flags.
|
||||
|
@ -141,12 +134,11 @@ struct bt_vcp_vol_rend_cb {
|
|||
* Called when the value is remotely read as the client.
|
||||
* Called if the value is changed by either the server or client.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
* @param err Error value. 0 on success, GATT error on positive value
|
||||
* or errno on negative value.
|
||||
* @param flags The flags of the Volume Control Service server.
|
||||
*/
|
||||
void (*flags)(struct bt_vcp *vcp, int err, uint8_t flags);
|
||||
void (*flags)(int err, uint8_t flags);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -166,84 +158,67 @@ int bt_vcp_vol_rend_set_step(uint8_t volume_step);
|
|||
/**
|
||||
* @brief Get the Volume Control Service volume state.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_get_state(struct bt_vcp *vcp);
|
||||
int bt_vcp_vol_rend_get_state(void);
|
||||
|
||||
/**
|
||||
* @brief Get the Volume Control Service flags.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_get_flags(struct bt_vcp *vcp);
|
||||
int bt_vcp_vol_rend_get_flags(void);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume down by one step on the server.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_vol_down(struct bt_vcp *vcp);
|
||||
int bt_vcp_vol_rend_vol_down(void);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume up by one step on the server.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_vol_up(struct bt_vcp *vcp);
|
||||
int bt_vcp_vol_rend_vol_up(void);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume down and unmute the server.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_unmute_vol_down(struct bt_vcp *vcp);
|
||||
int bt_vcp_vol_rend_unmute_vol_down(void);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume up and unmute the server.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_unmute_vol_up(struct bt_vcp *vcp);
|
||||
int bt_vcp_vol_rend_unmute_vol_up(void);
|
||||
|
||||
/**
|
||||
* @brief Set the volume on the server
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
* @param volume The absolute volume to set.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_set_vol(struct bt_vcp *vcp, uint8_t volume);
|
||||
int bt_vcp_vol_rend_set_vol(uint8_t volume);
|
||||
|
||||
/**
|
||||
* @brief Unmute the server.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_unmute(struct bt_vcp *vcp);
|
||||
int bt_vcp_vol_rend_unmute(void);
|
||||
|
||||
/**
|
||||
* @brief Mute the server.
|
||||
*
|
||||
* @param vcp Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_rend_mute(struct bt_vcp *vcp);
|
||||
int bt_vcp_vol_rend_mute(void);
|
||||
|
||||
struct bt_vcp_vol_ctlr_cb {
|
||||
/**
|
||||
|
|
|
@ -16,10 +16,9 @@
|
|||
#include <zephyr/bluetooth/conn.h>
|
||||
#include <zephyr/bluetooth/audio/vcp.h>
|
||||
|
||||
static struct bt_vcp *vcp;
|
||||
static struct bt_vcp_included vcp_included;
|
||||
|
||||
static void vcs_state_cb(struct bt_vcp *vcp, int err, uint8_t volume, uint8_t mute)
|
||||
static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
|
||||
{
|
||||
if (err) {
|
||||
printk("VCS state get failed (%d)\n", err);
|
||||
|
@ -28,7 +27,7 @@ static void vcs_state_cb(struct bt_vcp *vcp, int err, uint8_t volume, uint8_t mu
|
|||
}
|
||||
}
|
||||
|
||||
static void vcs_flags_cb(struct bt_vcp *vcp, int err, uint8_t flags)
|
||||
static void vcs_flags_cb(int err, uint8_t flags)
|
||||
{
|
||||
if (err) {
|
||||
printk("VCS flags get failed (%d)\n", err);
|
||||
|
@ -165,12 +164,12 @@ int vcp_vol_renderer_init(void)
|
|||
vcp_register_param.volume = 100;
|
||||
vcp_register_param.cb = &vcp_cbs;
|
||||
|
||||
err = bt_vcp_vol_rend_register(&vcp_register_param, &vcp);
|
||||
err = bt_vcp_vol_rend_register(&vcp_register_param);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = bt_vcp_vol_rend_included_get(vcp, &vcp_included);
|
||||
err = bt_vcp_vol_rend_included_get(&vcp_included);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -173,8 +173,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn,
|
|||
&vcp_inst.srv.state, sizeof(vcp_inst.srv.state));
|
||||
|
||||
if (vcp_inst.srv.cb && vcp_inst.srv.cb->state) {
|
||||
vcp_inst.srv.cb->state(&vcp_inst, 0,
|
||||
vcp_inst.srv.state.volume,
|
||||
vcp_inst.srv.cb->state(0, vcp_inst.srv.state.volume,
|
||||
vcp_inst.srv.state.mute);
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +186,7 @@ static ssize_t write_vcs_control(struct bt_conn *conn,
|
|||
&vcp_inst.srv.flags, sizeof(vcp_inst.srv.flags));
|
||||
|
||||
if (vcp_inst.srv.cb && vcp_inst.srv.cb->flags) {
|
||||
vcp_inst.srv.cb->flags(&vcp_inst, 0, vcp_inst.srv.flags);
|
||||
vcp_inst.srv.cb->flags(0, vcp_inst.srv.flags);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
|
@ -320,8 +319,7 @@ static int prepare_aics_inst(struct bt_vcp_vol_rend_register_param *param)
|
|||
}
|
||||
|
||||
/****************************** PUBLIC API ******************************/
|
||||
int bt_vcp_vol_rend_register(struct bt_vcp_vol_rend_register_param *param,
|
||||
struct bt_vcp **vcp)
|
||||
int bt_vcp_vol_rend_register(struct bt_vcp_vol_rend_register_param *param)
|
||||
{
|
||||
static bool registered;
|
||||
int err;
|
||||
|
@ -342,7 +340,6 @@ int bt_vcp_vol_rend_register(struct bt_vcp_vol_rend_register_param *param,
|
|||
}
|
||||
|
||||
if (registered) {
|
||||
*vcp = &vcp_inst;
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
|
@ -377,28 +374,22 @@ int bt_vcp_vol_rend_register(struct bt_vcp_vol_rend_register_param *param,
|
|||
|
||||
vcp_inst.srv.cb = param->cb;
|
||||
|
||||
*vcp = &vcp_inst;
|
||||
registered = true;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_included_get(struct bt_vcp *vcp, struct bt_vcp_included *included)
|
||||
int bt_vcp_vol_rend_included_get(struct bt_vcp_included *included)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (included == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
included->vocs_cnt = ARRAY_SIZE(vcp->srv.vocs_insts);
|
||||
included->vocs = vcp->srv.vocs_insts;
|
||||
included->vocs_cnt = ARRAY_SIZE(vcp_inst.srv.vocs_insts);
|
||||
included->vocs = vcp_inst.srv.vocs_insts;
|
||||
|
||||
included->aics_cnt = ARRAY_SIZE(vcp->srv.aics_insts);
|
||||
included->aics = vcp->srv.aics_insts;
|
||||
included->aics_cnt = ARRAY_SIZE(vcp_inst.srv.aics_insts);
|
||||
included->aics = vcp_inst.srv.aics_insts;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -413,160 +404,114 @@ int bt_vcp_vol_rend_set_step(uint8_t volume_step)
|
|||
}
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_get_state(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_rend_get_state(void)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (vcp->srv.cb && vcp->srv.cb->state) {
|
||||
vcp->srv.cb->state(vcp, 0, vcp->srv.state.volume,
|
||||
vcp->srv.state.mute);
|
||||
if (vcp_inst.srv.cb && vcp_inst.srv.cb->state) {
|
||||
vcp_inst.srv.cb->state(0, vcp_inst.srv.state.volume,
|
||||
vcp_inst.srv.state.mute);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_get_flags(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_rend_get_flags(void)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (vcp->srv.cb && vcp->srv.cb->flags) {
|
||||
vcp->srv.cb->flags(vcp, 0, vcp->srv.flags);
|
||||
if (vcp_inst.srv.cb && vcp_inst.srv.cb->flags) {
|
||||
vcp_inst.srv.cb->flags(0, vcp_inst.srv.flags);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_vol_down(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_rend_vol_down(void)
|
||||
{
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_REL_VOL_DOWN,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
.counter = vcp_inst.srv.state.change_counter,
|
||||
};
|
||||
int err;
|
||||
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_vol_up(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_rend_vol_up(void)
|
||||
{
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_REL_VOL_UP,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
.counter = vcp_inst.srv.state.change_counter,
|
||||
};
|
||||
int err;
|
||||
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_unmute_vol_down(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_rend_unmute_vol_down(void)
|
||||
{
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_UNMUTE_REL_VOL_DOWN,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
.counter = vcp_inst.srv.state.change_counter,
|
||||
};
|
||||
int err;
|
||||
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_unmute_vol_up(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_rend_unmute_vol_up(void)
|
||||
{
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_UNMUTE_REL_VOL_UP,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
.counter = vcp_inst.srv.state.change_counter,
|
||||
};
|
||||
int err;
|
||||
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_set_vol(struct bt_vcp *vcp, uint8_t volume)
|
||||
int bt_vcp_vol_rend_set_vol(uint8_t volume)
|
||||
{
|
||||
|
||||
const struct vcs_control_vol cp = {
|
||||
.cp = {
|
||||
.opcode = BT_VCP_OPCODE_SET_ABS_VOL,
|
||||
.counter = vcp->srv.state.change_counter
|
||||
.counter = vcp_inst.srv.state.change_counter
|
||||
},
|
||||
.volume = volume
|
||||
};
|
||||
int err;
|
||||
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_unmute(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_rend_unmute(void)
|
||||
{
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_UNMUTE,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
.counter = vcp_inst.srv.state.change_counter,
|
||||
};
|
||||
int err;
|
||||
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_rend_mute(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_rend_mute(void)
|
||||
{
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_MUTE,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
.counter = vcp_inst.srv.state.change_counter,
|
||||
};
|
||||
int err;
|
||||
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
|
|
|
@ -17,11 +17,9 @@
|
|||
|
||||
#include "bt.h"
|
||||
|
||||
static struct bt_vcp *vcp;
|
||||
static struct bt_vcp_included vcp_included;
|
||||
|
||||
static void vcp_vol_rend_state_cb(struct bt_vcp *vcp, int err, uint8_t volume,
|
||||
uint8_t mute)
|
||||
static void vcp_vol_rend_state_cb(int err, uint8_t volume, uint8_t mute)
|
||||
{
|
||||
if (err) {
|
||||
shell_error(ctx_shell, "VCP state get failed (%d)", err);
|
||||
|
@ -30,7 +28,7 @@ static void vcp_vol_rend_state_cb(struct bt_vcp *vcp, int err, uint8_t volume,
|
|||
}
|
||||
}
|
||||
|
||||
static void vcp_vol_rend_flags_cb(struct bt_vcp *vcp, int err, uint8_t flags)
|
||||
static void vcp_vol_rend_flags_cb(int err, uint8_t flags)
|
||||
{
|
||||
if (err) {
|
||||
shell_error(ctx_shell, "VCP flags get failed (%d)", err);
|
||||
|
@ -229,13 +227,13 @@ static int cmd_vcp_vol_rend_init(const struct shell *sh, size_t argc,
|
|||
|
||||
vcp_register_param.cb = &vcp_vol_rend_cbs;
|
||||
|
||||
result = bt_vcp_vol_rend_register(&vcp_register_param, &vcp);
|
||||
result = bt_vcp_vol_rend_register(&vcp_register_param);
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = bt_vcp_vol_rend_included_get(vcp, &vcp_included);
|
||||
result = bt_vcp_vol_rend_included_get(&vcp_included);
|
||||
if (result != 0) {
|
||||
shell_error(sh, "Failed to get included services: %d", result);
|
||||
return result;
|
||||
|
@ -267,7 +265,7 @@ static int cmd_vcp_vol_rend_volume_step(const struct shell *sh, size_t argc,
|
|||
static int cmd_vcp_vol_rend_state_get(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result = bt_vcp_vol_rend_get_state(vcp);
|
||||
int result = bt_vcp_vol_rend_get_state();
|
||||
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
|
@ -279,7 +277,7 @@ static int cmd_vcp_vol_rend_state_get(const struct shell *sh, size_t argc,
|
|||
static int cmd_vcp_vol_rend_flags_get(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result = bt_vcp_vol_rend_get_flags(vcp);
|
||||
int result = bt_vcp_vol_rend_get_flags();
|
||||
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
|
@ -291,7 +289,7 @@ static int cmd_vcp_vol_rend_flags_get(const struct shell *sh, size_t argc,
|
|||
static int cmd_vcp_vol_rend_volume_down(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result = bt_vcp_vol_rend_vol_down(vcp);
|
||||
int result = bt_vcp_vol_rend_vol_down();
|
||||
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
|
@ -304,7 +302,7 @@ static int cmd_vcp_vol_rend_volume_up(const struct shell *sh, size_t argc,
|
|||
char **argv)
|
||||
|
||||
{
|
||||
int result = bt_vcp_vol_rend_vol_up(vcp);
|
||||
int result = bt_vcp_vol_rend_vol_up();
|
||||
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
|
@ -316,7 +314,7 @@ static int cmd_vcp_vol_rend_volume_up(const struct shell *sh, size_t argc,
|
|||
static int cmd_vcp_vol_rend_unmute_volume_down(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result = bt_vcp_vol_rend_unmute_vol_down(vcp);
|
||||
int result = bt_vcp_vol_rend_unmute_vol_down();
|
||||
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
|
@ -328,7 +326,7 @@ static int cmd_vcp_vol_rend_unmute_volume_down(const struct shell *sh,
|
|||
static int cmd_vcp_vol_rend_unmute_volume_up(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result = bt_vcp_vol_rend_unmute_vol_up(vcp);
|
||||
int result = bt_vcp_vol_rend_unmute_vol_up();
|
||||
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
|
@ -349,7 +347,7 @@ static int cmd_vcp_vol_rend_volume_set(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_vol_rend_set_vol(vcp, volume);
|
||||
result = bt_vcp_vol_rend_set_vol(volume);
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -360,7 +358,7 @@ static int cmd_vcp_vol_rend_volume_set(const struct shell *sh, size_t argc,
|
|||
static int cmd_vcp_vol_rend_unmute(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result = bt_vcp_vol_rend_unmute(vcp);
|
||||
int result = bt_vcp_vol_rend_unmute();
|
||||
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
|
@ -372,7 +370,7 @@ static int cmd_vcp_vol_rend_unmute(const struct shell *sh, size_t argc,
|
|||
static int cmd_vcp_vol_rend_mute(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result = bt_vcp_vol_rend_mute(vcp);
|
||||
int result = bt_vcp_vol_rend_mute();
|
||||
|
||||
if (result) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
|
|
|
@ -23,7 +23,6 @@ extern enum bst_result_t bst_result;
|
|||
#define AICS_DESC_SIZE 0
|
||||
#endif /* CONFIG_BT_AICS */
|
||||
|
||||
static struct bt_vcp *vcp;
|
||||
static struct bt_vcp_included vcp_included;
|
||||
|
||||
static volatile uint8_t g_volume;
|
||||
|
@ -44,8 +43,7 @@ static char g_aics_desc[AICS_DESC_SIZE];
|
|||
static volatile bool g_cb;
|
||||
static bool g_is_connected;
|
||||
|
||||
static void vcs_state_cb(struct bt_vcp *vcp, int err, uint8_t volume,
|
||||
uint8_t mute)
|
||||
static void vcs_state_cb(int err, uint8_t volume, uint8_t mute)
|
||||
{
|
||||
if (err) {
|
||||
FAIL("VCP state cb err (%d)", err);
|
||||
|
@ -57,7 +55,7 @@ static void vcs_state_cb(struct bt_vcp *vcp, int err, uint8_t volume,
|
|||
g_cb = true;
|
||||
}
|
||||
|
||||
static void vcs_flags_cb(struct bt_vcp *vcp, int err, uint8_t flags)
|
||||
static void vcs_flags_cb(int err, uint8_t flags)
|
||||
{
|
||||
if (err) {
|
||||
FAIL("VCP flags cb err (%d)", err);
|
||||
|
@ -479,13 +477,13 @@ static void test_standalone(void)
|
|||
vcp_register_param.volume = 100;
|
||||
vcp_register_param.cb = &vcs_cb;
|
||||
|
||||
err = bt_vcp_vol_rend_register(&vcp_register_param, &vcp);
|
||||
err = bt_vcp_vol_rend_register(&vcp_register_param);
|
||||
if (err) {
|
||||
FAIL("VCP register failed (err %d)\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
err = bt_vcp_vol_rend_included_get(vcp, &vcp_included);
|
||||
err = bt_vcp_vol_rend_included_get(&vcp_included);
|
||||
if (err) {
|
||||
FAIL("VCP included get failed (err %d)\n", err);
|
||||
return;
|
||||
|
@ -504,7 +502,7 @@ static void test_standalone(void)
|
|||
|
||||
printk("Getting VCP volume state\n");
|
||||
g_cb = false;
|
||||
err = bt_vcp_vol_rend_get_state(vcp);
|
||||
err = bt_vcp_vol_rend_get_state();
|
||||
if (err) {
|
||||
FAIL("Could not get VCP volume (err %d)\n", err);
|
||||
return;
|
||||
|
@ -514,7 +512,7 @@ static void test_standalone(void)
|
|||
|
||||
printk("Getting VCP flags\n");
|
||||
g_cb = false;
|
||||
err = bt_vcp_vol_rend_get_flags(vcp);
|
||||
err = bt_vcp_vol_rend_get_flags();
|
||||
if (err) {
|
||||
FAIL("Could not get VCP flags (err %d)\n", err);
|
||||
return;
|
||||
|
@ -524,7 +522,7 @@ static void test_standalone(void)
|
|||
|
||||
printk("Downing VCP volume\n");
|
||||
expected_volume = g_volume - volume_step;
|
||||
err = bt_vcp_vol_rend_vol_down(vcp);
|
||||
err = bt_vcp_vol_rend_vol_down();
|
||||
if (err) {
|
||||
FAIL("Could not get down VCP volume (err %d)\n", err);
|
||||
return;
|
||||
|
@ -534,7 +532,7 @@ static void test_standalone(void)
|
|||
|
||||
printk("Upping VCP volume\n");
|
||||
expected_volume = g_volume + volume_step;
|
||||
err = bt_vcp_vol_rend_vol_up(vcp);
|
||||
err = bt_vcp_vol_rend_vol_up();
|
||||
if (err) {
|
||||
FAIL("Could not up VCP volume (err %d)\n", err);
|
||||
return;
|
||||
|
@ -544,7 +542,7 @@ static void test_standalone(void)
|
|||
|
||||
printk("Muting VCP\n");
|
||||
expected_mute = 1;
|
||||
err = bt_vcp_vol_rend_mute(vcp);
|
||||
err = bt_vcp_vol_rend_mute();
|
||||
if (err) {
|
||||
FAIL("Could not mute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -555,7 +553,7 @@ static void test_standalone(void)
|
|||
printk("Downing and unmuting VCP\n");
|
||||
expected_volume = g_volume - volume_step;
|
||||
expected_mute = 0;
|
||||
err = bt_vcp_vol_rend_unmute_vol_down(vcp);
|
||||
err = bt_vcp_vol_rend_unmute_vol_down();
|
||||
if (err) {
|
||||
FAIL("Could not down and unmute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -566,7 +564,7 @@ static void test_standalone(void)
|
|||
|
||||
printk("Muting VCP\n");
|
||||
expected_mute = 1;
|
||||
err = bt_vcp_vol_rend_mute(vcp);
|
||||
err = bt_vcp_vol_rend_mute();
|
||||
if (err) {
|
||||
FAIL("Could not mute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -577,7 +575,7 @@ static void test_standalone(void)
|
|||
printk("Upping and unmuting VCP\n");
|
||||
expected_volume = g_volume + volume_step;
|
||||
expected_mute = 0;
|
||||
err = bt_vcp_vol_rend_unmute_vol_up(vcp);
|
||||
err = bt_vcp_vol_rend_unmute_vol_up();
|
||||
if (err) {
|
||||
FAIL("Could not up and unmute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -588,7 +586,7 @@ static void test_standalone(void)
|
|||
|
||||
printk("Muting VCP\n");
|
||||
expected_mute = 1;
|
||||
err = bt_vcp_vol_rend_mute(vcp);
|
||||
err = bt_vcp_vol_rend_mute();
|
||||
if (err) {
|
||||
FAIL("Could not mute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -598,7 +596,7 @@ static void test_standalone(void)
|
|||
|
||||
printk("Unmuting VCP\n");
|
||||
expected_mute = 0;
|
||||
err = bt_vcp_vol_rend_unmute(vcp);
|
||||
err = bt_vcp_vol_rend_unmute();
|
||||
if (err) {
|
||||
FAIL("Could not unmute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -607,7 +605,7 @@ static void test_standalone(void)
|
|||
printk("VCP volume unmuted\n");
|
||||
|
||||
expected_volume = g_volume - 5;
|
||||
err = bt_vcp_vol_rend_set_vol(vcp, expected_volume);
|
||||
err = bt_vcp_vol_rend_set_vol(expected_volume);
|
||||
if (err) {
|
||||
FAIL("Could not set VCP volume (err %d)\n", err);
|
||||
return;
|
||||
|
@ -675,13 +673,13 @@ static void test_main(void)
|
|||
vcp_register_param.volume = 100;
|
||||
vcp_register_param.cb = &vcs_cb;
|
||||
|
||||
err = bt_vcp_vol_rend_register(&vcp_register_param, &vcp);
|
||||
err = bt_vcp_vol_rend_register(&vcp_register_param);
|
||||
if (err) {
|
||||
FAIL("VCP register failed (err %d)\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
err = bt_vcp_vol_rend_included_get(vcp, &vcp_included);
|
||||
err = bt_vcp_vol_rend_included_get(&vcp_included);
|
||||
if (err) {
|
||||
FAIL("VCP included get failed (err %d)\n", err);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue