Bluetooth: Audio: Add separate API for VCP vol controller
Add a separate API for the VCP volume controller (client). Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
966c9f80e7
commit
71bd487cc4
14 changed files with 450 additions and 452 deletions
|
@ -116,20 +116,7 @@ int bt_vcp_register(struct bt_vcp_register_param *param, struct bt_vcp **vcp);
|
|||
int bt_vcp_included_get(struct bt_vcp *vcp, struct bt_vcp_included *included);
|
||||
|
||||
/**
|
||||
* @brief Get the connection pointer of a client instance
|
||||
*
|
||||
* Get the Bluetooth connection pointer of a Volume Control Service
|
||||
* client instance.
|
||||
*
|
||||
* @param vcp Volume Control Service client instance pointer.
|
||||
* @param[out] conn Connection pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_client_conn_get(const struct bt_vcp *vcp, struct bt_conn **conn);
|
||||
|
||||
/**
|
||||
* @brief Callback function for bt_vcp_discover.
|
||||
* @brief Callback function for bt_vcp_vol_ctlr_discover.
|
||||
*
|
||||
* This callback is only used for the client.
|
||||
*
|
||||
|
@ -141,7 +128,7 @@ int bt_vcp_client_conn_get(const struct bt_vcp *vcp, struct bt_conn **conn);
|
|||
* @param aics_count Number of Audio Input Control Service instances on
|
||||
* peer device.
|
||||
*/
|
||||
typedef void (*bt_vcp_discover_cb)(struct bt_vcp *vcp, int err,
|
||||
typedef void (*bt_vcp_vol_ctlr_discover_cb)(struct bt_vcp *vcp, int err,
|
||||
uint8_t vocs_count, uint8_t aics_count);
|
||||
|
||||
/**
|
||||
|
@ -188,8 +175,8 @@ struct bt_vcp_cb {
|
|||
/* Volume Control Service */
|
||||
bt_vcp_state_cb state;
|
||||
bt_vcp_flags_cb flags;
|
||||
#if defined(CONFIG_BT_VCP_CLIENT)
|
||||
bt_vcp_discover_cb discover;
|
||||
#if defined(CONFIG_BT_VCP_VOL_CTLR)
|
||||
bt_vcp_vol_ctlr_discover_cb discover;
|
||||
bt_vcp_write_cb vol_down;
|
||||
bt_vcp_write_cb vol_up;
|
||||
bt_vcp_write_cb mute;
|
||||
|
@ -203,26 +190,9 @@ struct bt_vcp_cb {
|
|||
|
||||
/* Audio Input Control Service */
|
||||
struct bt_aics_cb aics_cb;
|
||||
#endif /* CONFIG_BT_VCP_CLIENT */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Discover Volume Control Service and included services.
|
||||
*
|
||||
* This will start a GATT discovery and setup handles and subscriptions.
|
||||
* This shall be called once before any other actions can be
|
||||
* executed for the peer device, and the @ref bt_vcp_discover_cb callback
|
||||
* will notify when it is possible to start remote operations.
|
||||
*
|
||||
* This shall only be done as the client,
|
||||
*
|
||||
* @param conn The connection to discover Volume Control Service for.
|
||||
* @param[out] vcp Valid remote instance object on success.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_discover(struct bt_conn *conn, struct bt_vcp **vcp);
|
||||
|
||||
/**
|
||||
* @brief Set the Volume Control Service volume step size.
|
||||
*
|
||||
|
@ -320,13 +290,142 @@ int bt_vcp_unmute(struct bt_vcp *vcp);
|
|||
int bt_vcp_mute(struct bt_vcp *vcp);
|
||||
|
||||
/**
|
||||
* @brief Registers the callbacks used by the Volume Control Service client.
|
||||
* @brief Registers the callbacks used by the Volume Controller.
|
||||
*
|
||||
* @param cb The callback structure.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_client_cb_register(struct bt_vcp_cb *cb);
|
||||
int bt_vcp_vol_ctlr_cb_register(struct bt_vcp_cb *cb);
|
||||
|
||||
/**
|
||||
* @brief Discover Volume Control Service and included services.
|
||||
*
|
||||
* This will start a GATT discovery and setup handles and subscriptions.
|
||||
* This shall be called once before any other actions can be
|
||||
* executed for the peer device, and the
|
||||
* @ref bt_vcp_vol_ctlr_discover_cb callback will notify when it is possible to
|
||||
* start remote operations.
|
||||
*
|
||||
* This shall only be done as the client,
|
||||
*
|
||||
* @param conn The connection to discover Volume Control Service for.
|
||||
* @param[out] vcp Valid remote instance object on success.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_discover(struct bt_conn *conn, struct bt_vcp **vcp);
|
||||
|
||||
/**
|
||||
* @brief Get the connection pointer of a client instance
|
||||
*
|
||||
* Get the Bluetooth connection pointer of a Volume Control Service
|
||||
* client instance.
|
||||
*
|
||||
* @param vcp Volume Control Service client instance pointer.
|
||||
* @param[out] conn Connection pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_conn_get(const struct bt_vcp *vcp, struct bt_conn **conn);
|
||||
|
||||
/**
|
||||
* @brief Get Volume Control Service included services.
|
||||
*
|
||||
* Returns a pointer to a struct that contains information about the
|
||||
* Volume Control Service included service instances, such as pointers to the
|
||||
* 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_ctlr_included_get(struct bt_vcp *vcp,
|
||||
struct bt_vcp_included *included);
|
||||
|
||||
/**
|
||||
* @brief Read the volume state of a remote Volume Renderer.
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_read_state(struct bt_vcp *vcp);
|
||||
|
||||
/**
|
||||
* @brief Read the volume flags of a remote Volume Renderer.
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_read_flags(struct bt_vcp *vcp);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume down one step on a remote Volume Renderer
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_vol_down(struct bt_vcp *vcp);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume up one step on a remote Volume Renderer
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_vol_up(struct bt_vcp *vcp);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume down one step and unmute on a remote Volume Renderer
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_unmute_vol_down(struct bt_vcp *vcp);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume up one step and unmute on a remote Volume Renderer
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_unmute_vol_up(struct bt_vcp *vcp);
|
||||
|
||||
/**
|
||||
* @brief Set the absolute volume on a remote Volume Renderer
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
* @param volume The absolute volume to set.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_set_vol(struct bt_vcp *vcp, uint8_t volume);
|
||||
|
||||
/**
|
||||
* @brief Unmute a remote Volume Renderer.
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_unmute(struct bt_vcp *vcp);
|
||||
|
||||
/**
|
||||
* @brief Mute a remote Volume Renderer.
|
||||
*
|
||||
* @param vcp Volume Controller instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcp_vol_ctlr_mute(struct bt_vcp *vcp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -16,10 +16,8 @@ if (CONFIG_BT_AICS OR CONFIG_BT_AICS_CLIENT)
|
|||
endif()
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_AICS_CLIENT aics_client.c)
|
||||
|
||||
if (CONFIG_BT_VCP OR CONFIG_BT_VCP_CLIENT)
|
||||
zephyr_library_sources(vcp.c)
|
||||
endif()
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_VCP_CLIENT vcp_client.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_VCP vcp.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_BT_VCP_VOL_CTLR vcp_vol_ctlr.c)
|
||||
|
||||
if (CONFIG_BT_MICP_MIC_DEV)
|
||||
zephyr_library_sources(micp_mic_dev.c)
|
||||
|
|
|
@ -63,17 +63,18 @@ endif # BT_VCS
|
|||
|
||||
##################### Volume Control Profile Client #####################
|
||||
|
||||
config BT_VCP_CLIENT
|
||||
bool "Volume Control Profile Client Support [EXPERIMENTAL]"
|
||||
config BT_VCP_VOL_CTLR
|
||||
bool "Volume Control Profile Volume Controller Support [EXPERIMENTAL]"
|
||||
select BT_GATT_CLIENT
|
||||
select BT_GATT_AUTO_DISCOVER_CCC
|
||||
select EXPERIMENTAL
|
||||
help
|
||||
This option enables support for Volume Control Profile.
|
||||
This option enables support for Volume Control Profile Volume
|
||||
Controller.
|
||||
|
||||
if BT_VCP_CLIENT
|
||||
if BT_VCP_VOL_CTLR
|
||||
|
||||
config BT_VCP_CLIENT_MAX_VOCS_INST
|
||||
config BT_VCP_VOL_CTLR_MAX_VOCS_INST
|
||||
int "Maximum number of VOCS instances to setup"
|
||||
default 0
|
||||
range 0 BT_VOCS_CLIENT_MAX_INSTANCE_COUNT
|
||||
|
@ -81,14 +82,14 @@ config BT_VCP_CLIENT_MAX_VOCS_INST
|
|||
Sets the maximum number of Volume Offset Control Service (VOCS)
|
||||
instances to setup and use.
|
||||
|
||||
config BT_VCP_CLIENT_VOCS
|
||||
config BT_VCP_VOL_CTLR_VOCS
|
||||
bool # Hidden
|
||||
default y if BT_VCP_CLIENT_MAX_VOCS_INST > 0
|
||||
default y if BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0
|
||||
help
|
||||
This hidden option makes it possible to easily check if VOCS is
|
||||
enabled for VCS client.
|
||||
|
||||
config BT_VCP_CLIENT_MAX_AICS_INST
|
||||
config BT_VCP_VOL_CTLR_MAX_AICS_INST
|
||||
int "Maximum number of AICS instances to setup"
|
||||
default 0
|
||||
range 0 3
|
||||
|
@ -96,25 +97,25 @@ config BT_VCP_CLIENT_MAX_AICS_INST
|
|||
Sets the maximum number of Audio Input Control Service (AICS)
|
||||
instances to setup and use.
|
||||
|
||||
config BT_VCP_CLIENT_AICS
|
||||
config BT_VCP_VOL_CTLR_AICS
|
||||
bool # Hidden
|
||||
default y if BT_VCP_CLIENT_MAX_AICS_INST > 0
|
||||
default y if BT_VCP_VOL_CTLR_MAX_AICS_INST > 0
|
||||
help
|
||||
This hidden option makes it possible to easily check if AICS is
|
||||
enabled for VCS client.
|
||||
|
||||
############# DEBUG #############
|
||||
|
||||
config BT_DEBUG_VCP_CLIENT
|
||||
bool "Volume Control Profile debug"
|
||||
config BT_DEBUG_VCP_VOL_CTLR
|
||||
bool "Volume Control Profile Volume Controller debug"
|
||||
select DEPRECATED
|
||||
help
|
||||
Use this option to enable Volume Control Profile debug logs for the
|
||||
Bluetooth Audio functionality.
|
||||
Use this option to enable Volume Control Profile Volume Controller
|
||||
debug logs for the Bluetooth Audio functionality.
|
||||
|
||||
module = BT_VCP_CLIENT
|
||||
legacy-debug-sym = BT_DEBUG_VCP_CLIENT
|
||||
module-str = "Volume Control Profile Client"
|
||||
module = BT_VCP_VOL_CTLR
|
||||
legacy-debug-sym = BT_DEBUG_VCP_VOL_CTLR
|
||||
module-str = "Volume Control Profile Volume Controller"
|
||||
source "subsys/bluetooth/common/Kconfig.template.log_config_bt"
|
||||
|
||||
endif # BT_VCP_CLIENT
|
||||
endif # BT_VCP_VOL_CTLR
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(bt_vcp);
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
|
||||
#define VOLUME_DOWN(current_vol) \
|
||||
((uint8_t)MAX(0, (int)current_vol - vcp_inst.srv.volume_step))
|
||||
#define VOLUME_UP(current_vol) \
|
||||
|
@ -383,7 +381,6 @@ int bt_vcp_register(struct bt_vcp_register_param *param, struct bt_vcp **vcp)
|
|||
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
|
||||
int bt_vcp_included_get(struct bt_vcp *vcp, struct bt_vcp_included *included)
|
||||
{
|
||||
|
@ -392,12 +389,6 @@ int bt_vcp_included_get(struct bt_vcp *vcp, struct bt_vcp_included *included)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_included_get(vcp, included);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
if (included == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -409,23 +400,16 @@ int bt_vcp_included_get(struct bt_vcp *vcp, struct bt_vcp_included *included)
|
|||
included->aics = vcp->srv.aics_insts;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_vol_step_set(uint8_t volume_step)
|
||||
{
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
if (volume_step > 0) {
|
||||
vcp_inst.srv.volume_step = volume_step;
|
||||
return 0;
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_get(struct bt_vcp *vcp)
|
||||
|
@ -435,20 +419,12 @@ int bt_vcp_vol_get(struct bt_vcp *vcp)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_read_vol_state(vcp);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
if (vcp->srv.cb && vcp->srv.cb->state) {
|
||||
vcp->srv.cb->state(vcp, 0, vcp->srv.state.volume,
|
||||
vcp->srv.state.mute);
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_flags_get(struct bt_vcp *vcp)
|
||||
|
@ -458,129 +434,88 @@ int bt_vcp_flags_get(struct bt_vcp *vcp)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_read_flags(vcp);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
if (vcp->srv.cb && vcp->srv.cb->flags) {
|
||||
vcp->srv.cb->flags(vcp, 0, vcp->srv.flags);
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_vol_down(struct bt_vcp *vcp)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_vol_down(vcp);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_REL_VOL_DOWN,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
};
|
||||
int err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
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;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_vol_up(struct bt_vcp *vcp)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_vol_up(vcp);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_REL_VOL_UP,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
};
|
||||
int err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
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;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_unmute_vol_down(struct bt_vcp *vcp)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_unmute_vol_down(vcp);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_UNMUTE_REL_VOL_DOWN,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
};
|
||||
int err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
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;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_unmute_vol_up(struct bt_vcp *vcp)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_unmute_vol_up(vcp);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_UNMUTE_REL_VOL_UP,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
};
|
||||
int err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
int err;
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_vol_set(struct bt_vcp *vcp, uint8_t volume)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_set_volume(vcp, volume);
|
||||
}
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
}
|
||||
|
||||
int bt_vcp_vol_set(struct bt_vcp *vcp, uint8_t volume)
|
||||
{
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
const struct vcs_control_vol cp = {
|
||||
.cp = {
|
||||
.opcode = BT_VCP_OPCODE_SET_ABS_VOL,
|
||||
|
@ -588,58 +523,50 @@ int bt_vcp_vol_set(struct bt_vcp *vcp, uint8_t volume)
|
|||
},
|
||||
.volume = volume
|
||||
};
|
||||
int err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
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;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_unmute(struct bt_vcp *vcp)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_unmute(vcp);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_UNMUTE,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
};
|
||||
int err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
int err;
|
||||
|
||||
return err > 0 ? 0 : err;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
||||
int bt_vcp_mute(struct bt_vcp *vcp)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp instance");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VCP_CLIENT) && vcp->client_instance) {
|
||||
return bt_vcp_client_mute(vcp);
|
||||
}
|
||||
err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
return err > 0 ? 0 : err;
|
||||
}
|
||||
|
||||
int bt_vcp_mute(struct bt_vcp *vcp)
|
||||
{
|
||||
const struct vcs_control cp = {
|
||||
.opcode = BT_VCP_OPCODE_MUTE,
|
||||
.counter = vcp->srv.state.change_counter,
|
||||
};
|
||||
int err = write_vcs_control(NULL, NULL, &cp, sizeof(cp), 0, 0);
|
||||
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;
|
||||
#else
|
||||
return -EOPNOTSUPP;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ struct vcs_control_vol {
|
|||
uint8_t volume;
|
||||
} __packed;
|
||||
|
||||
#if defined(CONFIG_BT_VCP_CLIENT)
|
||||
struct bt_vcp_client {
|
||||
#if defined(CONFIG_BT_VCP_VOL_CTLR)
|
||||
struct bt_vcp_vol_ctlr {
|
||||
struct vcs_state state;
|
||||
uint8_t flags;
|
||||
|
||||
|
@ -61,11 +61,11 @@ struct bt_vcp_client {
|
|||
struct bt_conn *conn;
|
||||
|
||||
uint8_t vocs_inst_cnt;
|
||||
struct bt_vocs *vocs[CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST];
|
||||
struct bt_vocs *vocs[CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST];
|
||||
uint8_t aics_inst_cnt;
|
||||
struct bt_aics *aics[CONFIG_BT_VCP_CLIENT_MAX_AICS_INST];
|
||||
struct bt_aics *aics[CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST];
|
||||
};
|
||||
#endif /* CONFIG_BT_VCP_CLIENT */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR */
|
||||
|
||||
#if defined(CONFIG_BT_VCP)
|
||||
struct bt_vcp_server {
|
||||
|
@ -87,21 +87,10 @@ struct bt_vcp {
|
|||
#if defined(CONFIG_BT_VCP)
|
||||
struct bt_vcp_server srv;
|
||||
#endif /* CONFIG_BT_VCP */
|
||||
#if defined(CONFIG_BT_VCP_CLIENT)
|
||||
struct bt_vcp_client cli;
|
||||
#endif /* CONFIG_BT_VCP_CLIENT */
|
||||
#if defined(CONFIG_BT_VCP_VOL_CTLR)
|
||||
struct bt_vcp_vol_ctlr cli;
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR */
|
||||
};
|
||||
};
|
||||
|
||||
int bt_vcp_client_included_get(struct bt_vcp *vcp,
|
||||
struct bt_vcp_included *included);
|
||||
int bt_vcp_client_read_vol_state(struct bt_vcp *vcp);
|
||||
int bt_vcp_client_read_flags(struct bt_vcp *vcp);
|
||||
int bt_vcp_client_vol_down(struct bt_vcp *vcp);
|
||||
int bt_vcp_client_vol_up(struct bt_vcp *vcp);
|
||||
int bt_vcp_client_unmute_vol_down(struct bt_vcp *vcp);
|
||||
int bt_vcp_client_unmute_vol_up(struct bt_vcp *vcp);
|
||||
int bt_vcp_client_set_volume(struct bt_vcp *vcp, uint8_t volume);
|
||||
int bt_vcp_client_unmute(struct bt_vcp *vcp);
|
||||
int bt_vcp_client_mute(struct bt_vcp *vcp);
|
||||
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_VCP_INTERNAL_*/
|
||||
|
|
|
@ -24,17 +24,17 @@
|
|||
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
LOG_MODULE_REGISTER(bt_vcp_client, CONFIG_BT_VCP_CLIENT_LOG_LEVEL);
|
||||
LOG_MODULE_REGISTER(bt_vcp_vol_ctlr, CONFIG_BT_VCP_VOL_CTLR_LOG_LEVEL);
|
||||
|
||||
#include "common/bt_str.h"
|
||||
|
||||
/* Callback functions */
|
||||
static struct bt_vcp_cb *vcp_client_cb;
|
||||
static struct bt_vcp_cb *vcp_vol_ctlr_cb;
|
||||
|
||||
static struct bt_vcp vcp_insts[CONFIG_BT_MAX_CONN];
|
||||
static int vcp_client_common_vcs_cp(struct bt_vcp *vcp, uint8_t opcode);
|
||||
static int vcp_vol_ctlr_common_vcs_cp(struct bt_vcp *vcp, uint8_t opcode);
|
||||
|
||||
static uint8_t vcp_client_notify_handler(struct bt_conn *conn,
|
||||
static uint8_t vcp_vol_ctlr_notify_handler(struct bt_conn *conn,
|
||||
struct bt_gatt_subscribe_params *params,
|
||||
const void *data, uint16_t length)
|
||||
{
|
||||
|
@ -53,25 +53,25 @@ static uint8_t vcp_client_notify_handler(struct bt_conn *conn,
|
|||
LOG_DBG("Volume %u, mute %u, counter %u",
|
||||
vcp_inst->cli.state.volume, vcp_inst->cli.state.mute,
|
||||
vcp_inst->cli.state.change_counter);
|
||||
if (vcp_client_cb && vcp_client_cb->state) {
|
||||
vcp_client_cb->state(vcp_inst, 0, vcp_inst->cli.state.volume,
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->state) {
|
||||
vcp_vol_ctlr_cb->state(vcp_inst, 0, vcp_inst->cli.state.volume,
|
||||
vcp_inst->cli.state.mute);
|
||||
}
|
||||
} else if (handle == vcp_inst->cli.flag_handle &&
|
||||
length == sizeof(vcp_inst->cli.flags)) {
|
||||
memcpy(&vcp_inst->cli.flags, data, length);
|
||||
LOG_DBG("Flags %u", vcp_inst->cli.flags);
|
||||
if (vcp_client_cb && vcp_client_cb->flags) {
|
||||
vcp_client_cb->flags(vcp_inst, 0, vcp_inst->cli.flags);
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->flags) {
|
||||
vcp_vol_ctlr_cb->flags(vcp_inst, 0, vcp_inst->cli.flags);
|
||||
}
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
|
||||
static uint8_t vcp_client_read_vol_state_cb(struct bt_conn *conn, uint8_t err,
|
||||
struct bt_gatt_read_params *params,
|
||||
const void *data, uint16_t length)
|
||||
static uint8_t vcp_vol_ctlr_read_vol_state_cb(struct bt_conn *conn, uint8_t err,
|
||||
struct bt_gatt_read_params *params,
|
||||
const void *data, uint16_t length)
|
||||
{
|
||||
int cb_err = err;
|
||||
struct bt_vcp *vcp_inst = &vcp_insts[bt_conn_index(conn)];
|
||||
|
@ -94,11 +94,11 @@ static uint8_t vcp_client_read_vol_state_cb(struct bt_conn *conn, uint8_t err,
|
|||
}
|
||||
}
|
||||
|
||||
if (vcp_client_cb && vcp_client_cb->state) {
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->state) {
|
||||
if (cb_err) {
|
||||
vcp_client_cb->state(vcp_inst, cb_err, 0, 0);
|
||||
vcp_vol_ctlr_cb->state(vcp_inst, cb_err, 0, 0);
|
||||
} else {
|
||||
vcp_client_cb->state(vcp_inst, cb_err,
|
||||
vcp_vol_ctlr_cb->state(vcp_inst, cb_err,
|
||||
vcp_inst->cli.state.volume,
|
||||
vcp_inst->cli.state.mute);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ static uint8_t vcp_client_read_vol_state_cb(struct bt_conn *conn, uint8_t err,
|
|||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
||||
static uint8_t vcp_client_read_flag_cb(struct bt_conn *conn, uint8_t err,
|
||||
static uint8_t vcp_vol_ctlr_read_flag_cb(struct bt_conn *conn, uint8_t err,
|
||||
struct bt_gatt_read_params *params,
|
||||
const void *data, uint16_t length)
|
||||
{
|
||||
|
@ -129,11 +129,11 @@ static uint8_t vcp_client_read_flag_cb(struct bt_conn *conn, uint8_t err,
|
|||
}
|
||||
}
|
||||
|
||||
if (vcp_client_cb && vcp_client_cb->flags) {
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->flags) {
|
||||
if (cb_err) {
|
||||
vcp_client_cb->flags(vcp_inst, cb_err, 0);
|
||||
vcp_vol_ctlr_cb->flags(vcp_inst, cb_err, 0);
|
||||
} else {
|
||||
vcp_client_cb->flags(vcp_inst, cb_err, vcp_inst->cli.flags);
|
||||
vcp_vol_ctlr_cb->flags(vcp_inst, cb_err, vcp_inst->cli.flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,44 +142,44 @@ static uint8_t vcp_client_read_flag_cb(struct bt_conn *conn, uint8_t err,
|
|||
|
||||
static void vcs_cp_notify_app(struct bt_vcp *vcp, uint8_t opcode, int err)
|
||||
{
|
||||
if (vcp_client_cb == NULL) {
|
||||
if (vcp_vol_ctlr_cb == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (opcode) {
|
||||
case BT_VCP_OPCODE_REL_VOL_DOWN:
|
||||
if (vcp_client_cb->vol_down) {
|
||||
vcp_client_cb->vol_down(vcp, err);
|
||||
if (vcp_vol_ctlr_cb->vol_down) {
|
||||
vcp_vol_ctlr_cb->vol_down(vcp, err);
|
||||
}
|
||||
break;
|
||||
case BT_VCP_OPCODE_REL_VOL_UP:
|
||||
if (vcp_client_cb->vol_up) {
|
||||
vcp_client_cb->vol_up(vcp, err);
|
||||
if (vcp_vol_ctlr_cb->vol_up) {
|
||||
vcp_vol_ctlr_cb->vol_up(vcp, err);
|
||||
}
|
||||
break;
|
||||
case BT_VCP_OPCODE_UNMUTE_REL_VOL_DOWN:
|
||||
if (vcp_client_cb->vol_down_unmute) {
|
||||
vcp_client_cb->vol_down_unmute(vcp, err);
|
||||
if (vcp_vol_ctlr_cb->vol_down_unmute) {
|
||||
vcp_vol_ctlr_cb->vol_down_unmute(vcp, err);
|
||||
}
|
||||
break;
|
||||
case BT_VCP_OPCODE_UNMUTE_REL_VOL_UP:
|
||||
if (vcp_client_cb->vol_up_unmute) {
|
||||
vcp_client_cb->vol_up_unmute(vcp, err);
|
||||
if (vcp_vol_ctlr_cb->vol_up_unmute) {
|
||||
vcp_vol_ctlr_cb->vol_up_unmute(vcp, err);
|
||||
}
|
||||
break;
|
||||
case BT_VCP_OPCODE_SET_ABS_VOL:
|
||||
if (vcp_client_cb->vol_set) {
|
||||
vcp_client_cb->vol_set(vcp, err);
|
||||
if (vcp_vol_ctlr_cb->vol_set) {
|
||||
vcp_vol_ctlr_cb->vol_set(vcp, err);
|
||||
}
|
||||
break;
|
||||
case BT_VCP_OPCODE_UNMUTE:
|
||||
if (vcp_client_cb->unmute) {
|
||||
vcp_client_cb->unmute(vcp, err);
|
||||
if (vcp_vol_ctlr_cb->unmute) {
|
||||
vcp_vol_ctlr_cb->unmute(vcp, err);
|
||||
}
|
||||
break;
|
||||
case BT_VCP_OPCODE_MUTE:
|
||||
if (vcp_client_cb->mute) {
|
||||
vcp_client_cb->mute(vcp, err);
|
||||
if (vcp_vol_ctlr_cb->mute) {
|
||||
vcp_vol_ctlr_cb->mute(vcp, err);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -215,10 +215,10 @@ static uint8_t internal_read_vol_state_cb(struct bt_conn *conn, uint8_t err,
|
|||
/* clear busy flag to reuse function */
|
||||
vcp_inst->cli.busy = false;
|
||||
if (opcode == BT_VCP_OPCODE_SET_ABS_VOL) {
|
||||
write_err = bt_vcp_client_set_volume(vcp_inst,
|
||||
write_err = bt_vcp_vol_ctlr_set_vol(vcp_inst,
|
||||
vcp_inst->cli.cp_val.volume);
|
||||
} else {
|
||||
write_err = vcp_client_common_vcs_cp(vcp_inst,
|
||||
write_err = vcp_vol_ctlr_common_vcs_cp(vcp_inst,
|
||||
opcode);
|
||||
}
|
||||
if (write_err) {
|
||||
|
@ -239,7 +239,7 @@ static uint8_t internal_read_vol_state_cb(struct bt_conn *conn, uint8_t err,
|
|||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
||||
static void vcp_client_write_vcs_cp_cb(struct bt_conn *conn, uint8_t err,
|
||||
static void vcp_vol_ctlr_write_vcs_cp_cb(struct bt_conn *conn, uint8_t err,
|
||||
struct bt_gatt_write_params *params)
|
||||
{
|
||||
struct bt_vcp *vcp_inst = &vcp_insts[bt_conn_index(conn)];
|
||||
|
@ -280,7 +280,7 @@ static void vcp_client_write_vcs_cp_cb(struct bt_conn *conn, uint8_t err,
|
|||
vcs_cp_notify_app(vcp_inst, opcode, err);
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0 || CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0)
|
||||
#if (CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0 || CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0)
|
||||
static uint8_t vcs_discover_include_func(struct bt_conn *conn,
|
||||
const struct bt_gatt_attr *attr,
|
||||
struct bt_gatt_discover_params *params)
|
||||
|
@ -296,11 +296,11 @@ static uint8_t vcs_discover_include_func(struct bt_conn *conn,
|
|||
vcp_inst->cli.vocs_inst_cnt);
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
/*
|
||||
* TODO: Validate that all mandatory handles were found
|
||||
*/
|
||||
vcp_client_cb->discover(vcp_inst, 0,
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, 0,
|
||||
vcp_inst->cli.vocs_inst_cnt,
|
||||
vcp_inst->cli.aics_inst_cnt);
|
||||
}
|
||||
|
@ -316,9 +316,9 @@ static uint8_t vcs_discover_include_func(struct bt_conn *conn,
|
|||
include = (struct bt_gatt_include *)attr->user_data;
|
||||
LOG_DBG("Include UUID %s", bt_uuid_str(include->uuid));
|
||||
|
||||
#if CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0
|
||||
#if CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0
|
||||
if (bt_uuid_cmp(include->uuid, BT_UUID_AICS) == 0 &&
|
||||
vcp_inst->cli.aics_inst_cnt < CONFIG_BT_VCP_CLIENT_MAX_AICS_INST) {
|
||||
vcp_inst->cli.aics_inst_cnt < CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST) {
|
||||
struct bt_aics_discover_param param = {
|
||||
.start_handle = include->start_handle,
|
||||
.end_handle = include->end_handle,
|
||||
|
@ -335,18 +335,18 @@ static uint8_t vcs_discover_include_func(struct bt_conn *conn,
|
|||
¶m);
|
||||
if (err != 0) {
|
||||
LOG_DBG("AICS Discover failed (err %d)", err);
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst, err,
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, err,
|
||||
0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_MAX_AICS_INST */
|
||||
#if CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST */
|
||||
#if CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0
|
||||
if (bt_uuid_cmp(include->uuid, BT_UUID_VOCS) == 0 &&
|
||||
vcp_inst->cli.vocs_inst_cnt < CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST) {
|
||||
vcp_inst->cli.vocs_inst_cnt < CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST) {
|
||||
struct bt_vocs_discover_param param = {
|
||||
.start_handle = include->start_handle,
|
||||
.end_handle = include->end_handle,
|
||||
|
@ -363,20 +363,20 @@ static uint8_t vcs_discover_include_func(struct bt_conn *conn,
|
|||
¶m);
|
||||
if (err != 0) {
|
||||
LOG_DBG("VOCS Discover failed (err %d)", err);
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst, err,
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, err,
|
||||
0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST */
|
||||
}
|
||||
|
||||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
#endif /* (CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0 || CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0) */
|
||||
#endif /* (CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0 || CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0) */
|
||||
|
||||
/**
|
||||
* @brief This will discover all characteristics on the server, retrieving the
|
||||
|
@ -395,7 +395,7 @@ static uint8_t vcs_discover_func(struct bt_conn *conn,
|
|||
if (attr == NULL) {
|
||||
LOG_DBG("Setup complete for VCP");
|
||||
(void)memset(params, 0, sizeof(*params));
|
||||
#if (CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0 || CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0)
|
||||
#if (CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0 || CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0)
|
||||
/* Discover included services */
|
||||
vcp_inst->cli.discover_params.start_handle = vcp_inst->cli.start_handle;
|
||||
vcp_inst->cli.discover_params.end_handle = vcp_inst->cli.end_handle;
|
||||
|
@ -405,15 +405,15 @@ static uint8_t vcs_discover_func(struct bt_conn *conn,
|
|||
err = bt_gatt_discover(conn, &vcp_inst->cli.discover_params);
|
||||
if (err != 0) {
|
||||
LOG_DBG("Discover failed (err %d)", err);
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst, err, 0, 0);
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, err, 0, 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst, err, 0, 0);
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, err, 0, 0);
|
||||
}
|
||||
#endif /* (CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0 || CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0) */
|
||||
#endif /* (CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0 || CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0) */
|
||||
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ static uint8_t vcs_discover_func(struct bt_conn *conn,
|
|||
sub_params->value_handle = chrc->value_handle;
|
||||
sub_params->ccc_handle = 0;
|
||||
sub_params->end_handle = vcp_inst->cli.end_handle;
|
||||
sub_params->notify = vcp_client_notify_handler;
|
||||
sub_params->notify = vcp_vol_ctlr_notify_handler;
|
||||
err = bt_gatt_subscribe(conn, sub_params);
|
||||
if (err == 0) {
|
||||
LOG_DBG("Subscribed to handle 0x%04X",
|
||||
|
@ -474,8 +474,8 @@ static uint8_t primary_discover_func(struct bt_conn *conn,
|
|||
|
||||
if (attr == NULL) {
|
||||
LOG_DBG("Could not find a VCP instance on the server");
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst, -ENODATA, 0, 0);
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, -ENODATA, 0, 0);
|
||||
}
|
||||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
@ -501,8 +501,8 @@ static uint8_t primary_discover_func(struct bt_conn *conn,
|
|||
err = bt_gatt_discover(conn, &vcp_inst->cli.discover_params);
|
||||
if (err != 0) {
|
||||
LOG_DBG("Discover failed (err %d)", err);
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst, err, 0, 0);
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, err, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,7 +512,7 @@ static uint8_t primary_discover_func(struct bt_conn *conn,
|
|||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
|
||||
static int vcp_client_common_vcs_cp(struct bt_vcp *vcp, uint8_t opcode)
|
||||
static int vcp_vol_ctlr_common_vcs_cp(struct bt_vcp *vcp, uint8_t opcode)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -535,7 +535,7 @@ static int vcp_client_common_vcs_cp(struct bt_vcp *vcp, uint8_t opcode)
|
|||
vcp->cli.write_params.data = &vcp->cli.cp_val.cp;
|
||||
vcp->cli.write_params.length = sizeof(vcp->cli.cp_val.cp);
|
||||
vcp->cli.write_params.handle = vcp->cli.control_handle;
|
||||
vcp->cli.write_params.func = vcp_client_write_vcs_cp_cb;
|
||||
vcp->cli.write_params.func = vcp_vol_ctlr_write_vcs_cp_cb;
|
||||
|
||||
err = bt_gatt_write(vcp->cli.conn, &vcp->cli.write_params);
|
||||
if (err == 0) {
|
||||
|
@ -544,7 +544,7 @@ static int vcp_client_common_vcs_cp(struct bt_vcp *vcp, uint8_t opcode)
|
|||
return err;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_VCP_CLIENT_AICS)
|
||||
#if defined(CONFIG_BT_VCP_VOL_CTLR_AICS)
|
||||
static struct bt_vcp *lookup_vcp_by_aics(const struct bt_aics *aics)
|
||||
{
|
||||
__ASSERT(aics != NULL, "aics pointer cannot be NULL");
|
||||
|
@ -572,14 +572,14 @@ static void aics_discover_cb(struct bt_aics *inst, int err)
|
|||
|
||||
if (err != 0) {
|
||||
LOG_DBG("Discover failed (err %d)", err);
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst, err, 0, 0);
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, err, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_AICS */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_AICS */
|
||||
|
||||
#if defined(CONFIG_BT_VCP_CLIENT_VOCS)
|
||||
#if defined(CONFIG_BT_VCP_VOL_CTLR_VOCS)
|
||||
static struct bt_vcp *lookup_vcp_by_vocs(const struct bt_vocs *vocs)
|
||||
{
|
||||
__ASSERT(vocs != NULL, "VOCS pointer cannot be NULL");
|
||||
|
@ -602,8 +602,8 @@ static void vocs_discover_cb(struct bt_vocs *inst, int err)
|
|||
if (vcp_inst == NULL) {
|
||||
LOG_ERR("Could not lookup vcp_inst from vocs");
|
||||
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst,
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst,
|
||||
BT_GATT_ERR(BT_ATT_ERR_UNLIKELY),
|
||||
0, 0);
|
||||
}
|
||||
|
@ -619,14 +619,14 @@ static void vocs_discover_cb(struct bt_vocs *inst, int err)
|
|||
|
||||
if (err != 0) {
|
||||
LOG_DBG("Discover failed (err %d)", err);
|
||||
if (vcp_client_cb && vcp_client_cb->discover) {
|
||||
vcp_client_cb->discover(vcp_inst, err, 0, 0);
|
||||
if (vcp_vol_ctlr_cb && vcp_vol_ctlr_cb->discover) {
|
||||
vcp_vol_ctlr_cb->discover(vcp_inst, err, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_VOCS */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_VOCS */
|
||||
|
||||
static void vcp_client_reset(struct bt_vcp *vcp_inst)
|
||||
static void vcp_vol_ctlr_reset(struct bt_vcp *vcp_inst)
|
||||
{
|
||||
memset(&vcp_inst->cli.state, 0, sizeof(vcp_inst->cli.state));
|
||||
vcp_inst->cli.flags = 0;
|
||||
|
@ -662,7 +662,7 @@ static void disconnected(struct bt_conn *conn, uint8_t reason)
|
|||
struct bt_vcp *vcp_inst = &vcp_insts[bt_conn_index(conn)];
|
||||
|
||||
if (vcp_inst->cli.conn == conn) {
|
||||
vcp_client_reset(vcp_inst);
|
||||
vcp_vol_ctlr_reset(vcp_inst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -670,12 +670,12 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
|
|||
.disconnected = disconnected,
|
||||
};
|
||||
|
||||
static void bt_vcp_client_init(void)
|
||||
static void bt_vcp_vol_ctlr_init(void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_VOCS_CLIENT) &&
|
||||
CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0) {
|
||||
CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0) {
|
||||
for (i = 0; i < ARRAY_SIZE(vcp_insts); i++) {
|
||||
for (j = 0; j < ARRAY_SIZE(vcp_insts[i].cli.vocs); j++) {
|
||||
vcp_insts[i].cli.vocs[j] = bt_vocs_client_free_instance_get();
|
||||
|
@ -684,13 +684,13 @@ static void bt_vcp_client_init(void)
|
|||
"Could not allocate VOCS client instance");
|
||||
|
||||
bt_vocs_client_cb_register(vcp_insts[i].cli.vocs[j],
|
||||
&vcp_client_cb->vocs_cb);
|
||||
&vcp_vol_ctlr_cb->vocs_cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_AICS_CLIENT) &&
|
||||
CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0) {
|
||||
CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0) {
|
||||
for (i = 0; i < ARRAY_SIZE(vcp_insts); i++) {
|
||||
for (j = 0; j < ARRAY_SIZE(vcp_insts[i].cli.aics); j++) {
|
||||
vcp_insts[i].cli.aics[j] = bt_aics_client_free_instance_get();
|
||||
|
@ -699,13 +699,13 @@ static void bt_vcp_client_init(void)
|
|||
"Could not allocate AICS client instance");
|
||||
|
||||
bt_aics_client_cb_register(vcp_insts[i].cli.aics[j],
|
||||
&vcp_client_cb->aics_cb);
|
||||
&vcp_vol_ctlr_cb->aics_cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int bt_vcp_discover(struct bt_conn *conn, struct bt_vcp **vcp)
|
||||
int bt_vcp_vol_ctlr_discover(struct bt_conn *conn, struct bt_vcp **vcp)
|
||||
{
|
||||
static bool initialized;
|
||||
struct bt_vcp *vcp_inst;
|
||||
|
@ -733,11 +733,11 @@ int bt_vcp_discover(struct bt_conn *conn, struct bt_vcp **vcp)
|
|||
}
|
||||
|
||||
if (!initialized) {
|
||||
bt_vcp_client_init();
|
||||
bt_vcp_vol_ctlr_init();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
vcp_client_reset(vcp_inst);
|
||||
vcp_vol_ctlr_reset(vcp_inst);
|
||||
|
||||
memcpy(&vcp_inst->cli.uuid, BT_UUID_VCS, sizeof(vcp_inst->cli.uuid));
|
||||
|
||||
|
@ -756,9 +756,9 @@ int bt_vcp_discover(struct bt_conn *conn, struct bt_vcp **vcp)
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_vcp_client_cb_register(struct bt_vcp_cb *cb)
|
||||
int bt_vcp_vol_ctlr_cb_register(struct bt_vcp_cb *cb)
|
||||
{
|
||||
#if defined(CONFIG_BT_VCP_CLIENT_VOCS)
|
||||
#if defined(CONFIG_BT_VCP_VOL_CTLR_VOCS)
|
||||
struct bt_vocs_cb *vocs_cb = NULL;
|
||||
|
||||
if (cb != NULL) {
|
||||
|
@ -782,9 +782,9 @@ int bt_vcp_client_cb_register(struct bt_vcp_cb *cb)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_VOCS */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_VOCS */
|
||||
|
||||
#if defined(CONFIG_BT_VCP_CLIENT_AICS)
|
||||
#if defined(CONFIG_BT_VCP_VOL_CTLR_AICS)
|
||||
struct bt_aics_cb *aics_cb = NULL;
|
||||
|
||||
if (cb != NULL) {
|
||||
|
@ -808,14 +808,14 @@ int bt_vcp_client_cb_register(struct bt_vcp_cb *cb)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_AICS */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_AICS */
|
||||
|
||||
vcp_client_cb = cb;
|
||||
vcp_vol_ctlr_cb = cb;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_vcp_client_included_get(struct bt_vcp *vcp,
|
||||
int bt_vcp_vol_ctlr_included_get(struct bt_vcp *vcp,
|
||||
struct bt_vcp_included *included)
|
||||
{
|
||||
CHECKIF(!included || vcp == NULL) {
|
||||
|
@ -831,7 +831,7 @@ int bt_vcp_client_included_get(struct bt_vcp *vcp,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_vcp_client_conn_get(const struct bt_vcp *vcp, struct bt_conn **conn)
|
||||
int bt_vcp_vol_ctlr_conn_get(const struct bt_vcp *vcp, struct bt_conn **conn)
|
||||
{
|
||||
CHECKIF(vcp == NULL) {
|
||||
LOG_DBG("NULL vcp pointer");
|
||||
|
@ -853,7 +853,7 @@ int bt_vcp_client_conn_get(const struct bt_vcp *vcp, struct bt_conn **conn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bt_vcp_client_read_vol_state(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_ctlr_read_state(struct bt_vcp *vcp)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -869,7 +869,7 @@ int bt_vcp_client_read_vol_state(struct bt_vcp *vcp)
|
|||
return -EBUSY;
|
||||
}
|
||||
|
||||
vcp->cli.read_params.func = vcp_client_read_vol_state_cb;
|
||||
vcp->cli.read_params.func = vcp_vol_ctlr_read_vol_state_cb;
|
||||
vcp->cli.read_params.handle_count = 1;
|
||||
vcp->cli.read_params.single.handle = vcp->cli.state_handle;
|
||||
vcp->cli.read_params.single.offset = 0U;
|
||||
|
@ -882,7 +882,7 @@ int bt_vcp_client_read_vol_state(struct bt_vcp *vcp)
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_vcp_client_read_flags(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_ctlr_read_flags(struct bt_vcp *vcp)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -898,7 +898,7 @@ int bt_vcp_client_read_flags(struct bt_vcp *vcp)
|
|||
return -EBUSY;
|
||||
}
|
||||
|
||||
vcp->cli.read_params.func = vcp_client_read_flag_cb;
|
||||
vcp->cli.read_params.func = vcp_vol_ctlr_read_flag_cb;
|
||||
vcp->cli.read_params.handle_count = 1;
|
||||
vcp->cli.read_params.single.handle = vcp->cli.flag_handle;
|
||||
vcp->cli.read_params.single.offset = 0U;
|
||||
|
@ -911,27 +911,27 @@ int bt_vcp_client_read_flags(struct bt_vcp *vcp)
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_vcp_client_vol_down(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_ctlr_vol_down(struct bt_vcp *vcp)
|
||||
{
|
||||
return vcp_client_common_vcs_cp(vcp, BT_VCP_OPCODE_REL_VOL_DOWN);
|
||||
return vcp_vol_ctlr_common_vcs_cp(vcp, BT_VCP_OPCODE_REL_VOL_DOWN);
|
||||
}
|
||||
|
||||
int bt_vcp_client_vol_up(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_ctlr_vol_up(struct bt_vcp *vcp)
|
||||
{
|
||||
return vcp_client_common_vcs_cp(vcp, BT_VCP_OPCODE_REL_VOL_UP);
|
||||
return vcp_vol_ctlr_common_vcs_cp(vcp, BT_VCP_OPCODE_REL_VOL_UP);
|
||||
}
|
||||
|
||||
int bt_vcp_client_unmute_vol_down(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_ctlr_unmute_vol_down(struct bt_vcp *vcp)
|
||||
{
|
||||
return vcp_client_common_vcs_cp(vcp, BT_VCP_OPCODE_UNMUTE_REL_VOL_DOWN);
|
||||
return vcp_vol_ctlr_common_vcs_cp(vcp, BT_VCP_OPCODE_UNMUTE_REL_VOL_DOWN);
|
||||
}
|
||||
|
||||
int bt_vcp_client_unmute_vol_up(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_ctlr_unmute_vol_up(struct bt_vcp *vcp)
|
||||
{
|
||||
return vcp_client_common_vcs_cp(vcp, BT_VCP_OPCODE_UNMUTE_REL_VOL_UP);
|
||||
return vcp_vol_ctlr_common_vcs_cp(vcp, BT_VCP_OPCODE_UNMUTE_REL_VOL_UP);
|
||||
}
|
||||
|
||||
int bt_vcp_client_set_volume(struct bt_vcp *vcp, uint8_t volume)
|
||||
int bt_vcp_vol_ctlr_set_vol(struct bt_vcp *vcp, uint8_t volume)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -956,7 +956,7 @@ int bt_vcp_client_set_volume(struct bt_vcp *vcp, uint8_t volume)
|
|||
vcp->cli.write_params.data = &vcp->cli.cp_val;
|
||||
vcp->cli.write_params.length = sizeof(vcp->cli.cp_val);
|
||||
vcp->cli.write_params.handle = vcp->cli.control_handle;
|
||||
vcp->cli.write_params.func = vcp_client_write_vcs_cp_cb;
|
||||
vcp->cli.write_params.func = vcp_vol_ctlr_write_vcs_cp_cb;
|
||||
|
||||
err = bt_gatt_write(vcp->cli.conn, &vcp->cli.write_params);
|
||||
if (err == 0) {
|
||||
|
@ -966,12 +966,12 @@ int bt_vcp_client_set_volume(struct bt_vcp *vcp, uint8_t volume)
|
|||
return err;
|
||||
}
|
||||
|
||||
int bt_vcp_client_unmute(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_ctlr_unmute(struct bt_vcp *vcp)
|
||||
{
|
||||
return vcp_client_common_vcs_cp(vcp, BT_VCP_OPCODE_UNMUTE);
|
||||
return vcp_vol_ctlr_common_vcs_cp(vcp, BT_VCP_OPCODE_UNMUTE);
|
||||
}
|
||||
|
||||
int bt_vcp_client_mute(struct bt_vcp *vcp)
|
||||
int bt_vcp_vol_ctlr_mute(struct bt_vcp *vcp)
|
||||
{
|
||||
return vcp_client_common_vcs_cp(vcp, BT_VCP_OPCODE_MUTE);
|
||||
return vcp_vol_ctlr_common_vcs_cp(vcp, BT_VCP_OPCODE_MUTE);
|
||||
}
|
|
@ -30,8 +30,8 @@ zephyr_library_sources_ifdef(
|
|||
vcp.c
|
||||
)
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_BT_VCP_CLIENT
|
||||
vcp_client.c
|
||||
CONFIG_BT_VCP_VOL_CTLR
|
||||
vcp_vol_ctlr.c
|
||||
)
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_BT_MICP_MIC_DEV
|
||||
|
|
|
@ -27,7 +27,7 @@ static void vcs_discover_cb(struct bt_vcp *vcp, int err, uint8_t vocs_count,
|
|||
shell_print(ctx_shell, "VCP discover done with %u AICS",
|
||||
aics_count);
|
||||
|
||||
if (bt_vcp_included_get(vcp, &vcp_included)) {
|
||||
if (bt_vcp_vol_ctlr_included_get(vcp, &vcp_included)) {
|
||||
shell_error(ctx_shell, "Could not get VCP context");
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ static void vcs_flags_cb(struct bt_vcp *vcp, int err, uint8_t flags)
|
|||
}
|
||||
}
|
||||
|
||||
#if CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0
|
||||
#if CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0
|
||||
static void vcs_aics_set_gain_cb(struct bt_aics *inst, int err)
|
||||
{
|
||||
if (err != 0) {
|
||||
|
@ -234,9 +234,9 @@ static void vcs_aics_description_cb(struct bt_aics *inst, int err,
|
|||
inst, description);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0 */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0 */
|
||||
|
||||
#if CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0
|
||||
#if CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0
|
||||
static void vcs_vocs_set_offset_cb(struct bt_vocs *inst, int err)
|
||||
{
|
||||
if (err != 0) {
|
||||
|
@ -282,7 +282,7 @@ static void vcs_vocs_description_cb(struct bt_vocs *inst, int err,
|
|||
inst, description);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0 */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0 */
|
||||
|
||||
static struct bt_vcp_cb vcs_cbs = {
|
||||
.discover = vcs_discover_cb,
|
||||
|
@ -298,7 +298,7 @@ static struct bt_vcp_cb vcs_cbs = {
|
|||
.flags = vcs_flags_cb,
|
||||
|
||||
/* Audio Input Control Service */
|
||||
#if CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0
|
||||
#if CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0
|
||||
.aics_cb = {
|
||||
.state = vcs_aics_state_cb,
|
||||
.gain_setting = vcs_aics_gain_setting_cb,
|
||||
|
@ -311,18 +311,18 @@ static struct bt_vcp_cb vcs_cbs = {
|
|||
.set_manual_mode = vcs_aics_set_manual_mode_cb,
|
||||
.set_auto_mode = vcs_aics_automatic_mode_cb,
|
||||
},
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0 */
|
||||
#if CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0 */
|
||||
#if CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0
|
||||
.vocs_cb = {
|
||||
.state = vcs_vocs_state_cb,
|
||||
.location = vcs_vocs_location_cb,
|
||||
.description = vcs_vocs_description_cb,
|
||||
.set_offset = vcs_vocs_set_offset_cb,
|
||||
}
|
||||
#endif /* CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST > 0 */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST > 0 */
|
||||
};
|
||||
|
||||
static int cmd_vcp_client_discover(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_discover(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -331,7 +331,7 @@ static int cmd_vcp_client_discover(const struct shell *sh, size_t argc,
|
|||
ctx_shell = sh;
|
||||
}
|
||||
|
||||
result = bt_vcp_client_cb_register(&vcs_cbs);
|
||||
result = bt_vcp_vol_ctlr_cb_register(&vcs_cbs);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "CB register failed: %d", result);
|
||||
return result;
|
||||
|
@ -342,7 +342,7 @@ static int cmd_vcp_client_discover(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_discover(default_conn, &vcp);
|
||||
result = bt_vcp_vol_ctlr_discover(default_conn, &vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ static int cmd_vcp_client_discover(const struct shell *sh, size_t argc,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_state_get(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_state_get(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -360,7 +360,7 @@ static int cmd_vcp_client_state_get(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_vol_get(vcp);
|
||||
result = bt_vcp_vol_ctlr_read_state(vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ static int cmd_vcp_client_state_get(const struct shell *sh, size_t argc,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_flags_get(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_flags_get(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -378,7 +378,7 @@ static int cmd_vcp_client_flags_get(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_flags_get(vcp);
|
||||
result = bt_vcp_vol_ctlr_read_flags(vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ static int cmd_vcp_client_flags_get(const struct shell *sh, size_t argc,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_volume_down(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_volume_down(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -396,7 +396,7 @@ static int cmd_vcp_client_volume_down(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_vol_down(vcp);
|
||||
result = bt_vcp_vol_ctlr_vol_down(vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ static int cmd_vcp_client_volume_down(const struct shell *sh, size_t argc,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_volume_up(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_volume_up(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
|
||||
{
|
||||
|
@ -415,7 +415,7 @@ static int cmd_vcp_client_volume_up(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_vol_up(vcp);
|
||||
result = bt_vcp_vol_ctlr_vol_up(vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ static int cmd_vcp_client_volume_up(const struct shell *sh, size_t argc,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_unmute_volume_down(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_unmute_volume_down(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -433,7 +433,7 @@ static int cmd_vcp_client_unmute_volume_down(const struct shell *sh,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_unmute_vol_down(vcp);
|
||||
result = bt_vcp_vol_ctlr_unmute_vol_down(vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ static int cmd_vcp_client_unmute_volume_down(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_unmute_volume_up(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_unmute_volume_up(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -451,7 +451,7 @@ static int cmd_vcp_client_unmute_volume_up(const struct shell *sh,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_unmute_vol_up(vcp);
|
||||
result = bt_vcp_vol_ctlr_unmute_vol_up(vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ static int cmd_vcp_client_unmute_volume_up(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_volume_set(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_volume_set(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
|
||||
{
|
||||
|
@ -476,7 +476,7 @@ static int cmd_vcp_client_volume_set(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_vol_set(vcp, volume);
|
||||
result = bt_vcp_vol_ctlr_set_vol(vcp, volume);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ static int cmd_vcp_client_volume_set(const struct shell *sh, size_t argc,
|
|||
}
|
||||
|
||||
|
||||
static int cmd_vcp_client_unmute(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_unmute(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -495,7 +495,7 @@ static int cmd_vcp_client_unmute(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_unmute(vcp);
|
||||
result = bt_vcp_vol_ctlr_unmute(vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ static int cmd_vcp_client_unmute(const struct shell *sh, size_t argc,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_mute(const struct shell *sh, size_t argc, char **argv)
|
||||
static int cmd_vcp_vol_ctlr_mute(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
||||
|
@ -512,7 +512,7 @@ static int cmd_vcp_client_mute(const struct shell *sh, size_t argc, char **argv)
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcp_mute(vcp);
|
||||
result = bt_vcp_vol_ctlr_mute(vcp);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ static int cmd_vcp_client_mute(const struct shell *sh, size_t argc, char **argv)
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_vocs_state_get(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_vocs_state_get(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -545,7 +545,7 @@ static int cmd_vcp_client_vocs_state_get(const struct shell *sh, size_t argc,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_vocs_location_get(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_vocs_location_get(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -570,7 +570,7 @@ static int cmd_vcp_client_vocs_location_get(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_vocs_location_set(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_vocs_location_set(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -604,7 +604,7 @@ static int cmd_vcp_client_vocs_location_set(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_vocs_offset_set(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_vocs_offset_set(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -637,7 +637,7 @@ static int cmd_vcp_client_vocs_offset_set(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_vocs_output_description_get(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_vocs_output_description_get(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -662,7 +662,7 @@ static int cmd_vcp_client_vocs_output_description_get(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_vocs_output_description_set(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_vocs_output_description_set(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -689,7 +689,7 @@ static int cmd_vcp_client_vocs_output_description_set(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_input_state_get(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_input_state_get(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -714,7 +714,7 @@ static int cmd_vcp_client_aics_input_state_get(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_gain_setting_get(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_gain_setting_get(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -739,7 +739,7 @@ static int cmd_vcp_client_aics_gain_setting_get(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_input_type_get(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_input_type_get(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -764,7 +764,7 @@ static int cmd_vcp_client_aics_input_type_get(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_input_status_get(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_input_status_get(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -789,7 +789,7 @@ static int cmd_vcp_client_aics_input_status_get(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_input_unmute(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_input_unmute(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -814,7 +814,7 @@ static int cmd_vcp_client_aics_input_unmute(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_input_mute(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_input_mute(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -839,7 +839,7 @@ static int cmd_vcp_client_aics_input_mute(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_manual_input_gain_set(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_manual_input_gain_set(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -864,7 +864,7 @@ static int cmd_vcp_client_aics_manual_input_gain_set(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_auto_input_gain_set(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_auto_input_gain_set(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -889,7 +889,7 @@ static int cmd_vcp_client_aics_auto_input_gain_set(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_gain_set(const struct shell *sh, size_t argc,
|
||||
static int cmd_vcp_vol_ctlr_aics_gain_set(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -921,7 +921,7 @@ static int cmd_vcp_client_aics_gain_set(const struct shell *sh, size_t argc,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_input_description_get(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_input_description_get(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -946,7 +946,7 @@ static int cmd_vcp_client_aics_input_description_get(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client_aics_input_description_set(const struct shell *sh,
|
||||
static int cmd_vcp_vol_ctlr_aics_input_description_set(const struct shell *sh,
|
||||
size_t argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
@ -973,7 +973,7 @@ static int cmd_vcp_client_aics_input_description_set(const struct shell *sh,
|
|||
return result;
|
||||
}
|
||||
|
||||
static int cmd_vcp_client(const struct shell *sh, size_t argc, char **argv)
|
||||
static int cmd_vcp_vol_ctlr(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
if (argc > 1) {
|
||||
shell_error(sh, "%s unknown parameter: %s",
|
||||
|
@ -985,101 +985,101 @@ static int cmd_vcp_client(const struct shell *sh, size_t argc, char **argv)
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
SHELL_STATIC_SUBCMD_SET_CREATE(vcp_client_cmds,
|
||||
SHELL_STATIC_SUBCMD_SET_CREATE(vcp_vol_ctlr_cmds,
|
||||
SHELL_CMD_ARG(discover, NULL,
|
||||
"Discover VCP and included services for current "
|
||||
"connection",
|
||||
cmd_vcp_client_discover, 1, 0),
|
||||
cmd_vcp_vol_ctlr_discover, 1, 0),
|
||||
SHELL_CMD_ARG(state_get, NULL,
|
||||
"Get volume state of the VCP server. Should be done "
|
||||
"before sending any control messages",
|
||||
cmd_vcp_client_state_get, 1, 0),
|
||||
cmd_vcp_vol_ctlr_state_get, 1, 0),
|
||||
SHELL_CMD_ARG(flags_get, NULL,
|
||||
"Read volume flags",
|
||||
cmd_vcp_client_flags_get, 1, 0),
|
||||
cmd_vcp_vol_ctlr_flags_get, 1, 0),
|
||||
SHELL_CMD_ARG(volume_down, NULL,
|
||||
"Turn the volume down",
|
||||
cmd_vcp_client_volume_down, 1, 0),
|
||||
cmd_vcp_vol_ctlr_volume_down, 1, 0),
|
||||
SHELL_CMD_ARG(volume_up, NULL,
|
||||
"Turn the volume up",
|
||||
cmd_vcp_client_volume_up, 1, 0),
|
||||
cmd_vcp_vol_ctlr_volume_up, 1, 0),
|
||||
SHELL_CMD_ARG(unmute_volume_down, NULL,
|
||||
"Turn the volume down, and unmute",
|
||||
cmd_vcp_client_unmute_volume_down, 1, 0),
|
||||
cmd_vcp_vol_ctlr_unmute_volume_down, 1, 0),
|
||||
SHELL_CMD_ARG(unmute_volume_up, NULL,
|
||||
"Turn the volume up, and unmute",
|
||||
cmd_vcp_client_unmute_volume_up, 1, 0),
|
||||
cmd_vcp_vol_ctlr_unmute_volume_up, 1, 0),
|
||||
SHELL_CMD_ARG(volume_set, NULL,
|
||||
"Set an absolute volume <volume>",
|
||||
cmd_vcp_client_volume_set, 2, 0),
|
||||
cmd_vcp_vol_ctlr_volume_set, 2, 0),
|
||||
SHELL_CMD_ARG(unmute, NULL,
|
||||
"Unmute",
|
||||
cmd_vcp_client_unmute, 1, 0),
|
||||
cmd_vcp_vol_ctlr_unmute, 1, 0),
|
||||
SHELL_CMD_ARG(mute, NULL,
|
||||
"Mute",
|
||||
cmd_vcp_client_mute, 1, 0),
|
||||
cmd_vcp_vol_ctlr_mute, 1, 0),
|
||||
SHELL_CMD_ARG(vocs_state_get, NULL,
|
||||
"Get the offset state of a VOCS instance <inst_index>",
|
||||
cmd_vcp_client_vocs_state_get, 2, 0),
|
||||
cmd_vcp_vol_ctlr_vocs_state_get, 2, 0),
|
||||
SHELL_CMD_ARG(vocs_location_get, NULL,
|
||||
"Get the location of a VOCS instance <inst_index>",
|
||||
cmd_vcp_client_vocs_location_get, 2, 0),
|
||||
cmd_vcp_vol_ctlr_vocs_location_get, 2, 0),
|
||||
SHELL_CMD_ARG(vocs_location_set, NULL,
|
||||
"Set the location of a VOCS instance <inst_index> "
|
||||
"<location>",
|
||||
cmd_vcp_client_vocs_location_set, 3, 0),
|
||||
cmd_vcp_vol_ctlr_vocs_location_set, 3, 0),
|
||||
SHELL_CMD_ARG(vocs_offset_set, NULL,
|
||||
"Set the offset for a VOCS instance <inst_index> "
|
||||
"<offset>",
|
||||
cmd_vcp_client_vocs_offset_set, 3, 0),
|
||||
cmd_vcp_vol_ctlr_vocs_offset_set, 3, 0),
|
||||
SHELL_CMD_ARG(vocs_output_description_get, NULL,
|
||||
"Get the output description of a VOCS instance "
|
||||
"<inst_index>",
|
||||
cmd_vcp_client_vocs_output_description_get, 2, 0),
|
||||
cmd_vcp_vol_ctlr_vocs_output_description_get, 2, 0),
|
||||
SHELL_CMD_ARG(vocs_output_description_set, NULL,
|
||||
"Set the output description of a VOCS instance "
|
||||
"<inst_index> <description>",
|
||||
cmd_vcp_client_vocs_output_description_set, 3, 0),
|
||||
cmd_vcp_vol_ctlr_vocs_output_description_set, 3, 0),
|
||||
SHELL_CMD_ARG(aics_input_state_get, NULL,
|
||||
"Get the input state of a AICS instance <inst_index>",
|
||||
cmd_vcp_client_aics_input_state_get, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_input_state_get, 2, 0),
|
||||
SHELL_CMD_ARG(aics_gain_setting_get, NULL,
|
||||
"Get the gain settings of a AICS instance <inst_index>",
|
||||
cmd_vcp_client_aics_gain_setting_get, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_gain_setting_get, 2, 0),
|
||||
SHELL_CMD_ARG(aics_input_type_get, NULL,
|
||||
"Get the input type of a AICS instance <inst_index>",
|
||||
cmd_vcp_client_aics_input_type_get, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_input_type_get, 2, 0),
|
||||
SHELL_CMD_ARG(aics_input_status_get, NULL,
|
||||
"Get the input status of a AICS instance <inst_index>",
|
||||
cmd_vcp_client_aics_input_status_get, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_input_status_get, 2, 0),
|
||||
SHELL_CMD_ARG(aics_input_unmute, NULL,
|
||||
"Unmute the input of a AICS instance <inst_index>",
|
||||
cmd_vcp_client_aics_input_unmute, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_input_unmute, 2, 0),
|
||||
SHELL_CMD_ARG(aics_input_mute, NULL,
|
||||
"Mute the input of a AICS instance <inst_index>",
|
||||
cmd_vcp_client_aics_input_mute, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_input_mute, 2, 0),
|
||||
SHELL_CMD_ARG(aics_manual_input_gain_set, NULL,
|
||||
"Set the gain mode of a AICS instance to manual "
|
||||
"<inst_index>",
|
||||
cmd_vcp_client_aics_manual_input_gain_set, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_manual_input_gain_set, 2, 0),
|
||||
SHELL_CMD_ARG(aics_automatic_input_gain_set, NULL,
|
||||
"Set the gain mode of a AICS instance to automatic "
|
||||
"<inst_index>",
|
||||
cmd_vcp_client_aics_auto_input_gain_set, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_auto_input_gain_set, 2, 0),
|
||||
SHELL_CMD_ARG(aics_gain_set, NULL,
|
||||
"Set the gain of a AICS instance <inst_index> <gain>",
|
||||
cmd_vcp_client_aics_gain_set, 3, 0),
|
||||
cmd_vcp_vol_ctlr_aics_gain_set, 3, 0),
|
||||
SHELL_CMD_ARG(aics_input_description_get, NULL,
|
||||
"Read the input description of a AICS instance "
|
||||
"<inst_index>",
|
||||
cmd_vcp_client_aics_input_description_get, 2, 0),
|
||||
cmd_vcp_vol_ctlr_aics_input_description_get, 2, 0),
|
||||
SHELL_CMD_ARG(aics_input_description_set, NULL,
|
||||
"Set the input description of a AICS instance "
|
||||
"<inst_index> <description>",
|
||||
cmd_vcp_client_aics_input_description_set, 3, 0),
|
||||
cmd_vcp_vol_ctlr_aics_input_description_set, 3, 0),
|
||||
SHELL_SUBCMD_SET_END
|
||||
);
|
||||
|
||||
SHELL_CMD_ARG_REGISTER(vcp_client, &vcp_client_cmds,
|
||||
SHELL_CMD_ARG_REGISTER(vcp_vol_ctlr, &vcp_vol_ctlr_cmds,
|
||||
"Bluetooth VCP client shell commands",
|
||||
cmd_vcp_client, 1, 1);
|
||||
cmd_vcp_vol_ctlr, 1, 1);
|
|
@ -50,9 +50,9 @@ CONFIG_BT_AICS_CLIENT_MAX_INSTANCE_COUNT=4
|
|||
CONFIG_BT_VCP=y
|
||||
CONFIG_BT_VCP_VOCS_INSTANCE_COUNT=2
|
||||
CONFIG_BT_VCP_AICS_INSTANCE_COUNT=2
|
||||
CONFIG_BT_VCP_CLIENT=y
|
||||
CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST=2
|
||||
CONFIG_BT_VCP_CLIENT_MAX_AICS_INST=2
|
||||
CONFIG_BT_VCP_VOL_CTLR=y
|
||||
CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST=2
|
||||
CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST=2
|
||||
|
||||
CONFIG_BT_MICP_MIC_DEV=y
|
||||
CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT=2
|
||||
|
@ -116,9 +116,8 @@ CONFIG_BT_CAP_INITIATOR=y
|
|||
|
||||
# DEBUGGING
|
||||
CONFIG_BT_DEBUG_LOG=y
|
||||
<<<<<<< HEAD
|
||||
CONFIG_BT_VCS_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_VCS_CLIENT_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_VCP_VOL_CTLR_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_AICS_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_AICS_CLIENT_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_VOCS_LOG_LEVEL_DBG=y
|
||||
|
@ -130,21 +129,6 @@ CONFIG_BT_TBS_LOG_LEVEL_DBG=y
|
|||
CONFIG_BT_TBS_CLIENT_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_MCS_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_MCC_LOG_LEVEL_DBG=y
|
||||
=======
|
||||
CONFIG_BT_DEBUG_VCP=y
|
||||
CONFIG_BT_DEBUG_VCP_CLIENT=y
|
||||
CONFIG_BT_DEBUG_AICS=y
|
||||
CONFIG_BT_DEBUG_AICS_CLIENT=y
|
||||
CONFIG_BT_DEBUG_VOCS=y
|
||||
CONFIG_BT_DEBUG_VOCS_CLIENT=y
|
||||
CONFIG_BT_DEBUG_MICP_MIC_DEV=y
|
||||
CONFIG_BT_DEBUG_MICP_MIC_CTLR=y
|
||||
CONFIG_BT_DEBUG_MPL=y
|
||||
CONFIG_BT_DEBUG_TBS=y
|
||||
CONFIG_BT_DEBUG_TBS_CLIENT=y
|
||||
CONFIG_BT_DEBUG_MCS=y
|
||||
CONFIG_BT_DEBUG_MCC=y
|
||||
>>>>>>> 11ca5c474e (Bluetooth: Audio: Rename VCS to VCP)
|
||||
CONFIG_BT_OTS_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_OTS_CLIENT_LOG_LEVEL_DBG=y
|
||||
CONFIG_MCTL_LOG_LEVEL_DBG=y
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "bstests.h"
|
||||
|
||||
extern struct bst_test_list *test_vcp_install(struct bst_test_list *tests);
|
||||
extern struct bst_test_list *test_vcp_client_install(struct bst_test_list *tests);
|
||||
extern struct bst_test_list *test_vcp_vol_ctlr_install(struct bst_test_list *tests);
|
||||
extern struct bst_test_list *test_micp_install(struct bst_test_list *tests);
|
||||
extern struct bst_test_list *test_micp_mic_ctlr_install(struct bst_test_list *tests);
|
||||
extern struct bst_test_list *test_csip_set_member_install(struct bst_test_list *tests);
|
||||
|
@ -33,7 +33,7 @@ extern struct bst_test_list *test_ias_client_install(struct bst_test_list *tests
|
|||
|
||||
bst_test_install_t test_installers[] = {
|
||||
test_vcp_install,
|
||||
test_vcp_client_install,
|
||||
test_vcp_vol_ctlr_install,
|
||||
test_micp_install,
|
||||
test_micp_mic_ctlr_install,
|
||||
test_csip_set_member_install,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BT_VCP_CLIENT
|
||||
#ifdef CONFIG_BT_VCP_VOL_CTLR
|
||||
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#include <zephyr/bluetooth/audio/vcp.h>
|
||||
|
@ -544,7 +544,7 @@ static void test_main(void)
|
|||
return;
|
||||
}
|
||||
|
||||
err = bt_vcp_client_cb_register(&vcs_cbs);
|
||||
err = bt_vcp_vol_ctlr_cb_register(&vcs_cbs);
|
||||
if (err) {
|
||||
FAIL("CB register failed (err %d)\n", err);
|
||||
return;
|
||||
|
@ -562,21 +562,21 @@ static void test_main(void)
|
|||
|
||||
WAIT_FOR_COND(g_is_connected);
|
||||
|
||||
err = bt_vcp_discover(default_conn, &vcp);
|
||||
err = bt_vcp_vol_ctlr_discover(default_conn, &vcp);
|
||||
if (err) {
|
||||
FAIL("Failed to discover VCP %d", err);
|
||||
}
|
||||
|
||||
WAIT_FOR_COND(g_discovery_complete);
|
||||
|
||||
err = bt_vcp_included_get(vcp, &vcp_included);
|
||||
err = bt_vcp_vol_ctlr_included_get(vcp, &vcp_included);
|
||||
if (err) {
|
||||
FAIL("Failed to get VCP included services (err %d)\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
printk("Getting VCP client conn\n");
|
||||
err = bt_vcp_client_conn_get(vcp, &cached_conn);
|
||||
err = bt_vcp_vol_ctlr_conn_get(vcp, &cached_conn);
|
||||
if (err != 0) {
|
||||
FAIL("Could not get VCP client conn (err %d)\n", err);
|
||||
return;
|
||||
|
@ -588,7 +588,7 @@ static void test_main(void)
|
|||
|
||||
printk("Getting VCP volume state\n");
|
||||
g_cb = false;
|
||||
err = bt_vcp_vol_get(vcp);
|
||||
err = bt_vcp_vol_ctlr_read_state(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not get VCP volume (err %d)\n", err);
|
||||
return;
|
||||
|
@ -598,7 +598,7 @@ static void test_main(void)
|
|||
|
||||
printk("Getting VCP flags\n");
|
||||
g_cb = false;
|
||||
err = bt_vcp_flags_get(vcp);
|
||||
err = bt_vcp_vol_ctlr_read_flags(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not get VCP flags (err %d)\n", err);
|
||||
return;
|
||||
|
@ -608,7 +608,7 @@ static void test_main(void)
|
|||
|
||||
expected_volume = g_volume != 100 ? 100 : 101; /* ensure change */
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_vol_set(vcp, expected_volume);
|
||||
err = bt_vcp_vol_ctlr_set_vol(vcp, expected_volume);
|
||||
if (err) {
|
||||
FAIL("Could not set VCP volume (err %d)\n", err);
|
||||
return;
|
||||
|
@ -619,7 +619,7 @@ static void test_main(void)
|
|||
printk("Downing VCP volume\n");
|
||||
previous_volume = g_volume;
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_vol_down(vcp);
|
||||
err = bt_vcp_vol_ctlr_vol_down(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not get down VCP volume (err %d)\n", err);
|
||||
return;
|
||||
|
@ -630,7 +630,7 @@ static void test_main(void)
|
|||
printk("Upping VCP volume\n");
|
||||
previous_volume = g_volume;
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_vol_up(vcp);
|
||||
err = bt_vcp_vol_ctlr_vol_up(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not up VCP volume (err %d)\n", err);
|
||||
return;
|
||||
|
@ -641,7 +641,7 @@ static void test_main(void)
|
|||
printk("Muting VCP\n");
|
||||
expected_mute = 1;
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_mute(vcp);
|
||||
err = bt_vcp_vol_ctlr_mute(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not mute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -653,7 +653,7 @@ static void test_main(void)
|
|||
previous_volume = g_volume;
|
||||
expected_mute = 0;
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_unmute_vol_down(vcp);
|
||||
err = bt_vcp_vol_ctlr_unmute_vol_down(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not down and unmute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -665,7 +665,7 @@ static void test_main(void)
|
|||
printk("Muting VCP\n");
|
||||
expected_mute = 1;
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_mute(vcp);
|
||||
err = bt_vcp_vol_ctlr_mute(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not mute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -677,7 +677,7 @@ static void test_main(void)
|
|||
previous_volume = g_volume;
|
||||
expected_mute = 0;
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_unmute_vol_up(vcp);
|
||||
err = bt_vcp_vol_ctlr_unmute_vol_up(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not up and unmute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -689,7 +689,7 @@ static void test_main(void)
|
|||
printk("Muting VCP\n");
|
||||
expected_mute = 1;
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_mute(vcp);
|
||||
err = bt_vcp_vol_ctlr_mute(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not mute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -700,7 +700,7 @@ static void test_main(void)
|
|||
printk("Unmuting VCP\n");
|
||||
expected_mute = 0;
|
||||
g_write_complete = g_cb = false;
|
||||
err = bt_vcp_unmute(vcp);
|
||||
err = bt_vcp_vol_ctlr_unmute(vcp);
|
||||
if (err) {
|
||||
FAIL("Could not unmute VCP (err %d)\n", err);
|
||||
return;
|
||||
|
@ -708,13 +708,13 @@ static void test_main(void)
|
|||
WAIT_FOR_COND(g_mute == expected_mute && g_cb && g_write_complete);
|
||||
printk("VCP volume unmuted\n");
|
||||
|
||||
if (CONFIG_BT_VCP_CLIENT_VOCS > 0) {
|
||||
if (CONFIG_BT_VCP_VOL_CTLR_VOCS > 0) {
|
||||
if (test_vocs()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (CONFIG_BT_VCP_CLIENT_MAX_AICS_INST > 0) {
|
||||
if (CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST > 0) {
|
||||
if (test_aics()) {
|
||||
return;
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ static void test_main(void)
|
|||
|
||||
static const struct bst_test_instance test_vcs[] = {
|
||||
{
|
||||
.test_id = "vcp_client",
|
||||
.test_id = "vcp_vol_ctlr",
|
||||
.test_post_init_f = test_init,
|
||||
.test_tick_f = test_tick,
|
||||
.test_main_f = test_main
|
||||
|
@ -733,16 +733,16 @@ static const struct bst_test_instance test_vcs[] = {
|
|||
BSTEST_END_MARKER
|
||||
};
|
||||
|
||||
struct bst_test_list *test_vcp_client_install(struct bst_test_list *tests)
|
||||
struct bst_test_list *test_vcp_vol_ctlr_install(struct bst_test_list *tests)
|
||||
{
|
||||
return bst_add_tests(tests, test_vcs);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct bst_test_list *test_vcp_client_install(struct bst_test_list *tests)
|
||||
struct bst_test_list *test_vcp_vol_ctlr_install(struct bst_test_list *tests)
|
||||
{
|
||||
return tests;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BT_VCP_CLIENT */
|
||||
#endif /* CONFIG_BT_VCP_VOL_CTLR */
|
|
@ -43,7 +43,7 @@ Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
|
|||
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=vcp -rs=23
|
||||
|
||||
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
|
||||
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=vcp_client -rs=46
|
||||
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=vcp_vol_ctlr -rs=46
|
||||
|
||||
# Simulation time should be larger than the WAIT_TIME in common.h
|
||||
Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \
|
||||
|
|
|
@ -73,9 +73,9 @@ CONFIG_BT_AICS_CLIENT_MAX_INSTANCE_COUNT=2
|
|||
CONFIG_BT_VCP=y
|
||||
CONFIG_BT_VCP_VOCS_INSTANCE_COUNT=1
|
||||
CONFIG_BT_VCP_AICS_INSTANCE_COUNT=1
|
||||
CONFIG_BT_VCP_CLIENT=y
|
||||
CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST=1
|
||||
CONFIG_BT_VCP_CLIENT_MAX_AICS_INST=1
|
||||
CONFIG_BT_VCP_VOL_CTLR=y
|
||||
CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST=1
|
||||
CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST=1
|
||||
|
||||
CONFIG_BT_MICP_MIC_DEV=y
|
||||
CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT=1
|
||||
|
@ -153,7 +153,7 @@ CONFIG_BT_AUDIO_BROADCAST_SINK_LOG_LEVEL_DBG=y
|
|||
CONFIG_BT_HAS_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_HAS_CLIENT_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_TBS_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_VCP_CLIENT_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_VCP_VOL_CTLR_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_VCP_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_MICP_MIC_CTLR_LOG_LEVEL_DBG=y
|
||||
CONFIG_BT_MICP_MIC_DEV_LOG_LEVEL_DBG=y
|
||||
|
|
|
@ -76,34 +76,34 @@ tests:
|
|||
- CONFIG_BT_VCP_AICS_INSTANCE_COUNT=0
|
||||
- CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT=0
|
||||
tags: bluetooth
|
||||
bluetooth.shell.audio.no_vcp_client:
|
||||
bluetooth.shell.audio.no_vcp_vol_ctlr:
|
||||
extra_args: CONF_FILE="audio.conf"
|
||||
build_only: true
|
||||
platform_allow: native_posix
|
||||
extra_configs:
|
||||
- CONFIG_BT_VCP_CLIENT=n
|
||||
- CONFIG_BT_VCP_VOL_CTLR=n
|
||||
tags: bluetooth
|
||||
bluetooth.shell.audio.no_vcs_vcp_client:
|
||||
bluetooth.shell.audio.no_vcs_vcp_vol_ctlr:
|
||||
extra_args: CONF_FILE="audio.conf"
|
||||
build_only: true
|
||||
platform_allow: native_posix
|
||||
extra_configs:
|
||||
- CONFIG_BT_VCP=n
|
||||
- CONFIG_BT_VCP_CLIENT=n
|
||||
- CONFIG_BT_VCP_VOL_CTLR=n
|
||||
tags: bluetooth
|
||||
bluetooth.shell.audio.vcp_client_no_aics_client:
|
||||
bluetooth.shell.audio.vcp_vol_ctlr_no_aics_client:
|
||||
extra_args: CONF_FILE="audio.conf"
|
||||
build_only: true
|
||||
platform_allow: native_posix
|
||||
extra_configs:
|
||||
- CONFIG_BT_VCP_CLIENT_MAX_AICS_INST=0
|
||||
- CONFIG_BT_VCP_VOL_CTLR_MAX_AICS_INST=0
|
||||
tags: bluetooth
|
||||
bluetooth.shell.audio.vcp_client_no_vocs_client:
|
||||
bluetooth.shell.audio.vcp_vol_ctlr_no_vocs_client:
|
||||
extra_args: CONF_FILE="audio.conf"
|
||||
build_only: true
|
||||
platform_allow: native_posix
|
||||
extra_configs:
|
||||
- CONFIG_BT_VCP_CLIENT_MAX_VOCS_INST=0
|
||||
- CONFIG_BT_VCP_VOL_CTLR_MAX_VOCS_INST=0
|
||||
tags: bluetooth
|
||||
bluetooth.shell.audio.no_micp_mic_dev:
|
||||
extra_args: CONF_FILE="audio.conf"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue