Bluetooth: audio: tbs_client: Minor Kconfig refactor
This intoduces dedicated Kconfig option to enable TBS client, that makes the configuration more intuitive. While configuring GTBS only, the user does not have to explicitly set the BT_TBS_CLIENT_MAX_TBS_INSTANCES to 0 to disable the TBS client functionality. This adds also `tbs_only_client` test case to test the TBS only build option. Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
parent
650a0d8331
commit
c09c4181cf
7 changed files with 43 additions and 36 deletions
|
@ -54,10 +54,8 @@ CONFIG_BT_VCP_VOL_REND_VOCS_INSTANCE_COUNT=1
|
|||
CONFIG_BT_BAS=y
|
||||
CONFIG_BT_IAS=y
|
||||
|
||||
CONFIG_BT_TBS_CLIENT=y
|
||||
CONFIG_BT_TBS_CLIENT_MINIMAL=y
|
||||
CONFIG_BT_TBS_CLIENT_GTBS=y
|
||||
CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES=0
|
||||
CONFIG_BT_TBS_CLIENT_CCID=y
|
||||
CONFIG_BT_TBS_CLIENT_STATUS_FLAGS=y
|
||||
|
||||
|
|
|
@ -43,9 +43,7 @@ CONFIG_BT_PAC_SNK_LOC=y
|
|||
CONFIG_BT_PAC_SRC_LOC=y
|
||||
|
||||
# CCP Client Support
|
||||
CONFIG_BT_TBS_CLIENT=y
|
||||
CONFIG_BT_TBS_CLIENT_GTBS=y
|
||||
CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES=0
|
||||
CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL=y
|
||||
CONFIG_BT_TBS_CLIENT_TERMINATE_CALL=y
|
||||
CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST=y
|
||||
|
|
|
@ -132,22 +132,23 @@ endif # BT_TBS
|
|||
|
||||
##################### Call Control Client #####################
|
||||
|
||||
config BT_TBS_CLIENT_GTBS
|
||||
bool "Generic Telephone Bearer Service client support"
|
||||
help
|
||||
This option enables support for the GTBS-oriented Call Control client.
|
||||
|
||||
config BT_TBS_CLIENT_TBS
|
||||
bool "Telephone Bearer Service client support"
|
||||
help
|
||||
This option enables support for the TBS-oriented Call Control client.
|
||||
|
||||
config BT_TBS_CLIENT
|
||||
bool "Telephone Bearer Service client"
|
||||
def_bool BT_TBS_CLIENT_GTBS || BT_TBS_CLIENT_TBS
|
||||
select BT_GATT_CLIENT
|
||||
select BT_GATT_AUTO_DISCOVER_CCC
|
||||
help
|
||||
This option enables support for Telephone Bearer Service client.
|
||||
|
||||
if BT_TBS_CLIENT
|
||||
|
||||
config BT_TBS_CLIENT_GTBS
|
||||
bool "Telephone Bearer Service client GTBS support"
|
||||
default y
|
||||
help
|
||||
This option enables support for the generic TBS for the
|
||||
Call Control client.
|
||||
|
||||
config BT_TBS_CLIENT_MAX_CALLS
|
||||
int "Maximum Number Of Calls Supported"
|
||||
default 1
|
||||
|
@ -156,8 +157,8 @@ config BT_TBS_CLIENT_MAX_CALLS
|
|||
|
||||
config BT_TBS_CLIENT_MAX_TBS_INSTANCES
|
||||
int "Maximum number of TBS instances to setup"
|
||||
depends on BT_TBS_CLIENT_TBS
|
||||
default 1
|
||||
range 0 3 if BT_TBS_CLIENT_GTBS
|
||||
range 1 3
|
||||
help
|
||||
Sets the maximum number of Telephone Bearer Service (TBS)
|
||||
|
|
|
@ -46,10 +46,10 @@ BUILD_ASSERT(CONFIG_BT_L2CAP_TX_BUF_COUNT >= TBS_CLIENT_BUF_COUNT, "Too few L2CA
|
|||
#include "common/bt_str.h"
|
||||
|
||||
struct bt_tbs_server_inst {
|
||||
#if CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
|
||||
struct bt_tbs_instance tbs_insts[CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES];
|
||||
uint8_t inst_cnt;
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0 */
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_GTBS)
|
||||
struct bt_tbs_instance gtbs_inst;
|
||||
#endif /* IS_ENABLED(CONFIG_BT_TBS_CLIENT_GTBS) */
|
||||
|
@ -74,13 +74,13 @@ static struct bt_tbs_instance *tbs_instance_find(struct bt_tbs_server_inst *serv
|
|||
return &server->gtbs_inst;
|
||||
}
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_GTBS */
|
||||
#if CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
|
||||
for (size_t i = 0; i < server->inst_cnt; i++) {
|
||||
if (func(&server->tbs_insts[i], user_data)) {
|
||||
return &server->tbs_insts[i];
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0 */
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -98,11 +98,11 @@ static struct bt_tbs_instance *tbs_inst_by_index(struct bt_conn *conn, uint8_t i
|
|||
return &server->gtbs_inst;
|
||||
}
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_GTBS */
|
||||
#if CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
|
||||
if (index < server->inst_cnt) {
|
||||
return &server->tbs_insts[index];
|
||||
}
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0 */
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -122,14 +122,14 @@ static uint8_t tbs_index(struct bt_conn *conn, const struct bt_tbs_instance *ins
|
|||
return BT_TBS_GTBS_INDEX;
|
||||
}
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_GTBS */
|
||||
#if CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
|
||||
index = inst - server->tbs_insts;
|
||||
__ASSERT(index >= 0 && index < ARRAY_SIZE(server->tbs_insts),
|
||||
"Invalid bt_tbs_instance pointer");
|
||||
|
||||
#else
|
||||
__ASSERT_PRINT("Invalid bt_tbs_instance pointer");
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0 */
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
|
||||
|
||||
return (uint8_t)index;
|
||||
}
|
||||
|
@ -693,11 +693,11 @@ static bool gtbs_found(struct bt_tbs_server_inst *srv_inst)
|
|||
|
||||
static uint8_t inst_cnt(struct bt_tbs_server_inst *srv_inst)
|
||||
{
|
||||
#if CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
|
||||
return srv_inst->inst_cnt;
|
||||
#else
|
||||
return 0;
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0 */
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
|
||||
}
|
||||
|
||||
static void tbs_client_discover_complete(struct bt_conn *conn, int err)
|
||||
|
@ -1617,7 +1617,7 @@ static void primary_discover_complete(struct bt_tbs_server_inst *server, struct
|
|||
* handles of the writeable characteristics and subscribing to all notify and
|
||||
* indicate characteristics.
|
||||
*/
|
||||
#if CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
|
||||
static const struct bt_uuid *tbs_uuid = BT_UUID_TBS;
|
||||
|
||||
static uint8_t primary_discover_tbs_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
|
@ -1639,7 +1639,7 @@ static uint8_t primary_discover_tbs_cb(struct bt_conn *conn, const struct bt_gat
|
|||
srv_inst->current_inst->start_handle = attr->handle + 1;
|
||||
srv_inst->current_inst->end_handle = prim_service->end_handle;
|
||||
|
||||
if (srv_inst->inst_cnt < CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES) {
|
||||
if (srv_inst->inst_cnt < ARRAY_SIZE(srv_inst->tbs_insts)) {
|
||||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
@ -1665,7 +1665,7 @@ static int primary_discover_tbs(struct bt_conn *conn)
|
|||
|
||||
return bt_gatt_discover(conn, params);
|
||||
}
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0 */
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
|
||||
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_GTBS)
|
||||
static const struct bt_uuid *gtbs_uuid = BT_UUID_GTBS;
|
||||
|
@ -1690,7 +1690,7 @@ static uint8_t primary_discover_gtbs_cb(struct bt_conn *conn, const struct bt_ga
|
|||
srv_inst->current_inst->end_handle = prim_service->end_handle;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
|
||||
int err;
|
||||
|
||||
err = primary_discover_tbs(conn);
|
||||
|
@ -1699,7 +1699,7 @@ static uint8_t primary_discover_gtbs_cb(struct bt_conn *conn, const struct bt_ga
|
|||
}
|
||||
|
||||
LOG_DBG("Discover failed (err %d)", err);
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0 */
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
|
||||
|
||||
primary_discover_complete(srv_inst, conn);
|
||||
|
||||
|
@ -2234,10 +2234,10 @@ int bt_tbs_client_discover(struct bt_conn *conn, bool subscribe)
|
|||
return -EBUSY;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_TBS)
|
||||
(void)memset(srv_inst->tbs_insts, 0, sizeof(srv_inst->tbs_insts)); /* reset data */
|
||||
srv_inst->inst_cnt = 0;
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 0 */
|
||||
#endif /* CONFIG_BT_TBS_CLIENT_TBS */
|
||||
/* Discover TBS on peer, setup handles and notify/indicate */
|
||||
srv_inst->subscribe_all = subscribe;
|
||||
#if defined(CONFIG_BT_TBS_CLIENT_GTBS)
|
||||
|
|
|
@ -119,7 +119,8 @@ CONFIG_BT_MPL_TRACK_MAX_SIZE=50
|
|||
# Telephone bearer service
|
||||
CONFIG_BT_TBS=y
|
||||
CONFIG_BT_TBS_SUPPORTED_FEATURES=3
|
||||
CONFIG_BT_TBS_CLIENT=y
|
||||
CONFIG_BT_TBS_CLIENT_TBS=y
|
||||
CONFIG_BT_TBS_CLIENT_GTBS=y
|
||||
|
||||
CONFIG_BT_MCS=y
|
||||
CONFIG_BT_MCC=y
|
||||
|
|
|
@ -289,14 +289,22 @@ tests:
|
|||
build_only: true
|
||||
platform_allow: native_posix
|
||||
extra_configs:
|
||||
- CONFIG_BT_TBS_CLIENT=n
|
||||
- CONFIG_BT_TBS_CLIENT_TBS=n
|
||||
- CONFIG_BT_TBS_CLIENT_GTBS=n
|
||||
tags: bluetooth
|
||||
bluetooth.shell.audio.tbs_only_client:
|
||||
extra_args: CONF_FILE="audio.conf"
|
||||
build_only: true
|
||||
platform_allow: native_posix
|
||||
extra_configs:
|
||||
- CONFIG_BT_TBS_CLIENT_GTBS=n
|
||||
tags: bluetooth
|
||||
bluetooth.shell.audio.gtbs_only_client:
|
||||
extra_args: CONF_FILE="audio.conf"
|
||||
build_only: true
|
||||
platform_allow: native_posix
|
||||
extra_configs:
|
||||
- CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES=0
|
||||
- CONFIG_BT_TBS_CLIENT_TBS=n
|
||||
tags: bluetooth
|
||||
bluetooth.audio_shell.no_cap_acceptor:
|
||||
extra_args: CONF_FILE="audio.conf"
|
||||
|
|
|
@ -72,7 +72,8 @@ CONFIG_BT_CSIP_SET_COORDINATOR_TEST_SAMPLE_DATA=y
|
|||
|
||||
# Telephone bearer service
|
||||
CONFIG_BT_TBS=y
|
||||
CONFIG_BT_TBS_CLIENT=y
|
||||
CONFIG_BT_TBS_CLIENT_TBS=y
|
||||
CONFIG_BT_TBS_CLIENT_GTBS=y
|
||||
CONFIG_BT_TBS_CLIENT_MAX_CALLS=4
|
||||
CONFIG_BT_TBS_MAX_CALLS=4
|
||||
CONFIG_BT_TBS_SUPPORTED_FEATURES=3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue