Commit graph

9523 commits

Author SHA1 Message Date
Emil Gydesen
884b296a6c Bluetooth: Audio: Fix bad CONTAINER_OF for BAP unicast and broadcast sent
In the sent callbacks we used CONTAINER_OF to get the bt_audio_ep,
but that no longer has the ISO channel, causing these
CONTAINER_OF to return a wrong pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:09:45 +02:00
Emil Gydesen
b2cbd9f58c Bluetooth: CSIS: Client use const for conn lookup funcs
`bt_conn_index` has been changed to take a `const bt_conn`
which allows our functions that use this to also take a
`const` parameter.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen
7148146348 Bluetooth: CSIS: Implement ordered access procedure for CSIS client
the CSIS client now has a ordered access procedure function.
The function implements the procedure as per the CSIP spec,
where it will verify that 1 or more members are unlocked,
and the execture a procedure on each member in ascending
order of rank.

The procedure can be anything (even a non-BT procedure),
and it will be up to the applicaiton to implement
what to do in that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen
0558b3af95 Bluetooth: CSIS: Stored actives members by rank
Instead of getting doing look ups for each member
for the CSIS client procedures, we store the active
members ordered by rank.

This is slightly less efficient in cases of error,
but for some procedures as the upcoming Ordered
access procedure where we need to access each
member twice, ordering them once is more
efficient.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Emil Gydesen
d995901a76 Bluetooth: CSIS: Remove const for members in API
Having the members array being const causes a lot of
limitations in the implementatation, and was
occasionally even disregarded. Removed to make the
implementation more flexible.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-23 09:08:05 +02:00
Lingao Meng
e6d27c77ef Bluetooth: Host: Fix ATT security vulnerabilities
When the client receives att error rsp, but the error code
is an illegal value, such as 0, an exception will be triggered.

gatt_read_type --> gatt_read_type_rsp --> parse_characteristic

`switch (rsp->len) {` null address access.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-22 12:29:26 +02:00
Emil Gydesen
b2c8fa9c53 Bluetooth: Shell: Fix unused variable in iso.c
The `iso_qos` was only used for connected ISO, but
was placed outside of the CONFIG_BT_ISO_UNICAST
guard, such that for broadcast ISO-only it was unused.

Move the declaration and renamed to cis_iso_qos.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-22 12:28:21 +02:00
Vinayak Kariappa Chettimada
048619639d boards: nrf5340dk_nrf5340_cpunet: Disable BT_ECC support
Disable BT_ECC support in network core to reduce RAM usage.
ECC implementation can instead be supported in the Host
running in the application core.

This is also to keep hci_uart (nRF52 Series) and hci_rpmsg
(nRF53 Series) have the same support features. ECC is not
enabled in hci_uart sample.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-22 12:28:05 +02:00
Troels Nilsson
eabdf16087 Bluetooth: host: Fix resume failing with extended advertising
Fix advertising failing to resume with BT_ADV_PERSIST set in
bt_hci_le_adv_set_terminated due to BT_ADV_ENABLED not getting
cleared before bt_le_adv_resume gets called

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-06-22 12:25:10 +02:00
Troels Nilsson
0f892ff8c8 Bluetooth: host: Fix missing endianness conversions
Fix missing endianness conversion for props in le_ext_adv_param_set
and bt_le_per_adv_set_param

Signed-off-by: Troels Nilsson <trnn@demant.com>
2022-06-22 12:25:10 +02:00
Vinayak Kariappa Chettimada
e994ec1557 Bluetooth: Controller: Fix Tx Buffer allocation for Encryption Request
Encryption request is enqueued in thread context from the Tx
buffer pool, so that it is serialized alongwith the already
enqueued data buffers ensuring they are transmitted out to
peer before encryption is setup. Allocate additional Tx
buffers to accommodate simultaneous encryption setup across
active connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-22 12:22:29 +02:00
Morten Priess
ca8457d882 Bluetooth: controller: Fixes for ISO from IAL testing
- Prevent NULL-pointer dereferencing if datapath is created late
- Support SDU fragment complete-counting for framed case

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Nirosharn Amarasinghe
fc107a0775 Bluetooth: controller: Unified ISO-AL TX SDU fragment count
Implemented incrementing TX SDU fragment count such that it indicates
the number of completed SDU fragments in the PDU being emitted for both
unframed and framed transmission.

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-06-22 12:21:16 +02:00
Nirosharn Amarasinghe
af37b444d4 Bluetooth: controller: fix for some problems in ISO-AL RX and HCI
HCI:
-- Discarded data from HCI ISO Data packets from controller to host if
   data has been lost

ISO-AL:
-- Corrected iso_interval in latency calculations
-- Updated handling and release of SDUs for error conditions / padding
   at the last PDU for the SDU
-- Updated prioritisation of error status in released PDUs
-- Included error spooling exit on based on payload number to SDU
   mapping for unframed reassembly
-- Updated sequence number handling for framed recombination

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
2022-06-22 12:21:16 +02:00
Morten Priess
ef28184af2 Bluetooth: controller: Asynch stop of ISO resume ticker in disable
Do not use ull_ticker_stop_with_mark for ISO one-shot resume ticker, but
stop without checking result. If active this will stop it, otherwise it
is ignored. Also, this prevents calling lll_disable twice.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Morten Priess
3d4215d6a3 Bluetooth: controller: LLCP and ISOAL Fixes for EBQ LL tests
- Prioritize CIS_REQ handling in (old) LLCP
- Reject if CIS_REQ uses exisiting CIS ID

These fixes prevent assertions in /LL/CIS/PER/BV-38-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-22 12:21:16 +02:00
Aleksandr Khromykh
c0749bef83 Bluetooth: Mesh: fix not initialized uuid in model publication
uuid wasn't initialized in the publication setting command.
It caused wrong the configuration clietn behavior.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-06-21 10:49:01 +02:00
Morten Priess
4e3aeeddde Bluetooth: host: Fix endianness error in L2CAP
Recent code change asserts on ECRED psm being consistent in
l2cap_ecred_conn_req. However, the values are compared between
endianness converted value and non-converted value, which fails on BE
archs.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-06-21 10:47:48 +02:00
Audun Korneliussen
db78d04a96 Bluetooth: ISO: Add function for reading TX sync
This function retrieves TX sync information
(timestamp, offset, and sequence number)
from controller using HCI command HCI_LE_Read_ISO_TX_Sync.

Signed-off-by: Audun Korneliussen <audun.korneliussen@nordicsemi.no>
2022-06-21 10:46:56 +02:00
Erik Brockhoff
96817164ea Bluetooth: controller: llcp: phy update proc, validate phys and instant
Implementing proper validation of PHY selection for PHY UPDATE procedure
Implement connection termination on PHY UPDATE with instant in the past

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-06-20 14:01:23 +02:00
Vinayak Kariappa Chettimada
7ff8581916 Bluetooth: Controller: Replace k_sem_take loop with k_sem_reset
Replace k_sem_take loop used for consuming the remaining
sem give counts with k_sem_reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-20 10:27:08 +02:00
Vinayak Kariappa Chettimada
ae8e7f4c22 Bluetooth: Controller: Fix pdu_free_sem_give assertion under ZLI use
Fix assertion due to multiple mayfly_enqueue calls used
under ZLI when pdu_free_sem_give is invoked from the LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-20 10:27:08 +02:00
Rubin Gerritsen
860592698b bluetooth: kconfig: Hide host options if not available
When performing a combined host and controller build, there is no point
in presenting the option to enable a given host feature if the
controller does not support it. This reduces the list of presented
features to enable/disable.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-06-17 10:49:51 -05:00
Azizah Ibrahim
2a175b6abd bluetooth: host: Revert "Avoid sending duplicate device to resolving list."
This reverts commit e11ff7df48.
This patch causes some PTS failure.
Another patch to address duplicate device will follow.

Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
2022-06-17 13:18:25 +02:00
Wolfgang Puffitsch
9a4c3f1afa Bluetooth: controller: Tie Configure Data Path to Read Supported Codecs
The Configure Data Path command must be included when the read Local
Supported Codecs [v2] command is supported. The Configure Data Path
command is needed when vendor-specific ISO data paths are supported,
but not otherwise tied to ISO. The respective weak function is
therefore moved to ull.c.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2022-06-16 11:26:03 +02:00
Anders Storrø
b28e024fdb Bluetooth: Mesh: Configurable RPL module
Introduce configuration options for chosen RPL implementations.

This will allow introducing alternate persistent storage schemes
for the replay protection list.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-06-16 10:29:38 +02:00
Szymon Janc
253070b76b Bluetooth: host: Fix L2CAP reconfigure response with invalid CID
When an L2CAP_CREDIT_BASED_RECONFIGURE_REQ packet is received with
invalid parameters, the recipient shall send an
L2CAP_CREDIT_BASED_RECONFIGURE_RSP PDU with a non-zero Result field
and not change any MTU and MPS values.

This fix incorrectly reconfiguring valid channels while responding with
0x003 (Reconfiguration failed - one or more Destination CIDs invalid)
result code.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-06-16 10:28:44 +02:00
Szymon Janc
266394dea4 Bluetooth: host: Fix L2CAP reconfigure response with invalid MTU
TSE18813 clarified IUT behavior and rejecting reconfiguration which
would result in MTU decrease is enough. There is no need to disconnect
L2CAP channel(s).

This was affecting L2CAP/ECFC/BI-03-C qualification test case
(TCRL 2022-2).

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2022-06-16 10:28:44 +02:00
Krzysztof Chruscinski
907cd8a54f bluetooth: Remove support for logging v1
Remove support for logging v1 from bluetooth monitor log backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-06-15 10:55:26 -04:00
Vinayak Kariappa Chettimada
ec286d0227 Bluetooth: Controller: Fix missing PDU next pointer initialization
When supporting chain PDUs, after HCI reset the first PDU
allocated did not initialize its next pointer causing use
of unallocated PDUs for chaining while a duplicate of such
PDU buffer being allocated for other states/roles. This
causes in certain cases both Extended and Periodic PDUs
having same data, the Extended Advertising PDU being
transmitted at the instant of the Periodic Advertising.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-15 09:13:22 +02:00
Vinayak Kariappa Chettimada
1578dc699b Bluetooth: Controller: Fix RX_ENQUEUE_HOLD for LOW_LAT_ULL
Fix BT_CTLR_RX_ENQUEUE_HOLD implementation that stalled
generating the CONN_UPDATE and PHY_UPDATE when there were
no Rx data or Tx acknowledgements to be processed when
the controller was built with BT_CTLR_LOW_LAT_ULL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-14 10:21:24 +02:00
Lingao Meng
bfec3b2ab4 Bluetooth: host: ASCS: Correction code comments
Audio Stream Control Service Revision: v1.0

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-13 12:12:50 +02:00
Lingao Meng
5af553d0d0 bluetooth: audio: pacs: Fix missing CONFIG_
`BT_PAC_SRC_LOC_WRITEABLE` should be `CONFIG_BT_PAC_SRC_LOC_WRITEABLE`

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-06-13 12:12:50 +02:00
Mariusz Skamra
790b73773e Bluetooth: audio: Allow user to set supported context as available only
This adds checks to avoid setting context that is not indicated as
supported to be available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-13 12:12:11 +02:00
Mariusz Skamra
e5cfb1ca4a Bluetooth: audio: Add getter for available audio context
Extend API with available audio contexts getter method.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-13 12:12:11 +02:00
Lars Knudsen
c27532eec4 Bluetooth: csis: add RSI advertising callback
Makes it possible for an application to
handle CSIS RSI advertising by registering a
callback, which will disable the internal
CSIS advertising.

Also fixes registering callbacks in CSIS.

Signed-off-by: Lars Knudsen <larsgk@gmail.com>
2022-06-10 09:47:40 +02:00
Mariusz Skamra
c44ef044b8 Bluetooth: monitor: Avoid sending corrupted packets over RTT
This fixes sending corrupted (incomplete) packets over RTT. Additional
helper buffer has been added to ensure the complete packet before it
can be sent over RTT. Once the complete packet is collected it is sent
to the RTT control block in non-blocking manner. From now there will
be no situation that only part of the packet (e.g. header) is sent
which lead btmon to fail to parse the corrupted data.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-09 11:32:39 +02:00
Mariusz Skamra
e7b66d1b73 Bluetooth: monitor: Fix sending logs over RTT
This fixes Bluetooth logs that were not sent over RTT.
Minor cleanup has been made to limit the number of ifdefs.

> ACL Data RX: Handle 0 flags 0x02 dlen 11      #1049 83.117000
      ATT: Handle Value Indication (0x1d) len 6
        Handle: 0x0003
          Data: 0100ffff
= bt: bt_att: Unhandled ATT code 0x1d                 83.117100
> HCI Event: Disconnect Complete (0x05) plen 4  #1050 84.247700
        Status: Success (0x00)
        Handle: 0
        Reason: Remote User Terminated Connection (0x13)

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-09 11:32:39 +02:00
Vinayak Kariappa Chettimada
1a56f766bc Bluetooth: Controller: Config ticker with slot window to yield
Add Kconfig option to conditionally enable tickers with slot
window to yield to normal tickers and be placed at the end
of their slot window if possible.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-06-09 11:32:33 +02:00
Mariusz Skamra
868b180d64 Bluetooth: Make use of BT_CODEC_LC3_CHAN_COUNT_SUPPORT macro
Use the BT_CODEC_LC3_CHAN_COUNT_SUPPORT macro to define the supported
channel counts.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:34 +02:00
Mariusz Skamra
132ad4ac89 csis: Remove check causing assertion
This removes the check that was causing missalignment in
csis->srv.conn_cnt conunting. The csis->srv.conn_cnt was increased for
each connected device while decreased for bonded only. This caused
assertion in csis_connected when reconnected.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:07 +02:00
Mariusz Skamra
2dff20fe4b csis: Simplify the current connections counting
This makes the code cleaner.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-08 12:45:07 +02:00
Mariusz Skamra
cf59606883 Bluetooth: has: Allocate context for client once link is encrypted
The HAS sends notifications to paired devices. Thus the client context
has to be initialized once the link has required security.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:36 +02:00
Mariusz Skamra
a4d9c82fca Bluetooth: pacs: Make location characteristics non-writable by default
The Sink Audio Locations and Source Audio Locations characteristics are
optionally writtable as defined in PACS_v1.0.
If the property is not mandatory in the specification it should be
disabled in implementation by default. It is more likely that the
location value will not change over time, as the end-product would
be designed to be used in specific way (in specific location).
If the user wants to make use of the writtable location feature, then
one has to enable it explicitly.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:23 +02:00
Mariusz Skamra
146124e7f9 tests: has: Extend tests with preset selection commands
The commands are used to change the active preset.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:04 +02:00
Mariusz Skamra
4e15cbe456 Bluetooth: has: Handle active preset selection
This adds handling of active preset selection in HAS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-06-07 18:55:04 +02:00
Emil Gydesen
c513fd87e1 Bluetooth: ISO: Rename sn to seq_num
Rename the `sn` field(s) to `seq_num` to be more readable
and clear what the value covers.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen
65b5db6e3a Bluetooth: ISO: Rename ISO_INTERVAL_MIN/MAX
Rename the BT_ISO_INTERVAL_MIN/MAX to
BT_ISO_SDU_INTERVAL_MIN/MAX to avoid confusing this
the the ISO interval which is different from the SDU
interval.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Emil Gydesen
6786bbdb32 Bluetooth: ISO: Add sn and ts to bt_iso_chan_send
Add two new parameters to bt_iso_chan_send:
sn: The packet sequence number which shall be incremeted
per SDU interval.
ts: An optional timestamp value used to synchronize SDUs.

The sequence number in the API uses a 32-bit value even though
the sequence number for the HCI command is 16-bit. This is to
properly handle wrapping of sequence numbers, which is much
easier to do with additional bits allocated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-06-07 18:53:44 +02:00
Pavel Vasilyev
953f8ee0d6 Bluetooth: Mesh: Fix RPL fragmentation
`bt_mesh_rpl_check` stops iterating `replay_list` if either it found an
entry with the requested source address or unassigned address. When IV
index updated, `bt_mesh_rpl_reset` is called. It will set `old_iv` to 1
for all entries with fresh IV index and remove entries with old IV index.
If the entries with old IV index are mixed with other entries, this will
cause fragmentation of `replay_list`. The next time `bt_mesh_rpl_check`
is called, it may stop iterating `replay_list` earlier than it should
because it will meet an empty entry before it iterates over all entries
in the list.

This commit does defragmentatino of `replay_list` on every
`bt_mesh_rpl_reset` by shiting existing entries to the vacated places.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-06-07 11:53:31 +02:00