Commit graph

71 commits

Author SHA1 Message Date
Emil Gydesen 85bb2624bc Bluetooth: Audio: Refactor codec_cfg_get_freq
Refactor the codec_cfg_get_freq function to return the assigned
numbers value, instead of a converted value, but with
support for converting the value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 14:05:18 +02:00
Emil Gydesen 4ab658be42 tests: Bluetooth: Add inval testing of bt_bap_broadcast_source_reconfigure
Add invalid parameter and state testing of
bt_bap_broadcast_source_reconfigure

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 13:14:49 +02:00
Emil Gydesen a5384bbf1a tests: Bluetooth: BAP: Initial Broadcast reconfigure test
Add a simple initial test for the reconfigure unittest.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-27 15:44:02 +02:00
Emil Gydesen 63badb0fa7 tests: Bluetooth: Audio: bt_audio_codec_cap_get unit tests
Add unit tests for the bt_audio_codec_cap_get* functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-25 09:48:47 +02:00
Emil Gydesen 7d65c55a50 tests: Bluetooth: BAP broadcast source param name fix
The test fixture used an invalid struct for the param
due to a renaming of the struct in another commit.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-21 11:52:39 +02:00
Emil Gydesen 6472054976 tests: Bluetooth: Audio: Codec meta_get unit tests
Add unit tests for the bt_audio_codec_meta_get_* functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:21:24 +01:00
Emil Gydesen c3c83c7049 Bluetooth: ASCS: Modify the ACL disconnect behavior
Instead of calling ase_release for each ASE in the ACL
disconnected callback, we now call the state_transition_work_handler
directly. This is to ensure that when the disconnected callback
returns, the bt_conn object has been properly unref'ed in
a timely manner.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:20:27 +01:00
Emil Gydesen ddf4504bce tests: Bluetooth: Add inval test of bt_bap_broadcast_source_start
Add tests to test invalid parameters to bt_bap_broadcast_source_start.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:17:34 +01:00
Emil Gydesen 830aa5f7da tests: Bluetooth: Add initial BAP Broadcast Source unit tests
Adds initial BAP Broadcast Source unit tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-11 11:06:52 +02:00
Mariusz Skamra 9a9855f711 tests: Bluetooth: audio: Unit test bt_audio_codec_cfg_get_* helpers
This adds unit tests for bt_audio_codec_cfg_get_* functio helpers.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-05 10:06:09 +02:00
Carles Cufi 8c748fd005 kernel: Modify the signature of k_mem_slab_free()
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.

The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);

has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);

The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.

All in-tree uses of the function have been adapted.

Fixes #61888.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-09-03 18:20:59 -04:00
Mariusz Skamra 17b9d11a35 tests: Bluetooth: ascs: Fix compilation warning
This fixes implicit declaration of function
‘bt_bap_unicast_server_disable’ compilation warning.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-30 17:48:52 +02:00
Mariusz Skamra d11bc6edb4 tests: Bluetooth: ascs: Fix linker warning
This fixes linker warning caused by invalid bonding of linker scripts
provided by multiple "-T" options.

mock-sections.ld contains output sections did you forget -T

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-30 17:48:52 +02:00
Emil Gydesen 6ccd112c56 Bluetooth: Audio: Refactor bt_audio_codec_cfg to flat arrays
Refactor the bt_audio_codec_cfg to use flat arrays to store
metadata and codec specific configurations.

The purpose of this is to make it easier to copy the data
between layers, but also to support non-LTV data for non-LC3
codec configurations.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-28 15:56:53 +02:00
Mariusz Skamra 02f399dc1d tests: Bluetooth: ascs: Add prohibited audio context metadata test
This adds for receiving and handling Enable operation with
prohibited audio context value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-22 09:59:53 +02:00
Mariusz Skamra 914dc408fd tests: Bluetooth: ascs: Fix improperly formatted metadata
This fixes improperly formatted metadata. The Stream Context value is 2
bytes in size.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-22 09:59:53 +02:00
Mariusz Skamra 0d49bb3d70 tests: Bluetooth: ascs: Add CIS connection retry test case
This adds test case testing whether ASE in Enabling state will accept
releated CIS Request if previous CIS establishment procedure failed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-16 20:39:15 +02:00
Mariusz Skamra ade1a4495e tests: Bluetooth: ascs: Add CIS link loss test cases
This adds test cases testing correctness of autonomous ASE
state transitions triggered by CIS link loss.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-16 20:39:15 +02:00
Mariusz Skamra c7476fd7c9 tests: Bluetooth: ascs: Get chan pointer from test_preamble_state_disabling
This adds a possibility to get the ISO channel pointer from
test_preamble_state_disabling function that can be further used in
tests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-16 20:39:15 +02:00
Mariusz Skamra e85a0bc572 tests: Bluetooth: ascs: Extend mock_bt_iso_disconnected with error param
This extends mock_bt_iso_disconnected function parameters with error
code that can provide the HCI error code that is the reason of CIS
disconnection.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-16 20:39:15 +02:00
Emil Gydesen 53502cb417 Bluetooth: Audio: Make codec_cap const
There is no reason why the capabilities
should be modified by the stack after registration,
nor any reason why a the unicast client application
needs to modify the reported remote capabilities, so
all have been marked as const.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-15 11:14:29 +00:00
Emil Gydesen aa990ae6dc Bluetooth: Audio: Refactor bt_audio_codec_cap to flat arrays
Refactor the bt_audio_codec_cap to use flat arrays to store
metadata and codec specific capabilities.

The purpose of this is to make it easier to copy the data
between layers, but also to support non-LTV data for non-LC3
codec capabilities.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-15 11:14:29 +00:00
Emil Gydesen 2390f974af tests: Bluetooth: Update audio mocs for bt_iso_chan_get_tx_sync
bt_iso_chan_get_tx_sync was missing a mock now that it is
being used by bap_stream.c

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Emil Gydesen 8600356f98 Bluetooth: BAP: Add bt_bap_stream_get_tx_sync
Add bt_bap_stream_get_tx_sync to get the ISO tx info from a BAP
stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Mariusz Skamra 9fa4543994 Bluetooth: audio: ascs: Defer ASE state transition
This adds handling of ASE control point operations in separate thread
so that the notifications of ASE state changes are sent from non-BT
thread. This ensures bt_gatt_notify_cb to be blocking waiting for
available buffers to send the notifications.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-18 11:05:03 +00:00
Emil Gydesen 5fa793fa9d Bluetooth: Modify stream_ops->stopped to be called on leaving streaming
When a stream leaves the streaming state the `stopped` callback
will now be called, similar to how the `started` callback works.

This ensures that `stopped` is always called and not just when
the CIS disconnects.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-05 12:34:01 +00:00
Mariusz Skamra 8797e50b64 tests: Bluetooth: ascs: Swap bt_gatt_attr_read mock with real function
This refactors the code to use exact copy of bt_gatt_attr_read instead
of mock, as the implementation might call the function with stack
allocated value. Using mock would require deep copy of the value for
further verification. As the buffer where the value is about to placed
is one of the attr->read() parameters, the test may call the read()
callback with stack allocated buffer of defined size and read the value
from the buffer.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-05 09:14:37 +02:00
Mariusz Skamra 03c04fd8d7 tests: Bluetooth: ascs: Fix build warning
This fixes incompatible pointer type warning.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-04 09:32:00 +02:00
Emil Gydesen 69f7fd9cb2 Bluetooth: Audio: Rename bt_codec to bt_audio_codec_{cap, conf, data}
Rename the bt_codec struct to bt_audio_codec_conf or
to the new struct bt_audio_codec_cap.
Rename the bt_codec_data to bt_audio_codec_data.

The purpose of this is to split the codec specific configuration
and codec capabilities into seperate structs, as they do not
reflect the same values, or used for the same purpose.

This commit depends on the preset macros workings on either
type of struct (for now), but will be modified in future updates.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 12:39:50 +02:00
Mariusz Skamra 91ad386cb5 tests: Bluetooth: ascs: Add ISO Data PDU recv tests
This adds tests for receiving ISO Data PDU.
* test_recv_in_streaming_state - test whether received ISO Data PDU is
  sent to upper layers.
* test_recv_in_enabling_state - test whether received ISO Data PDu is
  dropped because upper layer is not ready to receive the data yet.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:31 +02:00
Carles Cufi 22f73992b2 Bluetooth: Rework the HCI header set
In order to have clean, self-contained HCI headers that do not have any
dependencies towards the Host or any other part of the system (except
types), reorganize the headers in the following way:

- Split out the macros and structs from hci.h to a new hci_types.h
- Merge the existing hci_err.h into the new hci_types.h

Fixes #58214.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-06-12 06:20:24 -04:00
Théo Battrel f5ff886260 Bluetooth: Tests: Remove usage of BT_DEBUG_LOG
Remove usage of Kconfig symbol `CONFIG_BT_DEBUG_LOG` from tests. It has
been deprecated since this PR:
https://github.com/zephyrproject-rtos/zephyr/pull/56183

The Kconfig symbols has been replaced by `CONFIG_LOG=y` on most of the
cases. Or it has been removed when not needed anymore.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-07 13:56:55 -04:00
Emil Gydesen e8ade2356a Bluetooth: BAP: Add unicast client and server write long support
Add support for long writes for the unicast client and server.
This reuses the ATT buffer for long reads.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-26 05:55:15 -04:00
Anas Nashif be5dc33896 tests: bluetooth: ascs: cleanup test metadata
Remove definition of testcases in yaml file, those are now detected from
binary.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-05-25 04:44:11 -04:00
Gerard Marull-Paretas dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
Mariusz Skamra 626e47514e tests: Bluetooth: ascs: Factor out call count verification function
Reduce code duplicates by using common function to verify mock function
call count.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-22 10:16:02 +02:00
Mariusz Skamra a61dd0c950 tests: Bluetooth: ascs: Add test for stream pair release on ACL disc
This adds test case to verify if ACL disconnects, the associated
stream pair is released.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-22 10:16:02 +02:00
Mariusz Skamra 6c6a66711c tests: Bluetooth: ascs: Add test for ASE release on ACL disconnection
This adds test case to verify if ACL disconnects, the associated ASE
is released.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-22 10:16:02 +02:00
Mariusz Skamra df5317a6f0 tests: Bluetooth: ascs: Change bap_stream asserts to expectations
Continue test execution even if assumption failed. This won't break the
test execution prematurely and allow to perform a cleanup.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-22 10:16:02 +02:00
Emil Gydesen 89bcb874db tests: Bluetooth: Add missing ASCS mocks
Add mocks for k_sem_take, k_sem_give and bt_gatt_get_mtu

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-05-12 15:29:17 +02:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Mariusz Skamra 229d049d4d tests: Bluetooth: ascs: Add sink/source ASE only test variants
This adds tests to test Sink/Source only build configurations.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-03 15:11:27 +02:00
Mariusz Skamra 49b6684dbb tests: Bluetooth: ascs: Add invalid ASE state transition tests
This verifies whether implementation rejects invalid ASE Operation
in given state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-03 15:11:27 +02:00
Mariusz Skamra 748b062c15 tests: Bluetooth: ascs: Fix missing bt_bap_stream_start call
Calling bt_bap_stream_start moves the ASE to streaming state.
If the function is not called the Sink ASE stays in enabling state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-05-03 15:11:27 +02:00
Mariusz Skamra d6405cf999 tests: Bluetooth: ascs: Add multiple parameters test cases
This adds 2 new test cases that test whether arrayed parameters are
handled properly.
This improves the existing test_codec_configure_invalid_ase_id_unavailable
test case by handling request conatining 2 ASE_ID's where the 1st is
invalid.
This reproduces the issue fixed in
419772db94238debe114dfac337f5b238a15436e.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-25 12:21:23 +02:00
Mariusz Skamra d47120fad4 tests: Bluetooth: ascs: Remove unused variables
This removes unused variables from test functions.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 13:01:42 +02:00
Mariusz Skamra 280aff80bb tests: Bluetooth: ascs: Add ASE Control Point invalid len tests
This adds tests that validate the implementation handles invalid length
Control Point operations.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 13:01:42 +02:00
Mariusz Skamra 413f5c5d32 tests: Bluetooth: ascs: Factor out ASE control parameters validation tests
Move the tests to separate source file.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-21 13:01:42 +02:00
Mariusz Skamra 6c1363e34d tests: Bluetooth: ascs: Add server initiated ASE state transition tests
This adds tests for server initiated ASE Operations for Sink and Source
ASE.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-20 10:52:42 +02:00
Mariusz Skamra 2234b16893 tests: Bluetooth: ascs: Add Source ASE state transition tests
This adds source ASE state transition tests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-04-12 13:05:20 +02:00