Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bluetooth: tester: MICP Client tests #60045

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

piotrnarajowski
Copy link
Contributor

Add support for MICP Client tests

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @piotrnarajowski, and thank you very much for your first pull request to the Zephyr project!

A project maintainer just triggered our CI pipeline to run it against your PR and ensure it's compliant and doesn't cause any issues. You might want to take this opportunity to review the project's Contributor Expectations and make any updates to your pull request if necessary. 😊

@Thalley Thalley assigned Thalley and unassigned jhedberg Jul 5, 2023
@@ -271,6 +271,36 @@ int bt_micp_mic_ctlr_mute_get(struct bt_micp_mic_ctlr *mic_ctlr);
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_ctlr_cb_register(struct bt_micp_mic_ctlr_cb *cb);

/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that those APIs should be under BLUETOOTH_TESTING (those are upper tester interfaces only)

(see include/zephyr/bluetooth/testing.h)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be added at all :)

None of our other tests depend on the GATT handle - Why would these?

@@ -19,6 +19,7 @@
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/audio/micp.h>
#include <../../subsys/bluetooth/audio/aics_internal.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

#include "btp/btp.h"

static struct bt_micp_mic_ctlr *mic_ctlr;
#if defined(CONFIG_BT_MICP_MIC_CTLR_AICS)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: empty line before #if, no emptu line before #endif

(void) bt_conn_get_info(conn, &info);
bt_addr_le_copy(&ev.address, info.le.dst);

ev.mute_handle = mute_handle;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys_cpu_to_le16()

every uint16, uint32 and uint64 needs to be converted to LE when sending over BTP

(void) bt_conn_get_info(conn, &info);
bt_addr_le_copy(&ev.address, info.le.dst);

ev.state_handle = state_handle;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

err = bt_micp_mic_ctlr_discover(conn, &mic_ctlr);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

static uint8_t micp_aics_unmute(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
LOG_DBG("Unmute");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we verify that expected peer has profile connected? (BTP command has peer address)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MICP commands will return -ENOTCONN if not connected (or more like -EINVAL since the GATT handles would not have been set yet if discovery hasn't been done, so it will still fail gracefully if not connected


static uint8_t micp_aics_mute(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto and others command too


err = bt_micp_mic_ctlr_cb_register(&micp_cbs);
if (err != 0) {
LOG_DBG("Failed to register callbacks: %d", err);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return BTP_STATUS_FAILED;

we don't want to initialize service if those failed


uint8_t tester_unregister_micp(void)
{
return BTP_STATUS_SUCCESS;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call bt_micp_mic_ctlr_cb_register(NULL); here to "unregister" callbacks?

Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly code style and minor comment. The big comment is that these tests should not depend on the GATT handle if it can be avoided.

@@ -271,6 +271,36 @@ int bt_micp_mic_ctlr_mute_get(struct bt_micp_mic_ctlr *mic_ctlr);
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_ctlr_cb_register(struct bt_micp_mic_ctlr_cb *cb);

/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should not be added at all :)

None of our other tests depend on the GATT handle - Why would these?

tests/bluetooth/tester/overlay-le-audio.conf Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_micp.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_micp.c Show resolved Hide resolved
tests/bluetooth/tester/src/btp_micp.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_micp.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_micp.c Outdated Show resolved Hide resolved
static uint8_t micp_aics_unmute(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
{
LOG_DBG("Unmute");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MICP commands will return -ENOTCONN if not connected (or more like -EINVAL since the GATT handles would not have been set yet if discovery hasn't been done, so it will still fail gracefully if not connected

tests/bluetooth/tester/src/btp_micp.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_micp.c Outdated Show resolved Hide resolved
include/zephyr/bluetooth/audio/micp.h Outdated Show resolved Hide resolved
include/zephyr/bluetooth/audio/micp.h Outdated Show resolved Hide resolved
include/zephyr/bluetooth/audio/micp.h Outdated Show resolved Hide resolved
subsys/bluetooth/audio/micp_internal.h Outdated Show resolved Hide resolved
subsys/bluetooth/audio/micp_mic_ctlr.c Show resolved Hide resolved
tests/bluetooth/tester/CMakeLists.txt Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp/btp.h Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp/btp_aics.h Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp/btp_aics.h Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp/btp_micp.h Outdated Show resolved Hide resolved

if (err != 0) {
LOG_DBG("Discovery failed (%d)", err);
return BTP_MICP_DISCOVERY_STATUS_FAILED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build warning: 'return' with a value, in function returning void

Suggested change
return BTP_MICP_DISCOVERY_STATUS_FAILED;
return;


err = bt_micp_mic_ctlr_mute_get(mic_ctlr);
if (err != 0) {
BTP_STATUS_FAILED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build warning: statement with no effect

Suggested change
BTP_STATUS_FAILED;
return BTP_STATUS_FAILED;


#define LOG_MODULE_NAME bttester_aics
LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move closing bracket into upper line.

tests/bluetooth/tester/overlay-le-audio.conf Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_aics.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_aics.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_aics.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_aics.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_aics.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_aics.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_aics.c Outdated Show resolved Hide resolved
tests/bluetooth/tester/src/btp_aics.c Show resolved Hide resolved
tests/bluetooth/tester/src/btp_micp.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@Thalley Thalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments have been resolved, but I still see a few unresolved comments from other reviews

MariuszSkamra
MariuszSkamra previously approved these changes Aug 23, 2023
Copy link
Collaborator

@MariuszSkamra MariuszSkamra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thalley
Thalley previously approved these changes Aug 23, 2023
@@ -20,6 +20,7 @@
*/

#include <stdint.h>
#include <../../subsys/bluetooth/audio/micp_internal.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public header include/zephyr/bluetooth/audio/micp.h shall not include internal header ../../subsys/bluetooth/audio/micp_internal.h

This is needed for upper tester.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
Add support for MICP Client tests.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
@Thalley
Copy link
Collaborator

Thalley commented Aug 28, 2023

@carlescufi I think this can be merged without @sjanc approval (he is on OOO for 2 weeks it seems)

@carlescufi carlescufi merged commit 925a8b6 into zephyrproject-rtos:main Sep 8, 2023
19 checks passed
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @piotrnarajowski!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

9 participants