-
Notifications
You must be signed in to change notification settings - Fork 7.5k
tests: Bluetooth: Tester: VCP BSIM test #86664
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
Open
Thalley
wants to merge
1
commit into
zephyrproject-rtos:main
Choose a base branch
from
Thalley:bttester_bsim_vcp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2025 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include <zephyr/bluetooth/addr.h> | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/logging/log.h> | ||
#include <zephyr/net_buf.h> | ||
#include <zephyr/sys/util_macro.h> | ||
|
||
#include "babblekit/testcase.h" | ||
#include "bstests.h" | ||
|
||
#include "btp/btp.h" | ||
#include "bsim_btp.h" | ||
|
||
LOG_MODULE_REGISTER(bsim_vcp_central, CONFIG_BSIM_BTTESTER_LOG_LEVEL); | ||
|
||
static void test_vcp_central(void) | ||
{ | ||
char addr_str[BT_ADDR_LE_STR_LEN]; | ||
bt_addr_le_t remote_addr; | ||
|
||
bsim_btp_uart_init(); | ||
|
||
bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL); | ||
|
||
bsim_btp_core_register(BTP_SERVICE_ID_GAP); | ||
bsim_btp_core_register(BTP_SERVICE_ID_VCP); | ||
bsim_btp_core_register(BTP_SERVICE_ID_VOCS); | ||
bsim_btp_core_register(BTP_SERVICE_ID_AICS); | ||
|
||
bsim_btp_gap_start_discovery(BTP_GAP_DISCOVERY_FLAG_LE); | ||
bsim_btp_wait_for_gap_device_found(&remote_addr); | ||
bt_addr_le_to_str(&remote_addr, addr_str, sizeof(addr_str)); | ||
LOG_INF("Found remote device %s", addr_str); | ||
|
||
bsim_btp_gap_stop_discovery(); | ||
bsim_btp_gap_connect(&remote_addr, BTP_GAP_ADDR_TYPE_IDENTITY); | ||
bsim_btp_wait_for_gap_device_connected(NULL); | ||
LOG_INF("Device %s connected", addr_str); | ||
|
||
bsim_btp_gap_pair(&remote_addr); | ||
bsim_btp_wait_for_gap_sec_level_changed(NULL, NULL); | ||
|
||
bsim_btp_vcp_discover(&remote_addr); | ||
bsim_btp_wait_for_vcp_discovered(NULL); | ||
|
||
const uint8_t new_vol = 123; | ||
uint8_t ev_vol; | ||
|
||
bsim_btp_vcp_ctlr_set_vol(&remote_addr, new_vol); | ||
bsim_btp_wait_for_vcp_state(NULL, &ev_vol); | ||
TEST_ASSERT(ev_vol == new_vol, "%u != %u", ev_vol, new_vol); | ||
|
||
const int16_t new_offset = -5; | ||
int16_t ev_offset; | ||
|
||
bsim_btp_vocs_state_set(&remote_addr, new_offset); | ||
bsim_btp_wait_for_vocs_state(NULL, &ev_offset); | ||
TEST_ASSERT(ev_offset == new_offset, "%d != %d", ev_offset, new_offset); | ||
|
||
const int8_t new_gain = 5; | ||
int8_t ev_gain; | ||
|
||
bsim_btp_aics_set_gain(&remote_addr, new_gain); | ||
bsim_btp_wait_for_aics_state(NULL, &ev_gain); | ||
TEST_ASSERT(ev_gain == new_gain, "%d != %d", ev_gain, new_gain); | ||
|
||
bsim_btp_gap_disconnect(&remote_addr); | ||
bsim_btp_wait_for_gap_device_disconnected(NULL); | ||
LOG_INF("Device %s disconnected", addr_str); | ||
|
||
TEST_PASS("PASSED\n"); | ||
} | ||
|
||
static const struct bst_test_instance test_sample[] = { | ||
{ | ||
.test_id = "vcp_central", | ||
.test_descr = "Smoketest for the VCP central BT Tester behavior", | ||
.test_main_f = test_vcp_central, | ||
}, | ||
BSTEST_END_MARKER, | ||
}; | ||
|
||
struct bst_test_list *test_vcp_central_install(struct bst_test_list *tests) | ||
{ | ||
return bst_add_tests(tests, test_sample); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2025 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include <zephyr/bluetooth/addr.h> | ||
#include <zephyr/bluetooth/gap.h> | ||
#include <zephyr/bluetooth/hci_types.h> | ||
#include <zephyr/logging/log.h> | ||
#include <zephyr/sys/util_macro.h> | ||
|
||
#include "babblekit/testcase.h" | ||
#include "bstests.h" | ||
|
||
#include "btp/btp.h" | ||
#include "bsim_btp.h" | ||
|
||
LOG_MODULE_REGISTER(bsim_vcp_peripheral, CONFIG_BSIM_BTTESTER_LOG_LEVEL); | ||
|
||
static void test_vcp_peripheral(void) | ||
{ | ||
char addr_str[BT_ADDR_LE_STR_LEN]; | ||
bt_addr_le_t remote_addr; | ||
|
||
bsim_btp_uart_init(); | ||
|
||
bsim_btp_wait_for_evt(BTP_SERVICE_ID_CORE, BTP_CORE_EV_IUT_READY, NULL); | ||
|
||
bsim_btp_core_register(BTP_SERVICE_ID_GAP); | ||
bsim_btp_core_register(BTP_SERVICE_ID_VCS); | ||
bsim_btp_core_register(BTP_SERVICE_ID_VOCS); | ||
bsim_btp_core_register(BTP_SERVICE_ID_AICS); | ||
|
||
bsim_btp_gap_set_discoverable(BTP_GAP_GENERAL_DISCOVERABLE); | ||
bsim_btp_gap_start_advertising(0U, 0U, NULL, BT_HCI_OWN_ADDR_PUBLIC); | ||
bsim_btp_wait_for_gap_device_connected(&remote_addr); | ||
bt_addr_le_to_str(&remote_addr, addr_str, sizeof(addr_str)); | ||
LOG_INF("Device %s connected", addr_str); | ||
bsim_btp_wait_for_gap_device_disconnected(NULL); | ||
LOG_INF("Device %s disconnected", addr_str); | ||
|
||
TEST_PASS("PASSED\n"); | ||
} | ||
|
||
static const struct bst_test_instance test_sample[] = { | ||
{ | ||
.test_id = "vcp_peripheral", | ||
.test_descr = "Smoketest for the VCP peripheral BT Tester behavior", | ||
.test_main_f = test_vcp_peripheral, | ||
}, | ||
BSTEST_END_MARKER, | ||
}; | ||
|
||
struct bst_test_list *test_vcp_peripheral_install(struct bst_test_list *tests) | ||
{ | ||
return bst_add_tests(tests, test_sample); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the change to this file does not apply when assigning reviewers and labels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Only the maintainers file owner itself is notified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty interesting, because that means there's a chicken-and-egg situation here, right?
We cannot files to MAINTAINERS.yml before they exist, and the file isn't applied when added together :)
It's not a big issue, but was a bit surprising as generally changes to files in a PR is applied to CI