One of the tests is purposedly overwriting the stream pointer to NULL.
Which means it is lost and can't be free'd.
To avoid a memory leak warning, let's make sure we free it at the end
of each test by keeping the cap_streams ptr in the fixture.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Apply the U suffix to unsigned integer literal constants used in
contexts involving unsigned types (uint8_t, uint16_t, uint32_t,
uint64_t, size_t, etc.) with coding guideline 40 which requires that
"A u or U suffix shall be applied to all integer constants that are
represented in an unsigned type".
In addition to this requirement, this commit also ads U to any unsigned
literal integer for the sake of completeness.
Changes are limited to literal values in assignments, initializations,
comparisons, and for-loop bounds where the context is unambiguously
unsigned.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The characteristic name and definitions in the TBS spec for
the values are "optional opcodes" instead of "support features".
Additionally, the field is 16-bit, instead of the current 8-bit
in the register parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add missing error checks for any function calls in the
affected files, as that is required by the Zephyr coding guidelines.
Assisted-by: Copilot:claude-sonnet-4.6
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The provided name `inval_bearer_name` were not correctly set
as too long as it was not properly NULL terminated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Apply ARG_UNUSED() to unused function arguments as per the Zephyr
coding guidelines
Assisted-by: GitHub Copilot
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The technology values defined in tbs.h are actually defined
in assigned numbers under the HFP. They have been moved to
the assigned_numbers.h file, and name to match the placement
in Assigned Numbers. They have been defined in an enum instead
of multiple #define's, to more easily refer to them.
The callback for reading technology was likewise updated to use
the new enum.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add checks to verify the valid length of broadcast names
in codec_cfg and codec_cap, both in terms of size in octets,
but also in terms of length in characters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add checks to verify the valid length of broadcast names
in codec_cfg and codec_cap, both in terms of size in octets,
but also in terms of length in characters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
MISRA-C requires essentially boolean types in control flow.
Convert all if/while conditions using err or ret
as implicit booleans to explicit comparisons:
- if (err) -> if (err != 0)
- Same rules applied to while statements and ret variable
Also fix typos found during review:
- Fix "Failed to ser security level" -> "Failed to set security
level" in pacs_notify_client_test.c (4 places) and
csip_notify_client_test.c (2 places)
- Fix "Bluetoot" -> "Bluetooth" typo in media_controller_test.c
- Fix format/argument mismatch in bap_scan_delegator_test.c:
add missing `i` argument to FAIL() call
Assisted-by: GitHub Copilot
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make the qos parameter of the BAP can CAP APIs const,
as they are now only used as one-time parameters, and not stored.
This also means that any uses of this can place the qos
parameter in the stack, rather than static memory.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixed issue where an aborted CAP commander procedure would
never get past bt_cap_common_proc_all_handled and thus never
call the callback with an error, e.g. if the remote CAP
Acceptor rejects a request.
The fix required a significant refactor of the broadcast
part of the CAP commander, as it was fundamentally flawed.
The biggest change is that the implementation now uses both
the receive state notification as well as the write responses
to determine completeneess. Additionally, it also handles
notifications not initiated from our write requests, i.e.
it is now more similar to an event based procedure rather
than a linear one. This also means that when the callbacks
for the start and stop procedures are now called, we have
receive the events (notifications) from the remote CAP
acceptors that they are actually synced (or not synced) to
the broadcasts.
Since the broadcast reception start and stop now waits
for the receive state to be updated, a change in the
Handover implementation was also done.
To test the solution 2 new test cases were added,
and the existing tests were modified to allow for the
new expected behavior.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make the codec_cfg parameter of the BAP can CAP APIs const,
as they are now only used as one-time parameters, and not stored.
This also means that any uses of this can place the codec_cfg
parameter in the stack, rather than static memory.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The pointer represent the codec configuration
for a stream based on the ASE or broadcast configuration,
and serves as a read-only value. Changing it to `const` makes
this more clear.
Some minor changes were done to existing code to help
support this change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify foreach functions in LE Audio to follow the same pattern:
Return true to continue iterating.
Return false to stop iterating.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_uuid_from_str() uses hex2bin() from lib/utils/hex.c and
uuid_from_string() from lib/uuid/uuid.c. Add both dependencies
to each test CMakeLists.txt that compiles
subsys/bluetooth/host/uuid.c, fixing link failures on the
unit_testing platform.
Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
Modify bt_ccp_call_control_server_get_bearer_uci to
store the bearer UCI in an output buffer, instead of just
providing the pointer.
The reason for this is to make the result thread safe, and
avoid the user/application having a direct pointer to
internal storage.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Several places used CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH
instead of
CONFIG_BT_CCP_CALL_CONTROL_SERVER_PROVIDER_NAME_MAX_LENGTH.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify bt_ccp_call_control_server_get_bearer_provider_name to
store the bearer provider name in an output buffer, instead of just
providing the pointer.
The reason for this is to make the result thread safe, and
avoid the user/application having a direct pointer to
internal storage.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
After the switch to the native_sim board instead of
the unit_testing board, we no longer need or use these
mocks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add check in valid_unicast_audio_start_param to verify
that the ep connection matches the member_conn.
Instead of declaring the endpoints in the unit tests, we
not define them in the mock unicast client and use the
discover function to get pointers.
This allows for a proper implementation of
bt_bap_unicast_client_has_ep as well as makes the tests more similar
to a normal application.
This change required a significant change in the unicast_stop
unit tests as well, which uncovered a small bug in the implementation.
The bug was fixed as part of this commit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a user_data field to bt_ccp_call_control_client_cb. The
field is optional to enable via Kconfig. The field can be used
to provide additional context from the owner of the callback
structure, to the callbacks themselves.
This solves a memory use-after-free issue in the unit tests
where the values from the callback was accessed after they
were released, as the values were just stack allocated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When this test is built with CONFIG_NO_OPTIMIZATIONS (which is the case
when building with CONFIG_COVERAGE) or when building with debug logging,
it fails to link due to lacking bt_uuid_str().
Let's include the corresponding file so it can link.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add a dependency for UTF8 for LE Audio. Since (nearly?) all
string in LE Audio are UTF8 and that the stack wants to be
able to check and validate strings coming both from remove
deviecs and from the application, it will depend on the utf8
API that is guarded by CONFIG_UTF8.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for getting the UCI.
For now the UCI will be duplicated by the TBS
implementation, but will be optimizied in the future
so only one copy of the UCI exists.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The existing ASCS test callback verification functions scale poorly and are
not easily reusable across different cases.
This change introduces a more generic approach to expectation checks by
adding `expect_bt_bap_unicast_server_cb_release_called(_expected_count,
_streams)` and similar functions, improving readability and maintainability
of ASCS unit tests.
Fixes#58034
Signed-off-by: Dima Kushchevskyi <d.kushchevskyi@sirinsoftware.com>
Fix build issues,
- error: format %x expects argument of type
unsigned int, but argument 7 has type ssize_t
{aka long int} [-Werror=format=]
zassert_false(ret < 0, "attr->read returned unexpected (err 0x%02x)"
, BT_GATT_ERR(ret));
Signed-off-by: Biwen Li <biwen.li@nxp.com>
Remove duplicated #include directives within the same
preprocessor scope across the Zephyr tree.
Duplicates inside different #ifdef branches are preserved
as they may be intentional.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
To support mocking we cannot rely on the default
Kconfig options and values. The required Kconfig options
to satisfy dependencies are overridden in the Kconfig
file and the necessary Kconfig files are sourced.
We cannot enable e.g. CONFIG_BT as that would attempt
to pull in a lot of files we do not want in this test.
This commit also removes unused includes in the CMakelists
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
To support mocking we cannot rely on the default
Kconfig options and values. The required Kconfig options
to satisfy dependencies are overridden in the Kconfig
file and the necessary Kconfig files are sourced.
We cannot enable e.g. CONFIG_BT as that would attempt
to pull in a lot of files we do not want in this test.
This commit also removes unused includes in the CMakelists
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
To support mocking we cannot rely on the default
Kconfig options and values. The required Kconfig options
to satisfy dependencies are overridden in the Kconfig
file and the necessary Kconfig files are sourced.
We cannot enable e.g. CONFIG_BT as that would attempt
to pull in a lot of files we do not want in this test.
This commit also removes unused includes in the CMakelists
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
To support mocking we cannot rely on the default
Kconfig options and values. The required Kconfig options
to satisfy dependencies are overridden in the Kconfig
file and the necessary Kconfig files are sourced.
We cannot enable e.g. CONFIG_BT as that would attempt
to pull in a lot of files we do not want in this test.
This commit also removes unused includes in the CMakelists,
and cleans up the code.
Since the kernel is actually running, we also need to support
that e.g. k_work items are actually scheduled, and that we have
to wait for them to finish. test_drain_syswq has been implemented
as a way to drain the system workqueue before we check for
callbacks or perform subsequent actions.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
To support mocking we cannot rely on the default
Kconfig options and values. The required Kconfig options
to satisfy dependencies are overridden in the Kconfig
file and the necessary Kconfig files are sourced.
We cannot enable e.g. CONFIG_BT as that would attempt
to pull in a lot of files we do not want in this test.
This commit also removes unused includes in the CMakelists,
and moves the mock bap_broadcast_source.c file to the
correct location.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Some of the CAP initiator unit tests did not delete the group
after creation, even if they easily could.
Especially for test_initiator_unicast_group_add_streams it was
a problem, as the stream added was stack allocated, and by the
end of the test it was deallocated, causing issues when the
group was finally deleted in
cap_initiator_test_unicast_group_after.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
To support mocking we cannot rely on the default
Kconfig options and values. The required Kconfig options
to satisfy dependencies are overridden in the Kconfig
file and the necessary Kconfig files are sourced.
We cannot enable e.g. CONFIG_BT as that would attempt
to pull in a lot of files we do not want in this test.
This commit also removes unused includes in the CMakelists
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since Shorter Connection Intervals changes the unit that connection
intervals can be represented in. It is necessary to change how
they are stored and represented.
This commit deprecates interval in favour of interval_us.
Remove use of interval in internal bt_conn struct since it is no longer
needed.
Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.
This commit also removes unused includes in the CMakelists.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
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>
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>