Commit graph

8508 commits

Author SHA1 Message Date
Pavel Vasilyev
83b7513937 Bluetooth: Mesh: Move beacons Kconfiguration under separate submenu
Collect beacons Kconfiguration under own submenu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
bb75d1f813 Bluetooth: Mesh: Move Solicitation Kconfig options
Move Solicitation Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
343fa6d044 Bluetooth: Mesh: Move OdProxy models Kconfig options
Move OdProxy models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
168af2324d Bluetooth: Mesh: Move PRB models Kconfig options
Move PRB models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
84febe83a9 Bluetooth: Mesh: Move LCD models Kconfig options
Move LCD models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
5156f78386 Bluetooth: Mesh: Move OpAgg models Kconfig options
Move OpAgg models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
5b0a1bb165 Bluetooth: Mesh: Move SAR models Kconfig options
Move SAR models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
f89effbe75 Bluetooth: Mesh: Move RPR models Kconfig options
Move RPR models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
c2299e2120 Bluetooth: Mesh: Move DFU models Kconfig options
Move DFU models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
11986a29d8 Bluetooth: Mesh: Move MBT models Kconfig options
Move MBT models Kconfig options under the models menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
dcdbb4bceb Bluetooth: Mesh: Move CDP 1.1 Kconfig options
Move CDP 1.1 Kconfig options to the access layer menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
b94b9c7759 Bluetooth: Mesh: Move provisioning 1.1 Kconfig options
Move provisioning 1.1 Kconfig options to the provisioning menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
6060dfbc7f Bluetooth: Mesh: Move mesh-1.1 transport sar configuration
Move mesh 1.1 transport sar configuration under transport menu

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Pavel Vasilyev
981c79b7ce Bluetooth: Mesh: Drop explicit support for Bluetooth Mesh 1.0.1
Bluetooth Mesh Protocol 1.1 is backward compatible with Bluetooth Mesh
Profile 1.0.1, therefore the stack can still be qualified for 1.0.1 if
needed. But explicit support for both versions requires additional
maintenance efforts and doubles the CI time. To make the stack
qualifiable for 1.0.1, the one needs to remove Private Beacons reception
and compile out SHA256 algorithm support.

What is changed:
- Removed `CONFIG_BT_MESH_V1d1` option.
- Removed `transport_legacy.c` which was using 1.0.1 implementation. The
  new transport layer has new SaR logic that should still be possible to
  qualify for 1.0.1.
- Removed the legacy transport Kconfig options. They are superseded by
  the new transport Kconfig options.
- Tester app: `overlay-mesh-v1d1.conf` is merged into
  `overlay-mesh.conf`.
- Removed BabbleSim tests for 1.0.1.
- Updated documentation.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-19 12:55:40 +01:00
Emil Gydesen
d26ba10640 Bluetooth: GATT: Add missing busy check for auto discover CCC
When using the auto discover CCC, and the function is called
more than once with the same parameters before the previous
discovery has completed, then that may cause issues when we
reset the parameters when we get the response.

This commit adds a small check for the callback function
which is only set to the specified function when the
discovery is in progress. This way we can return an error
if the application calls bt_gatt_subscribe multiple times
before the previous discovery has completed, rather
than asserting.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-18 20:11:08 +01:00
Pavel Vasilyev
7a41a9d864 Bluetooth: Mesh: Fix processing SegAcks to wrong destination
Do not process SegAcks which were not targeted to the node.

They were rejected in the next if statement always, but generated
the annyoing warning "No matching TX context for ack".

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-18 10:55:24 +01:00
Emil Gydesen
490c5e3b20 Bluetooth: Audio: Shell: CAP change volume command
Add sthe change volume command to the CAP commander shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 12:00:09 -05:00
Emil Gydesen
6e52f384c8 tests: Bluetooth: CAP commander volume_change unit tests
Adds unit tests for the CAP Commander volume_change
procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 12:00:09 -05:00
Emil Gydesen
b09ce2fade Bluetooth: CAP: Commander set volume support
Add support for setting volume on one or more CAP
acceptors using the CAP Commander API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 12:00:09 -05:00
Emil Gydesen
1faa5a2aa2 Bluetooth: BAP: Add support for transparent coding format
Add support for controlling whether the local controller
should transcode, or whether it will be done by another
module (e.g. the host).

By default when using the macros,
controller transcoding will be disabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 11:59:14 -05:00
Emil Gydesen
476e7b3fa3 Bluetooth: Audio: Ensure that read callbacks can handle conn == NULL
The read callbacks may be called with conn == NULL if the device
does a local read of the attributes. This commit ensures that all
the read callbacks can handle the case where conn == NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-17 11:58:44 -05:00
Markus Swarowsky
11175c3ad3 tf-m: Change NS include path for TF-M 2.0.0
The place where TF-M places its non-secure api header files has changed
Therefore changing it for for all applications that use it.

Signed-off-by: Markus Swarowsky <markus.swarowsky@nordicsemi.no>
2024-01-17 16:52:52 +01:00
Morten Priess
056d5a354b Bluetooth: controller: Handle peripheral CIS creation latency
Instead of asserting, handle CIS creation latency for the peripheral by
finding next valid ISO event at which to start the CIG ticker.

Refactored calculations of the cig_offset to separate functions, to be
used also when calculating a new start offset.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-01-17 14:44:34 +01:00
Jonathan Rico
81d524d081 Bluetooth: L2CAP: always send from workqueue
Always pull from the channel queue from the system workqueue context.
This simplifies debugging.

This also allows us to remove `sent` from the metadata struct.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-17 14:42:40 +01:00
Jonathan Rico
2dcb91ab46 Bluetooth: L2CAP: extract LE part of bt_l2cap_chan_send
Separate most of the param checking in `bt_l2cap_chan_send()`, with the
logic in `bt_l2cap_dyn_chan_send()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-17 14:42:40 +01:00
Vinayak Kariappa Chettimada
60c0087555 Bluetooth: Controller: Fix ISO Sync Receiver time reservation calc
Fix missing ISO Synchronized Receiver radio event time
reservation that did not calculate for all the subevents.

Introduce BT_CTLR_SYNC_ISO_RESERVE_MAX Kconfig option to
allow using a minimal time reservation if needed to allow
other role to pre-empt ISO Synchronized Receiver in
pre-transmission and control subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-17 14:42:32 +01:00
Bi Jian
06fa287d45 Bluetooth: Audio: Update audio location definitions
The meaning of bit0 in the audio location bitmap will change to
mono audio, so we update the audio location macro and releated
test cases.

Refer to BT SIG ES-22266.

Signed-off-by: Bi Jian <bi_jian@qq.com>
2024-01-16 14:27:40 -05:00
Emil Gydesen
f4cbf403e8 Bluetooth: BAP: Fix uninitialized variable in source_reconfig
The stream_in_subgroup variable in bt_bap_broadcast_source_reconfig
may have been uninitialized.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:37:28 -06:00
Emil Gydesen
bf37784dea Bluetooth: PACS: Fix logical dead paths
In pac_notify and pac_notify_loc coverity found logical dead
paths since if both sink and source notify was disabled,
the functions would still be compiled, but would
never get past the default case.

This is not a real issue as the functions were never called
in that case, but to make coverity happy, and to prevent
any future issues where the functions may be called
incorrectly, the static functions are now fully guarded.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:35:37 -06:00
Emil Gydesen
9fc630d303 Bluetooth: CSIP: Use bt_crypto_aes_cmac instead of own
Instead of reimplementing the aes_cmac function, CSIP
will now use the bt_crypto_aes_cmac function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:33:58 -06:00
Emil Gydesen
64adf0b065 Bluetooth: BAP: Add log of err in bt_bap_stream_detach
We can't really do anything about it if it fails, so we
simply log the value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:32:22 -06:00
Emil Gydesen
f9c116ec73 Bluetooth: CAP: Shell: Fix channel allocation
The channel allocation was incorrect when setting up multiple
streams to a single device, in which case we should apply
individual bits to each stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 09:31:12 -06:00
Jonathan Rico
38c39af4df Bluetooth: L2CAP: Prepend SDU header immediately
Previously it was not always possible to prepend the header.

It was not possible if the application neglected to reserve the space
for headers.  This is bad because it forces a buffer segment allocation
even if the buffer had enough room for the headers. E.g. a payload of 10
bytes in a netbuf of 30 bytes would have been segmented.

We now explicitly reject the buffer if it does not have the headroom.

This allows us to do a nice thing; simplify L2CAP segmentation.

We convert the SDU from the application into a PDU payload, by
prepending the SDU header, i.e. the SDU length in the original buffer.

This PDU payload is ready to be chunked into PDUs without having to keep
track of where in the SDU we are. This has the effect of removing a
bunch of logic in the segmentation machine.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-01-16 11:29:43 +00:00
Aleksandr Khromykh
4e7d64b1b4 Bluetooth: Mesh: enable access responses randomization
Enable by default the access layer responses random delays.
Commit also adapts all mesh models, samples and
babblesim tests to use random delay functionality correctly.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-01-16 11:29:20 +00:00
Emil Gydesen
68f8c8ff29 Bluetooth: Audio: Fix off-by-one error in codec.c:ltv_set_val
The function did not move data correctly when increasing
or decreasing the size of a value that was not the last value
in the LTV array.

Added a few tests to verify the fix, using the CCID list as the
main way of verifying it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-16 10:00:04 +01:00
Emil Gydesen
400cdcaca4 Bluetooth: BAP: Fix invalid GATT error codes in scan delegator
There was a few places where the scan delegator returned an
errno value instead of a valid GATT error codes when rejecting
write request. These have been modified to send
BT_ATT_ERR_WRITE_REQ_REJECTED to the client instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-15 14:07:15 -05:00
Emil Gydesen
e2b271fbc4 Bluetooth: ASCS: Add additional dbg info in state changes
Add additional debug information in some ASCS debug statements,
so it is easier to follow the state when there is a potentional
state change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-15 13:59:08 -05:00
Piotr Narajowski
13b0052cfa Bluetooth: MPL: Add notification to track change
This adds notifications to do_first_track only when changing group.
Before the change was made, client was never notified about
track change when changing group in Media Player.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
2024-01-15 13:57:21 -05:00
Emil Gydesen
a72da864e0 Bluetooth: BAP: Restrict application ASCS response codes
Some of the ASCS response codes should not be used by the
unicast server, as those will be checked and validated by the
stack.

They are kept in the enum, as the enum is also used by the
unicast client.

Besides updating the documentation, this commit also adds
a function to validate the response codes as well as the
combination of response codes and reason/metadata values,
and log a warning if the application does not adhere to the
documented behavior.

A warning is used instead of an error/assert/modification
of the response codes, as there may be unforseen reasons
why an application provide a non-approved response code,
and since it may be spec-valid, we should not fully
prevent it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-15 13:56:22 -05:00
Emil Gydesen
234b322dc3 Bluetooth: Audio: Fix len check in ltv_set_val
The length check in ltv_set_val did not consider the size of
the length or type fields.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-15 13:55:55 -05:00
Jonathan Rico
75c2aeb8bd Bluetooth: L2CAP: stop stealing buffers from SDU pool
It seems like a nice idea at first, but leads to hard-to-debug
situations for the application.

The previous behavior can be implemented by the app by defining
`alloc_seg` and allocating from the same pool as `buf`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-15 09:58:58 +01:00
Pavel Vasilyev
27b1f4eb7f Bluetooth: Mesh: Fix dereferencing before null pointer check
Don't dereference pointer until it is checked on NULL.

Fixes: #66805
Coverity-CID: 338098

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-12 11:28:59 -06:00
Vinayak Kariappa Chettimada
7f99677aa6 Bluetooth: Controller: Add support for DYNAMIC_INTERRUPTS
Add support for DYNAMIC_INTERRUPTS and ARM specific
DYNAMIC_DIRECT_INTERRUPTS.

Co-authored-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-12 11:16:08 +01:00
Vinayak Kariappa Chettimada
2b30259e9f Bluetooth: Controller: Fix ull_prepare_dequeue for skipped events
Fix ull_prepare_dequeue to not skip events when preempt
does not match the event in the head of the prepare queue.
The head of the prepare queue does not match when
ull_prepare_dequeue has put the head of the queue to the
last of the queue when it is calling lll_resume interface.
This happens when there is already an active event which
needs a preempt timeout to be setup and there is another
non-resume event in the pipeline which now becomes the
head. The fix ensure to restore the order of the events
if a preempt timeout was to be setup.

Currently ull_prepare_dequeue loops through all events
before stopping at the original way the queue was. This is
not efficient and is a scope for improvement in future.

This reverts commit 91781306e9 ("Revert "Bluetooth:
Controller: Fix ull_prepare_dequeue for skipped events"").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-12 10:03:07 +01:00
Emil Gydesen
79af154ae7 tests: bsim: Bluetooth: CAP broadcast AC testing
Add testing of the Audio Configurations from the BAP spec using
the CAP API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-11 16:13:00 +00:00
Jonathan Rico
1e6ff5ff05 Bluetooth: L2CAP: separate BR/EDR and LE internal headers
Extract BR/EDR definitions from `l2cap_internal.c` into its own headers:
one for the interface with l2cap.c and one for the rest of the BR/EDR
stack.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-11 10:04:53 +01:00
Jonathan Rico
19da13313d Bluetooth: L2CAP: remove usage of bt_l2cap_send_cb by BR/EDR
Isolates BR/EDR's l2cap use from LE (most of l2cap.c).

Why? Because I'm refactoring l2cap.c and don't want to accidentally
break BR/EDR support, as there are very few tests in CI.

This way, once `bt_l2cap_chan_send` hands control to l2cap_br.c, it will
not call back into l2cap.c, it will instead be a parallel layer going
directly to conn.c.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-11 10:04:53 +01:00
Daniela Andreea Dumitrache
3bfb2e3ab2 Bluetooth: Audio: Add implementation for PBP and dedicated sample apps.
PBP API allows sources to create a Public Broadcast Announcement.
PBP API to parse a Public Broadcast Announcement.

public_broadcast_source application starts extended advertising and
includes a Public Broadcast Announcement. The advertised broadcast
audio stream quality will cycle between high and standard quality.

public_broadcast_sink application scans for broadcast sources and
synchronizes to the first found source which defines a Public Broadcast
Announcement including a High Quality Public Broadcast Audio Stream
configuration.

Add bsim tests for Public Broadcast Profile APIs.

Add shell implementation for Public Broadcast Profile APIs.

Signed-off-by: Daniela Andreea Dumitrache <danielaandreea.dumitrache@nxp.com>
2024-01-09 09:59:23 +01:00
Håvard Reierstad
6c5fc658ef Bluetooth: Mesh: suspend/resume gatt advs
Disables pb gatt- and gatt proxy advs when suspending Mesh, and
enables them again when resuming Mesh.

Adds `bt_mesh_adv_gatt_send` to `bt_mesh_resume` to make sure that
GATT advs start after resumption.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-01-08 13:21:58 -05:00
Håvard Reierstad
9285ea3238 Bluetooth: Mesh: fix proxy srv return value
Previously, `bt_mesh_proxy_gatt_enable` returned the return value from
`k_work_schedule`, which could be a positive (non-error) message.
Now, it only returns negative error codes (else 0).

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-01-08 13:21:58 -05:00
Piotr Pryga
4d0ef142f3 Bluetooth: services: Add HRS notification changed app callback
It is useful for an application to be informed when there is
a subscriber waiting for HRS service notification.
Extend HRS service API and add required code to service implementation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2024-01-08 15:34:20 +02:00
Jonathan Rico
79e86472c3 Bluetooth: L2CAP: clarify BT_L2CAP_STATUS_OUT
Makes it clearer what that bit means:
If set, the channel has capacity to send at least one PDU.

If unset, the channel ran out of credits and won't be able to send
anything until the peer sends credits back.

Also add debug logs.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-05 14:30:18 +01:00
Jonathan Rico
61f834ee67 Bluetooth: L2CAP: don't use bt_l2cap_send internally
Prevents confusion, as the similarly-named `l2cap_send()` also unrefs the
buffer if it fails to send.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-05 14:30:18 +01:00
Emil Gydesen
87c8b897b3 include: util: Add mem_xor functions
Add functions to do XOR on arrays of memory, with one that
takes arbitrary sizes and one for 32 bits and 128 bits as
those are common sizes for this functionality.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-05 09:06:36 +01:00
Erik Brockhoff
5f99c36ca1 Bluetooth: controller: fix procedure collision handling
If an instant based remote procedure 'overtakes' a local ditto
the local procedure will be 'completed' by remote rejection
but collision flag would not get set ensuring that a new local
conflicting procedure cannot be started before the remote is completed.
This can thus lead to invalid local initiation.

Added unittest to cover case

Fix by ensuring collision flag is set also in the above mentioned
scenario.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-01-05 09:05:26 +01:00
Mariusz Skamra
b79a3415a9 Bluetooth: audio: has_client: Move bt_has_client structure to header
This moves bt_has_client instance structure to has_internal.h header
file to be able to access to the instance members in tests.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2024-01-02 10:10:15 +01:00
Hang Fan
915f0fd74c Bluetooth: Shell: Fix coverity issue in cmd_adv_data
Fix wrong parameter type to avoid Unsigned compared against 0

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/65578

Signed-off-by: Hang Fan <fanhang8@gmail.com>
2023-12-27 12:36:23 +02:00
Emil Gydesen
547ffdab6e Bluetooth: MICP: Add mic_ctlr_get_by_conn
Add function to get a MICP microphone controller
instance from a connection pointer. This is effectively
the reverse of bt_micp_mic_ctlr_conn_get, and works similar to
bt_vcp_vol_ctlr_get_by_conn.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-22 14:41:17 +00:00
Mariusz Skamra
2bb8855467 Bluetooth: audio: tbs: Add call_alloc/call_free helper functions
This removes duplicated code by adding helper functions to allocate
and free bt_tbs_call objects.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-22 14:41:00 +00:00
Mariusz Skamra
1894fa1979 Bluetooth: audio: tbs: Simplify bt_tbs_set_signal_strength function
Simplify the function flow, by sending the signal strength notification
in one place, the reporting_interval_work handler.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-22 14:41:00 +00:00
Mariusz Skamra
b728ff9ed3 Bluetooth: audio: tbs: Factor out GTBS and TBS common code
This refactors the code to remove code duplicates by creating common
tbs_inst object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-22 14:41:00 +00:00
Jonas Woerner
2842f206eb Bluetooth: Host: add hci error to errno translation for INVALID_PARAM
now returns -EINVAL if invalid parameters a are supplied

Signed-off-by: Jonas Woerner <github@bolake.de>
2023-12-22 09:52:29 +01:00
Magdalena Kasenberg
e05d964b46 bluetooth: audio: broadcast: Fix missing update of meta_len
The length of the updated metadata was not updated.
Fixes the CAP/INI/BST/BV-13-C test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-12-21 17:18:09 +00:00
Aleksander Wasaznik
700f640948 Bluetooth: ATT: Reject read-by-uuid rsp outside range
A bad peer responding to read-by-uuid can return handles outside the
requested range. This confuses the stack. In particular, the "continue"
and "end" logic in the same function relies on this assumption.

This bad peer was a real issue at UPF, and it caused an infinite loop
during discovery.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/50686

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-21 09:18:14 +01:00
Aleksandr Khromykh
ac4cfe9880 Bluetooth: Mesh: remove 20ms tx delay in adv bearer
The recommendation to have 20ms is fair for two
consecutive messages over a single bearer. When mesh
sends two messages it can be interpreted as two
bearers working in parallel. No need to keep
an artificial 20ms delay for that. Delay was
removed and all related bsim tests were fixed.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-12-19 16:20:36 +01:00
Emil Gydesen
8df987935b Bluetooth: MPL: Add track position notifications during seeking
When seeking the media player should notify clients about the
track position change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-19 08:51:21 +01:00
Emil Gydesen
cda5e58aa5 Bluetooth: CAP: Commander discovery support
Implement the CAP Commander discovery function.

Adds support for it in the shell.

This includes initial babblesim and unit testing as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-19 08:50:40 +01:00
Erwan Gouriou
54d7793e82 drivers: bluethooth: stm32wba: Add HCI driver for STM32WBA
Add HCI Driver for STM32WBA devices.
Based on B91 HCI driver.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-12-18 17:31:08 +00:00
Fabio Baltieri
e51a877a90 bluetooth: shell: match cmd_conn_phy_update conditions
The condition for channel-map are CONFIG_BT_CENTRAL ||
CONFIG_BT_BROADCASTER, change the corresponding handler ifdef so that
it's included in the build if CONFIG_BT_BROADCASTER is enabled but
CONFIG_BT_CENTRAL is not.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-12-18 17:29:02 +00:00
Aaron Ye
d385150bb0 drivers: bluetooth: Add Ambiq HCI driver for Apollo4 Blue Plus.
This commits create the dts binding for Ambiq BT HCI instance.
And create the SPI based common HCI driver for Ambiq Apollox
Blue SoC and the extended soc driver for HCI.

Signed-off-by: Aaron Ye <aye@ambiq.com>
2023-12-18 14:54:53 +01:00
Anders Storrø
f70929a8f1 tests: Bluetooth: Mesh: Add proxy adv coex test.
Adds test that verifies correct Proxy advertisement behavior for
a device where the Proxy adv requirements changes over time,
both for single and multiple subnets.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-18 09:29:41 +01:00
Anders Storrø
6c67ab3a63 Bluetooth: Mesh: Refactor proxy adv
Refactors proxy advertising implementation to allow fair sharing of
advertising resources between all subnets.

In the new implementation, each subnet is agnostic to any other subnet
that might have active proxy advertisement work. When proxy
advertisement is triggered, the implementation will first check how
many subnets that has active work. If there are more than one active
subnet, a maximum timeslot will be calculated to ensure that all active
subnets get access to the medium. The implementation will then poll
the next eligible subnet for a proxy advertising request. If the
duration of this request exceeds the maximum timeslot, the duration
for the next advertisement will be set to the maximum value.

If a proxy advertisement for a subnet is interrupted by other
advertising activity, the implementation will now ensure that the
interrupted proxy adv continues from the point where it was
interrupted so that the subnet gets to utilize the entire allocated
timeslot.

This PR also alters the priv_proxy_net_id_multi Bsim test to align
with the refactored proxy advertising scheme.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-18 09:29:41 +01:00
Pavel Vasilyev
fe70e50d41 Bluetooth: Mesh: Added support for randomly delaying publications
The section 3.7.3.1 of the mesh specification recommends to delay
a message publication in certain cases:
- at power-up or upon state change for a time between 20 to 500 ms
- for periodic publications for a time between 20 to 50 ms

This change implements this recommendation by adding the
`CONFIG_BT_MESH_DELAYABLE_PUBLICATION` Kconfig option which enables
the randomization code and by adding the `bt_mesh_model_pub.delayable`
bit field which allows each model decide whether the publications
should be delayed for this model or not.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-12-18 09:29:24 +01:00
Jonathan Rico
b83b9bede3 Bluetooth: ATT: call-back on buffer destroy
This is just as arbitrary as what was before, but simpler.

Before this change, the callback were invoked upon receiving the num
complete packets event.
This did not necessarily work with all spec-compliant controllers.

Now the callback is invoked as soon as the lower layer destroys the
buffer. ATT shouldn't care whether L2CAP sends it over RFC1149 or
something else after that point.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-15 17:14:56 +02:00
Jonathan Rico
a05a47573a Bluetooth: ATT: Internalize ATT PDU TX pool
Why?
- metadata is easier to manage as an array + index
  - less error-prone -> less memory-management bugs
- we can. because of the previous refactor
- PDU allocations are more predictable
- ATT buffer size can be optimized by app
- isolates ATT from the rest of the ACL users
  - decouples ATT PDU size from e.g. SMP w/ LESC

Drawbacks:
- higher memory usage
- kconfig change

The higher memory use is only temporary, as this will be followed-up
with more refactors that should bring it back down.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-15 17:14:56 +02:00
Emil Gydesen
62ab25e3f5 Bluetooth: MPL: Make internal functions static
Several internal functions were not static.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Emil Gydesen
a8fbab6b1a Bluetooth: MPL: Simplify control point ops
Simplify how control point operations are handled, and
reduce code duplication.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Emil Gydesen
984e4213c1 Bluetooth: MPL: Simplify track and group changes
Simplify track and group changes by moving the
notifications into the functions that changes the states.

This removes some code duplication, and makes the code easier
to read, as well, as ensuring that notifications are always
sent.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Emil Gydesen
f138f7dd3e Bluetooth: MPL: Add mpl_set_state
Add the static function, mpl_set_state, to help set the playing
state of the media player.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Emil Gydesen
9616b3b182 Bluetooth: MPL: Use set_track_position more excessively
The set_track_position handles both correct clamping of the
position, as well as the notification, so use that instead
of setting the value and sending notifications manually.

Also adds a new function, set_relative_track_position,
to help set relative positions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-15 14:35:15 +01:00
Fredrik Danebjer
37e1a116ef bluetooth: shell: Fix stream_start_sine for single stream
Fixed the stream_start_sine function when omitting the all argument.
The verification of the sine checked reversed return value, and was
placed in incorrect order.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-12-15 11:42:26 +00:00
Mariusz Skamra
6e6311ebfb tests: Bluetooth: shell: Use BT_LE_CONN_PARAM_DEFAULT for connection
This basically reverts changes made by
9c8ec58beb.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-15 11:41:34 +00:00
Mariusz Skamra
d2745d6dba tests: Bluetooth: shell: Fix connection reference leak
This fixes regression introduced in recently.
Redundant connection reference is taken twice in connected()
callback. The redunant reference was then not returned, and
as a result we had a leak.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-15 11:41:34 +00:00
Mariusz Skamra
1cb80d3282 Bluetooth: audio: has_client: Use CONTAINER_OF to get client instance
This starts using CONTAINER_OF macro instead of inst_by_conn function
wherever possible. It's better approach as the client instance is
a container for parameters passed to the callbacks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-14 09:31:59 +01:00
Anders Storrø
25d44a828d Bluetooth: Mesh: Rename prov_dev->provisionee
Renames "prov device" references and options to
"provisionee" to align implementation with Mesh
Protocol specification v1.1, section 5.4.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-12-13 13:57:46 +01:00
Mariusz Skamra
d3d46a6d80 Bluetooth: has: Fix control point error return code
This fixes the return error code for Preset Write operation that shall
be returned when preset is not writable (or disabled via Kconfig like in
this case).

As per HAS_v1.0; 3.2.2.3 Write Preset Name operation
"If the Writable bit in the Properties field of the preset record which
is identified by the Index parameter is set to 0b0, then the server
shall return an ATT_ERROR_RSP PDU to the ATT_WRITE_REQ PDU with
the Error Code parameter set to Write Name Not Allowed."

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-13 09:42:04 +01:00
Xudong Zheng
545a3973a8 bluetooth: bas: remove select SENSOR
Bluetooth battery service does not use sensor.

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2023-12-12 19:10:17 +01:00
Mariusz Skamra
09e376068e Bluetooth: audio: bap_stream: Fix potential NULL pointer dereference
This fixes potential NULL stream pointer dereference.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-12 15:33:13 +01:00
Mariusz Skamra
025ba06c32 Bluetooth: ascs: Avoid possible unexpected assert
This avoids unexpected assert that may happen when the client tries to
QoS configure ASE that is in state which does not allow to be configured.
In such case the assert shall not be not be triggered, as it's not stack
fauly. The assert check has been moved after the state check, so the ASCS
implementation will just return an error code to the client.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-12 15:33:13 +01:00
Mariusz Skamra
ddf172c187 Bluetooth: gatt: Fix automatic resubscription causing CCC removal
This fixes CCC subscriptions that were removed if the automatic
resubscription was aborted by ACL disconnection.
As the client renews subscriptions, there is no point of removing those
if the link is disconnected unexpectedly.
The API user won't be notified about the failure, as the automatic
resubscriptions are implicit, and after reconnection the subscriptions
will be still valid.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-12 15:32:45 +01:00
Mariusz Skamra
af9f526ccd Bluetooth: has: Check writable preset support on preset registration
This fixes issue where API use is able to register writable preset even
if the CONFIG_BT_HAS_PRESET_NAME_DYNAMIC Kconfig option was disabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-11 19:26:36 +01:00
Emil Gydesen
9c8ec58beb Bluetooth: GMAP: Add GMAP shell
Add the GMAP shell module with support for running the
various audio configurations in an easy way.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 18:30:57 +01:00
Emil Gydesen
7913ebfba3 Bluetooth: GMAP: Add initial implementation of GMAP
Add initial implementation of Gaming Audio Profile (GMAP).

This is a top layer profile in the LE Audio stack,
designed for low latency audio ideal for gaming.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 18:30:57 +01:00
Lingao Meng
ffd716b4a2 Bluetooth: Host: iso_data extend bt_buf_data
Explicitly declare that iso_data extends bt_buf_data.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-11 12:50:54 +01:00
Lingao Meng
0ddb6aa82e Bluetooth: Host: Use actual user_data size
Use actual user_data size not default by 8.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-11 12:50:54 +01:00
Emil Gydesen
6158ff03f5 Bluetooth: Shell: Only auto-connect to unconnected devices
The bt connect and bt connect-name commands should only
attempt to connect to connectable devices that we are not
already connected to.

This commit moves the check for BT_GAP_ADV_PROP_CONNECTABLE
as well as checks that we do not already have a connection
to that device with the current ID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 09:54:04 +01:00
Emil Gydesen
01bd94ac4f Bluetooth: Shell: Remove tolower from is_substring
The tolower is not necessary and is what strncasecmp
does anyhow.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-11 09:53:36 +01:00
Joakim Andersson
f390f7d0a1 bluetooth: shell: Use helper function to convert string to int
Use helper function to convert string to int for appearance value.
This makes the code more clear, as the big-endian conversion function
gives the wrong impression about the byte order of advertising data.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-12-11 09:51:31 +01:00
Aleksandr Khromykh
d175ac0572 Bluetooth: Mesh: access tx msg randomizer
Commit adds implementation of the specification
recommendations regarding randomization of
responses on the access layer.
3.7.3.1 Transmitting an Access messages

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-12-11 09:50:18 +01:00
Lingao Meng
683098728a Bluetooth: Mesh: Use memslab replace with net_buf_pool
Use memslab more efficiency than net_buf_pool and consume
less ram with flash resource.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-08 20:19:10 +00:00
Pavel Vasilyev
ef1f2d1336 Bluetooth: Mesh: Convert no opcode error to debug log
This error message may confuse when `CONFIG_BT_MESH_ACCESS_LAYER_MSG` is
enabled and all messages are processed by the callback anyway.
This error message also confuses when a node is subscribed to the same
address as it publishes to, which makes it generating the error message
every time it publishes a message.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-12-08 10:25:36 +00:00
Pavel Vasilyev
bcd2aba4d7 Bluetooth: Mesh: Allow custom RPL use mesh settings work
This change allows a custom RPL use pending mechanism and the mesh
settings work to store pending RPL entries. `bt_mesh_rpl_pending_store`
is a public API and should be implemented anyway. The custom RPL
implementation has to trigger settings with the
`BT_MESH_SETTINGS_RPL_PENDING` flag to ask the mesh settings work to
call `bt_mesh_rpl_pending_store`.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-12-08 10:25:36 +00:00
Emil Gydesen
203949c42c Bluetooth: VCP: Allow for multiple vol_ctrl cb registers
Modify the VCP volume controller callbacks to support
multiple registers by making it into a linked list.

This allow for multiple applications to get the information
from procedures or notifications.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-08 10:04:31 +00:00
Lingao Meng
786b9a0ad4 Bluetooth: Host: Add const prefix for UUID
Add const prefix for service uuid and char uuid.

Since Service UUID and Char UUID should not change in the service
definition, they are most reasonably defined as rodata, also for
save some ram footprint.

The field `attr->user_data` type is `void *`, as this PR change
all Service UUID to rodata, so there must add (void *) to avoid warning.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-07 16:16:43 +00:00
Emil Gydesen
3fec3964e0 Bluetooth: CAP: Move initiator/commander common code to cap_common
The CAP Initiator and the CAP Commendar share quite a lot of
functionality in terms of discovery and performing set-based
procedures.

The code for handling most of this has been moved to
cap_common.c to avoid duplicating code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-07 16:14:42 +00:00
Jonathan Rico
3e56b12c58 Bluetooth: ATT: don't access l2cap ops struct
It's bad form, especially since in that case, it's always the same function
that is called `bt_att_sent()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-12-07 10:37:37 +00:00
Emil Gydesen
e496cbe512 Bluetooth: VCP: Vol rend: Add check before notification log
To avoid having "notification scheduled in 0ms" in the log,
check to verify that the delay is not K_NO_WAIT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-06 17:55:10 +00:00
Mariusz Skamra
78a4b33e5c Bluetooth: audio: pacs: Add bt_pacs_set_available_contexts_for_conn
This adds the function that sets the available contexts value per
connection object so that API user can set different available contexts
per connection.
The lifetime of such overriden value is the same as connection lifetime,
so on reconnection or device reboot all devices return to having the
same available contexts value again.

Fixes: #64968
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-06 17:54:14 +00:00
Mariusz Skamra
014c22c9c0 Bluetooth: audio: pacs: Fix invalid lookup
This fixes client lookup that was done with use of bt_conn_index while
the size of the client array is CONFIG_BT_MAX_PAIRED.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-06 17:54:14 +00:00
Mariusz Skamra
ef362e766a Bluetooth: audio: pacs: Disallow changing supported contexts
Disallow further changes of supported audio contexts characteristic is
the GATT Characteristic Notify Property is not set.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-06 17:54:14 +00:00
Jonathan Rico
ea04fd95f9 Bluetooth: ATT: remove BT_ATT_ENFORCE_FLOW
Enforcing the peer's behavior is not strictly necessary. All the host
should do is make sure it is resilient to a spec-violating peer.

Moreover, a growing number of platforms were disabling the check, as the
spec allows "batching" HCI num complete packets events, stalling ATT RX.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-06 17:53:54 +00:00
Piotr Narajowski
4dad6616f7 bluetooth: audio: Add API to get MCS service ATT handles
This is needed for upper tester.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
2023-12-06 17:52:49 +00:00
Emil Gydesen
38d73a6ccf Bluetooth: VCP: Add bt_vcp_vol_ctlr_get_by_conn
Add function to get a volume controller from a connection
pointer.

This is required for the CAP to get a vol_ctlr pointer
from the provided bt_conn.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-06 17:51:58 +00:00
Emil Gydesen
c9daed9712 Bluetooth: BAP: Refactor bt_bap_base
This removes the fixed size bt_bap_base, which provides
2 improvements:
1) The RAM usage of the broadcast sink has been reduced.
   For the Broadcast Sink sample it is a reduction of 120
   octets, but with much better scaling for supporting
   more or larger BASEs.
2) The functions to parse BASEs now support arbitrary sized
   BASEs, where they were previously restricted by our
   local Kconfig options. This allow us to parse any BASE
   from a remote device, without encounting memory issues.
   We are still memory restricted on the devices we
   actually want to sync to.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-12-06 17:51:47 +00:00
Aleksander Wasaznik
d3a0c769b0 Bluetooth: Shell: Workaround coverity uint comparation
The current code triggers a false positive from the heuristic "Macro
compares unsigned to 0". It's triggered because of a use of `IN_RANGE`
that checks against the extremal values of a enum type.

This patch replaces the use of `IN_RANGE` with an explicit list of the
possible values of the enum.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/65575

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-04 16:37:36 +00:00
Håvard Reierstad
897a1d0d1c Bluetooth: Mesh: suspend/resume advertising
Disables Mesh advertising when suspending, and enables advertising
when resuming Mesh.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-12-04 14:38:13 +01:00
Håvard Reierstad
3be26c4cb9 Bluetooth: Mesh: advertiser: add disable function
Adds a disable function for the extended advertising which stops and
deletes the advertising instances, allowing them to be properly
reinitialized when calling `bt_mesh_adv_enable()` after bluetooth has
been disabled and re-enabled.

For the legacy advertising, the function terminates the advertising
thread. If legacy advertising is used, `bt_mesh_adv_init()` must be
called before `bt_mesh_adv_enable()` to properly resume advertising
after suspension.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-12-04 14:38:13 +01:00
Mariusz Skamra
5174e94c91 Bluetooth: audio: has: Fix coverity issues
This fixes issues discovered by coverity check.

Fixes: #65325
Fixes: #65326
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-12-01 16:26:03 +01:00
Adam Cavender
ac4f9a6962 Bluetooth: Shell: Fix cmd_chan_map
Allow the channel map to be set when periodic advertising or acting as
an ISO source.

Signed-off-by: Adam Cavender <adam.cavender@nordicsemi.no>
2023-12-01 14:30:52 +01:00
Adam Cavender
ad485866b0 Bluetooth: Host: Fix bt_le_set_chan_map
Allow the channel map to be set when periodic advertising or acting as
an ISO source.

Signed-off-by: Adam Cavender <adam.cavender@nordicsemi.no>
2023-12-01 14:30:52 +01:00
Peter Johanson
be5a341467 bluetooth: Add CPF attribute to BAS battery level.
BAS v1.1, section 3.1.2.1 notes that a CPF should be added if the
device has more that one instance of the Battery Service, so
add one with the `main` description so that apps can add additional
Battery Level services with other descriptions, e.g. `auxiliary`.

Signed-off-by: Peter Johanson <peter@peterjohanson.com>
2023-12-01 10:58:27 +00:00
Mia Koen
0bcad09392 bluetooth: mesh: Doc fix Bluetooth mesh to Mesh
SIG has changed Bluetooth mesh to Bluetooth Mesh
Updating zephyr docs accordingly
Leaving out old release notes

Signed-off-by: Mia Koen <mia.koen@nordicsemi.no>
2023-12-01 10:56:18 +00:00
Andries Kruithof
c3e2be4314 Bluetooth: audio: host: call the stream disable callback
Even though the ASCS Sink ASE state machine does not enter the disabling
state according to ASCS spec, it still makes sense to do so.

the state transition unit tests are updated to verify calling or not
calling the disable callback, depending on the transition of the state

fixes #63230

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-12-01 10:50:04 +00:00
Magdalena Kasenberg
c94cd30cec bluetooth: bap: Fix shift of requested_bis_sync
The BIS_Sync bitfiled received over the air in Add Source and Modify
Source operations uses BIT(0) for BIS Index 1. Shift it when storing
it to match bis_sync bitfield where BIS Index 1 is at BIT(1).

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-30 12:10:35 +00:00
Magdalena Kasenberg
2094183d81 bluetooth: bap: Fix shift of BIS_Sync parameter of notification
bis_sync contains BIS index bitfield which is shifted by 1 bit relative
to the BIS_Sync parameter of Broadcast Receive State notification.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-30 12:10:35 +00:00
Aleksander Wasaznik
dc834cb217 Bluetooth: l2cap: remove bt_l2cap_chan_send_cb
It has no more users and was an internal API.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-30 10:06:19 +01:00
Aleksander Wasaznik
8a3201c223 Bluetooth: att: Remove att use of bt_l2cap_chan_send_cb
EATT is the only user of `bt_l2cap_chan_send_cb`, and not necessary. We
can maintain the same functionality without it.

Instead of passing and storing the callback into l2cap, we can store it
in a callback queue in the ATT bearer struct.

This will allow us to remove that internal API later, in order to
streamline the l2cap API.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-30 10:06:19 +01:00
Aleksander Wasaznik
535e003a00 Bluetooth: Use CONFIG_BT_CONN_TX_USER_DATA_SIZE
Replace hardcoded value `8` with `CONFIG_BT_CONN_TX_USER_DATA_SIZE`,
that is `8` but is going to change.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-30 10:06:19 +01:00
Armin Brauns
5b1b260f80 bluetooth: add HCI driver parameter to set controller's public address
This allows HCI drivers to expose vendor-specific functions to set the
public address.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-11-29 10:44:25 +01:00
Kyra Lengfeld
77ab683dc6 Bluetooth: Host: Align return lines of bt shell helper function phy2str
As other helper functions were introduced for the LE Power Control
Request Feature (see CONFIG_BT_TRANSMIT_POWER_CONTROL), it was noticed
that the return statements of switch cases should be on the next line
generally. This will align phy2str with the rest in bt.c.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-11-29 09:59:39 +01:00
Kyra Lengfeld
2c9af855bc Bluetooth: Host: Add bt shell functions LE Power Control Request Feature
To use LE commands of Le Power Control Request Feature one must utilize
the BT_TRANSMIT_POWER_CONTROL config.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-11-29 09:59:39 +01:00
Kyra Lengfeld
93e5cf6e61 Bluetooth: Host: Add LE Power Control Request Procedure APIs
This commits adds the LE API's for the LE Power Control Request Feature
in Zephyr.

The support of feature is provided with the controller-based feature
selection with BT_CTLR_LE_POWER_CONTROL_SUPPORT and is selectable via
BT_TRANSMIT_POWER_CONTROL.

With the new APIs, the applications will:
get improved reading of local and remote tx power
be aware of changes in remote or local tx power

Defined HCI commands in Core Spec v5.4:
7.8.117 LE Enhanced Read Transmit Power Level command:
improvement to existing local tx power reading.
7.8.118 LE Read Remote Transmit Power Level command:
Remote tx power is read through an event (LE Transmit Power Reporting)
7.8.121 LE Set Transmit Power Reporting Enable command:
Enables local or remote tx power reporting to monitor changes in tx power
7.7.65.33 LE Transmit Power Reporting event

Note: to utilize the Feature fully Nordic-LL-only vendor-specific commands
are needed. These will not be added in RTOS zephyr but instead
implemented in a maintainable way in sdk.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-11-29 09:59:39 +01:00
Kyra Lengfeld
56a5901955 Bluetooth: Controller: Add Kconfig for LE Power Control Request Feature
Add the controller Kconfig to use in Zephyr.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-11-29 09:59:39 +01:00
Troels Nilsson
f0032a369d Bluetooth: L2CAP: Fix leaking tx metadata
Fix l2cap error handling generally not properly disposing of tx buffers for
enhanced channels; Any callbacks have to be called and the
l2cap_tx_meta_data has to be freed

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-11-28 15:34:51 +01:00
Troels Nilsson
b782b11f16 Bluetooth: L2CAP: l2cap_create_le_sig_pdu() no longer uses buf
The l2cap_create_le_sig_pdu function no longer uses the buf
argument; Remove it from the function

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-11-28 15:34:51 +01:00
Pavel Vasilyev
161aadd590 Bluetooth: Mesh: Return immediately if labels not supported
This avoid unnecessary triggering of settings work.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-28 14:48:29 +01:00
Pavel Vasilyev
362924a693 Bluetooth: Mesh: Use ATOMIC_DEFINE instead of atomic_t
atomic_*_bit functions work with atomic_t arg as with array, therefore
the atomic variable should be declared using ATOMIC_DEFINE.

Coverity-CID: 333358
Fixes #65588

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-28 14:48:29 +01:00
Mariusz Skamra
b373079275 Bluetooth: audio: ascs: Remove spurious error message
This removes spurious error message printed when CIS has been
disconnected and it was not used by any of the endpoints.
This case is valid and may happen on Connection Timeout when the
controller reports ACL Disconnection first.
When the CIS Disconnection is reported after, the ASE is already in idle
state and the referenece to CIS has been already removed (on ACL
disconnection).

Fixes: #64896
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-27 12:16:30 +00:00
Vinayak Kariappa Chettimada
d36e085ecc Bluetooth: Controller: Fix scan aux context leak
Fix scan aux context leak under BT_CTLR_SCAN_UNRESERVED.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 12:15:29 +00:00
Vinayak Kariappa Chettimada
d573951f0d Bluetooth: Controller: Revert back early abort of previous prepare
Revert back to implementation that did early abort of
previous prepare when a short prepare is enqueued.

Adds back implementation deleted in
commit 7f388bb70a ("Bluetooth: Controller: Fix short
prepare when many enqueued in pipeline").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 12:15:29 +00:00
Vinayak Kariappa Chettimada
b444dc442b Bluetooth: Controller: Minor re-arrange advanced feature Kconfig
Minor refactor of Kconfig order such that the advanced
feature Kconfig is just above the enabling/visible of the
advanced features menu.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 12:15:29 +00:00
Vinayak Kariappa Chettimada
ec7bdde22b Bluetooth: Controller: Improve preempt timeout req/ack counting
Improve preempt timeout request and acknowledge counting.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-27 12:15:29 +00:00
Vinayak Kariappa Chettimada
12cefe1027 Bluetooth: Controller: Fix compiler warning when RL_SIZE=1
Fix compiler warning when BT_CTLR_RL_SIZE=1.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-25 08:54:39 -05:00
Vinayak Kariappa Chettimada
6c7c5bd5dd Bluetooth: Controller: Fix uninitialized ad_len_chain variable
Fix uninitialized ad_len_chain variable.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-25 08:47:36 -05:00
Vinayak Kariappa Chettimada
ca45155a23 Bluetooth: Controller: Fix NULL pointer dereferencing in Sync ISO
Fix NULL pointer dereferencing when Host supplies an out of
bounds BIG handle.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-25 08:47:00 -05:00
Lukas Streitenberger
10a167f6c1 Bluetooth: TBS: Added missing callState notifications
Changes of call state were not notified. Fixed by calling notify_calls
in respective functions.

Signed-off-by: Lukas Streitenberger <lukas.streitenberger@wsa.com>
2023-11-24 11:39:34 +01:00
Aleksandr Khromykh
3d37549bac Bluetooth: Mesh: allocate mesh max required buffer number
Since sending of public key was moved into system
work (https://github.com/zephyrproject-rtos/zephyr/pull/62331)
it uses the same context as a Host Tx buffer
allocator for gatt sending. Host cannot wait for
free buffer anymore. Mesh requires 4 buffers
to send max size frame(public key) during
provisioning.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-24 09:26:37 +01:00
Mariusz Skamra
e1a14bad30 Bluetooth: audio: has: Add non-volatile settings
This adds non-volatile settings for the HAS Server. Those are needed to
restore the client awareness of preset list entries exposed by the
server. Based on the settings, the implementation determines how to
notify the client about the HAS related characteristic value changes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-22 09:51:33 +01:00
Emil Gydesen
1829cf4324 Bluetooth: Audio: Add set functions for codec meta
Add set function for all metadata types for both
codec_cfg and codec_cap.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-21 08:38:29 +00:00
Pavel Vasilyev
07848a4456 Bluetooth: Mesh: Fix integer overflow
Fix potential integer overflow by casting one of operands to int64_t.

Coverity-CID: 329961
Fixes #65356

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Pavel Vasilyev
3bc17d1d18 Bluetooth: Mesh: Fix async behavior of Private Beacon Client API
The Private Beacon Client API requires a response argument to allow to
call the API in the asynchronous manner
(https://github.com/zephyrproject-rtos/zephyr/pull/56426).

Because the removal of the EXPERIMENTAL tag for this API was not
released yet, it should be OK to change this API.
The EXPERIMENTAL tag has been removed here:
https://github.com/zephyrproject-rtos/zephyr/pull/64866

Coverity-CID: 330039
Coverity-CID: 330029
Coverity-CID: 329977

Fixes #65336
Fixes #65338
Fixes #65354

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Pavel Vasilyev
b15611eb28 Bluetooth: Mesh: Check return value of bt_conn_get_info
Coverity-CID: 323094
Fixes #65366

Coverity-CID: 323081
Fixes #65370

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Pavel Vasilyev
6a5d082cc5 Bluetooth: Mesh: Ignore return value of settings_delete
This suppresses warning from Coverity.

Coverity-CID: 330638
Fixes #65330

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-20 09:23:56 +01:00
Lingao Meng
5f1c2f199b Bluetooth: Mesh: Make element as rodata
the reason is that the Mesh Profile clearly stipulates that Mesh nodes
cannot change their own element definitions.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-20 09:22:55 +01:00
Jonathan Rico
dfd7624270 Revert "Bluetooth: att: use a dedicated metadata struct for RSP PDUs"
This reverts commit 14858d96d87d33ebb593d61380f4607e14107287.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-11-17 09:26:08 +01:00
Jonathan Rico
bd9c35b496 Revert "Bluetooth: att: re-use REQ buf for RSP"
This reverts commit aa7954bd4725bbd46e974a03c0d0312b7e9a483f.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-11-17 09:26:08 +01:00
Jonathan Rico
530e845f92 Revert "Bluetooth: att: don't re-use the ATT buffer for confirmations"
This reverts commit 4cd0748a407b118145916393a954231ee11abb1e.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-11-17 09:26:08 +01:00
Aleksander Wasaznik
bf2f065876 Bluetooth: Host: Remove ifdef around sc_indicate
Instead, `sc_indicate` is defined as a no-op when if would previously
not be defined.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-11-17 09:25:34 +01:00
Lingao Meng
2cd8d40b97 Bluetooth: Mesh: Split Model Structure
Split Model Variables to separate structue.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-16 16:52:14 +01:00
Lingao Meng
ab08f34fd9 Bluetooth: Mesh: Make bt_mesh_model as rodata
Since model struct most of member should not change at run time,
so mark as const will be suitable and safely.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-16 16:52:14 +01:00
Mariusz Skamra
ba61420504 Bluetooth: audio: ascs: Retry ASE state notifications on error
This adds retry logic for ASE state notifications if failed due to
insufficient number of buffers to send ATT PDU. The state transition is
retried after connection interval delay.

Fixes: #64574
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-15 10:03:07 +01:00
Lingao Meng
1f4dacad08 Bluetooth: Mesh: Remove relay sets config for adv
Separate queue should also used for lagecy adv, due to
when local queue has adv buf, k_poll will process local queue.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-11-15 10:01:47 +01:00
Vinayak Kariappa Chettimada
09c69731cd Bluetooth: Controller: Reduce RTN for requested Max Transport Latency
Add implementation to reduce CIG's CIS retransmissions so as
to meet the Host requested Maximum Transport Latency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-11-14 09:46:02 +01:00
Kamil Piszczek
f6d6742ca1 bluetooth: id: make sharing RPA between adv sets optional
Added a Kconfig option that makes the RPA sharing feature optional. By
default, the Zephyr Bluetooth stack now uses the RPA rotation policy
that was active before the introduction of the RPA sharing functionality
in the following PR:

https://github.com/zephyrproject-rtos/zephyr/pull/55449

The new Kconfig option configures the advertising sets linked with the
same Bluetooth identity to use the same Resolvable Private Address in
a given rotation period. After the RPA timeout, the new RPA is
generated and shared between the advertising sets in the subsequent
rotation period.

When this option is disabled, the generated RPAs of the advertising
sets differ from each other in a given rotation period.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-14 09:22:51 +01:00
Jordan Yates
e74676223a bluetooth: host: gatt: statically init callback list
Statically initialise the callback list so that subscriptions can be
registered before the call to `bt_enable`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-11-14 09:21:16 +01:00
Pavel Vasilyev
64e1d0c3be bluetooth: mesh: Don't write to const value
`bt_mesh_default_key` is declared as const and thus located in flash.
`bt_mesh_cdb_subnet_key_export` tries to copy to that address which
results in a Bus Fault.

Use separate array for storing net_key.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-11-13 09:51:25 +01:00
Mariusz Skamra
f434198a2b Bluetooth: att: Retry ATT request if security elevation is in progress
If the conn security elevation is already in progress, retry the ATT
request if failed due to security reasons.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-11-13 09:45:20 +01:00
Emil Gydesen
06d5a625a6 Bluetooth: Audio: Add codec cap set functions
Add set functions for codec capability, to set all
assigned number values in the bt_audio_codec_cap
struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-13 09:42:35 +01:00
Emil Gydesen
c35e677d82 Bluetooth: Audio: Split ltv_set_val from codec_cfg_set_val
Add a new function, ltv_set_val, that did most of the
data manipulation from codec_cfg_set_val, so that we can
reuse that code for the codec cap and codec meta
functions as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-13 09:42:35 +01:00
Magdalena Kasenberg
647207c024 bluetooth: leaudio: Fix missing set of BIG_Encryption
In the PTS BASS/SR/CP/BV-19-C test case a client executes Set
Broadcast Code operation of Broadcast Audio Scan Control Point
characteristic with Broadcast_Code set to an invalid value.
After syncing to an ISO stream there is an expected failed attempt
to decrypt the stream data, but the host does not set BIG_Encryption
value to the expected value 0x03 (BT_BAP_BIG_ENC_STATE_BAD_CODE).
Add missing BIG_Encryption state into the failing check.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-10 10:40:40 +01:00
Magdalena Kasenberg
35f326b821 bluetooth: leaudio: Termination of PA at Modify Source
From BASS spec:
If the PA_Sync parameter value written by the client is set to a value
of 0x00 (Do not synchronize to PA) and the server is synchronized to
the PA, the server shall stop synchronization with the PA and shall
write a value of 0x00 (Not synchronized to PA) to the PA_Sync_State
field of the Broadcast Receive State characteristic .

Fixes BASS/SR/CP/BV-12-C test case.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-09 15:32:32 +01:00
Magdalena Kasenberg
a2210bde63 bluetooth: audio: delegator: Use BT_ATT_ERR_WRITE_REQ_REJECTED
If the total length of the opcode and parameter values of Broadcast
Receive State characteristic operation is incorrect, the server shall
respond with an ATT Error Response and the Error Code set to Write
Request Rejected (0xfc), instead of 0x0d
(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN).

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-08 15:10:39 +00:00
Aleksandr Khromykh
c5ee143d77 Bluetooth: Mesh: no more tinycrypt in ble mesh tfm image
PR allows to get rid of tinycrypt objects from
the final binary of the ble mesh apps based on
PSA TFM crypto.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-08 15:09:50 +00:00
Kamil Piszczek
29a67338d1 bluetooth: id: fix uninitialized RPA for non-default identities
This change fixes uninitialized RPA values for advertising sets of
non-default Bluetooth identities. The regression has been introduced
in the following commit:

8d6b206064

The follow-up fix for the default Bluetooth identity has been
introduced in a separate commit:

88c20b9cdd

Non-default Bluetooth identities can be loaded from the Settings
subsystem. In this case, RPAs of related advertising sets to these
identities are left uninitialized as the bt_id_create() function
context is not executed. As a result, the RPA is not created for
advertising sets of non-default Bluetooth identities, and the
advertising is started with the 00:00:00:00:00:00 address.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-11-08 15:09:22 +00:00
Aleksandr Khromykh
b6f20d67c2 Bluetooth: Mesh: fix On-Demand API usage
On-Demand proxy client API has been changed but
usage of this API in shell test was missed.
Commit fixes this API usage.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-08 10:08:36 +01:00
Aleksandr Khromykh
50d17a0d52 Bluetooth: Mesh: split gatt client and solicitation pdu sending
The ability to send the solicitation PDU doesn't
depend on GATT Client role.
Commit makes independent one functionality from
another.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-11-08 10:08:36 +01:00
Ingar Kulbrandstad
e1a5605889 Bluetooth: Mesh: Remove experimental tag
Remove experimental tag for Mesh Protocol v1.1,
Mesh Model v1.1, Mesh DFU v1.0 and Mesh BLOB v1.0
features.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-11-07 11:57:17 +01:00
Rubin Gerritsen
8b2dd61eba Bluetooth: HCI: Add bt_hci_get_ver_str()
This new API returns the version string corresponding to a given
HCI version.

The API can be used by applications to print out human-readable
information about the controller being used.

Adding this API removes possible code duplication.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-11-07 09:55:05 +01:00
Emil Gydesen
b92ac42677 Bluetooth: CAP: Commander API and skeleton
Adds the CAP Commendar API and skeleton that can
implemented.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-11-07 09:49:41 +01:00
Magdalena Kasenberg
1747c33796 bluetooth: audio: delegator: Notify state after updating BIG_Encryption
If the server has synchronized to the PA and detected that the BIS is
encrypted, the server writes a value of 0x01 (Broadcast_Code
required) to the BIG_Encryption field of the Broadcast Receive State
characteristic to request a client to provide a Broadcast_Code.
In PTS BASS/SR/CP/BV-14-C test case the PTS (client) expects that the
new value of the Broadcast Receive State characteristicstate will be
notified, so the PTS could sent Set Broadcast_Code operation to the
server.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-11-06 12:32:23 +01:00
Troels Nilsson
3c9d952820 Bluetooth: Controller: Fix failing LL/DDI/SCN/BV-88-C
Fixes failing EBQ test LL/DDI/SCN/BV-88-C Extended Scanning,
Active, Properly Ignore RFU Fields

Several minor modifications made to le_ext_adv_report() to
properly ignore any invalid fields present in the received PDUs

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-11-06 10:10:47 +01:00
Andries Kruithof
2a34ecf858 Bluetooth: shell: host: add missing conditional compile
There was a conditional compile misssing for the
BT_PER_ADV_SYNC_TRANSFER_SENDER, potentially leading
to build failures

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-11-06 10:10:07 +01:00
Benjamin Lucke
1b34884d81 Bluetooth: TBS: Fixed return call_index 0 after overflow
Fixed range of call_index 1 to 255, since 0 is reserved for outgoing calls.

Signed-off-by: Benjamin Lucke <git@lucke.tech>
2023-11-03 09:55:22 +01:00
Carles Cufi
9cf07bbdb5 bluetooth: Rename rpmsg HCI driver and sample to ipc
The existing driver and sample:

- drivers/bluetooth/hci/rpmsg
- samples/bluetooth/hci_rpmsg

are no longer correctly named, since they now use the IPC subsystem to
send and receive data. The IPC subsystem can use RPMsg as a transport,
but that is one of several selectable backends.

I initially wanted to deprecated both the BT_RPMSG Kconfig option as
well as the zephyr,bt-hci-rpmsg-ipc chosen node in Devicetree. However,
this proved to be undoable in the case of the Kconfig option. This is
because it's a choice option, and those have special behavior. In
particular, the only practical way to deprecate would've been to keep
the old Kconfig option outside the choice (much like it's done in this
commit) but then also add a 'depends on !BT_RPMSG' on each of the
remaining choice symbols *except* on the new BT_HCI_IPC one. This, however,
only works correctly for .conf files. If a board instead sets the
default BT_HCI_BUS_TYPE in the Kconfig.defconfig file then the Kconfig
tree parsing would fail, because it'd try to set it to a value
(BT_RPMSG) that is no longer part of the choice.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-11-02 08:32:20 +02:00
Benjamin Lucke
9c323d685b Bluetooth: BAP: Shell: Fixed some bap shell cmds
Added missing initialization for cmd_stream_qos and cmd_sync_broadcast.

Signed-off-by: Benjamin Lucke <git@lucke.tech>
2023-10-30 14:57:33 -05:00
Alberto Escolar Piedras
08f6532b67 Bluetooth: Controller: Fix corruption during BIG_CHANNEL_MAP_IND
radio_pkt_big_ctrl_get() returns a statically allocated
buffer of type pdu_big_ctrl, but the callers expect a
buffer where a whole PDU for a BIG control packet can fit
(not just space for the payload),
and use it as such, overflowing this statically
allocated buffer, and smashing other variables after.

Let's fix it by allocating a buffer of the correct size
to fit a BIG control PDU.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/64497

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-30 18:36:39 +01:00
Alberto Escolar Piedras
55c59e041e Bluetooth: Controller: Avoid division by 0 with BT_CTLR_THROUGHPUT
With very fast HCI interfaces (for ex. in the simulated nrf5340)
the tx_rate calculation can do a division by 0
(if to packets are enqueued in the same 32KHz clock period).
Let's avoid it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-10-30 10:49:51 +01:00
Andries Kruithof
8c1513c837 Bluetooth: shell: make behaviour of iso cmd same as bt cmd
When no parameters are given to the 'bt' command it prints
the help message. The 'iso' command responds with 'missing
subcommand'. This commit updates the behaviour of the iso
command so that it behaves the same as the bt command, i.e.
prints a help message

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-27 10:53:25 +02:00
Emil Gydesen
6aea1864c1 Bluetooth: ISO: Minor fixes for ISO shell
If CONFIG_BT_ISO_TEST_PARAMS=y then the CIG and BIG
create params was not properly initialized.

Modified the TX for BIS and CIS to be more similar

Added a timeout on the buffer to avoid any potentional
deadlocks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-26 09:48:54 +02:00
Emil Gydesen
34058146a5 Bluetooth: BAP: Shell: Remove unused variable stream_frame_duration_us
The variable was unsused and caused compiler warnings.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-25 17:36:22 +02:00
Anders Storrø
d4037ce6a1 Bluetooth: Mesh: Correct pack of net idx hb_status
Ensures correct packing of net idx in Heartbeat Publication Status
messages on the Configuration Server.

Reference to net idx packing format: MshPRTv1.1 section 4.3.1.1

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø
05774c5d76 Bluetooth: Mesh: Fix unpacking of hb_pub status
Fixes incorrect unpacking of Heartbeat Publication status
messages on the Configuration client.

Reference to packing format: MshPRTv1.1 section 4.3.2.63

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø
46d9c97991 Bluetooth: Mesh: HB pub status for unassigned addr
Fixes issue where Heartbeat Publication Status message sends
garbage data when destination field is set to the unassigned address.

MshPRTv1.1, section 4.4.1.2.15:
"When the Destination field is set to the unassigned address, the values
of the CountLog, PeriodLog, TTL, and Features fields shall be set to
0x00 and NetKeyIndex field shall be set to 0x0000."

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:22 +02:00
Anders Storrø
c51bb9c13b Bluetooth: Mesh: Update spec ref 1.0.1->1.1
Updates Bluetooth mesh specification references:

- Change "Profile" to "Protocol" since the main specification has
changed its name.
- Update/align formating of specification references. This will
make it easier to find spec references in the future.
- Change some section references to point to the correct section of the
newest version of the specification (v1.1).

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-25 14:50:14 +02:00
Vinayak Kariappa Chettimada
f64d123a3d Bluetooth: Controller: Fix missing ext adv terminate event
Fix missing Extended Advertising terminate event and
advertising scheduling not being stopped.

Under race conditions, auxiliary event is aborted without
the generation  of done extra event which is suppose to
stop the scheduling when max events count is used.

The fix now generates the done extra event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-24 15:12:18 +02:00
Vinayak Kariappa Chettimada
05c85ddbcf Bluetooth: Controller: Fix periodic advertising sync window
Fix periodic advertising sync window calculation to include
the scheduling resolution margin, i.e. be double as with
the event jitter value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-24 15:12:18 +02:00
Omkar Kulkarni
3de98643ed Bluetooth: Mesh: FU Server should not update internal state on error
According to conditions in the DFU spec section 6.1.3.7 (Sending a
Firmware Update Status message) and in 'Idempotency' part of section
6.1.3.4 (Receiving a Firmware Update Start message), the FU Server
should not update internal state when 'Wrong Phase' error condition
is triggered.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2023-10-24 09:05:59 +02:00
Andries Kruithof
e3d6aac5c0 Bluetooth: ISO: use IN_RANGE for CIG create parameters
Use IN_RANGE instead of explicitly checking that a value is
in between two other values

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-23 15:22:10 +02:00
Andries Kruithof
8b3b8cf2ad Bluetooth: ISO: extend API for setting SDU interval
The BT Core Spec v5.4 allows separate SDU_Interval to
be set on C_To_P and P_To_C directions,
but this is not possible with the existing interface.

This PR splits the interval parameter in the call to
bt_iso_sig_create into one for C_To_P
and one for P_To_C

It also splits the latency parameter into one for
C_To_P and one for P_To_C

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>

Bluetooth: ISO: update UI for extended API

The API for setting the SDU interval and latency have been updated.
This PR also updates the setting of these by the user in the shell
and the iso_connected_benchmark sample

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-23 15:22:10 +02:00
Aleksander Wasaznik
9f42c92e26 Bluetooth: Host: Fix GATT Long Read for EATT
When EATT is established, the value returned from `bt_att_get_mtu` is
not useful to determine the ATT_MTU that applies to a ATT response. This
is because `bt_att_get_mtu` may return the value for a different bearer
than the request is serviced on.

To fix this, the params struct for the GATT read operation is given a
new field that will record the ATT_MTU that applies to this ATT
operation. This value is then used to determine if the GATT long read
operation is concluded.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/61741

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-10-23 11:01:21 +02:00
Jordan Yates
7aa34e6482 bluetooth: hci_core: handle NUM_COMPLETED_PACKETS rsp
The `BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS` is not expected to generate a
response from the controller, but from the spec:

Normally, no event is generated after the
HCI_Host_Number_Of_Completed_Packets command has completed. However, if
the HCI_Host_Number_Of_Completed_Packets command contains one or more
invalid parameters, the Controller shall return an HCI_Command_Complete
event with a failure status indicating the Invalid HCI Command
Parameters error code.

In practice, this can also be generated if flow control is inadvertedly
turned off during operation. Running `hci_cmd_done` is not correct when
the event happens (as there is no corresponding command buffer), and
`ncmd` should not be returned as this command ignores the semaphore when
sending.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-10-20 15:16:54 +02:00
Anders Storrø
0a25a61c7d Bluetooth: Mesh: Op agg mdl coex
Refactors the implementation of the Opcode Aggregator
models to allow them to coexist on the same device.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:16:33 +02:00
Håvard Reierstad
765b31979f Bluetooth: mesh: update model extension
Adds a goto statement to ensure that model extensions are registered
in Composition Data Page 1 if it is enabled.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-20 15:14:41 +02:00
Ludvig Jordet
c613e23b4a Bluetooth: Mesh: Fix issue where dfu_cli could get stuck
This fixes an issue where the DFU client could get stuck trying to
transmit a message to servers if the DFU client was misconfigured, for
instance missing application key or network key.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2023-10-20 15:13:53 +02:00
Pavel Vasilyev
337ba330a2 Bluetooth: Mesh: Allow to set the extension list size to zero
If instantiated models don't have any relations at all, then the
extensions list will be empty. We should allow to disable it at all
to not waste RAM.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-20 15:13:35 +02:00
Emil Gydesen
f58bea6b7b Bluetooth: BAP: Scan Delegator bis_sync_req cb called on rem
If a receive state is removed, then the bis_syn_req callback
will be called with 0x00000000, to indicate to the application
that the sink should be desynced.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:10:37 +02:00
Emil Gydesen
8e9b2c745a Bluetooh: BAP: Fix issue with SRC_ID_VALID flag
The flag was not properly set when the broadcast sink
did not add the source (e.g. if a broadcast assistant
added it).

This also downgrades two LOG_WRN to LOG_DBG as they may
happen without indicating an issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:10:37 +02:00
Pavel Vasilyev
5b8a9517a1 tests: bluetooth: tester: Allow to compile mesh without LPN
This can be needed to qualify features without LPN support.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-20 15:09:25 +02:00
Pavel Vasilyev
6a2c102aca Bluetooth: Mesh: Keep sending Partial Block Report message
When the BLOB server is in Pull mode and all chunks were received for
the current block, and the current block is the last block, then
according to section 5.2.4 of MshMBTv1.0 the server should stop sending
BLOB Partial Block Report messages if it determines that the client
knows that the transfer is complete:

```
While the Pull BLOB State Machine is in the All Chunks Received state,
the Pull BLOB State Machine continues to send the BLOB Partial Block
Report messages until one of the following happens:
•  The Receive BLOB Timeout timer expires.
•  If the current block is not the last block, then the client starts a
new block, in which case a new Pull BLOB State Machine is instantiated.
•  If the current block is the last block, then the server determines
that the client knows the transfer is complete. For example, a
higher-layer model may indicate that the client considers the transfer
complete.
```

We currently don't have any OOB mean (for example, API) to determine
whether the client knows that the transfer is complete. We also need to
keep in mind that the Partial Block Report message can get lost so one
transmission may not be enough. The client could immediately send BLOB
Transfer Get message to get the transfer status, but this goes against
its state machine defined in section 6.2.4.2, where a Block transmission
completes when a BLOB Partial Block Report message is received with an
empty list of requested chunks (table 6.4, figure 6.1).

Because of this, we need to keep sending Partial Block Report messages.
We can keep sending them at least until Block Report timer expires.
If the client sends BLOB Transfer Get message, then it finished with
sending the block and we can change the phase and finish the transfer.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-20 15:09:25 +02:00
Anders Storrø
0ce77c227b Bluetooth: Host: CMake dependency for Mesh Bsim
Links host to mbedTLS library if Bluetooth Mesh is enabled, and
CONFIG_BT_TESTING=y.

Bluetooth Mesh has test dependencies in the host.
In order to compile Bsim tests with these test features
and PSA enabled, the libraries must be linked.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:07:51 +02:00
Emil Gydesen
a38d534ae0 Bluetooth: BAP: Shell: Add better checks for bis_sync
Since the BIS indexes start at 0x01, then BIT(0) is a
invalid BIS sync value and shall not be sent by the
broadcast assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:05:51 +02:00
Emil Gydesen
779f725db3 Bluetooth: CAP: Add verification of CCIDs as the initiator
When the initiator provides CCID in the metadata, we verify
that the CCIDs exist on the device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:05:33 +02:00
Troels Nilsson
7d96c997e2 Bluetooth: Controller: Fix endianness issues for SyncInfo
Fix bitfield crossing byte boundary - replaced with macros for
setting/getting the values

Fix missing endianness conversion for evt_cntr

Changed aa from uint32_t to uint8_t[4] to align with the rest of
the code and avoid any potential endianness issues

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-10-20 15:05:20 +02:00
Emil Gydesen
3b58fec96c Bluetooth: CAP: Add size and rank checks for CAS register
For the CAP acceptor the size and rank characteristic shall
be set as per the CAP spec. Add checks for 0, as 0 indicates
not initializing the characteristics in the CSIS instance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:05:00 +02:00
Anders Storrø
6f2ebb963a Bluetooth: Mesh: Add proxy test API
Adds internal proxy API to enhance testabillity of
the proxy implementation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:04:54 +02:00
Anders Storrø
5551b4cfad Bluetooth: Mesh: Priv net id parse on proxy cli
Adds parsing of Private Network Identity parsing in the proxy client,
allowing the client to use these messages to establish a GATT
connection.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-20 15:04:54 +02:00
Rubin Gerritsen
65501061ed Bluetooth: Controller: Kconfig: Move out BT_LL_SW_SPLIT configs
BT_CTLR_ISOAL_LOG_DBG_VERBOSE, BT_CTLR_ISO_TX_SEG_PLAYLOAD_MIN, and
BT_CTLR_CONN_ISO_AVOID_SEGMENTATION are very tied to the BT_LL_SW_SPLIT
implementation. It is very unlikely that these will ever be used by
another controller

Therefore move them out to the BT_LL_SW_SPLIT specific configuration
file. This will likely create less confusion when using another
controller.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-10-20 15:03:46 +02:00
Emil Gydesen
6054714a08 Bluetooth: BAP: Add PSN debug log support
Add a Kconfig that enables support for logging and
debugging invalid sequence numbers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:02:55 +02:00
Michele Imbriani - Oticon
b435dc1c6a bluetooth: shell: Fixed logic in is_substring function
Fixed the character check in is_substring function.

Signed-off-by: Michele Imbriani - Oticon <mbim@demant.com>
2023-10-20 15:02:28 +02:00
Emil Gydesen
a2ab57c240 Bluetooth: Audio: Update bsim and shell to use codec set chan alloc
Update the BSIM test and the shell to use
bt_audio_codec_cfg_set_chan_allocation rather than implementing
their own versions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 15:00:27 +02:00
Emil Gydesen
f67f840def tests: Bluetooth: Add tx/rx and data verification for BAP unicast
The BAP unicast babblesim tests now does RX and TX
and verifies that the data is correctly received on both
the client and server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:56:28 +02:00
Emil Gydesen
9c47eb924f Bluetooth: Audio: Refactor codec_cfg_get_frame_duration_us
Refactor the codec_cfg_get_frame_duration 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-10-20 14:56:13 +02:00
Lingao Meng
c2b2641fc1 Bluetooth: Mesh: Move ext adv sector to vector
Obviously, it looks obscure by putting it in a sector,
so, let's move to vector.

refs: https://github.com/zephyrproject-rtos/zephyr/pull/57883

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Lingao Meng
1b22324317 Bluetooth: Mesh: Use system workqueue for dhkey gen
Since the default process dhkey gen in bt rx, will block send
Trans Ack, cause peer device send more package.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Lingao Meng
141467a261 Bluetooth: Mesh: Rename adv relay to adv simultaneous
Since notice that simultaneous advertising is not only used
by relay message, provision over pb-adv can also be used.
so it was changed to a more general name.

refs:https://github.com/zephyrproject-rtos/zephyr/pull/48903

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Lingao Meng
b14d235c31 Bluetooth: Mesh: Remove bits for adv tag
since tag for buf single only, no need for bit, also for
save some memory for rfu.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00
Mariusz Skamra
49e7030363 Bluetooth: audio: has: Minor logging improvement
This adds more logs for debugging purposes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
27049744b9 Bluetooth: audio: has: Remove include of conn_internal header
This makes use of bt_conn_get_info function to access the conn address.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
df1fd21892 Bluetooth: audio: has: Truncate Control Point notifications to ATT MTU
This will truncate ATT notifications/indications if exceed ATT MTU size.
It is up to the client to exchange MTU.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
b0e7a1b0ac Bluetooth: audio: has: Fix missing memset of parameters
This fixes missing memset of parameters used for indications and/or
notifications.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
4d023023a3 Bluetooth: has: Fix preset list notifications after reconnection
This fixes sending proper Preset List notifications after
reconnection. The issue was observed when the last preset
known to the client has been removed.
As we do not hold the information about the deleted presets,
we need to use Generic Update procedure to:
 1. Notify the presets that have been removed in range
    (PrevIndex = current_preset_last, Index=previous_preset_last)
 2. Notify deletion of preset Index=previous_preset_last.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
a7406aa8f4 Bluetooth: has: Factor out bonded client persistent data
Some of the data shall be persistent across connections to bonded
clients. This includes notidication state flags that are used to
determine whether notify bonded client after reconnection.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
9c6419c615 Bluetooth: audio: has: Refactor preset list to single-linked list
This refactors the preset list to use sys_slist API. There have been
various issues seen while iterating presets, thus it's more save to use
well-defined and tested sys_slist API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
31e329bb2d Bluetooth: audio: has: Defer notifications to sysworkq
Defer sending the features, active index, preset list and preset read
response to sysworkq and retry sending in case failed due to buffers not
available at the moment.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
2735339a82 tests: Bluetooth: has: Add test Preset Changed Offline Behavior
Verify that a HAS Server IUT sends changed characteristic notifications
or indications when the Lower Tester reconnects.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
b89cdadc74 Bluetooth: audio: has: Factor out set_preset_availability function
This moves common code to set_preset_availability function to be called
from bt_has_preset_available and bt_has_preset_unavailable.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
f63726da79 Bluetooth: audio: has: Fix sending notifications on reconnect
This fixes missing setting of FLAG_CONTROL_POINT_NOTIFY flag that
indicate whether submit control_point_work. In case the there are more
indications/notifications to sent (is_last flag is unset), the
FLAG_CONTROL_POINT_NOTIFY shall be set to resubmit control_point_work.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
c44f0da4f1 Bluetooth: audio: has: Don't revert features value on error
This removes revering the features value back to previous state if work
submission failes. Even if it fails it indicates an internal sysworkq
issue, so even retry won't help. The client can read the features value
anyway, thus it's sane to just log an error in such case.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
cf2f2df61d Bluetooth: audio: has: Fix indentation
This fixes code indentation.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Mariusz Skamra
b10f02da61 Bluetooth: audio: has: Fix checking wrong flag
This fixes testing and clearing features flag.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-20 14:53:37 +02:00
Emil Gydesen
84c01bb527 Bluetooth: Audio: Add ISO test parameters to the BAP API
Add support for the ISO test parameters in the BAP API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:50:48 +02:00
Emil Gydesen
0521ffd5a3 Bluetooth: ISO: Rename BT_ISO_ADVANCED to BT_ISO_TEST_PARAMS
Rename the Kconfig option from BT_ISO_ADVANCED to
BT_ISO_TEST_PARAMS to more explicitly denote that it
enables support for using the ISO test parameters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-20 14:50:48 +02:00
Mariusz Skamra
3828f1cec2 Bluetooth: ascs: Check subscription state on ASE notification
Check whether peer is subscribed for ASE state notification before
calling bt_gatt_notify. This handles an assert thrown when the
notification failed to be sent.

Fixes: #63728
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-12 18:48:09 +03:00
Emil Gydesen
c47b7f7936 Bluetooth: BAP: Broadcast sink: Clear pa_sync on PA terminated
If the PA gets terminated, we clear the pa_sync field of the
corresponding broadcast sink object.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:19:46 +03:00
Emil Gydesen
00deb0ea75 Bluetooth: BAP: Remove static from state_changed in mod_src
For some reason the state_change variable was static, which
does not make any sense. Changed it to a regular local
bool in bt_bap_scan_delegator_mod_src.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:18:42 +03:00
Emil Gydesen
58e40239fd Bluetooth: BAP: Scan delegator missing state change for bis_sync
If the bis_sync value changes, that should trigger a state change
notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:18:42 +03:00
Aleksandr Khromykh
00457ae6c6 Bluetooth: Mesh: improve solicitation debug logging
Commits adds debug logging for all reasons
preventing of the proxy solicitation.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-10-12 18:07:50 +03:00
Aleksandr Khromykh
625faa7f03 Bluetooth: Mesh: fix proxy solicitation
Commit makes workable proxy solicitation functionality
only server part without dependencies on client part.
Only on demand proxy server is required.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-10-12 18:07:50 +03:00
Pavel Vasilyev
0af523eba7 Bluetooth: Mesh: Fix failing DFU/SR/FD/BV-08-C test
The `upload_status_rsp_with_progress` function uses the currently set
slot pointer to set firmware id field in the message. If another
upload starts but the firmware is already received, the slot API won't
let us to set the fwid and will return an error code. In this case, the
slot pointer stays invalid as fwid wasn't set, and
`upload_status_rsp_with_progress` will not add fwid as the lenght is
zero.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-12 15:29:45 +03:00
Pavel Vasilyev
5cf6218c62 Bluetooth: Mesh: Fix Capabilities Status message with OOB upload enabled
The `else` case was incorrectly excluded by preprocessor.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-12 13:59:06 +03:00
Vinayak Kariappa Chettimada
7ee427ff58 Bluetooth: Controller: Fix CIS encryption when DF support enabled
Fix hung Controller when establishing CIS on an encrypted
ACL connection with Controller built with direction finding
support enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-12 09:48:54 +03:00
Emil Gydesen
de67ec9e67 Bluetooth: BAP: Fix broadcast source reconfig with subset of streams
When the bt_bap_broadcast_source_reconfig was supplied with a subset
of the streams, it would only update the codec cfg and qos for the
streams provided in the parameters.

This commit changes that, so all streams are properly updated,
as they share some common values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:41:30 +03:00
Emil Gydesen
7339849077 Bluetooth: BAP: Broadcast Sink should not terminate the PA Sync
When calling bt_bap_broadcast_sink_delete, the broadcast sink
should not attempt to terminate the PA Sync. The PA sync can live
on without the broadcast sink, just as the broadcast sink can live
on without the PA sync (which is why the PA sync check was completely
removed).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:40:41 +03:00
Emil Gydesen
37b6ddd918 Bluetooth: BAP: Broadcast Sink only set synced BIS indexes
When updating the Scan Delegator receive state, we shall only
set the BIS indexes in bis_sync that we are actually synced to.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:33:55 +03:00
Pavel Vasilyev
2c9fc043d7 Bluetooth: Mesh: Print URI and FWID in Upload OOB Start msg
this is useful for debugging.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev
d1c2ca2525 Bluetooth: Mesh: Release previously reserved slot before reserving again
If the previous upload was in-band and it didn't complete, the slot will
stay reserved. By design we release slot not at the end of the upload
phase, but at the start of a new upload phase.

This fixes DFU/SR/FD/BV-13-C.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev
7154f356af Bluetooth: Mesh: Ignore duplicate OOB upload request
If a Fw Distribution Client sends the Upload OOB Start message, but the
application layer didn't call bt_mesh_dfd_srv_oob_check_complete yet,
we have no other option other than ignore the message. The next phase
in this case could be Transfer Active, Transfer Success or Failed and it
will be set only after Check Firmware OOB procedure completes.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev
1329a9d312 Bluetooth: Mesh: Fix Fw Dist Upload OOB Start msg length check
This message _at least_ 2 bytes long, but can be longer, thus
BT_MESH_LEN_MIN should be used.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev
9641864a20 Bluetooth: Mesh: Fix Upload Progress for already received fw
In OOB upload, when Check Firmware OOB procedure completes successfully
and the firmware is already received, we send Firmware Distribution
Upload Status message with update Phase set to Transfer Success. In this
case, we must set Upload Progress to 100%. This can't be done through
the callback as the application layer doesn't yet know that the firmware
is already received. This will happen by the exist from
bt_mesh_dfd_srv_oob_check_complete function, which will return error
code -EEXIST.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Mariusz Skamra
916df03e7a Bluetooth: ascs: Fix Source ASE link loss state transition
According to the ASCS_v1.0 the ASE in Streaming state shall transit to
QoS Configured state when link loss happen.

Relates: ES-24215 (errata)
Fixes: BAP/USR/SCC/BV-168-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-10 15:18:37 +03:00
Flavio Ceolin
e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Pavel Vasilyev
68365d5b67 Bluetooth: Mesh: Reset targets state before starting DFU on DFD srv
The list of receives in the Firmware Distribution Server model and
and the Firmware Update Client model are 2 different lists.

In the Firmware Update Client model it is called the Update Receives
state and the Active Update Receivers state which is a subset of
receivers from the Update Receivers State. In the Firmware Distribution
Server model it is called the Distribution Receivers List state.

When Distribute Firmware procedure starts, in the Initiate step, the
Receivers List input (which is the input for the Update Receivers
state), is composed of the Distribution Receives List state. During DFU,
the Update Receivers state becomes the Active Update Receivers state
which keeps only active nodes. Timed out or failed nodes dropped out
from this list. The Distribution Receivers List state stays unchanged
and thus don't need to be populated again after every successfull and
failed DFU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-09 16:18:53 +03:00
Håvard Reierstad
3d40d91f86 Bluetooth: mesh: access: Fix model relation register
Added offset to the model relation register for vendor
models to find correct model index
for Composition Data Page 1. The previous implementation used the
'mod_idx' from the 'bt_mesh_model' struct, which led to issues in the
model relation register due to SIG and vender models having the same
model index.
Modified existing functions related to the model relation
register to take in the offset.

Modified macros for determining if a model is a base- or
extending model.

Added check in 'add_items_to_page' to check whether the model relation
is an extension.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-09 15:06:06 +03:00
Håvard Reierstad
ea753eb52a Bluetooth: mesh: Change cfg_cli buffer length check
Changed buffer length check in bt_mesh_comp_p1_elem_pull.
The previous threshold would result in the
method not detecting the final element when it consisted of just one
model.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-09 15:06:06 +03:00
Dennis Grijalva
b122685eff bluetooth: conn: Fix compiler warning
When compiling conn.c using arm-none-eabi-gcc version 11.3.1 20220712
with the -Wmaybe-uninitialized flag a warning is emitted due to
pending_no_cb not being initialized. I'm not sure if initializing it to
NULL is the "correct" fix, but it's certainly not any worse then it being
uninitialized, and it fixes the warning.

Signed-off-by: Dennis Grijalva <dennisgrijalva@meta.com>
2023-10-08 18:17:22 +03:00
Carles Cufi
f2af4a7bfd Bluetooth: host: document the connection states
Connection states are non-trivial to understand based on their names
only, so add short descriptions in the header file explaining what they
do.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 17:50:03 +03:00
Fredrik Danebjer
fefbb28edb Bluetooth: Audio: Fix return code in PACS notify
Fix errenous return value in pacs_gatt_notify function. The function
would always return zero, and not forward the error correctly.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-10-06 17:43:08 +03:00
Pavel Vasilyev
f4a592f3bb Bluetooth: Mesh: Don't reset mod pointer
Don't reset values set in init callback as it is called only once by
bt_mesh_init call. The reset callback is called on every node reset.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-06 16:47:09 +03:00
Anders Storrø
65f029e185 Bluetooth: Mesh: Common comp page parse func
Create common composition page parser function.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-06 16:21:02 +03:00
Anders Storrø
57cb1b1ccb Bluetooth: Mesh: Add missing comp pages to LCD mod
Adds support for all composition data pages to the
Large Composition Data model.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-06 16:21:02 +03:00
Carles Cufi
ee0314a832 Bluetooth: host: Replace length check assert with if statement
A few of the length checks that deal with HCI packets coming from the
controller were using assert statements. But the recommended practice is
to drop invalid packets and continue execution whenever a malformed
packet arrives from an external source, so replace those assert
statements with branches that will drop the packet and return.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 16:18:43 +03:00
Ingar Kulbrandstad
a5d15ec017 Bluetooth: Mesh: Fixed issue with RPR server and client.
Fixed issue when reprovisioning is done on a device with
both RPR client and server on the same device.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-10-06 16:06:12 +03:00
Andries Kruithof
e8716bf793 Bluetooth: controller: change calc for data in PDU
The existing formula for the amount of data that can be filled
in in the current PDU is correct but confusing. Replace it with
a simpler formula.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-06 16:04:11 +03:00
Andries Kruithof
d00d44c925 Bluetooth: controller: fix failing EBQ advertising tests
Updates the chaining for advertising.
Instead of unconditionally adding a new PDU when new data
is added we now instead fill the last PDU in the chain with
the incoming data, only adding a new PDU when there is
not enough room.

This reduces the nr. of PDUs used for advertising, and also
fixes some qualification failures

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-06 16:04:11 +03:00
Emil Gydesen
af953a1d07 Bluetooth: BAP: Fix bug in BASE bis index
The indexes were reset to 0 for each subgroup, which meant
that if we had a broadcast source with 2 subgroups and
1 BIS in each, both of them would use index 0x01.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-06 12:21:42 +01:00
Jonathan Rico
b1da312e9d Bluetooth: ATT: discard RX on a disconnected connection
A race condition between ATT RX and the connection teardown can happen, as
the teardown is executed from a workqueue.

For example:
- connection is established
- `connected` cb is called (in BT RX context)
- user calls `bt_conn_disconnect` in that cb
- connection is marked as disconnecting
- ATT teardown & general conn cleanup is scheduled
- BT RX gets an ATT request, tries to handle it
- ATT bearer is still not GC'd, so it tries and fails to send it
  -> results in error message "not connected" on log
- ATT teardown & general conn cleanup runs

To avoid that, we not only check the bearer state, but also its ACL conn
state.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-10-06 12:19:39 +01:00
Vinayak Kariappa Chettimada
e50748b67c Bluetooth: Controller: Fix leak in scheduled ticker node
Fix leak in scheduled ticker node when rescheduling ticker
nodes.

Applications having active Extended Advertising or Observer
role with the use of ticker reschedule in window feature
would experience assertion check failure due to delayed
radio event preparation or stalled controller with no active
roles.

Fix updating of the ticker linked list when handling
rescheduled tickers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-06 12:54:12 +02:00
Vinayak Kariappa Chettimada
7495846b62 Bluetooth: Controller: Rename ticker reschedule variables
Rename ticker reschedule in window variable to improve
readability.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-06 12:54:12 +02:00
Carles Cufi
a5e7ba3564 Bluetooth: Controller: Remove legacy BT_CTLR_FAST_ENC option
When the legacy LLCP implementation was removed this Kconfig option was
mistakenly left over. Remove it now with all its users.

Fixes #63212.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 13:32:33 +03:00
Andrzej Głąbek
cb1b1ce7d1 bluetooth: common: Kconfig: Add missing dependency for BT_MONITOR
This module calls `log_output_*` functions so it should enable
the `LOG_OUTPUT` Kconfig option explicitly.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-10-06 11:42:40 +03:00
Emil Gydesen
147cef6660 Bluetooth: Controller: Add hdl checks in isoal.c
Add checks to verify the `hdl` parameters before accessing
the sink and source arrays.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-05 15:25:17 +02:00
Emil Gydesen
f4221d66c1 Bluetooth: Controller: Make aa in radio_aa_set const
Make the aa argument const to solve a Coverity issue
that assumes that any value that is being byteswapped
is tainted. Making the argument const should avoid
this assumption from Coverity.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-05 15:25:09 +02:00
Andries Kruithof
c5d844fe41 Bluetooth: controller: fix comparision of unsigned int to 0
Fix the coverity issue CWE570, comparison of unsigned int to 0
in the definition of IS_SYNC_ISO_HANDLE

There is a potentially the same issue for IS_ADV_ISO_HANDLE,
fixed that as well

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-05 15:24:54 +02:00
Aleksandr Khromykh
0ba6e80a12 Bluetooth: Mesh: fix settings work queue size for rpr
If RPR server is used then Mesh settings work queue
requires more size during provisioning procedure.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-10-05 09:44:00 +01:00
Emil Gydesen
e962fda0ee Bluetooth: Audio: Fix BAP Broadcast source reconfig param count
The check for number of streams in a subgroup was reversed, so
it would never allow for correct values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-05 09:19:56 +02:00
Mateusz Kapala
7a1b194a97 bluetooth: host: smp: Add runtime check for central-specific path
Added run-time BT_CENTRAL role check for the path that was
central specific and did not have such check.

When multi-role BT device tried to pair without bonding (peripheral role)
while already previously bonded with the same device on another
Bluetooth identity, pairing failed.
It executed central-specific code, which should not be executed in case
when the device acts as peripheral (as it is even opt-out from code when
CONFIG_BT_CENTRAL is not enabled).

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
2023-10-04 14:53:26 +01:00
Emil Gydesen
c6cecef120 Bluetooth: Controll: Fix dead code in ll_setup_iso_path
In ll_setup_iso_path cis is only ever set if CONFIG_BT_CTLR_CONN_ISO
is enabled, and similarly adv_stream is only ever set if
CONFIG_BT_CTLR_ADV_ISO is enabled.

The two assignments were reported as dead code by Coverity due
to this, which has been fixed by guarding the code with
the respective Kconfigs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-04 14:52:54 +01:00
Rait Rääk
6c2da47e4c bluetooth: conn: Fix forced pairing request handling
BT_SECURITY_FORCE_PAIR option gets overridden when CONFIG_BT_SMP_SC_ONLY
or CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY is defined. Cache the bit value
before overrides.
Add explicit forced pair handling to existing security level check.
Functionality did not change as this was done implicitly due to integer
comparison for enums.
Add extra clarification to the method doc.
Signed-off-by: Rait Rääk <raitraak@gmail.com>
2023-10-04 14:49:58 +01:00
Emil Gydesen
89db200117 Bluetooth: Controller: Remove unused terminate_ack
Remove the terminate_ack from struct ll_conn since it is
not used anywhere, and results in dead code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-04 10:08:07 +02:00
Alperen Şener
fe6fb0f467 bluetooth: mesh: fix static oob auth padding
The remaining bit should be zero if auth is
shorter than PROV_AUTH_MAX_LEN and it should
be trimmed by removing octets with indexes
higher than PROV_AUTH_MAX_LEN.

Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
2023-10-04 10:07:55 +02:00
Emil Gydesen
2248394327 Bluetooth: Audio: Fix issues when setting new cfg values
Fix issues when setting new values in cfg that modify
the length of the codec configuration LTV value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-03 09:21:20 +02:00
Ivan Iushkov
c650f6aea0 Bluetooth: documentation change of kconfig.iso configs
Added comment to KConfig.iso file to make description
of BT_ISO_TX_MTU and BT_ISO_RX_MTU more clear

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2023-10-02 22:58:58 +03:00
Ivan Iushkov
a4a196f002 Bluetooth: fix iso_has_ts field for SDU fragmented to multiple HCI packets
iso_has_ts wasn't set correcrly for fragments of HCI ISO Data packets,
now it is set depending on timestamp
provided in the original buffer provided by host user

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2023-10-02 22:58:58 +03:00
Ivan Iushkov
4f5323a1cf Bluetooth: fix HCI ISO Data packets fragmentation
this commit partially reverts e460847b60

According to Core Spec 5.4, Vol. 4, Part E, 5.4.5, Data_Total_Length field
contains length of the whole packet including optional fields of SDU
(Time_Stamp, Packet_Sequence_Number, ISO_SDU_Length, RFU and
Packet_Status_Flag). In Zephyr Host, Data_Total_Length value
is stored in bt_dev.le.iso_mtu field.
Therefore, there is no need to calculate iso_hdr_len(),
this length is already taken into account in conn_mtu(conn).

This commits removes iso_hdr_len() function and fixes
calculation of HCI ISO Data packet length calculations.

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2023-10-02 22:58:58 +03:00
Vinayak Kariappa Chettimada
48c83a1f42 Bluetooth: Controller: Fix num cmplt for BIS HCI ISO Data fragments
Fix number of completed packets generated when BIS HCI ISO
Data packets sent to Controller are in fragments. Use the
ISOAL stored sdu_fragment count to generate the number of
completed packets count.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 11:36:33 +02:00
Vinayak Kariappa Chettimada
a178aa9855 Bluetooth: Controller: Review rework flush timeout support
Review rework changed related to flush timeout support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
291cd03818 tests: bsim: Bluetooth: Test RTN=2, FT=2, Cen skip 2 SE in Controller
Test RTN=2, FT=2 in Controller with 2 subevents dropped by
central.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
2935d3b731 tests: bsim: Bluetooth: Test RTN=2, FT=2, Per skip 2 SE in Controller
Test RTN=2, FT=2 in Controller with 2 subevents dropped by
peripheral.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
61d00467b4 Bluetooth: Controller: Option to ignore Tx ISO Data Packet Seq Num
Kconfig option to turn off ISO Data Packet Sequence Number
use to place the ISO Data in the correct radio event,
instead simply buffer it to next radio event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
e3ecab3142 Bluetooth: Controller: Fix ISO Data timestamp when FT > 1
Fix ISO data timestamp to reflect the SDU reference point
and not the ISO event anchor point when PDUs received after
retransmissions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
7fa77a67fc Bluetooth: Controller: Use of payload_count for Flush Timeout
Use of payload_count for supporting flush timeout in
Central and Peripheral ISO Lower Link Layer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Vinayak Kariappa Chettimada
7a14830d85 Bluetooth: Controller: Remove HCI ISO data with invalid status
Remove incorrect implementation of HCI ISO data with invalid
status.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-02 10:00:27 +02:00
Emil Gydesen
f5dd62bbec Bluetooth: Audio: Update codec_cfg_get_chan_allocation
Update the function name from codec_cfg_get_chan_allocation_val
to just codec_cfg_get_chan_allocation, and add
codec_cfg_set_chan_allocation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 16:29:58 +02:00
Alperen Şener
05e806d31d bluetooth: mesh: check upload slot before release
Check if the slot is not reseved, NULL before try to
releas it.

Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
2023-09-29 16:26:42 +02:00
Emil Gydesen
c8a79e1fc1 Bluetooth: Audio: Add codec_cfg_set_frame_blocks_per_sdu
Add the bt_audio_codec_cfg_set_frame_blocks_per_sdu function
to set or add the frame blocks per SDU field in the
codec configuration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 16:25:17 +02:00
Alberto Escolar Piedras
2243d7b717 Bluetooth controller nrf: Provide radio hal header for simulated nrf5340
Provide a radio HAL header for the new nrf53 bsim target

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-29 16:21:43 +03:00
Alberto Escolar Piedras
48f70eba2b Bluetooth: Controller: Fix clang warning on ull
Fix a clang warning
ull.c:1235: warning: use of bitwise '|' with boolean operands

The result of ({1/0} &&(int)) is either true(1) or false(0),
not the int and therefore bm is not a bitmask, but just true(1)
or false(0) all together.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-29 15:07:34 +02:00
Vinayak Kariappa Chettimada
303ce143c2 Bluetooth: Controller: Fix regression in Adv PDU overflow calculation
Fix regression in Adv PDU payload length overflow
calculation.

Regression in commit de8c19da5e ("Bluetooth: controller:
Handle fragmented AD without chaining PDUs").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-29 15:41:14 +03:00
Emil Gydesen
5656c23243 Bluetooth: Audio: Add codec_cfg_set_octets_per_frame
Add the bt_audio_codec_cfg_set_octets_per_frame function
to set or add the octets per frame field in the
codec configuration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 09:46:58 +02:00
Emil Gydesen
8ab3fbf570 Bluetooth: Audio: Split bt_audio_codec_meta_get to cfg and cap
Split the bt_audio_codec_meta_get functions to cfg and cap
variants. This provides a more explicit API where users
do not need to dereference their cfg/cap structs in order
to use this functions.

Furthermore this will also make the get functions more
similar to the upcoming set functions, where the set functions
will require the use of the cfg and cap structs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-29 09:46:15 +02:00
Armin Brauns
4c8866243d bluetooth: disable BT_ATT_ENFORCE_FLOW for BlueNRG devices
The firmware on these devices seems to have a bug that can cause reordering
of received packets. This can lead to new GATT requests being received
before the acknowledgement of the previous GATT response, accompanied by
log messages like the following:

<wrn> bt_att: bt_att_recv: Ignoring unexpected request

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-09-29 09:45:48 +02:00
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
Erik Brockhoff
1de8a76f58 Bluetooth: controller: adding API for unmasking peer features
For asymetrical features there needs to be a separate mechanism to
unmask features in peer. This must be used in central for unmasking in case
of 'unsupported in peer' condition for CIS Create.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-09-28 14:05:00 +02:00
Erik Brockhoff
730f7caa21 Bluetooth: controller: add missing NTF alloc in central CIS Create
If a CIS create is requested prior to having a complete feature exchange
the central will initiate a feat exch before enqueing the CIS create.
IF then the feature exchange results in peripheral NOT supporting
CIS create the central needs to allocate an RX node for the NTF

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-09-28 14:05:00 +02:00
Vinayak Kariappa Chettimada
28ed48cbac Bluetooth: Controller: Fix connected ISO dynamic tx power
Fix connected ISO dynamic tx power support compilation
error.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-28 13:31:40 +02:00
Jonathan Rico
c1baa8282d tests: Bluetooth: Add ATT sequential procedures test
The purpose of this test is to prove that the zephyr host can handle the
behavior described in the Bluetooth Core Specification Vol.3 Part.F
3.3.2 "Sequential protocol".

The host should be able to handle all of those in parallel: one
indication, one write request, multiple commands and multiple
notifications.

The "tester" part had to be written with a "tiny host" implementation
instead of the Zephyr host, as the ZH conflates GATT client and server
and doesn't allow a device to enqueue an ATT request + an ATT indication
on the same bearer.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-28 14:21:27 +03:00
Jonathan Rico
7093538c42 Bluetooth: att: don't re-use the ATT buffer for confirmations
If the peer is a zephyr host, there is no problem, as the Zephyr
host limits sending parallel REQs and INDs.

But the spec allows sending those in parallel, and it may end up that
the re-used REQ buffer hasn't been destroyed when an indication comes.

Only re-use the buffer when enqueuing ATT responses.

This means that we may run out of buffers if the peer sends too many
indications and our application also sends a lot of commands/notifications.

The rationale for this is that having to handle a lot of requests is a
more plausible scenario (e.g. being discovered by multiple peers) than
handling lots of parallel indications.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-28 14:21:27 +03:00
Vinayak Kariappa Chettimada
3bfeadfa4a Bluetooth: Controller: Fix ULL_HIGH ticker operations count
Fix ULL_HIGH ticker operations count, it is discovered in
new BabbleSim test implementations that mesh tests using
Extended Advertising and Scanning enqueue upto 4 ticker
operations before ULL_LOW ticker_job could process it.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-28 13:21:05 +02:00
Piotr Narajowski
54126ec4e5 bluetooth: audio: Add API to get VCP service ATT handles
This is needed for upper tester.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
2023-09-28 13:16:23 +02:00
Emil Gydesen
cbf7312e37 Bluetooth: Controller: ISO: Fix compile issue with unicast
There was a case where TICKER_ID_ADV_AUX_BASE was not available
but was attempted to be used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 13:12:19 +02:00
Emil Gydesen
c2328a7bc3 Bluetooth: ISO: Fix issue with bt_iso_cig_reconfigure
bt_iso_cig_reconfigure would almost always fail due to invalid
checks that did not take the functioner properly into account.

The CIS provided to bt_iso_cig_reconfigure can now be allocated
beforehand, if the CIG for the CIS is the same as the one being
reconfigured.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-28 13:12:19 +02:00
Vinayak Kariappa Chettimada
1b0cb324f3 Bluetooth: Controller: nRF53: Fix back-to-back PDU chaining
Fix back-to-back PDU chaining using DPPI on nRF53x SoC.
Relates to commit b61bd2364c ("Bluetooth: Controller:
nrf53: Fix back-to-back Tx Rx implementation").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-28 09:35:33 +02:00
Théo Battrel
c2b99c0123 Revert "Bluetooth: Host: Fix GATT server handling of CCC"
This reverts commit cfd368fef1.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-09-28 09:21:57 +02:00
Théo Battrel
545f17b722 Bluetooth: Host: Fix SYS_SLIST_FOR_EACH_NODE_SAFE misuse
In `gatt_write_ccc_rsp`, the third field of
`SYS_SLIST_FOR_EACH_NODE_SAFE` was use as the `prev` sys_node when
calling `gatt_sub_remove`. This was wrong because the third field of
`SYS_SLIST_FOR_EACH_NODE_SAFE` is actually the next node.

Fix the issue by adding a pointer to the previous node and passing it to
`gatt_sub_remove`.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-09-27 15:48:49 +02:00
Vinayak Kariappa Chettimada
7af967a2f5 Bluetooth: Controller: Fix BIS payload sliding window overrun check
Fix BIS implementation for checking overrun of the BIS PDU
sliding window buffer overrun.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 15:48:38 +02:00
Dominik Ermel
dfccc473a6 Bluetooth: Host: Use memcpy instad of strncpy in bt_set_name
memcpy makes more sense here.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-09-27 15:48:25 +02:00
Aleksandr Khromykh
0e98a35e39 Bluetooth: Mesh: refactor mandatory oob for mesh1d1
Provisioner should be able to manage received capabilities
unconditionally. Mandatory oob authentication is the node
feature and it is still compile time feature.
Split handling of this feature on provisioner and node part.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-09-27 15:48:08 +02:00
Aleksandr Khromykh
236e3b64db Bluetooth: Mesh: shell supports 32 bytes static oob
Commit adds support of 32 bytes static oob in mesh shell.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-09-27 15:48:08 +02:00
Aleksandr Khromykh
707d1ed819 Bluetooth: Mesh: fix static oob setting
According to specification it is possible to provide
static oob value with any length. Mesh should trim or
append\prepend by zeroes if it is longer\shorter than
required value.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-09-27 15:48:08 +02:00
Vinayak Kariappa Chettimada
3c2b1f952c Bluetooth: Controller: Add BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX Kconfig
Add BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX Kconfig to allow the
omit of EVENT_OVERHEAD_START_US and EVENT_OVERHEAD_END_US in
the time reservation calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 15:47:45 +02:00
Vinayak Kariappa Chettimada
1ab007a2ba Bluetooth: Controller: Fix compile error when BT_CTLR_CENTRAL_SPACING=n
Fix compile error when CONFIG_BT_CTLR_CENTRAL_SPACING is
undefined.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 15:47:45 +02:00
Fredrik Danebjer
c2a13a0bec Bluetooth: Audio: Make CSIP delete bonds in cache locally
This change from using the mechanic of CONFIG_BT_KEYS_OVERWRITE_OLDEST
to instead handle the bonding cache through bond_deleted.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-09-27 15:47:33 +02:00
Fredrik Danebjer
078b00b155 Bluetooth: Audio: Add resend mechanic to CSIP notifications
Added retry mechanic to CSIP notifications by adding them into system
workqueue. Bookkeeping is done for notifications for all clients, and
potentially disconncted clients will also receive notifications on
reconnect. This also adds mechanic to restore the local clients list
upon registration of the service, as well as BSIMs to test notify on
reconnect.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-09-27 15:47:33 +02:00
Fredrik Danebjer
147796b36f Bluetooth: Audio: Change CSIP notification to use Atomic flags
Reformated csip_set_member to use atomic flags for notifications
instead of a pending notification array. This better conforms the
style of the code to how its done in other LE Audio services.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-09-27 15:47:33 +02:00
Vinayak Kariappa Chettimada
b61bd2364c Bluetooth: Controller: nrf53: Fix back-to-back Tx Rx implementation
Back-to-back Tx Rx implementation was incorrect for nRF53
that uses DPPI. Both current and next DPPI channels where
enabled in the implementation which only worked correctly
to have the right tIFS when current and next PDU length
were same.

Fix ensures that the correct current DPPI is subscribed
to by the radio subscribe.

The implementation has been refactor to be able to use the
current sw_tifs_toggle value in the HAL implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 09:52:53 +02:00
Vinayak Kariappa Chettimada
e39d98302d Bluetooth: Controller: nRF53: Cleanup dppi and dppi resources file
Minor cleanup typo, redundant conditional compile and
refinition.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-27 09:52:53 +02:00
Vinayak Kariappa Chettimada
652544e396 Bluetooth: Controller: Fix CIS assymmetric PHY usage
Fix CIS assymmetric PHY usage by adding implementation to
use correct PHY in radio when switching transceiver.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-26 17:45:18 +03:00
Vinayak Kariappa Chettimada
9e01c4df53 Bluetooth: Controller: nRF53: Fix missing NRF_CCM subscribe clear
Fix missing NRF_CCM subscribe clear which can lead to
spurious trigger of TASK_CRYPT in NRF_CCM. This may
lead to corruption of Rx PDU buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-26 15:09:31 +02:00
Vinayak Kariappa Chettimada
ed5883d9a0 Bluetooth: Controller: Use unique goto label in scan aux code
Use unique goto label in scan aux connect response ISR.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-26 15:08:07 +02:00
Alberto Escolar Piedras
292ca93795 Bluetooth controller nrf: nrf52 bsim radio hal fix
hal_radio_tx_chain_delay_ns_get() was incorrectly
returning the microsecond value, resulting in a 1us
error in the timing => Fix it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-26 11:43:43 +02:00
Alberto Escolar Piedras
865f3c1614 Bluetooth controller nrf: nrf52 bsim radio hal header minor updates
Align the header a bit with the one for the real radio,
adding missing Tx power levels and removing TODO which did not
need doing.
The old one originated as a copy of the nrf52833 one, and did not
evolve like the real ones.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-26 11:43:43 +02:00
Alberto Escolar Piedras
07bb88d28a Bluetooth: Controller: nrf: HAL for DPPI configuration cleanup
Remove a few macros which are not used anywhere in the tree.
For the sake of simplifying the header and easing its understanding.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-26 11:43:31 +02:00
Alberto Escolar Piedras
c5191ba5b7 Bluetooth: Controller: nrf: Use HAL for DPPI configuration
The following changes have been done:
1.
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_TASK(index)
  = HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_TASK(channel)
has been convered into
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_TASK(index, channel)

2.
HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_REGISTER_TASK(index)
  = HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_TASK
Which was only used in one place, has been replaced with the
equivalent HAL call

3.
HAL_SW_SWITCH_GROUP_TASK_ENABLE_PPI_REGISTER_TASK(index) = 0
was replaced with the HAL subscribe clear function
nrf_dppi_subscribe_clear(NRF_DPPIC,
   HAL_SW_DPPI_TASK_EN_FROM_IDX(SW_SWITCH_TIMER_TASK_GROUP(index)));

4.
NRF_DPPIC->SUBSCRIBE_CHG[group].EN/DIS = 0;
have been replaced with the equivalent HAL clear call

5.
NRF_DPPIC->TASKS_CHG[group].DIS = 1;
have been replaced with the equivalent hal task_trigger() call

6.
Manually setting the CHG registers, has been replaced with a
clear + add (because the hal does not have a set function yet)
So,
  NRF_DPPIC->CHG[group] = value
has been replaced with
  nrf_dppi_group_clear(NRF_DPPIC, group);
  nrf_dppi_channels_include_in_group(NRF_DPPIC, value, group);
(A set function has been requested from the HAL team)

Note: There is other direct registes writes to the dppi subscribe and CHG
registers in the coded phy parts which have not been changed yet.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-26 11:43:31 +02:00
Jonathan Rico
480e228a50 Bluetooth: host: document settings backend requirement
This requirement was implicit as the only backend the host is currently
tested with behaves this way.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-26 08:39:09 +02:00
Vinayak Kariappa Chettimada
8c9ac505db Bluetooth: Controller: nRF53: Fix sw switch single timer id regression
Fix regression in sw switch single timer id use for nRF53x
series SoC.

Regression introduced in commit cfcbe5d68e ("Bluetooth:
Controller: Remove redudant header file includes").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-25 19:47:10 +02:00
Alberto Escolar Piedras
bae0dace16 Bluetooth controller nrf: Rename bsim radio hal header
Rename the bsim header in preparation for having more
simulated targets.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-25 16:42:45 +02:00
Alberto Escolar Piedras
f1557804a9 Bluetooth controller nrf: ifdef some coded phy only code
To avoid a build error when coded phy is not enabled
for a nrf53: These three functions are only used for coded phy,
and depend on macros which are only defined if coded phy
is enabled.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-25 16:42:45 +02:00
Alberto Escolar Piedras
bab4ed1623 Bluetooth controller: nrf: Switch to use SOC_COMPATIBLE
Switch use of kconfig:
* SOC_SERIES_NRF53X -> SOC_COPATIBLE_NRF53X
* SOC_NRF5340_CPUNET -> SOC_COMPATIBLE_NRF5340_CPUNET
to also select those options/code when building for
the nrf53 simulated targets.

Also switch three kconfig range dependencies from
SOC_SERIES_NRF52X to SOC_COPATIBLE_NRF52X
(IRQ priority related) for consistency. These sound
not really have an impact.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-25 16:42:45 +02:00
Vinayak Kariappa Chettimada
94bd4837bb Bluetooth: Controller: Fix missing host feature reset
Fix missing host feature reset on HCI reset command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-25 16:42:20 +02:00
Vinayak Kariappa Chettimada
cb28104cb0 Bluetooth: Controller: Fix assertion due to late PER CIS active set
Fix assertion due to late Peripheral CIS active flag being
initialized. CIS active flag shall be initialized when it is
acquired.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-25 16:42:20 +02:00
Vinayak Kariappa Chettimada
e4cc5838fd Bluetooth: Controller: Fix PHY value in HCI LE CIS Established Event
Fix PHY_C_TO_P and PHY_P_TO_C value in HCI LE CIS
Established Event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-25 16:42:20 +02:00
Emil Gydesen
e51ac69156 Bluetooth: Audio: Add bt_audio_codec_cap_get helper functions
Add helper function to get specific values from
a codec capability struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-25 09:48:47 +02:00
Pavel Vasilyev
6267259f91 Bluetooth: Mesh: Use decimals instead of hex nums in DFD shell cmds
JSON doesn't support hexdecimals as numbers.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-09-22 09:30:07 +02:00
Pavel Vasilyev
ac050455c5 Bluetooth: Mesh: Fix printing device UUID
IS_ENABLED was incorrectly used here.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-09-22 09:23:44 +02:00
Emil Gydesen
2147eefa15 Bluetooth: PACS: Remove CONFIG_BT_PACS_{SNK,SRC}_CONTEXT
The Kconfig option was never used by the stack and should
thus be removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-22 09:21:53 +02:00
Vinayak Kariappa Chettimada
3fba1a18e7 Bluetooth: Controller: Use max time when scheduling Broadcast ISO
Use maximum event time length when scheduling Broadcast ISO
events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 12:49:48 +02:00
Vinayak Kariappa Chettimada
0f2980db15 Bluetooth: Controller: Maximize BIG event length and preempt PTO & CTRL
Maximize BIG event length to extend upto ISO interval, and
allow PTO and Control subevents to be pre-emptible.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 12:49:48 +02:00
Vinayak Kariappa Chettimada
87138e7ee3 Bluetooth: Controller: Calculate Broadcast ISO event overheads
Calculate Broadcast ISO event overheads due to extended and
periodic advertising events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 12:49:48 +02:00
Vinayak Kariappa Chettimada
5b4eb9bc76 Bluetooth: Controller: Minor rename ull_adv_sync_iso_created()
Minor rename to ull_adv_sync_iso_created().

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 12:49:48 +02:00
Fabio Baltieri
6e78b435be Bluetooth: BAP: drop unused variable
stream_in_subgroup is set but never used here.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-09-21 12:44:08 +02:00
Vinayak Kariappa Chettimada
e8fe144f3a Bluetooth: Controller: Fix missing PHY_CODED cond compile
Fix missing Coded PHY implementation conditional compile
causing compile error when disabling Coded PHY support in
SoCs that have radio that support Coded PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
d8f0006de5 Bluetooth: Controller: Revert EVENT_OVERHEAD_START_US for Coded PHY
Revert EVENT_OVERHEAD_START_US value for Coded PHY support,
needed to pass LL/DDI/SCN/BV-21-C and LL/DDI/SCN/BV-25-C.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
02b1c76820 Bluetooth: Controller: Reduce successive ticker_job() on Extended Scan
Reduce number of successive calls to ticker_job() by
disabling mayflies in the ULL_HIGH priority, enqueue
ticker_yield_abs() and ticker_start() before re-enabling
so that single ticker_job() handles both yield and start.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
c1042dff40 Bluetooth: Controller: Refactor prepare dequeue iteration code
Refactor/rename prepare dequeue iteration code and reuse it.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
7f388bb70a Bluetooth: Controller: Fix short prepare when many enqueued in pipeline
Fix short prepare handling when more than one event is
enqueued in the pipeline and the short prepare is placed at
the end of the prepare pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
377e2a1f48 Bluetooth: Controller: Fix ticks_slot_window use in Observer
Fix ticks_slot_window use in Observer, do not use for
unreserved continuous scanning, and do not use when scanning
on both 1M and Coded PHY simultaneously.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
67a2fc4293 Bluetooth: Controller: Use ticker_ticks_diff_get to check short prepare
Use ticker_ticks_diff_get consistently when calculating
difference between ticker ticks when determining short
prepare requests.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
dacadf2f1a Bluetooth: Controller: Use the state/role param in prepare pipeline
Use the state/role context parameter in prepare pipeline
to identify the preempt timeout that was setup.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Vinayak Kariappa Chettimada
91781306e9 Revert "Bluetooth: Controller: Fix ull_prepare_dequeue for skipped events"
These change are reverted as part of fixing regression
failure in LL/DDI/SCN/BV-21-C and LL/DDI/SCN/BV-25-C.

This reverts commit 0d54ca8761.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-21 09:27:15 +02:00
Emil Gydesen
f0cc8d4cb1 Bluetooth: CAP: Add support for long read/write
Add support for reading and writing long values (> MTU)
when using the CAP API.

This change does make it slightly slower to execute the
CAP procedures as it is now done on a one-by-one basis,
which affect multi-ACL setups, but that also means
that the buffer requirements for CAP will generally be lower.

There is still room for improvement as we can perform the BAP
operations in parallel on each ACl, which should return this to
its former performance.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:24:27 +01:00
Emil Gydesen
5cc14b6c50 Bluetooth: Audio: Replace BT_AUDIO_CODEC_PARSE_ERR_ with errno
Replace the BT_AUDIO_CODEC_PARSE_ERR_ values with errno values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:22:24 +01:00
Emil Gydesen
9693ae3021 Bluetooth: Audio: Add parsers for getting metadata values
Add parsers to retrieve metadata values from codec
capabilities and codec configuration structs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:21:24 +01:00
Emil Gydesen
8eecca2419 Bluetooth: BAP: Broadcast sink call stopped after BIG cleanup
Modify the order of operation in
broadcast_sink_iso_disconnected so that when the application
gets the last stopped callback, the BIG has already been cleaned
up, and the broadcast sink is in a reusable state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:21:16 +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
f93caa3903 Bluetooth: Audio: BT_AUDIO_CODEC_LC3_ID -> BT_HCI_CODING_FORMAT_LC3
Replace the BT_AUDIO_CODEC_LC3_ID macro with the
BT_HCI_CODING_FORMAT_LC3 as there is no reason to
define and use the LC3 ID different than the other
allowed codec IDs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:19:50 +01:00
Emil Gydesen
956a202ab8 Bluetooth: BAP: Add cc len check for BT_HCI_CODING_FORMAT_TRANSPARENT
When using BT_HCI_CODING_FORMAT_TRANSPARENT as the codec_id, the
codec configuration (cc) len sent to the controller shall be 0.

Since this goes for all devices, we ensure that we don't
send invalid codec ID and cc data over air.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:19:50 +01:00
Emil Gydesen
d327b1625c Bluetooth: BAP: Broadcast source reconfig with subgroups
Modify the bt_bap_broadcast_source_reconfig to use the same
parameter struct as bt_bap_broadcast_source_create so that
the two are more similar, since they both set the same values.

This allow for full control of which subgroups and stream
are updated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-20 20:16:52 +01:00
Vinayak Kariappa Chettimada
879c611f58 Bluetooth: Controller: Fix LE Set Ext Adv Param Cmd invalid status
Fix HCI LE Set Extended Advertising Parameter Command
invalid status reason.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-19 15:26:32 +01:00
Vinayak Kariappa Chettimada
4cefcb6fc7 Bluetooth: Controller: Fix order of preempt timeout requested flag
Fix the order of setting the flag that indicates that
preempt timeout has been successfully requested versus
the request is waiting to be scheduled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-19 15:25:30 +01:00
Vinayak Kariappa Chettimada
f4e05e3e54 Bluetooth: Controller: Fix ticker to prefer ticker node started
Fix ticker implementation to prefer to keep ticker node
started in case of race condition to start and stop.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-19 15:25:21 +01:00
Emil Gydesen
9d62bef3ac Bluetooth: BAP: Broadcast source state checks for ID and BASE
Add state checks for the get_id and get_base functions, as the
ID and base are not valid when the state of the broadcast
source is BT_BAP_EP_STATE_IDLE.

Since the broadcast_source_get_state uses the slist functions,
the broadcast source object for bt_bap_broadcast_source_get_id
can no longer be `const`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-19 15:23:10 +01:00
Nirosharn Amarasinghe
b96436296f Bluetooth: controller: Included kconfigs for ISO-AL logging
Included kconfigs to set the ISO-AL logging level and control debug
logging verbosity.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-09-18 14:35:42 +02:00
Erik Brockhoff
365a56ce87 Bluetooth: controller: disregard length field on pdu error
In case of unframed iso rx, length field cannot be trusted in case of
PDU error.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2023-09-18 14:35:42 +02:00
Nirosharn Amarasinghe
d414cab87a Bluetooth: Controller: ISO-AL validation and selection of TX time stamps
Intent is to pass Ellisys ISOAL quality tests for framed TX scenarios
where the TX SDU includes a time stamp that is not based on the
controller's clock.

Changes:
-- Include controller's reception time as a separate field in the TX SDU
   information
-- Include decision on whether SDU time stamp is valid and based on the
   controller's clock
-- Arbitrate and select / compute time stamp for the SDU

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-09-18 14:35:42 +02:00
Nirosharn Amarasinghe
31df0ef80b Bluetooth: controller: corrected time-offset for endianness
Changes:
-- Corrected reading and writing time offset in framed segment header to
   account for endianness
-- Corrected bit positioning of time offset bit field in the segment
   header structure definition
-- Fixed upstream Zephyr BSIM test build failure due to debug logging
   39-bit variable

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-09-18 14:35:42 +02:00
Nirosharn Amarasinghe
e318a3032b Bluetooth: controller: Use consecutive event for framed TX and RX bugfix
Changes:
-- Disregards target event after segmenting the first TX SDU and instead
   decide event based on the next payload and feasibility to fragment
   for that event (time-offset > 0)
-- Corrected error SDU release logic when an error occurs while
   expecting the start of a new SDU, to avoid releasing an SDU which
   could be received in the next payload or event
-- Included additional debug logging

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2023-09-18 14:35:42 +02:00
Vinayak Kariappa Chettimada
5daa864b5e Bluetooth: Controller: Use DIV_ROUND_UP macro in HAL ticker
Use DIV_ROUND_UP macro in HAL ticker.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Vinayak Kariappa Chettimada
34100cb7ea Bluetooth: Controller: Use defines for femto and pico seconds
Use defines for femto and pico seconds in HAL ticker
calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Vinayak Kariappa Chettimada
333ff94e6b Bluetooth: Controller: Use HAL_TICKER_US_TO_TICKS_CEIL for ticks_slot
Use HAL_TICKER_US_TO_TICKS_CEIL for ticks_slot calculations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Vinayak Kariappa Chettimada
01314b2e43 Bluetooth: Controller: Make openisa and test hal ticker.h consistent
Make openisa and unit test hal ticker.h consistent with
nrf hal ticker.h.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Vinayak Kariappa Chettimada
c986104485 Bluetooth: Controller: Revert EVENT_OVERHEAD_END_US to original value
Revert back the EVENT_OVERHEAD_END_US value to original
value in initial commit 5c3709c13f ("bluetooth:
controller: Add def's re. update to slot reservation calc").

40 us is a sufficient margin considering ~30 us being the
worst case Rx chain delay for S8 Coded PHY on nRF5x SoCs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-18 14:25:02 +02:00
Ludvig Samuelsen Jordet
b990a74f8b Bluetooth: Mesh: Add support for Upload OOB Start
This adds support for the Upload OOB Start message to the DFD server, by
providing callbacks that the application can use to hook any OOB scheme
into the model behavior.

There are also extensive changes to the dfu_slot module, to accomodate
the new needs that appeared with the support for OOB transfer (mainly,
fwid, size and metadata are no longer available when the slot is
allocated, they appear later in the handling).

Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
2023-09-18 10:55:20 +01:00
Gerard Marull-Paretas
4f80e50b55 bluetooth: controller: coex: convert to DT device
Convert the driver to a dt-based device. Also update Kconfig so that it
depends on the right compatible being enabled, initialize in POST_KERNEL
(APPLICATION should not be used for devices) and remove one redundant
include.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Gerard Marull-Paretas
349306bda7 bluetooth: audio: use SYS_INIT
The device model was not used for anything useful, only to call some
init code. Change to SYS_INIT instead.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-15 16:04:19 +02:00
Vinayak Kariappa Chettimada
d42d14e392 Bluetooth: Controller: Fix missing lazy calculation for Central ISO
Fix missing lazy calculation when using ticker interface
required for Central CIS create.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-15 09:27:37 +02:00
Vinayak Kariappa Chettimada
1291e4b686 Bluetooth: Controller: Fix initialization of lazy_active
Fix initialization of CIS lazy_active event count used when
first CIS event is active. Now initialization for first and
any subsequent CISes made active.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-15 09:27:37 +02:00
Vinayak Kariappa Chettimada
afd48e03d0 Bluetooth: Controller: Minor clean up of redundant initialization
Minor clean up of redundant initialization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-15 09:27:37 +02:00
Donatien Garnier
185a6117c0 Bluetooth: Host: Amend existing L2CAP accept callbacks
This patch amends the existing L2CAP accept callbacks to use the new
accept signature that includes a pointer to the L2CAP server structure.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-09-14 14:36:34 +02:00
Donatien Garnier
815891643e Bluetooth: Host: Pass pointer to server in L2CAP accept() callback
Add a pointer to the associated server structure in the L2CAP accept()
callback. This allows the callee to know which server an incoming L2CAP
connection is associated with.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-09-14 14:36:34 +02:00
Emil Gydesen
3f585f527b Bluetooth: Host: Add additional logging for bt_conn_exists_le
The bt_conn_exists_le is commonly hit by users attempting
to connect (either as central or peripheral) to a device
they are already connected to in some way. The current log statement
does not provide particularly much information, so added more.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-14 14:36:09 +02:00
Vinayak Kariappa Chettimada
f2069530ee Bluetooth: Controller: Fix some compiler instruction re-ordering
Fix some compiler instruction re-ordering. Mayfly code with
cpu_dmb() help avoid stalled memq_ull_rx processing when
rx_demux is to be executed using mayfly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-14 14:30:36 +02:00
Gerard Marull-Paretas
691facc20f include: always use <> for Zephyr includes
Double quotes "" should only be used for local headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-14 13:49:58 +02:00
Hang Fan
3fb434a653 Bluetooth: Shell: Fix bt adv-data command
Fix wrong adv elements length for bt adv-data command

Signed-off-by: Hang Fan <fanhang8@gmail.com>
2023-09-14 08:35:40 +02:00
Alperen Şener
f6a9fc1202 Bluetooth: Mesh: add optional OOB info to ext scan report
Even though the OOB information is optional we can add it
to extended scan reports in cases there is detected unprovisoned
devices.

Referring to MshPRT section 4.4.5.3:
When the Remote Provisioning Extended Scan procedure completes without
receiving an advertisement from the unprovisioned device, the
OOBInformation and AdvStructures fields shall be skipped. When the
obtained data is empty, the AdvStructures field shall be skipped. The
Status field shall be set to Success.

and referring to MshPRT section 4.3.4.9:
The OOBInformation field contains the OOB Information of either the
unprovisioned device or the Remote Provisioning Server.

Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
2023-09-13 10:07:42 +02:00
Anders Storrø
6559de3238 Bluetooth: Mesh: Store priv proxy in sep entry
Stores persistent on-demand private GATT proxy state in separate
settings entry. This is implemented to avoid issues related to
backwards compatibility between device firmware updates.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-11 19:58:05 +02:00
Anders Storrø
c80a52a1e3 Bluetooth: Mesh: Store priv beacon in sep entry
Stores persistent private beacon state in separate settings entry.
This is implemented to avoid issues related to backwards compatibility
between device firmware updates.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-11 19:58:05 +02:00
Jamie McCrae
da96722552 bluetooth: Make long workqueue init priority configurable
Makes the long workqueue init priority configurable and sets
the default to 50, this is to allow for relocating bluetooth
libraries to other parts of memory e.g. external flash, and
allows for those flash drivers to be initialised prior to
calling functions residing in them.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-11 19:57:08 +02:00
Pirun Lee
008a82e3ba Bluetooth: OTS: Fix memory leak while procedure is not finished
cur_inst is the copy of ots_client instance to prevent duplicate
API call while client is in middle of read/write procedure.
But cur_inst can only be cleared while write_obj_tx_done or read rx_done.
If ACL is disconnected while read/write is on-going, there is no chance
for cur_inst being cleared.
This causes ots client will no longer perform select/read/write
procedure anymore. API will always return -EBUSY.

Let l2cap_disconnect check if cur_inst is NULL and NULL it
unconditionally as what it is designed.

Make bt_ots_client_unregister public API.

Signed-off-by: Pirun Lee <pirun.lee@nordicsemi.no>
2023-09-11 19:55:56 +02:00
Mariusz Skamra
ff71508d5f Bluetooth: audio: ascs: Add endpoint by stream lookup function
This adds endpoint by stream lookup function used to find the active
endpoints that use the stream object provided. The function is used
instead of dereferencing stream->ep that may be not valid if application
did not memset the stream object.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-11 11:08:53 +02:00
Mariusz Skamra
c1214f2067 Bluetooth: audio: ascs: Make stream->ep valid in bt_bap_stream_ops.released
Once the application bt_bap_stream_ops.released callback is called make
sure the stream->ep pointer is valid so that application can still access
the endpoint details like e.g. endpoint direction.

Fixes: ASCS/SR/ACP/BV-{24,25,26,27,28,29,30,31}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-11 11:08:53 +02:00
Emil Gydesen
b86548ca7c Bluetooth: Audio: Add check for valid cid and vid for LC3
When using the LC3 codec, the cid and vid fields of the
codec shall both be 0x00, as per the BAP and ASCS specs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-11 11:08:39 +02:00
Alperen Şener
66bf33f090 Bluetooth: Mesh: Fix Solicitation Mesh crypto API use
Pointer of the keys should be send to mesh en/decryption APIs.

Signed-off-by: Alperen Şener <alperen.sener@nordicsemi.no>
2023-09-08 14:45:22 +02:00
Alberto Escolar Piedras
bb811a1e1d Bluetooth: Controller: Nordic LLL: Use HAL to clear EVENTs
Use the HAL event clear functions to clear EVENTS
instead of accessing the registers directly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-08 14:45:13 +02:00
Alberto Escolar Piedras
7082222ac6 Bluetooth: Controller: Nordic LLL: Use HAL to clear RTC event
Use the HAL event clear function to clear the RTC EVENT
instead of accessing the register directly.

This allows using an updated version of the RTC HW models
which generate level interrupts (as the real HW) and in
which if the EVEN register is not properly cleared,
the interrupts are kept high, resulting in the interrupt
handler reentering immediately after exiting.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-09-08 14:45:13 +02:00
Emil Gydesen
1e826bb670 Bluetooth: BAP: Shell: Fix issue in cmd add_pa_sync
The command was missing a metalen check, and attempted
to access array of size 0, which could give a build
warning.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-08 14:44:39 +02:00
Anders Storrø
6b627771c8 Bluetooth: Mesh: Shell support for comp data page2
Adds shell support for composition data page 2 and 130

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-08 14:44:25 +02:00
Anders Storrø
9d849736ef Bluetooth: Mesh: Support for comp data page 2
Adds support for composition data page 2 & 130.

In this implementation the responsibillity for filling the page 2
buffer is left to the application through the new comp page 2 cb API.
Only the application can know/decide if the device is NLC compliant,
and must thus be given the responsibillity for cheking the NLC profile
requirements, defined in the NLC specs, and filling the response buffer
for comp data page 2.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-08 14:44:25 +02:00
Emil Gydesen
1e50132237 Bluetooth: ISO: Handle central disc of pending CIS
If the central disconnects a CIS while it is being
established, then we receive both a CIS established event
with BT_HCI_ERR_OP_CANCELLED_BY_HOST and a disconnect complete
event.

In this case we should not call bt_iso_disconnected in the
CIS established event handler, as that will also be
called from the disconnect complete event handler.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-08 14:43:23 +02:00
Emil Gydesen
7e66bb1e09 Bluetooth: ISO: Reject disconnecting pending CIS as peripheral
As per the core spec, the CIS is not allowed to disconnect
a CIS if it is pending (i.e. in the connecting state).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-08 14:43:23 +02:00
Piotr Narajowski
96954acfff bluetooth: audio: Add API to get MICP service ATT handles
This is needed for upper tester.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
2023-09-08 14:43:00 +02:00
Jonathan Rico
22bde976e5 Bluetooth: l2cap: validate reconfigure packet length
The specification only allows up to 5 16-bit CIDs in this PDU.
Enforce it.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-07 20:18:06 +02:00
Morten Priess
79ab982f46 Bluetooth: controller: Introduce config for avoiding SDU fragmentation
The CIS Central uses the algorithm described in BT Core 5.4 Vol 6,
Part G, Section 2.2 to calculate the Max_PDU value for framed mode.

However, HAP needs the Max_PDU to be calculated according to "Core
enhancement for ISOAL CR" coming with the "Atlanta" update. With this
update, the fragmentation is controlled via a parameter at CIG creation.

Enabling CONFIG_BT_CTLR_CONN_ISO_AVOID_SEGMENTATION will set the
ISO_Interval to 7.5 ms for a 10 ms framed CIG, and calculate Max_PDU to
45/65 for 16/24 kHz.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-09-07 14:25:35 +02:00
Emil Gydesen
592da93644 Bluetooth: CAP: Add minimum metadata len req for CAP
CAP requires setting the streaming context in the metadata,
which requires 4 octets of metadata, so the metadata for
CAP must be greater than or equal to 4.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-07 09:42:46 +02:00
Anders Storrø
01a6ecb6bf Bluetooth: Mesh: Send od priv proxy with devkey
According to the mesh 1.1 spec, section  4.4.14.1: “. The access layer
security on the On-Demand Private Proxy Client model shall use the
device key of the node supporting the On-Demand Private Proxy
Server model.“

This commit alters the API and implementation to reflect this.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-09-06 13:05:14 +02:00
Pavel Vasilyev
d36b7f4de0 Bluetooth: Mesh: Fix Solicitation RPL PDU Server compilation
A pointer to the key struct should be passed after the PSA support has
been added.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-09-06 09:35:10 +02:00
Pavel Vasilyev
2a472b8b47 Bluetooth: Mesh: Fix Opcode Aggregator Server compilation
Remove ifdef around `srcs` and let linker exclude it when Opcode
Aggregator Client model is not enabled.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-09-06 09:35:10 +02:00
Théo Battrel
8bd36fc589 Bluetooth: Host: Fixes SMP issues
If the bonding information has been cleared before pairing had a chance
to complete (probably by the application), indicate this by setting an
appropriate log message.

Also check that keys exist before calling `bt_keys_store`.

Fixes #59788 and #61465

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-09-06 09:35:01 +02:00
Mariusz Skamra
dd3cffcd20 Bluetooth: audio: Fix bt_audio_codec_cfg_get_chan_allocation_val return
This fixes bt_audio_codec_cfg_get_chan_allocation_val return value that
shall be 0 in case of success.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-05 10:06:09 +02:00
Mariusz Skamra
856b8cb5e9 Bluetooth: audio: Fix pointer value assignment
This fixes data pointer that was never set because wrong pointer
assignment.
It's regression introduced in:
b4af917ad0

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-09-05 10:06:09 +02:00
Vinayak Kariappa Chettimada
f6bf73de83 Bluetooth: Controller: Use NRF_CCM HEADERMASK for ISO PDU encryption
Use NRF_CCM HEADERMASK register to use correct Additional
Authentication Data (AAD) from ISO PDU header.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-05 10:04:57 +02:00
Kamil Piszczek
42c904526b bluetooth: host: convert conn address on identity resolution
Fix an issue in the CCC configuration when the Peripheral device
maintains two or more distinct connections on different identities
with the same peer. The issue occurs when the local device performs
the pairing and the bonding procedure on a connection associated
with one of the Bluetooth identities. During the identity resolution,
the peer address field in the CCC descriptor is converted from the
RPA-type address to the Identity Address. However, the destination
address on the remaining connection objects associated with other
Bluetooth identities is not converted. Due to this, their CCC
configuration is reset and GATT indications and notification fail
to be sent even if the Central device subscribed to them.

Added necessary code to iterate over all connection objects during
the identity resolution phase and aligned their destination address
from the RPA-type to the Identity Address.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2023-09-04 18:41:48 +02:00
Vinayak Kariappa Chettimada
96c12650e8 Bluetooth: Controller: Fix timestamp to use CIS reference anchor point
Fix timestamp calculation to use CIS reference anchor point
instead of incorrectly used CIG reference anchor point.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-09-04 18:22:24 +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
Emil Gydesen
68a4d0f6c5 Bluetooth: BAP: Broadcast Source: Modify when enabling state is set
Modify when the BT_BAP_EP_STATE_ENABLING state is set during
bt_bap_broadcast_source_start.

The reason why the state is now set before the call to
bt_iso_big_create, is to handle the case where the BIG
created event actually happens and is handled (by another
thread) faster than the state change is done, which could
cause an invalid state check if the streaming state is
attempted to be set before the enabling state.

Since the events from the controller may be handled by a
different thread, we should not assume that this function returns
before the event is handled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-01 17:45:07 +02:00
Rubin Gerritsen
faee29c229 Bluetooth: Shell: Only print valid ISO data
The application gets notified about both valid and invalid data.
As data arrives every SDU interval, we would like to only print the
valid data to avoid the shell being flooded with logs.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-09-01 17:44:39 +02:00
Emil Gydesen
76e35635b6 Bluetooth: Audio: Rename codec qos framing
Rename BT_AUDIO_CODEC_QOS_[UN]FRAMED to
BT_AUDIO_CODEC_QOS_FRAMING_[UN]FRAMED and give a name
to the enum, which is then used by the
struct bt_audio_codec_qos.

The rename was needed as we had a codec_qos initializer of the
same name, so the values were renamed to avoid duplicated
macro names.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-09-01 09:54:18 +02:00
Morten Priess
ef5d0fd291 Bluetooth: controller: Fix ISO Transmit Test Mode parameters
Fix incorrect use of Max_SDU_Size and SDU_Interval parameters in
ISO Transmit Test Mode code.

Fixes EBQ test LL/CIS/PER/BV-08-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-31 10:34:14 +02:00
Mariusz Skamra
b4af917ad0 Bluetooth: audio: Change bt_audio_codec_cfg_get_val return value
This changes bt_audio_codec_cfg_get_val function to return the data
length found. Otherwise, this function gives no information about the
returned data length.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-31 10:21:07 +02:00
Fabio Baltieri
8450eec4a3 bluetooth: mesh: fix few mismatched CONTAINER_OF
Fix few mismatched CONTAINER_OF, one missing k_work_delayable_from_work
and few that should be pointing at the first elemnet.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-31 10:20:31 +02:00
Mads Winther-Jensen
f0c10d0332 Bluetooth: controller: Implement ISO link quality for CIS streams
Added optional support for read ISO link quality command.
Added link quality member in struct ll_iso_stream_hdr.

Signed-off-by: Mads Winther-Jensen <mdwt@demant.com>
2023-08-30 17:51:26 +02:00
Troels Nilsson
8ff4585270 Bluetooth: Controller: Check for duplicate handles in le_set_ext_adv_enable
If there are duplicate handles the Controller shall return the
error code Invalid HCI Command Parameters (0x12)

Fixes a failure in the EBQ test LE/AdvExt/Req-01 (part of the Ellisys
quality test suite)

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-30 15:18:16 +02:00
Anders Storrø
8bb7a280eb Bluetooth: Mesh: Support for comp data page 129
Adds support for composition data page 129.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-30 14:14:49 +02:00
Troels Nilsson
d3f386d52b Bluetooth: Controller: Fix some incorrect asserts on connection
Fixes some incorrect assertions in ull_adv.c on connection establishment

Note that the usual checks using adv->lll.conn doesn't work here,
since ull_periph_setup() NULLs the lll's conn structure pointer
before stopping the ticker

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-30 13:48:59 +02:00
Tom Finet
2b8762a438 bt: fix bt_l2cap_chan_send_sdu to return total bytes sent
bt_l2cap_chan_send_sdu previously returned the number of bytes sent
in the last sent sdu buf fragment or 0 if the buf has only
one fragment. bt_l2cap_chan_send_sdu now returns the total data
bytes sent from the buf.

Signed-off-by: Tom Finet <tom.codeninja@gmail.com>
2023-08-30 10:23:05 +02:00
Fabio Baltieri
a16f1cee4a bluetooth: host: fix few mismatched CONTAINER_OF
Fix a bunch of mismatched CONTAINER_OF, few missing
k_work_delayable_from_work conversions but also many
bt_l2cap_le_chan/bt_l2cap_chan and few others.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-30 10:22:37 +02:00
Thomas Ebert Hansen
00c5edd411 Bluetooth: controller: Fix LLCP enc. execution ctx
rp_enc_state_wait_ltk_reply() is executed in thread context, so
it is not allowed to move the encryption state machine forward.

Defer LTK reply handling to next prepare event by introducing a continue
state.

Update the unit test to reflect this, and remove the TODO that actually
said there was an issue in the first place.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2023-08-30 10:22:15 +02:00
Morten Priess
6985e6262f Bluetooth: controller: Add memory barrier to ticker transactions
Prevent compiler optimizations from changing the order of assignments in
the ticker API transactions. This could cause lost operation requests
and unexpected behavior under certain race conditions.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-29 16:14:50 +02:00
Emil Gydesen
86fd899bbf Bluetooth: PACS: Fix a couple of issues in PACS notify handling
There were a few issues in the way that PACS handled notifying:
1) A couple of dangling pointers (fixed by declaring some
   `static const struct bt_uuid`
2) Some wrong Kconfig guards were used

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-29 16:14:42 +02:00
Troels Nilsson
8a2a2bd613 Bluetooth: Controller: Add trpa cache for BT_CTLR_SW_DEFERRED_PRIVACY
Adds a target RPA known unknown cache; it fulfills a similar function
to the existing peer RPA cache, used for scanning of directed
advertisements

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-29 16:13:22 +02:00
Gerard Marull-Paretas
59946f16ca bluetooth: audio: s/device.h/init.h
File was not using any device.h API, but init.h (SYS_INIT).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-08-29 11:54:36 +01:00
Anders Storrø
3183ff3ff5 Bluetooth: Mesh: Add buf size check in comp p1 get
According to mesh 1.1 spec (4.4.1.2.2 Composition Data state):
“If the complete list of models does not fit in the Data field, the
element shall not be reported.“

The implementation of bt_mesh_comp_data_get_page_1 does
not consider this, and further it will assert the device if the passed
buffer is to small.

This commit adds a check that prevents populating passed buffer
if the full element entry wont fit in the buffer.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-29 12:17:42 +02:00
Emil Gydesen
71b1591337 Bluetooth: CAP: Remove qos from start_stream_param
Remove the qos field from
bt_cap_unicast_audio_start_stream_param as it was not used.

The QOS values are set when creating the unicast group,
and not when starting the streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-29 10:22:43 +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
Fredrik Danebjer
32b00dd6f4 Bluetooth: Audio: Make BSIM tests for PACS notify functionality
Added a BSIM tests for PACS notification functionality. This test
tests that all optional notifies are working, as well as verifying
that a disconnected subscribed client will be notified on reconnect.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-08-28 15:56:26 +02:00
Fredrik Danebjer
2ebbc7b130 Bluetooth: Audio: Make PACS notify bonded clients on reconnect
This fix allows PACS to notify bonded clients, that were disconnected
when a characteristic with notify property was changed, are being
reconnected.

This fix also implements a defer work so to not block the bt rx
thread during auth callbacks. All other notify calls are for
consistency and style also moved to use the defer work.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-08-28 15:56:26 +02:00
Fredrik Danebjer
4c94056f74 Bluetooth: Audio: Make PACS optional notify actually optional
Added Kconfig options to make the various PACS characteristics that are
optionally notifiable selectable as notifiable. Selecting a
characteristic as notifiable will make it so for all pacs instance on
the device.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-08-28 15:56:26 +02:00
Fabio Baltieri
ec71be5d9d drivers,subsys: fix few missing k_work_delayable_from_work
Fix few instances of delayable work handlers using the k_work pointer
directly in a CONTAINER_OF pointing to a k_work_delayable.

This is harmless since the k_work is the first element in
k_work_delayable, but using k_work_delayable_from_work is the right way
of handling it.

Change a couple of explicit CONTAINER_OF doing the same work as the
macro in the process.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-28 10:12:21 +02:00
Pavel Vasilyev
4fc1734917 Bluetooth: Mesh: Remove bt_mesh_beacon_priv_random_get as unused
This function is not used anywhere.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-24 22:09:57 +01:00
Pavel Vasilyev
8799286990 Bluetooth: Mesh: Don't compile priv_random if Priv Beacons not enabaled
This should fix unused variable issue when compiled with -Werror.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-24 22:09:57 +01:00
Mariusz Skamra
f69d83aedf Bluetooth: vocs: Retry sending notification on error
Retry sending notification was not sent due to e.g. lack of
buffers currently available.

Fixes: #57456
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-24 10:22:12 +02:00
Mariusz Skamra
de11c129fb Bluetooth: aics: Retry sending notification on error
Retry sending notification was not sent due to e.g.
lack of buffers currently available.

Fixes: #57452
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-24 10:22:12 +02:00
Mariusz Skamra
54b958af29 Bluetooth: vcp_vol_rend: Retry sending notification on error
Retry sending notification was not sent due to e.g. lack of
buffers currently available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-24 10:22:12 +02:00
Mariusz Skamra
26110d5a1b Bluetooth: micp_mic_dev: Retry sending notification on error
Retry sending notification was not sent due to e.g. lack of
buffers currently available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-24 10:22:12 +02:00
Morten Priess
cdbcdb8e14 Bluetooth: host: Fix endianness in hci_le_remove_iso_data_path
Add missing endianness conversion of handle sent over HCI.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-23 18:47:06 +02:00
Mariusz Skamra
fc215282bc Bluetooth: audio: tbs_client: Fix missing discovery complete event
This fixes missing Fix bt_tbs_client_cb.discover call that has been
observed when CONFIG_BT_TBS_CLIENT_CCID was disabled. In such case the
discovery proces was not finished from application point of view,
as the callback was not called.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-23 15:44:07 +02:00
Mariusz Skamra
2b27b4ebe0 Bluetooth: audio: tbs_client: Subscribe to all required notifications
This removes odd `subscribe` parameter from bt_tbs_client_discover
function parameters list. As the API user enables specific
CONFIG_BT_TBS_CLIENT_* option, the client implementation should
subscribe to the characteristic notifications so that the user receives
the value updates.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-23 15:44:07 +02:00
Morten Priess
83fcbfd0be Bluetooth: controller: Fixes for CIS Central error handling
- Fix masking for no coded phy
- Allow ISO_Interval < SDU_Interval for framed mode
- Change BT_HCI_ERR_INSUFFICIENT_RESOURCES to
  BT_HCI_ERR_CONN_LIMIT_EXCEEDED.
- Prevent starting same CIS twice
- Cancel an initiated CIS creation procedure if terminated before
  sending CIS_IND.
- Implement canceling of local CC procedure. Respond to CIS_RSP with
  REJECT, if canceled after CIS_REQ was sent.
- Introduce state CIG_STATE_INITIATING for central, to keep track of
  initiating CIS connection, in transition between CONFIGURABLE and
  ACTIVE.

Fixes EBQ test /HCI/CIS/BC-03-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-23 14:45:24 +02:00
Mariusz Skamra
c563e7a1b8 Bluetooth: mesh: Fix uninitialized variable error
This fixes the error below:

main.c: In function ‘bt_mesh_provision’:
main.c:173:17: error: ‘node’ may be used uninitialized in
	       this function [-Werror=maybe-uninitialized]
  173 |                 bt_mesh_cdb_node_del(node, true);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-23 14:44:48 +02:00
Emil Gydesen
271004adb1 Bluetooth: CAP: bt_cap_initiator_started called without unicast support fix
The bt_cap_initiator_started may be called in cap_stream_started_cb,
even if there is no unicast support. Added a guard for
CONFIG_BT_BAP_UNICAST to avoid calling an unlinked function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-23 14:43:43 +02:00
Bi Jian
bc7205ebd3 Bluetooth: ISO: Fix invalid conn type check
The bt_conn_lookup_handle will check ISO type, if check failed, the
iso will be NULL and return.

Signed-off-by: Bi Jian <bi_jian@qq.com>
2023-08-22 18:11:54 +02:00
Alberto Escolar Piedras
392769e425 BT mesh: Rename shadow variables
Rename shadow variables found by -Wshadow

After e38fc6de8a
was merged, this cause CI failures.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-08-22 15:14:32 +02:00
Thomas Ebert Hansen
8ae2eb53dc Bluetooth: controller: Handle invalid enc. pause
Reject LL_PAUSE_ENC_REQ while the ACL is associated with a CIS that is
created.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2023-08-22 10:53:47 +02:00
Mariusz Skamra
d28f180473 Bluetooth: audio: ascs: Move metadata validation to stack
As the metadata has to be validated anyway, let the initial vaidation of
metadata to be done in ASCS. The application can still reject the
metadata, but the length validation and supported type validation can be
performed by the stack.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-22 09:59:53 +02:00
Morten Priess
250c6f5829 Bluetooth: controller: Prevent slot reservation update for JIT scheduler
When using the JIT scheduler (CONFIG_BT_CTLR_JIT_SCHEDULING), doing
ticker updates which only change the slot reservation, will fail.

For compatibility, the updates to ull.ticks_slot are preserved, as some
link layer implementations use this to predict collisions.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:54 +02:00
Morten Priess
8b98a93623 Bluetooth: controller: Modify reason for local CIS_TERMINATE procedure
When executing a local CIS_TERMINATE procedure, the reason sent to the
host must be changed to match the perspective of the initiator.

According to BT Core 5.4 Vol 4, Part E, section 7.1.6, the disconnect
reason must be BT_HCI_ERR_LOCALHOST_TERM_CONN for a local disconnect.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Morten Priess
42a108aad3 Bluetooth: controller: Prevent assert in ll_conn_iso_stream_get_by_acl
Do not assert in case of race conditions or asymmetric CIS
create/release. There are cases where ll_conn_iso_stream_get_by_group
legally returns NULL, and this should just cause for-loop continuing to
next iteration.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Morten Priess
44cdd881f4 Bluetooth: controller: Introduce CIS LLL flush states
To keep track of requested/pending CIS LLL flushing, change 'flushed'
binary state to 'flush' with states NONE, PENDING and COMPLETE.

This enables CIS teardown to know that a CIS already has a pending LLL
flush, and ULL does not need to initiate it.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Morten Priess
856e555b51 Bluetooth: controller: Fix HCI ISO header RFU bit masking
Mask out RFU bits in HCI ISO header to prevent set RFU bits leaking into
length values.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-21 15:11:48 +02:00
Alperen Sener
2fe4493564 Revert "bluetooth: mesh: increase mesh scan window"
This reverts commit dbb0b30bdd.

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2023-08-21 11:48:36 +02:00
Carles Cufi
3f0d7012a6 Bluetooth: controller: Check minimum sizes of adv PDUs
While the maximum sizes were already correctly checked by the code, the
minimum sizes of the PDUs were not. This meant that PDUs smaller than
the minimum required length (typically 6 bytes for AdvA) were
incorrectly forwarded up to the Host.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-08-21 10:48:26 +01:00
Anders Storrø
41addf67a9 Bluetooth: Mesh: Add ext timeout in PB for OOB I/O
Adds separate extended protocol timeout of 120 sec in provisioning
implementation when OOB method Input or Output is used. This
complies with recommendation in the mesh 1.1 protocol spec (5.4.4).

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-21 10:55:43 +02:00
Emil Gydesen
a954157752 Bluetooth: BAP: Fix reset internal BASS state values on remove
A few fields of the internal state were not properly reset by
scan_delegator_rem_src.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-18 10:13:54 +02:00
Rubin Gerritsen
569d988585 Bluetooth: ISO: Don't call LE Create Conn Cancel on ISO disconnect
When calling `bt_iso_chan_disconnect()` while the channel is
connecting, the host should simply use HCI Disconnect.

Note: For the peripheral it is not allowed to call HCI Disconnect
on a CIS after it has accepted the CIS request, but before it has
received the CIS established event. The implementation in this
commit does not fix this case. In that case the controller will
return an error code.

Also, this commit does not handle the events following the
HCI Disconnect correctly.
In this particular case, two events are raised by the controller.
See Core_v5.4, Vol 6, Part D, Figure 6.51.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-18 10:13:36 +02:00
Anas Nashif
c8a9e445bb Bluetooth: BT_OTS_OACP_CHECKSUM_SUPPORT implies CRC support
BT_OTS_OACP_CHECKSUM_SUPPORT requires CRC to be enabled.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-08-18 08:52:16 +03:00
Anders Storrø
254ee94fc0 Bluetooth: Mesh: Remove conflicting shell OOB func
Removes redundant mesh shell OOB implementation that makes
existing command implementation fail. Alters capabilities
CB to print provisionee caps.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-17 16:50:28 +02:00
Pavel Vasilyev
065e7571eb Bluetooth: Mesh: Fix usage of Identity and NRPA adv options for proxy
Both options are kind of mutually exclusive and can't be used together.
Also, USE_IDENTITY is used for debug purpose and could be useful when
debugging Private Proxy as well. Since CONFIG_BT_MESH_DEBUG_USE_ID_ADDR
is not allowed to be used in production, it is fine to use it for
Private Proxy advertisements as well.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-17 16:49:27 +02:00
Aleksandr Khromykh
2cdacb3fa8 tests: Bluetooth: Mesh: add cfg mesh with mbedtls PSA to bsim CI
Commit adds configuration for mesh with mbedtls PSA
to CI BabbleSim tests as well as emulation of
the Internal Trustable Storage(ITS) based on Zephyr's
settings to run in parallel environment.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-08-17 15:14:19 +02:00
Emil Gydesen
1f9990fbd5 Bluetooth: Shell: Set newest conn as default_conn for central
When dealing with multiple connections in the shell as the central,
it is more often than not the newest connection you want
to interact with.

The behavior for the peripheral remains unchanged.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-17 13:11:14 +02:00
Daniel Leung
e3ecca5784 bluetooth: fixes shadow variables
Massaging code to fix shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-17 13:00:09 +02:00
Mariusz Skamra
1ff7b49a3a Bluetooth: audio: ascs: Remove redundant check
This removes redundant state check that is covered below.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-16 20:39:15 +02:00
Mariusz Skamra
8dcec59115 Bluetooth: audio: ascs: Fix ASE state transition due to CIS link loss
This fixes ASE state transition to QoS Configured state that shall be
done autononously when CIS has been terminated due to link loss.

As per ASCS v1.0:
"If the server detects link loss of a CIS for an ASE in the Streaming
state or the Disabling state, the server shall immediately transition
that ASE to the QoS Configured state. Link loss of a CIS for an ASE in
any state other than Streaming or Disabling shall not cause a
transition of the ASE state machine."

Fixes: #60669
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-16 20:39:15 +02:00
Bi Jian
243516e6e5 bluetooth: audio: fix code comments error
Added PB_Flag 0b10:The ISO_SDU_Fragment field contains a complete SDU.

Signed-off-by: Bi Jian <bi_jian@qq.com>
2023-08-16 15:04:28 +02:00
Magdalena Kasenberg
7bf502d806 Bluetooth: Audio: Fix missing setting of data and meta len
A recent refactor of bt_audio_codec_cap to flat arrays missed setting
data_len and meta_len fields.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-08-16 14:48:11 +02:00
Anders Storrø
e588e488e8 Bluetooth: Mesh: Unassign elem addr on comp unprov
Unassigns all element addresses when unprovisioning the composition
data.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-08-16 10:25:18 +02:00
Henrik Eriksen
b8564ac33e bluetooth: audio: csip: Unlock Non-bonded devices immediately.
Qualification test CSIS/SR/SP/BV-03-C [Lock Timeout]

Specification: Coordinated Set Identification Service Revision v1.0.1
Section 5.3.1.1.

When the server and the client are not bonded and they disconnect when
the value of the Set Member Lock characteristic is set to Locked, the
server shall set the value of the Set Member Lock characteristic to
Unlocked immediately after the disconnection.

Signed-off-by: Henrik Eriksen <heri@demant.com>
2023-08-16 10:25:11 +02:00
Henrik Eriksen
5a18f0dda7 bluetooth: audio: micp: Wrong error response for invalid Mute Value.
Qualification test MICS/SR/SPE/BI-01-C [Invalid Mute Value]

Specification: Microphone Control Service Revision v1.0 Section 3.1.1

If the client writes a value of Disabled or RFU to the Mute
characteristic, the server shall return an ATT Error Response with the
ATT error code Value Not Allowed (0x13) as defined in Assigned Numbers.

Signed-off-by: Henrik Eriksen <heri@demant.com>
2023-08-16 10:24:53 +02:00
Rubin Gerritsen
76dad61bf3 Bluetooth: Shell: Add value handle to notification print
This makes it possible to see what service the notification corresponds
to.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-15 21:56:07 +00:00
Rubin Gerritsen
e9d0340a99 Bluetooth: Shell: Fix the command bt adv-data
The command did no longer set the user specified data if the user
specified more than 1 AD field.

We were using the return value of ad_init() to set the number
of AD fields. This did not take into account the number of
existing data fields. By chance this usually returned 1.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-15 21:54:56 +00:00
Morten Priess
ed92ea94e8 Bluetooth: controller: Defer ticker stop after start
To prevent failure stopping a ticker node after starting it within the
same ticker_job execution (queued operations), defer the stopping until
after start. This will sequence the operations correctly and prevent
failures.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-15 21:54:00 +00:00
Morten Priess
fa61a047a6 Bluetooth: controller: Fix CIS Central FT calculation
For config CONFIG_BT_CTLR_CONN_ISO_RELIABILITY_POLICY, set
CIG_Sync_Delay fixed as high as possible, and calculate FT by iteration.
This favors utilizing as much as possible of the Max_Transport_latency,
and spreads out payloads over multiple CIS events (if necessary).

Add exit with cleanup as ll_cig_parameters_commit may fail after
creating new CIG/CIS instances.

Fixes issue #59605.
Fixes EBQ test HCI/CIS/BI-12-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-15 21:52:18 +00: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
Mariusz Skamra
76e17857e8 Bluetooth: audio: vocs: Refactor bt_vocs object
This adds refactor of bt_vocs object that is common interface for client
and server commands. As the bt_vocs_client is significantly larger than
bt_vocs_server the memory usage is not optimized when bt_vocs has an
union of those. Thus RAM consumption has been minimized by using
CONTAINER_OF macro to reference either to bt_vocs_client or
bt_vocs_server instance that bt_vocs is a member of.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-14 18:10:32 +00:00
Mariusz Skamra
e84d76f90b Bluetooth: audio: vocs: Fix missing instance type checks
The VOCS API uses `bt_vocs` object to reference both client and server
instance. This adds missing instance type checks to avoid invalid API
usage.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-14 18:10:32 +00:00
Pavel Vasilyev
ad0ea14b2f Bluetooth: Mesh: Add delay for Proxy Service registration
When settings_load() is not called from system workqueue, but still
called from a cooperative thread, rescheduling during the settings
loading can wake up system workqueue and try to register the Mesh
Proxy Service, which can not be allowed yet. This is the case for bsim
tests.

Postpone registering the service with some small timeout.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-14 18:09:54 +00:00
Mariusz Skamra
d74b9eb6b9 Bluetooth: audio: tbs: Fix possible buffer overflow
This fixes possible buffer overflow that may happen when `buf->len`
equals `buf->size` while adding null terminator.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-14 18:09:31 +00:00
Pavel Vasilyev
f997dc3842 Bluetooth: Mesh: Keep Composition Data Page 128 if RPR Server is present
According to section 4.2.2.4, Compositiion Data page 128 shall be
present if the node supports Remote Provisioning Server (section
4.2.2.4).

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-14 13:35:19 +00:00
Pavel Vasilyev
9122c514ab Bluetooth: Mesh: Use NRPA for private proxy advertisements
According to sections 7.2.2.2.4 and 7.2.2.2.5 of MshPRTd1.1v20,
when starting Private Node Identity or Private Network Identity, the
node shall use either RPA or NRPA and the advertising address. The
address shall be regenerated when Random field is regenerated.

Use BT_LE_ADV_OPT_USE_NRPA options to make advertiser generate and use
NRPA on every start of advertising Private Node Identity or Private
Network Identity.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-08-14 13:35:11 +00:00
Emil Gydesen
db2624def4 Bluetooth: BAP: Remove scan and PA sync from broadcast sink
This removes the scanning and PA sync capabilities from the
broadcast sink implementation, moving the responsibility of this
to the application layer.

The reason for this is to add more flexibility and choice to the
upper layers, while simplifying the Broadcast Sink implementation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:34:26 +00:00
Emil Gydesen
5b888c361d Bluetooth: BAP: Shell: Remove use of broadcast sink scan API
The broadcast sink scan API is no longer used by the BAP
shell, which handles everything related to PA sync and scan
itself now.

It has also been made easier to sync to a broadcast
source by simply using create_broadcast_sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:34:26 +00:00
Emil Gydesen
09116e1100 Bluetooth: Shell: Add selected_per_adv_sync
Add support for selecting a periodic advertising
sync object for use. This will also be available outside
the scope of bt.c via the extern declaration.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:34:26 +00:00
Emil Gydesen
4f966de74b Bluetooth: CAP: Add cap stream send and tx sync
Add bt_cap_stream_send and bt_cap_stream_get_tx_sync for
CAP streams

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
Emil Gydesen
e882847cf3 Bluetooth: BAP: Add can_send field to bt_bap_ep_info
This makes it easier to check if a stream, or ep, can send.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-08-14 13:33:57 +00:00
Rubin Gerritsen
5e44f2761b Bluetooth: ISO: Fix HCI SDU length sent to controller
Fixes a race condition that could occur if the TX queue was read out
before iso_has_ts was set. In that case, the provided buffer is of
wrong length.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-08-11 09:12:12 +02:00
Mariusz Skamra
73be1430b2 Bluetooth: gatt: Fix setting actual error in notify_cb
This fixes return error from notify_cb function that was never set up.
As the result, the functions like bt_gatt_notify_cb and bt_gatt_indicate
returned invalid error when failed to send notification.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-10 16:01:01 +03:00
Andries Kruithof
ca6adf1364 Bluetooth: controller: some arguments are unsigned instead of int
There are some calls to ull_adv_aux_pdu_set_clear that are set to 0
but the argument is actually unsigned. This PR replaces the '0'
with '0U'

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-08-10 08:13:43 +00:00
Ingar Kulbrandstad
d36697ac53 Bluetooth: Mesh: Fixed OP_AGG_SRV dependency of OP_AGG_CLI
The OP_AGG_SRV is dependent that the OP_AGG_CLI is add
for the OP_AGG_SRV to work. Moved the define of OP_AGG_CLI
so it will call op_agg_send without the OP_AGG_CLI.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-08-09 18:15:32 +03:00
Ingar Kulbrandstad
eafa2bb81b Bluetooth: Mesh: Fixed shell call to metadata-encode
The call to metadata-encode call in code and documentation
does does not match. Because the shell call in the documentation
looks correct the shell call in the code has been changed by
removeing the double metadata request.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-08-09 18:14:41 +03:00
Morten Priess
d21e3e3514 Bluetooth: controller: Fix CIS offset equivalent calculation
First implementation had a math error where the offset would be the
remainder from division (modulo). It should have been an ISO interval
minus the remainder. Refactored to not use modulo.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-09 08:40:52 +00:00
Aleksander Wasaznik
8e5fd3990f Bluetooth: Host: Explicitly ignore return value of auth latch
Fixes a coverity-reported issue by explicitly ignoring the return value
of the cas-operation. The return value is the old value, but we are not
interested in it in the situation when we just want to initialize a
value if it is in the uninitialized state.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/60474

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-08-09 08:33:47 +00:00
Morten Priess
b0ab952ffe Bluetooth: controller: Prevent ULL stuck in semaphore
In certain scenarios, the semaphore sem_ticker_api_cb may be taken
during attempt to complete a synchronous ticker operation such as start
or stop, but is never released via ull_ticker_status_give. This could
happen if ticker temporarily runs out of ticker operation slots for any
ticker client.
The consequence of ULL stuck waiting in semaphore is anything from
allocation assertions to watchdog timeouts.

This commit also sets a timeout on ull_disable calls, which relies on
the disable callback being invoked from 'done'. Invocation of 'done' is
mandatory, and code shall not allow that not to happen, but to avoid
hiding the real cause, the semaphore now has a timeout which causes
assertion in the location the issue occurred.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-09 08:33:34 +00:00
Morten Priess
3ad58fde71 Bluetooth: controller: Introduce vendor ticker operations for ULL_LOW
Allow vendor configuration of addition ticker user operations for
TICKER_USER_ID_ULL_LOW.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-09 08:33:04 +00:00
Morten Priess
e1f4452798 Bluetooth: controller: Use mayfly_is_running() in csrand_get()
Check mayfly_is_running() to determine use of blocking- or non-blocking
version of lll_csrand, instead of k_is_in_isr().
As mayflies run in ISR context for Nordic platform, change will have no
impact on Nordic configuration.

For vendors using META_IRQ mayflies, implementation will now prevent
blocking and reduce latencies and jitter in soft-realtime code.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-08-09 08:32:55 +00:00
Troels Nilsson
70f62adbde Bluetooth: Controller: Fix bug in read_codecs_v2()
The loop for copying the vendor specific codecs was using num_std_codecs
instead of num_vs_codecs

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-07 11:27:13 +02:00
Dmitry Lukyantsev
34a966f219 doc: Fix a typo
Fix a typo in the spelling of "current".
Add "current" to spelling.txt.

Signed-off-by: Dmitry Lukyantsev <dmitrylu@google.com>
2023-08-04 21:18:43 +00:00
Jonathan Rico
4433ff7154 Bluetooth: l2cap: add debug print for EATT
Add debug print when a buffer intended for ECRED is segmented
unnecessarily.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
2bbda0fbe4 Bluetooth: att: allocate RSP buffer from same channel as REQ
Using a different channel for responding to a request is forbidden by spec.

The allocator was especially flawed as it iterated over all the EATT
channels to find one w/ a big enough MTU, but the sending was still done
over the same channel as the REQ.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
e195ae2d09 Bluetooth: att: re-use REQ buf for RSP
This to ensure we don't fail to send a response and never get an ATT
TIMEOUT due to ACL TX buffer starvation caused by other users of the stack.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
828be80986 Bluetooth: att: use a dedicated metadata struct for RSP PDUs
The ATT module has provisions to queue a packet/buffer for sending later if
it can't send it right away. For example if the conn.c tx context
allocation fails.

This unfortunately doesn't work if the buffer can't get allocated in the
first place, or if the ATT metadata can't also be allocated.

The metadata is allocated from a global pool set to the same number as
conn.c TX contexts. That can lead to a situation where other users of ATT
manage to queue a bunch of buffers (e.g. the app spamming GATT
notifications), depleting the number of ATT metadata slots so that none are
available.

When none are available, and we receive an ATT REQ, we try to allocate one,
fail, and drop the buffer (!). That pretty much guarantees an ATT timeout.

As a workaround for this, use a per-channel metadata slot, that is only
used for completing transactions.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
ad36d0d9cc Bluetooth: att: log address on timeout
This is useful in multilink scenarios, especially since there is not user
callback when the ATT channel times out.

Adding a user-facing callback should ideally also be done, but just logging
the address already provides useful insight.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Jonathan Rico
32f719122e Bluetooth: att: return INSUFFICENT_RESOURCES on PDU alloc failure
Easier to debug that way.

Ideally we'd have more error codes/logging instead of just returning
UNLIKELY for most errors.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-08-04 15:06:05 +02:00
Herman Berget
b0e9cb3f48 Bluetooth: Host: Use RPA as responder address if BT_PRIVACY=y
When a PAwR sync connects to a PAwR advertiser and CONFIG_BT_PRIVACY
is enabled a Resolvable Private Address will be used. Use that
as responder address instead of the identity address to match what
the central sees.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2023-08-03 13:18:27 +02:00
Troels Nilsson
0a2d538c2b Bluetooth: Controller: Remove separate done memq
The separate done memq was introduced to handle the old LLCP
stalling processing of the rx queue; This is no longer an issue with
the new LLCP, so we can remove it

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-08-02 16:39:45 +02:00
Donatien Garnier
e4bcd6b92c Bluetooth: Host: Check connection status before sending credits
Upon receiving a L2CAP PDU, only send credits back if the L2CAP channel
hasn't been disconnected. The recv() callback called from
l2cap_chan_le_recv() can trigger a disconnect, which would cause an
assert failure when attempting to send credits back.

Signed-off-by: Donatien Garnier <donatien.garnier@blecon.net>
2023-08-02 14:06:40 +02:00
Mariusz Skamra
d511ef44ed Bluetooth: audio: tbs: Refactor service definition macro
This removes code duplications by unifying GTBS and TBS service
definition macros.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-01 11:58:56 +02:00
Mariusz Skamra
49fefcfddf Bluetooth: audio: tbs: Fix List_Item_Length value in CCL
This fixes setting invalid List_Item_Length in Current Calls List.
The fix complements 9c7ef8e.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-08-01 11:58:39 +02:00
Lars Knudsen
96bc04f7ac shell: Fix faulty error check in bt shell
bt_addr_le_to_str returns a length of bytes needed
for string conversion, not an error code.

Signed-off-by: Lars Knudsen <lakd@demant.com>
2023-07-31 19:39:26 +00:00
Jonathan Rico
a7cf7eb393 Bluetooth: l2cap: change connected cb call condition for ECRED
This was recently refactored (in #58440). But it introduced a bug in which
some channels were connected but not the whole list asked for by the peer.

In that case, `result` will not be `SUCCESS` but we still want to call the
`connected` callback as the peer will consider those channels to be
connected when we send the response.

The symptom is that EATT channels are being instantiated, but not
considered connected (ie. usable by the stack).

Also introduce a test that has asymmetric channel resources (5 on central
vs 2 on peripheral) to reproduce the bug.

Fixes #60212

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-07-31 19:39:09 +00:00
Jonathan Rico
8f3e0fdc02 Bluetooth: att: fix bt_eatt_count()
Make `bt_eatt_count()` return what it says on the tin, ie. the number of
channels that are actually connected.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-07-31 19:39:09 +00:00
Emil Gydesen
0081ecd626 Bluetooth: ISO: Add advanced broadcast ISO parameters
Add support for setting advanced broadcast ISO parameters
using the ISO test commands. This allows the host to set
ISO parameters that the controller normally would handle.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-31 09:04:52 +00:00
Emil Gydesen
5a66daa94d Bluetooth: ISO: Add broadcast RTN check in valid_chan_io_qos
The RTN value range for broadcast is more limited than
connected ISO.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-31 09:04:52 +00:00
Emil Gydesen
63aca8d868 Bluetooth: ISO: Add advanced unicast ISO parameters
Add support for setting advanced unicast ISO parameters
using the ISO test commands. This allows the host to
set ISO parameters that the controller normally would
handle.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-31 09:04:52 +00:00
Théo Battrel
ff54350ef0 Bluetooth: Host: Remove 'Experimental' flag of EAD
Nordic Semiconductor has been testing the feature extensively on its CI.
The tests includes the sample data and the PTS tests.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-07-28 17:48:16 +02:00
Rubin Gerritsen
88f161778a Bluetooth: Controller: Kconfig: Move BT_LL_SW_SPLIT specific configs
These configs are very tied to the BT_LL_SW_SPLIT implementation,
so it makes sense that these are only visible when that link layer is
used.

For the ones that may be used by other controllers in the future,
a dependency has been added.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2023-07-27 10:20:55 +02:00
Troels Nilsson
c0649ef694 Bluetooth: Controller: Fix truncation of adv. data
Truncation of advertising data has to be done at a PDU
boundary; Including only part of a PDUs advertising data is
not allowed

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-27 10:20:18 +02:00
Troels Nilsson
e0370f5439 Bluetooth: Controller: Stop following aux ptr if DATA_LEN_MAX is hit
If the aux scanner already has CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX
advertising data, there is no point in following an aux ptr -
instead flush the data and produce an incomplete report

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-27 10:20:18 +02:00
Jonathan Rico
0a8bbbda4a Bluetooth: adv: add USE_NRPA advertising option
Allows the application to force the use of an NRPA.

This is applied regardless of any other roles running (ie scanner) or
advertising type.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-07-25 10:47:37 +02:00
Alperen Sener
dbb0b30bdd bluetooth: mesh: increase mesh scan window
Increaing mesh scan window in order to reduce the number
of messages colliding into scan window end which happens
every 30ms currently. Increasing the window to 3000ms in
order to improve performance.

Keeping 30ms window only for legacy advertiser support.

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2023-07-25 09:23:12 +02:00
Troels Nilsson
00f3e44689 Bluetooth: Controller: Fix missing endianness conversion in scan_enable
Both duration and period are uint16 and thus require endianness conversion

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-25 09:14:02 +02:00
Mariusz Skamra
c2402a4368 Bluetooth: att: Make bt_att_chan_create_pdu static function
This fixes missing `static` function specifier.
The bt_att_chan_create_pdu is not called outside of att.c.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-24 09:09:58 +00:00
Mariusz Skamra
0fa7c01adc Bluetooth: att: Remove unused bt_att_free_tx_meta_data function
This function seems to unused thus can be safely removed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-24 09:09:44 +00:00
Anders Storrø
878d15cf94 Bluetooth: Mesh: Align handling of seg_ack to spec
Updates the handling of incoming seg ack messages to comply with
the mesh protocol specification, section 3.5.3.3.2 and section
3.5.3.3.3.

Previous implementation did not restart the retransmission timer unless
the incoming ack contained at least one segment newly marked as
acknowledged. According to the spec, the timer should be restated
regardless. The implementation depends on the retransmission
timer to end the transmission early if there was no more retransmission
attempts. Checks have been added to ensure that this now happens
immediately.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-07-24 09:07:59 +00:00
Lucas Mathias Balling
b8546150a3 Bluetooth: Controller: Added ISO CH feature bit check in le_create_cis
Check that the Isochronous Channels (Host Support) feature bit is set
before creating a CIS.

Signed-off-by: Lucas Mathias Balling <lutb@demant.com>
2023-07-24 09:06:32 +00:00
Vinayak Kariappa Chettimada
63f718f9b8 Bluetooth: Controller: Fix coverity issue 318648
[Coverity CID: 318648] Explicit null dereferenced in
subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Fixes #59002.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-24 09:05:06 +00:00
Emil Gydesen
bf153e576b Bluetooth: CCP: Fix coverity issue for current_inst == NULL
In discover_next_instance coverity did not consider the
ASSERT and warns about possibly dereferecing current_inst
which could be NULL. Modifed the code slightly to make
Coverity happy.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-21 10:54:01 +00:00
Flavio Ceolin
ddd2bc94e2 bt: mesh: shell: Fix possible buffer overflow
Fix possible overflow in rpr_scan_report.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-20 11:09:50 +00:00
Flavio Ceolin
e55af04e65 bt: audio: shell: Fix possible buffer overflow
Check the size of the search argument in cmd_media_set_search
before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-20 11:09:50 +00:00
Flavio Ceolin
02e70f509f bt: audio: shell: Fix possible buffer overflow
Check the size of the search argument in cmd_mcc_send_search_raw
before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-20 11:09:50 +00:00
Flavio Ceolin
fbd56fd920 bt: host: Fix possible buffer overflow
Check in bt_conn_le_start_encryption if the given
ltk fits in bt_conn.ltk before copying it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-07-20 11:09:50 +00:00
Magdalena Kasenberg
6135ae0fa0 bluetooth: audio: ascs: Fix Codec Config initiated by server
The Codec Specific Configuration Parameters provided by server was
not copied at bt_ascs_config_ase. Detected by PTS in BAP/USR/SCC PTS
test cases, because no LTV values appeared in ASE Codec Configured
notification.

Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
2023-07-20 10:46:55 +00:00
Stine Åkredalen
e5fcca6e99 Bluetooth: mesh: Update default values for transport SAR configuration
Updated SAR default values to align with the latest mesh 1.1 drafts,
and relevant Bsim tests.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2023-07-19 11:07:07 +00:00
Emil Gydesen
bbbc28a0ba Bluetooth: CAP: Always register BAP callbacks with CAP callbacks
Modified bt_cap_stream_ops_register to always register BAP callbacks
to ensure that the callbacks are always forwarded (unless later
overwritten by the application...)

The CAP Initiator Unicast will still register the callbacks itself,
to ensure that the unicast procedures still work even if
bt_cap_stream_ops_register was never called.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-18 11:11:12 +00:00
Emil Gydesen
a2ceded56f Bluetooth: ASCS: Update ISO QOS based on BAP QOS
When a CIS is established for the peripheral, then not all
QOS values are completely valid as they are simply missing
from the CIS established event. This commit updates the
missing fields based on the QOS settings provided by the
BAP Unicast Client during QoS Configuration of the endpoint.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-18 11:09:51 +00:00
Mariusz Skamra
c09c4181cf Bluetooth: audio: tbs_client: Minor Kconfig refactor
This intoduces dedicated Kconfig option to enable TBS client,
that makes the configuration more intuitive.
While configuring GTBS only, the user does not have to explicitly set
the BT_TBS_CLIENT_MAX_TBS_INSTANCES to 0 to disable the TBS client
functionality.
This adds also `tbs_only_client` test case to test the TBS only build
option.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-18 11:06:57 +00:00
Mariusz Skamra
650a0d8331 Bluetooth: audio: tbs_client: Separate GTBS from TBS instances
This improves the code readability and reduces flash usage a bit by
spliting up GTBS from other TBS instances in bt_tbs_server_inst
structure, so that some of the code could be conditionally compiled
out.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-18 11:06: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
Mariusz Skamra
03d296d546 Bluetooth: audio: ascs: Remove unused variable
The `ops` variable is unused, thus can be removed.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-18 11:05:03 +00:00
Emil Gydesen
bdd83e7239 Bluetooth: CAP: Shell: Add support for specific audio configs
Add CAP shell commands for starting specific audio configurations
based on the BAP specification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-18 11:04:25 +00:00
Emil Gydesen
b140b70a17 tests: CAP: Add testing of all audio configs
Add test cases to test all audio configurations with
all presets.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-18 11:04:03 +00:00
Kyra Lengfeld
c607179cc4 Bluetooth: Controller: Add missing nRF53x Tx Power Kconfig
This commit adds missing tx power config options for nRF53x SoCs, as
well as the missing Radio defines for nRF53x SoCs.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2023-07-17 21:41:08 +00:00
Anders Storrø
0e35bbbfd2 Bluetooth: Mesh: Add missing CBs for cfg_cli msg
Adds callback API for the following config client status messages:
- Composition data status
- Model publication status
- SIG model subscription list
- Vendor model subscription list
- Netkey list
- Appkey list
- SIG model app list
- Vendor model app list
- Key refresh status
- Heartbeat publication status
- Heartbeat subscription status

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-07-17 10:13:14 +00:00
Emil Gydesen
388af8fda4 Bluetooth: BAP: Remove stream->dir field
The BAP stream object should not have a dir field. The
dir field should be stored in the EP only (to avoid having two
fields storing the same value, causing possible issues).

The field was removed, and the places that use it has been updated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-14 16:48:41 +00:00
Emil Gydesen
983864e4d8 Bluetooth: BAP: Shell: Add support for multiple TX streams
Add support for transmitting on multiple streams, e.g.
with the simple `send` command or with the sine generator.

This extends the start and stop sine to take a "all"
paramter to start sending on all streams.

This also fixes an issue with the seq_num when multiple
streams are transmitting, since the timing may get delayed
which then delays the seq_num which are then scheduled too late.
The fix here is to only use the timer for the inital sequence
number when starting to send the sine way, and then increment it
per TX.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-14 16:47:42 +00:00
Carles Cufi
5824e95b1e Bluetooth: Host: Introduce BT_CONN_PARAM_ANY
Some controllers support additional connection parameter ranges
beyond what is described in the specification. Enabling this new option
allows the application to set any value to all connection parameters.
Tbe Host will perform no limits nor consistency checks on any of the
connection parameters (conn interval min and max, latency and timeou).
However, the Host will still use numerical comparisons between the
min and max connection intervals in order to verify whether the
desired parameters have been established in the connection.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-07-14 09:40:52 +00:00
Mariusz Skamra
1ca75e3b6e Bluetooth: audio: ascs: Fix invalid memset of QoS parameters
This fixes invalid memset of QoS parameters that may happen if Config
Qos operation is requested on ASE in QoS Configured state. In such case
if the requested parameters have been rejected, the ASE QoS parameters
shall remain unchanged (were memset instead). Otherwise, the stack shall
send QoS Configured state notification with cleaned up parameters (all
zero's) which was not done.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-13 09:23:24 +02:00
Anders Storrø
8c7ffac4a6 Bluetooth: Mesh: Fix err in mod_app_list packing
Fixes erroneous packing/unpacking of model app list messages
in the configuration client and server. According to the mesh 1.1
protcol spec (4.3.1.1) two app indexes shall be packed in a 3 octet
interleaved format. The current implementation packs them in 4 octets.

This commit also provide a helper function for unpacking key indexes
as public API to facilitate future config model callback API.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-07-12 14:37:23 +02:00
Emil Gydesen
b9c16c9cdd Bluetooth: ISO: Add comment for peripheral SDU size
Adds a comment stating the state of the peripheral SDU size
and why it is being assigned the PDU size on CIS established.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-12 14:36:28 +02:00
Lingao Meng
75cfa34481 Bluetooth: Mesh: Discard iv update 1 0 --> 1 1
According spec, for the same iv index, iv update flag
should trans to false, when iv update procedure complete.

When local environment has attack-node
to store old network beacon(1,1), and re-send same
network beacon(1,1) after 192hours, will cause whole
bluetooth mesh network broke.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-07-11 18:19:27 +00:00
Alperen Sener
4e83af0dd9 Bluetooth: Mesh: Fix OOB info and URI hash in scan report message
OOB information should be in little endian in scan report messages.
URI hash should be retrieved as it is from unprovisioned device beacon
and encoded likewise into scan report messages like we do for UUID.

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2023-07-11 18:18:48 +00:00
Mariusz Skamra
36f35f8335 Bluetooth: audio: ascs: Fix possible ASE leak
This fixes possible ASE leak in bt_ascs_config_ase in case
ascs_ep_set_codec function returns an error.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-11 15:05:51 +02:00
Mariusz Skamra
abf6fc37d0 Bluetooth: audio: ascs: Remove redundant ase_cleanup function
This removes redundant ase_cleanup function, as bt_ascs_release_ase
can be called instead.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-11 15:05:43 +02:00
Mariusz Skamra
0af2a75a7e Bluetooth: audio: ascs: Refactor ASE Disable handler
This removes code duplicates.
ASE Disable operation handler has been refactored by providing the
`rsp` pointer as one of the function parameters. ascs_cp_rsp_add is
not called from ase_disable explicitly, so the contents of the
response buffer are not changed in case the ase_disable is called
from non control point context.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-11 15:05:43 +02:00
Mariusz Skamra
2abdeab768 Bluetooth: audio: ascs: Refactor ASE Release handler
This removes code duplicates.
The ASE Release operation handler has been refactored by moving the state
validation check to the ase_release function body and providing the
`rsp` pointer that is later filled. ascs_cp_rsp_add is not called from
ase_release explicitly, so the contents of the respons buffer are not
changed in case the ase_release is called from non control point context
e.g. `disconnected` callback.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-11 15:05:43 +02:00
Mariusz Skamra
bc710a49f1 Bluetooth: audio: unicast_server: Do not store metadata if rejected
This moves copying of parameters after application return value
validation so that the metadata is not stored if rejected.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-07 19:03:55 +00:00
Vinayak Kariappa Chettimada
a2ebec5c64 Bluetooth: Controller: Fix coverity issue 318807
[Coverity CID: 318807] Dereference before null check in
subsys/bluetooth/controller/ll_sw/ull_iso.c

Fixes #59514.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-07 19:01:04 +00:00
Emil Gydesen
275c86d399 Bluetooth: BAP: Shell: Merge the unicast and broadcast stream structs
Merging the two structs cleans up significant amount of code
and makes it easier to expand later.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 14:53:24 +02:00
Emil Gydesen
d17cde46d1 Bluetooth: BAP: Shell: Improve handling of PSN when sending
Previously the calculation of the PSN was done using
just a timer. This would not work correctly when
attempting to send multiple packets in a single SDU
interval (e.g. to enqueue 2 or more).

Previously we only ever attempted to send 1 packet in
the `sent` callback but scheduling the work item. However
in the case that the `sent` callback was called twice
before the work item had been triggered (possible due
to the priority of the RX thread being higher than the
system workqueue thread). This has been modified so that
if we can enqueue more packets in the lc3_audio_send_data
function, we re-enqueue the work item. We re-enqueue rather
than sending multiple in a single call to avoid blocking
other items on the system workqueue from being scheduled.
This could cause possible missed intervals (if other workqueue
items are processed), but it should be OK from a ISO perspective,
and the new PSN calculator handles this much better.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 14:53:24 +02:00
Emil Gydesen
06dc36d268 Bluetooth: BAP: Shell: Fix formatting in lc3_audio_send_data
Some formatting was not compliant with the coding style.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 14:53:24 +02:00
Emil Gydesen
d02a215a14 Bluetooth: BAP: Shell: Add support for TX retry when sending sine
Modify lc3_audio_send_data to be triggered on a delayable
k_work so that we can retry it with a delay if it fails for whatever
reason.

This also moves the calculation of the seq_num closer
to when it is used, which makes sense as it is based on
a timed calculation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 14:53:24 +02:00
Mateusz Kapala
5b44ebe159 bluetooth: host: smp: Add bondable flag overlay per connection
The current API for changing the bondable mode uses the global flag.
With Zephyr support for multiple Bluetooth identities, the API for
changing the bondable mode should be more fine-grained.
The bondable requirements of one identity should not have an impact on
another identity which can have a different set of requirements.
This change introduces function to overlay bondable flag per
connection.

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
2023-07-07 14:55:29 +03:00
Pavel Vasilyev
8fc22e14a9 Bluetooth: Mesh: Remove TODO file is outdated
Remove TODO file is outdated.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-07-07 10:51:10 +02:00
Pavel Vasilyev
2bf61ee8d6 Bluetooth: Mesh: Restructure Kconfig options
Current structure of Bluetooth Mesh Kconfig options is quite messy.
This makes impossible to understand which configuration belongs to
which feature. Especially when using interactive Kconfig interface, like
menuconfig or guiconfig.

This commit restructures the options grouping them by protocol layer
they belong to (Network, Transport, Access, etc.), or specific feature
(LPN, Friend, Proxy, Relay, etc.), or implementation (Advertiser, Shell,
Persistent storage). Amount of supported keys, subnets, group addresses
and labels are grouped under Capabilities menu. Generic options that
don't fall to any category are kept at the root menu. For better
visibility, if a specific feature or layer has more than 1 option, they
are hidden under menu.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-07-07 10:51:10 +02:00
Aleksandr Khromykh
9b4d080419 Bluetooth: Mesh: add shell statistic commands
Commit adds commands to get and to clear
the frame statistic.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-07-07 09:20:33 +02:00
Aleksandr Khromykh
7199425792 Bluetooth: Mesh: add statistic module
PR adds the statistic module to estimate frame handling.
The module helps to understand the ratio of
the received\relayed\dropped\transmited frames.
That shows the efficiency of the current configuration\implementation.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-07-07 09:20:33 +02:00
Emil Gydesen
3f2daa256c Bluetooth: BAP: Fix issue with pa sync and ID in broadcast_sink_create
The broadcast_id and the pa_sync fields should be set before calling
broadcast_sink_add_src as broadcast_sink_add_src will those values to
compare against other receive states.

The function was also missing a call to broadcast_sink_cleanup
for the newly allocated sink in case there was an error.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-07 09:20:23 +02:00
Morten Priess
12ef3453c6 Bluetooth: controller: Fix CIG state overwrite in parameters_commit
The CIG state variable is set to CIG_STATE_CONFIGURABLE, but then
cleared by memcpy from configuration cache. Set state after memcpy.

Fixes EBQ test /HCI/CIS/BI-10-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-07-07 09:19:27 +02:00
Morten Priess
016774a06b Bluetooth: controller: Fix link_tx overwrite at Central CIS creation
In the case where memq_deinit in LLL flushing ends up with the free
link being the link provided by the CIS instance, and pointed to by
lll.link_tx_free, the free counter data in the link element is
overwritten during central CIS creation.

This has the effect that when starting the next CIG, there will suddenly
be 0 links available, and controller fails assertion.

By saving- and restoring the lll.link_tx before and after CIS
configuration cache copying, the free counter is intact.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-07-07 09:19:27 +02:00
Troels Nilsson
c7627cab29 Bluetooth: Controller: Fix a couple of compiler warnings
Remove set but unused enable variable

Flag sync_iso_create_get() function

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-05 12:34:23 +00:00
Troels Nilsson
287eb04d6f Bluetooth: Controller: Don't report when AUX_ADV_IND is not received
An advertising report must not be generated unless the AUX_ADV_IND
has been received (for ADV_EXT_IND with an auxptr)

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-05 12:34:23 +00:00