Commit graph

9523 commits

Author SHA1 Message Date
Emil Gydesen
715478fe8e Bluetooth: Shell: Add log of error code from bt_audio_stream_qos
Print the error code from calling bt_audio_stream_qos if it fails.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-28 14:06:06 +00:00
Erik Brockhoff
183370277b Bluetooth: controller: fixing slot reservation for connection setup
With introduction of refactored LLCP was also introduced an error
re. calculation of initial slot reservation in connection setups.

Due to this error a bigger slot was reserved, leading to failure due to
connection overlaps in multiple.sh test.
Also the removal of this 'overhead' in slot reservations calls for
bigger time-allowance for l2pcap_stress test.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-09-27 10:02:07 +00:00
Emil Gydesen
186181687b Bluetooth: Audio: Remove unicast client set state
The unicast client should never need to set the state of the
endpoints directly, without an notification from the server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-27 09:16:21 +00:00
Emil Gydesen
a59bc35235 Bluetooth: Audio: Ensure that ASEs don't get idled when CIS is connected
Ensure that the CIS for an ASE, if any, is disconnected before we
go into the idle state.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-27 09:16:21 +00:00
Emil Gydesen
874c45241e Bluetooth: Audio: Remove caching ASE on release
Remove the support for caching ASEs on release.

This is mainly due to the 2-stage design in Zephyr: We
have the bt_audio_stream and the bt_audio_ep, where the
the latter represents an ASE in most cases.

However, once the endpoint goes into the codec configured
state, then a stream must be bound to it. This would be fine
(although a stream is technically not established at this point),
except that a stream is also, for unicast, specified for a
specific ACL. Once the ACL disconnects, the stream technically
becomes invalid, and if the stream is invalid, so is the endpoint.

Based on that, there's no reason (or even option) to keep the
endpoint in a codec configured state, as it would not
have a valid stream associated with it.

If we want to support an ASE going into the codec
configured state on ASE release (or ACL disconnect),
the relationsship between ASEs and streams needs to
be redefined.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-27 09:16:21 +00:00
Jonathan Rico
1051607c7c Bluetooth: l2cap: prevent deadlock on chan timeout
When getting a channel timeout, l2cap_chan_destroy is called from the
rtx_work work item.

In that function we attempted to cancel the current work item, and sync on
it being cancelled. The kernel API says that this will block until the work
item completes execution, hence a deadlock.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 15:13:13 +00:00
Vinayak Kariappa Chettimada
744e5f4da4 Bluetooth: Controller: Fix ticks_slot_id_previous reset on ticker yield
Fix implementation to not reset the ticks_slot_id_previous
when ticker yields its reserved slot, only reset if ticker
was stopped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-26 13:20:28 +02:00
Vinayak Kariappa Chettimada
245b1e0330 Bluetooth: Controller: Fix ticker worker check ticks_slot_previous
Fix ticker worker from checking the ticks_slot_id_previous,
only ticks_slot_previous be checked as previous slot id
would be assigned to TICKER_NULL if the ticker was stopped.
The ticks_slot_previous value should be used to check that
a slot is reserved even if the ticker has been stopped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-26 13:20:28 +02:00
Ahmed Moheb
fab9c5a140 tests: bluetooth: host: Add UT for bt_keys_get_addr()
Unit test project for bt_keys_get_addr().
This part of subsys/bluetooth/host/buf.c unit testing

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-26 13:05:47 +02:00
Ahmed Moheb
fd888df41d tests: bluetooth: host: Add mocks for keys.c
Add required mocks to be able to compile and test /bluetooth/host/keys.c

Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
2022-09-26 13:05:47 +02:00
Vinayak Kariappa Chettimada
e348fe494a Bluetooth: Controller: Warn LLCP Legacy implementation as DEPRECATED
Add in Kconfig, select DEPRECATED, to warn at build time
that the LLCP legacy implementation is deprecated and the
refactored LLCP enabled by BT_LL_SW_LLCP Kconfig option be
used instead (which is the default now).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-26 11:07:17 +02:00
Jonathan Rico
109c47639e Bluetooth: l2cap: remove ambiguous naming
`l2cap_tx_meta_data` is also a function-like macro.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Jonathan Rico
77e1a9dcad Bluetooth: host: l2cap: add alloc_seg callback
This callback allows use-cases where the SDU is much larger than the l2cap
MPS. The stack will then try to allocate using this callback if specified,
and fall-back on using the buffer's pool (previous behavior).

This way one can define two buffer pools, one with a very large buffer
size, and one with a buffer size >= MPS, and the stack will allocate from
that instead.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Jonathan Rico
8e207fefad Bluetooth: host: l2cap: workaround SDU deadlock
See the code comments.

SDUs might enter a state where they will be blocked forever, as a
workaround, we nudge them when another SDU has been sent.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Jonathan Rico
3c1ca93fe8 Bluetooth: host: l2cap: don't send too much credits
There was an edge-case where we were sending back too much credits, add a
check so we can't do that anymore.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Jonathan Rico
1c8fe67a52 Bluetooth: host: l2cap: release segment in all cases
See code comment

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2022-09-26 11:05:04 +02:00
Vinayak Kariappa Chettimada
88705be89b Bluetooth: Controller: Fix BIS max PDU size used in calc of sub_interval
Fix BIS max PDU size used in calc of sub_interval, use the
minimum of supported maximum BIS PDU size and the requested
SDU size. This will avoid wasted air time between subevents
when SDU size is less than maximum supported PDU size, where
only 150 us tIFS is mandatory between subevents.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-23 12:47:17 +00:00
Anders Storrø
3cbb8315fc Bluetooth: Mesh: Shell: Fix cfgCli appkey arg conv
Rectifies incorrect conversion of appkey string in config client
appkey add command.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2022-09-23 13:13:59 +02:00
Vinayak Kariappa Chettimada
b867f0e8a6 Bluetooth: Controller: Fix T_MAFS between broadcasting roles
When calculating the offsets between primary advertising
PDU, auxiliary PDU, Periodic Advertising PDU, and BIS PDU,
the values used as anchor points for starting the periodic
interval for auxiliary, periodic and BIG events, should be
ensured to have the minimum auxiliary frame spacing T_MAFS
between the PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-23 11:51:52 +02:00
Vinayak Kariappa Chettimada
1bbe209a30 Bluetooth: Controller: Fix auxiliary scan stop assertion check
Use a local variable to assert check on auxiliary context's
release.
Add missing volatile qualifier to the parent field of the
auxiliary scan context.
Under race condition a released aux context can be allocated
for reception of chain PDU of a periodic sync role, hence
fix the assertion check to consider that the released
context can be allocated to other roles.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-23 08:11:39 +00:00
Vinayak Kariappa Chettimada
16e0e6607c Bluetooth: Controller: Increase BIS PDU access address receive timeout
Increase the BIS PDU access address receive timeout, use the
+/- 2 us jitter for each subevent.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-23 09:57:06 +02:00
Vinayak Kariappa Chettimada
24efea7ba1 Bluetooth: Controller: Fix infinite loop receiving ISO Data
Fix inifinite loop in ll_rx_get() when both ISO Broadcast
and ISO Receive features are enabled in a build. Missing
conditional compile prevented the ack_last index that
maintains a relation between number of packets complete and
the received data packets was unassigned.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-22 18:05:36 +02:00
Piotr Pryga
047b756e64 Bluetooth: df: Add ntf of insufficient resources for IQ samples
According to Bluetooth 5.3 Vol 4, Part E section 7.7.65.21 the
Controller should send an IQ report with Packet_Status set to 0xFF
and Sample_Count to 0x0, to inform Host that it is not able to
store IQ samples for all received Constant Tone Extensions and has
failed to sample at least once.

This commit adds handling of such situation for direction finding
in connectionless mode in lower link layer. It includes:
- lack of node_rx_iq_report to store IQ samples,
- lack of free node_rx to report received advertising data (generates
  an advertising data report with indication "incomplete, no more to
  come" and cancels reception of chained PDUs,
- cancellation of chained PDUs reception due to other scheduling
  reasons.
In all of these situations CTE reception must be enabled and number of
received CTEs is smaller than requested by Host.

If there is not sufficient number of node_rx_iq_report nodes and
report was generated, the CTE will not be samples in a given
periodic advertising synchronization event. The CTE will be
sampled again in next event if there are node_rx_iq_report available.

End user applications may check periodic advertising sync event
counter when use of the reports to be sure about sync event
the received report is connected with.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-09-22 18:04:00 +02:00
Vinayak Kariappa Chettimada
30823c6f56 Bluetooth: Controller: Fix stream index use in Broadcast ISO Tx
Fix incorrect use of stream handle instead of connection
handle to enqueue Tx ISO Data, and use stream index to get
stream instance.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-22 15:53:35 +02:00
Pavel Vasilyev
e4921cc84d Bluetooth: Mesh: Trigger GATT update when subnet is added
When the node is part of only one subnet, it starts Network ID
advertisements with infinite timeout. It is not an issue when using
legacy advertising and extended advertising with shared set for local
messages and GATT because any message will stop advertisements. However,
when a separate adv set is used for GATT advertisements,
`struct bt_le_ext_adv_cb.start` callback won't be called, but the
implementation relies on that callback to switch to a next subnet.
Calling `bt_mesh_adv_gatt_update()` stop GATT advertisement so that the
implementation can switch to the next subnet.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-22 10:03:39 +02:00
Pavel Vasilyev
20a3a83c9f Bluetooth: Mesh: Fix node identity interleave multiple subnets
Reduce advertising duration to `max_timeout` when advertising node
identity for multiple subnets. This will let the node to interleave
subnets for NODE_ID_TIMEOUT.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-22 10:03:39 +02:00
Pavel Vasilyev
326786efd6 Bluetooth: Mesh: Avoid indefinite timeout when duration less than zero
`struct bt_le_ext_adv_start_param.timeout` resolution is in 10ms. When
duration is less than 10ms, division will be evaluated to zero, which
will result in indefinite timeout. Set timeout to 10ms to avoid
indefinite timeout. The advertisement will end earlier anyway after the
event is finished.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-22 10:03:39 +02:00
Vinayak Kariappa Chettimada
d53d9fb6bf Bluetooth: Controller: Add error log for Advertising enable/disable
Add error message logging for Advertising enable/disable at
RPA timeout when the resolvable address is updated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-21 13:04:00 +00:00
Vinayak Kariappa Chettimada
6c40427931 Bluetooth: Host: Fix resolvable address update with Ext Adv enabled
Fix resolvable address update after RPA timeout with
Extended Advertising support enabled. As Extended
Advertising HCI Commands are being used to start legacy
advertising, incorrectly the local random address was being
used instead of using the random address populated in the
Extended Advertising set. BT_DEV_RPA_VALID is not cleared
when Extended Advertising HCI commands are used, hence the
local random address is not updated and the incorrect use
of it did not make any change to the advertising when
disabled and enabled at RPA timeout.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-21 13:04:00 +00:00
Vinayak Kariappa Chettimada
87b39c5975 Bluetooth: Controller: Fix repeated skip in ticker resolve collision
Enforce next_is_older only when current has equal force as
with the next ticker.

Added Kconfig to disable priority feature in ticker that is
currently not used by Zephyr Bluetooth Low Energy
Controller.

The priority feature if enabled then a custom ULL is needed
by vendors to avoid repeated skipping of overlapping events
as next_has_priority check uses lazy value that would be
always lazy_next > lazy_current as currently skipped event
becomes the next event with lazy value incremented by 1.

Regression in commit 3a9173afe1 ("bluetooth: controller:
Revised ticker for improved conflict resolution") due to
Zephyr Controller does not implement any vendor specific
priority logic.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-21 12:28:44 +02:00
Mariusz Skamra
933a987d75 Bluetooth: audio: Fix possible memory violation
This fixes possible memory violation by using the index outside of an
instance array by tbs_client_common_call_control.
This basically fixes the get_inst_by_index function to return NULL if
the index is invalid. The function calls have been guarded to catch the
returned NULL.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-09-21 12:25:44 +02:00
Vinayak Kariappa Chettimada
fca96cfe33 Bluetooth: Controller: Reduce cntr_cnt_get() calls in ticker
Reduce the number of times cntr_cnt_get() is called in
ticker implementation as call to this function halts the
CPU inorder to access the RTC count in the 32KHz clock
domain.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-21 08:53:03 +00:00
Vinayak Kariappa Chettimada
69fb2dced0 Bluetooth: Controller: Fix TICKER_LOW_LAT Ext. Scan assert check
Fix Extended Scanning assertion check when using Ticker
Low Latency Implementation where the failure to schedule
a ticker timeout is returned inline compared to deferred
failure in the operation callback.

Auxiliary PDU is received using a single-shot ticker
timeout with ticks_slot reservation. This single-shot
ticker is allowed to fail if it is overlapping another
event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-20 09:10:40 +00:00
Pavel Vasilyev
ef7f5226cf Bluetooth: Mesh: Fix description in BT_MESH_ADV_BUF_COUNT option
Fix description in BT_MESH_ADV_BUF_COUNT option.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-09-20 08:43:32 +00:00
Aleksander Wasaznik
7e11b98125 Bluetooth: Host: Add "assert non-null" to bt_conn_ref
Clearly `conn` must be non-null since it's dereferenced without checks.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-09-20 08:22:28 +00:00
Aleksander Wasaznik
a8f12ab690 Bluetooth: Host: Name enum bt_keys_type
Name annonymous enum with `BT_KEYS_` as `bt_keys_type`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-09-20 08:22:06 +00:00
Mariusz Skamra
bc2414e094 Bluetooth: audio: ascs: Fix crash on source QoS config
This fixes crash that happened during source ASE QoS by setting
the tx path that was left uninitialized.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-09-20 09:40:17 +02:00
Wolfgang Puffitsch
06e7751303 Bluetooth: controller: Fix error codes for accept/reject CIS request
The LE Accept/Reject CIS Request commands shall return Unknown
Connection Identifier if the handle is not a CIS handle or does not
exist. If the CIS already has been established, the commands shall
return Command Disallowed.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2022-09-19 18:34:41 +02:00
Emil Gydesen
927df43092 Bluetooth: Audio: Fix bad BASE config check for broadcast sink
The broadcast sink did not allow codec config data to exist
in both the subgroup and in the individual BISes, which
not only doesn't make sense to not allow, but would
also cause interoperability issues.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-09-19 18:34:25 +02:00
Vinayak Kariappa Chettimada
d7b183d1da Bluetooth: Controller: Fix incorrect data type use
Fix incorrect data type int32_t local variable used for lazy
value which is uint16_t type.

Other minor code refactor done.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:27:38 +02:00
Vinayak Kariappa Chettimada
e8d1ed5d0d Bluetooth: Controller: Fix missing TICKER_SLOT_AGNOSTIC cond. compile
Fix missing conditional compile of structure members not
required with BT_TICKER_SLOT_AGNOSTIC is enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:18:12 +02:00
Vinayak Kariappa Chettimada
336013fe34 Bluetooth: Controller: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned
variable.
MISRA-C rule 7.2

Relates to commit b97db52de7 ("misra-c: Add 'U' to
unsigned variable assignments in subsys/").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
da2b1b615c Bluetooth: Controller: Fix incorrect use of stream instead of bis
Fix incorrect use of stream index (application selected list
of BIS stream) instead of BIS index when checking for
whether the received PDU is to be stored and to be
dispatched as ISO data to ULL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
be7a9ade7d Bluetooth: Controller: Fix missing terminate reason initialization
Fix missing Broadcast ISO Synchronized Receiver terminate
reason initialization that caused Sync Lost immediately on
a new Sync Establishment due to previous Sync terminate
reason not being reset.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
dfa3d959e0 Bluetooth: Controller: Initialize invalid ISO data packet
Initialize the invalid ISO data packet generated by LLL.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
75346a47f9 Bluetooth: Controller: Fix Rx chan idx when skipping BIS subevents
Fix missing implementation to correctly to use data channel
index for subevents when previous subevent of previous BIS
stream where skipped.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
3c92b25234 Bluetooth: Controller: Fix ISO broadcast to flush and ack for all BIS
Fix ISO broadcast implementation to flush stale ISO data for
all BIS streams and like wise generate acknowledgements for
all BIS streams that had its ISO data transmitted at its
reference anchor points.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
c8f5fbcf8d Bluetooth: Controller: Restrict maximum Pre-Transmissions to 1
Restrict the calculated possible Pre-Transmission subevents
count to a maximum of 1 so that the full ISO interval is
not fully occupied by the BIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
eff946a9ad Bluetooth: Controller: Fix leak in Num Completed Packets
Fix a leak in generation of Number of Completed Packets when
more than one handle has acknowledgements to be processed.

The loop exited for the current handle by dequeueing the
node tx element of the next handle leading to lost Number of
Completed Packets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:11:40 +02:00
Vinayak Kariappa Chettimada
f11fe69450 Bluetooth: Controller: Fix missing supervision/sync lost
When radio event prepare is cancelled due to preemption by
overlapping radio events, the extra done event processing
was missing and hence the use of accumulated prepares'
skip/latency count.
This caused the check for supervision timeout and sync
lost not be aware of the elapsed events.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-09-19 18:02:28 +02:00