From e71c4a728bc0d8b6b964d2c5fd3c297f2f22f351 Mon Sep 17 00:00:00 2001 From: Pisit Sawangvonganan Date: Fri, 3 Jan 2025 15:16:31 +0700 Subject: [PATCH 1/5] bluetooth: shell: move `bt_shell_private.c` to `common` folder Relocated `bt_shell_private.c` to the `common` folder to enable independent use between `BT_SHELL` and `BT_MESH_SHELL`. Signed-off-by: Pisit Sawangvonganan --- subsys/bluetooth/Kconfig | 1 + subsys/bluetooth/common/CMakeLists.txt | 1 + subsys/bluetooth/common/Kconfig | 4 ++++ subsys/bluetooth/{host/shell => common}/bt_shell_private.c | 0 subsys/bluetooth/{host/shell => common}/bt_shell_private.h | 0 subsys/bluetooth/host/shell/CMakeLists.txt | 5 +---- subsys/bluetooth/host/shell/bt.c | 2 +- subsys/bluetooth/host/shell/cs.c | 2 +- subsys/bluetooth/host/shell/gatt.c | 2 +- subsys/bluetooth/host/shell/iso.c | 2 +- subsys/bluetooth/host/shell/l2cap.c | 2 +- 11 files changed, 12 insertions(+), 9 deletions(-) rename subsys/bluetooth/{host/shell => common}/bt_shell_private.c (100%) rename subsys/bluetooth/{host/shell => common}/bt_shell_private.h (100%) diff --git a/subsys/bluetooth/Kconfig b/subsys/bluetooth/Kconfig index 1665059ce333e..1898fd10b1cd0 100644 --- a/subsys/bluetooth/Kconfig +++ b/subsys/bluetooth/Kconfig @@ -236,6 +236,7 @@ rsource "Kconfig.logging" config BT_SHELL bool "Bluetooth shell" select SHELL + select BT_PRIVATE_SHELL select BT_TICKER_NEXT_SLOT_GET if BT_LL_SW_SPLIT help Activate shell module that provides Bluetooth commands to the diff --git a/subsys/bluetooth/common/CMakeLists.txt b/subsys/bluetooth/common/CMakeLists.txt index 2138b23c7d51a..d088d366cff77 100644 --- a/subsys/bluetooth/common/CMakeLists.txt +++ b/subsys/bluetooth/common/CMakeLists.txt @@ -7,5 +7,6 @@ zephyr_library_sources(dummy.c) zephyr_library_sources(bt_str.c) zephyr_library_sources_ifdef(CONFIG_BT_RPA rpa.c) +zephyr_library_sources_ifdef(CONFIG_BT_PRIVATE_SHELL bt_shell_private.c) zephyr_library_link_libraries(subsys__bluetooth) diff --git a/subsys/bluetooth/common/Kconfig b/subsys/bluetooth/common/Kconfig index afba64312ef04..a9c17ebceec55 100644 --- a/subsys/bluetooth/common/Kconfig +++ b/subsys/bluetooth/common/Kconfig @@ -244,6 +244,10 @@ config BT_RPA bool depends on BT_HOST_CRYPTO || BT_CTLR_CRYPTO +config BT_PRIVATE_SHELL + bool + default n + config BT_ASSERT bool "Custom Bluetooth assert implementation" default y diff --git a/subsys/bluetooth/host/shell/bt_shell_private.c b/subsys/bluetooth/common/bt_shell_private.c similarity index 100% rename from subsys/bluetooth/host/shell/bt_shell_private.c rename to subsys/bluetooth/common/bt_shell_private.c diff --git a/subsys/bluetooth/host/shell/bt_shell_private.h b/subsys/bluetooth/common/bt_shell_private.h similarity index 100% rename from subsys/bluetooth/host/shell/bt_shell_private.h rename to subsys/bluetooth/common/bt_shell_private.h diff --git a/subsys/bluetooth/host/shell/CMakeLists.txt b/subsys/bluetooth/host/shell/CMakeLists.txt index 73ff18086f315..98f1e6ac2a590 100644 --- a/subsys/bluetooth/host/shell/CMakeLists.txt +++ b/subsys/bluetooth/host/shell/CMakeLists.txt @@ -1,10 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 zephyr_library() -zephyr_library_sources( - bt.c - bt_shell_private.c - ) +zephyr_library_sources(bt.c) zephyr_library_sources_ifdef(CONFIG_BT_CONN gatt.c) zephyr_library_sources_ifdef(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL l2cap.c) zephyr_library_sources_ifdef(CONFIG_BT_ISO iso.c) diff --git a/subsys/bluetooth/host/shell/bt.c b/subsys/bluetooth/host/shell/bt.c index 50847d3c7b977..45a5860344518 100644 --- a/subsys/bluetooth/host/shell/bt.c +++ b/subsys/bluetooth/host/shell/bt.c @@ -35,7 +35,7 @@ #include #include -#include "bt_shell_private.h" +#include "common/bt_shell_private.h" #include "audio/shell/audio.h" #include "controller/ll_sw/shell/ll.h" diff --git a/subsys/bluetooth/host/shell/cs.c b/subsys/bluetooth/host/shell/cs.c index 2597063cbed47..ee9c417902799 100644 --- a/subsys/bluetooth/host/shell/cs.c +++ b/subsys/bluetooth/host/shell/cs.c @@ -25,7 +25,7 @@ #include #include "host/shell/bt.h" -#include "host/shell/bt_shell_private.h" +#include "common/bt_shell_private.h" static int check_cs_sync_antenna_selection_input(uint16_t input) { diff --git a/subsys/bluetooth/host/shell/gatt.c b/subsys/bluetooth/host/shell/gatt.c index 080361cc29b3f..35543a0e285a9 100644 --- a/subsys/bluetooth/host/shell/gatt.c +++ b/subsys/bluetooth/host/shell/gatt.c @@ -27,7 +27,7 @@ #include #include "host/shell/bt.h" -#include "host/shell/bt_shell_private.h" +#include "common/bt_shell_private.h" #if defined(CONFIG_BT_GATT_CLIENT) || defined(CONFIG_BT_GATT_DYNAMIC_DB) extern uint8_t selected_id; diff --git a/subsys/bluetooth/host/shell/iso.c b/subsys/bluetooth/host/shell/iso.c index 43e8fb80c2634..3b6340c5e9cbd 100644 --- a/subsys/bluetooth/host/shell/iso.c +++ b/subsys/bluetooth/host/shell/iso.c @@ -23,7 +23,7 @@ #include #include "host/shell/bt.h" -#include "host/shell/bt_shell_private.h" +#include "common/bt_shell_private.h" #if defined(CONFIG_BT_ISO_TX) #define DEFAULT_IO_QOS \ diff --git a/subsys/bluetooth/host/shell/l2cap.c b/subsys/bluetooth/host/shell/l2cap.c index 48c568c11a0ae..07fc465163c8a 100644 --- a/subsys/bluetooth/host/shell/l2cap.c +++ b/subsys/bluetooth/host/shell/l2cap.c @@ -30,7 +30,7 @@ #include #include "host/shell/bt.h" -#include "host/shell/bt_shell_private.h" +#include "common/bt_shell_private.h" #define CREDITS 10 #define DATA_MTU (23 * CREDITS) From 3d421ae2d282b86b26ae5fed6cf372f63959c632 Mon Sep 17 00:00:00 2001 From: Pisit Sawangvonganan Date: Fri, 3 Jan 2025 15:26:34 +0700 Subject: [PATCH 2/5] bluetooth: audio: shell: eliminate `ctx_shell` usage This change aims to eliminate the dependency on `ctx_shell` in the Bluetooth `audio/shell/*`, making the code more maintainable. Replaced `shell_*` functions that depended on `ctx_shell` with the appropriate `bt_shell_*` functions. Signed-off-by: Pisit Sawangvonganan --- subsys/bluetooth/audio/shell/audio.h | 355 +++++++++--------- subsys/bluetooth/audio/shell/bap.c | 316 ++++++++-------- .../audio/shell/bap_broadcast_assistant.c | 108 +++--- .../audio/shell/bap_scan_delegator.c | 71 ++-- subsys/bluetooth/audio/shell/cap_acceptor.c | 18 +- subsys/bluetooth/audio/shell/cap_commander.c | 44 +-- subsys/bluetooth/audio/shell/cap_initiator.c | 53 ++- .../audio/shell/csip_set_coordinator.c | 54 ++- .../bluetooth/audio/shell/csip_set_member.c | 18 +- subsys/bluetooth/audio/shell/gmap.c | 15 +- subsys/bluetooth/audio/shell/has.c | 3 +- subsys/bluetooth/audio/shell/has_client.c | 27 +- subsys/bluetooth/audio/shell/mcc.c | 208 +++++----- .../bluetooth/audio/shell/media_controller.c | 203 +++++----- subsys/bluetooth/audio/shell/micp_mic_ctlr.c | 92 ++--- subsys/bluetooth/audio/shell/micp_mic_dev.c | 52 ++- subsys/bluetooth/audio/shell/mpl.c | 4 - subsys/bluetooth/audio/shell/pbp.c | 6 +- subsys/bluetooth/audio/shell/tmap.c | 9 +- subsys/bluetooth/audio/shell/vcp_vol_ctlr.c | 147 +++----- subsys/bluetooth/audio/shell/vcp_vol_rend.c | 80 ++-- 21 files changed, 846 insertions(+), 1037 deletions(-) diff --git a/subsys/bluetooth/audio/shell/audio.h b/subsys/bluetooth/audio/shell/audio.h index a02724bd75fdb..82865453eca75 100644 --- a/subsys/bluetooth/audio/shell/audio.h +++ b/subsys/bluetooth/audio/shell/audio.h @@ -33,6 +33,7 @@ #include #include "host/shell/bt.h" +#include "common/bt_shell_private.h" #define SHELL_PRINT_INDENT_LEVEL_SIZE 2 #define MAX_CODEC_FRAMES_PER_SDU 4U @@ -233,21 +234,19 @@ int cap_ac_unicast(const struct shell *sh, const struct bap_unicast_ac_param *pa #endif /* CONFIG_BT_BAP_UNICAST_CLIENT */ #endif /* CONFIG_BT_BAP_UNICAST */ -static inline void print_qos(const struct shell *sh, const struct bt_bap_qos_cfg *qos) +static inline void print_qos(const struct bt_bap_qos_cfg *qos) { #if defined(CONFIG_BT_BAP_BROADCAST_SOURCE) || defined(CONFIG_BT_BAP_UNICAST) - shell_print(sh, - "QoS: interval %u framing 0x%02x phy 0x%02x sdu %u rtn %u latency %u pd %u", - qos->interval, qos->framing, qos->phy, qos->sdu, qos->rtn, qos->latency, - qos->pd); + bt_shell_print("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u rtn %u latency %u pd %u", + qos->interval, qos->framing, qos->phy, qos->sdu, qos->rtn, qos->latency, + qos->pd); #else - shell_print(sh, "QoS: interval %u framing 0x%02x phy 0x%02x sdu %u rtn %u pd %u", - qos->interval, qos->framing, qos->phy, qos->sdu, qos->rtn, qos->pd); + bt_shell_print("QoS: interval %u framing 0x%02x phy 0x%02x sdu %u rtn %u pd %u", + qos->interval, qos->framing, qos->phy, qos->sdu, qos->rtn, qos->pd); #endif /* CONFIG_BT_BAP_BROADCAST_SOURCE || CONFIG_BT_BAP_UNICAST */ } struct print_ltv_info { - const struct shell *sh; size_t indent; size_t cnt; }; @@ -257,27 +256,25 @@ static bool print_ltv_elem(struct bt_data *data, void *user_data) struct print_ltv_info *ltv_info = user_data; const size_t elem_indent = ltv_info->indent += SHELL_PRINT_INDENT_LEVEL_SIZE; - shell_print(ltv_info->sh, "%*s#%zu: type 0x%02x value_len %u", ltv_info->indent, "", - ltv_info->cnt, data->type, data->data_len); + bt_shell_print("%*s#%zu: type 0x%02x value_len %u", ltv_info->indent, "", + ltv_info->cnt, data->type, data->data_len); - shell_fprintf(ltv_info->sh, SHELL_NORMAL, "%*s", elem_indent, ""); + bt_shell_fprintf_print("%*s", elem_indent, ""); for (uint8_t i = 0U; i < data->data_len; i++) { - shell_fprintf(ltv_info->sh, SHELL_NORMAL, "%02X", data->data[i]); + bt_shell_fprintf_print("%02X", data->data[i]); } - shell_fprintf(ltv_info->sh, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); ltv_info->cnt++; return true; } -static void print_ltv_array(const struct shell *sh, size_t indent, const uint8_t *ltv_data, - size_t ltv_data_len) +static void print_ltv_array(size_t indent, const uint8_t *ltv_data, size_t ltv_data_len) { struct print_ltv_info ltv_info = { - .sh = sh, .cnt = 0U, .indent = indent, }; @@ -285,14 +282,13 @@ static void print_ltv_array(const struct shell *sh, size_t indent, const uint8_t err = bt_audio_data_parse(ltv_data, ltv_data_len, print_ltv_elem, <v_info); if (err != 0 && err != -ECANCELED) { - shell_error(sh, "%*sInvalid LTV data: %d", indent, "", err); + bt_shell_error("%*sInvalid LTV data: %d", indent, "", err); } } -static inline void print_codec_meta_pref_context(const struct shell *sh, size_t indent, - enum bt_audio_context context) +static inline void print_codec_meta_pref_context(size_t indent, enum bt_audio_context context) { - shell_print(sh, "%*sPreferred audio contexts:", indent, ""); + bt_shell_print("%*sPreferred audio contexts:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; @@ -301,16 +297,15 @@ static inline void print_codec_meta_pref_context(const struct shell *sh, size_t const uint16_t bit_val = BIT(i); if (context & bit_val) { - shell_print(sh, "%*s%s (0x%04X)", indent, "", - bt_audio_context_bit_to_str(bit_val), bit_val); + bt_shell_print("%*s%s (0x%04X)", indent, "", + bt_audio_context_bit_to_str(bit_val), bit_val); } } } -static inline void print_codec_meta_stream_context(const struct shell *sh, size_t indent, - enum bt_audio_context context) +static inline void print_codec_meta_stream_context(size_t indent, enum bt_audio_context context) { - shell_print(sh, "%*sStreaming audio contexts:", indent, ""); + bt_shell_print("%*sStreaming audio contexts:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; @@ -319,121 +314,118 @@ static inline void print_codec_meta_stream_context(const struct shell *sh, size_ const uint16_t bit_val = BIT(i); if (context & bit_val) { - shell_print(sh, "%*s%s (0x%04X)", indent, "", - bt_audio_context_bit_to_str(bit_val), bit_val); + bt_shell_print("%*s%s (0x%04X)", indent, "", + bt_audio_context_bit_to_str(bit_val), bit_val); } } } -static inline void print_codec_meta_program_info(const struct shell *sh, size_t indent, - const uint8_t *program_info, +static inline void print_codec_meta_program_info(size_t indent, const uint8_t *program_info, uint8_t program_info_len) { - shell_print(sh, "%*sProgram info:", indent, ""); + bt_shell_print("%*sProgram info:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; - shell_fprintf(sh, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < program_info_len; i++) { - shell_fprintf(sh, SHELL_NORMAL, "%c", (char)program_info[i]); + bt_shell_fprintf_print("%c", (char)program_info[i]); } - shell_fprintf(sh, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } -static inline void print_codec_meta_language(const struct shell *sh, size_t indent, +static inline void print_codec_meta_language(size_t indent, const uint8_t lang[BT_AUDIO_LANG_SIZE]) { - shell_print(sh, "%*sLanguage: %c%c%c", indent, "", (char)lang[0], (char)lang[1], - (char)lang[2]); + bt_shell_print("%*sLanguage: %c%c%c", indent, "", (char)lang[0], (char)lang[1], + (char)lang[2]); } -static inline void print_codec_meta_ccid_list(const struct shell *sh, size_t indent, - const uint8_t *ccid_list, uint8_t ccid_list_len) +static inline void print_codec_meta_ccid_list(size_t indent, const uint8_t *ccid_list, + uint8_t ccid_list_len) { - shell_print(sh, "%*sCCID list:", indent, ""); + bt_shell_print("%*sCCID list:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; /* There can be up to 16 bits set in the field */ for (uint8_t i = 0U; i < ccid_list_len; i++) { - shell_print(sh, "%*s0x%02X ", indent, "", ccid_list[i]); + bt_shell_print("%*s0x%02X ", indent, "", ccid_list[i]); } } -static inline void print_codec_meta_parental_rating(const struct shell *sh, size_t indent, +static inline void print_codec_meta_parental_rating(size_t indent, enum bt_audio_parental_rating parental_rating) { - shell_print(sh, "%*sRating: %s (0x%02X)", indent, "", - bt_audio_parental_rating_to_str(parental_rating), (uint8_t)parental_rating); + bt_shell_print("%*sRating: %s (0x%02X)", indent, "", + bt_audio_parental_rating_to_str(parental_rating), (uint8_t)parental_rating); } -static inline void print_codec_meta_program_info_uri(const struct shell *sh, size_t indent, +static inline void print_codec_meta_program_info_uri(size_t indent, const uint8_t *program_info_uri, uint8_t program_info_uri_len) { - shell_print(sh, "%*sProgram info URI:", indent, ""); + bt_shell_print("%*sProgram info URI:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; - shell_fprintf(sh, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < program_info_uri_len; i++) { - shell_fprintf(sh, SHELL_NORMAL, "%c", (char)program_info_uri[i]); + bt_shell_fprintf_print("%c", (char)program_info_uri[i]); } - shell_fprintf(sh, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } -static inline void print_codec_meta_audio_active_state(const struct shell *sh, size_t indent, +static inline void print_codec_meta_audio_active_state(size_t indent, enum bt_audio_active_state state) { - shell_print(sh, "%*sAudio active state: %s (0x%02X)", indent, "", - bt_audio_active_state_to_str(state), (uint8_t)state); + bt_shell_print("%*sAudio active state: %s (0x%02X)", indent, "", + bt_audio_active_state_to_str(state), (uint8_t)state); } -static inline void print_codec_meta_bcast_audio_immediate_rend_flag(const struct shell *sh, - size_t indent) +static inline void print_codec_meta_bcast_audio_immediate_rend_flag(size_t indent) { - shell_print(sh, "%*sBroadcast audio immediate rendering flag set", indent, ""); + bt_shell_print("%*sBroadcast audio immediate rendering flag set", indent, ""); } -static inline void print_codec_meta_extended(const struct shell *sh, size_t indent, - const uint8_t *extended_meta, size_t extended_meta_len) +static inline void print_codec_meta_extended(size_t indent, const uint8_t *extended_meta, + size_t extended_meta_len) { - shell_print(sh, "%*sExtended metadata:", indent, ""); + bt_shell_print("%*sExtended metadata:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; - shell_fprintf(sh, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < extended_meta_len; i++) { - shell_fprintf(sh, SHELL_NORMAL, "%u", (uint8_t)extended_meta[i]); + bt_shell_fprintf_print("%u", (uint8_t)extended_meta[i]); } - shell_fprintf(sh, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } -static inline void print_codec_meta_vendor(const struct shell *sh, size_t indent, - const uint8_t *vendor_meta, size_t vender_meta_len) +static inline void print_codec_meta_vendor(size_t indent, const uint8_t *vendor_meta, + size_t vender_meta_len) { - shell_print(sh, "%*sVendor metadata:", indent, ""); + bt_shell_print("%*sVendor metadata:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; - shell_fprintf(sh, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < vender_meta_len; i++) { - shell_fprintf(sh, SHELL_NORMAL, "%u", (uint8_t)vendor_meta[i]); + bt_shell_fprintf_print("%u", (uint8_t)vendor_meta[i]); } - shell_fprintf(sh, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } -static inline void print_codec_cap_freq(const struct shell *sh, size_t indent, - enum bt_audio_codec_cap_freq freq) +static inline void print_codec_cap_freq(size_t indent, enum bt_audio_codec_cap_freq freq) { - shell_print(sh, "%*sSupported sampling frequencies:", indent, ""); + bt_shell_print("%*sSupported sampling frequencies:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; /* There can be up to 16 bits set in the field */ @@ -441,16 +433,16 @@ static inline void print_codec_cap_freq(const struct shell *sh, size_t indent, const uint16_t bit_val = BIT(i); if (freq & bit_val) { - shell_print(sh, "%*s%s (0x%04X)", indent, "", - bt_audio_codec_cap_freq_bit_to_str(bit_val), bit_val); + bt_shell_print("%*s%s (0x%04X)", indent, "", + bt_audio_codec_cap_freq_bit_to_str(bit_val), bit_val); } } } -static inline void print_codec_cap_frame_dur(const struct shell *sh, size_t indent, +static inline void print_codec_cap_frame_dur(size_t indent, enum bt_audio_codec_cap_frame_dur frame_dur) { - shell_print(sh, "%*sSupported frame durations:", indent, ""); + bt_shell_print("%*sSupported frame durations:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; /* There can be up to 8 bits set in the field */ @@ -458,16 +450,16 @@ static inline void print_codec_cap_frame_dur(const struct shell *sh, size_t inde const uint8_t bit_val = BIT(i); if (frame_dur & bit_val) { - shell_print(sh, "%*s%s (0x%02X)", indent, "", - bt_audio_codec_cap_frame_dur_bit_to_str(bit_val), bit_val); + bt_shell_print("%*s%s (0x%02X)", indent, "", + bt_audio_codec_cap_frame_dur_bit_to_str(bit_val), bit_val); } } } -static inline void print_codec_cap_chan_count(const struct shell *sh, size_t indent, +static inline void print_codec_cap_chan_count(size_t indent, enum bt_audio_codec_cap_chan_count chan_count) { - shell_print(sh, "%*sSupported channel counts:", indent, ""); + bt_shell_print("%*sSupported channel counts:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; /* There can be up to 8 bits set in the field */ @@ -475,82 +467,80 @@ static inline void print_codec_cap_chan_count(const struct shell *sh, size_t ind const uint8_t bit_val = BIT(i); if (chan_count & bit_val) { - shell_print(sh, "%*s%s (0x%02X)", indent, "", - bt_audio_codec_cap_chan_count_bit_to_str(bit_val), bit_val); + bt_shell_print("%*s%s (0x%02X)", indent, "", + bt_audio_codec_cap_chan_count_bit_to_str(bit_val), bit_val); } } } static inline void print_codec_cap_octets_per_codec_frame( - const struct shell *sh, size_t indent, - const struct bt_audio_codec_octets_per_codec_frame *codec_frame) + size_t indent, const struct bt_audio_codec_octets_per_codec_frame *codec_frame) { - shell_print(sh, "%*sSupported octets per codec frame counts:", indent, ""); + bt_shell_print("%*sSupported octets per codec frame counts:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; - shell_print(sh, "%*sMin: %u", indent, "", codec_frame->min); - shell_print(sh, "%*sMax: %u", indent, "", codec_frame->max); + bt_shell_print("%*sMin: %u", indent, "", codec_frame->min); + bt_shell_print("%*sMax: %u", indent, "", codec_frame->max); } -static inline void print_codec_cap_max_codec_frames_per_sdu(const struct shell *sh, size_t indent, +static inline void print_codec_cap_max_codec_frames_per_sdu(size_t indent, uint8_t codec_frames_per_sdu) { - shell_print(sh, "%*sSupported max codec frames per SDU: %u", indent, "", - codec_frames_per_sdu); + bt_shell_print("%*sSupported max codec frames per SDU: %u", indent, "", + codec_frames_per_sdu); } -static inline void print_codec_cap(const struct shell *sh, size_t indent, - const struct bt_audio_codec_cap *codec_cap) +static inline void print_codec_cap(size_t indent, const struct bt_audio_codec_cap *codec_cap) { - shell_print(sh, "%*scodec cap id 0x%02x cid 0x%04x vid 0x%04x", indent, "", codec_cap->id, - codec_cap->cid, codec_cap->vid); + bt_shell_print("%*scodec cap id 0x%02x cid 0x%04x vid 0x%04x", indent, "", codec_cap->id, + codec_cap->cid, codec_cap->vid); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; #if CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE > 0 - shell_print(sh, "%*sCodec specific capabilities:", indent, ""); + bt_shell_print("%*sCodec specific capabilities:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; if (codec_cap->data_len == 0U) { - shell_print(sh, "%*sNone", indent, ""); + bt_shell_print("%*sNone", indent, ""); } else if (codec_cap->id == BT_HCI_CODING_FORMAT_LC3) { struct bt_audio_codec_octets_per_codec_frame codec_frame; int ret; ret = bt_audio_codec_cap_get_freq(codec_cap); if (ret >= 0) { - print_codec_cap_freq(sh, indent, (enum bt_audio_codec_cap_freq)ret); + print_codec_cap_freq(indent, (enum bt_audio_codec_cap_freq)ret); } ret = bt_audio_codec_cap_get_frame_dur(codec_cap); if (ret >= 0) { - print_codec_cap_frame_dur(sh, indent, + print_codec_cap_frame_dur(indent, (enum bt_audio_codec_cap_frame_dur)ret); } ret = bt_audio_codec_cap_get_supported_audio_chan_counts(codec_cap, true); if (ret >= 0) { - print_codec_cap_chan_count(sh, indent, + print_codec_cap_chan_count(indent, (enum bt_audio_codec_cap_chan_count)ret); } ret = bt_audio_codec_cap_get_octets_per_frame(codec_cap, &codec_frame); if (ret >= 0) { - print_codec_cap_octets_per_codec_frame(sh, indent, &codec_frame); + print_codec_cap_octets_per_codec_frame(indent, &codec_frame); } ret = bt_audio_codec_cap_get_max_codec_frames_per_sdu(codec_cap, true); if (ret >= 0) { - print_codec_cap_max_codec_frames_per_sdu(sh, indent, (uint8_t)ret); + print_codec_cap_max_codec_frames_per_sdu(indent, (uint8_t)ret); } } else { /* If not LC3, we cannot assume it's LTV */ - shell_fprintf(sh, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < codec_cap->data_len; i++) { - shell_fprintf(sh, SHELL_NORMAL, "%*s%02X", indent, "", codec_cap->data[i]); + bt_shell_fprintf_print("%*s%02X", indent, "", codec_cap->data[i]); } - shell_fprintf(sh, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } /* Reduce for metadata*/ @@ -558,169 +548,166 @@ static inline void print_codec_cap(const struct shell *sh, size_t indent, #endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE > 0 */ #if CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE > 0 - shell_print(sh, "%*sCodec capabilities metadata:", indent, ""); + bt_shell_print("%*sCodec capabilities metadata:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; if (codec_cap->meta_len == 0U) { - shell_print(sh, "%*sNone", indent, ""); + bt_shell_print("%*sNone", indent, ""); } else { const uint8_t *data; int ret; ret = bt_audio_codec_cap_meta_get_pref_context(codec_cap); if (ret >= 0) { - print_codec_meta_pref_context(sh, indent, (enum bt_audio_context)ret); + print_codec_meta_pref_context(indent, (enum bt_audio_context)ret); } ret = bt_audio_codec_cap_meta_get_stream_context(codec_cap); if (ret >= 0) { - print_codec_meta_stream_context(sh, indent, (enum bt_audio_context)ret); + print_codec_meta_stream_context(indent, (enum bt_audio_context)ret); } ret = bt_audio_codec_cap_meta_get_program_info(codec_cap, &data); if (ret >= 0) { - print_codec_meta_program_info(sh, indent, data, (uint8_t)ret); + print_codec_meta_program_info(indent, data, (uint8_t)ret); } ret = bt_audio_codec_cap_meta_get_lang(codec_cap, &data); if (ret >= 0) { - print_codec_meta_language(sh, indent, data); + print_codec_meta_language(indent, data); } ret = bt_audio_codec_cap_meta_get_ccid_list(codec_cap, &data); if (ret >= 0) { - print_codec_meta_ccid_list(sh, indent, data, (uint8_t)ret); + print_codec_meta_ccid_list(indent, data, (uint8_t)ret); } ret = bt_audio_codec_cap_meta_get_parental_rating(codec_cap); if (ret >= 0) { - print_codec_meta_parental_rating(sh, indent, + print_codec_meta_parental_rating(indent, (enum bt_audio_parental_rating)ret); } ret = bt_audio_codec_cap_meta_get_audio_active_state(codec_cap); if (ret >= 0) { - print_codec_meta_audio_active_state(sh, indent, + print_codec_meta_audio_active_state(indent, (enum bt_audio_active_state)ret); } ret = bt_audio_codec_cap_meta_get_bcast_audio_immediate_rend_flag(codec_cap); if (ret >= 0) { - print_codec_meta_bcast_audio_immediate_rend_flag(sh, indent); + print_codec_meta_bcast_audio_immediate_rend_flag(indent); } ret = bt_audio_codec_cap_meta_get_extended(codec_cap, &data); if (ret >= 0) { - print_codec_meta_extended(sh, indent, data, (uint8_t)ret); + print_codec_meta_extended(indent, data, (uint8_t)ret); } ret = bt_audio_codec_cap_meta_get_vendor(codec_cap, &data); if (ret >= 0) { - print_codec_meta_vendor(sh, indent, data, (uint8_t)ret); + print_codec_meta_vendor(indent, data, (uint8_t)ret); } } #endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE > 0 */ } -static inline void print_codec_cfg_freq(const struct shell *sh, size_t indent, - enum bt_audio_codec_cfg_freq freq) +static inline void print_codec_cfg_freq(size_t indent, enum bt_audio_codec_cfg_freq freq) { - shell_print(sh, "%*sSampling frequency: %u Hz (0x%04X)", indent, "", - bt_audio_codec_cfg_freq_to_freq_hz(freq), (uint16_t)freq); + bt_shell_print("%*sSampling frequency: %u Hz (0x%04X)", indent, "", + bt_audio_codec_cfg_freq_to_freq_hz(freq), (uint16_t)freq); } -static inline void print_codec_cfg_frame_dur(const struct shell *sh, size_t indent, +static inline void print_codec_cfg_frame_dur(size_t indent, enum bt_audio_codec_cfg_frame_dur frame_dur) { - shell_print(sh, "%*sFrame duration: %u us (0x%02X)", indent, "", - bt_audio_codec_cfg_frame_dur_to_frame_dur_us(frame_dur), (uint8_t)frame_dur); + bt_shell_print("%*sFrame duration: %u us (0x%02X)", indent, "", + bt_audio_codec_cfg_frame_dur_to_frame_dur_us(frame_dur), (uint8_t)frame_dur); } -static inline void print_codec_cfg_chan_allocation(const struct shell *sh, size_t indent, +static inline void print_codec_cfg_chan_allocation(size_t indent, enum bt_audio_location chan_allocation) { - shell_print(sh, "%*sChannel allocation:", indent, ""); + bt_shell_print("%*sChannel allocation:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; if (chan_allocation == BT_AUDIO_LOCATION_MONO_AUDIO) { - shell_print(sh, "%*s Mono", indent, ""); + bt_shell_print("%*s Mono", indent, ""); } else { /* There can be up to 32 bits set in the field */ for (size_t i = 0; i < 32; i++) { const uint8_t bit_val = BIT(i); if (chan_allocation & bit_val) { - shell_print(sh, "%*s%s (0x%08X)", indent, "", - bt_audio_location_bit_to_str(bit_val), bit_val); + bt_shell_print("%*s%s (0x%08X)", indent, "", + bt_audio_location_bit_to_str(bit_val), bit_val); } } } } -static inline void print_codec_cfg_octets_per_frame(const struct shell *sh, size_t indent, - uint16_t octets_per_frame) +static inline void print_codec_cfg_octets_per_frame(size_t indent, uint16_t octets_per_frame) { - shell_print(sh, "%*sOctets per codec frame: %u", indent, "", octets_per_frame); + bt_shell_print("%*sOctets per codec frame: %u", indent, "", octets_per_frame); } -static inline void print_codec_cfg_frame_blocks_per_sdu(const struct shell *sh, size_t indent, +static inline void print_codec_cfg_frame_blocks_per_sdu(size_t indent, uint8_t frame_blocks_per_sdu) { - shell_print(sh, "%*sCodec frame blocks per SDU: %u", indent, "", frame_blocks_per_sdu); + bt_shell_print("%*sCodec frame blocks per SDU: %u", indent, "", frame_blocks_per_sdu); } -static inline void print_codec_cfg(const struct shell *sh, size_t indent, - const struct bt_audio_codec_cfg *codec_cfg) +static inline void print_codec_cfg(size_t indent, const struct bt_audio_codec_cfg *codec_cfg) { - shell_print(sh, "%*scodec cfg id 0x%02x cid 0x%04x vid 0x%04x count %u", indent, "", - codec_cfg->id, codec_cfg->cid, codec_cfg->vid, codec_cfg->data_len); + bt_shell_print("%*scodec cfg id 0x%02x cid 0x%04x vid 0x%04x count %u", indent, "", + codec_cfg->id, codec_cfg->cid, codec_cfg->vid, codec_cfg->data_len); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; #if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE > 0 - shell_print(sh, "%*sCodec specific configuration:", indent, ""); + bt_shell_print("%*sCodec specific configuration:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; if (codec_cfg->data_len == 0U) { - shell_print(sh, "%*sNone", indent, ""); + bt_shell_print("%*sNone", indent, ""); } else if (codec_cfg->id == BT_HCI_CODING_FORMAT_LC3) { enum bt_audio_location chan_allocation; int ret; ret = bt_audio_codec_cfg_get_freq(codec_cfg); if (ret >= 0) { - print_codec_cfg_freq(sh, indent, (enum bt_audio_codec_cfg_freq)ret); + print_codec_cfg_freq(indent, (enum bt_audio_codec_cfg_freq)ret); } ret = bt_audio_codec_cfg_get_frame_dur(codec_cfg); if (ret >= 0) { - print_codec_cfg_frame_dur(sh, indent, + print_codec_cfg_frame_dur(indent, (enum bt_audio_codec_cfg_frame_dur)ret); } ret = bt_audio_codec_cfg_get_chan_allocation(codec_cfg, &chan_allocation, false); if (ret == 0) { - print_codec_cfg_chan_allocation(sh, indent, chan_allocation); + print_codec_cfg_chan_allocation(indent, chan_allocation); } ret = bt_audio_codec_cfg_get_octets_per_frame(codec_cfg); if (ret >= 0) { - print_codec_cfg_octets_per_frame(sh, indent, (uint16_t)ret); + print_codec_cfg_octets_per_frame(indent, (uint16_t)ret); } ret = bt_audio_codec_cfg_get_frame_blocks_per_sdu(codec_cfg, false); if (ret >= 0) { - print_codec_cfg_frame_blocks_per_sdu(sh, indent, (uint8_t)ret); + print_codec_cfg_frame_blocks_per_sdu(indent, (uint8_t)ret); } } else { /* If not LC3, we cannot assume it's LTV */ - shell_fprintf(sh, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < codec_cfg->data_len; i++) { - shell_fprintf(sh, SHELL_NORMAL, "%*s%02X", indent, "", codec_cfg->data[i]); + bt_shell_fprintf_print("%*s%02X", indent, "", codec_cfg->data[i]); } - shell_fprintf(sh, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } /* Reduce for metadata*/ @@ -728,65 +715,65 @@ static inline void print_codec_cfg(const struct shell *sh, size_t indent, #endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE > 0 */ #if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE > 0 - shell_print(sh, "%*sCodec specific metadata:", indent, ""); + bt_shell_print("%*sCodec specific metadata:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; if (codec_cfg->meta_len == 0U) { - shell_print(sh, "%*sNone", indent, ""); + bt_shell_print("%*sNone", indent, ""); } else { const uint8_t *data; int ret; ret = bt_audio_codec_cfg_meta_get_pref_context(codec_cfg, true); if (ret >= 0) { - print_codec_meta_pref_context(sh, indent, (enum bt_audio_context)ret); + print_codec_meta_pref_context(indent, (enum bt_audio_context)ret); } ret = bt_audio_codec_cfg_meta_get_stream_context(codec_cfg); if (ret >= 0) { - print_codec_meta_stream_context(sh, indent, (enum bt_audio_context)ret); + print_codec_meta_stream_context(indent, (enum bt_audio_context)ret); } ret = bt_audio_codec_cfg_meta_get_program_info(codec_cfg, &data); if (ret >= 0) { - print_codec_meta_program_info(sh, indent, data, (uint8_t)ret); + print_codec_meta_program_info(indent, data, (uint8_t)ret); } ret = bt_audio_codec_cfg_meta_get_lang(codec_cfg, &data); if (ret >= 0) { - print_codec_meta_language(sh, indent, data); + print_codec_meta_language(indent, data); } ret = bt_audio_codec_cfg_meta_get_ccid_list(codec_cfg, &data); if (ret >= 0) { - print_codec_meta_ccid_list(sh, indent, data, (uint8_t)ret); + print_codec_meta_ccid_list(indent, data, (uint8_t)ret); } ret = bt_audio_codec_cfg_meta_get_parental_rating(codec_cfg); if (ret >= 0) { - print_codec_meta_parental_rating(sh, indent, + print_codec_meta_parental_rating(indent, (enum bt_audio_parental_rating)ret); } ret = bt_audio_codec_cfg_meta_get_audio_active_state(codec_cfg); if (ret >= 0) { - print_codec_meta_audio_active_state(sh, indent, + print_codec_meta_audio_active_state(indent, (enum bt_audio_active_state)ret); } ret = bt_audio_codec_cfg_meta_get_bcast_audio_immediate_rend_flag(codec_cfg); if (ret >= 0) { - print_codec_meta_bcast_audio_immediate_rend_flag(sh, indent); + print_codec_meta_bcast_audio_immediate_rend_flag(indent); } ret = bt_audio_codec_cfg_meta_get_extended(codec_cfg, &data); if (ret >= 0) { - print_codec_meta_extended(sh, indent, data, (uint8_t)ret); + print_codec_meta_extended(indent, data, (uint8_t)ret); } ret = bt_audio_codec_cfg_meta_get_vendor(codec_cfg, &data); if (ret >= 0) { - print_codec_meta_vendor(sh, indent, data, (uint8_t)ret); + print_codec_meta_vendor(indent, data, (uint8_t)ret); } } #endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE > 0 */ @@ -813,7 +800,7 @@ static inline bool print_base_subgroup_bis_cb(const struct bt_bap_base_subgroup_ size_t indent = 2 * SHELL_PRINT_INDENT_LEVEL_SIZE; struct bt_bap_base_codec_id *codec_id = user_data; - shell_print(ctx_shell, "%*sBIS index: 0x%02X", indent, "", bis->index); + bt_shell_print("%*sBIS index: 0x%02X", indent, "", bis->index); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; @@ -828,22 +815,22 @@ static inline bool print_base_subgroup_bis_cb(const struct bt_bap_base_subgroup_ err = bt_bap_base_subgroup_bis_codec_to_codec_cfg(bis, &codec_cfg); if (err == 0) { - print_codec_cfg(ctx_shell, indent, &codec_cfg); + print_codec_cfg(indent, &codec_cfg); } else { - shell_print(ctx_shell, "%*sCodec specific configuration:", indent, ""); - print_ltv_array(ctx_shell, indent, bis->data, bis->data_len); + bt_shell_print("%*sCodec specific configuration:", indent, ""); + print_ltv_array(indent, bis->data, bis->data_len); } } else { /* If not LC3, we cannot assume it's LTV */ - shell_print(ctx_shell, "%*sCodec specific configuration:", indent, ""); + bt_shell_print("%*sCodec specific configuration:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; - shell_fprintf(ctx_shell, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < bis->data_len; i++) { - shell_fprintf(ctx_shell, SHELL_NORMAL, "%02X", bis->data[i]); + bt_shell_fprintf_print("%02X", bis->data[i]); } - shell_fprintf(ctx_shell, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } return true; @@ -858,20 +845,20 @@ static inline bool print_base_subgroup_cb(const struct bt_bap_base_subgroup *sub uint8_t *data; int ret; - shell_print(ctx_shell, "Subgroup %p:", subgroup); + bt_shell_print("Subgroup %p:", subgroup); ret = bt_bap_base_get_subgroup_codec_id(subgroup, &codec_id); if (ret < 0) { return false; } - shell_print(ctx_shell, "%*sCodec Format: 0x%02X", indent, "", codec_id.id); - shell_print(ctx_shell, "%*sCompany ID : 0x%04X", indent, "", codec_id.cid); - shell_print(ctx_shell, "%*sVendor ID : 0x%04X", indent, "", codec_id.vid); + bt_shell_print("%*sCodec Format: 0x%02X", indent, "", codec_id.id); + bt_shell_print("%*sCompany ID : 0x%04X", indent, "", codec_id.cid); + bt_shell_print("%*sVendor ID : 0x%04X", indent, "", codec_id.vid); ret = bt_bap_base_subgroup_codec_to_codec_cfg(subgroup, &codec_cfg); if (ret == 0) { - print_codec_cfg(ctx_shell, indent, &codec_cfg); + print_codec_cfg(indent, &codec_cfg); } else { /* If we cannot store it in a codec_cfg, then we cannot easily print it as such */ ret = bt_bap_base_get_subgroup_codec_data(subgroup, &data); @@ -879,20 +866,20 @@ static inline bool print_base_subgroup_cb(const struct bt_bap_base_subgroup *sub return false; } - shell_print(ctx_shell, "%*sCodec specific configuration:", indent, ""); + bt_shell_print("%*sCodec specific configuration:", indent, ""); indent += SHELL_PRINT_INDENT_LEVEL_SIZE; /* Print CC data */ if (codec_id.id == BT_HCI_CODING_FORMAT_LC3) { - print_ltv_array(ctx_shell, indent, data, (uint8_t)ret); + print_ltv_array(indent, data, (uint8_t)ret); } else { /* If not LC3, we cannot assume it's LTV */ - shell_fprintf(ctx_shell, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < (uint8_t)ret; i++) { - shell_fprintf(ctx_shell, SHELL_NORMAL, "%c", data[i]); + bt_shell_fprintf_print("%c", data[i]); } - shell_fprintf(ctx_shell, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } ret = bt_bap_base_get_subgroup_codec_meta(subgroup, &data); @@ -900,21 +887,21 @@ static inline bool print_base_subgroup_cb(const struct bt_bap_base_subgroup *sub return false; } - shell_print(ctx_shell, - "%*sCodec specific metadata:", indent - SHELL_PRINT_INDENT_LEVEL_SIZE, - ""); + bt_shell_print( + "%*sCodec specific metadata:", indent - SHELL_PRINT_INDENT_LEVEL_SIZE, + ""); /* Print metadata */ if (codec_id.id == BT_HCI_CODING_FORMAT_LC3) { - print_ltv_array(ctx_shell, indent, data, (uint8_t)ret); + print_ltv_array(indent, data, (uint8_t)ret); } else { /* If not LC3, we cannot assume it's LTV */ - shell_fprintf(ctx_shell, SHELL_NORMAL, "%*s", indent, ""); + bt_shell_fprintf_print("%*s", indent, ""); for (uint8_t i = 0U; i < (uint8_t)ret; i++) { - shell_fprintf(ctx_shell, SHELL_NORMAL, "%c", data[i]); + bt_shell_fprintf_print("%c", data[i]); } - shell_fprintf(ctx_shell, SHELL_NORMAL, "\n"); + bt_shell_fprintf_print("\n"); } } @@ -930,12 +917,12 @@ static inline void print_base(const struct bt_bap_base *base) { int err; - shell_print(ctx_shell, "Presentation delay: %d", bt_bap_base_get_pres_delay(base)); - shell_print(ctx_shell, "Subgroup count: %d", bt_bap_base_get_subgroup_count(base)); + bt_shell_print("Presentation delay: %d", bt_bap_base_get_pres_delay(base)); + bt_shell_print("Subgroup count: %d", bt_bap_base_get_subgroup_count(base)); err = bt_bap_base_foreach_subgroup(base, print_base_subgroup_cb, NULL); if (err < 0) { - shell_info(ctx_shell, "Invalid BASE: %d", err); + bt_shell_info("Invalid BASE: %d", err); } } diff --git a/subsys/bluetooth/audio/shell/bap.c b/subsys/bluetooth/audio/shell/bap.c index d06d055318d4f..492c90e9024e5 100644 --- a/subsys/bluetooth/audio/shell/bap.c +++ b/subsys/bluetooth/audio/shell/bap.c @@ -294,23 +294,23 @@ static int16_t lc3_tx_buf[LC3_MAX_NUM_SAMPLES_MONO]; static int init_lc3_encoder(struct shell_stream *sh_stream) { if (sh_stream == NULL) { - shell_error(ctx_shell, "NULL stream to init LC3"); + bt_shell_error("NULL stream to init LC3"); return -EINVAL; } if (!sh_stream->is_tx) { - shell_error(ctx_shell, "Invalid stream to init LC3 encoder"); + bt_shell_error("Invalid stream to init LC3 encoder"); return -EINVAL; } if (sh_stream->tx.lc3_encoder != NULL) { - shell_error(ctx_shell, "Already initialized"); + bt_shell_error("Already initialized"); return -EALREADY; } if (sh_stream->lc3_freq_hz == 0 || sh_stream->lc3_frame_duration_us == 0) { - shell_error(ctx_shell, "Invalid freq (%u) or frame duration (%u)", - sh_stream->lc3_freq_hz, sh_stream->lc3_frame_duration_us); + bt_shell_error("Invalid freq (%u) or frame duration (%u)", + sh_stream->lc3_freq_hz, sh_stream->lc3_frame_duration_us); return -EINVAL; } @@ -319,25 +319,25 @@ static int init_lc3_encoder(struct shell_stream *sh_stream) const size_t frame_size = bap_usb_get_frame_size(sh_stream); if (frame_size > sizeof(lc3_tx_buf)) { - shell_error(ctx_shell, "Cannot put %u octets in lc3_tx_buf of size %zu", - frame_size, sizeof(lc3_tx_buf)); + bt_shell_error("Cannot put %u octets in lc3_tx_buf of size %zu", + frame_size, sizeof(lc3_tx_buf)); return -EINVAL; } } - shell_print(ctx_shell, - "Initializing LC3 encoder for BAP stream %p with %u us duration and %u Hz " - "frequency", - bap_stream_from_shell_stream(sh_stream), sh_stream->lc3_frame_duration_us, - sh_stream->lc3_freq_hz); + bt_shell_print( + "Initializing LC3 encoder for BAP stream %p with %u us duration and %u Hz " + "frequency", + bap_stream_from_shell_stream(sh_stream), sh_stream->lc3_frame_duration_us, + sh_stream->lc3_freq_hz); sh_stream->tx.lc3_encoder = lc3_setup_encoder(sh_stream->lc3_frame_duration_us, sh_stream->lc3_freq_hz, IS_ENABLED(CONFIG_USB_DEVICE_AUDIO) ? USB_SAMPLE_RATE : 0, &sh_stream->tx.lc3_encoder_mem); if (sh_stream->tx.lc3_encoder == NULL) { - shell_error(ctx_shell, "Failed to setup LC3 encoder - wrong parameters?\n"); + bt_shell_error("Failed to setup LC3 encoder - wrong parameters?\n"); return -EINVAL; } @@ -391,15 +391,15 @@ static bool encode_frame(struct shell_stream *sh_stream, uint8_t index, size_t f } if ((sh_stream->tx.encoded_cnt % bap_stats_interval) == 0) { - shell_print(ctx_shell, "[%zu]: Encoding frame of size %u (%u/%u)", - sh_stream->tx.encoded_cnt, octets_per_frame, frame_cnt + 1, - total_frames); + bt_shell_print("[%zu]: Encoding frame of size %u (%u/%u)", + sh_stream->tx.encoded_cnt, octets_per_frame, frame_cnt + 1, + total_frames); } lc3_ret = lc3_encode(sh_stream->tx.lc3_encoder, LC3_PCM_FORMAT_S16, lc3_tx_buf, 1, octets_per_frame, net_buf_tail(out_buf)); if (lc3_ret == -1) { - shell_error(ctx_shell, "LC3 encoder failed - wrong parameters?: %d", lc3_ret); + bt_shell_error("LC3 encoder failed - wrong parameters?: %d", lc3_ret); return false; } @@ -456,22 +456,22 @@ static void lc3_audio_send_data(struct shell_stream *sh_stream) } if (sh_stream->tx.lc3_encoder == NULL) { - shell_error(ctx_shell, "LC3 encoder not setup, cannot encode data"); + bt_shell_error("LC3 encoder not setup, cannot encode data"); return; } if (bap_stream == NULL || bap_stream->qos == NULL) { - shell_error(ctx_shell, "invalid stream, aborting"); + bt_shell_error("invalid stream, aborting"); return; } if (tx_sdu_len == 0U || tx_sdu_len > SINE_TX_POOL_SIZE) { - shell_error(ctx_shell, - "Cannot send %u length SDU (from frame blocks per sdu %u, channel " - "count %u and %u octets per frame) for pool size %d", - tx_sdu_len, sh_stream->lc3_frame_blocks_per_sdu, - sh_stream->lc3_chan_cnt, sh_stream->lc3_octets_per_frame, - SINE_TX_POOL_SIZE); + bt_shell_error( + "Cannot send %u length SDU (from frame blocks per sdu %u, channel " + "count %u and %u octets per frame) for pool size %d", + tx_sdu_len, sh_stream->lc3_frame_blocks_per_sdu, + sh_stream->lc3_chan_cnt, sh_stream->lc3_octets_per_frame, + SINE_TX_POOL_SIZE); return; } @@ -487,16 +487,16 @@ static void lc3_audio_send_data(struct shell_stream *sh_stream) err = bt_bap_stream_send(bap_stream, buf, sh_stream->tx.seq_num); if (err < 0) { - shell_error(ctx_shell, "Failed to send LC3 audio data (%d)", err); + bt_shell_error("Failed to send LC3 audio data (%d)", err); net_buf_unref(buf); return; } if ((sh_stream->tx.lc3_sdu_cnt % bap_stats_interval) == 0U) { - shell_info(ctx_shell, "[%zu]: stream %p : TX LC3: %zu (seq_num %u)", - sh_stream->tx.lc3_sdu_cnt, bap_stream, tx_sdu_len, - sh_stream->tx.seq_num); + bt_shell_info("[%zu]: stream %p : TX LC3: %zu (seq_num %u)", + sh_stream->tx.lc3_sdu_cnt, bap_stream, tx_sdu_len, + sh_stream->tx.seq_num); } sh_stream->tx.lc3_sdu_cnt++; @@ -587,7 +587,7 @@ static void set_unicast_stream(struct bt_bap_stream *stream) for (size_t i = 0U; i < ARRAY_SIZE(unicast_streams); i++) { if (stream == bap_stream_from_shell_stream(&unicast_streams[i])) { - shell_print(ctx_shell, "Default stream: %u", i + 1); + bt_shell_print("Default stream: %u", i + 1); } } } @@ -639,20 +639,20 @@ static int lc3_config(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_ const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream, struct bt_bap_qos_cfg_pref *const pref, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "ASE Codec Config: conn %p ep %p dir %u", conn, ep, dir); + bt_shell_print("ASE Codec Config: conn %p ep %p dir %u", conn, ep, dir); - print_codec_cfg(ctx_shell, 0, codec_cfg); + print_codec_cfg(0, codec_cfg); *stream = stream_alloc(); if (*stream == NULL) { - shell_print(ctx_shell, "No unicast_streams available"); + bt_shell_print("No unicast_streams available"); *rsp = BT_BAP_ASCS_RSP(BT_BAP_ASCS_RSP_CODE_NO_MEM, BT_BAP_ASCS_REASON_NONE); return -ENOMEM; } - shell_print(ctx_shell, "ASE Codec Config stream %p", *stream); + bt_shell_print("ASE Codec Config stream %p", *stream); set_unicast_stream(*stream); @@ -665,9 +665,9 @@ static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_qos_cfg_pref *const pref, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "ASE Codec Reconfig: stream %p", stream); + bt_shell_print("ASE Codec Reconfig: stream %p", stream); - print_codec_cfg(ctx_shell, 0, codec_cfg); + print_codec_cfg(0, codec_cfg); if (default_stream == NULL) { set_unicast_stream(stream); @@ -681,9 +681,9 @@ static int lc3_reconfig(struct bt_bap_stream *stream, enum bt_audio_dir dir, static int lc3_qos(struct bt_bap_stream *stream, const struct bt_bap_qos_cfg *qos, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "QoS: stream %p %p", stream, qos); + bt_shell_print("QoS: stream %p %p", stream, qos); - print_qos(ctx_shell, qos); + print_qos(qos); return 0; } @@ -691,20 +691,18 @@ static int lc3_qos(struct bt_bap_stream *stream, const struct bt_bap_qos_cfg *qo static int lc3_enable(struct bt_bap_stream *stream, const uint8_t meta[], size_t meta_len, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "Enable: stream %p meta_len %zu", stream, - meta_len); + bt_shell_print("Enable: stream %p meta_len %zu", stream, meta_len); return 0; } static int lc3_start(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "Start: stream %p", stream); + bt_shell_print("Start: stream %p", stream); return 0; } - static bool meta_data_func_cb(struct bt_data *data, void *user_data) { struct bt_bap_ascs_rsp *rsp = (struct bt_bap_ascs_rsp *)user_data; @@ -721,29 +719,28 @@ static bool meta_data_func_cb(struct bt_data *data, void *user_data) static int lc3_metadata(struct bt_bap_stream *stream, const uint8_t meta[], size_t meta_len, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "Metadata: stream %p meta_len %zu", stream, - meta_len); + bt_shell_print("Metadata: stream %p meta_len %zu", stream, meta_len); return bt_audio_data_parse(meta, meta_len, meta_data_func_cb, rsp); } static int lc3_disable(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "Disable: stream %p", stream); + bt_shell_print("Disable: stream %p", stream); return 0; } static int lc3_stop(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "Stop: stream %p", stream); + bt_shell_print("Stop: stream %p", stream); return 0; } static int lc3_release(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp) { - shell_print(ctx_shell, "Release: stream %p", stream); + bt_shell_print("Release: stream %p", stream); if (stream == default_stream) { default_stream = NULL; @@ -913,10 +910,9 @@ static void print_remote_codec_cap(const struct bt_conn *conn, const struct bt_audio_codec_cap *codec_cap, enum bt_audio_dir dir) { - shell_print(ctx_shell, "conn %p: codec_cap %p dir 0x%02x", conn, codec_cap, - dir); + bt_shell_print("conn %p: codec_cap %p dir 0x%02x", conn, codec_cap, dir); - print_codec_cap(ctx_shell, 0, codec_cap); + print_codec_cap(0, codec_cap); } #if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 @@ -926,14 +922,14 @@ static void add_sink(const struct bt_conn *conn, struct bt_bap_ep *ep) for (size_t i = 0U; i < ARRAY_SIZE(snks[conn_index]); i++) { if (snks[conn_index][i] == NULL) { - shell_print(ctx_shell, "Conn: %p, Sink #%zu: ep %p", conn, i, ep); + bt_shell_print("Conn: %p, Sink #%zu: ep %p", conn, i, ep); snks[conn_index][i] = ep; return; } } - shell_error(ctx_shell, "Could not add more sink endpoints"); + bt_shell_error("Could not add more sink endpoints"); } #endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */ @@ -944,14 +940,14 @@ static void add_source(const struct bt_conn *conn, struct bt_bap_ep *ep) for (size_t i = 0U; i < ARRAY_SIZE(srcs[conn_index]); i++) { if (srcs[conn_index][i] == NULL) { - shell_print(ctx_shell, "Conn: %p, Source #%zu: ep %p", conn, i, ep); + bt_shell_print("Conn: %p, Source #%zu: ep %p", conn, i, ep); srcs[conn_index][i] = ep; return; } } - shell_error(ctx_shell, "Could not add more sink endpoints"); + bt_shell_error("Could not add more sink endpoints"); } #endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */ @@ -978,7 +974,7 @@ static void endpoint_cb(struct bt_conn *conn, enum bt_audio_dir dir, struct bt_b static void discover_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir) { - shell_print(ctx_shell, "Discover complete: err %d", err); + bt_shell_print("Discover complete: err %d", err); } static void discover_all(struct bt_conn *conn, int err, enum bt_audio_dir dir) @@ -990,30 +986,30 @@ static void discover_all(struct bt_conn *conn, int err, enum bt_audio_dir dir) err = bt_bap_unicast_client_discover(default_conn, dir); if (err) { - shell_error(ctx_shell, "bt_bap_unicast_client_discover err %d", err); + bt_shell_error("bt_bap_unicast_client_discover err %d", err); } } } static void unicast_client_location_cb(struct bt_conn *conn, - enum bt_audio_dir dir, - enum bt_audio_location loc) + enum bt_audio_dir dir, + enum bt_audio_location loc) { - shell_print(ctx_shell, "dir %u loc %X\n", dir, loc); + bt_shell_print("dir %u loc %X\n", dir, loc); } static void available_contexts_cb(struct bt_conn *conn, enum bt_audio_context snk_ctx, enum bt_audio_context src_ctx) { - shell_print(ctx_shell, "snk ctx %u src ctx %u\n", snk_ctx, src_ctx); + bt_shell_print("snk ctx %u src ctx %u\n", snk_ctx, src_ctx); } static void config_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason) { - shell_print(ctx_shell, "stream %p config operation rsp_code %u reason %u", - stream, rsp_code, reason); + bt_shell_print("stream %p config operation rsp_code %u reason %u", + stream, rsp_code, reason); if (default_stream == NULL) { default_stream = stream; @@ -1023,50 +1019,50 @@ static void config_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rs static void qos_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason) { - shell_print(ctx_shell, "stream %p qos operation rsp_code %u reason %u", - stream, rsp_code, reason); + bt_shell_print("stream %p qos operation rsp_code %u reason %u", + stream, rsp_code, reason); } static void enable_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason) { - shell_print(ctx_shell, "stream %p enable operation rsp_code %u reason %u", - stream, rsp_code, reason); + bt_shell_print("stream %p enable operation rsp_code %u reason %u", + stream, rsp_code, reason); } static void start_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason) { - shell_print(ctx_shell, "stream %p start operation rsp_code %u reason %u", - stream, rsp_code, reason); + bt_shell_print("stream %p start operation rsp_code %u reason %u", + stream, rsp_code, reason); } static void stop_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason) { - shell_print(ctx_shell, "stream %p stop operation rsp_code %u reason %u", - stream, rsp_code, reason); + bt_shell_print("stream %p stop operation rsp_code %u reason %u", + stream, rsp_code, reason); } static void disable_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason) { - shell_print(ctx_shell, "stream %p disable operation rsp_code %u reason %u", - stream, rsp_code, reason); + bt_shell_print("stream %p disable operation rsp_code %u reason %u", + stream, rsp_code, reason); } static void metadata_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason) { - shell_print(ctx_shell, "stream %p metadata operation rsp_code %u reason %u", - stream, rsp_code, reason); + bt_shell_print("stream %p metadata operation rsp_code %u reason %u", + stream, rsp_code, reason); } static void release_cb(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason) { - shell_print(ctx_shell, "stream %p release operation rsp_code %u reason %u", - stream, rsp_code, reason); + bt_shell_print("stream %p release operation rsp_code %u reason %u", + stream, rsp_code, reason); } static struct bt_bap_unicast_client_cb unicast_client_cbs = { @@ -2337,8 +2333,8 @@ static int cmd_preset(const struct shell *sh, size_t argc, char *argv[]) shell_print(sh, "%s", named_preset->name); - print_codec_cfg(ctx_shell, 0, &named_preset->preset.codec_cfg); - print_qos(ctx_shell, &named_preset->preset.qos); + print_codec_cfg(0, &named_preset->preset.codec_cfg); + print_qos(&named_preset->preset.qos); return 0; } @@ -2454,8 +2450,8 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, struct auto_scan.broadcast_info.broadcast_id = sr_info.broadcast_id; identified_broadcast = true; - shell_print(ctx_shell, "Found matched broadcast name '%s' with address %s", - sr_info.broadcast_name, addr_str); + bt_shell_print("Found matched broadcast name '%s' with address %s", + sr_info.broadcast_name, addr_str); } if (identified_broadcast && (auto_scan.broadcast_sink != NULL) && @@ -2463,13 +2459,13 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, struct struct bt_le_per_adv_sync_param create_params = {0}; int err; - shell_print(ctx_shell, - "Found broadcaster with ID 0x%06X and addr %s and sid 0x%02X ", - sr_info.broadcast_id, addr_str, info->sid); + bt_shell_print( + "Found broadcaster with ID 0x%06X and addr %s and sid 0x%02X ", + sr_info.broadcast_id, addr_str, info->sid); err = bt_le_scan_stop(); if (err != 0) { - shell_error(ctx_shell, "Could not stop scan: %d", err); + bt_shell_error("Could not stop scan: %d", err); } bt_addr_le_copy(&create_params.addr, info->addr); @@ -2478,10 +2474,10 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, struct create_params.skip = PA_SYNC_SKIP; create_params.timeout = interval_to_sync_timeout(info->interval); - shell_print(ctx_shell, "Attempting to PA sync to the broadcaster"); + bt_shell_print("Attempting to PA sync to the broadcaster"); err = bt_le_per_adv_sync_create(&create_params, auto_scan.out_sync); if (err != 0) { - shell_error(ctx_shell, "Could not create Broadcast PA sync: %d", err); + bt_shell_error("Could not create Broadcast PA sync: %d", err); } else { auto_scan.broadcast_sink->pa_sync = *auto_scan.out_sync; } @@ -2494,7 +2490,7 @@ static void base_recv(struct bt_bap_broadcast_sink *sink, const struct bt_bap_ba /* Don't print duplicates */ if (base_size != default_broadcast_sink.base_size || memcmp(base, &default_broadcast_sink.received_base, base_size) != 0) { - shell_print(ctx_shell, "Received BASE from sink %p:", sink); + bt_shell_print("Received BASE from sink %p:", sink); (void)memcpy(&default_broadcast_sink.received_base, base, base_size); default_broadcast_sink.base_size = base_size; @@ -2509,8 +2505,8 @@ static void syncable(struct bt_bap_broadcast_sink *sink, const struct bt_iso_big return; } - shell_print(ctx_shell, "Sink %p is ready to sync %s encryption", sink, - biginfo->encryption ? "with" : "without"); + bt_shell_print("Sink %p is ready to sync %s encryption", sink, + biginfo->encryption ? "with" : "without"); default_broadcast_sink.syncable = true; } } @@ -2520,21 +2516,21 @@ static void bap_pa_sync_synced_cb(struct bt_le_per_adv_sync *sync, { if (auto_scan.broadcast_sink != NULL && auto_scan.out_sync != NULL && sync == *auto_scan.out_sync) { - shell_print(ctx_shell, "PA synced to broadcast with broadcast ID 0x%06x", - auto_scan.broadcast_info.broadcast_id); + bt_shell_print("PA synced to broadcast with broadcast ID 0x%06x", + auto_scan.broadcast_info.broadcast_id); if (auto_scan.broadcast_sink->bap_sink == NULL) { - shell_print(ctx_shell, "Attempting to create the sink"); + bt_shell_print("Attempting to create the sink"); int err; err = bt_bap_broadcast_sink_create(sync, auto_scan.broadcast_info.broadcast_id, &auto_scan.broadcast_sink->bap_sink); if (err != 0) { - shell_error(ctx_shell, "Could not create broadcast sink: %d", err); + bt_shell_error("Could not create broadcast sink: %d", err); } } else { - shell_print(ctx_shell, "Sink is already created"); + bt_shell_print("Sink is already created"); } } @@ -2555,7 +2551,7 @@ static void bap_pa_sync_terminated_cb(struct bt_le_per_adv_sync *sync, static void broadcast_scan_timeout_cb(void) { - shell_print(ctx_shell, "Scan timeout"); + bt_shell_print("Scan timeout"); clear_auto_scan(); } @@ -2609,37 +2605,36 @@ static struct shell_stream *usb_right_stream; static int init_lc3_decoder(struct shell_stream *sh_stream) { if (sh_stream == NULL) { - shell_error(ctx_shell, "NULL stream to init LC3 decoder"); + bt_shell_error("NULL stream to init LC3 decoder"); return -EINVAL; } if (!sh_stream->is_rx) { - shell_error(ctx_shell, "Invalid stream to init LC3 decoder"); + bt_shell_error("Invalid stream to init LC3 decoder"); return -EINVAL; } if (sh_stream->rx.lc3_decoder != NULL) { - shell_error(ctx_shell, "Already initialized"); + bt_shell_error("Already initialized"); return -EALREADY; } if (sh_stream->lc3_freq_hz == 0 || sh_stream->lc3_frame_duration_us == 0) { - shell_error(ctx_shell, "Invalid freq (%u) or frame duration (%u)", - sh_stream->lc3_freq_hz, sh_stream->lc3_frame_duration_us); + bt_shell_error("Invalid freq (%u) or frame duration (%u)", + sh_stream->lc3_freq_hz, sh_stream->lc3_frame_duration_us); return -EINVAL; } - shell_print(ctx_shell, - "Initializing the LC3 decoder with %u us duration and %u Hz frequency", - sh_stream->lc3_frame_duration_us, sh_stream->lc3_freq_hz); + bt_shell_print("Initializing the LC3 decoder with %u us duration and %u Hz frequency", + sh_stream->lc3_frame_duration_us, sh_stream->lc3_freq_hz); /* Create the decoder instance. This shall complete before stream_started() is called. */ sh_stream->rx.lc3_decoder = lc3_setup_decoder(sh_stream->lc3_frame_duration_us, sh_stream->lc3_freq_hz, IS_ENABLED(CONFIG_USB_DEVICE_AUDIO) ? USB_SAMPLE_RATE : 0, &sh_stream->rx.lc3_decoder_mem); if (sh_stream->rx.lc3_decoder == NULL) { - shell_error(ctx_shell, "Failed to setup LC3 decoder - wrong parameters?\n"); + bt_shell_error("Failed to setup LC3 decoder - wrong parameters?\n"); return -EINVAL; } @@ -2659,7 +2654,7 @@ static bool decode_frame(struct lc3_data *data, size_t frame_cnt) iso_data = NULL; /* perform PLC */ if ((sh_stream->rx.decoded_cnt % bap_stats_interval) == 0) { - shell_print(ctx_shell, "[%zu]: Performing PLC", sh_stream->rx.decoded_cnt); + bt_shell_print("[%zu]: Performing PLC", sh_stream->rx.decoded_cnt); } data->do_plc = false; /* clear flag */ @@ -2667,17 +2662,17 @@ static bool decode_frame(struct lc3_data *data, size_t frame_cnt) iso_data = net_buf_pull_mem(data->buf, octets_per_frame); if ((sh_stream->rx.decoded_cnt % bap_stats_interval) == 0) { - shell_print(ctx_shell, "[%zu]: Decoding frame of size %u (%u/%u)", - sh_stream->rx.decoded_cnt, octets_per_frame, frame_cnt + 1, - total_frames); + bt_shell_print("[%zu]: Decoding frame of size %u (%u/%u)", + sh_stream->rx.decoded_cnt, octets_per_frame, frame_cnt + 1, + total_frames); } } err = lc3_decode(sh_stream->rx.lc3_decoder, iso_data, octets_per_frame, LC3_PCM_FORMAT_S16, lc3_rx_buf, 1); if (err < 0) { - shell_error(ctx_shell, "Failed to decode LC3 data (%u/%u - %u/%u)", frame_cnt + 1, - total_frames, octets_per_frame * frame_cnt, buf->len); + bt_shell_error("Failed to decode LC3 data (%u/%u - %u/%u)", frame_cnt + 1, + total_frames, octets_per_frame * frame_cnt, buf->len); return false; } @@ -2768,7 +2763,7 @@ static void lc3_decoder_thread_func(void *arg1, void *arg2, void *arg3) struct shell_stream *sh_stream = data->sh_stream; if (sh_stream->is_rx && sh_stream->rx.lc3_decoder == NULL) { - shell_warn(ctx_shell, "Decoder is NULL, discarding data from FIFO"); + bt_shell_warn("Decoder is NULL, discarding data from FIFO"); k_mem_slab_free(&lc3_data_slab, (void *)data); continue; /* Wait for new data */ } @@ -2818,14 +2813,14 @@ static void audio_recv(struct bt_bap_stream *stream, } if ((sh_stream->rx.rx_cnt % bap_stats_interval) == 0) { - shell_print(ctx_shell, - "[%zu]: Incoming audio on stream %p len %u ts %u seq_num %u flags %u " - "(valid %zu, dup ts %zu, dup psn %zu, err_pkts %zu, lost_pkts %zu, " - "empty SDUs %zu)", - sh_stream->rx.rx_cnt, stream, buf->len, info->ts, info->seq_num, - info->flags, sh_stream->rx.valid_sdu_pkts, sh_stream->rx.dup_ts, - sh_stream->rx.dup_psn, sh_stream->rx.err_pkts, sh_stream->rx.lost_pkts, - sh_stream->rx.empty_sdu_pkts); + bt_shell_print( + "[%zu]: Incoming audio on stream %p len %u ts %u seq_num %u flags %u " + "(valid %zu, dup ts %zu, dup psn %zu, err_pkts %zu, lost_pkts %zu, " + "empty SDUs %zu)", + sh_stream->rx.rx_cnt, stream, buf->len, info->ts, info->seq_num, + info->flags, sh_stream->rx.valid_sdu_pkts, sh_stream->rx.dup_ts, + sh_stream->rx.dup_psn, sh_stream->rx.err_pkts, sh_stream->rx.lost_pkts, + sh_stream->rx.empty_sdu_pkts); } (void)memcpy(&sh_stream->rx.last_info, info, sizeof(sh_stream->rx.last_info)); @@ -2842,7 +2837,7 @@ static void audio_recv(struct bt_bap_stream *stream, * in a FIFO */ if (k_mem_slab_alloc(&lc3_data_slab, (void **)&data, K_NO_WAIT)) { - shell_warn(ctx_shell, "Could not allocate LC3 data item"); + bt_shell_warn("Could not allocate LC3 data item"); return; } @@ -2851,8 +2846,7 @@ static void audio_recv(struct bt_bap_stream *stream, data->do_plc = true; } else if (buf->len != (octets_per_frame * chan_cnt * frame_blocks_per_sdu)) { if (buf->len != 0U) { - shell_error( - ctx_shell, + bt_shell_error( "Expected %u frame blocks with %u channels of size %u, but " "length is %u", frame_blocks_per_sdu, chan_cnt, octets_per_frame, buf->len); @@ -2878,7 +2872,7 @@ static void audio_recv(struct bt_bap_stream *stream, #if defined(CONFIG_BT_BAP_UNICAST) static void stream_enabled_cb(struct bt_bap_stream *stream) { - shell_print(ctx_shell, "Stream %p enabled", stream); + bt_shell_print("Stream %p enabled", stream); if (IS_ENABLED(CONFIG_BT_BAP_UNICAST_SERVER)) { struct bt_bap_ep_info ep_info; @@ -2887,7 +2881,7 @@ static void stream_enabled_cb(struct bt_bap_stream *stream) err = bt_conn_get_info(stream->conn, &conn_info); if (err != 0) { - shell_error(ctx_shell, "Failed to get conn info: %d", err); + bt_shell_error("Failed to get conn info: %d", err); return; } @@ -2897,7 +2891,7 @@ static void stream_enabled_cb(struct bt_bap_stream *stream) err = bt_bap_ep_get_info(stream->ep, &ep_info); if (err != 0) { - shell_error(ctx_shell, "Failed to get ep info: %d", err); + bt_shell_error("Failed to get ep info: %d", err); return; } @@ -2906,7 +2900,7 @@ static void stream_enabled_cb(struct bt_bap_stream *stream) err = bt_bap_stream_start(stream); if (err != 0) { - shell_error(ctx_shell, "Failed to start stream: %d", err); + bt_shell_error("Failed to start stream: %d", err); return; } } @@ -2924,7 +2918,7 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) ret = bt_bap_ep_get_info(bap_stream->ep, &info); if (ret != 0) { - shell_error(ctx_shell, "Failed to get EP info: %d", ret); + bt_shell_error("Failed to get EP info: %d", ret); return; } @@ -2949,16 +2943,15 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) ret == 48000) { sh_stream->lc3_freq_hz = (uint32_t)ret; } else { - shell_error(ctx_shell, "Unsupported frequency for LC3: %d", - ret); + bt_shell_error("Unsupported frequency for LC3: %d", ret); sh_stream->lc3_freq_hz = 0U; } } else { - shell_error(ctx_shell, "Invalid frequency: %d", ret); + bt_shell_error("Invalid frequency: %d", ret); sh_stream->lc3_freq_hz = 0U; } } else { - shell_error(ctx_shell, "Could not get frequency: %d", ret); + bt_shell_error("Could not get frequency: %d", ret); sh_stream->lc3_freq_hz = 0U; } @@ -2968,11 +2961,11 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) if (ret > 0) { sh_stream->lc3_frame_duration_us = (uint32_t)ret; } else { - shell_error(ctx_shell, "Invalid frame duration: %d", ret); + bt_shell_error("Invalid frame duration: %d", ret); sh_stream->lc3_frame_duration_us = 0U; } } else { - shell_error(ctx_shell, "Could not get frame duration: %d", ret); + bt_shell_error("Could not get frame duration: %d", ret); sh_stream->lc3_frame_duration_us = 0U; } @@ -2982,7 +2975,7 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) sh_stream->lc3_chan_cnt = bt_audio_get_chan_count(sh_stream->lc3_chan_allocation); } else { - shell_error(ctx_shell, "Could not get channel allocation: %d", ret); + bt_shell_error("Could not get channel allocation: %d", ret); sh_stream->lc3_chan_allocation = BT_AUDIO_LOCATION_MONO_AUDIO; sh_stream->lc3_chan_cnt = 1U; } @@ -2991,7 +2984,7 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) if (ret >= 0) { sh_stream->lc3_frame_blocks_per_sdu = (uint8_t)ret; } else { - shell_error(ctx_shell, "Could not get frame blocks per SDU: %d", ret); + bt_shell_error("Could not get frame blocks per SDU: %d", ret); sh_stream->lc3_frame_blocks_per_sdu = 0U; } @@ -2999,7 +2992,7 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) if (ret >= 0) { sh_stream->lc3_octets_per_frame = (uint16_t)ret; } else { - shell_error(ctx_shell, "Could not get octets per frame: %d", ret); + bt_shell_error("Could not get octets per frame: %d", ret); sh_stream->lc3_octets_per_frame = 0U; } @@ -3008,7 +3001,7 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) const int err = init_lc3_encoder(sh_stream); if (err != 0) { - shell_error(ctx_shell, "Failed to init LC3 encoder: %d", err); + bt_shell_error("Failed to init LC3 encoder: %d", err); return; } @@ -3026,8 +3019,7 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) const int err = init_lc3_decoder(sh_stream); if (err != 0) { - shell_error(ctx_shell, "Failed to init LC3 decoder: %d", - err); + bt_shell_error("Failed to init LC3 decoder: %d", err); return; } @@ -3039,26 +3031,22 @@ static void stream_started_cb(struct bt_bap_stream *bap_stream) if ((sh_stream->lc3_chan_allocation & BT_AUDIO_LOCATION_FRONT_LEFT) != 0) { if (usb_left_stream == NULL) { - shell_info(ctx_shell, - "Setting USB left stream to %p", - sh_stream); + bt_shell_info("Setting USB left stream to %p", + sh_stream); usb_left_stream = sh_stream; } else { - shell_warn(ctx_shell, - "Multiple left streams started"); + bt_shell_warn("Multiple left streams started"); } } if ((sh_stream->lc3_chan_allocation & BT_AUDIO_LOCATION_FRONT_RIGHT) != 0) { if (usb_right_stream == NULL) { - shell_info(ctx_shell, - "Setting USB right stream to %p", - sh_stream); + bt_shell_info("Setting USB right stream to %p", + sh_stream); usb_right_stream = sh_stream; } else { - shell_warn(ctx_shell, - "Multiple right streams started"); + bt_shell_warn("Multiple right streams started"); } } } @@ -3094,13 +3082,13 @@ static void update_usb_streams_cb(struct shell_stream *sh_stream, void *user_dat if (sh_stream->is_rx) { if (usb_left_stream == NULL && (sh_stream->lc3_chan_allocation & BT_AUDIO_LOCATION_FRONT_LEFT) != 0) { - shell_info(ctx_shell, "Setting new USB left stream to %p", sh_stream); + bt_shell_info("Setting new USB left stream to %p", sh_stream); usb_left_stream = sh_stream; } if (usb_right_stream == NULL && (sh_stream->lc3_chan_allocation & BT_AUDIO_LOCATION_FRONT_RIGHT) != 0) { - shell_info(ctx_shell, "Setting new USB right stream to %p", sh_stream); + bt_shell_info("Setting new USB right stream to %p", sh_stream); usb_right_stream = sh_stream; } } @@ -3110,12 +3098,12 @@ static void update_usb_streams(struct shell_stream *sh_stream) { if (sh_stream->is_rx) { if (sh_stream == usb_left_stream) { - shell_info(ctx_shell, "Clearing USB left stream (%p)", usb_left_stream); + bt_shell_info("Clearing USB left stream (%p)", usb_left_stream); usb_left_stream = NULL; } if (sh_stream == usb_right_stream) { - shell_info(ctx_shell, "Clearing USB right stream (%p)", usb_right_stream); + bt_shell_info("Clearing USB right stream (%p)", usb_right_stream); usb_right_stream = NULL; } @@ -3177,14 +3165,14 @@ static void stream_stopped_cb(struct bt_bap_stream *stream, uint8_t reason) static void stream_configured_cb(struct bt_bap_stream *stream, const struct bt_bap_qos_cfg_pref *pref) { - shell_print(ctx_shell, "Stream %p configured\n", stream); + bt_shell_print("Stream %p configured\n", stream); } static void stream_released_cb(struct bt_bap_stream *stream) { struct shell_stream *sh_stream = shell_stream_from_bap_stream(stream); - shell_print(ctx_shell, "Stream %p released\n", stream); + bt_shell_print("Stream %p released\n", stream); #if defined(CONFIG_BT_BAP_UNICAST_CLIENT) if (default_unicast_group != NULL) { @@ -3210,12 +3198,12 @@ static void stream_released_cb(struct bt_bap_stream *stream) if (group_can_be_deleted) { int err; - shell_print(ctx_shell, "All streams released, deleting group\n"); + bt_shell_print("All streams released, deleting group\n"); err = bt_bap_unicast_group_delete(default_unicast_group); if (err != 0) { - shell_error(ctx_shell, "Failed to delete unicast group: %d", err); + bt_shell_error("Failed to delete unicast group: %d", err); } else { default_unicast_group = NULL; } @@ -3694,7 +3682,7 @@ static int cmd_set_loc(const struct shell *sh, size_t argc, char *argv[]) err = bt_pacs_set_location(dir, loc); if (err) { - shell_error(ctx_shell, "Set available contexts err %d", err); + shell_error(sh, "Set available contexts err %d", err); return -ENOEXEC; } @@ -3741,13 +3729,13 @@ static int cmd_context(const struct shell *sh, size_t argc, char *argv[]) err = bt_pacs_set_supported_contexts(dir, ctx); if (err) { - shell_error(ctx_shell, "Set supported contexts err %d", err); + shell_error(sh, "Set supported contexts err %d", err); return err; } } else if (!strcmp(argv[3], "available")) { err = bt_pacs_set_available_contexts(dir, ctx); if (err) { - shell_error(ctx_shell, "Set available contexts err %d", err); + shell_error(sh, "Set available contexts err %d", err); return err; } } else { @@ -3762,8 +3750,6 @@ static int cmd_init(const struct shell *sh, size_t argc, char *argv[]) { int err, i; - ctx_shell = sh; - if (initialized) { shell_print(sh, "Already initialized"); return -ENOEXEC; @@ -4124,7 +4110,7 @@ static int cmd_print_ase_info(const struct shell *sh, size_t argc, char *argv[]) #define HELP_CFG_META \ "\n[meta" HELP_SEP "[pref_ctx ]" HELP_SEP "[stream_ctx ]" HELP_SEP \ - "[program_info ]" HELP_SEP "[lang ]" HELP_SEP \ + "[program_info ]" HELP_SEP "[lang ]" HELP_SEP \ "[ccid_list ]" HELP_SEP "[parental_rating ]" HELP_SEP \ "[program_info_uri ]" HELP_SEP "[audio_active_state ]" HELP_SEP \ "[bcast_flag]" HELP_SEP "[extended ]" HELP_SEP "[vendor ]]" @@ -4273,7 +4259,7 @@ static ssize_t connectable_ad_data_add(struct bt_data *data_array, size_t uuid16_size; if (data_array_size <= ad_len) { - shell_warn(ctx_shell, "No space for AD_UUID16"); + bt_shell_warn("No space for AD_UUID16"); return ad_len; } @@ -4347,7 +4333,7 @@ static ssize_t nonconnectable_ad_data_add(struct bt_data *data_array, if (ARRAY_SIZE(ad_ext_uuid16) > 0) { if (data_array_size <= ad_len) { - shell_warn(ctx_shell, "No space for AD_UUID16"); + bt_shell_warn("No space for AD_UUID16"); return ad_len; } diff --git a/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c b/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c index d492330b5ead8..279a5062345d1 100644 --- a/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c +++ b/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c @@ -65,7 +65,7 @@ static bool pa_decode_base(struct bt_data *data, void *user_data) base_size = bt_bap_base_get_size(base); if (base_size < 0) { - shell_error(ctx_shell, "BASE get size failed (%d)", base_size); + bt_shell_error("BASE get size failed (%d)", base_size); return true; } @@ -93,12 +93,10 @@ static void bap_broadcast_assistant_discover_cb(struct bt_conn *conn, int err, uint8_t recv_state_count) { if (err != 0) { - shell_error(ctx_shell, "BASS discover failed (%d)", err); + bt_shell_error("BASS discover failed (%d)", err); } else { - shell_print(ctx_shell, "BASS discover done with %u recv states", - recv_state_count); + bt_shell_print("BASS discover done with %u recv states", recv_state_count); } - } static void bap_broadcast_assistant_scan_cb(const struct bt_le_scan_recv_info *info, @@ -107,8 +105,7 @@ static void bap_broadcast_assistant_scan_cb(const struct bt_le_scan_recv_info *i char le_addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(info->addr, le_addr, sizeof(le_addr)); - shell_print( - ctx_shell, + bt_shell_print( "[DEVICE]: %s, broadcast_id 0x%06X, interval (ms) %u (0x%04x)), SID 0x%x, RSSI %i", le_addr, broadcast_id, BT_GAP_PER_ADV_INTERVAL_TO_MS(info->interval), info->interval, info->sid, info->rssi); @@ -120,8 +117,8 @@ static bool metadata_entry(struct bt_data *data, void *user_data) bin2hex(data->data, data->data_len, metadata, sizeof(metadata)); - shell_print(ctx_shell, "\t\tMetadata length %u, type %u, data: %s", - data->data_len, data->type, metadata); + bt_shell_print("\t\tMetadata length %u, type %u, data: %s", + data->data_len, data->type, metadata); return true; } @@ -135,7 +132,7 @@ static void bap_broadcast_assistant_recv_state_cb( bool is_bad_code; if (err != 0) { - shell_error(ctx_shell, "BASS recv state read failed (%d)", err); + bt_shell_error("BASS recv state read failed (%d)", err); return; } @@ -143,26 +140,25 @@ static void bap_broadcast_assistant_recv_state_cb( bin2hex(state->bad_code, BT_ISO_BROADCAST_CODE_SIZE, bad_code, sizeof(bad_code)); is_bad_code = state->encrypt_state == BT_BAP_BIG_ENC_STATE_BAD_CODE; - shell_print(ctx_shell, - "BASS recv state: src_id %u, addr %s, sid %u, broadcast_id 0x%06X, sync_state " - "%u, encrypt_state %u%s%s", - state->src_id, le_addr, state->adv_sid, state->broadcast_id, - state->pa_sync_state, state->encrypt_state, is_bad_code ? ", bad code" : "", - is_bad_code ? bad_code : ""); + bt_shell_print( + "BASS recv state: src_id %u, addr %s, sid %u, broadcast_id 0x%06X, sync_state " + "%u, encrypt_state %u%s%s", + state->src_id, le_addr, state->adv_sid, state->broadcast_id, + state->pa_sync_state, state->encrypt_state, is_bad_code ? ", bad code" : "", + is_bad_code ? bad_code : ""); for (int i = 0; i < state->num_subgroups; i++) { const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i]; struct net_buf_simple buf; - shell_print(ctx_shell, "\t[%d]: BIS sync 0x%04X, metadata_len %zu", i, - subgroup->bis_sync, subgroup->metadata_len); + bt_shell_print("\t[%d]: BIS sync 0x%04X, metadata_len %zu", i, + subgroup->bis_sync, subgroup->metadata_len); net_buf_simple_init_with_data(&buf, (void *)subgroup->metadata, subgroup->metadata_len); bt_data_parse(&buf, metadata_entry, NULL); } - if (state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ) { struct bt_le_per_adv_sync *per_adv_sync = NULL; struct bt_le_ext_adv *ext_adv = NULL; @@ -172,21 +168,20 @@ static void bap_broadcast_assistant_recv_state_cb( if (per_adv_syncs[i] != NULL && bt_addr_le_eq(&per_adv_syncs[i]->addr, &state->addr)) { per_adv_sync = per_adv_syncs[i]; - shell_print(ctx_shell, "Found matching PA sync [%zu]", i); + bt_shell_print("Found matching PA sync [%zu]", i); break; } } if (per_adv_sync && IS_ENABLED(CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER)) { - shell_print(ctx_shell, "Sending PAST"); + bt_shell_print("Sending PAST"); err = bt_le_per_adv_sync_transfer(per_adv_sync, conn, BT_UUID_BASS_VAL); if (err != 0) { - shell_error(ctx_shell, "Could not transfer periodic adv sync: %d", - err); + bt_shell_error("Could not transfer periodic adv sync: %d", err); } return; @@ -204,9 +199,7 @@ static void bap_broadcast_assistant_recv_state_cb( &oob_local); if (err != 0) { - shell_error(ctx_shell, - "Could not get local OOB %d", - err); + bt_shell_error("Could not get local OOB %d", err); return; } @@ -218,61 +211,58 @@ static void bap_broadcast_assistant_recv_state_cb( if (ext_adv != NULL && IS_ENABLED(CONFIG_BT_PER_ADV) && IS_ENABLED(CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER)) { - shell_print(ctx_shell, "Sending local PAST"); + bt_shell_print("Sending local PAST"); err = bt_le_per_adv_set_info_transfer(ext_adv, conn, BT_UUID_BASS_VAL); if (err != 0) { - shell_error(ctx_shell, - "Could not transfer per adv set info: %d", - err); + bt_shell_error("Could not transfer per adv set info: %d", err); } } else { - shell_error(ctx_shell, - "Could not send PA to Scan Delegator"); + bt_shell_error("Could not send PA to Scan Delegator"); } } } static void bap_broadcast_assistant_recv_state_removed_cb(struct bt_conn *conn, uint8_t src_id) { - shell_print(ctx_shell, "BASS recv state %u removed", src_id); + bt_shell_print("BASS recv state %u removed", src_id); } static void bap_broadcast_assistant_scan_start_cb(struct bt_conn *conn, int err) { if (err != 0) { - shell_error(ctx_shell, "BASS scan start failed (%d)", err); + bt_shell_error("BASS scan start failed (%d)", err); } else { - shell_print(ctx_shell, "BASS scan start successful"); + bt_shell_print("BASS scan start successful"); } } static void bap_broadcast_assistant_scan_stop_cb(struct bt_conn *conn, int err) { if (err != 0) { - shell_error(ctx_shell, "BASS scan stop failed (%d)", err); + bt_shell_error("BASS scan stop failed (%d)", err); } else { - shell_print(ctx_shell, "BASS scan stop successful"); + bt_shell_print("BASS scan stop successful"); } } static void bap_broadcast_assistant_add_src_cb(struct bt_conn *conn, int err) { if (err != 0) { - shell_error(ctx_shell, "BASS add source failed (%d)", err); + bt_shell_error("BASS add source failed (%d)", err); } else { - shell_print(ctx_shell, "BASS add source successful"); + bt_shell_print("BASS add source successful"); } } static void bap_broadcast_assistant_mod_src_cb(struct bt_conn *conn, int err) { if (err != 0) { - shell_error(ctx_shell, "BASS modify source failed (%d)", err); + bt_shell_error("BASS modify source failed (%d)", err); } else { - shell_print(ctx_shell, "BASS modify source successful"); + bt_shell_print("BASS modify source successful"); } } @@ -280,18 +270,18 @@ static void bap_broadcast_assistant_broadcast_code_cb(struct bt_conn *conn, int err) { if (err != 0) { - shell_error(ctx_shell, "BASS broadcast code failed (%d)", err); + bt_shell_error("BASS broadcast code failed (%d)", err); } else { - shell_print(ctx_shell, "BASS broadcast code successful"); + bt_shell_print("BASS broadcast code successful"); } } static void bap_broadcast_assistant_rem_src_cb(struct bt_conn *conn, int err) { if (err != 0) { - shell_error(ctx_shell, "BASS remove source failed (%d)", err); + bt_shell_error("BASS remove source failed (%d)", err); } else { - shell_print(ctx_shell, "BASS remove source successful"); + bt_shell_print("BASS remove source successful"); } } @@ -551,18 +541,18 @@ static void scan_recv_cb(const struct bt_le_scan_recv_info *info, is_substring(auto_scan.broadcast_name, sr_info.broadcast_name)) { identified_broadcast = true; - shell_print(ctx_shell, "Found matched broadcast name '%s' with address %s", - sr_info.broadcast_name, addr_str); + bt_shell_print("Found matched broadcast name '%s' with address %s", + sr_info.broadcast_name, addr_str); } if (identified_broadcast) { - shell_print(ctx_shell, - "Found BAP broadcast source with address %s and ID 0x%06X\n", - addr_str, sr_info.broadcast_id); + bt_shell_print( + "Found BAP broadcast source with address %s and ID 0x%06X\n", + addr_str, sr_info.broadcast_id); err = bt_le_scan_stop(); if (err) { - shell_error(ctx_shell, "Failed to stop scan: %d", err); + bt_shell_error("Failed to stop scan: %d", err); } bt_addr_le_copy(¶m.addr, info->addr); @@ -575,7 +565,7 @@ static void scan_recv_cb(const struct bt_le_scan_recv_info *info, err = bt_bap_broadcast_assistant_add_src(default_conn, ¶m); if (err) { - shell_print(ctx_shell, "Failed to add source: %d", err); + bt_shell_print("Failed to add source: %d", err); } memset(&auto_scan, 0, sizeof(auto_scan)); @@ -586,7 +576,7 @@ static void scan_recv_cb(const struct bt_le_scan_recv_info *info, static void scan_timeout_cb(void) { - shell_print(ctx_shell, "Scan timeout"); + bt_shell_print("Scan timeout"); memset(&auto_scan, 0, sizeof(auto_scan)); auto_scan.broadcast_id = BT_BAP_INVALID_BROADCAST_ID; @@ -891,8 +881,8 @@ static inline bool add_pa_sync_base_subgroup_cb(const struct bt_bap_base_subgrou int ret; if (param->num_subgroups == CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) { - shell_warn(ctx_shell, "Cannot fit all subgroups param with size %d", - CONFIG_BT_BAP_BASS_MAX_SUBGROUPS); + bt_shell_warn("Cannot fit all subgroups param with size %d", + CONFIG_BT_BAP_BASS_MAX_SUBGROUPS); return true; /* return true to avoid returning -ECANCELED as this is OK */ } @@ -905,8 +895,8 @@ static inline bool add_pa_sync_base_subgroup_cb(const struct bt_bap_base_subgrou subgroup_param = ¶m->subgroups[param->num_subgroups]; if (ret > ARRAY_SIZE(subgroup_param->metadata)) { - shell_info(ctx_shell, "Cannot fit %d octets into subgroup param with size %zu", ret, - ARRAY_SIZE(subgroup_param->metadata)); + bt_shell_info("Cannot fit %d octets into subgroup param with size %zu", ret, + ARRAY_SIZE(subgroup_param->metadata)); return false; } @@ -1001,7 +991,7 @@ static int cmd_bap_broadcast_assistant_add_pa_sync(const struct shell *sh, err = bt_bap_base_foreach_subgroup((const struct bt_bap_base *)received_base, add_pa_sync_base_subgroup_cb, ¶m); if (err < 0) { - shell_error(ctx_shell, "Could not add BASE to params %d", err); + shell_error(sh, "Could not add BASE to params %d", err); return -ENOEXEC; } @@ -1023,7 +1013,7 @@ static int cmd_bap_broadcast_assistant_add_pa_sync(const struct shell *sh, if ((subgroups_bis_sync & bis_bitfield_req) != bis_bitfield_req) { /* bis_sync of all subgroups should contain at least all the bits in request */ /* Otherwise Command will be rejected */ - shell_error(ctx_shell, "Cannot set BIS index 0x%06X when BASE subgroups only " + shell_error(sh, "Cannot set BIS index 0x%06X when BASE subgroups only " "supports %d", bis_bitfield_req, subgroups_bis_sync); return -ENOEXEC; } diff --git a/subsys/bluetooth/audio/shell/bap_scan_delegator.c b/subsys/bluetooth/audio/shell/bap_scan_delegator.c index a4a515a0db508..e88b153c332fb 100644 --- a/subsys/bluetooth/audio/shell/bap_scan_delegator.c +++ b/subsys/bluetooth/audio/shell/bap_scan_delegator.c @@ -33,6 +33,7 @@ #include