Commit graph

9523 commits

Author SHA1 Message Date
Emil Gydesen
c627164d28 Bluetooth: CSIP: Shell: Fix discover_members
The cmd_csip_set_coordinator_discover_members did not properly
handle the members_found and addr_found values.

It has been modified to run through all known values
before scanning, and set the value appropriately.

This also fixes a minor bug where err = 0 was missing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-29 21:05:02 +02:00
Vinayak Kariappa Chettimada
96c076b9c1 Bluetooth: Controller: Add LL_ASSERT_OVERHEAD define
Add LL_ASSERT_OVERHEAD define to reuse the assertion check
related to increase in actual EVENT_OVERHEAD_START_US value.

Introduce Kconfig option to permit radio event be skipped
when increased prepare callback latencies are measured,
instead of assertion.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:16:47 +02:00
Vinayak Kariappa Chettimada
5aae5d2583 Bluetooth: Controller: Fix Connected ISO for aborted prepare
Fix Connected ISO implementation to correctly handle SN,
NESN and payload_count when prepare callback is aborted due
to CPU overhead related latencies.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:16:47 +02:00
Vinayak Kariappa Chettimada
ae679bc9ff Bluetooth: Controller: Move EVENT_OVERHEAD_START_US verbose assertion
Move the EVENT_OVERHEAD_START_US verbose assertion to each
state/role LLL implementation so that correct state/role
that is delayed is conveyed in the assertion message.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:16:47 +02:00
Vinayak Kariappa Chettimada
3c34163908 Bluetooth: Controller: Add -ECANCELED on return from lll_preempt_calc
Add -ECANCELED on return from lll_preempt_calc so that
assert check can be placed in the prepare callbacks of the
state/role implementations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:16:47 +02:00
Vinayak Kariappa Chettimada
ac8499550d Bluetooth: Controller: Fix use of pre-programmed PPI
Fix to not use pre-programmed PPI when NRF_TIMER0 is not
used as the radio event timer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:15:48 +02:00
Vinayak Kariappa Chettimada
cfcbe5d68e Bluetooth: Controller: Remove redudant header file includes
Remove redundant header file includes, introduce radio used
resources header file.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:15:48 +02:00
Vinayak Kariappa Chettimada
019f88ec21 Bluetooth: Controller: Fix CIS failed to be established
Fix CIS create implementation to consider CIG events with
laziness before the new CIS in an already active CIG is
made active.

Previous laziness value of the CIG events is determined and
at the CIG event where the new CIS event_count is calculated
the lazy_active value determined is decremented from the
total lazy value.

Without this fix, event_count of the new active CIS events
where incorrect, causing CIS create resulting in fail to be
established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:15:27 +02:00
Vinayak Kariappa Chettimada
6da521c9b6 Bluetooth: Controller: Fix offset_min_us be >= PDU_CIS_OFFSET_MIN_US
Fix calculation that ensured cis_offset_min_us being >=
PDU_CIS_OFFSET_MIN_US.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 17:15:27 +02:00
Vinayak Kariappa Chettimada
bd9cee0a9f Bluetooth: Controller: Inherit BT_ISO_TX_MTU value
Inherit BT_ISO_TX_MTU value for BT_CTLR_ISO_TX_BUFFER_SIZE.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-06-29 10:06:19 +00:00
Pavel Vasilyev
4256472fbf Bluetooth: Mesh: Reduce BT_L2CAP_TX_MTU for mesh to 33
Since the acl mtu for mesh is reduced to 37 in PR #59004, there is no
need in BT_L2CAP_TX_MTU to be longer than 33 bytes for mesh.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-29 10:05:03 +00:00
Théo Battrel
cd264b21e4 Bluetooth: Host: Abort pairing if disconnected
If disconnection has been triggered in between the security update and
the call to `smp_pairing_complete` we need to abort the pairing.

The disconnection may have been triggered by `bt_unpair`, in that case
the keys will have been erased and it will lead to an assertion to
continue as if nothing happened.

To resolve this issue, at the beginning of `smp_pairing_complete` the
`status` is set to `BT_SMP_ERR_UNSPECIFIED` if there is no connection.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-29 10:04:41 +00:00
Theo Gasteiger
b9d46b5483 Bluetooth: Audio: Encrypted BISes cause MPU FAULT
When enabling BIS encryption, a MPU fault will occur.

Signed-off-by: Theo Gasteiger <gatcode@wdw.one>
2023-06-29 10:01:16 +00:00
Aleksandr Khromykh
4d4886c056 Bluetooth: Mesh: remove unnecessary mbedtls options from mesh
Unnecessary mbedtls config option has been removed from
ble mesh KConfig.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-28 06:48:52 +00:00
Emil Gydesen
a46fb81449 Bluetooth: BAP: Shell: Set default_stream on configured
Instead of setting the default_stream when we initiate
the configure operatio, we set it when it has succeded.

In case that the codec configure fails, the stream should
not really be considered configured as the default.

This also ensures that the default_stream is set when
using the CAP shell commands.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-28 06:48:32 +00:00
Mariusz Skamra
b3259e5bf5 Bluetooth: ascs: Fix possible ASE stuck in releasing state
It may happen that CIS is scheduled in the future and did not started
yet once accepted. When ASE goes to Releasing state in such case
the ISO has to be disconnected, because otherwise ASE will stuck in
releasing state.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-27 12:17:56 +00:00
Emil Gydesen
379ee55ee0 Bluetooth: BAP: Shell: Move audio_send_work above clear_lc3_sine_data
Since clear_lc3_sine_data references audio_send_work, it must
be declared before the clear_lc3_sine_data function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:17:47 +00:00
Emil Gydesen
82e5eba817 Bluetooth: BAP: Fix bt_bap_scan_delegator_find_state
The bt_bap_scan_delegator_find_state did not properly return the
correct receive state due to confusing return value of the
iterator function.

Modify it to use a simple bool.

This fixes all issues with "Failed to find receive state for sink"
when using the Broadcast Sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:16:50 +00:00
Emil Gydesen
2b74450544 Bluetooth: CSIP: Update CSIP duplicate rank search
In the CSIP Set Coordinator verify_members we verify that
all members have unique ranks.

This was done as part of the initial loop, but it is
more efficient to do this as a separate loop as we can reduce
the number of items to compare, as well as guarding this properly
by !zero_rank.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:16:12 +00:00
Emil Gydesen
ac8dc34911 Bluetooth: CAP: Shell: Fix type in cmd_cap_initiator_unicast_stop
"starteds" should be "started".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:15:36 +00:00
Emil Gydesen
feaae8b104 Bluetooth: BAP: Shell: Only register scan delegator callbacks once
If the callbacks are registered more than once, the linked list
causes an infinite loop.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:15:19 +00:00
Emil Gydesen
2901e7cd59 Bluetooth: BAP: Shell: Fix assistant broadcast code
Fixes 2 issues:
1) The broadcast code would only ever get the first value, even if
the command specified up to 16 values.
2) The broadcast code is not just hex values, so hex2bin does not make
sense, and strlen + memcpy is much simpler.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:15:01 +00:00
Emil Gydesen
addc8a538a Bluetooth: BAP: Shell: Stop scan on broadcast found
When the broadcast assistant have found the expected broadcast
source it should stop scanning.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:14:34 +00:00
Emil Gydesen
acc59cfc9a Bluetooth: BAP: Shell: Add missing addr print in broadcast assistant
The shell_print was meant to print the address of the broadcast
source along with the broadcast_id.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:14:15 +00:00
Emil Gydesen
dd0db3f7d6 Bluetooth: BAP: Shell: Fix broadcast assistant bad code print
The bad code field should only be printed when there is an actual
bad code, otherwise it just prints all-0s.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:13:46 +00:00
Emil Gydesen
7993f2001e Bluetooth: BAP: Shell: Fix missing NULL check for cmd_list
stream may be NULL when we check for stream->conn.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-27 12:13:30 +00:00
Sean Madigan
2c3dd0122e bluetooth: controller: kconfig: Move BT_CTLR_SCAN_SYNC_ISO_SET
Move BT_CTLR_SCAN_SYNC_ISO_SET to Kconfig from Kconfig.ll_sw_split
This means it can be used by other controllers and alligns with location
of other iso configs - e.g. BT_CTLR_SYNC_ISO_STREAM_COUNT

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2023-06-27 12:12:20 +00:00
Emil Gydesen
e99b8f3433 Bluetooth: BAP: Shell: Fix missing src_id in mod_src
The src_id was never set in
cmd_bap_broadcast_assistant_mod_src.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-26 16:14:42 +02:00
Emil Gydesen
5a4c9a2112 Bluetooth: BAP: Unicast client shall support 0 or > 1 endpoints
As per table 4.2 in BAP v1.0.1, the BAP unicast client shall
support at least 2 (> 1) endpoints in either direction if it
supports that direction.

Since Kconfig does not support such requirements (0 || > 1),
this is done using a BUILD_ASSERT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-26 12:40:39 +00:00
Emil Gydesen
9d3f594432 Bluetooth: BAP: Shell: Print received broadcast code
Print the received broadcast code as the scan delegator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-26 12:39:16 +00:00
Mariusz Skamra
93abc2ad76 Bluetooth: att: Reset ATT timer when retrying on security error
If the remote responds with and security related error the stack tries
to increase the security level to satisfy the remote permissions.
This fixes missing ATT timer reset on security related ATT Error
Response as the ATT operation is considered as complete.

< ACL Data TX: Handle 0 flags 0x00 dlen 7
      ATT: Read Request (0x0a) len 2
        Handle: 0x0084
        TMAS: Role
> ACL Data RX: Handle 0 flags 0x02 dlen 9
      ATT: Error Response (0x01) len 4
        Read Request (0x0a)
        Handle: 0x0084
        Error: Insufficient Authentication (0x05)
          TMAS: Role
           Error code: 0x05
< ACL Data TX: Handle 0 flags 0x00 dlen 6
      SMP: Security Request (0x0b) len 1
        Authentication requirement: Bonding, No MITM, SC, No Keypresses
= bt: bt_att: ATT Timeout

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:55:17 +02:00
Théo Battrel
a996159362 Bluetooth: Host: Fix connection reference leak
If connection reference is acquired from `bt_conn_lookup_addr_le` but
`bt_gatt_ccc_cfg_is_matching_conn` return false the connection was not
unreferenced properly. This commit fix the issue by unreferencing the
connection if the condition is false.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-24 18:55:04 +02:00
Mariusz Skamra
d72c17684c Bluetooth: tbs_client: Fix possible NULL pointer dereference
This fixes notification callback that can be called with NULL conn
parameter when peer is being unpaired.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:54:56 +02:00
Mariusz Skamra
6f0dc490e7 Bluetooth: vocs_client: Remove unused subscribe_cnt variable
This removes unused subscribe_cnt from bt_vocs_client.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:54:56 +02:00
Mariusz Skamra
a7231a4ca4 Bluetooth: aics_client: Remove unused subscribe_cnt variable
This removes unused subscribe_cnt from bt_aics_client structure.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:54:56 +02:00
Mariusz Skamra
5452ef378f Bluetooth: tbs_client: Remove unused subscribe_cnt variable
This removes unused subscribe_cnt from bt_tbs_instance.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-24 18:54:56 +02:00
Emil Gydesen
192e425b90 Bluetooth: Host: Add NULL check for addr in unpair
unpair may be called from bt_unpair where addr is NULL.
One such case is the `bt clear all` shell command which
calls bt_unpair with addr = NULL, and the addr is just forwarded
to unpair which does not check for NULL.

bt_unpair allows for the addr to be NULL to clear all, but only
if SMP is enabled.

Modified the checks in bt_unpair to increase readability
and ensure that unpair is not called with NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-23 09:21:35 +02:00
Mariusz Skamra
9ef019d28d Bluetooth: tmap: Fix TMAS characteristic permissions
This fixes TMAS characteristic permissions.
The characteristic shall have no security related
permissions as per TMAP_v1.0.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-06-22 16:31:18 +02:00
Pavel Vasilyev
c214ec3cf4 Bluetooth: Mesh: Fix dead code issue when getting node id state
Refactor the function to avoid dead code.

Coverity-CID: 321153
Fixes #59527

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-22 12:34:23 +02:00
Pavel Vasilyev
a16bcd291d Bluetooth: Mesh: Avoid NULL pointer dereference in shell utils
bt_mesh_elem_find can return NULL.
This also gets rid of VLA in bt_mesh_shell_mdl_print_all.

Coverity-CID: 321075
Fixes #59522

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-06-22 12:34:23 +02:00
Emil Gydesen
8cd0758bdf Bluetooth: Shell: Move scan filter to function
Move the scan filter to a new function so that it may
be reused by other shell modules.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 12:28:12 +02:00
Emil Gydesen
3ede93f166 Bluetooth: BAP: Shell: Fix missing clear of txing_stream
If the stream is stopped or released, we did not clear the
txing_stream which is what would stop the sine from being
attempted to being sent.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 12:27:14 +02:00
Emil Gydesen
d9082cd5b4 Bluetooth: ASCS: Fix bad size of metadata_backup
The metadata_backup used the codec config size instead of
the metadata size.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 12:26:41 +02:00
Emil Gydesen
17ea3546d3 Bluetooth: BAP: Shell: Fix endianess of broadcast_id in adv data
The broadcast ID was encoded as big instead of little endian
in the advertising data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 06:16:23 -04:00
Emil Gydesen
c0d842bb55 Bluetooth: BAP: Shell: Remove duplicate increment of seq_num
The seq_num in lc3_audio_send_data was updated twice:
Once when calling get_next_seq_num and once at the end
of the function.

This increased the sequence numbers too fast, and made
TX not worker properly.

Modified to only use get_next_seq_num.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 06:16:11 -04:00
Théo Battrel
c5623c641a Bluetooth: Host: Check that conn is not NULL
In `gatt.c`, the function `bt_gatt_ccc_cfg_conn_lookup()` was not
checking that `conn` was not NULL. That leaded to a NULL pointer
dereferences later in `bt_conn_is_peer_addr_le`.

Fix by checking that `conn` is not NULL.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2023-06-22 06:15:54 -04:00
Emil Gydesen
6815d9f720 Bluetooth: MCC: Shell: Format IDs as 64-bit (llu)
Fix formatting of the OTS object IDs to the proper
formatting.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 06:05:57 -04:00
Emil Gydesen
8d15cf2829 Bluetooth: CAP: Shell: Handle -ECANCELED error code specifically
If the procedure was called, we print a more specific string
to let the user know that there was not an actual issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 09:54:59 +00:00
Emil Gydesen
c2a730edc7 Bluetooth: Shell: Also parse Broadcast Name as a valid name
In the case that the advertising data has both a device name
and a broadcast name, whichever one comes first will be used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-06-22 08:14:28 +00:00
Aleksandr Khromykh
10ef3b46d8 Bluetooth: Mesh: fix provisionee public key usage
Provisionee shall fail if provisioner sent public key
identicall to OOB public key back.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-06-21 16:49:54 +02:00