Commit graph

8508 commits

Author SHA1 Message Date
Jonathan Rico
18c3571145 Bluetooth: conn: check for disconnected earlier when sending
Verify the connection is active before popping the buffer from the TX
queue.

The current behavior enables a race condition between `create_frag` and
the connection being torn down, as `buf` can be popped from the TX queue
but not destroyed by `bt_conn_process_tx`.

In that case, `buf` will be leaked.

Original analysis and fix proposal by @watsug.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Reported-by: Adam Augustyn<watsug@gmail.com>
2024-02-09 16:27:50 -06:00
Emil Gydesen
7cfc8b3340 Bluetooth: BAP: Reset _prev_seq_num on ISO connection
Once an ISO channel has connected, the sequence number
always starts at 0. This reset was missing in the implementation,
and the _prev_seq_num from a previous connection may have
been kept.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-09 14:39:40 +01:00
Thomas Ebert Hansen
b15452bd08 Bluetooth: controller: Fix Data Length Update
Before a LL_FEATURE_REQ is sent, verify that the Data Length Update
procedure is still supported as it could have been unmasked as the result
of a previously completed Feature Exchange procedure.

Add unit test to verify the case of enqueuing both a
Feature Exchange procedure and Data Length Update procedure, where the
Feature Exchange procedure would result in the unmasking of the Data
Length Update procedure.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2024-02-09 13:46:41 +01:00
Thomas Ebert Hansen
8c412971a9 Bluetooth: controller: Fix PHY Update TX Q
Resume the TX Data Q when a LL_UNKNOWN_RSP is recieved instead of a
LL_PHY_RSP.

Update PHY Update unit test with more coverage of the TX Data Q pause
state.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2024-02-09 13:46:41 +01:00
Alexander Svensen
199487be54 Bluetooth: Host: Send status for terminated directed adv
- Fix bug where status was only sent for legacy adv

Signed-off-by: Alexander Svensen <alexander.svensen@nordicsemi.no>
2024-02-08 10:11:34 +00:00
Pavel Vasilyev
9171ee24da Bluetooth: Mesh: Warn if trying to send adv while suspended
This will warn if any of the mesh module will try to send anything while
the stack is suspended. Not clear what to do here as both advertisers
(legacy and ext) behaves differently. The legacy advertiser has a
thread which is stopped after the `bt_mesh_adv_disable` call and any
sent advs after suspending the stack will stay in the pool until the
advertiser is resumed. The extended advertiser will schedule its work,
but then fail because `ext_adv->instance` value is NULL, but will call
`bt_mesh_send_cb.start` with error `-ENODEV`. What to do with these 2
behaviors is unclear at the moment. Ideally none of the mesh stack
modules should call `bt_mesh_adv_send` after the stack was suspended, so
if this warning appears, the faulty module wasn't stopped properly and
this should be fixed. If not to add the adv to the pool, then it kind
of gets lost as the implementation probably expects one
of `bt_mesh_send_cb` callbacks which will never be called. Leaving the
warning until clear customer request comes.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-02-08 10:11:19 +00:00
Ivan Iushkov
a3cbf8e2ac Bluetooth: fixing null-pointer dereference in l2cap channel destroyer
During local testing with UBSAN enabled, warning was reported:
bluetooth/host/l2cap.c:980:25: runtime error: member access
within null pointer of type 'struct k_work_q'

It turned out that le_chan->rtx_work.queue can be NULL.
Since null-pointer dereference is a UB, additional check
was added to ensure we don't access
`le_chan->rtx_work.queue->thread` when
`le_chan->rtx_work.queue == NULL`

The same changes applied to l2cap_br.c

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2024-02-08 09:48:02 +00:00
Ivan Iushkov
e8d090011b Bluetooth: fixing UBSAN warnings related to Codec Configuration
During local testing with UBSAN enabled, warning was reported:
bluetooth/host/iso.c:237:2: runtime error: null pointer passed
as argument 2, which is declared to never be null

It turned out that when datapath doesn't contain
codec information, cc_len is 0 and cc is NULL

In order to avoid UB,
now we call memcpy only when cp->codec_config_len > 0

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2024-02-08 09:48:02 +00:00
Ivan Iushkov
b1e9f86378 Bluetooth: Fixing UBSAN warning in CTE field parsing in adv.c/scan.c
during local testling, UBSAN reported the following warnings:
- bluetooth/host/adv.c:2067:19: runtime error: shift exponent
255 is too large for 32-bit type 'long unsigned int'
- bluetooth/host/scan.c:828:18: runtime error: shift exponent
255 is too large for 32-bit type 'long unsigned int'

It turned out that we can't use BIT() macro directly on
bt_hci_evt_le_per_advertising_report::cte_type field.
According to Core Spec, `cte_type = 0xFF` corresponds
to `No contstant tone extension`.

Added separate function to convert CTE bit field from
HCI format to bt_df_cte_type

Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
2024-02-08 09:48:02 +00:00
Pavel Vasilyev
548851ac7a Bluetooth: Mesh: Fix solicitation PDU tx dep on proxy
If `CONFIG_BT_MESH_GATT_SERVER` is disabled or the advertising set
doesn't support proxy adv, the solicitation PDU will not be sent.
However, solicitation PDU transmission doesn't depend on the proxy
feature of the device it sends. Therefore, solicatation PDU should be
sent regradless of `CONFIG_BT_MESH_GATT_SERVER` option and advertiser
tag.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-02-08 09:04:48 +01:00
Kamil Piszczek
129b73ce26 bluetooth: gatt: remove operation infix from authorization callback API
Removed the "operation" infix from the bt_gatt_authorization_cb
callback structure in the Bluetooth GATT header.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2024-02-07 15:36:25 +00:00
Emil Gydesen
df3fcc9b1f Bluetooth: CAP and HAP: Shell: Replace - with _ in commands
The dash (-) makes clang-format unhappy, and most other commands
use underscore (_) instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-07 15:26:29 +00:00
Pavel Vasilyev
e495876db6 Bluetooth: Mesh: Reset solicitation settings before calling reset cb
Trigger erasing solicitation settings before calling
`bt_mesh_settings_store_pending` and `bt_mesh_prov.reset` callback.
The `bt_mesh_settings_store_pending` flushes every settings that is
pending to be erased. The `bt_mesh_prov.reset` callback must be called
as the last step because a user is free to do anything from this
callback including rebooting or reprovisioning the device.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-02-07 15:25:18 +00:00
Emil Gydesen
590d3e1114 Bluetooth: BAP: Broadcast source enabling state transition fix
Since we may go from enabling to qos-configured state if the
call to bt_iso_big_create fails, that is a valid transition.
If bt_iso_big_create currently fails, then the source ends in a
state where it cannot be recovered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-06 09:51:16 +01:00
Emil Gydesen
f4b83415d6 Bluetooth: CAP: Fix uninitialized values in broadcast start
When CONFIG_BT_ISO_TEST_PARAMS is enabled then the
bt_bap_broadcast_source_param in
bt_cap_initiator_broadcast_audio_create had uninitialized values.

A general and future proof solution for this is to simply initialize
the entire struct to 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-06 09:50:53 +01:00
Emil Gydesen
b9056de5d1 Bluetooth: ISO: Fix duplicate log statements for PDU check
Modifies two log statements so that it is clear whether it
is failing to validate broadcast or unicast PDU sizes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 19:52:21 +00:00
Emil Gydesen
27abc1d944 Bluetooth: BAP: Broadcast assistant shell treat PA sync as bool
Modify the broadcast assistant commands that take the PA sync argument
so that it is treated as a bool. This allows users to use
"true", "on", "1" or "0x01" for true values and "false", "off", "0"
for false values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 12:40:23 -06:00
Troels Nilsson
8acca664d2 Bluetooth: Controller: Fix periodic adv data truncation
Advertising data has to be truncated at a PDU boundary

Similar to earlier fix for extended advertising reports

Found in several EBQ tests, including LL/DDI/SCN/BV-25-C,
LL/DDI/SCN/BV-21-C and LL/DDI/SCN/BV-46-C

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-02-05 18:18:57 +01:00
Lyle Zhu
4e7be1ecaa Bluetooth: Host: set valid SCO packet type
The SCO cannot be created if the eSCO is unsupported.
It is caused by the packet type cannot be set
correctly.

Set valid bitmap for SCO and eSCO packet type in
command "Accept Synchronous Connection Request".

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-02-05 17:46:49 +01:00
Emil Gydesen
017f59cb66 Bluetooth: BAP: Broadcast sink: Fix bis_sync in update_recv_state_base
In the update_recv_state_base function, we should update the
BASE with any new metadata that we have received (as that may
change while streaming). However, this function did not properly
keep the existing bis_sync values for the
subgroups, causing the bis_sync for all subgroups to be 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 17:46:31 +01:00
Emil Gydesen
43bc3200fa Bluetooth: BAP: Stop broadcast sink from removing receive state
The receive state may be added by the broadcast sink if not added
by the application, but even in that case when the broadcast sink
is deleted, we should not remove the receive state, as the receive
state may still container information about the PA sync that has a
lifetime not coupled with the broadcast sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 17:46:11 +01:00
Emil Gydesen
7643526086 Bluetooth: BAP: Do not send PA term request on local remove
If the receive state is locally removed, then we should not
request permission from the application, as that is implicit
when removing the source locally.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 17:45:45 +01:00
Emil Gydesen
cbc81b2a0f Bluetooth: Audio: Remove LC3 from the assigned numbers defines
The defines from the Bluetooth Audio assigned numbers are not
specific for LC3. This commit removes the LC3 infix and
the reference to LC3 in the documentation for them.

It also cleans up some of the documentation and
names of the enums.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 09:14:44 -06:00
Emil Gydesen
68ed2e019f Bluetooth: VCP: Fix missing guards for AICS and VOCS
Some places VCP accessed AICS and VOCS when it was not supported.
Also modify existing guards to be consistent with new guards.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 13:13:00 +01:00
Emil Gydesen
adb74f0f16 Bluetooth: MICP: Fix missing guards for AICS
Some places MICP accessed AICS when it was not supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 13:13:00 +01:00
Emil Gydesen
ab1b43ee1a Bluetooth: VCP/MICP: Fix VOCS and AICS instance counts
The VCP and MICP instances should use their respective
AICS and VOCS Kconfig options, rather than the overall
Kconfig options.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-05 13:13:00 +01:00
Emil Gydesen
065253c173 Bluetooth: CAP: Make unicast stop more similar to unicast start
Modify the parameters for bt_cap_initiator_unicast_audio_stop
so that they are more similar to
bt_cap_initiator_unicast_audio_start.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-04 19:54:18 -06:00
Emil Gydesen
ec549cebd5 Bluetooth: CAP: Make unicast update more similar to unicast start
Modify the parameters for bt_cap_initiator_unicast_audio_update
so that they are more similar to
bt_cap_initiator_unicast_audio_start.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-04 19:54:18 -06:00
Emil Gydesen
f35e9871d5 Bluetooth: CAP: Remove unicast group param from unicast_audio_start
Since we can always lookup the group from the streams, the
group parameter had no purpose.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-04 19:54:18 -06:00
Radoslaw Koppel
8f98b8b574 bluetooth: nordic: lll: Use direct ISR when applicable
This commit updates nordic lll controller to use
IRQ_DIRECT_CONNECT where applicable instead of
using IRQ_CONNECT with ISR_FLAG_DIRECT.

Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
2024-02-02 19:49:36 +01:00
Emil Gydesen
ec41dd9ba6 Bluetooth: Audio: Use BT_GATT_SUBSCRIBE_FLAG_VOLATILE
The LE Audio implementations do not really support bonding yet,
and removing subs on disconnect is the most effective (and correct)
way of ensuring that we do not subscribe more than once when we
re-discover after reconnection.

The broadcast assistant and the media control client does not
support multiple connections as of this commit, so they needed
special treatment. In the case that we do discovery on multiple
ACL connections, it is important that the existing subscriptions
are removed correctly by calling bt_gatt_unsubscribe.

In order to implement this change properly on some of the clients,
thet had no proper connection references or support
for clearing the data on disconnects, they had to be updated
as well.

The csip_notify.sh test has been disabled, as that expected a
notification in the client, but since this commit removes that
(until bonding is properly supported in the clients), then the
test will fail.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-02 09:34:52 -06:00
Emil Gydesen
922ac3c7c1 Bluetooth: Audio: Add missing error checks for calls to bt_gatt_subscribe
Several places the LE Audio clients called bt_gatt_subscribe without
checking the return value, which could cause some issues in the worst
case, and in the best case, cause some unexpected behavior.

Some implementations had a bit more updating to handle the new
behavior.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-02 09:34:52 -06:00
Troels Nilsson
89ce3566c0 Bluetooth: Controller: Fix handling of CTEInfo in le_ext_adv_report()
Handling of CTEInfo being present was missing; Fixes test failure of
LL/DDI/SCN/BV-89-C

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-02-02 09:30:06 -06:00
Lyle Zhu
d7328eac67 Bluetooth: Host: Set user data size for hfp tx pool
The user data size of hfp tx pool is zero.

There is not enough space to put tx_mate.

Use CONFIG_BT_CONN_TX_USER_DATA_SIZE to
set data size of hfp tx pool.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-02-02 14:09:38 +01:00
Vinayak Kariappa Chettimada
10fece0c1e Bluetooth: Controller: Fix PA sync-ed ACL supervision timeout
Fix Periodic Advertising Synchronization leading to
Peripheral ACL connection supervision timeout, due to
direction finding related radio hardware registers being
updated in the implementation that is not built for
direction finding feature support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-02-02 12:49:43 +01:00
Vinayak Kariappa Chettimada
83321eed41 Bluetooth: Controller: Fix coverity issue 340844
Fix coverity issue 340844, Uninitialized pointer read.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-02-02 12:49:30 +01:00
Vinayak Kariappa Chettimada
c5474085db Bluetooth: Controller: Fix coverity issue 340845
Fix coverity issue 340845, Uninitialized pointer read.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-02-02 12:49:19 +01:00
Vinayak Kariappa Chettimada
054dc35542 Bluetooth: Controller: Fix coverity issue 330027
Fix coverity issue 330027, Structurally dead code.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-02-02 12:49:07 +01:00
Vinayak Kariappa Chettimada
f214913e16 Bluetooth: Controller: Fix coverity issue 330043
Fix coverity issue 330043, Unsigned compared against 0.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-02-02 12:48:54 +01:00
Vinayak Kariappa Chettimada
f358243b26 Bluetooth: Controller: Enforce range for BT_CTLR_ADV_AUX_SYNC_OFFSET
Enfore a range for BT_CTLR_ADV_AUX_SYNC_OFFSET such that
it does not take negative integer values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-02-02 12:48:54 +01:00
Vinayak Kariappa Chettimada
8e5c9c3b8a Bluetooth: Controller: Fix MFIFO_DEFINE to reduce FLASH usage
Fix MFIFO_DEFINE to reduce FLASH usage by moving the pool
outside the struct that is static initialized.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-02-02 12:48:42 +01:00
Vinayak Kariappa Chettimada
550b16a04e Bluetooth: Controller: Fix missing ull_chan_reset call
Fix missing call to ull_chan_reset(), this fixes
uninitialized channel map being used after LL reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-02-02 12:43:07 +01:00
Ping Wang
2f138fad5f Bluetooth: Audio: MCC optional procedures actually optional
This change makes the optional procedures in the Media Control Client
optional and configurable through Kconfig.

Signed-off-by: Ping Wang <pinw@demant.com>
2024-02-02 12:42:55 +01:00
Andries Kruithof
38e0e6e555 Bluetooth: audio: BAP: fix Kconfig description
The description for BT_BAP_SCAN_DELEGATOR_BUF_TIMEOUT is a bit misleading.
Rewriting this to be more accurate

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-02-01 13:09:17 -06:00
huajiang zheng
3d9f76b8e5 Bluetooth: Host: add unregister connection callback function
[Description]
tests: shell: Restart bt will register the same connection callback twice.
Callback next node point to itself, when link established callback function
loop infinitely.
[Fix]
Unregister the previous callback to avoid register repeatedly.
[Test]
After bt init/disable times, create connection successfully.

Signed-off-by: huajiang zheng <huajiang.zheng@nxp.com>
2024-02-01 16:05:38 +01:00
Luis Ubieda
efb5d8372d Bluetooth: Host: Added Recycled evt notifying conn object is available
- Which allow listeners to attempt to use the freed connection object to
perform actions as e.g: start connectable advertisements.
- Refactored bt_conn_unref() so it does not access conn struct after
decrementing its reference count.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-02-01 14:31:27 +00:00
Andries Kruithof
3ef1b045ce Bluetooth: audio: fix bug in scan delegator sync
In the scan delegator when modifying the source we only want to
send a sync request to the upper layers if we are not yet synced,
and not also on a state change

Note that without this change the babblesim test for long writes
will fail

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

Scan del bugfix

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-02-01 14:37:40 +01:00
Andries Kruithof
c5dcc1a4ce Bluetooth: audio: bap: add support for long notifications
Add support for sending long notifications, coming
from a long read, back to the application

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-02-01 14:37:40 +01:00
Andries Kruithof
90a5d02710 Bluetooth: audio: bap: add support for long read
Make sure that buffers are large enough and add
semaphores so that we can do long reads

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-02-01 14:37:40 +01:00
Andries Kruithof
9887ebf471 Bluetooth: audio: bap: long write
Increase the buffer size to allow for long writes

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-02-01 14:37:40 +01:00
Emil Gydesen
e92e4c249d Bluetooth: Audio: Update return value of {cfg,cap}_get_val
The get_val functions will now return -ENODATA in case that
a value isn't found, instead of 0.

This makes them more similar to the meta_get_val functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-01 10:55:31 +01:00
Emil Gydesen
6c403da3cd Bluetooth: Audio: Shell: CAP change volume offset command
Add sthe change volume offset command to the CAP commander shell.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 21:35:17 -05:00
Emil Gydesen
4be42784ea Bluetooth: CAP: Commander change volume offset procedure
Adds the CAP Commander Change Volume Offset procedure.
This procedure changes the volume offset on one or more
CAP Acceptors, but not to the same value (unlike the
volume change procedure).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 21:35:17 -05:00
Emil Gydesen
562166b685 Bluetooth: MICP: Allow for multiple mic_ctrl cb registers
Modify the MICP microphone 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>
2024-01-31 21:35:00 -05:00
Emil Gydesen
029afad6c1 Bluetooth: CSIP: Add bt_csip_set_member_unregister
Add support for unregistering a CSIS as the CSIP set member.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 21:34:27 -05:00
Emil Gydesen
1da84e99aa Bluetooth: MPL: Fix track position in playing and stopped state
In the playing state, we should still increment the track position,
but just avoid notifying it.

If the track is stopped, then we set the track position to 0, which
we should always notify, regardless of whether the current track position
is 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 21:34:12 -05:00
Emil Gydesen
01d0f1a566 Bluetooth: PBP: Fix parsing and return issue with bt_pbp_parse_announcement
bt_pbp_parse_announcement was defined as uint8_t return value function,
but returned errno values, so it was modified to return an int instead.
The return values are also now more granular and documented.

The function also triggered a coverity issue with the way that it
parsed the data->data, as it would be marked as tainted. This should
be fixed by using the net_buf_simple API, which also improves on
some other parts of the code.

Finally the meta argument for the function was changed from an
unknown sized buffer, where the caller somehow had to know the
size of the metadata before calling the parsing function, to
an output pointer. This also omits the requirement for the
caller to always copy the metadata, where now it just
gets a pointer to the metadata in the bt_data struct. The application
can now always decide whether to continue to parse the metadata or
to copy it, using the pointer and the return value of the function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 21:33:56 -05:00
Emil Gydesen
13a357b019 Bluetooth: BAP: Update log for unicast iso recv without endpoint
Since we always set up the ISO data path for endpoints in both
directions (due to limitations in the ISO API), we can actually
receive valid (empty) SDUs on a CIS in a direction that has not
been configured.

This is not the ideal solution, but prevents unncessary LOG_ERR.
The ideal solution is to modify the ISO API to provide the
flexibility that BAP needs w.r.t. ISO data paths, but that is
a larger change for later.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 17:58:58 -06:00
Emil Gydesen
8b8569e1da Bluetooth: BAP: Add missing reset of client on disconnected
If we disconnect in the middle of e.g. a discovery, then
client-busy (and other values) were not correctly reset,
which effectively rendered the client useless.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 17:57:28 -06:00
Kristoffer Rist Skøien
ace435d0d1 Bluetooth: Audio: Moved seq_num check
Moved seq_num check to after bt_iso_chan_send.
This prevents WRN prints if ISO send fails.

Signed-off-by: Kristoffer Rist Skøien <kristoffer.skoien@nordicsemi.no>
2024-01-31 15:13:10 -06:00
Vinayak Kariappa Chettimada
2a6169e2fe Bluetooth: Controller: Fix coverity issue 340852
Fix coverity issue 340852, Uninitialized scalar variable.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-31 18:21:59 +01:00
Aleksander Wasaznik
9426309dbe Bluetooth: Host: Refactor bt_buf_get_evt
This is purely a syntactical refactor.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-01-31 17:50:35 +01:00
Aleksander Wasaznik
b6a10516b0 Bluetooth: Host: Remove bt_buf_get_cmd_complete
After the previous commit, this function no longer has any users.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-01-31 17:50:35 +01:00
Aleksander Wasaznik
1cb83a81f0 Bluetooth: Host: Remove use of bt_buf_get_cmd_complete
`bt_buf_get_cmd_complete` is broken due to
https://github.com/zephyrproject-rtos/zephyr/issues/64158, and fixing it
would require changing its signature and put even more complexity into
the HCI drivers, as it would require the drivers to perform an even
deeper peek into the event in order to observe the opcode.

Instead of the above, this patch removes the use of
`bt_buf_get_cmd_complete` and adds logic to allow the host to accept
command complete events in normal event buffers.

The above means performing a copy into the destination buffer, which is
the original command buffer. This is a small inefficiency for now, but
we should strive to redesign the host into a streaming architecture as
much as possible and handle events immediately instead of retaining
buffers.

This fixes https://github.com/zephyrproject-rtos/zephyr/issues/64158:
Like all command completed events, the completion event for
`BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS` is now placed in normal event
buffers. The the logic where the host discards this event is already
present. Since it's discarded, it will not interfere with the logic
around `bt_dev.cmd_send`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-01-31 17:50:35 +01:00
Stine Åkredalen
a1b9f0a7d6 Bluetooth: Mesh: fix SRPL always accepting sol pdus with sseq 0
Updated logic in srpl_entry_save.

Signed-off-by: Stine Åkredalen <stine.akredalen@nordicsemi.no>
2024-01-31 10:34:06 -06:00
Vinayak Kariappa Chettimada
e3357ef271 Bluetooth: Controller: Minor indentation of RXFIFO_DEFINE
Minor indentation of RXFIFO_DEFINE.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-31 15:52:47 +00:00
Vinayak Kariappa Chettimada
eb5ce8bfe0 Bluetooth: Controller: Fix RXFIFO_DEFINE to reduce FLASH usage
Fix RXFIFO_DEFINE to reduce FLASH usage by moving the pool
outside the struct that is static initialized.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-31 15:52:47 +00:00
Emil Gydesen
b173c21d9c Bluetooth: BAP: client: Add support for source ASEs disconnects
When the CIS of a source ASE disconnects, the server shall put
it into the QoS Configured state, which is not really part of the
state machine for source ASEs, but more like a hidden bonus state
change.

The state machine handler in the unicast client has been updated
to support this state change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-31 12:05:47 +00:00
Emil Gydesen
515ef17915 Bluetooth: Audio: Change samples and shell to use sinf
Change the samples and shell to use sinf instead of sin,
as that return the expect float data type, instead of
a double.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-30 12:45:26 +01:00
Ping Wang
6dcde57952 Bluetooth: Audio: improve BASS state logging to be more readable.
When debugging it is hard to remember each state value (e.g. 0, 1, 2,
3) means. Therefore, make functions to improve logging for humans.

Fixes #59679

Signed-off-by: Ping Wang <pinw@demant.com>
2024-01-29 13:20:18 +01:00
Ping Wang
c7d1dc3b42 Bluetooth: Audio: Use utf8_lcpy to copy UTF8 strings with termination.
use the function utf8_lcpy to ensure that UTF8 encoded strings are
properly copied and NULL terminated.

Fixes #42128

Signed-off-by: Ping Wang <pinw@demant.com>
2024-01-29 10:28:18 +01:00
Jonathan Rico
2d9b56d713 Bluetooth: L2CAP: remove metadata allocation
The only thing we put in there is the CID and that fits comfortably into
the (at least) 4-byte void pointer `user_data`.

This removes the dependency between `CONFIG_BT_ATT_TX_COUNT` and
`CONFIG_BT_L2CAP_TX_BUF_COUNT` since previously there was still a need
for an L2CAP context for every TX'd buffer.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-29 09:41:23 +01:00
Jonathan Rico
3a4fd5e23d Bluetooth: L2CAP: remove cb/userdata from TX metadata
They were never used.
Only thing to remove is `cid`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-29 09:41:23 +01:00
Jonathan Rico
77d8c2768e Bluetooth: L2CAP: initialize servers slist
Somehow it slipped through the cracks and didn't crash before.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-29 09:41:23 +01:00
Pavel Vasilyev
54c048989d Bluetooth: Mesh: Send provisioning PDUs with randomized delay
This implements the following statement from the section 5.3.3:
Each Generic Provisioning PDU shall be sent after a random delay between
20 and 50 milliseconds.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-29 09:26:22 +01:00
Pavel Vasilyev
fcfc99a21d Bluetooth: Mesh: Add error code for bt_mesh_adv_terminate
Return error code to let an implementation know if the adv was actually
stopped (was scheduled) or not.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-29 09:26:22 +01:00
Pavel Vasilyev
9af051e349 Bluetooth: Mesh: Call bt_mesh_send_cb.end cb by the end of adv
Before this change, the bt_mesh_send_cb.end callback was called when all
references to the adv were removed. If an implementation kept more
references to the adv buffer after calling `bt_mesh_adv_send`, the end
callback would not be called when the advertiser finished advertising
this adv.

With this change, the end callback is always called by the advertiser
when the advertisement is finished regardless of the number of
references. This allows an implementation to keep the adv buffer for the
future use. As an example, pb_adv.c keeps advs for retransmission.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-01-29 09:26:22 +01:00
Jonathan Rico
d75b44327a Bluetooth: ATT: don't callback if bearer is invalid
If an att buf is destroyed during bearer teardown, we want to avoid
using and passing invalid references to the application.

Double-check that the current bearer, the ATT object and the ACL conn
objects it is attached to are not NULL before proceeding.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-26 11:57:10 -06:00
Vinayak Kariappa Chettimada
87aa53ccae Bluetooth: Controller: Fix BIS Encryption for first subevent PDU empty
Fix radio packet length configuration when first subevent
has empty PDU in the BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-26 09:45:35 +01:00
Vinayak Kariappa Chettimada
4192f8a844 Bluetooth: Controller: Fix ISO Sync Receiver sequential BIS PDU drop
Fix ISO Synchronized Receiver sequential packing BIS PDU
being dropped in the first repetation just after previous
BIS subevents where skipped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-26 09:45:24 +01:00
Vinayak Kariappa Chettimada
653d285210 Bluetooth: Controller: Fix Broadcast ISO Create Scheduling
Fix Broadcast ISO Create Scheduling to consider reducing
Host requested RTN value. And also use maximum overhead
calculation when Extended Advertising and Periodic
Advertising have not been started before BIG create.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-26 09:45:09 +01:00
Vinayak Kariappa Chettimada
818ae7acb0 Bluetooth: Controller: Fix incorrect HCI ISO Data length check
Fix incorrect HCI ISO data length check for Broadcast ISO
transmissions.

Removed initially added code when preliminary support for
Broadcast ISO was implemented.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-26 09:45:09 +01:00
Emil Gydesen
2b0e39dfa5 Bluetooth: Audio: Add bt_audio_codec unset functions
Add functions to unset, or remove, specific codec
LTV structure from codec_cfgs or codec_caps.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-26 09:43:30 +01:00
Hang Fan
b3d2891e16 Bluetooth: Classic: Add support for class of device
Add `CONFIG_BT_COD` for class of device.

< HCI Command: Write Class of Device (0x03|0x0024) plen 3
        Class: 0x200408
          Major class: Audio/Video (headset, speaker, stereo, video, vcr)
          Minor class: Hands-free Device
          Audio (Speaker, Microphone, Headset)
> HCI Event: Command Complete (0x0e) plen 4
      Write Class of Device (0x03|0x0024) ncmd 1
        Status: Success (0x00)

Signed-off-by: Hang Fan <fanhang8@gmail.com>
2024-01-25 15:09:01 +00:00
Jonathan Rico
6fa5d1e6a5 Bluetooth: L2CAP: fix net buf frags handling
Fix the handling of buffers with fragments. What seems to have been
broken is the metadata reference that was not passed to the next frag in
the chain.

Add a test to regression too.

The main user of this is IPSP.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-24 14:56:16 +01:00
Jonathan Rico
9d5217f68b Bluetooth: L2CAP: call bt_l2cap_send_cb once
Small refactor to improve readability.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-24 14:56:16 +01:00
Vinayak Kariappa Chettimada
ac39ad7249 Bluetooth: Controller: Fix extended scanning assertion
Fix extended scanning assertion after long duration.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-24 10:44:12 +01:00
Vinayak Kariappa Chettimada
585d98e0d8 Bluetooth: Controller: Fix prepare overhead in scheduling ISO
Fix double prepare overhead considered in scheduling
extended, periodic and ISO broadcast radio events when using
LOW LAT variant.

ticks_slot maintained in ticker includes the overhead, the
ticks_slot stored in role/state context exclude the overhead
hence take care to include ticks_slot_overhead when value is
used from context and not when value used from ticker nodes.

Add jitter due to ticker resolution unit between scheduled
radio events. This will allow the synchronizing side too to
not overlap due to ticker resolution related jitter.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-23 14:45:29 +01:00
Vinayak Kariappa Chettimada
4a51f68bcc Bluetooth: Controller: Fix ISO Sync Receiver subevent Rx window
Fix ISO Synchronized Receiver subevent Rx window timing and
PDU address receive timeout to consider the +/- 2us active
clock jitter.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-23 14:45:16 +01:00
Vinayak Kariappa Chettimada
83174ef7dc Bluetooth: Controller: Fix ISO Sync Receiver sequential subevent skip
Fix ISO Synchronized Receiver sequential packing subevent
skip to next BIS subevent, so that radio channel is
correctly calculated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-23 14:45:02 +01:00
Vinayak Kariappa Chettimada
6e51950cd8 Bluetooth: Controller: Use EVENT_OVERHEAD_RESERVE_MAX in Periodic Sync
Use EVENT_OVERHEAD_RESERVE_MAX conditional compile in
Periodic Advertising Sync implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-23 14:44:41 +01:00
Anders Storrø
93a6ee501a Bluetooth: Mesh: Add artificial beacon delay
After removing 20ms in advertiser, all subnetwork beacons are sent as high
dense packet of frames with minimal distance between them. That might
cause collisions if beacon interval on devices will coincide.

This commit adds an artificial delay between each subnet advertsing
beacons.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-01-23 10:02:00 +01:00
Vinayak Kariappa Chettimada
4158d9523e Bluetooth: Controller: Fix extended scanning data length assertion
Fix assertion due to LLL scheduling of auxiliary PDU
reception was not considered in the ULL when checking for
accumulated data length exceeding the supported maximum scan
data length. This caused the auxiliary context to be release
while LLL was still active with scheduled PDU reception.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-22 16:55:09 +01:00
Mustafa Homsi
e51c47bf43 Bluetooth: Controller: Fix regression in BT_CTLR_USED_PPI_CHANNELS
Fix regression in BT_CTLR_USED_PPI_CHANNELS introduced
in commit e39d98302d ("Bluetooth: Controller: nRF53:
Cleanup dppi and dppi resources file").

Signed-off-by: Mustafa Homsi <mustafa.homsi@rivieh.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-01-22 14:31:12 +01:00
Emil Gydesen
aef39f6923 Bluetooth: BAP: Fix issue with setting invalid iso data path
BAP would always set up the ISO data path in both directions,
even for unidirectional CIS. This meant that in the
unconfigured direction, the data path configuration data
would all be 0, which causes issues on some controllers.

The new refactored approach implemented by this commit
will always ensure that the data path is setup correctly,
and that we only set the data path in one direction for
unidirectional CIS. The unset path will use the default
ISO path of HCI and transparant format, which should always
be allowed by a controller.

This is building on the requirement in BAP that all streams in
a unicast group shall be QoS configured at the same time. This
ensures that before any streams in the CIG has been connected,
they have all been configured.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-22 13:09:16 +01:00
Rubin Gerritsen
db58810492 Bluetooth: ISO: Fix CIS peripheral disconnection during setup
When the central aborts the CIS setup during the CIS Creation
procedure after it has accepted the CIS request, the peripheral
will receive the HCI LE CIS Established event with an error code.
It does not receive a disconnection event.
See the message sequence chart in Core_v5.4, Vol 6, Part D,
Section 6.23.

This commit ensures that the perirpheral disconnected callback gets
called for this particular scenario.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-01-22 12:59:38 +01:00
Emil Gydesen
b857ef7f83 Bluetooth: BAP: Add ISO state callbacks
Add callbacks to the stream objects that reflects the
state of the isochronous channel. The connected callback
is called when the isochronous channel is connected, and
similarly the disconnected callback is called when it is
disconnected.

There is a special case for unicast, where if the ACL
disconnects first, then we won't get a ISO disconnect
callback. It should be assumed that the isochronous channel
is no longer valid when the BAP stream enters the idle state,
i.e. when the "released" callback is called.

The purpose of the new callbacks is to provide additional
information to the application. Especially the unicast client
can use this to determine when the stream_start function
can be called again, as there can only ever be 1 outstanding
CIS connection request at a time, but there can be multiple
GATT requests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-01-22 12:59:11 +01:00
Gerard Marull-Paretas
27f14eb3a8 bluetooth: controller: ll_sw: RV32M1: add missing include
cntr.c accesses some registers defined in fsl_device_registers.h.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-01-19 15:13:53 +00:00
Kamil Piszczek
6852abf521 bluetooth: gatt: add authorization callback API for gatt operations
Added the GATT authorization callback API that allows the user to
define application-specific authorization logic for GATT operations.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2024-01-19 16:08:46 +01:00
Jonathan Rico
68316ace22 Bluetooth: L2CAP: remove l2cap_chan_create_seg()
Remove the logic for adding the SDU length when allocating segments. That
section was dead code after the recent patches.

Inline the remainder of the logic into `l2cap_chan_le_send()`.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-01-19 16:59:11 +02:00
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