From 709af79c933a77be7e8597c7006cfb16ee617c1c Mon Sep 17 00:00:00 2001 From: Cheng Chang Date: Fri, 17 Oct 2025 09:30:31 +0800 Subject: [PATCH] bluetooth: shell: a2dp: fix warning when enable sink or source only add #if defined() to control unused codes. Signed-off-by: Cheng Chang --- subsys/bluetooth/host/classic/shell/a2dp.c | 30 ++++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/subsys/bluetooth/host/classic/shell/a2dp.c b/subsys/bluetooth/host/classic/shell/a2dp.c index 8b60c8425e5c5..2802731dab8a9 100644 --- a/subsys/bluetooth/host/classic/shell/a2dp.c +++ b/subsys/bluetooth/host/classic/shell/a2dp.c @@ -433,6 +433,7 @@ static void stream_suspended(struct bt_a2dp_stream *stream) bt_shell_print("stream suspended"); } +#if defined(CONFIG_BT_A2DP_SINK) static void sink_sbc_streamer_data(struct bt_a2dp_stream *stream, struct net_buf *buf, uint16_t seq_num, uint32_t ts) { @@ -454,6 +455,17 @@ static void stream_recv(struct bt_a2dp_stream *stream, sink_sbc_streamer_data(stream, buf, seq_num, ts); } +static void app_delay_report_rsp(struct bt_a2dp_stream *stream, uint8_t rsp_err_code) +{ + if (rsp_err_code == 0) { + bt_shell_print("success to send report delay"); + } else { + bt_shell_print("fail to send report delay"); + } +} +#endif + +#if defined(CONFIG_BT_A2DP_SOURCE) static int app_delay_report_req(struct bt_a2dp_stream *stream, uint16_t value, uint8_t *rsp_err_code) { @@ -462,14 +474,11 @@ static int app_delay_report_req(struct bt_a2dp_stream *stream, uint16_t value, return 0; } -static void app_delay_report_rsp(struct bt_a2dp_stream *stream, uint8_t rsp_err_code) +static void delay_report(struct bt_a2dp_stream *stream, uint16_t value) { - if (rsp_err_code == 0) { - bt_shell_print("success to send report delay"); - } else { - bt_shell_print("fail to send report delay"); - } + bt_shell_print("received delay report: %d 1/10ms", value); } +#endif static int app_get_config_req(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code) { @@ -621,11 +630,6 @@ static int cmd_disconnect(const struct shell *sh, int32_t argc, char *argv[]) return 0; } -static void delay_report(struct bt_a2dp_stream *stream, uint16_t value) -{ - bt_shell_print("received delay report: %d 1/10ms", value); -} - static struct bt_a2dp_stream_ops stream_ops = { .configured = stream_configured, .established = stream_established, @@ -838,6 +842,7 @@ static int cmd_send_media(const struct shell *sh, int32_t argc, char *argv[]) return 0; } +#if defined(CONFIG_BT_A2DP_SINK) static int cmd_send_delay_report(const struct shell *sh, int32_t argc, char *argv[]) { int err; @@ -854,6 +859,7 @@ static int cmd_send_delay_report(const struct shell *sh, int32_t argc, char *arg return 0; } +#endif static int cmd_get_config(const struct shell *sh, int32_t argc, char *argv[]) { @@ -886,7 +892,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(a2dp_cmds, SHELL_CMD_ARG(suspend, NULL, "\"suspend the stream\"", cmd_suspend, 1, 0), SHELL_CMD_ARG(abort, NULL, "\"abort the stream\"", cmd_abort, 1, 0), SHELL_CMD_ARG(send_media, NULL, HELP_NONE, cmd_send_media, 1, 0), +#if defined(CONFIG_BT_A2DP_SINK) SHELL_CMD_ARG(send_delay_report, NULL, HELP_NONE, cmd_send_delay_report, 1, 0), +#endif SHELL_CMD_ARG(get_config, NULL, HELP_NONE, cmd_get_config, 1, 0), SHELL_SUBCMD_SET_END );