Skip to content

Commit

Permalink
bluetooth: tester: MICP Client tests
Browse files Browse the repository at this point in the history
Add support for MICP Client tests.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
  • Loading branch information
piotrnarajowski committed Jul 7, 2023
1 parent 61ec4aa commit 2917a40
Show file tree
Hide file tree
Showing 7 changed files with 668 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/bluetooth/tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ endif()
if(CONFIG_BT_HAS)
target_sources(app PRIVATE src/btp_has.c)
endif()

if(CONFIG_BT_MICP_MIC_DEV)
target_sources(app PRIVATE src/btp_micp.c)
endif()
5 changes: 5 additions & 0 deletions tests/bluetooth/tester/overlay-le-audio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ CONFIG_BT_BUF_EVT_RX_COUNT=16
CONFIG_BT_BUF_EVT_RX_SIZE=255
CONFIG_BT_BUF_CMD_TX_SIZE=255

# MICP
CONFIG_BT_MICP_MIC_DEV=y
CONFIG_BT_MICP_MIC_CTLR=y
CONFIG_BT_MICP_MIC_CTLR_MAX_AICS_INST=2

# ASCS
CONFIG_BT_ASCS_ASE_SNK_COUNT=2
CONFIG_BT_ASCS_ASE_SRC_COUNT=2
Expand Down
5 changes: 4 additions & 1 deletion tests/bluetooth/tester/src/btp/btp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "btp_ascs.h"
#include "btp_bap.h"
#include "btp_has.h"
#include "btp_micp.h"

#define BTP_MTU 1024
#define BTP_DATA_MAX_SIZE (BTP_MTU - sizeof(struct btp_hdr))
Expand All @@ -47,8 +48,10 @@
#define BTP_SERVICE_ID_ASCS 13
#define BTP_SERVICE_ID_BAP 14
#define BTP_SERVICE_ID_HAS 15
#define BTP_SERVICE_ID_MICP 16
#define BTP_SERVICE_ID_MICS 17

#define BTP_SERVICE_ID_MAX BTP_SERVICE_ID_HAS
#define BTP_SERVICE_ID_MAX BTP_SERVICE_ID_MICS

#define BTP_STATUS_SUCCESS 0x00
#define BTP_STATUS_FAILED 0x01
Expand Down
109 changes: 109 additions & 0 deletions tests/bluetooth/tester/src/btp/btp_micp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* btp_micp.h - Bluetooth tester headers */

/*
* Copyright (c) 2023 Codecoup
*
* SPDX-License-Identifier: Apache-2.0
*/

/* MICP commands */
#define BTP_MICP_READ_SUPPORTED_COMMANDS 0x01
struct btp_micp_read_supported_commands_rp {
uint8_t data[0];
} __packed;

#define BTP_MICP_DISCOVER 0x02
struct btp_micp_discover_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_SET_GAIN 0x03
struct btp_micp_set_gain_cmd {
bt_addr_le_t address;
int8_t gain;
} __packed;

#define BTP_MICP_AICS_STATE 0x04
struct btp_micp_aics_state_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_MUTE_READ 0x05
struct btp_micp_mute_read_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_GAIN_SETTING_PROP 0x06
struct btp_micp_gain_setting_prop_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_MUTE 0x07
struct btp_micp_mute_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_AICS_TYPE 0x08
struct btp_micp_aics_type_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_AICS_STATUS 0x09
struct btp_micp_aics_status_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_AICS_UNMUTE 0x0a
struct btp_micp_aics_unmute_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_AICS_MUTE 0x0b
struct btp_micp_aics_mute_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_AICS_MAN_GAIN 0x0c
struct btp_micp_aics_manual_gain_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_AICS_AUTO_GAIN 0x0d
struct btp_micp_aics_auto_gain_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_DISCOVERY_STATUS_SUCCESS 0x00
#define BTP_MICP_DISCOVERY_STATUS_FAILED 0x01

/* MICP events */
#define BTP_MICP_DISCOVERED_EV 0x80
struct btp_micp_discovered_ev {
bt_addr_le_t address;
uint16_t mute_handle;
} __packed;

#define BTP_MICP_AICS_STATE_EV 0x81
struct btp_micp_aics_state_ev {
bt_addr_le_t address;
int8_t gain;
uint8_t mute;
uint8_t mode;
} __packed;

#define BTP_MICP_MUTE_READ_EV 0x82
struct btp_micp_mute_read_ev {
bt_addr_le_t address;
uint8_t mute;
} __packed;

#define BTP_MICP_AICS_CHRC_EV 0x83
struct btp_micp_aics_handle_ev {
bt_addr_le_t address;
uint16_t state_handle;
uint16_t gain_handle;
uint16_t type_handle;
uint16_t status_handle;
uint16_t control_handle;
uint16_t desc_handle;
} __packed;
3 changes: 3 additions & 0 deletions tests/bluetooth/tester/src/btp/bttester.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ uint8_t tester_unregister_bap(void);

uint8_t tester_init_has(void);
uint8_t tester_unregister_has(void);

uint8_t tester_init_micp(void);
uint8_t tester_unregister_micp(void);
9 changes: 9 additions & 0 deletions tests/bluetooth/tester/src/btp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ static uint8_t supported_services(const void *cmd, uint16_t cmd_len,
#if defined(CONFIG_BT_HAS) || defined(CONFIG_BT_HAS_CLIENT)
tester_set_bit(rp->data, BTP_SERVICE_ID_HAS);
#endif /* CONFIG_BT_HAS */
#if defined(CONFIG_BT_MICP_MIC_DEV) || defined(CONFIG_BT_MICP_MIC_CTLR)
tester_set_bit(rp->data, BTP_SERVICE_ID_MICP);
#endif /* CONFIG_BT_MICP_MIC_DEV */

*rsp_len = sizeof(*rp) + 2;

Expand Down Expand Up @@ -142,6 +145,9 @@ static uint8_t register_service(const void *cmd, uint16_t cmd_len,
case BTP_SERVICE_ID_BAP:
status = tester_init_bap();
break;
case BTP_SERVICE_ID_MICP:
status = tester_init_micp();
break;
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT or CONFIG_BT_BAP_UNICAST_SERVER */
#if defined(CONFIG_BT_HAS)
case BTP_SERVICE_ID_HAS:
Expand Down Expand Up @@ -220,6 +226,9 @@ static uint8_t unregister_service(const void *cmd, uint16_t cmd_len,
case BTP_SERVICE_ID_BAP:
status = tester_unregister_bap();
break;
case BTP_SERVICE_ID_MICP:
status = tester_unregister_micp();
break;
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT or CONFIG_BT_BAP_UNICAST_SERVER */
#if defined(CONFIG_BT_HAS)
case BTP_SERVICE_ID_HAS:
Expand Down
Loading

0 comments on commit 2917a40

Please sign in to comment.