Commit graph

9523 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
a2ebec5c64 Bluetooth: Controller: Fix coverity issue 318807
[Coverity CID: 318807] Dereference before null check in
subsys/bluetooth/controller/ll_sw/ull_iso.c

Fixes #59514.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Flag sync_iso_create_get() function

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

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-05 12:34:23 +00:00
Troels Nilsson
813c9104fa Bluetooth: Controller: Handle unsupported coded phy in ull_scan_aux
Use CONFIG_BT_CTLR_PHY_CODED to flag out coded phy code

Don't schedule a scan for coded phy when it is not supported

Signed-off-by: Troels Nilsson <trnn@demant.com>
2023-07-05 12:34:23 +00:00
Emil Gydesen
5fa793fa9d Bluetooth: Modify stream_ops->stopped to be called on leaving streaming
When a stream leaves the streaming state the `stopped` callback
will now be called, similar to how the `started` callback works.

This ensures that `stopped` is always called and not just when
the CIS disconnects.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-05 12:34:01 +00:00
Arkadiusz Kozdra
82d8f09de1 bluetooth: host: track connection type enum
The enum used for connection types gets named bt_conn_type to guard
against accidental usage of generic integers with relation to it.

The added default case in several switch statements avoids warnings
against unhandled enum values.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-07-05 09:15:48 +02:00
Arkadiusz Kozdra
0885416b60 bluetooth: host: add checks for connection types
Fail gracefully if an HCI event of one type arrives for a handle of a
different connection type.  The requested types are currently based on
what fields are used, not on the usage context, in order to keep every
correct use so far still working.

A warning is logged if the connection identified by the handle does not
match the requested connection type.

Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
2023-07-05 09:15:48 +02:00
Mariusz Skamra
7c21a9c189 Bluetooth: ascs: Make sure idle state can be always read
Instead of waiting for ase_buf to be available, the read of an
ASE in IDLE state can be handled without using ase_buf.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-05 09:14:37 +02:00
Mariusz Skamra
12c89edc39 Bluetooth: ascs: Fix return without state change nor response
This fixes missing control point status and ASE status change, when
failed to disconnect the CIS. As the server may, but does not have to
disconnect the CIS, the operation should not be considered as failed
when it happens.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-07-05 09:13:45 +02:00
Aleksandr Khromykh
25bfbb1caf Bluetooth: Mesh: instantiate cdb and core keys
PR instantiates cdb and core keys to prevent scenario
when key is changed over cdb API and gets new ID but
core still operates with old ID(potentially invalid).

Known issue the keys will be desynchronized
during\after key refresh procedure.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-07-04 11:01:47 +00:00
Szymon Czapracki
42a402abe3 bluetooth: audio: Rework PACS notify system
This commits eliminates the old way of
pacs notifications, replacing k_work with
simple bt_gatt_notify.

Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
2023-07-04 11:00:38 +00:00
Emil Gydesen
b20ef863cd Bluetooth: OTS: Add explicit ignore of ret error when reset dir_list
When doing the bt_ots_dir_list_reset_anchor we now explicitly ignore
the return value of bt_gatt_ots_obj_manager_first_obj_get
to fix a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-07-04 09:30:01 +02:00
Carles Cufi
9e0e2be765 Bluetooth: controller: Fix indent in calls to ticker_stop()
Follow-up from #59602.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-07-03 16:56:26 +00:00
Mateusz Kusiak
4337675436 Bluetooth: Controller: Ignore ticker_stop() return value
Cast ticker_stop() calls to void where return value is not checked.
This is to satisfy coverity and indicate that return value is not
important.

Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
2023-07-03 16:14:34 +02:00
Vinayak Kariappa Chettimada
bc60619b90 Bluetooth: Controller: Fix coverity issue 248393
[Coverity CID: 248393] Explicit null dereferenced in
subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Fixes #58942.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 13:43:46 +02:00
Vinayak Kariappa Chettimada
7366dfd1cc Bluetooth: Controller: Fix coverity issue 318804
[Coverity CID: 318804] Copy-paste error in
subsys/bluetooth/controller/ll_sw/nordic/lll/lll_central_iso.c

Fixes #59512.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:34:30 +02:00
Vinayak Kariappa Chettimada
80632b50c7 Bluetooth: Controller: Fix coverity issue 318644
[Coverity CID: 318644] Unused value in
subsys/bluetooth/controller/ll_sw/ull_central_iso.c.

Fixes #58999.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:33:22 +02:00
Vinayak Kariappa Chettimada
41cfe217b2 Bluetooth: Controller: Fix coverity issue 318626
[Coverity CID: 318626] Unintended sign extension in
subsys/bluetooth/controller/ll_sw/ull_adv_iso.c.

Fixes #58984.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-07-03 09:32:47 +02:00
Emil Gydesen
915a649392 Bluetooth: CSIP: Add missing input validation for csis_int_by_handle
The bt_csip_set_coordinator_csis_inst_by_handle did not check the input
parameters and could call lookup_instance_by_handle with handle == 0
which triggers an ASSERT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:27 +02:00
Emil Gydesen
11b12ae905 Bluetooth: MICP: Return if AICS inst count is 0
In the prepare_aics_inst the loop
should not run if the count is 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:04 +02:00
Emil Gydesen
92d612e79d Bluetooth: VCP: Return if VOCS/AICS inst count is 0
In the prepare_aics_inst and prepare_vocs_inst the loops
should not run if the count is 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:13:04 +02:00
Emil Gydesen
3d53a75180 Bluetooth: BAP: Shell: Register CAP callbacks if CAP initiator
If we are use the shell as a CAP initiator, then we need to
register the stream callbacks for the CAP streams as well, as
CAP will use the BAP callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:48 +02:00
Emil Gydesen
f1a3b7d7e2 Bluetooth: CAP: Add null check for free_conn
When populating the conns array in
bt_cap_initiator_codec_configured, coverity did not like just
having the __ASSERT, so modified the checks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:30 +02:00
Emil Gydesen
4e15a09083 Bluetooth: BAP: Filter PA data duplicates by default
When syncing via the broadcast sink or the scan delegator
it makes more sense to filter on duplicates, as the expected
data rarely changes.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:12:13 +02:00
Emil Gydesen
c6632d65d8 Bluetooth: BAP: Shell: Add runtime config of recv_stats_interval
The internval of how often we report
receive stats can now be configured via the cmd_recv_stats
command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:11:57 +02:00
Emil Gydesen
6e066b4683 Bluetooth: BAP: Shell: Improve recv statistics
Add more information when we print the recv every 100th
packet, and remove all per-recv printing.

This also resets all information on stream start. This does,
however, no properly support multiple streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:11:57 +02:00
Emil Gydesen
49a70aa1bb Bluetooth: TMAP: Add TMAP shell module
Add simple TMAP shell module that supports the TMAP
discovery.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:10:51 +02:00
Emil Gydesen
43ef100a22 Bluetooth: TMAP: Make callback const
The callback should not be modified by the stack,
and should thus be const.

Also fixes a missing include of conn.h.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:10:51 +02:00
Emil Gydesen
cd78331c23 Bluetooth: Shell: Only print PAST peer if there is one
Only print the "PAST peer" string if there is an actual
PAST peer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 16:08:17 +02:00
Aleksander Wasaznik
e61ac77119 Bluetooth: Shell: Restore missing bt_addr_le_to_str in scan_recv
This restores a line of code that was accidentally deleted in
5580cb4391. This fixes an uninitialized
`le_addr` getting printed and producing garbage output in the scan
results.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-06-30 16:07:44 +02:00
Jai Arora
cf0ff30b53 bluetooth: ots: Fix bt_ots_init paramter struct naming
Patch to rename struct bt_ots_init to struct bt_ots_init_param
to avoid duplicating the name bt_ots_init.

Fix for issue#45968

Signed-off-by: Jai Arora <infolinesoni@gmail.com>
2023-06-30 16:06:08 +02:00
Emil Gydesen
69f7fd9cb2 Bluetooth: Audio: Rename bt_codec to bt_audio_codec_{cap, conf, data}
Rename the bt_codec struct to bt_audio_codec_conf or
to the new struct bt_audio_codec_cap.
Rename the bt_codec_data to bt_audio_codec_data.

The purpose of this is to split the codec specific configuration
and codec capabilities into seperate structs, as they do not
reflect the same values, or used for the same purpose.

This commit depends on the preset macros workings on either
type of struct (for now), but will be modified in future updates.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-30 12:39:50 +02:00
Mariusz Skamra
17223f136f Bluetooth: audio: Fix metadata length checks
This fixes metadata length checks for BT_AUDIO_METADATA_TYPE_EXTENDED
and BT_AUDIO_METADATA_TYPE_VENDOR that should be at least 2 bytes long.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:58 +02:00
Mariusz Skamra
db5767e50f Bluetooth: audio: Accept empty CCID list in audio metadata
The CCID list can be empty, as the Assigned Numbers is not strict
regarding it's minimum length.

Fixes: #59666
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:58 +02:00
Emil Gydesen
a32ba627ce Bluetooth: BAP: Shell: Improve printing of the BASE
Add offsets for each layer in the BASE and add printing
of the presentation delay.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-29 21:06:46 +02:00
Mariusz Skamra
7b94d57b32 Bluetooth: unicast_client: Drop ISO PDUs if ASE is not in streaming state
This fixes missing drop of ISO Data PDUs received in non-streaming state.
The client shall indicate first it's readiness to receive the ISO Data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:31 +02:00
Mariusz Skamra
9694e85614 Bluetooth: ascs: Drop ISO PDUs if ASE is not in streaming state
This fixes missing drop of ISO Data PDUs received in non-streaming state.
The server shall indicate first it's readiness to receive the ISO Data
by calling bt_bap_stream_start that triggers state transition from
Enabling to Streaming state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-29 21:06:31 +02:00
Emil Gydesen
f4550dbda8 Bluetooth: TBS: Guard check for MAX_TBS_INSTANCES
Add check for CONFIG_BT_TBS_CLIENT_MAX_TBS_INSTANCES > 1 before
comparing inst_cnt, as otherwise it was always false which
caused a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-29 21:06:14 +02:00