Commit graph

2,691 commits

Author SHA1 Message Date
Emil Gydesen
f6905b7374 tests: Bluetooth: Shell: Add bluetooth.shell.audio.no_assert
Add a test case that disables asserts to ensure that the
BT shell with audio can be built without compiler
warnings/errors when asserts are disabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-07 12:47:30 +02:00
Emil Gydesen
f0c6168e54 tests: Bluetooth: CAP: Update unicast audio start unittests
Update the CAP initiator audio start unittest.
The reason for this, is that the recent change to endpoints
means that we need to properly generate a BAP unicast group
and call bt_bap_stream_config, instead of trying to manage
the bap_iso values directly.

As part of updating this, the tests were also updated to
significantly reduce code duplication, but generating
a default start param that can easily be reused.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-03 12:51:45 +03:00
Emil Gydesen
c63ec6b5b0 tests: Bluetooth: Audio: Fix uninitalized value
copy may be uninitialzed in the default case, which causes some
compiler warnings/errors when returned and used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-02 15:15:17 +03:00
Emil Gydesen
881a24270c Bluetooth: BAP: Rename and fix bt_bap_is_x_ep
Rename the bt_bap_is_x_ep functions to better match the
modules where they are implemented.

Additionally modify the check to use IS_ARRAY_ELEMENT
in the broadcast sink and source for a stricter check.
IS_ARRAY_ELEMENT cannot easily be used in the unicast
client and server, as the endpoints are part of another
structure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-29 12:38:06 -04:00
Emil Gydesen
6c1cd61792 Bluetooth: BAP: Add missing check for unicast server ep
We check for all other roles when checking whether
an endpoint can send or receive, except for the unicast server.
It is technically implied, but if the ep is not a valid pointer,
then we may access invalid memory.

Add check for bt_bap_ep_is_unicast_server (which uses the new
bt_ascs_has_ep function).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-29 12:38:06 -04:00
Make Shi
2b622a14e3 Bluetooth: Classic: AVRCP : Enable AVRCP features in shell test config
This patch enables AVRCP-related configuration options in the shell
test project. These options are required to test AVRCP functionality
in Bluetooth Classic shell environment.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-09-29 05:50:47 +02:00
Fabio Baltieri
a3bb826a20 tests: bluetooth: fix various shadowed declarations
Fix various -Werror=shadow errors.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-09-26 09:34:40 -04:00
Szymon Janc
b6e7b650a2 Bluetooth: tester: Tune native_sim HCI configuration
Memory usage is not an issue since this is native_sim build runing
on Linux.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-09-23 09:40:25 +01:00
Szymon Janc
6efb6bf008 tests: Bluetooth: Tester: Always enable ISO for GAP
This is part of GAP and should be always enabled (just like periodic
advertising and others).

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-09-22 13:29:05 -04:00
Lyle Zhu
bcf9a088f4 Bluetooth: tester: Add SDP discover command
Add commands `BTP_SDP_SEARCH_REQ`, `BTP_SDP_ATTR_REQ`, and
`BTP_SDP_SEARCH_ATTR_REQ`.

Add service record handle report event
`BTP_SDP_EV_SERVICE_RECORD_HANDLE`.

Handle the commands and call function `bt_sdp_discover()` to start the
SDP discovery.

And report the discovered service record handle if the request type is
`BTP_SDP_SEARCH_REQ`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-09-16 14:05:09 +02:00
Lyle Zhu
9d386edb4a Bluetooth: tester: Add service for SDP
Add service id BTP_SERVICE_ID_SDP=0x1f for SDP.

Implement function `tester_init_sdp` and `tester_unregister_sdp`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-09-16 14:05:09 +02:00
Szymon Janc
0907701688 tests: Bluetooth: Tester: Fix storing invalid broadcast ID
Broadcast ID is 24bits and uinitialized broadcast_id resulted in
(pseudo) random failures since only 3 bytes were set by call to
bt_rand().

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-09-11 06:27:18 -04:00
Szymon Janc
7d84a3b639 tests: Bluetooth: Tester: Increase number of ISO RX bufs
This helps to circumvent issues in current BAP implementation when
multiple streams are present. Also puts RX path in line with
configuration of TX path.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-09-10 16:40:55 +02:00
Lyle Zhu
3052891af6 tests: bluetooth: classic: Add test cases for ATTR ID list feature
Add two optional arguments to shell commands `sdp_client sa_discovery`
and `sdp_client ssa_discovery`.

The first argument is the beginning of the attribute ID.
The second argument is the ending of the attribute ID. If the second
argument is omitted, the ending of the attribute ID is 0xffff.

Add test case `test_sdp_ssa_discover_multiple_records_with_range` to
test the ssa request with attribute ID list.

Add test case `test_sdp_sa_discover_multiple_records_with_range` to
test the sa request with attribute ID list.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-09-10 08:27:21 +02:00
Emil Gydesen
bcf7469ce8 tests: Bluetooth: tester: Don't access BAP endpoints directly
Modify the code to use the public API to get the endpoint
ID and direction rather than relying on the internal
bap_endpoint.h header file.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 10:30:45 +02:00
Emil Gydesen
ce9e8f8b9e Bluetooth: BAP: Fix bad use of bt_ascs_ase_status
The bt_ascs_ase_status was stored directly in the
struct bt_bap_ep, which was an issue as
bt_ascs_ase_status is a variable sized struct.
The struct could have been moved to the end of
bt_bap_ep to avoid the issues it caused, but
there is no actual reason to use that struct
rather than storing the ID and state as
seperate values.

The ascs_ep_get_state exists but was not widely
used in ascs. Modify places to use the function
instead of directly accessing the state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 10:30:45 +02:00
Szymon Janc
634a5d0ef3 tests: Bluetooth: Tester: Enable debug logs by default
This is mainly used for testing.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-09-09 09:10:35 +02:00
Kyle Micallef Bonnici
789532cb59 devicetree: format files in tests/bluetooth/shell
Applying dts-linter results for files in

tests/bluetooth/shell

Signed-off-by: Kyle Micallef Bonnici <kylebonnici@hotmail.com>
2025-09-08 10:28:48 +01:00
Szymon Janc
e0ce77dd28 tests: Bluetooth: Tester: Disallow changing adv type when enabled
This is used for properly tracking if legacy or extended advertising
API is used and should not be changed if advertisign is enabled.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-09-04 16:45:56 +02:00
Szymon Janc
7ef7dee60f tests: Bluetooth: Tester: Fix leaking advertising instance
If extended advertising was used GAP module was always creating
new instance on advertising start (while failing to stop it at
the same time).

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-09-04 16:45:56 +02:00
Emil Gydesen
aa27460880 Bluetooth: CCP: Add support for set/get provider name
Add support for setting and getting the bearer provider
name. For now the name will be duplicated by the TBS
implementation, but will be optimizied in the future
so only one copy of the name exists.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-04 11:30:36 +02:00
Emil Gydesen
2d85792e6a tests: Bluetooth: CAP: Unittest bt_cap_unicast_group_get_info
Add unittests for bt_cap_unicast_group_get_info.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-03 13:49:54 +03:00
Flavio Ceolin
bfa44f5aa2 tests: bt/tester: Use proper flexible array
0 length array is a GNU extension. Use proper C99 flexible
array.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-09-03 13:49:31 +03:00
Emil Gydesen
600010cf5f Bluetooth: BAP: Switch to new USB stack for BAP shell
Modify the BAP shell to use the new USB stack, as the current
one used is now deprecated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-02 12:33:11 +02:00
Emil Gydesen
f6f79f0c5b Bluetooth: Audio: Shell: Reduce memory usage of the shell
Modify values in audio.conf to reduce memory usage.
Most notably disabling logs reduced the FLASH requirements.
Ideally the shell works as expected without debug logs, but
there are far too many profiles and services to verify them all.
All the log options are left in audio.conf so they can easily be
re-enabled when needed.

Memory before this change:
Memory region         Used Size  Region Size  %age Used
           FLASH:     1018512 B         1 MB     97.13%
             RAM:      423146 B       448 KB     92.24%
        IDT_LIST:          0 GB        32 KB      0.00%

Memory after this change:
Memory region         Used Size  Region Size  %age Used
           FLASH:      791308 B         1 MB     75.47%
             RAM:      369090 B       448 KB     80.46%
        IDT_LIST:          0 GB        32 KB      0.00%

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-30 12:30:34 +02:00
Lyle Zhu
77e6ff8ad4 tests: tester: Correct return value if ext adv create failed
The error code instead of `BTP_STATUS_FAILED` of the function
`bt_le_ext_adv_create()` should be returned.

Returns the error code returned by `bt_le_ext_adv_create()`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-29 11:05:29 +02:00
Lyle Zhu
7f12732dd6 tests: tester: Add debug log
Add debug log if the function `tester_gap_create_adv_instance()` is
failed.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-29 11:05:29 +02:00
Lyle Zhu
e8bbf5c732 tests: tester: Add LOG_* to btp.c for debug purpose
Add `LOG_ERR()` to log all reasons if status is `BTP_STATUS_FAILED`.
Add `LOG_DBG()` to log the excution result of the BTP commander.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-29 11:05:29 +02:00
Lyle Zhu
d973e4e3ce tests: bsim: tester: Add BT tester GAP ISO smoke test
Add test iso_broadcaster for GAP ISO broadcaster.
Add test iso_sync_receiver for GAP ISO sync receiver.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-29 11:05:29 +02:00
Lyle Zhu
eaf1439ea9 Bluetooth: tester: Add event of periodic BIGInfo advertising report
Add event `BTP_GAP_EV_PERIODIC_BIGINFO` to notify the received periodic
BIGInfo advertising report.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-29 11:05:29 +02:00
Lyle Zhu
a7eeea1130 Bluetooth: tester: Support feature ISO broadcaster
Add command `BTP_GAP_CREATE_BIG` to create BIG.

Add command `BTP_GAP_BIS_BROADCAST` to send broadcast data.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-29 11:05:29 +02:00
Lyle Zhu
33fc4a8d2d Bluetooth: tester: Support feature ISO sync receiver
Add command `BTP_GAP_BIG_CREATE_SYNC` to create BIG sync establishment.

Add event `BTP_GAP_EV_BIG_SYNC_ESTABLISHED` to notify the event that
the BIG sync is established.

Add event `BTP_GAP_EV_BIG_SYNC_LOST` to notify the event that the BIG
sync is lost.

Add event `BTP_GAP_EV_BIS_DATA_PATH_SETUP` to notify the event that
the data path of the BIS is setup.

Add event `BTP_GAP_EV_BIS_STREAM_RECEIVED` to notify the received BIS
stream data.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-29 11:05:29 +02:00
Vinayak Kariappa Chettimada
c2eb901ea1 Bluetooth: Controller: Introduce prepare deferred feature
Introduce prepare being deferred due to previous events
desire to continue. In such case the deferred prepare param
will have the defer flag set.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-28 19:57:28 +02:00
Pavel Vasilyev
dfe05dd0d7 bluetooth: host: prefix API functions with bt_
Prefix API functions of a module with bt_ to avoid confusion when
reading code.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-22 14:50:38 +02:00
Lyle Zhu
f772e3f21d tests: Bluetooth: Add test case test_sdp_discover_with_range
Add a test case test_sdp_discover_with_range to test the ssa request
with attribute ID range with the following test steps.
Step 1, Discover all included attribute IDs,
Step 2, Set the start of range from 0 to (max value + 9) of the
        discovered attribute ID,
Step 3, Set the end of range from start of range to (max value + 9)
        of the discovered attribute ID.
step 4, Send SSA request with the specific attribute ID range,
Step 5, check the discovery result according to the range,
Step 6, repeat step 4 - 5 until the range to
        (max value + 9, max value + 9).

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-22 12:36:09 +02:00
Vinayak Kariappa Chettimada
e4df18b51b Bluetooth: Controller: Fix bt_ctrl to bt_ctlr abbreviation
The Controller is abbreviated as CTLR in contrast to CTRL
which is used in the context of Link Layer Control
Procedures.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 17:13:30 +02:00
Cheng Chang
a5f25ba7b7 tests: bluetooth: classic: Add test suite l2cap client.
IUT works as a l2cap client with basic mode. The peer device,
l2cap server with basic mode, is a PC with running bumble on it.
This test only performs the function of L2CAP basic mode.
Support multiple l2cap enerties in new shell l2cap_br,
which may support more test function.

In the test suite , there are two groups in test cases.
Group 1 Including case1-case24 focuses on connection and
disconnection around l2cap. The impact of active and passive
acl connectivity, disconnectivity and authentication as well as
disconnection from ACL without l2cap disconnect is tested.

Group2 Including case25-case31 revolves around the basic
 parameters of L2CAPserver configuration, data transfer.
Case 25: Test l2cap connection with max MTU(0xffff).But the max mtu
which the stack supports is (CONFIG_BT_BUF_ACL_RX_SIZE - 4U = 196).
Case 26:  Test l2cap multi_channel connection and data tranfer.
Case 27: Test l2cap connection with invaild PSM.
Case 28: Test l2cap re_connect after disconnected.
Case 29: Test l2cap connection with min MTU(0x30).set server mtu = 48,
client mtu=48. l2cap connect successfully,
both server and client mtu should be 48.
Case 30: Test l2cap connection with min MTU(0x30). set server mtu = 48,
client mtu=0x27. l2cap connect fail.
Case 31: Test l2cap connection with min MTU(0x30).set server mtu = 30,
client mtu=48.l2cap connect successfully,
both server and client mtu should be 48.

test_l2cap_client.py is a file containing real test cases.
test_l2cap_common.py is a common file. It encapsulates some
test function functions that are commonly used for test cases.

Signed-off-by: Cheng Chang <cheng.chang@nxp.com>
2025-08-21 13:07:08 +02:00
Lyle Zhu
2df8578c7a Bluetooth: Classic: SDP: Improve SDP discovery response
In current implementation, the attribute of the registered SDP record
will not be included in responding packet if the attribute data length
is more than the MAX payload size(`MIN(SDP_MTU, sad->sdp->chan.tx.mtu)
- sizeof(struct bt_sdp_hdr)`). And it causes the failure of ssa or sa
discovery.

Improve the SDP server to support the case by extending the
continuation state length. A 4 bytes space is extended to store the
attribute offset.

In this way, the attribute can be transmitted in segments according
to the reaming space of the responding buffer.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-18 11:57:23 +02:00
Emil Gydesen
f3a0e276a0 tests: Bluetooth: CAP: Test return early for unicast_group_foreach_stream
Add test that ensures that bt_cap_unicast_group_foreach_stream terminates
correctly if the callback returns true.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-16 10:20:18 +02:00
Emil Gydesen
dd3aa38f2f tests: Bluetooth: BAP: Unittest bt_bap_broadcast_source_foreach_stream
Adds unittests for bt_bap_broadcast_source_foreach_stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-16 10:20:10 +02:00
Vinayak Kariappa Chettimada
72dac165d8 Bluetooth: Controller: Use OVERHEAD_XTAL_US from devicetree
Use the external crystal high frequency clock settling value
from devicetree.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-15 15:34:00 +02:00
Emil Gydesen
3eb4d79aeb tests: Bluetooth: CAP: Add verification of CAP unicast start callbacks
Add verification of the CAP Unicast Audio Start callback parameters.
There was a missing part in the BAP Unicast Client mock that did not
set the ISO state correctly, which caused the procedures to fail, but
without the verification that was not caught.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-15 10:10:02 +03:00
Lyle Zhu
3a46e25582 Bluetooth: Classic: Shell: Add connectionless command set
Add connectionless shell commands, `register`, `unregister`, and
`send`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-14 10:39:54 +03:00
Jori Rintahaka
0f89b4ab87 tests: bluetooth: tester: add filter list flag to start discovery
Implement Start Discovery command Accept Filter List filtering.
Add a flag to the command's flags field to enable filtering.

Signed-off-by: Jori Rintahaka <jori.rintahaka@silabs.com>
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-08-13 14:33:40 +03:00
Johan Hedberg
811cd87734 tests: Don't use deprecated BT_CTLR Kconfig option
The new option is HAS_BT_CTLR, however since it's a promptless option,
disable the native link layer instead, which most likely was the intended
effect.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-08-12 18:40:20 -04:00
Emil Gydesen
965bcd6312 Bluetooth: CAP: Implement unicast to broadcast handover
Implement the unicast to broadcast handover procedure,
as per the Bluetooth CAP specificiation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-12 12:35:57 +02:00
Lyle Zhu
ccad303d50 Bluetooth: shell: Add OBEX commands for GOEP
Add commands for GOEP to test OBEX features.

Add command `alloc-buf` and `release-buf` to allocate and release TX
buffer.

Add command set `add-header` to add the OBEX headers to allocated TX
buffer.

Add command set `client` to send OBEX client requests with allocated
TX buffer.

Add command set `server` to send OBEX responses with allocated TX
buffer.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-08 10:43:07 -05:00
Lyle Zhu
8d1b3e9111 Bluetooth: shell: Add transport commands for GOEP
Add commands for GOEP to test transport features.

Add commands for transport over RFCOMM, including `register-rfcomm`,
`connect-rfcomm`, and `disconnect-rfcomm`.

Add commands for transport over L2CAP, including `register-l2cap`,
`connect-l2cap`, and `disconnect-l2cap`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-08 10:43:07 -05:00
Johann Fischer
f63a2b70aa tests: bluetooth: shell: remove test bluetooth.shell.cdc_acm
The default integration platform for all test cases is native_sim, but
there has never been a USB device controller available for native_sim
platform. Since legacy device support has been deprecated and all tests
and samples now use the usbd test feature tag, this test cannot be
performed on native_sim.

Remove bluetooth.shell.cdc_acm to resolve CI failures.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-08-07 13:14:08 +02:00
Johann Fischer
891e700ce8 tests: bluetooth: use new USB device stack
Use new USB device stack.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-08-06 11:57:39 -04:00