When a synchronous API is used, the content of `buf` will not be
valid by the time the thread that called the synchronous API is woken up
again.
Therefore, the simplest way to solve this is when a user allocates the
buffer which will be filled up with the content of the buffer passed to
the model callback.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The initial implementation of RPL check for Subnet Bridge wasn't fully
correct. It decides whether to relay or not a PDU based on RPL of only
received messages. However, the spec section 3.9.8 says:
```
In addition, a Subnet Bridge node shall implement replay protection for
all Access and Transport Control messages that are sent to bridged
subnets.
A Subnet Bridge node shall maintain the most recent IVISeq value for
each source address authorized to send messages to bridged subnets.
Messages received by the Subnet Bridge node with the IVISeq value less
than or equal to the last stored value from that source address shall
be discarded immediately upon reception. When a message is retransmitted
to a bridged subnet, the stored IVISeq value shall be updated. In this
way, bridged subnets are protected against replay attacks from other
subnets.
```
This was noticed with MESH/NODE/SBR/NET/BV-02-C test. It passes when
PTS misses the message at step 3 and 4, and fails when PTS manages to
receive the message.
This commit fixes the wrong behavior by removing argument for
`bt_mesh_rpl_check` function making store a new message and bypassing
`local_match` check in case of Subnet Bridge node.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Though nvs backend checks whether the data passed to it is identical to
the stored one, this isn't guaranteed by other the settings api. We can
also avoid going into the settings subsystem since we know what was
actually changed.
This commit adds 2 flags that allow to control whether Subnet Bridge
or Bridging Table states were changed and skips storing if the certain
state was not changed.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Added support for the Bridge Configuration client and server
to the tester application.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Adds implementation for the Bridge Configuration Server model.
Updates `brg_cfg` module to add sanity check for
bt_mesh_brg_cfg_tbl_remove() API. Also, updates the unit test
accordingly.
Adds documentation for the Bridge Configuration Server model
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
The `brg_cfg` module implements the states needed for subnet bridge
feature. It provides two states - enable state, and bridging table
state. APIs are provided to access and modify the states. The module
handles responsibility of persistence of the states.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Any places that checked for GTBS is now always enabled
as GTBS is mandatory to support, and the Kconfig option
was removed.
Also removed a duplicate Kconfig option for TBS,
BT_TBS_SERVICE_COUNT, as it was unused.
The other Kconfig option BT_TBS_BEARER_COUNT is used
instead exclusively to set it if needed.
Since GTBS can now exist alone, it must also
support having its own calls and other values.
This means that the GTBS and TBS instances now share
the same underlying struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use a new file and command for this where all CS commands
can live.
Added support for bt_cs_set_default_settings command.
Added test case where shell is built with CS to ensure code
is built in CI.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
The unit tests needed to enable the hidden Kconfig
BT_BAP_BASE. Instead of adding an additional Kconfig for this,
just enable one of the roles that enable it.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There were a couple of controller tests outside the
controller directory which have been moved there to
simplify the structure a bit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added option to set the ASE count through the bap API, making ASE
configuration runtime available. The upper limit of ASEs are still
bound by the Kconfig options set for ASEs.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
Move the network buffer header file from zephyr/net/buf.h to
zephyr/net_buf.h as the implementation now lives outside of the networking
subsystem.
Add (deprecated) zephyr/net/buf.h header to maintain compatibility with old
file path.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
Move the net_buf implementation from the networking subsystem to a library
as they have no dependency on the networking subsystem.
Network buffers are used in subsystems outside of networking
(e.g. Bluetooth, USB).
Fixes: #36374
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
The TBS client callbacks are just informative so we
provide the information to multiple listeners.
To support this for the long strings, the function
handle_string_long_read was refactored.
This also allows for multiple users of the TBS client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CAP commander used bt_audio_valid_ltv which required
BT_BAP_STREAM to be enabled, but the CAP Commander does not
need BT_BAP_STREAM to be enabled.
Moved the function to audio.c which is always compiled for
the CAP Commander, thus removing the requirement for
BT_BAP_STREAM and the accompanying bt_bap_stream.c file.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When calling bt_cap_initiator_unicast_audio_start on a set of streams
that are all in the streaming state we return early with -EALREADY.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The unicast_start procedure should take a stream in any state
and put it in the streaming state. Adds tests with streams
in various states.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added volume offset for CAP commander
Added gain settings for CAP commander
Added play, pause and seeking for MCS
Added program_info and metadata update for PBP
Added long read and notify for all TBS characteristics
Added TMAP CG
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since testing.c/h was moved to mesh, all functions and
structs in those files now follow a bt_mesh_test_*
naming scheme to be consistent with the naming in Zephyr.
Due to missing includes in many files, this commit also
added some that were missing in order to build since
the order of includes have changed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The file is only ever used by mesh and it is even stated in the
header of the file that it is internal APIs.
The include file has been merged with the host testing.h file
as that was mesh specific as well. Similarly the testing.c
file was also moved
This is part of a process to clean up the file structure of
Bluetooth as it's a bit messy, which is evident from the
MAINTAINERS.yml file.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
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>