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 Aug 18, 2023
1 parent 1953a49 commit 22bca3f
Show file tree
Hide file tree
Showing 10 changed files with 1,101 additions and 275 deletions.
8 changes: 8 additions & 0 deletions tests/bluetooth/tester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ endif()
if (CONFIG_BT_CSIP_SET_MEMBER)
target_sources(app PRIVATE src/btp_csis.c)
endif()

if(CONFIG_BT_MICP_MIC_DEV)
target_sources(app PRIVATE src/btp_micp.c)
endif()

if(CONFIG_BT_AICS)
target_sources(app PRIVATE src/btp_aics.c)
endif()
6 changes: 6 additions & 0 deletions tests/bluetooth/tester/overlay-le-audio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ CONFIG_BT_BUF_CMD_TX_SIZE=255
# were freed too slow. The bt_bap_stream_ops.configured callback comes earlier.
CONFIG_BT_L2CAP_TX_BUF_COUNT=4

# MICP
CONFIG_BT_MICP_MIC_DEV=y
CONFIG_BT_MICP_MIC_CTLR=y
CONFIG_BT_MICP_MIC_CTLR_MAX_AICS_INST=1
CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT=1

# ASCS
CONFIG_BT_ASCS_ASE_SNK_COUNT=2
CONFIG_BT_ASCS_ASE_SRC_COUNT=2
Expand Down
2 changes: 2 additions & 0 deletions tests/bluetooth/tester/src/btp/btp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "btp_bap.h"
#include "btp_has.h"
#include "btp_csis.h"
#include "btp_micp.h"

#define BTP_MTU 1024
#define BTP_DATA_MAX_SIZE (BTP_MTU - sizeof(struct btp_hdr))
Expand All @@ -48,6 +49,7 @@
#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_CSIS 17

#define BTP_SERVICE_ID_MAX BTP_SERVICE_ID_CSIS
Expand Down
100 changes: 98 additions & 2 deletions tests/bluetooth/tester/src/btp/btp_aics.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,125 @@
*/

#include <zephyr/sys/util.h>
#include <zephyr/bluetooth/conn.h>

/*AICS service */
struct btp_aics_instance {
/** Number of Audio Input Control Service instances */
uint8_t aics_cnt;
/** Array of pointers to Audio Input Control Service instances */
struct bt_aics **aics;
};

extern struct bt_aics_cb aics_client_cb;
extern struct btp_aics_instance aics_client_instance;
extern struct btp_aics_instance aics_server_instance;
void btp_send_aics_state_changed_ev(struct bt_conn *conn);
void btp_send_aics_state_ev(struct bt_conn *conn, int8_t gain, uint8_t mute, uint8_t mode);
void btp_send_gain_setting_properties_ev(struct bt_conn *conn, uint8_t units, int8_t minimum,
int8_t maximum);
void btp_send_aics_input_type_event(struct bt_conn *conn, uint8_t input_type);
void btp_aics_status_ev(struct bt_conn *conn, bool active);
void btp_aics_description_ev(struct bt_conn *conn, uint8_t data_len, char *description);

#define BTP_AICS_READ_SUPPORTED_COMMANDS 0x01
struct btp_aics_read_supported_commands_rp {
uint8_t data[0];
} __packed;

/* AICS client/server commands */
#define BTP_AICS_SET_GAIN 0x02
struct btp_aics_set_gain_cmd {
bt_addr_le_t address;
int8_t gain;
} __packed;

#define BTP_AICS_MUTE 0x03
struct btp_aics_mute_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_AICS_UNMUTE 0x04
struct btp_aics_unmute_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_AICS_MAN_GAIN 0x05
struct btp_aics_manual_gain_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_AICS_AUTO_GAIN 0x06
struct btp_aics_auto_gain_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_AICS_MAN_GAIN_ONLY 0x07
#define BTP_AICS_AUTO_GAIN_ONLY 0x08

#define BTP_AICS_DESCRIPTION 0x09
#define BTP_AICS_AUDIO_DESCRIPTION_SET 0x09
struct btp_aics_audio_desc_cmd {
uint8_t desc_len;
uint8_t desc[0];
} __packed;

#define BTP_AICS_MUTE_DISABLE 0x0a
#define BTP_AICS_GAIN_SETTING_PROP 0x0b
struct btp_aics_gain_setting_prop_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_AICS_TYPE 0x0c
struct btp_aics_type_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_AICS_STATUS 0x0d
struct btp_aics_status_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_AICS_STATE 0x0e
struct btp_aics_state_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_AICS_DESCRIPTION 0x0f
struct btp_aics_desc_cmd {
bt_addr_le_t address;
} __packed;

/* AICS events */
#define BTP_AICS_STATE_EV 0x80
struct btp_aics_state_ev {
bt_addr_le_t address;
int8_t gain;
uint8_t mute;
uint8_t mode;
} __packed;

#define BTP_GAIN_SETTING_PROPERTIES_EV 0x81
struct btp_gain_setting_properties_ev {
bt_addr_le_t address;
uint8_t units;
int8_t minimum;
int8_t maximum;
} __packed;

#define BTP_AICS_INPUT_TYPE_EV 0x82
struct btp_aics_input_type_ev {
bt_addr_le_t address;
uint8_t input_type;
} __packed;

#define BTP_AICS_STATUS_EV 0x83
struct btp_aics_status_ev {
bt_addr_le_t address;
bool active;
} __packed;

#define BTP_AICS_DESCRIPTION_EV 0x84
struct btp_aics_description_ev {
bt_addr_le_t address;
uint8_t data_len;
char data[0];
} __packed;
47 changes: 47 additions & 0 deletions tests/bluetooth/tester/src/btp/btp_micp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* 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_CTLR_DISCOVER 0x02
struct btp_micp_discover_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_CTLR_MUTE_READ 0x03
struct btp_micp_mute_read_cmd {
bt_addr_le_t address;
} __packed;

#define BTP_MICP_CTLR_MUTE 0x04
struct btp_micp_mute_cmd {
bt_addr_le_t address;
} __packed;

/* MICP events */
#define BTP_MICP_DISCOVERED_EV 0x80
struct btp_micp_discovered_ev {
bt_addr_le_t address;
uint16_t mute_handle;
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;

#define BTP_MICP_MUTE_STATE_EV 0x81
struct btp_micp_mute_state_ev {
bt_addr_le_t address;
uint8_t mute;
} __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 @@ -92,3 +92,6 @@ uint8_t tester_unregister_has(void);

uint8_t tester_init_csis(void);
uint8_t tester_unregister_csis(void);

uint8_t tester_init_micp(void);
uint8_t tester_unregister_micp(void);
Loading

0 comments on commit 22bca3f

Please sign in to comment.