From 2627063ab21913bf82c5342ce115af1bf18e4299 Mon Sep 17 00:00:00 2001 From: Mariusz Skamra Date: Thu, 20 Oct 2022 11:25:38 +0200 Subject: [PATCH] Bluetooth: audio: pacs: Replace capabilities API with pacs This changes the API to use proper naming convention, as the code has been moved out of capabilities. Signed-off-by: Mariusz Skamra --- .../audio/{capabilities.h => pacs.h} | 45 +++++++------ .../bluetooth/broadcast_audio_sink/src/main.c | 6 +- samples/bluetooth/hap_ha/src/bap_unicast_sr.c | 10 +-- samples/bluetooth/hap_ha/src/main.c | 24 +++---- .../bluetooth/unicast_audio_server/src/main.c | 28 ++++---- subsys/bluetooth/audio/ascs.c | 10 +-- subsys/bluetooth/audio/has.c | 16 ++--- subsys/bluetooth/audio/pacs.c | 67 +++++++++---------- subsys/bluetooth/shell/audio.c | 28 ++++---- subsys/bluetooth/shell/bt.c | 2 +- .../bsim_test_audio/src/broadcast_sink_test.c | 6 +- .../bsim_test_audio/src/unicast_client_test.c | 2 +- .../bsim_test_audio/src/unicast_server_test.c | 26 +++---- 13 files changed, 135 insertions(+), 135 deletions(-) rename include/zephyr/bluetooth/audio/{capabilities.h => pacs.h} (59%) diff --git a/include/zephyr/bluetooth/audio/capabilities.h b/include/zephyr/bluetooth/audio/pacs.h similarity index 59% rename from include/zephyr/bluetooth/audio/capabilities.h rename to include/zephyr/bluetooth/audio/pacs.h index 20c7a9a07bc..db8d903dfc8 100644 --- a/include/zephyr/bluetooth/audio/capabilities.h +++ b/include/zephyr/bluetooth/audio/pacs.h @@ -7,8 +7,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_ -#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_ +#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_ +#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_ #include @@ -16,8 +16,8 @@ extern "C" { #endif -/** @brief Audio Capability structure. */ -struct bt_audio_capability { +/** @brief Published Audio Capability structure. */ +struct bt_pacs_cap { /** Capability codec reference */ struct bt_codec *codec; @@ -25,19 +25,19 @@ struct bt_audio_capability { sys_snode_t _node; }; -/** @typedef bt_audio_foreach_capability_func_t - * @brief Capability iterator callback. +/** @typedef bt_pacs_cap_foreach_func_t + * @brief Published Audio Capability iterator callback. * - * @param capability Capability found. + * @param cap Capability found. * @param user_data Data given. * * @return true to continue to the next capability * @return false to stop the iteration */ -typedef bool (*bt_audio_foreach_capability_func_t)(const struct bt_audio_capability *capability, - void *user_data); +typedef bool (*bt_pacs_cap_foreach_func_t)(const struct bt_pacs_cap *cap, + void *user_data); -/** @brief Capability iterator. +/** @brief Published Audio Capability iterator. * * Iterate capabilities with endpoint direction specified. * @@ -45,10 +45,11 @@ typedef bool (*bt_audio_foreach_capability_func_t)(const struct bt_audio_capabil * @param func Callback function. * @param user_data Data to pass to the callback. */ -void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capability_func_t func, - void *user_data); +void bt_pacs_cap_foreach(enum bt_audio_dir dir, + bt_pacs_cap_foreach_func_t func, + void *user_data); -/** @brief Register Audio Capability. +/** @brief Register Published Audio Capability. * * Register Audio Local Capability. * @@ -57,9 +58,9 @@ void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capabil * * @return 0 in case of success or negative value in case of error. */ -int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capability *cap); +int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap); -/** @brief Unregister Audio Capability. +/** @brief Unregister Published Audio Capability. * * Unregister Audio Local Capability. * @@ -68,7 +69,7 @@ int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capabili * * @return 0 in case of success or negative value in case of error. */ -int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capability *cap); +int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap); /** @brief Set the location for an endpoint type * @@ -76,16 +77,16 @@ int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capabi * @param location The location to be set. * */ -int bt_audio_capability_set_location(enum bt_audio_dir dir, - enum bt_audio_location location); +int bt_pacs_set_location(enum bt_audio_dir dir, + enum bt_audio_location location); /** @brief Set the available contexts for an endpoint type * * @param dir Direction of the endpoints to change available contexts for. * @param contexts The contexts to be set. */ -int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir, - enum bt_audio_context contexts); +int bt_pacs_set_available_contexts(enum bt_audio_dir dir, + enum bt_audio_context contexts); /** @brief Get the available contexts for an endpoint type * @@ -93,10 +94,10 @@ int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir, * * @return Bitmask of available contexts. */ -enum bt_audio_context bt_audio_capability_get_available_contexts(enum bt_audio_dir dir); +enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir); #ifdef __cplusplus } #endif -#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAPABILITIES_H_ */ +#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_ */ diff --git a/samples/bluetooth/broadcast_audio_sink/src/main.c b/samples/bluetooth/broadcast_audio_sink/src/main.c index ceb7558a7b9..66b41933136 100644 --- a/samples/bluetooth/broadcast_audio_sink/src/main.c +++ b/samples/bluetooth/broadcast_audio_sink/src/main.c @@ -6,7 +6,7 @@ #include #include -#include +#include #define SEM_TIMEOUT K_SECONDS(10) @@ -148,7 +148,7 @@ static struct bt_audio_broadcast_sink_cb broadcast_sink_cbs = { .pa_sync_lost = pa_sync_lost_cb }; -static struct bt_audio_capability capabilities = { +static struct bt_pacs_cap cap = { .codec = &codec, }; @@ -164,7 +164,7 @@ static int init(void) printk("Bluetooth initialized\n"); - err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &capabilities); + err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap); if (err) { printk("Capability register failed (err %d)\n", err); return err; diff --git a/samples/bluetooth/hap_ha/src/bap_unicast_sr.c b/samples/bluetooth/hap_ha/src/bap_unicast_sr.c index 0def2418c45..e8465aac7d6 100644 --- a/samples/bluetooth/hap_ha/src/bap_unicast_sr.c +++ b/samples/bluetooth/hap_ha/src/bap_unicast_sr.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include NET_BUF_POOL_FIXED_DEFINE(tx_pool, CONFIG_BT_ASCS_ASE_SRC_COUNT, BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_TX_MTU), @@ -411,11 +411,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { .disconnected = disconnected, }; -static struct bt_audio_capability caps_sink = { +static struct bt_pacs_cap cap_sink = { .codec = &lc3_codec, }; -static struct bt_audio_capability caps_source = { +static struct bt_pacs_cap cap_source = { .codec = &lc3_codec, }; @@ -423,10 +423,10 @@ int bap_unicast_sr_init(void) { bt_audio_unicast_server_register_cb(&unicast_server_cb); - bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink); + bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink); if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) { - bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source); + bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source); } for (size_t i = 0; i < ARRAY_SIZE(streams); i++) { diff --git a/samples/bluetooth/hap_ha/src/main.c b/samples/bluetooth/hap_ha/src/main.c index 0c8c1d889b0..816b1b35248 100644 --- a/samples/bluetooth/hap_ha/src/main.c +++ b/samples/bluetooth/hap_ha/src/main.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -213,22 +213,22 @@ void main(void) * Front Left and the Front Right bits to a value of 0b1 * in the Sink Audio Locations characteristic value. */ - bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, - (BT_AUDIO_LOCATION_FRONT_LEFT | - BT_AUDIO_LOCATION_FRONT_RIGHT)); + bt_pacs_set_location(BT_AUDIO_DIR_SINK, + (BT_AUDIO_LOCATION_FRONT_LEFT | + BT_AUDIO_LOCATION_FRONT_RIGHT)); } else { - bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, - BT_AUDIO_LOCATION_FRONT_LEFT); + bt_pacs_set_location(BT_AUDIO_DIR_SINK, + BT_AUDIO_LOCATION_FRONT_LEFT); } - bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, - AVAILABLE_SINK_CONTEXT); + bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK, + AVAILABLE_SINK_CONTEXT); if (IS_ENABLED(CONFIG_BT_ASCS_ASE_SRC)) { - bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, - BT_AUDIO_LOCATION_FRONT_LEFT); - bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, - AVAILABLE_SOURCE_CONTEXT); + bt_pacs_set_location(BT_AUDIO_DIR_SOURCE, + BT_AUDIO_LOCATION_FRONT_LEFT); + bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE, + AVAILABLE_SOURCE_CONTEXT); } k_work_init_delayable(&adv_work, adv_work_handler); diff --git a/samples/bluetooth/unicast_audio_server/src/main.c b/samples/bluetooth/unicast_audio_server/src/main.c index daaa64d415e..fefc6a50ce6 100644 --- a/samples/bluetooth/unicast_audio_server/src/main.c +++ b/samples/bluetooth/unicast_audio_server/src/main.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #define AVAILABLE_SINK_CONTEXT (BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | \ @@ -563,11 +563,11 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { .disconnected = disconnected, }; -static struct bt_audio_capability caps_sink = { +static struct bt_pacs_cap cap_sink = { .codec = &lc3_codec, }; -static struct bt_audio_capability caps_source = { +static struct bt_pacs_cap cap_source = { .codec = &lc3_codec, }; @@ -576,8 +576,8 @@ static int set_location(void) int err; if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) { - err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, - BT_AUDIO_LOCATION_FRONT_CENTER); + err = bt_pacs_set_location(BT_AUDIO_DIR_SINK, + BT_AUDIO_LOCATION_FRONT_CENTER); if (err != 0) { printk("Failed to set sink location (err %d)\n", err); return err; @@ -585,9 +585,9 @@ static int set_location(void) } if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) { - err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, - (BT_AUDIO_LOCATION_FRONT_LEFT | - BT_AUDIO_LOCATION_FRONT_RIGHT)); + err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE, + (BT_AUDIO_LOCATION_FRONT_LEFT | + BT_AUDIO_LOCATION_FRONT_RIGHT)); if (err != 0) { printk("Failed to set source location (err %d)\n", err); return err; @@ -604,8 +604,8 @@ static int set_available_contexts(void) int err; if (IS_ENABLED(CONFIG_BT_PAC_SNK)) { - err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, - AVAILABLE_SINK_CONTEXT); + err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK, + AVAILABLE_SINK_CONTEXT); if (err != 0) { printk("Failed to set sink available contexts (err %d)\n", err); return err; @@ -613,8 +613,8 @@ static int set_available_contexts(void) } if (IS_ENABLED(CONFIG_BT_PAC_SRC)) { - err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, - AVAILABLE_SOURCE_CONTEXT); + err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE, + AVAILABLE_SOURCE_CONTEXT); if (err != 0) { printk("Failed to set source available contexts (err %d)\n", err); return err; @@ -640,8 +640,8 @@ void main(void) bt_audio_unicast_server_register_cb(&unicast_server_cb); - bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink); - bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source); + bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink); + bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source); for (size_t i = 0; i < ARRAY_SIZE(streams); i++) { bt_audio_stream_cb_register(&streams[i], &stream_ops); diff --git a/subsys/bluetooth/audio/ascs.c b/subsys/bluetooth/audio/ascs.c index 59bb65ee056..a7befe9b4cb 100644 --- a/subsys/bluetooth/audio/ascs.c +++ b/subsys/bluetooth/audio/ascs.c @@ -20,7 +20,7 @@ #include #include "zephyr/bluetooth/iso.h" #include -#include +#include #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_ASCS) #define LOG_MODULE_NAME bt_ascs @@ -1187,12 +1187,12 @@ struct codec_lookup_id_data { struct bt_codec *codec; }; -static bool codec_lookup_id(const struct bt_audio_capability *capability, void *user_data) +static bool codec_lookup_id(const struct bt_pacs_cap *cap, void *user_data) { struct codec_lookup_id_data *data = user_data; - if (capability->codec->id == data->id) { - data->codec = capability->codec; + if (cap->codec->id == data->id) { + data->codec = cap->codec; return false; } @@ -1216,7 +1216,7 @@ static int ascs_ep_set_codec(struct bt_audio_ep *ep, uint8_t id, uint16_t cid, BT_DBG("ep %p dir %u codec id 0x%02x cid 0x%04x vid 0x%04x len %u", ep, ep->dir, id, cid, vid, len); - bt_audio_foreach_capability(ep->dir, codec_lookup_id, &lookup_data); + bt_pacs_cap_foreach(ep->dir, codec_lookup_id, &lookup_data); if (lookup_data.codec == NULL) { return -ENOENT; diff --git a/subsys/bluetooth/audio/has.c b/subsys/bluetooth/audio/has.c index 8cc0946aa0b..424b753078e 100644 --- a/subsys/bluetooth/audio/has.c +++ b/subsys/bluetooth/audio/has.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -1151,15 +1151,15 @@ static int has_init(const struct device *dev) * Front Left and the Front Right bits to a value of 0b1 * in the Sink Audio Locations characteristic value. */ - bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, - (BT_AUDIO_LOCATION_FRONT_LEFT | - BT_AUDIO_LOCATION_FRONT_RIGHT)); + bt_pacs_set_location(BT_AUDIO_DIR_SINK, + (BT_AUDIO_LOCATION_FRONT_LEFT | + BT_AUDIO_LOCATION_FRONT_RIGHT)); } else if (IS_ENABLED(CONFIG_BT_HAS_HEARING_AID_LEFT)) { - bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, - BT_AUDIO_LOCATION_FRONT_LEFT); + bt_pacs_set_location(BT_AUDIO_DIR_SINK, + BT_AUDIO_LOCATION_FRONT_LEFT); } else { - bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, - BT_AUDIO_LOCATION_FRONT_RIGHT); + bt_pacs_set_location(BT_AUDIO_DIR_SINK, + BT_AUDIO_LOCATION_FRONT_RIGHT); } } diff --git a/subsys/bluetooth/audio/pacs.c b/subsys/bluetooth/audio/pacs.c index e0b484bec13..c4a79f84afe 100644 --- a/subsys/bluetooth/audio/pacs.c +++ b/subsys/bluetooth/audio/pacs.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include "../host/conn_internal.h" #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_PACS) @@ -101,10 +101,10 @@ struct pac_records_build_data { struct net_buf_simple *buf; }; -static bool build_pac_records(const struct bt_audio_capability *capability, void *user_data) +static bool build_pac_records(const struct bt_pacs_cap *cap, void *user_data) { struct pac_records_build_data *data = user_data; - struct bt_codec *codec = capability->codec; + struct bt_codec *codec = cap->codec; struct net_buf_simple *buf = data->buf; struct net_buf_simple_state state; struct bt_pac_ltv_data *cc, *meta; @@ -153,17 +153,17 @@ static bool build_pac_records(const struct bt_audio_capability *capability, void return true; fail: - __ASSERT(true, "No space for %p", capability); + __ASSERT(true, "No space for %p", cap); net_buf_simple_restore(buf, &state); return false; } -static void foreach_capability(sys_slist_t *list, bt_audio_foreach_capability_func_t func, - void *user_data) +static void foreach_cap(sys_slist_t *list, bt_pacs_cap_foreach_func_t func, + void *user_data) { - struct bt_audio_capability *cap; + struct bt_pacs_cap *cap; SYS_SLIST_FOR_EACH_CONTAINER(list, cap, _node) { if (!func(cap, user_data)) { @@ -184,7 +184,7 @@ static void get_pac_records(struct bt_conn *conn, sys_slist_t *list, data.rsp->num_pac = 0; data.buf = buf; - foreach_capability(list, build_pac_records, &data); + foreach_cap(list, build_pac_records, &data); } static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value) @@ -192,7 +192,6 @@ static void available_context_cfg_changed(const struct bt_gatt_attr *attr, uint1 BT_DBG("attr %p value 0x%04x", attr, value); } - static ssize_t available_contexts_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) @@ -558,10 +557,10 @@ static void pac_notify_src_loc(struct k_work *work) #if defined(CONFIG_BT_PAC_SNK) static void pac_notify_snk(struct k_work *work) { - struct pacs *caps = CONTAINER_OF(work, struct pacs, work); + struct pacs *pac = CONTAINER_OF(work, struct pacs, work); int err; - get_pac_records(NULL, &caps->list, &read_buf); + get_pac_records(NULL, &pac->list, &read_buf); err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SNK, pacs_svc.attrs, read_buf.data, read_buf.len); @@ -574,10 +573,10 @@ static void pac_notify_snk(struct k_work *work) #if defined(CONFIG_BT_PAC_SRC) static void pac_notify_src(struct k_work *work) { - struct pacs *caps = CONTAINER_OF(work, struct pacs, work); + struct pacs *pac = CONTAINER_OF(work, struct pacs, work); int err = 0; - get_pac_records(NULL, &caps->list, &read_buf); + get_pac_records(NULL, &pac->list, &read_buf); err = bt_gatt_notify_uuid(NULL, BT_UUID_PACS_SRC, pacs_svc.attrs, read_buf.data, read_buf.len); @@ -636,35 +635,34 @@ static struct pacs *pacs_get(enum bt_audio_dir dir) } } -void bt_audio_foreach_capability(enum bt_audio_dir dir, bt_audio_foreach_capability_func_t func, - void *user_data) +void bt_pacs_cap_foreach(enum bt_audio_dir dir, bt_pacs_cap_foreach_func_t func, void *user_data) { - struct pacs *caps; + struct pacs *pac; CHECKIF(func == NULL) { BT_ERR("func is NULL"); return; } - caps = pacs_get(dir); - if (!caps) { + pac = pacs_get(dir); + if (!pac) { return; } - foreach_capability(&caps->list, func, user_data); + foreach_cap(&pac->list, func, user_data); } /* Register Audio Capability */ -int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capability *cap) +int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap) { - struct pacs *caps; + struct pacs *pac; if (!cap || !cap->codec) { return -EINVAL; } - caps = pacs_get(dir); - if (!caps) { + pac = pacs_get(dir); + if (!pac) { return -EINVAL; } @@ -672,39 +670,39 @@ int bt_audio_capability_register(enum bt_audio_dir dir, struct bt_audio_capabili "codec vid 0x%04x", cap, dir, cap->codec->id, cap->codec->cid, cap->codec->vid); - sys_slist_append(&caps->list, &cap->_node); + sys_slist_append(&pac->list, &cap->_node); - pacs_changed(caps); + pacs_changed(pac); return 0; } /* Unregister Audio Capability */ -int bt_audio_capability_unregister(enum bt_audio_dir dir, struct bt_audio_capability *cap) +int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap) { - struct pacs *caps; + struct pacs *pac; if (!cap) { return -EINVAL; } - caps = pacs_get(dir); - if (!caps) { + pac = pacs_get(dir); + if (!pac) { return -EINVAL; } BT_DBG("cap %p dir 0x%02x", cap, dir); - if (!sys_slist_find_and_remove(&caps->list, &cap->_node)) { + if (!sys_slist_find_and_remove(&pac->list, &cap->_node)) { return -ENOENT; } - pacs_changed(caps); + pacs_changed(pac); return 0; } -int bt_audio_capability_set_location(enum bt_audio_dir dir, enum bt_audio_location location) +int bt_pacs_set_location(enum bt_audio_dir dir, enum bt_audio_location location) { switch (dir) { case BT_AUDIO_DIR_SINK: @@ -716,8 +714,7 @@ int bt_audio_capability_set_location(enum bt_audio_dir dir, enum bt_audio_locati return -EINVAL; } -int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir, - enum bt_audio_context contexts) +int bt_pacs_set_available_contexts(enum bt_audio_dir dir, enum bt_audio_context contexts) { switch (dir) { case BT_AUDIO_DIR_SINK: @@ -729,7 +726,7 @@ int bt_audio_capability_set_available_contexts(enum bt_audio_dir dir, return -EINVAL; } -enum bt_audio_context bt_audio_capability_get_available_contexts(enum bt_audio_dir dir) +enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir) { switch (dir) { case BT_AUDIO_DIR_SINK: diff --git a/subsys/bluetooth/shell/audio.c b/subsys/bluetooth/shell/audio.c index f7520fce5b6..aa8eefcc82c 100644 --- a/subsys/bluetooth/shell/audio.c +++ b/subsys/bluetooth/shell/audio.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include "bt.h" @@ -684,11 +684,11 @@ static const struct bt_audio_unicast_server_cb unicast_server_cb = { .release = lc3_release, }; -static struct bt_audio_capability caps_sink = { +static struct bt_pacs_cap cap_sink = { .codec = &lc3_codec, }; -static struct bt_audio_capability caps_source = { +static struct bt_pacs_cap cap_source = { .codec = &lc3_codec, }; @@ -1697,7 +1697,7 @@ static int cmd_set_loc(const struct shell *sh, size_t argc, char *argv[]) } loc = shell_strtoul(argv[2], 16, &err); - err = bt_audio_capability_set_location(dir, loc); + err = bt_pacs_set_location(dir, loc); if (err) { shell_error(ctx_shell, "Set available contexts err %d", err); return -ENOEXEC; @@ -1727,7 +1727,7 @@ static int cmd_context(const struct shell *sh, size_t argc, char *argv[]) return err; } - err = bt_audio_capability_set_available_contexts(dir, ctx); + err = bt_pacs_set_available_contexts(dir, ctx); if (err) { shell_error(ctx_shell, "Set available contexts err %d", err); return err; @@ -1753,26 +1753,28 @@ static int cmd_init(const struct shell *sh, size_t argc, char *argv[]) if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER) || IS_ENABLED(CONFIG_BT_AUDIO_BROADCAST_SINK)) { - bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps_sink); + bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap_sink); } if (IS_ENABLED(CONFIG_BT_AUDIO_UNICAST_SERVER)) { - bt_audio_capability_register(BT_AUDIO_DIR_SOURCE, &caps_source); + bt_pacs_cap_register(BT_AUDIO_DIR_SOURCE, &cap_source); } if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) { - err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, LOCATION); + err = bt_pacs_set_location(BT_AUDIO_DIR_SINK, LOCATION); __ASSERT(err == 0, "Failed to set sink location"); - err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, CONTEXT); + err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK, + CONTEXT); __ASSERT(err == 0, "Failed to set sink available contexts"); } if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) { - err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, LOCATION); + err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE, LOCATION); __ASSERT(err == 0, "Failed to set source location"); - err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, CONTEXT); + err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE, + CONTEXT); __ASSERT(err == 0, "Failed to set source available contexts"); } @@ -1971,10 +1973,10 @@ ssize_t audio_ad_data_add(struct bt_data *data_array, const size_t data_array_si }; enum bt_audio_context snk_context, src_context; - snk_context = bt_audio_capability_get_available_contexts(BT_AUDIO_DIR_SINK); + snk_context = bt_pacs_get_available_contexts(BT_AUDIO_DIR_SINK); sys_put_le16(snk_context, &ad_bap_announcement[3]); - src_context = bt_audio_capability_get_available_contexts(BT_AUDIO_DIR_SOURCE); + src_context = bt_pacs_get_available_contexts(BT_AUDIO_DIR_SOURCE); sys_put_le16(snk_context, &ad_bap_announcement[5]); /* Metadata length */ diff --git a/subsys/bluetooth/shell/bt.c b/subsys/bluetooth/shell/bt.c index 72dff3b90da..c45897e81a3 100644 --- a/subsys/bluetooth/shell/bt.c +++ b/subsys/bluetooth/shell/bt.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include diff --git a/tests/bluetooth/bsim_bt/bsim_test_audio/src/broadcast_sink_test.c b/tests/bluetooth/bsim_bt/bsim_test_audio/src/broadcast_sink_test.c index d45d228e2d4..12837f994e0 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_audio/src/broadcast_sink_test.c +++ b/tests/bluetooth/bsim_bt/bsim_test_audio/src/broadcast_sink_test.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include "common.h" extern enum bst_result_t bst_result; @@ -130,7 +130,7 @@ static struct bt_audio_broadcast_sink_cb broadcast_sink_cbs = { .pa_sync_lost = pa_sync_lost_cb }; -static struct bt_audio_capability capabilities = { +static struct bt_pacs_cap cap = { .codec = &preset_16_2_1.codec, }; @@ -171,7 +171,7 @@ static int init(void) printk("Bluetooth initialized\n"); - err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &capabilities); + err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap); if (err) { FAIL("Capability register failed (err %d)\n", err); return err; diff --git a/tests/bluetooth/bsim_bt/bsim_test_audio/src/unicast_client_test.c b/tests/bluetooth/bsim_bt/bsim_test_audio/src/unicast_client_test.c index 1e0b73a2683..61f9d6c49ad 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_audio/src/unicast_client_test.c +++ b/tests/bluetooth/bsim_bt/bsim_test_audio/src/unicast_client_test.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include "common.h" #include "unicast_common.h" diff --git a/tests/bluetooth/bsim_bt/bsim_test_audio/src/unicast_server_test.c b/tests/bluetooth/bsim_bt/bsim_test_audio/src/unicast_server_test.c index ee85104a832..d080a05471a 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_audio/src/unicast_server_test.c +++ b/tests/bluetooth/bsim_bt/bsim_test_audio/src/unicast_server_test.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include "common.h" #include "unicast_common.h" @@ -232,7 +232,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = { static void init(void) { - static struct bt_audio_capability caps = { + static struct bt_pacs_cap cap = { .codec = &lc3_codec, }; int err; @@ -247,7 +247,7 @@ static void init(void) bt_audio_unicast_server_register_cb(&unicast_server_cb); - err = bt_audio_capability_register(BT_AUDIO_DIR_SINK, &caps); + err = bt_pacs_cap_register(BT_AUDIO_DIR_SINK, &cap); if (err != 0) { FAIL("Failed to register capabilities: %d", err); return; @@ -271,8 +271,8 @@ static void set_location(void) int err; if (IS_ENABLED(CONFIG_BT_PAC_SNK_LOC)) { - err = bt_audio_capability_set_location(BT_AUDIO_DIR_SINK, - BT_AUDIO_LOCATION_FRONT_CENTER); + err = bt_pacs_set_location(BT_AUDIO_DIR_SINK, + BT_AUDIO_LOCATION_FRONT_CENTER); if (err != 0) { FAIL("Failed to set sink location (err %d)\n", err); return; @@ -280,9 +280,9 @@ static void set_location(void) } if (IS_ENABLED(CONFIG_BT_PAC_SRC_LOC)) { - err = bt_audio_capability_set_location(BT_AUDIO_DIR_SOURCE, - (BT_AUDIO_LOCATION_FRONT_LEFT | - BT_AUDIO_LOCATION_FRONT_RIGHT)); + err = bt_pacs_set_location(BT_AUDIO_DIR_SOURCE, + (BT_AUDIO_LOCATION_FRONT_LEFT | + BT_AUDIO_LOCATION_FRONT_RIGHT)); if (err != 0) { FAIL("Failed to set source location (err %d)\n", err); return; @@ -296,16 +296,16 @@ static void set_available_contexts(void) { int err; - err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SINK, - BT_AUDIO_CONTEXT_TYPE_MEDIA | - BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL); + err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SINK, + BT_AUDIO_CONTEXT_TYPE_MEDIA | + BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL); if (IS_ENABLED(CONFIG_BT_PAC_SNK) && err != 0) { FAIL("Failed to set sink available contexts (err %d)\n", err); return; } - err = bt_audio_capability_set_available_contexts(BT_AUDIO_DIR_SOURCE, - BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS); + err = bt_pacs_set_available_contexts(BT_AUDIO_DIR_SOURCE, + BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS); if (IS_ENABLED(CONFIG_BT_PAC_SRC) && err != 0) { FAIL("Failed to set source available contexts (err %d)\n", err); return;