diff --git a/include/zephyr/bluetooth/audio/vcp.h b/include/zephyr/bluetooth/audio/vcp.h index 44118f227b1..7235102a135 100644 --- a/include/zephyr/bluetooth/audio/vcp.h +++ b/include/zephyr/bluetooth/audio/vcp.h @@ -319,72 +319,6 @@ int bt_vcp_unmute(struct bt_vcp *vcp); */ int bt_vcp_mute(struct bt_vcp *vcp); -/** - * @brief Read the Volume Offset Control Service offset state. - * - * @param vcp Volume Control Service instance pointer. - * @param inst Pointer to the Volume Offset Control Service instance. - * - * @return 0 if success, errno on failure. - */ -int bt_vcp_vocs_state_get(struct bt_vcp *vcp, struct bt_vocs *inst); - -/** - * @brief Read the Volume Offset Control Service location. - * - * @param vcp Volume Control Service instance pointer. - * @param inst Pointer to the Volume Offset Control Service instance. - * - * @return 0 if success, errno on failure. - */ -int bt_vcp_vocs_location_get(struct bt_vcp *vcp, struct bt_vocs *inst); - -/** - * @brief Set the Volume Offset Control Service location. - * - * @param vcp Volume Control Service instance pointer. - * @param inst Pointer to the Volume Offset Control Service instance. - * @param location The location to set. - * - * @return 0 if success, errno on failure. - */ -int bt_vcp_vocs_location_set(struct bt_vcp *vcp, struct bt_vocs *inst, - uint8_t location); - -/** - * @brief Set the Volume Offset Control Service offset state. - * - * @param vcp Volume Control Service instance pointer. - * @param inst Pointer to the Volume Offset Control Service instance. - * @param offset The offset to set (-255 to 255). - * - * @return 0 if success, errno on failure. - */ -int bt_vcp_vocs_state_set(struct bt_vcp *vcp, struct bt_vocs *inst, - int16_t offset); - -/** - * @brief Read the Volume Offset Control Service output description. - * - * @param vcp Volume Control Service instance pointer. - * @param inst Pointer to the Volume Offset Control Service instance. - * - * @return 0 if success, errno on failure. - */ -int bt_vcp_vocs_description_get(struct bt_vcp *vcp, struct bt_vocs *inst); - -/** - * @brief Set the Volume Offset Control Service description. - * - * @param vcp Volume Control Service instance pointer. - * @param inst Pointer to the Volume Offset Control Service instance. - * @param description The description to set. - * - * @return 0 if success, errno on failure. - */ -int bt_vcp_vocs_description_set(struct bt_vcp *vcp, struct bt_vocs *inst, - const char *description); - /** * @brief Registers the callbacks used by the Volume Control Service client. * diff --git a/subsys/bluetooth/audio/vcp.c b/subsys/bluetooth/audio/vcp.c index b74855a1cb5..3d2d763eaed 100644 --- a/subsys/bluetooth/audio/vcp.c +++ b/subsys/bluetooth/audio/vcp.c @@ -27,23 +27,6 @@ #include LOG_MODULE_REGISTER(bt_vcp); -static bool valid_vocs_inst(struct bt_vcp *vcp, struct bt_vocs *vocs) -{ - if (vocs == NULL) { - return false; - } - -#if defined(CONFIG_BT_VCP) - for (int i = 0; i < ARRAY_SIZE(vcp->srv.vocs_insts); i++) { - if (vcp->srv.vocs_insts[i] == vocs) { - return true; - } - } -#endif /* CONFIG_BT_VCP */ - - return false; -} - #if defined(CONFIG_BT_VCP) #define VOLUME_DOWN(current_vol) \ @@ -660,120 +643,3 @@ int bt_vcp_mute(struct bt_vcp *vcp) return -EOPNOTSUPP; #endif /* CONFIG_BT_VCP */ } - -int bt_vcp_vocs_state_get(struct bt_vcp *vcp, struct bt_vocs *inst) -{ - CHECKIF(vcp == NULL) { - LOG_DBG("NULL vcp instance"); - return -EINVAL; - } - - if (IS_ENABLED(CONFIG_BT_VCP_CLIENT_VOCS) && - bt_vcp_client_valid_vocs_inst(vcp, inst)) { - return bt_vocs_state_get(inst); - } - - if (IS_ENABLED(CONFIG_BT_VCP_VOCS) && valid_vocs_inst(vcp, inst)) { - return bt_vocs_state_get(inst); - } - - return -EOPNOTSUPP; -} - -int bt_vcp_vocs_location_get(struct bt_vcp *vcp, struct bt_vocs *inst) -{ - CHECKIF(vcp == NULL) { - LOG_DBG("NULL vcp instance"); - return -EINVAL; - } - - if (IS_ENABLED(CONFIG_BT_VCP_CLIENT_VOCS) && - bt_vcp_client_valid_vocs_inst(vcp, inst)) { - return bt_vocs_location_get(inst); - } - - if (IS_ENABLED(CONFIG_BT_VCP_VOCS) && valid_vocs_inst(vcp, inst)) { - return bt_vocs_location_get(inst); - } - - return -EOPNOTSUPP; -} - -int bt_vcp_vocs_location_set(struct bt_vcp *vcp, struct bt_vocs *inst, - uint8_t location) -{ - CHECKIF(vcp == NULL) { - LOG_DBG("NULL vcp instance"); - return -EINVAL; - } - - if (IS_ENABLED(CONFIG_BT_VCP_CLIENT_VOCS) && - bt_vcp_client_valid_vocs_inst(vcp, inst)) { - return bt_vocs_location_set(inst, location); - } - - if (IS_ENABLED(CONFIG_BT_VCP_VOCS) && valid_vocs_inst(vcp, inst)) { - return bt_vocs_location_set(inst, location); - } - - return -EOPNOTSUPP; -} - -int bt_vcp_vocs_state_set(struct bt_vcp *vcp, struct bt_vocs *inst, - int16_t offset) -{ - CHECKIF(vcp == NULL) { - LOG_DBG("NULL vcp instance"); - return -EINVAL; - } - - if (IS_ENABLED(CONFIG_BT_VCP_CLIENT_VOCS) && - bt_vcp_client_valid_vocs_inst(vcp, inst)) { - return bt_vocs_state_set(inst, offset); - } - - if (IS_ENABLED(CONFIG_BT_VCP_VOCS) && valid_vocs_inst(vcp, inst)) { - return bt_vocs_state_set(inst, offset); - } - - return -EOPNOTSUPP; -} - -int bt_vcp_vocs_description_get(struct bt_vcp *vcp, struct bt_vocs *inst) -{ - CHECKIF(vcp == NULL) { - LOG_DBG("NULL vcp instance"); - return -EINVAL; - } - - if (IS_ENABLED(CONFIG_BT_VCP_CLIENT_VOCS) && - bt_vcp_client_valid_vocs_inst(vcp, inst)) { - return bt_vocs_description_get(inst); - } - - if (IS_ENABLED(CONFIG_BT_VCP_VOCS) && valid_vocs_inst(vcp, inst)) { - return bt_vocs_description_get(inst); - } - - return -EOPNOTSUPP; -} - -int bt_vcp_vocs_description_set(struct bt_vcp *vcp, struct bt_vocs *inst, - const char *description) -{ - CHECKIF(vcp == NULL) { - LOG_DBG("NULL vcp instance"); - return -EINVAL; - } - - if (IS_ENABLED(CONFIG_BT_VCP_CLIENT_VOCS) && - bt_vcp_client_valid_vocs_inst(vcp, inst)) { - return bt_vocs_description_set(inst, description); - } - - if (IS_ENABLED(CONFIG_BT_VCP_VOCS) && valid_vocs_inst(vcp, inst)) { - return bt_vocs_description_set(inst, description); - } - - return -EOPNOTSUPP; -} diff --git a/subsys/bluetooth/audio/vcp_client.c b/subsys/bluetooth/audio/vcp_client.c index 199d7593a6b..72320750bb2 100644 --- a/subsys/bluetooth/audio/vcp_client.c +++ b/subsys/bluetooth/audio/vcp_client.c @@ -34,33 +34,6 @@ static struct bt_vcp_cb *vcp_client_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); -bool bt_vcp_client_valid_vocs_inst(struct bt_vcp *vcp, struct bt_vocs *vocs) -{ - if (vcp == NULL) { - return false; - } - - if (!vcp->client_instance) { - return false; - } - - if (vcp->cli.conn == NULL) { - return false; - } - - if (vocs == NULL) { - return false; - } - - for (int i = 0; i < ARRAY_SIZE(vcp->cli.vocs); i++) { - if (vcp->cli.vocs[i] == vocs) { - return true; - } - } - - return false; -} - static uint8_t vcp_client_notify_handler(struct bt_conn *conn, struct bt_gatt_subscribe_params *params, const void *data, uint16_t length) diff --git a/subsys/bluetooth/audio/vcp_internal.h b/subsys/bluetooth/audio/vcp_internal.h index c841600585e..69b0fbc4f72 100644 --- a/subsys/bluetooth/audio/vcp_internal.h +++ b/subsys/bluetooth/audio/vcp_internal.h @@ -104,6 +104,4 @@ 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); - -bool bt_vcp_client_valid_vocs_inst(struct bt_vcp *vcp, struct bt_vocs *vocs); #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_VCP_INTERNAL_*/ diff --git a/subsys/bluetooth/shell/vcp.c b/subsys/bluetooth/shell/vcp.c index cf4c6e4192e..38905407741 100644 --- a/subsys/bluetooth/shell/vcp.c +++ b/subsys/bluetooth/shell/vcp.c @@ -392,7 +392,7 @@ static int cmd_vcs_vocs_state_get(const struct shell *sh, size_t argc, return -ENOEXEC; } - result = bt_vcp_vocs_state_get(NULL, vcp_included.vocs[index]); + result = bt_vocs_state_get(vcp_included.vocs[index]); if (result) { shell_print(sh, "Fail: %d", result); } @@ -412,7 +412,7 @@ static int cmd_vcs_vocs_location_get(const struct shell *sh, size_t argc, return -ENOEXEC; } - result = bt_vcp_vocs_location_get(NULL, vcp_included.vocs[index]); + result = bt_vocs_location_get(vcp_included.vocs[index]); if (result) { shell_print(sh, "Fail: %d", result); } @@ -439,7 +439,7 @@ static int cmd_vcs_vocs_location_set(const struct shell *sh, size_t argc, } - result = bt_vcp_vocs_location_set(NULL, vcp_included.vocs[index], + result = bt_vocs_location_set(vcp_included.vocs[index], location); if (result) { shell_print(sh, "Fail: %d", result); @@ -467,7 +467,7 @@ static int cmd_vcs_vocs_offset_set(const struct shell *sh, size_t argc, return -ENOEXEC; } - result = bt_vcp_vocs_state_set(NULL, vcp_included.vocs[index], offset); + result = bt_vocs_state_set(vcp_included.vocs[index], offset); if (result) { shell_print(sh, "Fail: %d", result); } @@ -487,7 +487,7 @@ static int cmd_vcs_vocs_output_description_get(const struct shell *sh, return -ENOEXEC; } - result = bt_vcp_vocs_description_get(NULL, vcp_included.vocs[index]); + result = bt_vocs_description_get(vcp_included.vocs[index]); if (result) { shell_print(sh, "Fail: %d", result); } @@ -508,7 +508,7 @@ static int cmd_vcs_vocs_output_description_set(const struct shell *sh, return -ENOEXEC; } - result = bt_vcp_vocs_description_set(NULL, vcp_included.vocs[index], + result = bt_vocs_description_set(vcp_included.vocs[index], description); if (result) { shell_print(sh, "Fail: %d", result); diff --git a/subsys/bluetooth/shell/vcp_client.c b/subsys/bluetooth/shell/vcp_client.c index edf3c49fa4a..9078c04e934 100644 --- a/subsys/bluetooth/shell/vcp_client.c +++ b/subsys/bluetooth/shell/vcp_client.c @@ -537,7 +537,7 @@ static int cmd_vcp_client_vocs_state_get(const struct shell *sh, size_t argc, return -ENOEXEC; } - result = bt_vcp_vocs_state_get(vcp, vcp_included.vocs[index]); + result = bt_vocs_state_get(vcp_included.vocs[index]); if (result != 0) { shell_print(sh, "Fail: %d", result); } @@ -562,7 +562,7 @@ static int cmd_vcp_client_vocs_location_get(const struct shell *sh, return -ENOEXEC; } - result = bt_vcp_vocs_location_get(vcp, vcp_included.vocs[index]); + result = bt_vocs_location_get(vcp_included.vocs[index]); if (result != 0) { shell_print(sh, "Fail: %d", result); } @@ -595,7 +595,7 @@ static int cmd_vcp_client_vocs_location_set(const struct shell *sh, } - result = bt_vcp_vocs_location_set(vcp, vcp_included.vocs[index], + result = bt_vocs_location_set(vcp_included.vocs[index], location); if (result != 0) { shell_print(sh, "Fail: %d", result); @@ -628,7 +628,7 @@ static int cmd_vcp_client_vocs_offset_set(const struct shell *sh, return -ENOEXEC; } - result = bt_vcp_vocs_state_set(vcp, vcp_included.vocs[index], + result = bt_vocs_state_set(vcp_included.vocs[index], offset); if (result != 0) { shell_print(sh, "Fail: %d", result); @@ -654,7 +654,7 @@ static int cmd_vcp_client_vocs_output_description_get(const struct shell *sh, return -ENOEXEC; } - result = bt_vcp_vocs_description_get(vcp, vcp_included.vocs[index]); + result = bt_vocs_description_get(vcp_included.vocs[index]); if (result != 0) { shell_print(sh, "Fail: %d", result); } @@ -680,7 +680,7 @@ static int cmd_vcp_client_vocs_output_description_set(const struct shell *sh, return -ENOEXEC; } - result = bt_vcp_vocs_description_set(vcp, vcp_included.vocs[index], + result = bt_vocs_description_set(vcp_included.vocs[index], description); if (result != 0) { shell_print(sh, "Fail: %d", result); diff --git a/tests/bluetooth/bsim_bt/bsim_test_audio/src/vcp_client_test.c b/tests/bluetooth/bsim_bt/bsim_test_audio/src/vcp_client_test.c index d6deda453c5..5214a8f51c0 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_audio/src/vcp_client_test.c +++ b/tests/bluetooth/bsim_bt/bsim_test_audio/src/vcp_client_test.c @@ -458,7 +458,7 @@ static int test_vocs(void) printk("Getting VOCS state\n"); g_cb = false; - err = bt_vcp_vocs_state_get(vcp, vcp_included.vocs[0]); + err = bt_vocs_state_get(vcp_included.vocs[0]); if (err) { FAIL("Could not get VOCS state (err %d)\n", err); return err; @@ -468,7 +468,7 @@ static int test_vocs(void) printk("Getting VOCS location\n"); g_cb = false; - err = bt_vcp_vocs_location_get(vcp, vcp_included.vocs[0]); + err = bt_vocs_location_get(vcp_included.vocs[0]); if (err) { FAIL("Could not get VOCS location (err %d)\n", err); return err; @@ -478,7 +478,7 @@ static int test_vocs(void) printk("Getting VOCS description\n"); g_cb = false; - err = bt_vcp_vocs_description_get(vcp, vcp_included.vocs[0]); + err = bt_vocs_description_get(vcp_included.vocs[0]); if (err) { FAIL("Could not get VOCS description (err %d)\n", err); return err; @@ -489,7 +489,7 @@ static int test_vocs(void) printk("Setting VOCS location\n"); expected_location = g_vocs_location + 1; g_cb = false; - err = bt_vcp_vocs_location_set(vcp, vcp_included.vocs[0], + err = bt_vocs_location_set(vcp_included.vocs[0], expected_location); if (err) { FAIL("Could not set VOCS location (err %d)\n", err); @@ -501,7 +501,7 @@ static int test_vocs(void) printk("Setting VOCS state\n"); expected_offset = g_vocs_offset + 1; g_write_complete = g_cb = false; - err = bt_vcp_vocs_state_set(vcp, vcp_included.vocs[0], expected_offset); + err = bt_vocs_state_set(vcp_included.vocs[0], expected_offset); if (err) { FAIL("Could not set VOCS state (err %d)\n", err); return err; @@ -514,7 +514,7 @@ static int test_vocs(void) sizeof(expected_description)); expected_description[sizeof(expected_description) - 1] = '\0'; g_cb = false; - err = bt_vcp_vocs_description_set(vcp, vcp_included.vocs[0], + err = bt_vocs_description_set(vcp_included.vocs[0], expected_description); if (err) { FAIL("Could not set VOCS description (err %d)\n", err); diff --git a/tests/bluetooth/bsim_bt/bsim_test_audio/src/vcp_test.c b/tests/bluetooth/bsim_bt/bsim_test_audio/src/vcp_test.c index 9c3f5956bcd..f16f02fd5bf 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_audio/src/vcp_test.c +++ b/tests/bluetooth/bsim_bt/bsim_test_audio/src/vcp_test.c @@ -364,7 +364,7 @@ static int test_vocs_standalone(void) printk("Getting VOCS state\n"); g_cb = false; - err = bt_vcp_vocs_state_get(vcp, vcp_included.vocs[0]); + err = bt_vocs_state_get(vcp_included.vocs[0]); if (err) { FAIL("Could not get VOCS state (err %d)\n", err); return err; @@ -374,7 +374,7 @@ static int test_vocs_standalone(void) printk("Getting VOCS location\n"); g_cb = false; - err = bt_vcp_vocs_location_get(vcp, vcp_included.vocs[0]); + err = bt_vocs_location_get(vcp_included.vocs[0]); if (err) { FAIL("Could not get VOCS location (err %d)\n", err); return err; @@ -384,7 +384,7 @@ static int test_vocs_standalone(void) printk("Getting VOCS description\n"); g_cb = false; - err = bt_vcp_vocs_description_get(vcp, vcp_included.vocs[0]); + err = bt_vocs_description_get(vcp_included.vocs[0]); if (err) { FAIL("Could not get VOCS description (err %d)\n", err); return err; @@ -394,7 +394,7 @@ static int test_vocs_standalone(void) printk("Setting VOCS location\n"); expected_location = g_vocs_location + 1; - err = bt_vcp_vocs_location_set(vcp, vcp_included.vocs[0], + err = bt_vocs_location_set(vcp_included.vocs[0], expected_location); if (err) { FAIL("Could not set VOCS location (err %d)\n", err); @@ -405,7 +405,7 @@ static int test_vocs_standalone(void) printk("Setting VOCS state\n"); expected_offset = g_vocs_offset + 1; - err = bt_vcp_vocs_state_set(vcp, vcp_included.vocs[0], expected_offset); + err = bt_vocs_state_set(vcp_included.vocs[0], expected_offset); if (err) { FAIL("Could not set VOCS state (err %d)\n", err); return err; @@ -418,7 +418,7 @@ static int test_vocs_standalone(void) sizeof(expected_description) - 1); expected_description[sizeof(expected_description) - 1] = '\0'; g_cb = false; - err = bt_vcp_vocs_description_set(vcp, vcp_included.vocs[0], + err = bt_vocs_description_set(vcp_included.vocs[0], expected_description); if (err) { FAIL("Could not set VOCS description (err %d)\n", err);