Adds unittests for the CAP Initiator start procedure, simply
verifying that the procedure works as well as
testing invalid parameters.
This also allows us to remove the invalid behavior checks
from the babblesim test implementation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Very very weird behavior.
Deleting the `options & BT_LE_ADV_OPT_USE_NRPA` branch in
`id.c:bt_id_set_adv_own_addr` makes the test pass. But add a log in that
branch, and you'll see that we never take it in the UT binary..
I don't have time for this, maybe some compiler guru or C language
lawyer can look at that decompiled function and figure out the root
cause.
Someone should also really fix the Bluetooth unit tests and make them
run on any Bluetooth related PR. Also nightly.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
When running on native_posix, the thread needs to be created
before the thread name can be set.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The tests manually include sources that are normally conditionally
included (ie based on kconfig values) in the stack.
The tests should be fixed by the original authors.
For now, force-on the hidden kconfig that enables the log options.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
There was hardcoded value for user_data which is no longer valid.
Use proper CONFIG_BT_CONN_TX_USER_DATA_SIZE for that.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Unfortunatelly new Qualification Workspace is not able to properly import
ICS if file is UNIX line endings.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
To make the scanner module more understandable and more streamlined, I
reworked the update mechanism of the scanner. The scanner tracks now the
parameters that were used to enable it and the reason why it is running.
This facilitates state logic and allows other modules to "start the
scanner", altough it is already running.
This is mostly a refactoring and not a functional change.
Added a test to verify the behavior.
Signed-off-by: Jan Müller <jan.mueller@nordicsemi.no>
add to task
Add conn parameter to status/flags callbacks of bt_vcp_vol_rend_cb
to differentiate between remote and local changes.
Signed-off-by: Chang An <chang.an_1@nxp.com>
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Path loss monitoring was not being enabled anywhere, meaning
that issues could be merged in without catching the issue.
This commit adds a test case to build the shell with path
loss monitoring enabled to catch issues.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
A few tests were only allowed for native_posix, but we are
deprecating it. Let's switch them to native_sim instead.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Convert users of net_buf_put() and net_buf_get() functions to use
non-wrapped putters and getters k_fifo_put() and k_fifo_get().
Special handling of net_bufs in k_fifos is no longer needed after commit
3d306c181f, since these actions are now
atomic regardless of any net_buf fragments.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
[Description]
Device hang is observed when LE Scan
[Root Cause]
For le_ext_adv_report, Data[i] of one adv report is 0-229,
for the adv_buf of saving, it just is 73 bytes, so sometimes
the bytes of adv report is more than the adv_buf, resulted hang
[Fix]
consider the le ext adv case.
[Testing]
After modified, Device hang is not observed after stress
testing with LE Scan
Signed-off-by: Guotao Zhang <guotao.zhang@nxp.com>
Setting SOURCES before calling find_package() was deprecated in #51049.
Cleanup usage of SOURCES and instead use the proper target_sources()
CMake function.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fixes: #73831
find_package(Zephyr) should be called before first project() call.
Zephyr package will test and force-set the correct toolchain, especially
the C compiler.
The project() will also set the C compiler, if not set already.
If project() is called first, then conflict arises on the C compiler
selection and thus the following message is seen:
> You have changed variables that require your cache to be deleted.
> Configure will be re-run and you may have to reset some variables.
> The following variables have changed:
> CMAKE_C_COMPILER= /usr/bin/gcc
This cache deletion results in other errors, such as a missing BOARD
setting.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Add commands to allow requesting a subrate change via the BT shell.
A new build configuration has been added to ensure this is tested in CI.
Signed-off-by: Aleksandar Stanoev <aleksandar.stanoev@nordicsemi.no>
The .bls files are no longer useful after the BT SIG switched
qualification tool. This will still remain in the git history
and can safely be removed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The test expects this feature to be enabled.
We should therefore enable explicitly instead of relying on
default values.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
When developing Bluetooth applications, you typically run into
some errors. If you are an experienced Bluetooth developer,
you would typically have an HCI error lookup table in your memory.
Others might not.
This commit utilizes defines CONFIG_BT_DEBUG_HCI_ERR_TO_STR
and utilizes bt_hci_err_to_str() to print out HCI error strings
when enabled to improve the user experience.
Several alternatives where considered. This approach was chosen
as it had the best balance between readability, code size, and
implementation complexity.
The alternatives are listed below as a reference.
1. Macro defined format specifier:
```c
#define HCI_ERR_FMT "%s"
#define BT_HCI_ERR_TO_STR(err) (err)
#define HCI_ERR_FMT "%d"
#define BT_HCI_ERR_TO_STR(err) bt_hci_err_to_str((err))
LOG_INF("The event contained " HCI_ERR_FMT " as status",
BT_HCI_ERR_TO_STR(err));
```
Advantage: Space efficient: Code size does not increase
Disadvantage: Code becomes hard to read
2. Format specifier to always include both integer and string:
```c
static inline const char bt_hci_err_to_str(err)
{
return "";
}
LOG_INF("The event contained %s(0x%02x) as status",
bt_hci_err_to_str(err), err);
```
Advantage: Simple to use, implement, and read,
Disadvantage: Increases code size when CONFIG_BT_DEBUG_HCI_ERR_TO_STR
is disabled. The compiler seems unable to optimize away the unused
format specifier. Note: The size increase is only present when
logging is enabled.
3. Always print as string, allocate a stack variable when printing:
```c
const char *bt_hci_err_to_str(char *dst, size_t dst_size, uint8_t err)
{
snprintf(dst, dst_size, 0x%02x, err);
return dst;
}
LOG_INF("The event contained %s as status", BT_HCI_ERR_TO_STR(err));
```
Advantage: Very easy to read.
Disadvantage: Printing error codes becomes slow as it involves calling
snprint.
4. Implement a custom printf specifier, for example E.
This requires a global CONFIG_ERR_AS_STR as I assume we cannot have
one specifier for each type of error code.
Also, I assume we cannot start adding specifiers for each subsystem.
```c
#define BT_HCI_ERR_TO_STR(err) (err)
#define BT_HCI_ERR_TO_STR(err) bt_hci_err_to_str((err))
LOG_INF("The event contained %E as status", BT_HCI_ERR_TO_STR(err));
```
Advantage: Both efficient code and readable code.
Disadvantage: This requires a global CONFIG_ERR_AS_STR as I assume
we cannot have one specifier for each type of error code.
Also, I assume we cannot start adding specifiers for each subsystem.
That is, this approach is hard to implement correctly in a scalable
way.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
For the LE Audio unittests there exists a few mock files
that implement mock versions, or callbacks, for some of the
roles and features tested.
These have been moved to where they are actually used,
reducing the scope of these files.
This both allows the individual tests to implement their own
versions of it, but more importantly it prevents issues when
adding tests for these roles. For example, due to the
bap_unicast_client.c mock file, it is impossible to implement
unit tests for the unicast client, as the functions are already
defined.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Zero length arrays are only allowed at the end of the structure. Here
those were used as placeholders for BTP response creation and can be
easily replaced with common member.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Enable sysbuild for nRF5340 app core.
This automatically builds the image for the network core, making a
better user experience.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Refactors teh BIS bitfield values used for ISO
and BAP.
Previously BIT(1) meant BIS index 1, which was a Zephyr choice
in the early days of ISO, as the BT Core spec did not use
a bitfield for BIS indexes.
Later the BASS specification came along and defined that
BIT(0) meant BIS index 1, which meant that we had to shift BIS
bitfields between BAP and ISO.
This commit refactors the ISO layer to use BIT(0) for Index 1 now,
which means that there is no longer a need for conversion
between the BAP and ISO layers, and that we can use a value
range defined by a BT Core spec (BASS).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the application is not explicitly scanning, then there is not
really any need to parse advertising reports nor send them to the
application.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
It was pointed out in a future PR that they should have
a corresponding experimental Kconfig entry.
See PR #73795.
This updates the APIs added in PR #73826 and PR #74295.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Profile names MBT and DFU are updated as MBTM and DFUM respectively,
according to TCRL 2024-1.
Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
Following changes in HCI drivers
(https://github.com/zephyrproject-rtos/zephyr/pull/72323) the build for
the snippet allowing to have the Bluetooth shell run with BabbleSim was
broken.
Fix the snippet by disabling the HCI UART driver.
Add a twister test case that will build the snippet in CI to avoid
silent breaking.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
With new BT SIG Qualification Workspace it is no longer possible to
export/import full project. Only ICS export/import is possible.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The bug should be fixed now, so it possible to have it enabled as
long as OTS is not registered with the feature flag.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add validation of the number of ASEs in control point
write requests.
This validates that the number of ASEs
in the control point is not greater than the total number
of ASEs we support.
This also validates that the GATT MTU is large enough to
hold all the responses from the write since those can only be
sent as notifications and never be truncated.
Finally this validates and updates the size of the buffer used to
hold the responses, which may be an optimization for some builds.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The macro was changed to return a const pointer, but the
BTP use the returned pointer in a non-const way.
Modify the usage so that the macro is used to initialize
the adv_param instead, and then provide a non-const pointer
to tester_gap_create_adv_instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
`checkpatch.pl` requires that dts sources are indented with tabs,
fix all the spaces that slipped in while checkpatch wasn't watching.
Signed-off-by: Jordan Yates <jordan@embeint.com>
This can be useful if application developers
want to print them in the applications.
Later we can also use them in
the host to improve debuggability.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The function reuses the ATT implementation.
To make the function simpler to use, the function handles both positive
and negative values.
Unfortunately the APIs do not document if the API returns an
errno val or a GATT return value.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This API converts a SMP error code to a string.
This can be useful if application developers want
to print them in the applications.
BT_SMP_ERR_SUCCESS was added for completeness.
Later we can also use them in the host to improve debuggability.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This can be useful if application developers
want to print them in the applications.
Later we can also use them in
the host to improve debuggability.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
`CONFIG_BT_DEBUG_LOG` has been deprecated for more than 2
releases, replace it with `CONFIG_BT` + `CONFIG_LOG`:
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Added check if ccc_values[i].attr != NULL,
before accessing to ccc_values[i].attr structure:
(handle == ccc_values[i].attr->handle)
On 20829 platform it's causing hard fault, not sure about
another platforms (in GAP testing).
Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
This API converts a HCI error code to a string.
This can be useful if application developers want to print them
in the applications.
Later we can also use them in the host to improve debuggability.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>