Bluetooth: Audio: Specify MICP Mic Dev API

Modify the existing bt_micp API for the
MICP Microphone Device to be more specific
by adding mic_dev as an infix. This follows
the naming scheme used for the MICP microphone
controller (mic_ctlr).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2022-06-21 18:21:49 +02:00 committed by Carles Cufí
commit e95b640df6
12 changed files with 234 additions and 240 deletions

View file

@ -26,11 +26,11 @@
extern "C" {
#endif
#if defined(CONFIG_BT_MICP)
#define BT_MICP_AICS_CNT CONFIG_BT_MICP_AICS_INSTANCE_COUNT
#if defined(CONFIG_BT_MICP_MIC_DEV)
#define BT_MICP_MIC_DEV_AICS_CNT CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT
#else
#define BT_MICP_AICS_CNT 0
#endif /* CONFIG_BT_MICP */
#define BT_MICP_MIC_DEV_AICS_CNT 0
#endif /* CONFIG_BT_MICP_MIC_DEV */
/** Application error codes */
#define BT_MICP_ERR_MUTE_DISABLED 0x80
@ -45,14 +45,14 @@ extern "C" {
struct bt_micp;
/** @brief Register parameters structure for Microphone Input Control Profile instance */
struct bt_micp_register_param {
#if defined(CONFIG_BT_MICP_AICS)
struct bt_micp_mic_dev_register_param {
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
/** Register parameter structure for Audio Input Control Services */
struct bt_aics_register_param aics_param[BT_MICP_AICS_CNT];
#endif /* CONFIG_BT_MICP_AICS */
struct bt_aics_register_param aics_param[BT_MICP_MIC_DEV_AICS_CNT];
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
/** Microphone Input Control Profile callback structure. */
struct bt_micp_cb *cb;
struct bt_micp_mic_dev_cb *cb;
};
/**
@ -83,7 +83,7 @@ struct bt_micp_included {
*
* @return 0 if success, errno on failure.
*/
int bt_micp_register(struct bt_micp_register_param *param,
int bt_micp_mic_dev_register(struct bt_micp_mic_dev_register_param *param,
struct bt_micp **micp);
/**
@ -93,32 +93,27 @@ int bt_micp_register(struct bt_micp_register_param *param,
* Microphone Input Control Profile included services instances, such as
* pointers to the Audio Input Control Service instances.
*
* Requires that @kconfig{CONFIG_BT_MICP_AICS}
* Requires that @kconfig{CONFIG_BT_MICP_MIC_DEV_AICS}
*
* @param micp Microphone Input Control Profile instance pointer.
* @param[out] included Pointer to store the result in.
*
* @return 0 if success, errno on failure.
*/
int bt_micp_included_get(struct bt_micp *micp,
int bt_micp_mic_dev_included_get(struct bt_micp *micp,
struct bt_micp_included *included);
struct bt_micp_mic_dev_cb {
/**
* @brief Callback function for Microphone Input Control Profile mute.
*
* Called when the value is read,
* Called when the value is read with bt_micp_mic_dev_mute_get(),
* or if the value is changed by either the server or client.
*
* @param micp Microphone Input Control Profile instance pointer.
* @param err Error value. 0 on success, GATT error or errno on fail.
* For notifications, this will always be 0.
* @param mute The mute setting of the Microphone Input Control Profile instance.
*/
typedef void (*bt_micp_mute_read_cb)(struct bt_micp *micp, int err,
uint8_t mute);
struct bt_micp_cb {
bt_micp_mute_read_cb mute;
void (*mute)(struct bt_micp *micp, uint8_t mute);
};
/**
@ -128,7 +123,7 @@ struct bt_micp_cb {
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_unmute(struct bt_micp *micp);
int bt_micp_mic_dev_unmute(struct bt_micp *micp);
/**
* @brief Mute the server.
@ -137,19 +132,19 @@ int bt_micp_unmute(struct bt_micp *micp);
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mute(struct bt_micp *micp);
int bt_micp_mic_dev_mute(struct bt_micp *micp);
/**
* @brief Disable the mute functionality.
*
* Can be reenabled by called @ref bt_micp_mute or @ref bt_micp_unmute.
* Can be reenabled by called @ref bt_micp_mic_dev_mute or @ref bt_micp_mic_dev_unmute.
* This can only be done as the server.
*
* @param micp Microphone Input Control Profile instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mute_disable(struct bt_micp *micp);
int bt_micp_mic_dev_disable(struct bt_micp *micp);
/**
* @brief Read the mute state of a Microphone Input Control Profile instance.
@ -158,7 +153,7 @@ int bt_micp_mute_disable(struct bt_micp *micp);
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mute_get(struct bt_micp *micp);
int bt_micp_mic_dev_mute_get(struct bt_micp *micp);
struct bt_micp_mic_ctlr_cb {
/**

View file

@ -17,7 +17,7 @@ if (CONFIG_BT_VCS OR CONFIG_BT_VCS_CLIENT)
endif()
zephyr_library_sources_ifdef(CONFIG_BT_VCS_CLIENT vcs_client.c)
if (CONFIG_BT_MICP)
if (CONFIG_BT_MICP_MIC_DEV)
zephyr_library_sources(micp_mic_dev.c)
endif()
zephyr_library_sources_ifdef(CONFIG_BT_MICP_MIC_CTLR micp_mic_ctlr.c)

View file

@ -1,45 +1,47 @@
# Bluetooth Audio - Microphone Input Control Service options
#
# Copyright (c) 2020 Bose Corporation
# Copyright (c) 2020-2021 Nordic Semiconductor ASA
# Copyright (c) 2020-2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#
##################### Microphone Input Control Service #####################
########### Microphone Input Control Profile Microphone Device ###########
config BT_MICP
bool "Microphone Input Control Profile Support [EXPERIMENTAL]"
config BT_MICP_MIC_DEV
bool "Microphone Input Control Profile Microphone Device Support [EXPERIMENTAL]"
select EXPERIMENTAL
help
This option enables support for Microphone Input Control Service.
This option enables support for Microphone Input Control Profile
Microphone Device.
if BT_MICP
if BT_MICP_MIC_DEV
config BT_MICP_AICS_INSTANCE_COUNT
int "Audio Input Control Service instance count for Microphone Input Control Service"
config BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT
int "Audio Input Control Service instance count for \
Microphone Input Control Service Microphone Device"
default 0
range 0 BT_AICS_MAX_INSTANCE_COUNT
help
This option sets the number of instances of Audio Input Control
Services for MICP.
Services for Microphone Input Control Profile Microphone Device.
config BT_MICP_AICS
config BT_MICP_MIC_DEV_AICS
bool # Hidden
default y if BT_MICP_AICS_INSTANCE_COUNT > 0
default y if BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT > 0
help
This hidden option makes it possible to easily check if AICS is
enabled for MICP.
enabled for Microphone Input Control Profile Microphone Device.
############# DEBUG #############
config BT_DEBUG_MICP
bool "Microphone Input Control Service debug"
config BT_DEBUG_MICP_MIC_DEV
bool "Microphone Input Control Profile Microphone Device debug"
help
Use this option to enable Microphone Input Control Service debug logs
for the Bluetooth Audio functionality.
Use this option to enable Microphone Input Control Profile
Microphone Device debug logs for the Bluetooth Audio functionality.
endif # BT_MICP
endif # BT_MICP_MIC_DEV
########### Microphone Input Control Profile Microphone Controller ###########

View file

@ -9,14 +9,14 @@
#include <zephyr/types.h>
#include <zephyr/bluetooth/gatt.h>
#if defined(CONFIG_BT_MICP)
#if defined(CONFIG_BT_MICP_MIC_DEV)
struct bt_micp_server {
uint8_t mute;
struct bt_micp_cb *cb;
struct bt_micp_mic_dev_cb *cb;
struct bt_gatt_service *service_p;
struct bt_aics *aics_insts[CONFIG_BT_MICP_AICS_INSTANCE_COUNT];
struct bt_aics *aics_insts[CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT];
};
#endif /* CONFIG_BT_MICP */
#endif /* CONFIG_BT_MICP_MIC_DEV */
#if defined(CONFIG_BT_MICP_MIC_CTLR)
struct bt_micp_mic_ctlr {
@ -42,9 +42,9 @@ struct bt_micp_mic_ctlr {
struct bt_micp {
bool client_instance;
union {
#if defined(CONFIG_BT_MICP)
#if defined(CONFIG_BT_MICP_MIC_DEV)
struct bt_micp_server srv;
#endif /* CONFIG_BT_MICP */
#endif /* CONFIG_BT_MICP_MIC_DEV */
#if defined(CONFIG_BT_MICP_MIC_CTLR)
struct bt_micp_mic_ctlr cli;
#endif /* CONFIG_BT_MICP_MIC_CTLR */

View file

@ -21,7 +21,7 @@
#include "micp_internal.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MICP)
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_MICP_MIC_DEV)
#define LOG_MODULE_NAME bt_micp
#include "common/log.h"
@ -75,7 +75,7 @@ static ssize_t write_mute(struct bt_conn *conn, const struct bt_gatt_attr *attr,
&micp_inst.srv.mute, sizeof(micp_inst.srv.mute));
if (micp_inst.srv.cb != NULL && micp_inst.srv.cb->mute != NULL) {
micp_inst.srv.cb->mute(NULL, 0, micp_inst.srv.mute);
micp_inst.srv.cb->mute(NULL, micp_inst.srv.mute);
}
}
@ -88,7 +88,7 @@ static ssize_t write_mute(struct bt_conn *conn, const struct bt_gatt_attr *attr,
#define BT_MICP_SERVICE_DEFINITION \
BT_GATT_PRIMARY_SERVICE(BT_UUID_MICS), \
AICS_INCLUDES(CONFIG_BT_MICP_AICS_INSTANCE_COUNT) \
AICS_INCLUDES(CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT) \
BT_GATT_CHARACTERISTIC(BT_UUID_MICS_MUTE, \
BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_NOTIFY, \
BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT, \
@ -98,13 +98,13 @@ static ssize_t write_mute(struct bt_conn *conn, const struct bt_gatt_attr *attr,
#define MICS_ATTR_COUNT \
ARRAY_SIZE(((struct bt_gatt_attr []){ BT_MICP_SERVICE_DEFINITION }))
#define MICS_INCL_COUNT (CONFIG_BT_MICP_AICS_INSTANCE_COUNT)
#define MICS_INCL_COUNT (CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT)
static struct bt_gatt_attr mics_attrs[] = { BT_MICP_SERVICE_DEFINITION };
static struct bt_gatt_service mics_svc;
#if defined(CONFIG_BT_MICP_AICS)
static int prepare_aics_inst(struct bt_micp_register_param *param)
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
static int prepare_aics_inst(struct bt_micp_mic_dev_register_param *param)
{
int i;
int j;
@ -128,21 +128,21 @@ static int prepare_aics_inst(struct bt_micp_register_param *param)
mics_attrs[i].user_data = bt_aics_svc_decl_get(micp_inst.srv.aics_insts[j]);
j++;
if (j == CONFIG_BT_MICP_AICS_INSTANCE_COUNT) {
if (j == CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT) {
break;
}
}
}
__ASSERT(j == CONFIG_BT_MICP_AICS_INSTANCE_COUNT,
__ASSERT(j == CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT,
"Invalid AICS instance count");
return 0;
}
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
/****************************** PUBLIC API ******************************/
int bt_micp_register(struct bt_micp_register_param *param,
int bt_micp_mic_dev_register(struct bt_micp_mic_dev_register_param *param,
struct bt_micp **micp)
{
int err;
@ -155,14 +155,14 @@ int bt_micp_register(struct bt_micp_register_param *param,
__ASSERT(param, "MICS register parameter cannot be NULL");
#if defined(CONFIG_BT_MICP_AICS)
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
err = prepare_aics_inst(param);
if (err != 0) {
BT_DBG("Failed to prepare AICS instances: %d", err);
return err;
}
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
mics_svc = (struct bt_gatt_service)BT_GATT_SERVICE(mics_attrs);
micp_inst.srv.service_p = &mics_svc;
@ -180,7 +180,7 @@ int bt_micp_register(struct bt_micp_register_param *param,
return err;
}
int bt_micp_mute_disable(struct bt_micp *micp)
int bt_micp_mic_dev_disable(struct bt_micp *micp)
{
uint8_t val = BT_MICP_MUTE_DISABLED;
int err;
@ -195,7 +195,7 @@ int bt_micp_mute_disable(struct bt_micp *micp)
return err > 0 ? 0 : err;
}
int bt_micp_included_get(struct bt_micp *micp,
int bt_micp_mic_dev_included_get(struct bt_micp *micp,
struct bt_micp_included *included)
{
CHECKIF(micp == NULL) {
@ -208,15 +208,15 @@ int bt_micp_included_get(struct bt_micp *micp,
return -EINVAL;
}
#if defined(CONFIG_BT_MICP_AICS)
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
included->aics_cnt = ARRAY_SIZE(micp_inst.srv.aics_insts);
included->aics = micp_inst.srv.aics_insts;
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
return 0;
}
int bt_micp_unmute(struct bt_micp *micp)
int bt_micp_mic_dev_unmute(struct bt_micp *micp)
{
const uint8_t val = BT_MICP_MUTE_UNMUTED;
int err;
@ -231,7 +231,7 @@ int bt_micp_unmute(struct bt_micp *micp)
return err > 0 ? 0 : err;
}
int bt_micp_mute(struct bt_micp *micp)
int bt_micp_mic_dev_mute(struct bt_micp *micp)
{
const uint8_t val = BT_MICP_MUTE_MUTED;
int err;
@ -246,7 +246,7 @@ int bt_micp_mute(struct bt_micp *micp)
return err > 0 ? 0 : err;
}
int bt_micp_mute_get(struct bt_micp *micp)
int bt_micp_mic_dev_mute_get(struct bt_micp *micp)
{
CHECKIF(micp == NULL) {
BT_DBG("NULL micp pointer");
@ -254,7 +254,7 @@ int bt_micp_mute_get(struct bt_micp *micp)
}
if (micp_inst.srv.cb && micp_inst.srv.cb->mute) {
micp_inst.srv.cb->mute(NULL, 0, micp_inst.srv.mute);
micp_inst.srv.cb->mute(NULL, micp_inst.srv.mute);
}
return 0;

View file

@ -34,7 +34,7 @@ zephyr_library_sources_ifdef(
vcs_client.c
)
zephyr_library_sources_ifdef(
CONFIG_BT_MICP
CONFIG_BT_MICP_MIC_DEV
micp_mic_dev.c
)
zephyr_library_sources_ifdef(

View file

@ -18,24 +18,20 @@
static struct bt_micp *micp;
static void micp_mute_cb(struct bt_micp *micp, int err, uint8_t mute)
static void micp_mic_dev_mute_cb(struct bt_micp *micp, uint8_t mute)
{
if (err != 0) {
shell_error(ctx_shell, "Mute get failed (%d)", err);
} else {
shell_print(ctx_shell, "Mute value %u", mute);
}
}
static struct bt_micp_cb micp_cbs = {
.mute = micp_mute_cb,
static struct bt_micp_mic_dev_cb micp_mic_dev_cbs = {
.mute = micp_mic_dev_mute_cb,
};
#if defined(CONFIG_BT_MICP_AICS)
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
static struct bt_micp_included micp_included;
static void micp_aics_state_cb(struct bt_aics *inst, int err, int8_t gain,
uint8_t mute, uint8_t mode)
static void micp_mic_dev_aics_state_cb(struct bt_aics *inst, int err,
int8_t gain, uint8_t mute, uint8_t mode)
{
if (err != 0) {
shell_error(ctx_shell, "AICS state get failed (%d) for "
@ -46,7 +42,7 @@ static void micp_aics_state_cb(struct bt_aics *inst, int err, int8_t gain,
}
}
static void micp_aics_gain_setting_cb(struct bt_aics *inst, int err,
static void micp_mic_dev_aics_gain_setting_cb(struct bt_aics *inst, int err,
uint8_t units, int8_t minimum,
int8_t maximum)
{
@ -60,7 +56,7 @@ static void micp_aics_gain_setting_cb(struct bt_aics *inst, int err,
}
}
static void micp_aics_input_type_cb(struct bt_aics *inst, int err,
static void micp_mic_dev_aics_input_type_cb(struct bt_aics *inst, int err,
uint8_t input_type)
{
if (err != 0) {
@ -72,7 +68,8 @@ static void micp_aics_input_type_cb(struct bt_aics *inst, int err,
}
}
static void micp_aics_status_cb(struct bt_aics *inst, int err, bool active)
static void micp_mic_dev_aics_status_cb(struct bt_aics *inst, int err,
bool active)
{
if (err != 0) {
shell_error(ctx_shell, "AICS status get failed (%d) for "
@ -83,7 +80,7 @@ static void micp_aics_status_cb(struct bt_aics *inst, int err, bool active)
}
}
static void micp_aics_description_cb(struct bt_aics *inst, int err,
static void micp_mic_dev_aics_description_cb(struct bt_aics *inst, int err,
char *description)
{
if (err != 0) {
@ -96,18 +93,19 @@ static void micp_aics_description_cb(struct bt_aics *inst, int err,
}
static struct bt_aics_cb aics_cb = {
.state = micp_aics_state_cb,
.gain_setting = micp_aics_gain_setting_cb,
.type = micp_aics_input_type_cb,
.status = micp_aics_status_cb,
.description = micp_aics_description_cb,
.state = micp_mic_dev_aics_state_cb,
.gain_setting = micp_mic_dev_aics_gain_setting_cb,
.type = micp_mic_dev_aics_input_type_cb,
.status = micp_mic_dev_aics_status_cb,
.description = micp_mic_dev_aics_description_cb,
};
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
static int cmd_micp_param(const struct shell *sh, size_t argc, char **argv)
static int cmd_micp_mic_dev_param(const struct shell *sh, size_t argc,
char **argv)
{
int result;
struct bt_micp_register_param micp_param;
struct bt_micp_mic_dev_register_param micp_param;
if (ctx_shell == NULL) {
ctx_shell = sh;
@ -115,8 +113,8 @@ static int cmd_micp_param(const struct shell *sh, size_t argc, char **argv)
(void)memset(&micp_param, 0, sizeof(micp_param));
#if defined(CONFIG_BT_MICP_AICS)
char input_desc[CONFIG_BT_MICP_AICS_INSTANCE_COUNT][16];
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
char input_desc[CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT][16];
for (int i = 0; i < ARRAY_SIZE(micp_param.aics_param); i++) {
micp_param.aics_param[i].desc_writable = true;
@ -131,11 +129,11 @@ static int cmd_micp_param(const struct shell *sh, size_t argc, char **argv)
micp_param.aics_param[i].max_gain = 100;
micp_param.aics_param[i].cb = &aics_cb;
}
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
micp_param.cb = &micp_cbs;
micp_param.cb = &micp_mic_dev_cbs;
result = bt_micp_register(&micp_param, &micp);
result = bt_micp_mic_dev_register(&micp_param, &micp);
if (result != 0) {
shell_error(sh, "MICP register failed: %d", result);
return result;
@ -143,53 +141,20 @@ static int cmd_micp_param(const struct shell *sh, size_t argc, char **argv)
shell_print(sh, "MICP initialized: %d", result);
#if defined(CONFIG_BT_MICP_AICS)
result = bt_micp_included_get(NULL, &micp_included);
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
result = bt_micp_mic_dev_included_get(NULL, &micp_included);
if (result != 0) {
shell_error(sh, "MICP get failed: %d", result);
}
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
return result;
}
static int cmd_micp_mute_get(const struct shell *sh, size_t argc, char **argv)
{
int result = bt_micp_mute_get(NULL);
if (result != 0) {
shell_error(sh, "Fail: %d", result);
}
return result;
}
static int cmd_micp_mute(const struct shell *sh, size_t argc, char **argv)
{
int result = bt_micp_mute(NULL);
if (result != 0) {
shell_error(sh, "Fail: %d", result);
}
return result;
}
static int cmd_micp_unmute(const struct shell *sh, size_t argc, char **argv)
{
int result = bt_micp_unmute(NULL);
if (result != 0) {
shell_error(sh, "Fail: %d", result);
}
return result;
}
static int cmd_micp_mute_disable(const struct shell *sh, size_t argc,
static int cmd_micp_mic_dev_mute_get(const struct shell *sh, size_t argc,
char **argv)
{
int result = bt_micp_mute_disable(micp);
int result = bt_micp_mic_dev_mute_get(NULL);
if (result != 0) {
shell_error(sh, "Fail: %d", result);
@ -198,8 +163,44 @@ static int cmd_micp_mute_disable(const struct shell *sh, size_t argc,
return result;
}
#if defined(CONFIG_BT_MICP_AICS)
static int cmd_micp_aics_deactivate(const struct shell *sh, size_t argc,
static int cmd_micp_mic_dev_mute(const struct shell *sh, size_t argc,
char **argv)
{
int result = bt_micp_mic_dev_mute(NULL);
if (result != 0) {
shell_error(sh, "Fail: %d", result);
}
return result;
}
static int cmd_micp_mic_dev_unmute(const struct shell *sh, size_t argc,
char **argv)
{
int result = bt_micp_mic_dev_unmute(NULL);
if (result != 0) {
shell_error(sh, "Fail: %d", result);
}
return result;
}
static int cmd_micp_mic_dev_mute_disable(const struct shell *sh, size_t argc,
char **argv)
{
int result = bt_micp_mic_dev_disable(micp);
if (result != 0) {
shell_error(sh, "Fail: %d", result);
}
return result;
}
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
static int cmd_micp_mic_dev_aics_deactivate(const struct shell *sh, size_t argc,
char **argv)
{
int result;
@ -219,7 +220,7 @@ static int cmd_micp_aics_deactivate(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_activate(const struct shell *sh, size_t argc,
static int cmd_micp_mic_dev_aics_activate(const struct shell *sh, size_t argc,
char **argv)
{
int result;
@ -239,8 +240,8 @@ static int cmd_micp_aics_activate(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_input_state_get(const struct shell *sh, size_t argc,
char **argv)
static int cmd_micp_mic_dev_aics_input_state_get(const struct shell *sh,
size_t argc, char **argv)
{
int result;
int index = strtol(argv[1], NULL, 0);
@ -259,8 +260,8 @@ static int cmd_micp_aics_input_state_get(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_gain_setting_get(const struct shell *sh, size_t argc,
char **argv)
static int cmd_micp_mic_dev_aics_gain_setting_get(const struct shell *sh,
size_t argc, char **argv)
{
int result;
int index = strtol(argv[1], NULL, 0);
@ -279,8 +280,8 @@ static int cmd_micp_aics_gain_setting_get(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_input_type_get(const struct shell *sh, size_t argc,
char **argv)
static int cmd_micp_mic_dev_aics_input_type_get(const struct shell *sh,
size_t argc, char **argv)
{
int result;
int index = strtol(argv[1], NULL, 0);
@ -299,8 +300,8 @@ static int cmd_micp_aics_input_type_get(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_input_status_get(const struct shell *sh, size_t argc,
char **argv)
static int cmd_micp_mic_dev_aics_input_status_get(const struct shell *sh,
size_t argc, char **argv)
{
int result;
int index = strtol(argv[1], NULL, 0);
@ -319,8 +320,8 @@ static int cmd_micp_aics_input_status_get(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_input_unmute(const struct shell *sh, size_t argc,
char **argv)
static int cmd_micp_mic_dev_aics_input_unmute(const struct shell *sh,
size_t argc, char **argv)
{
int result;
int index = strtol(argv[1], NULL, 0);
@ -339,7 +340,7 @@ static int cmd_micp_aics_input_unmute(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_input_mute(const struct shell *sh, size_t argc,
static int cmd_micp_mic_dev_aics_input_mute(const struct shell *sh, size_t argc,
char **argv)
{
int result;
@ -359,7 +360,7 @@ static int cmd_micp_aics_input_mute(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_manual_input_gain_set(const struct shell *sh,
static int cmd_micp_mic_dev_aics_manual_input_gain_set(const struct shell *sh,
size_t argc, char **argv)
{
int result;
@ -379,8 +380,9 @@ static int cmd_micp_aics_manual_input_gain_set(const struct shell *sh,
return result;
}
static int cmd_micp_aics_automatic_input_gain_set(const struct shell *sh,
size_t argc, char **argv)
static int cmd_micp_mic_dev_aics_automatic_input_gain_set(const struct shell *sh,
size_t argc,
char **argv)
{
int result;
int index = strtol(argv[1], NULL, 0);
@ -399,7 +401,7 @@ static int cmd_micp_aics_automatic_input_gain_set(const struct shell *sh,
return result;
}
static int cmd_micp_aics_gain_set(const struct shell *sh, size_t argc,
static int cmd_micp_mic_dev_aics_gain_set(const struct shell *sh, size_t argc,
char **argv)
{
int result;
@ -426,7 +428,7 @@ static int cmd_micp_aics_gain_set(const struct shell *sh, size_t argc,
return result;
}
static int cmd_micp_aics_input_description_get(const struct shell *sh,
static int cmd_micp_mic_dev_aics_input_description_get(const struct shell *sh,
size_t argc, char **argv)
{
int result;
@ -446,7 +448,7 @@ static int cmd_micp_aics_input_description_get(const struct shell *sh,
return result;
}
static int cmd_micp_aics_input_description_set(const struct shell *sh,
static int cmd_micp_mic_dev_aics_input_description_set(const struct shell *sh,
size_t argc, char **argv)
{
int result;
@ -467,7 +469,7 @@ static int cmd_micp_aics_input_description_set(const struct shell *sh,
return result;
}
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
static int cmd_micp(const struct shell *sh, size_t argc, char **argv)
{
@ -484,65 +486,65 @@ static int cmd_micp(const struct shell *sh, size_t argc, char **argv)
SHELL_STATIC_SUBCMD_SET_CREATE(micp_cmds,
SHELL_CMD_ARG(init, NULL,
"Initialize the service and register callbacks",
cmd_micp_param, 1, 0),
cmd_micp_mic_dev_param, 1, 0),
SHELL_CMD_ARG(mute_get, NULL,
"Get the mute state",
cmd_micp_mute_get, 1, 0),
cmd_micp_mic_dev_mute_get, 1, 0),
SHELL_CMD_ARG(mute, NULL,
"Mute the MICP server",
cmd_micp_mute, 1, 0),
cmd_micp_mic_dev_mute, 1, 0),
SHELL_CMD_ARG(unmute, NULL,
"Unmute the MICP server",
cmd_micp_unmute, 1, 0),
cmd_micp_mic_dev_unmute, 1, 0),
SHELL_CMD_ARG(mute_disable, NULL,
"Disable the MICP mute",
cmd_micp_mute_disable, 1, 0),
#if defined(CONFIG_BT_MICP_AICS)
cmd_micp_mic_dev_mute_disable, 1, 0),
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
SHELL_CMD_ARG(aics_deactivate, NULL,
"Deactivates a AICS instance <inst_index>",
cmd_micp_aics_deactivate, 2, 0),
cmd_micp_mic_dev_aics_deactivate, 2, 0),
SHELL_CMD_ARG(aics_activate, NULL,
"Activates a AICS instance <inst_index>",
cmd_micp_aics_activate, 2, 0),
cmd_micp_mic_dev_aics_activate, 2, 0),
SHELL_CMD_ARG(aics_input_state_get, NULL,
"Get the input state of a AICS instance <inst_index>",
cmd_micp_aics_input_state_get, 2, 0),
cmd_micp_mic_dev_aics_input_state_get, 2, 0),
SHELL_CMD_ARG(aics_gain_setting_get, NULL,
"Get the gain settings of a AICS instance <inst_index>",
cmd_micp_aics_gain_setting_get, 2, 0),
cmd_micp_mic_dev_aics_gain_setting_get, 2, 0),
SHELL_CMD_ARG(aics_input_type_get, NULL,
"Get the input type of a AICS instance <inst_index>",
cmd_micp_aics_input_type_get, 2, 0),
cmd_micp_mic_dev_aics_input_type_get, 2, 0),
SHELL_CMD_ARG(aics_input_status_get, NULL,
"Get the input status of a AICS instance <inst_index>",
cmd_micp_aics_input_status_get, 2, 0),
cmd_micp_mic_dev_aics_input_status_get, 2, 0),
SHELL_CMD_ARG(aics_input_unmute, NULL,
"Unmute the input of a AICS instance <inst_index>",
cmd_micp_aics_input_unmute, 2, 0),
cmd_micp_mic_dev_aics_input_unmute, 2, 0),
SHELL_CMD_ARG(aics_input_mute, NULL,
"Mute the input of a AICS instance <inst_index>",
cmd_micp_aics_input_mute, 2, 0),
cmd_micp_mic_dev_aics_input_mute, 2, 0),
SHELL_CMD_ARG(aics_manual_input_gain_set, NULL,
"Set the gain mode of a AICS instance to manual "
"<inst_index>",
cmd_micp_aics_manual_input_gain_set, 2, 0),
cmd_micp_mic_dev_aics_manual_input_gain_set, 2, 0),
SHELL_CMD_ARG(aics_automatic_input_gain_set, NULL,
"Set the gain mode of a AICS instance to automatic "
"<inst_index>",
cmd_micp_aics_automatic_input_gain_set, 2, 0),
cmd_micp_mic_dev_aics_automatic_input_gain_set, 2, 0),
SHELL_CMD_ARG(aics_gain_set, NULL,
"Set the gain in dB of a AICS instance <inst_index> "
"<gain (-128 to 127)>",
cmd_micp_aics_gain_set, 3, 0),
cmd_micp_mic_dev_aics_gain_set, 3, 0),
SHELL_CMD_ARG(aics_input_description_get, NULL,
"Get the input description of a AICS instance "
"<inst_index>",
cmd_micp_aics_input_description_get, 2, 0),
cmd_micp_mic_dev_aics_input_description_get, 2, 0),
SHELL_CMD_ARG(aics_input_description_set, NULL,
"Set the input description of a AICS instance "
"<inst_index> <description>",
cmd_micp_aics_input_description_set, 3, 0),
#endif /* CONFIG_BT_MICP_AICS */
cmd_micp_mic_dev_aics_input_description_set, 3, 0),
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
SHELL_SUBCMD_SET_END
);

View file

@ -47,8 +47,8 @@ CONFIG_BT_VCS_CLIENT=y
CONFIG_BT_VCS_CLIENT_MAX_VOCS_INST=2
CONFIG_BT_VCS_CLIENT_MAX_AICS_INST=2
CONFIG_BT_MICP=y
CONFIG_BT_MICP_AICS_INSTANCE_COUNT=2
CONFIG_BT_MICP_MIC_DEV=y
CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT=2
CONFIG_BT_MICP_MIC_CTLR=y
CONFIG_BT_MICP_MIC_CTLR_MAX_AICS_INST=2
@ -108,7 +108,7 @@ CONFIG_BT_DEBUG_AICS=y
CONFIG_BT_DEBUG_AICS_CLIENT=y
CONFIG_BT_DEBUG_VOCS=y
CONFIG_BT_DEBUG_VOCS_CLIENT=y
CONFIG_BT_DEBUG_MICP=y
CONFIG_BT_DEBUG_MICP_MIC_DEV=y
CONFIG_BT_DEBUG_MICP_MIC_CTLR=y
CONFIG_BT_DEBUG_MPL=y
CONFIG_BT_DEBUG_TBS=y

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifdef CONFIG_BT_MICP
#ifdef CONFIG_BT_MICP_MIC_DEV
#include <zephyr/bluetooth/audio/micp.h>
#include "common.h"
@ -32,22 +32,17 @@ static char g_aics_desc[AICS_DESC_SIZE];
static volatile bool g_cb;
static bool g_is_connected;
static void micp_mute_cb(struct bt_micp *micp, int err, uint8_t mute)
static void micp_mute_cb(struct bt_micp *micp, uint8_t mute)
{
if (err != 0) {
FAIL("MICP mute cb err (%d)", err);
return;
}
g_mute = mute;
g_cb = true;
}
static struct bt_micp_cb micp_cb = {
static struct bt_micp_mic_dev_cb micp_cb = {
.mute = micp_mute_cb,
};
#if defined(CONFIG_BT_MICP_AICS)
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
static void aics_state_cb(struct bt_aics *inst, int err, int8_t gain,
uint8_t mute, uint8_t mode)
{
@ -120,7 +115,7 @@ static struct bt_aics_cb aics_cb = {
.status = aics_status_cb,
.description = aics_description_cb
};
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
static void connected(struct bt_conn *conn, uint8_t err)
{
@ -297,10 +292,10 @@ static int test_aics_server_only(void)
return 0;
}
static void test_server_only(void)
static void test_mic_dev_only(void)
{
int err;
struct bt_micp_register_param micp_param;
struct bt_micp_mic_dev_register_param micp_param;
uint8_t expected_mute;
err = bt_enable(NULL);
@ -313,8 +308,8 @@ static void test_server_only(void)
(void)memset(&micp_param, 0, sizeof(micp_param));
#if defined(CONFIG_BT_MICP_AICS)
char input_desc[CONFIG_BT_MICP_AICS_INSTANCE_COUNT][16];
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
char input_desc[CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT][16];
for (int i = 0; i < ARRAY_SIZE(micp_param.aics_param); i++) {
micp_param.aics_param[i].desc_writable = true;
@ -328,18 +323,18 @@ static void test_server_only(void)
micp_param.aics_param[i].max_gain = 100;
micp_param.aics_param[i].cb = &aics_cb;
}
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
micp_param.cb = &micp_cb;
err = bt_micp_register(&micp_param, &micp);
err = bt_micp_mic_dev_register(&micp_param, &micp);
if (err != 0) {
FAIL("MICP init failed (err %d)\n", err);
return;
}
if (IS_ENABLED(CONFIG_BT_MICP_AICS)) {
err = bt_micp_included_get(micp, &micp_included);
if (IS_ENABLED(CONFIG_BT_MICP_MIC_DEV_AICS)) {
err = bt_micp_mic_dev_included_get(micp, &micp_included);
if (err != 0) {
FAIL("MICP get failed (err %d)\n", err);
return;
@ -350,7 +345,7 @@ static void test_server_only(void)
printk("Getting MICP mute\n");
g_cb = false;
err = bt_micp_mute_get(micp);
err = bt_micp_mic_dev_mute_get(micp);
if (err != 0) {
FAIL("Could not get MICP mute (err %d)\n", err);
return;
@ -360,7 +355,7 @@ static void test_server_only(void)
printk("Setting MICP mute\n");
expected_mute = BT_MICP_MUTE_MUTED;
err = bt_micp_mute(micp);
err = bt_micp_mic_dev_mute(micp);
if (err != 0) {
FAIL("MICP mute failed (err %d)\n", err);
return;
@ -370,7 +365,7 @@ static void test_server_only(void)
printk("Setting MICP unmute\n");
expected_mute = BT_MICP_MUTE_UNMUTED;
err = bt_micp_unmute(micp);
err = bt_micp_mic_dev_unmute(micp);
if (err != 0) {
FAIL("MICP unmute failed (err %d)\n", err);
return;
@ -380,7 +375,7 @@ static void test_server_only(void)
printk("Setting MICP disable\n");
expected_mute = BT_MICP_MUTE_DISABLED;
err = bt_micp_mute_disable(micp);
err = bt_micp_mic_dev_disable(micp);
if (err != 0) {
FAIL("MICP disable failed (err %d)\n", err);
return;
@ -388,19 +383,19 @@ static void test_server_only(void)
WAIT_FOR_COND(expected_mute == g_mute);
printk("MICP disable set\n");
if (CONFIG_BT_MICP_AICS_INSTANCE_COUNT > 0) {
if (CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT > 0) {
if (test_aics_server_only()) {
return;
}
}
PASS("MICP passed\n");
PASS("MICP mic_dev passed\n");
}
static void test_main(void)
{
int err;
struct bt_micp_register_param micp_param;
struct bt_micp_mic_dev_register_param micp_param;
err = bt_enable(NULL);
if (err != 0) {
@ -412,8 +407,8 @@ static void test_main(void)
(void)memset(&micp_param, 0, sizeof(micp_param));
#if defined(CONFIG_BT_MICP_AICS)
char input_desc[CONFIG_BT_MICP_AICS_INSTANCE_COUNT][16];
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS)
char input_desc[CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT][16];
for (int i = 0; i < ARRAY_SIZE(micp_param.aics_param); i++) {
micp_param.aics_param[i].desc_writable = true;
@ -428,18 +423,18 @@ static void test_main(void)
micp_param.aics_param[i].max_gain = 100;
micp_param.aics_param[i].cb = &aics_cb;
}
#endif /* CONFIG_BT_MICP_AICS */
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
micp_param.cb = &micp_cb;
err = bt_micp_register(&micp_param, &micp);
err = bt_micp_mic_dev_register(&micp_param, &micp);
if (err != 0) {
FAIL("MICP init failed (err %d)\n", err);
return;
}
if (IS_ENABLED(CONFIG_BT_MICP_AICS)) {
err = bt_micp_included_get(micp, &micp_included);
if (IS_ENABLED(CONFIG_BT_MICP_MIC_DEV_AICS)) {
err = bt_micp_mic_dev_included_get(micp, &micp_included);
if (err != 0) {
FAIL("MICP get failed (err %d)\n", err);
return;
@ -458,18 +453,18 @@ static void test_main(void)
WAIT_FOR_COND(g_is_connected);
PASS("MICP passed\n");
PASS("MICP mic_dev passed\n");
}
static const struct bst_test_instance test_micp[] = {
{
.test_id = "micp_server_only",
.test_id = "micp_mic_dev_only",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = test_server_only
.test_main_f = test_mic_dev_only
},
{
.test_id = "micp",
.test_id = "micp_mic_dev",
.test_post_init_f = test_init,
.test_tick_f = test_tick,
.test_main_f = test_main
@ -487,4 +482,4 @@ struct bst_test_list *test_micp_install(struct bst_test_list *tests)
return tests;
}
#endif /* CONFIG_BT_MICP */
#endif /* CONFIG_BT_MICP_MIC_DEV */

View file

@ -24,10 +24,10 @@ BOARD="${BOARD:-nrf52_bsim}"
cd ${BSIM_OUT_PATH}/bin
printf "\n\n======== Running MICP Server Only (API) test =========\n\n"
printf "\n\n==== Running MICP Microphone Device Only (API) test ====n\n"
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=micp_server_only -rs=23
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=micp_mic_dev_only -rs=23
# Simulation time should be larger than the WAIT_TIME in common.h
Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \
@ -37,10 +37,10 @@ for PROCESS_ID in $PROCESS_IDS; do
wait $PROCESS_ID || let "EXIT_CODE=$?"
done
printf "\n\n======== Running MICP and MICP client test =========\n\n"
printf "\n\n==== Running MICP Microphone Device and MICP Microphone Controller test ====n\n"
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=micp -rs=23
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=0 -testid=micp_mic_dev -rs=23
Execute ./bs_${BOARD}_tests_bluetooth_bsim_bt_bsim_test_audio_prj_conf \
-v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=micp_mic_ctlr -rs=46

View file

@ -54,8 +54,8 @@ CONFIG_BT_VCS_CLIENT=y
CONFIG_BT_VCS_CLIENT_MAX_VOCS_INST=1
CONFIG_BT_VCS_CLIENT_MAX_AICS_INST=1
CONFIG_BT_MICP=y
CONFIG_BT_MICP_AICS_INSTANCE_COUNT=1
CONFIG_BT_MICP_MIC_DEV=y
CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT=1
CONFIG_BT_MICP_MIC_CTLR=y
CONFIG_BT_MICP_MIC_CTLR_MAX_AICS_INST=1

View file

@ -58,7 +58,7 @@ tests:
extra_configs:
- CONFIG_BT_AICS_MAX_INSTANCE_COUNT=0
- CONFIG_BT_VCS_AICS_INSTANCE_COUNT=0
- CONFIG_BT_MICP_AICS_INSTANCE_COUNT=0
- CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT=0
tags: bluetooth
bluetooth.shell.audio.no_aics_vocs:
extra_args: CONF_FILE="audio.conf"
@ -69,7 +69,7 @@ tests:
- CONFIG_BT_VCS_VOCS_INSTANCE_COUNT=0
- CONFIG_BT_AICS_MAX_INSTANCE_COUNT=0
- CONFIG_BT_VCS_AICS_INSTANCE_COUNT=0
- CONFIG_BT_MICP_AICS_INSTANCE_COUNT=0
- CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT=0
tags: bluetooth
bluetooth.shell.audio.no_vcs_client:
extra_args: CONF_FILE="audio.conf"
@ -100,12 +100,12 @@ tests:
extra_configs:
- CONFIG_BT_VCS_CLIENT_MAX_VOCS_INST=0
tags: bluetooth
bluetooth.shell.audio.no_micp:
bluetooth.shell.audio.no_micp_mic_dev:
extra_args: CONF_FILE="audio.conf"
build_only: true
platform_allow: native_posix
extra_configs:
- CONFIG_BT_MICP=n
- CONFIG_BT_MICP_MIC_DEV=n
tags: bluetooth
bluetooth.shell.audio.no_micp_mic_ctlr:
extra_args: CONF_FILE="audio.conf"
@ -114,12 +114,12 @@ tests:
extra_configs:
- CONFIG_BT_MICP_MIC_CTLR=n
tags: bluetooth
bluetooth.shell.audio.no_micp_micp_mic_ctlr:
bluetooth.shell.audio.no_micp_mic_dev_micp_mic_ctlr:
extra_args: CONF_FILE="audio.conf"
build_only: true
platform_allow: native_posix
extra_configs:
- CONFIG_BT_MICP=n
- CONFIG_BT_MICP_MIC_DEV=n
- CONFIG_BT_MICP_MIC_CTLR=n
tags: bluetooth
bluetooth.shell.audio.micp_mic_ctlr_no_aics_client: