From c8e1b1e264060bc4e39fde376b0d1a4bc1db3dad Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Thu, 16 Mar 2023 17:18:08 +0100 Subject: [PATCH] Bluetooth: Audio: Move audio shell to audio directory Move all audio related shell implementations to the audio directory, to use the same structure as Mesh. Signed-off-by: Emil Gydesen --- subsys/bluetooth/audio/CMakeLists.txt | 2 + subsys/bluetooth/audio/shell/CMakeLists.txt | 79 +++++++++++++++++++ subsys/bluetooth/audio/shell/audio.h | 25 ++++++ subsys/bluetooth/{ => audio}/shell/bap.c | 2 +- .../shell/bap_broadcast_assistant.c | 4 +- .../{ => audio}/shell/bap_scan_delegator.c | 2 +- .../{ => audio}/shell/cap_acceptor.c | 2 +- .../{ => audio}/shell/cap_initiator.c | 2 +- .../{ => audio}/shell/csip_set_coordinator.c | 2 +- .../{ => audio}/shell/csip_set_member.c | 2 +- subsys/bluetooth/{ => audio}/shell/has.c | 2 +- .../bluetooth/{ => audio}/shell/has_client.c | 2 +- subsys/bluetooth/{ => audio}/shell/mcc.c | 6 +- .../{ => audio}/shell/media_controller.c | 4 +- .../{ => audio}/shell/micp_mic_ctlr.c | 2 +- .../{ => audio}/shell/micp_mic_dev.c | 2 +- subsys/bluetooth/{ => audio}/shell/mpl.c | 4 +- subsys/bluetooth/{ => audio}/shell/tbs.c | 2 +- .../bluetooth/{ => audio}/shell/tbs_client.c | 2 +- .../{ => audio}/shell/vcp_vol_ctlr.c | 2 +- .../{ => audio}/shell/vcp_vol_rend.c | 2 +- subsys/bluetooth/shell/CMakeLists.txt | 76 ------------------ subsys/bluetooth/shell/bt.c | 1 + subsys/bluetooth/shell/bt.h | 6 -- 24 files changed, 130 insertions(+), 105 deletions(-) create mode 100644 subsys/bluetooth/audio/shell/CMakeLists.txt create mode 100644 subsys/bluetooth/audio/shell/audio.h rename subsys/bluetooth/{ => audio}/shell/bap.c (99%) rename subsys/bluetooth/{ => audio}/shell/bap_broadcast_assistant.c (99%) rename subsys/bluetooth/{ => audio}/shell/bap_scan_delegator.c (99%) rename subsys/bluetooth/{ => audio}/shell/cap_acceptor.c (99%) rename subsys/bluetooth/{ => audio}/shell/cap_initiator.c (98%) rename subsys/bluetooth/{ => audio}/shell/csip_set_coordinator.c (99%) rename subsys/bluetooth/{ => audio}/shell/csip_set_member.c (99%) rename subsys/bluetooth/{ => audio}/shell/has.c (99%) rename subsys/bluetooth/{ => audio}/shell/has_client.c (99%) rename subsys/bluetooth/{ => audio}/shell/mcc.c (99%) rename subsys/bluetooth/{ => audio}/shell/media_controller.c (99%) rename subsys/bluetooth/{ => audio}/shell/micp_mic_ctlr.c (99%) rename subsys/bluetooth/{ => audio}/shell/micp_mic_dev.c (99%) rename subsys/bluetooth/{ => audio}/shell/mpl.c (99%) rename subsys/bluetooth/{ => audio}/shell/tbs.c (99%) rename subsys/bluetooth/{ => audio}/shell/tbs_client.c (99%) rename subsys/bluetooth/{ => audio}/shell/vcp_vol_ctlr.c (99%) rename subsys/bluetooth/{ => audio}/shell/vcp_vol_rend.c (99%) diff --git a/subsys/bluetooth/audio/CMakeLists.txt b/subsys/bluetooth/audio/CMakeLists.txt index e49db297e0b..c72f580d0b7 100644 --- a/subsys/bluetooth/audio/CMakeLists.txt +++ b/subsys/bluetooth/audio/CMakeLists.txt @@ -1,5 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 +add_subdirectory_ifdef(CONFIG_BT_SHELL shell) + zephyr_library() zephyr_library_sources( audio.c diff --git a/subsys/bluetooth/audio/shell/CMakeLists.txt b/subsys/bluetooth/audio/shell/CMakeLists.txt new file mode 100644 index 00000000000..47e90c5b79b --- /dev/null +++ b/subsys/bluetooth/audio/shell/CMakeLists.txt @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: Apache-2.0 + +zephyr_library() +zephyr_library_link_libraries(subsys__bluetooth) + +zephyr_library_sources_ifdef( + CONFIG_BT_VCP_VOL_REND + vcp_vol_rend.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_VCP_VOL_CTLR + vcp_vol_ctlr.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_MICP_MIC_DEV + micp_mic_dev.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_MICP_MIC_CTLR + micp_mic_ctlr.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_CSIP_SET_MEMBER + csip_set_member.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_CSIP_SET_COORDINATOR + csip_set_coordinator.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_TBS + tbs.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_TBS_CLIENT + tbs_client.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_MPL + mpl.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_MCC + mcc.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_MCS + media_controller.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_HAS_PRESET_SUPPORT + has.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER + cap_acceptor.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_CAP_INITIATOR + cap_initiator.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_HAS_CLIENT + has_client.c + ) +# We use BT_BAP_STREAM as a common ground for audio, as that is set whenever +# any audio stream functionality is enabled. +zephyr_library_sources_ifdef( + CONFIG_BT_BAP_STREAM + bap.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_BAP_SCAN_DELEGATOR + bap_scan_delegator.c + ) +zephyr_library_sources_ifdef( + CONFIG_BT_BAP_BROADCAST_ASSISTANT + bap_broadcast_assistant.c + ) diff --git a/subsys/bluetooth/audio/shell/audio.h b/subsys/bluetooth/audio/shell/audio.h new file mode 100644 index 00000000000..1776812637d --- /dev/null +++ b/subsys/bluetooth/audio/shell/audio.h @@ -0,0 +1,25 @@ +/** @file + * @brief Bluetooth audio shell functions + * + * This is not to be included by the application. + */ + +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef __AUDIO_H +#define __AUDIO_H + +#include + +extern struct bt_csip_set_member_svc_inst *svc_inst; + +ssize_t audio_ad_data_add(struct bt_data *data, const size_t data_size, const bool discoverable, + const bool connectable); +ssize_t audio_pa_data_add(struct bt_data *data_array, const size_t data_array_size); +ssize_t csis_ad_data_add(struct bt_data *data, const size_t data_size, const bool discoverable); + +#endif /* __AUDIO_H */ diff --git a/subsys/bluetooth/shell/bap.c b/subsys/bluetooth/audio/shell/bap.c similarity index 99% rename from subsys/bluetooth/shell/bap.c rename to subsys/bluetooth/audio/shell/bap.c index 72d4fb77b73..43cf8b7f6ee 100644 --- a/subsys/bluetooth/shell/bap.c +++ b/subsys/bluetooth/audio/shell/bap.c @@ -25,7 +25,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" #define LOCATION BT_AUDIO_LOCATION_FRONT_LEFT #define CONTEXT BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | BT_AUDIO_CONTEXT_TYPE_MEDIA diff --git a/subsys/bluetooth/shell/bap_broadcast_assistant.c b/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c similarity index 99% rename from subsys/bluetooth/shell/bap_broadcast_assistant.c rename to subsys/bluetooth/audio/shell/bap_broadcast_assistant.c index 5af44c93627..342a62b86b7 100644 --- a/subsys/bluetooth/shell/bap_broadcast_assistant.c +++ b/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c @@ -18,8 +18,8 @@ #include #include #include -#include "bt.h" -#include "../host/hci_core.h" +#include "shell/bt.h" +#include "../../host/hci_core.h" static void bap_broadcast_assistant_discover_cb(struct bt_conn *conn, int err, uint8_t recv_state_count) diff --git a/subsys/bluetooth/shell/bap_scan_delegator.c b/subsys/bluetooth/audio/shell/bap_scan_delegator.c similarity index 99% rename from subsys/bluetooth/shell/bap_scan_delegator.c rename to subsys/bluetooth/audio/shell/bap_scan_delegator.c index c355df42def..4e452a2d258 100644 --- a/subsys/bluetooth/shell/bap_scan_delegator.c +++ b/subsys/bluetooth/audio/shell/bap_scan_delegator.c @@ -16,7 +16,7 @@ #include #include #include -#include "bt.h" +#include "shell/bt.h" static void pa_synced(struct bt_bap_scan_delegator_recv_state *recv_state, const struct bt_le_per_adv_sync_synced_info *info) diff --git a/subsys/bluetooth/shell/cap_acceptor.c b/subsys/bluetooth/audio/shell/cap_acceptor.c similarity index 99% rename from subsys/bluetooth/shell/cap_acceptor.c rename to subsys/bluetooth/audio/shell/cap_acceptor.c index 34cd5efb380..63e5b1c791e 100644 --- a/subsys/bluetooth/shell/cap_acceptor.c +++ b/subsys/bluetooth/audio/shell/cap_acceptor.c @@ -13,7 +13,7 @@ #include #include #include -#include "bt.h" +#include "shell/bt.h" extern const struct shell *ctx_shell; static struct bt_csip_set_member_svc_inst *cap_csip_svc_inst; diff --git a/subsys/bluetooth/shell/cap_initiator.c b/subsys/bluetooth/audio/shell/cap_initiator.c similarity index 98% rename from subsys/bluetooth/shell/cap_initiator.c rename to subsys/bluetooth/audio/shell/cap_initiator.c index 06519b99687..a68a255ed39 100644 --- a/subsys/bluetooth/shell/cap_initiator.c +++ b/subsys/bluetooth/audio/shell/cap_initiator.c @@ -15,7 +15,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" #if defined(CONFIG_BT_BAP_UNICAST_CLIENT) diff --git a/subsys/bluetooth/shell/csip_set_coordinator.c b/subsys/bluetooth/audio/shell/csip_set_coordinator.c similarity index 99% rename from subsys/bluetooth/shell/csip_set_coordinator.c rename to subsys/bluetooth/audio/shell/csip_set_coordinator.c index 7d15942310e..acf45fa7935 100644 --- a/subsys/bluetooth/shell/csip_set_coordinator.c +++ b/subsys/bluetooth/audio/shell/csip_set_coordinator.c @@ -18,7 +18,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" #include diff --git a/subsys/bluetooth/shell/csip_set_member.c b/subsys/bluetooth/audio/shell/csip_set_member.c similarity index 99% rename from subsys/bluetooth/shell/csip_set_member.c rename to subsys/bluetooth/audio/shell/csip_set_member.c index 0eccb3b35a0..7f382a8f522 100644 --- a/subsys/bluetooth/shell/csip_set_member.c +++ b/subsys/bluetooth/audio/shell/csip_set_member.c @@ -17,7 +17,7 @@ #include #include #include -#include "bt.h" +#include "shell/bt.h" extern const struct shell *ctx_shell; struct bt_csip_set_member_svc_inst *svc_inst; diff --git a/subsys/bluetooth/shell/has.c b/subsys/bluetooth/audio/shell/has.c similarity index 99% rename from subsys/bluetooth/shell/has.c rename to subsys/bluetooth/audio/shell/has.c index 1e647792594..480059ef0f0 100644 --- a/subsys/bluetooth/shell/has.c +++ b/subsys/bluetooth/audio/shell/has.c @@ -15,7 +15,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" static int preset_select(uint8_t index, bool sync) { diff --git a/subsys/bluetooth/shell/has_client.c b/subsys/bluetooth/audio/shell/has_client.c similarity index 99% rename from subsys/bluetooth/shell/has_client.c rename to subsys/bluetooth/audio/shell/has_client.c index a10a430a5de..520304369fd 100644 --- a/subsys/bluetooth/shell/has_client.c +++ b/subsys/bluetooth/audio/shell/has_client.c @@ -15,7 +15,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" static struct bt_has *inst; diff --git a/subsys/bluetooth/shell/mcc.c b/subsys/bluetooth/audio/shell/mcc.c similarity index 99% rename from subsys/bluetooth/shell/mcc.c rename to subsys/bluetooth/audio/shell/mcc.c index 80586dc9c9c..7432b01b7f0 100644 --- a/subsys/bluetooth/shell/mcc.c +++ b/subsys/bluetooth/audio/shell/mcc.c @@ -15,11 +15,11 @@ #include #include -#include "bt.h" +#include "shell/bt.h" #include -#include "../services/ots/ots_client_internal.h" -#include "../audio/media_proxy_internal.h" +#include "../../services/ots/ots_client_internal.h" +#include "../media_proxy_internal.h" #include diff --git a/subsys/bluetooth/shell/media_controller.c b/subsys/bluetooth/audio/shell/media_controller.c similarity index 99% rename from subsys/bluetooth/shell/media_controller.c rename to subsys/bluetooth/audio/shell/media_controller.c index d4c323e5603..a291e47dc0e 100644 --- a/subsys/bluetooth/shell/media_controller.c +++ b/subsys/bluetooth/audio/shell/media_controller.c @@ -14,11 +14,11 @@ #include #include -#include "bt.h" +#include "shell/bt.h" #include #include -#include "../audio/media_proxy_internal.h" /* For MPL_NO_TRACK_ID - TODO: Fix */ +#include "../media_proxy_internal.h" /* For MPL_NO_TRACK_ID - TODO: Fix */ #include diff --git a/subsys/bluetooth/shell/micp_mic_ctlr.c b/subsys/bluetooth/audio/shell/micp_mic_ctlr.c similarity index 99% rename from subsys/bluetooth/shell/micp_mic_ctlr.c rename to subsys/bluetooth/audio/shell/micp_mic_ctlr.c index 0639c18d2be..086155b70b6 100644 --- a/subsys/bluetooth/shell/micp_mic_ctlr.c +++ b/subsys/bluetooth/audio/shell/micp_mic_ctlr.c @@ -14,7 +14,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" static struct bt_micp_mic_ctlr *mic_ctlr; #if defined(CONFIG_BT_MICP_MIC_CTLR_AICS) diff --git a/subsys/bluetooth/shell/micp_mic_dev.c b/subsys/bluetooth/audio/shell/micp_mic_dev.c similarity index 99% rename from subsys/bluetooth/shell/micp_mic_dev.c rename to subsys/bluetooth/audio/shell/micp_mic_dev.c index e1f761ddc41..6e4ace111b5 100644 --- a/subsys/bluetooth/shell/micp_mic_dev.c +++ b/subsys/bluetooth/audio/shell/micp_mic_dev.c @@ -14,7 +14,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" static void micp_mic_dev_mute_cb(uint8_t mute) { diff --git a/subsys/bluetooth/shell/mpl.c b/subsys/bluetooth/audio/shell/mpl.c similarity index 99% rename from subsys/bluetooth/shell/mpl.c rename to subsys/bluetooth/audio/shell/mpl.c index eb1669410ab..fe0c986cc03 100644 --- a/subsys/bluetooth/shell/mpl.c +++ b/subsys/bluetooth/audio/shell/mpl.c @@ -14,10 +14,10 @@ #include #include -#include "bt.h" +#include "shell/bt.h" #include -#include "../audio/mpl_internal.h" +#include "../mpl_internal.h" #include diff --git a/subsys/bluetooth/shell/tbs.c b/subsys/bluetooth/audio/shell/tbs.c similarity index 99% rename from subsys/bluetooth/shell/tbs.c rename to subsys/bluetooth/audio/shell/tbs.c index d829c087cc1..a188d87f31f 100644 --- a/subsys/bluetooth/shell/tbs.c +++ b/subsys/bluetooth/audio/shell/tbs.c @@ -14,7 +14,7 @@ #include -#include "bt.h" +#include "shell/bt.h" static struct bt_conn *tbs_authorized_conn; static bool cbs_registered; diff --git a/subsys/bluetooth/shell/tbs_client.c b/subsys/bluetooth/audio/shell/tbs_client.c similarity index 99% rename from subsys/bluetooth/shell/tbs_client.c rename to subsys/bluetooth/audio/shell/tbs_client.c index a9bd49fbf42..3295ff865e4 100644 --- a/subsys/bluetooth/shell/tbs_client.c +++ b/subsys/bluetooth/audio/shell/tbs_client.c @@ -22,7 +22,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" static int cmd_tbs_client_discover(const struct shell *sh, size_t argc, char *argv[]) diff --git a/subsys/bluetooth/shell/vcp_vol_ctlr.c b/subsys/bluetooth/audio/shell/vcp_vol_ctlr.c similarity index 99% rename from subsys/bluetooth/shell/vcp_vol_ctlr.c rename to subsys/bluetooth/audio/shell/vcp_vol_ctlr.c index 7e0afa3b53a..90fa26bb1a0 100644 --- a/subsys/bluetooth/shell/vcp_vol_ctlr.c +++ b/subsys/bluetooth/audio/shell/vcp_vol_ctlr.c @@ -13,7 +13,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" static struct bt_vcp_vol_ctlr *vol_ctlr; static struct bt_vcp_included vcp_included; diff --git a/subsys/bluetooth/shell/vcp_vol_rend.c b/subsys/bluetooth/audio/shell/vcp_vol_rend.c similarity index 99% rename from subsys/bluetooth/shell/vcp_vol_rend.c rename to subsys/bluetooth/audio/shell/vcp_vol_rend.c index 729cd4149f7..9fb2287d6ba 100644 --- a/subsys/bluetooth/shell/vcp_vol_rend.c +++ b/subsys/bluetooth/audio/shell/vcp_vol_rend.c @@ -15,7 +15,7 @@ #include #include -#include "bt.h" +#include "shell/bt.h" static struct bt_vcp_included vcp_included; diff --git a/subsys/bluetooth/shell/CMakeLists.txt b/subsys/bluetooth/shell/CMakeLists.txt index f0d0c48c41d..6c8509fcd8a 100644 --- a/subsys/bluetooth/shell/CMakeLists.txt +++ b/subsys/bluetooth/shell/CMakeLists.txt @@ -25,82 +25,6 @@ zephyr_library_sources_ifdef( CONFIG_BT_ISO iso.c ) -zephyr_library_sources_ifdef( - CONFIG_BT_VCP_VOL_REND - vcp_vol_rend.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_VCP_VOL_CTLR - vcp_vol_ctlr.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_MICP_MIC_DEV - micp_mic_dev.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_MICP_MIC_CTLR - micp_mic_ctlr.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_CSIP_SET_MEMBER - csip_set_member.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_CSIP_SET_COORDINATOR - csip_set_coordinator.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_TBS - tbs.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_TBS_CLIENT - tbs_client.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_MPL - mpl.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_MCC - mcc.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_MCS - media_controller.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_HAS_PRESET_SUPPORT - has.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER - cap_acceptor.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_CAP_INITIATOR - cap_initiator.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_HAS_CLIENT - has_client.c - ) -# We use BT_BAP_STREAM as a common ground for audio, as that is set whenever -# any audio stream functionality is enabled. -zephyr_library_sources_ifdef( - CONFIG_BT_BAP_STREAM - bap.c - ) - -zephyr_library_sources_ifdef( - CONFIG_BT_BAP_SCAN_DELEGATOR - bap_scan_delegator.c - ) -zephyr_library_sources_ifdef( - CONFIG_BT_BAP_BROADCAST_ASSISTANT - bap_broadcast_assistant.c - ) - zephyr_library_sources_ifdef( CONFIG_BT_IAS ias.c diff --git a/subsys/bluetooth/shell/bt.c b/subsys/bluetooth/shell/bt.c index a7f135b09be..5644bf08242 100644 --- a/subsys/bluetooth/shell/bt.c +++ b/subsys/bluetooth/shell/bt.c @@ -41,6 +41,7 @@ #include "bt.h" #include "ll.h" #include "hci.h" +#include "../audio/shell/audio.h" static bool no_settings_load; diff --git a/subsys/bluetooth/shell/bt.h b/subsys/bluetooth/shell/bt.h index 9c0a2a408a2..76772f85bf5 100644 --- a/subsys/bluetooth/shell/bt.h +++ b/subsys/bluetooth/shell/bt.h @@ -18,7 +18,6 @@ extern const struct shell *ctx_shell; extern struct bt_conn *default_conn; -extern struct bt_csip_set_member_svc_inst *svc_inst; #if defined(CONFIG_BT_ISO) extern struct bt_iso_chan iso_chan; @@ -33,10 +32,5 @@ extern struct bt_le_per_adv_sync *per_adv_syncs[CONFIG_BT_PER_ADV_SYNC_MAX]; #endif /* CONFIG_BT_EXT_ADV */ void conn_addr_str(struct bt_conn *conn, char *addr, size_t len); -ssize_t audio_ad_data_add(struct bt_data *data, const size_t data_size, const bool discoverable, - const bool connectable); -ssize_t audio_pa_data_add(struct bt_data *data_array, - const size_t data_array_size); -ssize_t csis_ad_data_add(struct bt_data *data, const size_t data_size, const bool discoverable); #endif /* __BT_H */