Fixes two issues with the JIT scheduler:
Rescheduling of primary advertising packets for extended advertising
when using the JIT scheduler did not work, since the done events for
the primary events never made it into the reschedule logic
The EVENT_DONE_EXTRA_TYPE_ADV_AUX event (for auxillary packets) could
cause a "reschedule" for a primary event that was actually sent
successfully (causing it to be sent twice)
Signed-off-by: Troels Nilsson <trnn@demant.com>
audio_iso.c should only be compiled if we require any streams,
so it is now guarded by CONFIG_BT_AUDIO_STREAM.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In case that CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SNK_COUNT or
CONFIG_BT_AUDIO_UNICAST_CLIENT_ASE_SRC_COUNT is set to NULL, the
unicast client implementation in the shell would have compile
warnings, since the arrays would be 0 and we would attempt to
access it some places (or rather the compiler/linker would
think that, but it would never happen at runtime).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Clear the `ATT_CONNECTED` flag when a channel is detached (could be after
an ATT timeout).
Also convert the assert checking it in `chan send` to an `if` test, since
the channel could be disconnected from a different thread than the one
triggering `chan_send`.
Fixes#53247.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Change the BT_AUDIO_ISO logging module to use
log_config_inherit to be consistent with the other LE Audio
logging modules.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
ISO Synchronized Receiver only builds do not transmit and
hence may not have any tx buffers allocated in a
Controller, leaving bt_dev.le.acl_pkts semaphore
uninitialized or bt_conn_get_pkts() returning NULL.
Do not use the semaphore if no Tx buffers allocated in a
Controller.
Regression in commit ef19c64f1b ("Bluetooth: host: poll on
CTLR buffers instead of host TX queue").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add common function to handle large GATT reads of strings.
Initialize the buffer pointers in the net_buf which is used for large
GATT reads by bt_tbs_client_read_call_state() and
bt_tbs_client_read_current_calls().
Define the size of the allocated buffer based on the enabled features.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
The way that the braodcast clause for handling failing
ISO data path would end up in the __ASSERT. It has been
slightly modified to make it use if-else properly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The direction of a stream/endpoint/parameter has just been
logged as a unsigned integer. This commits adds a
value -> string internal function that would log
BT_AUDIO_DIR_SINK as "sink" and BT_AUDIO_DIR_SOURCE
as "source".
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The macro BT_CONN_INTERVAL_TO_MS was used a fair amount
of places, but it often was used with integers. This meant
that sometimes the resulting (integer) value would be
incorrect, as something like 7.5ms interval would not
be properly stored as a integer in millisecond units.
Adding BT_CONN_INTERVAL_TO_US allows users to still use
integers to store the result, but in a more accurate unit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fixes possible ASE state race condition. The notification is sent
immediately once the ASE state changed that eliminates a situation where
the state was changed by user action (API function call) when the state
was not yet notified to the remote Unicast Client.
Fixes: BAP/USR/SCC/BV-158-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes deadlock that happened waiting for meta data in system
workqueue.
The meta data always get freed in the system workqueue,
so if we're in the same workqueue but there are no immediate
contexts available, there's no chance we'll get one by waiting.
Fixes: #53455
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
As the unicast client, we would always create bidirectional
CIS to ensure that the PHY parameter is correctly set.
We can, however, just set the (required) PHY value and
leave the SDU and RTN values as 0, to avoid
creating bidirectional CIS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If either the sink or source ASE count was zero, calls to
ARRAY_SIZE(srcs) or ARRAY_SIZE(sinks) would cause a build warning.
The arrays should actually not be there at all if the respective
ASE count was 0, as that is just a waste of memory. The arrays,
and all uses of them, have been properly guarded.
This also adds a build assert to ensure that at least one
of them is non-zero, and that we also test building either
of them with the value 0.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This allows us to allocate and bind the Audio ISO structs
to Audio Streams, thus allowing us to create the unicast group
before they have been configured.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There was a bug in bt_audio_iso_unbind_ep that caused an
assert, missing unbinding on stream released callback
and missing state check in bt_audio_unicast_group_delete
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the ISO packing field when creating a unicast group.
This refactors the structure of the unicast group create,
as it now takes both the packing as a group parameter, as well
as an array of stream-specific parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When there is an ACL disconnect, or the unicast group is otherwise
deleted, the endpoints were not properly handled, causing
incorrect `dir` values and ASSERTs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When adding or removing a stream from the group, the
endpoint may or may not have been allocated depending
on the state of the endpoint.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The hci_le_setup_iso_data_path function required that if
the path->cc was set, the length could not be 0.
There is no reason why it should not be allowed to be 0
in that case.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The unicast client could not create a CIG with a unidirectional
CIS, because it would not set the correct values as per the
HCI spec for the unused CIS direction.
Instead of implementating a work around, this commit modifies
it so that for unidirectional CIS, we copy the QoS values
to the unused direction, so that we always set valid values,
but it also allows us to actually use that CIS direction later,
assuming that the QoS settings does not change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
For the unicast client, the direction for the endpoint
is reversed in terms of RX/TX, i.e. a sink endpoint is
RX for the unicast server and broadcast sink, but TX
for the unicast client, and similar for the source endpoint.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
The macros are added to make clear which fields of `struct
bt_mesh_msg_ctx` needs to be initialized by an application.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This changes HAS registration to be dynamic and let's the
application set Hearing Aid Type and binaural features.
Often, devices are flashed with generic firmware with some
features stored post factory production, requiring
the settings to be moved from compile time to run-time.
This change will increase the RAM usage as the GATT
service is moved from ROM to RAM.
Signed-off-by: Lars Knudsen <larsgk@gmail.com>
Co-author: Soren Engquist <soren@engquist.dk>
Add API to do the BAP Broadcast Source Metadata update procedure,
which updates the metadata of a broadcast source while
it is streaming.
This is also makes all checks for the "head stream" the same.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The codec is assigned to the stream. However since the metadata,
which is stored in the codec, may be modified by other means,
the stored pointer cannot be const, and thus the
codec argument to bt_audio_stream_reconfig cannot be const
either.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Decoupled the ASEs from the ASCS Session and made them dynamically
allocated instead. A Kconfig option was added to set the maximum
number of active ASEs at a single time. The intent here is to allow
the developer greater control over memory usage; this fix addresses
one of the largest ram usages in le audio.
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Refactored out the client and server members of the endpoint struct
and placed the relevant members in wrappers in ascs and
unicast_client.
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Add logging of the fields in the sent and received pairing
requests and responses. This makes it easier to debug
why a pairing would be e.g. rejected, or simply to get
more insight in the resulting pairing.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If CONFIG_BT_BREDR=y and bt_dev.le.acl_mtu == 0, then we
would report the bt_dev.br.mtu for ISO channels.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the bt_dev.le.iso_mtu was 0, then we would report
bt_dev.le.acl_mtu if CONFIG_BT_CONN=y (which is often true when
CONFIG_BT_ISO=y). Thus if the ISO MTU is 0, we would often
return a non-0 value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of only conditionally starting the discovery at
0x0001, we now always start it at that handle. Since we are
reading by UUID, this should not really affect performance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
mcc.c used 0x%016x, but for some platforms we need to
be more explicit and use 0x%016llx to avoid compile
warnings.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The HAS implementation of the security_changed callback
expected all devices to have bonded, and thus always added them
to the ntf_bonded implementation.
This adds a check to whether the device is actually bonded.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The address could have changed. The issue linked (and bsim test in previous
commit) shows a scenario where that could happen:
- we start scanning, host will use NRPA
- we start advertising, host will use identity address
- a device connects (as a central)
-> advertising resume fails for some unrelated reason
- another device connects (as a peripheral)
- the central device disconnects, we resume scanning
- the peripheral disconnects, the stack resumes advertising
-> but it mistakenly advertises using the NRPA set by the scanner
Fixes#52059 .
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Moved the name filter last, as that it the most expensive
to use.
The address filter has almost been moved after the more
trivial checks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add filtering for the pa_interval. This can be used to
easier find devices that are advertising with periodic
advertising.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The status field is currently a uint32_t even though there are only
3 possible values. Reducing it to a uint8_t allows status to fit in
existing padding in the struct, saving 4 bytes per ticker_user_op
Updated function signatures to match; ticker_op_func left as-is
to avoid having to update a whole bunch of files for no real benefit
Signed-off-by: Troels Nilsson <trnn@demant.com>
In case CIS failed to be established, leave the ASE in enabling state
waiting for peer to retry.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Only copy the data from the 'parent' buf into the segment buf if we
successfully acquired the HCI semaphore (ie there are available controller
buffers).
This way we avoid pulling and pushing back the data in the case where there
aren't any controller buffers available.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
When there are no buffers, it doesn't make sense to repeatedly try to send
the host TX queue.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Make the ACL fragmentation asynchronous, freeing the TX thread for sending
commands when the ACL buffers are full.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Instead of printing every audio packet (typically
arriving every 7.5 or 10ms), we now only print every 100th.
Ideally we would add support for changing the number of
"skippe" audio packets at runtime in a shell command, but
that will be postponed.
Ideally we would also have a rx_cnt per stream, but that will
also be postponed to the future, and should be fixed with e.g.
the sequence number (seq_num) as well.
Finally this commit also adds a verification if the currently
incoming data packet contains the same ts or seq_num of the
previous one, and print if it does, as this indicates that
we are receiving some invalid data.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The lc3_start_time and lc3_sdu_cnt were not reset properly,
causing it to fail when trying to do start_sine after calling
stop_sine.
This commit also ensures that the sending of the sine wave is
stopped once the stream is either released or stopped.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_le_per_adv_set_data would not accept the ad to be NULL or
the ad_len to be 0, making it impossible to set no data (which
effectively clears existing data).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the advertised length, and the actual length, in the log statement
so it is more clear what the issue is.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix MIC failure transmitting LL_CIS_REQ PDU.
The MAXPACKETSIZE value was not set with using Long Control
PDUs.
Relates to commit e895948047 ("Bluetooth: Controller: Add
Long Control PDU support").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove duplicate PPI/DPPI configuration in
radio_tmr_start_now() which reuses radio_tmr_start_us().
And other minor refactor to remove unnecessary conditional
compilation of a define.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compilation error for ISO Broadcaster with dynamix Tx
power support, and remove setting tx power for ISO
Synchronized Receiver.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated implementation to save power consumption by
scheduling BIG event starting at the first BIS selected for
synchronization. Also, skip reception of any unselected
BISes in between multiple BISes that the Broadcaster is
transmitting. Added advance calculation of next subevent
channel index.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
From Bluetooth Core Specification v5.3 Vol 6 Part B Section
4.4.6.8 Channel indices,
The subevent number se_n shall be set to the values 1 to
NSE, in order, for the subevents on a given BIS - the same
values shall be used for all the BISes in a BIG - and to 1
for the control subevent.
Hence, fix implementation to reset back to se_n to 1 when
next BIS PDUs are transmitted in the subevents.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix broadcast ISO PDU receive connection handle. The look up
was using BIS index instead of the index of the selected
stream that is being received.
Example, when receiving BISes 2 and 4, only the connection
handle for BIS 2 was correct and connection handle lookup
was out-of-bounds for BIS 4; symptoms being that Host
dropped the received ISO PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Budget for one extra ISO Rx PDU buffer for empty/NULL PDU
reception that has to always remain free in order to be able
to setup radio h/w for new PDU receptions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes error log that has been shown if number of calls in the list
was equal to CONFIG_BT_TBS_CLIENT_MAX_CALLS.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When Receiver Stop Ready operation has completed, the Unicast Server
may request to terminate a CIS and set source ASE state to Qos
configured state immediately. But after CIS disconnected completed,
it will transition source ASE state from Qos Configured to Disabling
state. It's invalid and will cause assert.
we should add Streaming and Enabling state check when CIS disconnected.
Signed-off-by: Hang Fan <fanhang@xiaomi.com>
Fix compile error building application with
BT_LL_SW_LLCP_LEGACY. Request Peer SCA command is not
supported in legacy control procedure implementation.
Relates to commit 76439d0ba4 ("Bluetooth: controller:
integrating SCA procedure and adding HCI API").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introducing common pdu struct declarations for conn param req/rsp and
data length req/rsp to utilize identicality for optimal pdu handling
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
If a central or peripheral is not configured for ISO connected streams,
reject a remote LL_CIS_TERMINATE_IND procedure, responding with an
unsupported feature error (BT_HCI_ERR_UNSUPP_FEATURE).
This fixes EBQ test /LL/PAC/CEN/BV-01-C.
Signed-off-by: Morten Priess <mtpr@oticon.com>
For making handle available in vendor sink creation, add ISO handle
to function prototype.
Expose datapath allocation via new ull_iso_datapath_alloc function.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Function ll_setup_iso_path has a construction which causes proprietary
compiler to generate incorrect code. As a workaround, local data path
pointer variables are eliminated.
Signed-off-by: Morten Priess <mtpr@oticon.com>
For framed case, the internal RX SDU counter would increment regardless
of whether the first valid SDU was received or not. According to spec,
SDU counter synchronization is done from first valid SDU.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Make sure ll_iso_stream_connected_get returns NULL until CIS is
established. Always return DISALLOWED when trying to disconnect a CIS
which is not connected.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When a CIS is terminated, the associated link pool must be de-
initialized to be ready for next creation of the corresponding
instance in memory.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Log modes other than the deferred may cause unintended delays during
processing of log messages. This in turns will affect scheduling of the
receive delay and receive window for both, Friend and LPN.
Adding a compilation warning instead of assert as a user may still want
to compile a code with friendship feature enabled without actually
establishing a friendship.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The duration value passed to `struct bt_mesh_adv_cb::start` is an
estimation.
When running mesh with BT_MESH_ADV_EXT option, the actual duration will
be shorter and the `struct bt_mesh_adv_cb::end` is called right after
the contorller finished advertising. Using the calculated duration the
lpn node can be configured for a shorter receive delay and receive
window and eventually use less power.
When running mesh with BT_MESH_ADV_LEGACY option, the time when adv will
be sent out by controller is unpredictable. But the time between start
and end `struct bt_mesh_adv_cb` callbacks is always 50ms for a single
advertisement. Therefore, the receive delay can't be less than 50ms.
With this change, adv duration is calculated between start and end
callbacks, but timers are started after end callback is called. Therefore
we need to consider time between two callbacks when setting timeouts for
timers.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If a user does some heavy operations in friendship callbacks
unintentionally, this may break friendship communication as timers will
be scheduled or messages will be queued only after code execution comes
back from these callbacks. To avoid this issue, call callbacks only after
required operations are done.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Do not assert on invalid PDU in CIS create procedure. Instead terminate
with reason BT_HCI_ERR_LMP_PDU_NOT_ALLOWED
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Corrected an omission in the ISO-AL that required an SDU interval to
be added to the reconstructed RX time stamps for each SDU after the
first.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
This commit removes illegal use of NET_BUF_FRAG in friend.c, which is an
internal flag.
Now `struct bt_mesh_friend_seg` keeps pointer to a first received
segment of a segmented message. The rest segments are added as fragments
using net_buf API. Friend Queue keeps only head of the fragments.
When one segment (currently head of fragments) is removed from Friend
Queue, the next segment is added to the queue. Head has always 2
references: one when allocated, another one when added as fragments
head.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
- New calculation of Max_PDU for framed case according to BT Core 5.4
- Fix CIS_Offset calculation for multiple CIS usecase
- Fix resume ticker setup for central
Signed-off-by: Morten Priess <mtpr@oticon.com>
Rather than exposing shell commands that take an opcode and
an optional parameter, the shell commands are now explicit
so that it is easier for a person to use the shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The `audio connect` shell command did not really do
anything anymore, and has thus been removed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Some of the unicast audio shell commands were guarded by
CONFIG_BT_AUDIO_UNICAST_CLIENT and only usable by the client.
This moves some of the commands to a CONFIG_BT_AUDIO_UNICAST
guard instead, so that they are usable for builds with just
the server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fixes VCP Volume Renderer linker error that was seen if built
with VOCS and/or AICS support disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
An LE controller shall no longer support HCI_Read_Local_Supported_Codecs
[v1] according to BT Core 5.3.
Command bit and support code removed.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Adding a bit-mask to the 'extra' data structure allowing passing info
re. active CIS's to the ull_conn_iso_done handling. Per CIS storing
an expiration time counter, monitoring in done handling. Adding
establishment timeout monitor in CIS Create procedure, completing
and ntf'ing accordingly.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
If a CIS is in teardown state, the data in structure should not be
trusted, so skip passing data to ISOAL
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Instead of storing the calculated reload value (in conn intervals) in
the conn object, now store the timeout value, and perform calculation
when used. This allows using the timeout value across all CIS's without
having to re-calc and store on change of TO
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Added a new Kconfig option for the Bluetooth Host to allow
unauthenticated pairing attempts made by the peer where an
unauthenticated bond already exists on other local identity.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Update the Bluetooth specific Kconfig legacy log template to use the new
log inheriting template.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Missing decode of conn_event_count on CIS_IND
Peripheral Suggest update to conn_event_count in case of a delayed
CIS_IND, allowing CIS peripheral more time to setup
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
The Bluetooth spec states that a K-frame exceeding the device's MPS
should trigger a disconnection of the channel.
Fixes two PTS tests that verify this behavior:
L2CAP/LE/CFC/BV-27-C
L2CAP/ECFC/BV-34-C
The current behavior is a silent truncation, which is not very nice for
the user, even if the spec would allow it.
Fixes#52228 and #51174.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Add mayfly locking around the access to the local pending procedure list
as it is accessed by both thread and mayfly.
Fixes#45427
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
When generating notification for Sleep clock accuracy, check for
success on rx_node allocation was left out. This is added.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
When MCC disconnected, it would memset the entire instance.
This causes issues, because the subscription parameters
would also be memset, causing the `notify` callback to
be set to NULL. If this was done as part of a disconnect,
the GATT layer would attempt to call the notify callback
as part of cleaning up the ACL, but if the callback was
set to NULL (from the memset) this caused a fatal error.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When reporting a receive state to the upper layers, the broadcast
assistant should report NULL if there is not a receive state
active. The "activeness" of a receive state is determined by
the length of the characteristic - If it is 0 then there
is no receive state active.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the struct bt_vcp pointer from the volume
renderer API, as there is only ever a single
Volume Renderer instance on a device.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Split the `bt_vcp_cb` struct into separate structure for
the volume controller and the volume renderer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The VCP server, known as the volume renderer, has a
more explicity bt_vcp_vol_rend API naming scheme now.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the bt_vcp_vocs API as it did the same as the
bt_vocs API, and did not really any functionality.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The AICS functionality can be exercised using the
bt_aics API instead. These functions did very little
besides cluttering up the bt_vcp API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Renames almost all occurences of VCS to VCP, as we want to
use the profile as the namespace for volume control.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename vcs.h to vcp.h to better detail what the
file contains, as it is more than just VCS. This also
renames the Kconfig file.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The `bluetooth/common/log.h` and `bluetooth/common/log.c` files have been
removed. Files that were using them have been updated to use
`zephyr/logging/log.h` instead.
Those replacement have been done consequently:
- `/BT_DBG/LOG_DBG/`
- `/BT_ERR/LOG_ERR/`
- `/BT_WARN/LOG_WRN/`
- `/BT_INFO/LOG_INF/`
- `/BT_HEXDUMP_DBG/LOG_HEXDUMP_DBG/`
- `/BT_DBG_OBJ_ID/LOG_DBG_OBJ_ID/`
Also, some files were relying on the `common/log.h` include to include
`zephyr/bluetooth/hci.h`, in those cases the include of `hci.h` has
been added.
For files that were including `common/log.h` but not using any logs,
the include has been removed and not replaced.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Ensure that another established connection with the mesh device don't
mess up pb-gatt server state.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When a remote devices establishes a ble connection with the mesh device
with default identity and there are more available connection slots, the
mesh stack will try to restart connectable advertisements (either
pb-gatt or proxy depending on the provisioning state). This makes
difficult for an application to advertise own connectable advertisements
as the mesh stack will not let a chance the app to start advertising.
This change adds a Kconfig option that limits number of connection slots
that the mesh stack can use for own connectable advertisements.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This fixes build error that happens when shell is built without CAP
Acceptor Set Member support. The cap_acceptor.c contains shell commands
for Set Member only, thus it's OK to build the code if
CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER is set for now. This can be modified
in the future when shell will be extended with other
Set Member non-specific CAP commands.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The compliance check did not like the otherwise valid
way of returning from read_set_sirk.
The code has been slightly refactored to avoid the check
failing in CI.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the service instance struct instead of the more generic
`bt_csip` for the CSIP set member API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the bt_csip_set_coordinator_svc_inst struct in the
set coordinator implementation instead of the more
generic bt_csip.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modified the CSIP set coordinator slightly to not use the
bt_csip struct at all. For the use a void pointer works
equally well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Renamed remaining structs and functions that are not
for the set coordinator to use the set member CSIP
role name.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Renamed the coordinated set implementation to use the
profile (CSIP) name instead of the service (CSIS) name, as
the former is more general.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implement HCI commands HCI_Read_Connection_Accept_Timeout and
HCI_Write_Connection_Accept_Timeout, and enable the feature in
supported commands.
Remove hardcoded use of default accept timeout in new LLCP code, and
use configurable value instead.
This makes EBQ test /HCI/CIN/BV-03-C pass.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Updates the broadcast source API to create subgroups and
to set BIS specific codec configuration
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
LPN should send Poll\Sub Add\Sub Del only once.
Sending multiple times breaks polling time parameters
(Figure 3.17: Friendship timing parameters).
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Adjust skip value so that there is minimum of 6 events that can be
listened to before Sync_Timeout occurs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add the local advertising address to bt_le_ext_adv_get_info.
This may help with debugging, but is also needed to
properly support something like the BAP Broadcast Assistant.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Ensure maximum size of common extended header format be
reserved when CONFIG_BT_CTLR_ADV_RESERVE_MAX=n is used so
that changes to ACAD, like channel map update does not need
frequent update to periodic advertising auxiliary channel
PDU time reservations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
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. EVENT_OVERHEAD_START_US has to be reduced
as this value is used to offset the start of the radio
event on air.
Reverts commit b867f0e8a6 ("Bluetooth: Controller: Fix
T_MAFS between broadcasting roles").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable advertiser main to support relay messages, this maximizes
theutilization efficiency of advertising sets, which is helpful for the
sending of dense relays, but for Friend and LPN, it delays the sending
of local messages a little, this may cause the time slot deviation between
friend and lpn, and the power consumption of lpn will increase.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
For Mesh Message, should only process by model layer when dst
is unicast address of this nodes or model subscrip on.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The default number of buffers (contexts) for locally initiated
procedures was 4. Per default the host initiates 3 procedures
when opening a connection, allowing the application to initiate
only 1 additional procedure in parallel.
This commit increases the default to 6, if auto phy-update and
dle is enabled, increasing the robustness for an application.
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
mcc.c does not include `conn_internal.h` so it does not
know the `bt_conn` struct, causing logging issues when
trying to log a `bt_conn` pointer.
Fixed by casting the `conn` pointers to `(void *)`.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
One of the notification callback functions did not properly
get the `read_params` pointer, causing an invalid result of
CONTAINER_OF as it would use a NULL pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Call the RPA expired callback on advertising sets even when they are
not enabled.
The RPA expired callback will now be called on advertising sets
when the BT_ADV_RPA_VALID flag is cleared for the set.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix RPA timeout expiration when BT_EXT_ADV has been enabled.
Always invalidate the device RPA on RPA timeout.
This RPA is used by the scan roles, and the advertiser that was started
using the bt_le_adv_start API.
Call the RPA expire callback only on advertising sets that are enabled
and not being limited by a timeout and not using the identity address.
On RPA timeout always invalidate the RPA of advertising sets that are
disabled.
Fixes: #51208Fixes: #51228Fixes: #51247
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add shell support for RPA expire callback.
This prints a message when the callback is called on the specific
advertising set.
Add a command to control the return value of this callback for a
specific advertising set.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
- Add CIS Create policy config choices
- Implemented CIS Central in ULL following proposed setup/commit flow
- Full support for HCI_LE_Set_CIG_Parameters_Test
- Extend ull_conn_iso_start and ull_conn_iso_ticker_cb to handle
central role
- Partial support for HCI_LE_Set_CIG_Parameters. TODOs:
* Drop suggested retransmissions if Max_Transmission_Latency is
exceeded
* Calculate ISO interval based on policy
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix issues with referencing invalid netbuf data and add missing
parameter. Removed returning of handle in setup functions, as handles
are not available until commit.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Move ull_peripheral_iso_start ull_peripheral_iso_ticker_cb to
ull_conn_iso, to share code between CIS peripheral and central.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Local procedure for CIS central establishment. Calls yet unimplemented
functions in ull_central. Changes are guarded by
CONFIG_BT_CTLR_CENTRAL_ISO.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Replace the BT_CTLR_ADVANCED_SCHEDULING_CENTRAL_CONN_SPACING
Kconfig with BT_CTLR_CENTRAL_SPACING to configure the
the spacing from the beginning of a central connection event
to beginning of the next central connection when supporting
multiple simulataneous central connections.
If the BT_CTLR_CENTRAL_SPACING in microseconds is smaller
then the required time reservation for a connection event,
for given maximum data length and PHY in use, then the
calculated time reservation will be used as the spacing
between consecution central connection events.
The change fixes an issue wherein use of old Kconfig with
higher values causes new central connections to be placed
in between already connected central role if there was
free time space available to fit the new connections time
reservation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When application uses multiple identities mesh stack keeps reacting
on connection events not related to the own identity (BT_ID_DEFAULT)
causing it to trigger additional advertising and this leads to errors.
Though not harmful, this also leads to mesh stack counting connections
wrongly and consuming internal resources.
This commit fixes the issue described above by checking the
connection id before proceeding further.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Explicitly set all bits of used radio registers when
configuring radio events, removing the dependency on having
the power-on reset value and removing the need to ensuring
power-on reset values being set in the radio peripheral.
This will ensure the Controller has radio register value
correctly configured irrespective of changes across SoCs'
radio register power-on reset values.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
strcpy copies string including terminating null character.
strlen returns length without terminating null symbol.
If oob string is 16 bytes length then strcpy will corrupt byte
after auth array.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The sample in the Provisioning protocol spec chapter
is in big endian. Static OOB value should append
zeroes on the little endian platforms.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Rename BASS to BAP Scan Delegator and BASS Client
to BAP Broadcast Assistant. This is the first step towards
integrating the BASS with the rest of BAP.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In file `subsys/bluetooth/mesh/net.c`:
renamed `loopback` to `net_loopback`.
In file `subsys/bluetooth/host/settings.c`:
Renamed `set` to `set_setting` and `commit` to `commit_settings`.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Removes the global cur_mcs_inst and replace it
with lookup functionality.
This fixes an issue with bt_mcc_discover_mcs not being able
to be called more than once, as well
as streamline the implementation significantly.
This is also the first step towards not only supporting
multipe MCS instances for a single device, but also a
step towards handling multiple devices.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
It was possible that on re-connect, the MCC implementation
would receive notifications when cur_mcs_inst was NULL.
This is partially caused by a bug in gatt.c, but can
and should also be handled in MCC.
This commit ensures that we do not compare handles
on notifications with a NULL instance.
This commit also ensures that subscribe_mcs_char_func
is not called outside the context of the discovery
procedure by setting the subscribe callback
to NULL.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If adv stop was called form connected callback,
it would continue and unref the wrong conn object
if there where 2 connectable advertisers running,
but with only one 1 id configured.
Fixes#52196
Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
Fix advertising set's is_enabled flag to be reset when
connection complete is dequeued for connectable advertising
started using legacy advertising enable HCI commands. And
reset the is_enabled flag when advertising set terminated
is dequeued for connectable advertising enabled using
Extended Advertising HCI commands.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticks difference calculation to determine delayed
prepare callback. Without the use of masking by
ticker_ticks_diff_get, the diff value can be higher than
the supported 24-bit value. i.e. ticker_ticks_now_get()
rolls over in 24-bit value, whereas ticks_at_event is
free running value of 32-bits.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add long control PDU size support, also the implementation
now allocates control PDU size restricted to the supported
biggest control PDU that is enabled in the application
build. Features that are covered based on the increasing
control PDU sizes are ClearText connections, Encrypted
Connections, Connection Parameter Request support and
Create CIS control Procedure (Connected Central ISO)
support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After merging #51809, a few things were spotted that needed tweaking.
Among them:
- Rename the folder from bt_crypto to crypto, since the prefix is
unnecesary
- Remove the include folder
- Remove the path from the global include paths
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
-- Handle time calculations across the point at which the controller's
time information from the controller's clock will wrap (in the
microsecond range)
-- Use wrapped time in all ISO-AL time calculations
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Add to the cryptographic toolbox the h8 function, defined in the Bluetooth
Core Vol. 6, part E 1.1.1.
Also add test and SMP self test for this function. The data used for those
are from the Bluetooth Core.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Move functions defined in the Cryptographic toolbox of the Bluetooth
specification inside their own files in the following folder:
`zephyr/subsys/bluetooth/bt_crypto`. The functions were previously
implemented in `zephyr/subsys/bluetooth/host/smp.c`.
The cryptographic toolbox functions can now be accessed from outside of the
host.
In addition to that, tests for each cryptographic toolbox functions have
been added.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
When a BIS disconnected, we removed the references between
the endpoint and the stream. This made it impossible
to later unbind the audio_iso when
broadcast_sink_cleanup_streams was called.
Fixed by unbind the audio_iso when we remove the reference.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding support for allowing user extension code to support deferring
anchor point moves. Refactored LLCP only.
Note: This is NOT supported by LEGACY LLCP impl.
KConfig'd by BT_CTLR_USER_CPR_ANCHOR_POINT_MOVE
Modified ll_conn_update API, to accommodate passing offsets
Modified CPR/CU context data structure
Modified CPR/CU procedure to handle anchor point move wait state
Fixed up unit tests, adding anchor point move cases to CPR/CU test
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Using a macro instead of repeated identical code for validation
Use macro for pdu length field encoding
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Instead of guarding all BT ISO data log statements with
CONFIG_BT_DEBUG_ISO_DATA, a new macro, BT_ISO_DATA_DBG, is
implemented to handle the guarding.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Guard additional debug statements in ISO that deals
with TX/RX with CONFIG_BT_DEBUG_ISO_DATA to avoid spamming
the log.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_eatt_init currently registers a l2cap server, however should not
register a new one if it has already been registered - for example in
bt_enable previously.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
Init bt_workq in bt_enable so it can be safely disabled.
Cancel rpa_update work upon disable as it is no longer required.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
Add bt_pub_key_hci_disrupted function for when hci is disrupted during
a pub key hci command, to clear callbacks and BT_DEV_PUB_KEY_BUSY flag.
Call this from bt_disable for the case bt_disable disrupts the pub key
hci command.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
Reset disconnected handles as is no longer needed after disable.
Created a destroy function to clear all connection states and cancel any
deferred work.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
Reset the adv_pool in disable so that advertising can be started after
re-enabling without issue.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
In bt_att_init, bt_conn_init and bt_l2cap_init, init the fifos and
slists before use. This means that they can be used after disable
without memory leakage.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
This fixes invalid error code that was returned in case remote requested
Disable operation with invalid ASE ID.
Fixes: BAP/USR/SPE/BI-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When a provisioner connects to the device, gatt_connected callback is
called in pb_gatt_srv.c, then pb-gatt advertising is stopped and adv_sent
callback is triggered in adv_ext.c. adv_sent callback reschedules
advertising and eventually calls bt_mesh_adv_gatt_send. Since the device
is not provisioned yet, it tries to start pb-gatt advertising again. If
number of available connections is reached, this results in "Advertising
failed" error in adv_ext.c.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Add implementation to retry the automatic peripheral
perferred connection parameter request with a configurable
retry countdown and retry back-off timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ASE in QoS state already have audio ISO object.
This will just skip the audio ISO allocation and binding in such case
if CIG and CIS parameters did not change.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Since Mesh Spec and Mesh model sayes, some model no need
groups and no need keys, such as Config Server, but the
current implementation, all model use same configuration,
which cause some ram ext comsume.
So that, change to specific way, but will consume more footprint size.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Adding controller support for updating SCA in ACL and ISO peripherals
Adding HCI API support for le_request_peer_sca and complete event.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
The broadcast sink supports multiple subgroups, but was
not possible due to the Kconfig option.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Check LE event mask state as well as host controlled feature mask state
and reject CIS request accordingly.
Release pre-allocated ISO resources on rejection of request
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
The CSIS client shell did not print the pointers of the instances
discovered, which are needed for future commands.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the set absolute volume opcode was received, we
logged the current volume, but without any explaining
text.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The metadata in the presets are just defined
using the BT_AUDIO_LC3_PRESET which ultimately
uses BT_CODEC_LC3_CONFIG_META which correctly
sets the data pointer, but the `value` array is unused.
So we cannot just update the `value`, as that is actually
not used in those cases, and the `data` pointer is `const`.
The solution is to a copy of the metadata data, and use
the copy when calling the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Unbind ISO when goint to idle state if there's still reference kept.
It may happen that we get CIS disconnection being in non-releasing
state, so we have to handle that case. This fixes regression that was
introduced in 3fa456905d.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes adding 2 redundant bytes... to the PAC records.
As a result we end up with broken PAC record.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The bt_iso_chan contains vaild pointers for Tx and Rx QoS parameters.
This unifies the implementation between different roles.
This fixes checking ISO type that is done based on ISO type that
is kept inside of conn.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds common bt_audio_iso pool that will be used across all the
roles/profiles. The pool range is dependent on the CONFIG_BT_ISO_MAX_CHAN
which is the maximum number of ISO connections the host can maintain.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Move the control point work to the EP. The aim is to cleanup the code so
that it there's no EP for ASE that means ASE is in idle state.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Select BT_TICKER_NEXT_SLOT_GET when BT_LL_SW_SPLIT enabled
and building applications with shell support (BT_SHELL).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The endpoint was only partially memset on disconnect,
which left the handles untouched. This meant that the
reset endpoint would still get returned by
unicast_client_ep_find.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Program CIG ticker with window widening drift. Introduce vendor specific
conversion macros allowing sub-microsecond resolution in the
accumulation of window widening drift per interval.
Calculation of window_widening_max_us is done for NSE<3, and must be
adjusted in the LLL before use, if the first CIS in the CIG has a
NSE>=3. In that case window_widening_max_us shall be limited to one sub
interval.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Remove the `bt_hex`, `bt_addr_str`, `bt_addr_le_str` and `bt_uuid_str`
macros from `bt_str.h` as they were just aliases for the `*_real` functions
in the same file.
The functions has been renamed without the `_real` suffix.
Some files were using the functions and not the macros, they have been
updated to use the new name of the functions.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Functions related to string manipulation that were defined in
`common/log.h` has been moved to the `common/bt_str.h` file and their
implementation in `common/bt_str.c`.
Files that were using those functions has been updated consequently.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Fix ticker slot reserved check to handle deferred execution
of ticker worker where ticks_elapsed is greater than
ticks_slot_previous. In which case, each ticker expiring be
checked for overlap with previous slot reservation.
This fixes:
ASSERTION FAIL [0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/
controller/ll_sw/nordic/lll/lll.c:476
lll_preempt_calc: Actual EVENT_OVERHEAD_START_US = 3906
Flash erase operation exposed the assertion, CPU being
halted deferred the ticker_worker collision resolution and
ticker expiry was not individually checked for overlap with
previous expired ticker reservation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing first connection event due to first connection
event ticks_slot of central and peripheral overlapping with
the initiator window ticks_slot and advertising ticks_slot,
respectively.
Use ticker_stop_abs interface so that when the ticker is
stopped the ticks_slot_previous is truncated to the actual
ticks used as requested by the supplied absolute ticks.
Relates to commit 8a294a62d4 ("Bluetooth: controller:
legacy: Fix missing first conn event").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker instance ticks_current initialization to be
acquired from the RTC counter value. The RTC counter may
have run in previous use of ticker before bt_disable hence
keep the instance ticks_current equal to RTC counter value
when ticker_init() is called again.
Relates to commit 4349a475a8 ("Bluetooth: Controller: Add
deinit() infrastructure").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add back erroneously removed ll-addr command, when removing
legacy Controller, which is provided when using Zephyr
Bluetooth Low Energy Controller to read the random and
public address set by the Host, and used by the Controller.
Relates to commit b67a31e411 ("Bluetooth: controller:
Remove legacy LL").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Setting the extended advertiser as default advertiser
to improve both preformence and reliability.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
There were a bug in a prepare_cl_cte_rx_enable_cmd_params function.
The size of command buffer was wrong when CTE enabled in AoD mode.
The command buffer was extended by param->num_ant_ids, that was
zero in case of AoD. Then a dummy antenna switch pattern was copied
into the command buffer.
That lead to: memory overwrite, and wrong command buffer length.
The command was rejected by Controller.
To fix, use cp->switch_pattern_len that was already assigned with
correct antenna pattern length.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In order to avoid using multiple sources of truth for the platfom's
endianness, convert the in-tree code to use the (BIG|LITTLE)_ENDIAN
Kconfig variables exclusively, instead of the compiler's
__BYTE_ORDER__.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
If using the advertiser list when syncing to a PA, then the
address address needs to be updated for the PA sync object.
This is a small optimization to avoid doing a copy when
the address and SID is already set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When deleting a PA sync with bt_le_per_adv_sync_delete
Zephyr should call the `term` callback for the PA sync
as per the documentation for the callback.
This was not done in the case that the PA sync was
terminated by local request.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
To avoid legacy extended adv repots blocking important
events or work, mark them as discaradble.
Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
According to specification, when executing a remote procedure the
rx parameters used need to be updated when the REQ from the peer
is received. Currently this is done only when an ACK is
received on the RSP PDU send out.
This commit updates the RX parameters upon receipt of the REQ PDU
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This commit prevents the assertion error added in the previous commit,
by introducing the following behavior.
When the Host detects that a pairing procedue would result in more than
one local identity having a bond with the same remote address, it will
try to abort the pairing. If the pairing procedure cannot be properly
aborted, it will remove the pairing locally and disconnect.
This commit also introduces a new kconfig `BT_ID_UNPAIR_MATCHING_BONDS`.
This config changes the above-described behavior to instead un-pair the
old bond and continue with the pairing (if the new bond has the same or
better security.)
The new kconfig is not enabled by default. See the help text of the new
kconfig option for more details.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
This change prevents two local identities from having bonds to the same
device.
The Core specification is not well suited for Zephyr's multiple-local-
identities feature. The HCI specification seems written with intent that
a controller is used for only one GAP device. A GAP device has at most
one public address, and at most one random static address.
The Zephyr Bluetooth API, on the other hand, has a concept of local
identities. This feature allows the Zephyr Bluetooth stack to
simulatainously assume multiple local addresses. This does not mesh well
with the above intent in the specification.
In particular, the HCI specification for the resolve list does not allow
more than one entry for a remote address. The controller will deny any
attempts at doing this.
The current implementation of the Zephyr host will try the above and be
denied. But there is no handling for this situation and the host ends up
in a confused state. Some parts of the system are ok with the two bonds,
but other parts assume this situation never occurs behave badly.
The result is that the host confuses the multiple bonds to the same
device. Symtoms include:
- Directed advertisements have a different source address than what the
host intended, in which case the two sides are confused about the
address of the Zephyr advertiser, and as a result LTKs will not match.
- Errors in the log.
This commit simply asserts. This is not a solution, just a placeholder
for a fix. The next commit will implement a strategy for handling this
situation instead of failing this assert.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
If 2 ASEs shared the same CIS and the first ASE had the CIS
connected before the second ASE was QoS configured, then
the CIS was missing either the TX or RX pointer, causing
it to be considered unidirectional by the ISO layer.
This commit fixes this issue by configuring the (static)
pointers at an earlier time, so that the RX and TX QoS
pointers are always valid.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This changes the API to use proper naming convention, as the code has
been moved out of capabilities.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes missing checks, and invalid struct bt_pac definition that was
missing one mandatory metadata byte.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This makes use of bt_audio_foreach_capability fuction to
simplify building the PAC attribute value.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
There is no point of having dedicated source file that is PACS
dependent. This moves all of the code from capabilities.c to pacs.c.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Macro that was defined in the `common/log.h` has been moved to the newly
created `common/assert.h` file.
Files that were using those macro has been updated consequently. Also, the
include of `common/log.h` has been removed of files that were actually not
using any logging methods.
Some `#include "common/log.h"` have been removed. Those were required
before when including `hal/debug.h`. With this change, `hal/debug.h` no
longer has this requirement, because the replacement, `common/assert.h`
includes what it uses.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Replace unnecessary `BT_HEXDUMP_DBG` with `LOG_HEXDUMP_DBG`.
`BT_HEXDUMP_DBG` did an extra cast to `const uint8_t *` on its first
argument. This was probably the reason it was introduced. But the
current definition of `LOG_HEXDUMP_DBG` does this cast for us.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Fix copying addresses returned in response to command
BT_HCI_OP_VS_READ_STATIC_ADDRS for reading controller static addresses.
The loop was iterating only over the destination locations while
keeping the source address pointing to the first location of
the command response.
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
Add a new stream object, bt_cap_stream, which is an extension
of the BAP bt_audio_stream. The purpose of this stream
is that we can extend the data stored in the BAP stream for
CAP usage, as well as making it more explicit what type
of stream should be used for CAP.
The callbacks will be extended for CAP in specific use cases,
e.g. when starting one or more unicast audio streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the generic CONFIG_BT_CAP and CONFIG_BT_DEBUG_CAP
and only use Kconfigs specific to the individual roles.
This also includes renaming cap.c to cap_acceptor.c.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CAP initiator will now discover, or return a
known, CSIS instance included by CAS (if any).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the CSIS client callback to a slist so that
multiple applications can register it. An example of
such a case is that both the application and CAP initiator
want to get the callbacks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The API will now take a simple bt_conn instead of a
set member struct. This is due to the set member struct
being moved to the stack. The reasoning for this is that
having the struct in the stack, rather than in the
application, the stack itself can initiate the CSIS
discovery which is useful if the remote device
has a service that includes a CSIS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This is the primary discovery of the CAS on the remote device,
but does not include discovering the (optional) CSIS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add skeleton for the expected APIs and
implementation. May be subject to change as
implementation progresses.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The sequence number is by the core spec defined as 16-bit.
We had implemented a workaround for the wrapping of the
sequence number, which required the type to be larger
than 16-bit (32-bit).
However, since the definition of the sequence number,
and the use of, is poorly defined by the core spec, we
are reverting this workaround and reducing the sequence
number to 16-bit again. This way it is more in line
with the core spec, as well as more intuitive given the
other uses for the sequence number.
This change moves the responsibility of using the
right value to the upper layers, as the stack can
and will no longer provide any guarantees.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The function did not provide anything that could
not just as easily have been done in the existing
loops.
This just required moving the call to ad_init to
after the param parsing loop.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The struct bt_ascs holds the conn reference already,
thus it's not needed to store the device address.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
bt_id_del() was setting the bit 'BT_KEYS_ID_PENDING_ADD' instead
of setting the bit 'BT_KEYS_ID_PENDING_DEL'
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
Increment the number of identities after a successful execution
of id_create() by checking if the return value is 0.
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
Document `bt_irk.rpa` as "Cache for `bt_keys_find_irk`. Not reliable as
"current RPA"!".
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Add NULL checks when registering the media_proxy_pl_calls.
Currently the media player expects all of them to be set.
In the future, ideally the callbacks would mostly be
optional and reflect which of the optional
characteristics that there is in the MCS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Convert model_ackd_send and model_send from health_cli.c to a common API
to get rid of code duplication in other client models that implement
synchronous messages' sending.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
There should be functional equivalence between these two forms. And the
'_eq'-form is more readable.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Adds check to verify that the audio stream is actually
in the streaming state before handling the
audio data. As per the BAP spec, a stream that
is not in the streaming state shall not send
any data, and this check is to handle any
remote devices that are not working correctly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Change linkage for ctx_shell and default_key in shell.c to external to
share their usage in other places.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commits renames `health_cli.c` and `cfg_cli.c` under `mesh/shell`
folder to `health.c` and `cfg.c` accordingly. This is to create a
generic pattern for the future, when not only clients, but server models
will also expose some API through shell commands. This means that server
models' shell commands should be located in the same file as client
commands to avoid cluttering `mesh models` subcommand.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This code is a boulerplate that will be needed for many models in mesh
shell module. This commit adds a special macro designed to improve
readability of the code and helps to avoid potential bugs when
copy-pasting identical code.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Not all shell commands may be needed for an end application even if a
certain feature is enabled. In that case they will just occupy flash
space without being used. This commit adds a separate Kconfig for each
feature to make possible to selectively disable some mesh shell commands.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Move mesh shell related options to a new file to avoid cluttering of
the main Bluetooth Mesh Kconfig file when extending it with new options.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The "limit" field of struct k_sem was in use in two places in the BTLE
host code, in one it was being used as a duplicate placeholder for the
"iso_max_num" field received in read_buffer_size_v2_complete[1]. In
another, it was just being tested for zero[2].
Those are pretty clear abuses of internal data, provide minimal value
beyond a few bytes of memory in struct bt_dev_le, and in any case
won't work with zync, where that field doesn't have the same name and
may not even exist depending on app configuration.
Copy the limit value into the struct where it belongs, and use it from
there.
[1] I strongly suspect there is a bug lurking there if the semaphore
maximum is being used to implement the kind of "packet buffer" this
code looks like. Calling k_sem_give() on a "full" semaphore WILL NOT
BLOCK. It will just drop the increment on the floor and return
synchronously. Semaphores aren't msgqs or ringbuffers! But disabling
the max value feature in zync does not result in test failures, so
maybe this usage is safe.
[2] Again, this seems suspicious; a valid k_sem should never have a
zero in that field. Presumably this is really a test for "is
initialized", and so implies there's a mixed up initialization path
somewhere?
Signed-off-by: Andy Ross <andyross@google.com>
Zephyrs Host has by default enabled automatic resume of advertising
in case of disconnection when peripheral role is enabled.
The feature becomes a bit problematic in case of multirole usage.
For example assume a use case where a device is working as peripheral
and central, where it may establish single connection for each role.
In case there are two connections established and connection in
central role is dropped by peer, Host will automatically resume
advertising. After that an application can resume scanning, e.g.
in disconnected callback. That should not happen.
If one of connections was used for central role, it should not
be stolen by Host to run peripheral role. Host should verify
if a disconnected connection role was peripheral and then resume
advertising.
This approach will not break backward compatibility and change
correct resume behavior. What more, Host will follow an application
decisions about use of connection objects.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The `audio init` should only initialize the audio (BAP)
stack. Furthermore, given that the `bt init` may do more
than just calling `bt_enable` it is generally for the best,
and more future proof, to let that command be the exclusive
way of calling `bt_enable` in the shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
It was possible to enter a state where setting the QoS
for a source stream after having released a sink stream
as the unicast client would cause a segmentation error.
This issue is related to how the unicast shell is using
the unicast group.
A fix has been added for it, and a check for
whether or not `audio init` (to register the needed
callback) has been added. This check has also been added
for the broadcast sink.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds proper support for having more than one PDU pool for the advertising
PDUs (to save memory)
- Introduces lll_adv_aux_data_init, lll_adv_aux_scan_rsp_alloc and
lll_adv_sync_data_init to indicate if the PDU is a primary/legacy PDU
or secondary/auxillary PDU
- Scan response PDUs are initialized later, since the correct pool to draw
from depends on whether the advertising is extended or legacy
Signed-off-by: Troels Nilsson <trnn@demant.com>
Not all C compilers understands how to use the address of a return
value as an argument to a function call. At least not our compiler.
Fix the issue by adding a variable to hold the converted value
before passing it to the function call.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
When calling bt_audio_discover, the discovered PAC records
were just added to the pac_cache. If called multiple times,
the PAC records would just be duplicated.
This change reset the pac records for the direction when
called.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_audio_stream_config should not be called with a stream
that is already configured to another connection.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This caused the sink to attempt to sync to more stream
for each call to bt_audio_broadcast_sink_sync as the
stream count was stored in the struct bt_audio_broadcast_sink
but never reset.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is no reason for the previous limitation.
The limit of 255 for the ASEs is based on the ASE IDs
which is a uint8_t, so there is a maximum of 255 of
each ASE type.
The limit of 73 * 2 = 146 is based on the maximum size of an
GATT attribute (512), and the minimum size of a PAC record (7)
makes it a total of 73 PAC records for each direction.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is access to the procedure context after a potential release
of the context, which (in theory) can lead to incorrect behaviour
There is no good way of testing this with a unittest without adding
specal debug code to the ull_llcp_local module
After code-inspection no other location has been found with
potential access after context release
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This refactors how the BAP broadcast source handles the
extended and periodic advertising.
First it removes the start and stop of the extended
advertising, and instead expects the application
(or upper layers) to do this.
Second it exposes API functions to get the
necessary advertising data from BAP (service data and
the BASE), which the upper layers will then also
be responsible for setting and updating.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The metadataa_updated callback has existed for a long
time, but was never actually used. The metadata is set
or updated in the enabling and streaming state.
Added checks to see if the state actually changes when going
into these states, and if not, then it means that the
metadata was updated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If bt_audio_stream_connect didn't fail, we would just return
without sending the receive start ready command.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since the net cache is accumulated in positive order, the net
cache uses reverse order traversal, which can filter duplicate
messages more effectively.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Since in bt_mesh_net_recv will call msg_cache_add
and if lpn reject this message, should remove this cache.
But this function sequentially and will not be interrupt
by any thread so, we no need a copy var to save this value.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
According to Core 5.3 Vol 4, Part E, section 7.8.82 slot_durations,
switch_pattern_len and ant_ids are used only for AoA and do not affect
reception of AoD CTE.
To improve interoperability checking of correctness of these parameters
is not required. It will not affect lower link layer in case the AoA
CTE reception feature is not enabled in Kconfig.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This function exposes list pointer, so that it allows the user to modify
the internal list. This adds bt_audio_foreach_capability iterator finction
that can be used instead.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The sys* ops like sys_clear_bit are indirectly included via arch CPU
header. Other stuff like find_msb_set end up included via this header as
well.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
- Account for the added random delay when updating remaining duration
- Re-worked JIT re-scheduling update a bit to keep the random delay
information and remaining duration correct
Signed-off-by: Troels Nilsson <trnn@demant.com>
- Remaining duration is now in us instead of ticks to avoid
overflow when ticks have higher resolution
- First advertising event should not reduce remain duration
Signed-off-by: Troels Nilsson <trnn@demant.com>
Add EVENT_OVERHEAD_START_US to ticks_anchor when enabling
advertising, so the first advertising event is not late due
to calculations for aux packets etc.
Signed-off-by: Troels Nilsson <trnn@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Tune the EVENT_OVERHEAD_START_US for typical usecases on
nRF52833 SoC using the central_gatt_write and
peripheral_gatt_write samples.
Manually run the samples for over 30 mins without any
assertions and use the actual profiled value that would
otherwise be printed on assertion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When ticks_to_expire is in the past, i.e. ticks_to_expire is
0, perform an explicit trigger of ticker worker instead of
setting up the compare which delays the trigger by the
minimum ticks offset margin. The changes reduce latencies
of the O(n) ticker_resolve_collision by upto the minimum
ticks offset margin (3 for nRF SoCs) for each resolution.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When an event's prepare is delayed due to ULL scheduling or
ISR latencies, check and have a verbose assertion that logs
the actual EVENT_OVERHEAD_START_US required.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Conditional compile ticker interfaces like ticker_update
which are not required when individual state or role samples
are build.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the BIG event counter calculation from stored payload
counter. Event latency should not be multiplied by burst
count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing includes and rearrange header includes to be able
to build a full feature set Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
added `audio start_sine` and `audio stop_sine` to start/stop
sending an LC3 encoded sine tone.
This code is heavily inspired from the sine tone implementation
from the unicast_client sample implementation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add printing of the broadcast source advertising address in the
scan callback. Also rename the scan callback to make
it more clear that it is for broadcast scanning.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the PA sync is lost, we clear the received_base so
that once we resync to the PA, we get the BASE again.
This is to make it easier to decode and use the BASE again
if the sync was lost, as the previous BASE may have
been printed a long time before.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In the unicast client, it is possible for the unicast server
to send a notification for ASE when it is in the codec
configured state after a reconnect. In that case, the
unicast client does not have a coupling between the ASE
and the audio stream.
This caused a BT_ERR to trigger, but it is not really an
error, but rather a state that the current unicast client
cannot handle, so the BT_ERR has been replaced with
a BT_WARN.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the stream->conn instead of the iso->acl, as the iso->acl
may already have been free'd by the ISO layer when the
disconnected callback is called.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This patch fixes invalid ASE state transition,
ASE now waits for Receiver Start Ready before
going into Streaming state.
Signed-off-by: Szymon Czapracki <szymon.czapracki@codecoup.pl>
If the CIS was connected before the sink endpoint was
in the enabling state, it never autonousmly went into
the streaming state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_ascs is per connection, so the control point attribute pointer
should not be part of this structure.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The direction is used to identify the list to append the registered
capabilities. There is no need to keep it in the bt_audio_capabilities,
it can be provided as a function parameter instead.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The return check for adding MPL objects in OTS with
bt_ots_obj_add was incorrect, as only negative values
indicate an error, and a positive value returns the ID.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Set the correct number of Ctrl Tx buffers used for the new
implementation, so that the ACK-fifo gets the correct size
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Conditionally compile the legacy control procedure defined
control Tx buffers that is not required in the new control
procedure implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The codec->path_id supplied to the capabilities
were not being used for the endpoint codec.
Important note: This only works if there is a single
capability per codec ID per direction. This limitation
is also an existing limitation in the current
implementation of capabilities.c.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixed an issue with syncing to multiple BIS as the broadcast
sink in the shell. Also changed a check in the broadcast
sink implementation from an assert to a `if` to provide
a better way of handling bad input.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds support for handling fragmented advertising data over HCI when
CONFIG_BT_CTLR_ADV_AUX_PDU_LINK is not enabled
- Added support for appending advertising data to ull_adv_aux_hdr_set_clear
and ull_adv_aux_pdu_set_clear via ULL_ADV_PDU_HDR_FIELD_AD_DATA_APPEND
- Updated ll_adv_aux_ad_data_set and ll_adv_aux_sr_data_set to
handle fragmentation ops without CONFIG_BT_CTLR_ADV_AUX_PDU_LINK
Signed-off-by: Troels Nilsson <trnn@demant.com>
Gives the application a two way mapping between array index
and a per_adv_sync object instead of current only per_adv_sync
obj -> index using bt_le_per_adv_sync_get_index.
Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
Show function names for all BT_xx logging levels when BT_DEBUG_LOG is
enabled. This makes it easier to find the problematic lines.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
- Downgrade the warning emitted when we run out of channels.
- Only log a warning when failing to establish channels and the error is
not -ENOMEM.
- Add a debug log message in that case to hint what might've happened.
This should make it less confusing to the average user not aware of the
stack internals.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This is a scary-looking warning for users, and should only really matter to
stack developers. It will eventually show up in the wild for embedded
devices that don't get updated to the latest and greatest.
Reword it to make it clear we are rejecting it, and it doesn't impact the
stack in any way.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This makes it more user-friendly, in case no failed cb has been
registered so this error is printed out of context.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Reword the scary-looking `bt_hci_core; Malformed data` warning to show
where it is originating from.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This fixes GTBS index used in API. The index that is exposed to the
application is 255 in case of GTBS.
The code has been reworked to remove redundant booleans and index that
was kept inside instance.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
By design, adv main set can use to send relay mesh messages
but here adv main set is invoked.
Add in the ended, so, adv main set only can be used when all
relay adv sets busy.
and this way does not cause too much delay for adv main set,
due to local message will process firstly.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Adds feature that deletes the shell CDB node after perfoming a config
client reset of another node.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Remove redundant assertion check, and minor indentation fix
to correct the alignment of function call.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Alters several provisioning related features to allow commands to be
functional with application defined Provisioning properties &
capabilities.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Update the existing ASE EP state checks to be more correct
and aligned with the ASCS specification.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Enable ticker ticks slow window extensions implementation
when broadcaster role is enabled. This feature moves the
primary channel advertising event within the specified
window when overlapping with other roles.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implemented:
-- Combining segments from multiple SDUs in a single PDU for TX
-- Release of PDU based on remaining capacity below threshold
-- Release of any PDUs in production on receiving a timeout for the
upcoming event
-- Release of PDUs in production if source if destroyed
-- Synchronization flag to exclude multiple contexts in ISO-AL
-- New Kconfig BT_CTLR_ISO_TX_SEG_PLAYLOAD_MIN to allow definition of
minimum TX segment size
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Implements:
-- SDU fragments can be buffered in the ISO-AL so that the correct size
of the SDU can be computed such that it can be released for inclusion
in the first fragment's header
-- Changed SDU emit interface to allow the same structure to be used to
buffer as well as release fragments
-- New configuration BT_CTLR_ISO_RX_SDU_BUFFERS to specify the number of
SDU buffers for each sink
(Buffering disabled when BT_CTLR_ISO_RX_SDU_BUFFERS=0)
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Implemented:
-- Storing information required to service HCI_LE_Read_ISO_TX_Sync
request
-- Implemented interface to retrieve information
-- Cleared ISO-AL source and sink state on deallocation
-- Renamed cig_ref_point to grp_ref_point as it serves a common purpose
in both CIS and BIS
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Improvement for IAL/CIS/FRA/PER/BI-01-C & IAL/CIS/FRA/PER/BI-02-C
-- Test appears to fail as the transmitted PDU is packed with less data
than is indicated in the segment headers.
-- Guards were included to verify that sufficient data exists in the PDU
before extracting the segment.
General
-- Updated timestamps in error SDUs to better approximate the expected
timestamps if time information is missing.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
In case a connection update complete event reports an error, the
parameters reported should be the ones active on the connection and not
the ones requested
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Some variables shadow global, which is difficult to handle when
porting to other platforms with shadow warnings turned on.
https://github.com/zephyrproject-rtos/zephyr/pull/50581
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This removes the callbacks from capabilities. The callbacks are used for
unicast server role only, while the capabilities are used for the
broadcast sink role as well. Thus the callbacks can be removed as there
is another bt_audio_unicast_server_cb API that is specific for unicast
server role.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fixes the discovery function that handles GTBS only discovery. The
discovery stops when there is no space left for another instance. The
function has been split to improve the code readability and avoid
unnecessary UUID comparison.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Adds Kconfig option for the Mesh Shell Health server.
The shell implementation of Health Server test commands is
dependent on the user adding and initializing the shell Health
Server instance in their application to make the commands functional.
To prevent any confussion about how these commands work, a Kconfig
option has been added to allow conditional compilation of these
commands. In this way the user must actively enable this feature, making
the conditional requirements more clear.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
LE Write Suggested Default Data Length and LE Set Data Length commands
are suggestions from host and should be validated only as per HCI
specification regarding internal setting of LLCP.
LLCP is allowed to use other values if needed.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
The memory used for Tx buffers and procedure context must
be aligned on a word boundary, otherwise it is possible
to get unaligned memory access
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This change fixes a bug where the second use of shell command `gatt
exchange-mtu` would trigger an assertion failure in the stack. The BT
API `bt_gatt_exchange_mtu` asserts `params->func != NULL`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Fix radio_tmr_start_us to be soft realtime, if the requested
start in microseconds is in the past, setup the next
earliest expiry. This is to prevent radio not being started
and not let the LLL hanging. When setup to receive auxiliary
PDU in LLL scheduling, is_aux_sched is set and if radio does
not start and the window is requested to be pre-empted, then
it is blocked from being preempted due to the is_aux_sched
flag remaining to be set. This stalls the scanning
infinitely until explicit scan disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing is_aux_sched flag being reset before resuming to
scan for new advertising PDU in the same scan window after
having received an earlier primary channel PDU and auxiliary
channel PDU using LLL scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix receiving spurious overlapping ADV_IND and SCAN_IND PDU
when LLL state expects to receive SCAN_RSP PDU. Explicitly
check that these PDUs are not processed when in active
scanning and waiting for SCAN_RSP PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If scan is being disabled, rx could already be enqueued
before coming to ull_scan_aux_rx_flush. Check if node rx is
not the last in the list of received PDUs then add it to the
list, else do not add it to the list to avoid duplicate
report generation, release and probable infinite loop
processing of the list. It is possible that node rx has not
be already added in case of last PDU in the chain, under
this case when scan is being stopped add it to the list
before auxiliary context is flushed.
Add the node rx to aux context list of node rx if not
already added when coming to ull_scan_aux_rx_flush. This is
handling a race condition wherein the last PDU in chain is
received and at the same time scan is being disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix scan aux context leak on Periodic Sync Terminate. On
Periodic Sync Terminate the `is_stop` flag is set to prevent
the ULL from assigning an aux context to the sync context,
but the acquired aux context was neither assigned to sync
context nor was being released back to the aux context pool.
Fixed by releasing the aux context if not assigned to the
sync context when `is_stop` flag is set.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If a device sends an MTU that is bigger than our maximum tx buffer size,
that could cause assertion failures down the line.
This PR limits it to the maximum we support (CONFIG_BT_L2CAP_TX_MTU).
The issue has been observed with a gatt discovery procedure, but is likely
present in other places in att.c.
To reproduce it, we need two zephyr shell devices, with one having a larger
MTU than the other:
- connect
- do data length update to the bigger MTU
- set security to 2, EATT channels get connected
- launch a gatt discovery from the device with the larger MTU
- observe kernel panic on the other device when it attempts to add too much
memory to a net buf.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Log the LE Secure Connection (SC) LTK in a pairing procedure without
bonding when CONFIG_BT_LOG_SNIFFER_INFO is enabled.
Fixes: #50691
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
`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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Add the missing ticker resolution margin when calculating
the ticks_anchor to be used to get non-overlapping BIG
events.
Relates to commit fab4511164 ("Bluetooth: Controller: Fix
overlapping advertising events").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
this changes adv_new_legacy to adv_get_legacy.
without this fix the function would return NULL if BT_EXT_ADV is enabled.
Signed-off-by: Jonas Woerner <jonas.woerner@online.de>
Sharing the same pool for both, local and relayed messages has some
disadwantages. In a high-traffic environment the relayed messages may
occupy the whole pool without letting the node to send own messages,
neither to process segmented messages. The vice versa situation is
possible when local messages takes the whole pool so that the node is
not able to relay other messages. Another thing is that it doesn't let
to controll amount of local and relayed messages that the node can send
at once. Controlling the number of messages that the node can relay may
help to reduce the message latency.
This change adds separate net_buf_pool for the relayed messages that
helps to avoid problems described above.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
If `struct bt_mesh_prov::unprovisioned_beacon` callback is not set,
don't process the beacon.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
For the encryption procedure exists a flag used to indicate that the
procedure expects all PDUs to be delivered to the procedure STM.
This flag was not cleared during creation of new procedure. This could
lead to unexpected PDUs being passed to local procedure STM
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Fix compile error when BT_CTLR_JIT_SCHEDULING is enabled but
BT_CTLR_ADV_EXT is disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When friend entry is cleared by `friend_clear` after an adv buffer has
been sent to that friend in `friend_timeout`, another friend request
coming after this may reuse the same entry. It is possible that
`friend_timeout` will be scheduled twice: once by the friend request
and once by `buf_send_end` of the previously sent buffer.
In that case, the code will assert on line friend.c:1234. It is not
possible to cancel an adv buffer for the friendship that is to be
cleared, therefore, we need to ensure in correctness of the pending_buf
value in start and end callbacks.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When local node enter iv recovery procedure, should clear
replay list at first due to avoid possible wrong replay attack.
At present, `bt_mesh_rpl_clear` schedule a timer to clear rpl,
this would cause local node unable precess mesh message(IV Updated).
Also, in `bt_mesh_rpl_pending_store` also not clear rpl, which check
`BT_MESH_VALID` flag, always valid for iv recovery.
So, Add `rpl_clear_pending` work handler process rpl clear.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The CDB module is a mandatory part of provisioning features in BTM, and
can not be regarded as experimental anymore.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Using the passed address is incorrect since the passed address can be
zero to find the lowest available address.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
According to MshPRFv1.0.1, section 3.10.7, the Provisioner shall only
use reuse addresses of the deleted nodes after IV Index is updated.
This change prevents CDB reusing addresses of the deleted nodes until IV
Index is updated. Due to a high range of the unicast addresses, CDB only
stores the highest deleted address once a node is deleted. This creates
a limitation where allocating a node with the high primary unicast
address and then deleting it will make CDB skip big range of address
until next IV Index update.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
When periodic advertising with chaining is re-enabled after
changing interval or just re-enabled then the chain PDUs
where not duplicated causing the LLL to assert detecting the
presence of aux pointer but no linked chain PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a new command, connect-name, which takes a string
as the single input and uses that to setup a scan filter
and connect to the first device that matches the name.
This command is thus basically shorthand for
bt scan-filter-set <name>
bt scan on
bt scan off
bt connect
bt scan-filter-clear-name
The idea of this command is to not only make it easier
find and connect to devices in a crowded environment,
but also to more easily connect to devices that changes
their advertised address.
The implementation is minimal as it uses existing
shell commands.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
As per BAP_v1.0, Section 5.6.3.1:
If HCI is used when setting up their respective audio data paths,
and if the codec in use resides in the Bluetooth Host of the device
using the LE Setup ISO Data Path command, the Unicast Client and/or
Unicast Server shall:
* Write the LE Setup ISO Data Path command Codec_Configuration_Length
parameter with the value 0x00.
* Write octet 0 (Coding_Format) of the LE Setup ISO Data Path command
Codec_ID parameter with the value 0x03 (Transparent).
We can assume the codec in use resides in the Bluetooth Host default.
Signed-off-by: Hang Fan <fanhang@xiaomi.com>
Refactor to revert back the terminate check condition to
check the connection role first.
Reverts legacy code changed in
commit 8b1d50b981 ("Bluetooth: controller: llcp: fix issue
re. missing ack of terminate ind").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not use lazy value to prioritize ticker with ticks slot
window that yield to other tickers. Primary channel PDUs
use ticks slow window to nudge themself after an
overlapping ticker within the ticks slot window, but such
ticker may be skipped to next interval. At the next
interval if they again overlap with other tickers then
lazy value shall not be used to prioritize but rather
continue to yield again. This is required to avoid BIG
events from being skipped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The timestamp is not part of the SDU, and should
thus not be used to get the maximum SDU size.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix BIG Create implementation from silently failing on
values of RTN and SDU_interval that lead to BIG events that
cannot be acheived when using sequential or interleaved
subevents by the Controller Implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a Kconfig for Advertising Data Chaining in Extended and
Periodic Advertising, permitting AD data lengths of upto
1650 bytes. The implementation is experimental and needs
further testing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_ADV_DATA_LEN_MAX and other Kconfig dependencies,
and clean up the use of PDU_AC_LL_SIZE_MAX which is used to
allocate scratch packet to be atleast able to accommodate
the minimum 31 bytes AD data such that it is sufficient to
transmit and/or receive scan response PDUs when either
broadcaster or observer alone is supported.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit splits out the model related commands from mesh shell to
separate shell modules. The purpose of this alteration is to make model
commands more flexible by letting the application itself define the
model instances.
- Move Health Client commands to separate shell module.
- Move Config Client commands to separate shell module.
- Remove Health Client instance from shell.c.
- Add Health Client instance to mesh_shell test application.
- Add util library for Mesh shell.
- Some refactoring of shell menu layout.
- Update Mesh shell documentation.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Moves shell.c to shell subfolder. Done as a separate step to preserve
diff between previous and new revision of shell.c.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Allow requesting any TX power in SDC via kconfig. This enables easily
setting higher TX values when using a FEM.
Signed-off-by: Timothy Keys <timothy.keys@nordicsemi.no>
- Fix ISO TX data pool corruption due to multiple calls to
tx_cmplt_get, without removing the nodes
- Added missing release of TX node link in case of ISOAL error
Signed-off-by: Morten Priess <mtpr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO Tx PDU memory pool corruption due to duplicate ISO
Tx PDU buffers repeatedly released into the memory pool.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the removal of BIG context association with the
Periodic Advertising context to when the BIG streams are
release and BIG terminate message is generated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The current implementation of provisioning features is dependent on CDB
to compile, which is reflected poorly in the Kconfig options for mesh.
This commit alters the Kconfig options for provisioning to be dependent
on the CDB option to compile.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Added implementation to use the BIS array parameter and
selectively synchronize to subset of multiple Broadcast
Isochronous Streams in a Broadcast Isochronous Group.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix calculation of BIS subevents that was missing num_bis
when calculating the PDU latency.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect conditional compile to disable Controller
advanced scheduling feature which is required for Broadcast
ISO implementation.
Regression in commit 6fe1299c33 ("Bluetooth: controller:
llcp: fix CI tests for new LLCP").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In a Host plus Controller combined build for ISO feature
restrict the maximum ISO Tx PDU size to minimum of 251 bytes
and Host ISO Tx MTU. This will allow controller to use
reduced Tx time (subevent interval).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.
The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.
NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This PR adds a `*_cli_*` infix to the Config Client API to match
the changes in Health Client. The old API is marked as deprecated.
Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
bt_keys_find_addr() is used to find key by both ID and address.
Following checks must continue to compare ID and address as well.
Or, we can compare key references which is faster.
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
Add support for setting a vendor specific data path using
the BAP API, instead of only support the HCI data path.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CC/Codec Configuration in bt_iso_chan_path was
defined as an array of size 0. This meant that the
CC always had to be allocated right after the
bt_iso_chan_path struct.
This does not give a very flexible API, and also makes
it impossible for two bt_iso_chan_path to share the same
CC.
The API is modified so that the CC is simply a pointer
to a an array now.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
`bt_l2cap_chan_send_cb()` overwrote the buffer user data for internal
use. In the case where sending fails, this would be visible for the
caller. If the caller relied on the buffer user data to be unchanged,
this could cause unexpected behavior.
L2CAP tx metadata was also not freed in the error case.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Fix prepare pipeline preempt timeout stop from stopping a
a prevously started timeout for the next in pipeline event.
The preempt timeout started prior for the current event that
has its prepare that is invoked is to be not explicitly
stopped. If there is a next prepare event in pipeline, then
the prior preempt timeout if started will be stopped before
starting the new preempt timeout. Refer to implementation in
preempt_ticker_start().
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation in Periodic Sync LLL abort to use near
fair scheduling to ensure overlapping multiple Periodic
Sync set each get to use the radio and not lead to Sync
Loss.
The implementation is used when overlap in radio event
happens in unreserved time space of the event. An abort
count is maintain in each Periodic Sync instance and is
used to decide whether the current event or the next
event is to be aborted when they overlap.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Kconfig to use minimal time reservation for auxiliary
and sync PDU reception. A peer device could be scheduling
multiple advertising sets in a short duration with small
PDUs hence using the minimal time reservation would avoid
skipping closely scheduled reception of multiple auxiliary
PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit clears cached random address in bt_dev when calling
bt_disable(). This change makes future calls of set_random_address()
function possible with previously used address value, after BLE stack
re-initialization. Without this change no HCI command was sent, see this
condition in set_random_address():
/* Do nothing if we already have the right address */
if (!bt_addr_cmp(addr, &bt_dev.random_addr.a)) {
return 0;
}
Signed-off-by: Adam Augustyn <adam.augustyn@hidglobal.com>
Additional uncontrolled delay for transmitting segack affects throughput
of the segmented messages. Though the best throughput can be achieved
with the smallest allowed values, move them to Kconfig option so that
the segack delay can be controlled by a user.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit replaces API that became deprecated with the release
of nrfx2.9 - see CHANGELOG in zephyrproject-rtos:hal_nordic repository
Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
When AUX_ADV_IND or AUX_CHAIN_IND auxiliary channel PDU scan
radio event overlaps Periodic Sync radio event in unreserved
time space, let the Periodic Sync radio event be aborted so
that the auxiliary channel PDU can be received to generate
Extended Advertising Reports. Added a new Kconfig to enable
this.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Set the location in the init command. Also updates the
available context to the CONTEXT macro value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Normal usage for Bluetooth applications are getting close to or
already overflowing the default BT RX stack size of 1024.
For example:
- Discovery using the fixed ATT channel used 984 bytes.
- Discovery using an enhanced ATT channel used 1048 bytes,
which would lead to stack overflow using the default BT RX thread
stack size.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
When using periodic advertising list and receiving
hci_le_per_adv_sync_established event from controller with
an error code the bt_le_per_adv_sync_term_info would be
incorrectly populated with le_addr and sid. This is because
the current pending advertising sync object is not populated
with any le_addr and sid from bt_le_per_adv_sync_create as
those are not used when option
BT_LE_PER_ADV_SYNC_OPT_USE_PER_ADV_LIST is set.
Instead the bt_le_per_adv_sync_term_info shall be populated
with the le_addr and sid coming in the event from controller.
Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
Re. peripheral phy update procedure: UNKNOWN_RSP from central was not
handled, leading to stall of procedure and subsequent procedure timeout
Proper handle and unit test for case added.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Multiple places we assumed that we could simply just do
sink_stream->iso == chan without checking if sink_stream
was NULL.
This commit fixes that by adding proper NULL checks for that,
as well as additional checks before defaulting to the
source_stream.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The Bluetooth address constants (BT_ADDR[_LE]_ANY, BT_ADDR[_LE]_NONE)
are currently defined as the address of the local anonymous structs
that are initialised to the corresponding address values, and assigning
them to a variable whose scope is greater than that of a function may
end up creating dangling pointers (for instance, as done in the
`bt_conn_get_info` function).
This commit defines the Bluetooth address constants as global constant
variables that are placed in the read-only data section, and modifies
the Bluetooth address constant macros to use the address of these
variables instead.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit adds the `const` qualifier to the `addr` parameter of the
`bt_monitor_new_index` function because this parameter is and should
never be modified within this function.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit adds the `const` qualifier to the `addr` parameter of the
`find_sc_cfg` function because this parameter is and should never be
modified within this function.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Fix regression in overlapping 1M and Coded PHY scan window
by considering rounding margins when checking for same
interval and same window durations.
Relates to commit c14bde45b6 ("Bluetooth: Controller: Fix
overlapping 1M and Coded PHY scannning").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The unicast_client_pacs_avail_ctx_notify_cb had a direction
check that was a leftover copy from the location notification.
However the context notification is always for both sink and
source, and thus does not need any direction checks (in fact
the dir variable was unused).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fixes invalid check, which is redundant in fact as the length
is already checked in ascs_parse_metadata function.
The check be test 'greater than' only, as 'equal' condition is valid.
Moreover this fixes return value from ascs_verify_metadata function.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Swaps response scheme for Fault_test command so that it
aligns with description of the documentation.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
When AD data length of greater than 191 bytes support is
enabled then default to using the back-to-back PDU chaining
feature in the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising and Periodic Advertising's parent
PDU's aux ptr field to contain correct aux offset value to
its chain PDU.
Uninitialized pointer reference to aux ptr in the parent PDU
was used before the pointer reference was returned by the
function adding the aux ptr fields in the parent PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use local variable to update current PDU's Common Extended
Header Format flags instead of updating it directly in the
PDU buffer. This is required to be able to non-destructively
be able to manipulate the PDU's header flags and contents
many time before a final commit of the updated PDU.
In order to calculate overflowed AD data length, PDU is
manipulated couple of times to determine the overflow length
and next to be able to add aux ptr field when chain PDU is
appended.
The changes are now consistent with how Periodic Advertising
PDU's Common Extended Header Format is manipulated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in adding ADI in scan response PDU introduced
in implementation adding support for AD data fragment
operation.
Setting scan response data with ADI failed with too long
data error. This was caused by a bug in calculating the
offset to the overflow length returned back by the call
to set_clear function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds missing feature so that the config client is able to receive
odd number of app index entries.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
The commit is a minor refactor of the common Host and Controller
Kconfig. There were used "default n" that should be avoided.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In case Controller reports to Host insufficient resources to store IQ
samples, according to BT 5.3 Core spec. Vol 4, Part E, sections
7.7.65.21 and 7.7.65.22:
1) packet_status shall be set to BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES
2) sample_count shall be set to zero.
That means there should be no IQ samples stored in IQ report.
HCI implementation stored single IQ sample with value BT_HCI_LE_CTE-
_REPORT_NO_VALID_SAMPLE.
The commit fixes that. No additional memory is added to event buffer
and no IQ sample is stored if sample_count is zero.
Also there is added code that handles situation where ULL provides
IQ report with packet_status indicating valid IQ samples report
but sample_count is zero. In such case Host event stores single IQ
sample with value BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE.
In case of vendor specific counter part of the event the value is
BT_HCI_VS_LE_CTE_REPORT_NO_VALID_SAMPLE.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Bluetooth Controller has a vendor specific extensions that allows it
to send IQ report events with IQ samples that are 8 bits or 16 bits
signed integer. To use that functionality, there is added common
handler of vendor specific events.
Vendor specific events handling is prioritized to be done by user
provided event handler. If that is not available, then Host generic
implementation enters.
Added vendor specific events that are handled by common Host code
are BT_HCI_EVT_VS_LE_CONNECTIONLESS_IQ_REPORT and BT_HCI_EVT_VS_LE-
_CONNECTION_IQ_REPORT.
The only difference between regular IQ report events is size of
IQ samples, hence implementation of IQ report events is changed to
use the same user callback. To avoid differentiation of user callbacks
new member sample_type was added to bt_df_per_adv_sync_iq_samples-
_report. Also sample member is changed to be a union, to allow easy
access to IQ samples without type casting.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add vendor specific IQ samples report that holds IQ data in 16 bits
signed integer format. Thanks to that we preserve complete accuracy of
IQ samples provided by Nordic Direction Finding Extension in Radio
peripheral. That helps to maintain better accuracy of evaluated
angles with use of reported IQ samples.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
We had two bugs:
- we didn't check the subscription, only the fact that the passed chrc can
be subscribed to.
- that check only worked if we passed the chrc descriptor handle, not its
value handle.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This introduces a new option that allows the user to disable the
subscription checking when notifying or indicating.
Some users might have use-cases where they would like to send notifications
or indications without the peer having to go through the subscription
process, as that is allowed by the Bluetooth specification.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
To avoid compilation issues when including tbs.h header file when
CONFIG_BT_TBS_MAX_URI_LENGTH is not set, just pass the URI pointer
instead of an array in bt_tbs_client_call structure.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
If LPN loses Subscription List Add Confirmation it repeats
Subscription List Add frame. Friend doesn't check both
transaction number and presence addresses in the list.
That causes situation when Friend fills the same address
full list.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
With extended advertiser a precision of transmission becomes high.
The first frame is emitted quite quickly. The scanner latency
config option to enable scanner a bit in advance is not sufficient.
Sometimes replays on Friend Poll are lost.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The function will be used to update the RSI value. The returned value
can be later used in advertisement data for set identification. This
removes the need of specific bt_csis_advertise function so that the user
can call the API to generate new RSI once needed (e.g. on RPA change).
This allows the user to manage the advertisement data to fit it's needs.
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
Extended advertising: Disabled (0x00)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x00
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 33
Handle: 0x00
Operation: Complete extended advertising data (0x03)
Fragment preference: Minimize fragmentation (0x01)
Data length: 0x1d
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
Unknown EIR field 0x2e: 16e61d64dc45
Name (complete): audio test shell
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Advertising Data (0x08|0x0037) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7
Advertising handle: 0x00
Advertising random address: 4E:21:29:F8:94:93 (Resolvable)
> HCI Event: Command Complete (0x0e) plen 4
LE Set Advertising Set Random Address (0x08|0x0035) ncmd 1
Status: Success (0x00)
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
Extended advertising: Enabled (0x01)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x00
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
Status: Success (0x00)
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When sending an ATT packet, do not just try to send the first packet in
the queue, but find the first one that can be sent using the channel.
This makes sure that eg. packets that shall be sent on an unenhanced ATT
channel are not blocked by packets that shall be sent on enhanced ATT
channels.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
bt_eatt_connect was documented to return -EINVAL if conn is NULL, but
this was not the case. Instead it lead to undefined behavior.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Disallow trying to send requests or notifications on only EATT channels
if no EATT channels are connected or the link is not encrypted. In these
cases the operation will always fail, so it should not be queued.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
A channel option field has been added to the bt_gatt_*_params structs.
This allows the application to choose wether Unenhanced ATT, Enhanced
ATT, or Any ATT channel shall be used for the
request/command/indication/notification.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
It is frequent to find variable definitions like this:
```c
static const struct device *dev = DEVICE_DT_GET(...)
```
That is, module level variables that are statically initialized with a
device reference. Such value is, in most cases, never changed meaning
the variable can also be declared as const (immutable). This patch
constifies all such cases.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Initialize monitor UART device at compile time so that device pointer
can be constified.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This new option prevents the Host from using Controller-provided
identity roots. This potentially increases privacy.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Move the flagging of `BT_DEV_STORE_ID` to a separate if-statement.
This clarifies the meaning of the code, and paves way for wrapping the
if-statement with the call to `bt_smp_irk_get` in another conditional.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
When registering VOCS callbacks via bt_vcs_client_cb_register
it could fail if the application did not reset the
vocs_cb.discover as that is set internally.
This commit adds a simple check to also allow the
vocs_cb.discover to be the callback VCS expect/want it to be.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When registering AICS callbacks via bt_vcs_client_cb_register
or bt_micp_mic_ctlr_cb_register it could fail if the application
did not reset the aics_cb.discover as that is set internally.
This commit adds a simple check to also allow the
aics_cb.discover to be the callback they expect/want it to be.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
bt_csis_lock would call write_set_lock with `attr` set to
NULL, which was dereferenced to get the bt_csis instance.
This commit modified the functions such that we instead have
common function to handle changes to the lock value, called
from either the GATT write callback function, or the
bt_csis_lock, so that we have a clearer separation of what
the individual functions do.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds client support for switching the active preset along with bsim
tests implementation.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The unicast client would simply reset all existing ISO QoS
when there was a state change to the QoS state (and only
update the stream QoS).
This caused issue with some ISO check later, as well
as wrongly resetting the data path too.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Verify that the HCI ISO data packet is smaller than
the maximum SDU size we support, based on the group
settings.
Since we do not yet support fragmentation we also
verify that the data length is smaller than the
HCI ISO buffer size.
For the ISO peripheral is it not possible to know
the SDU, and we are forced to not send any value larger
than the PDU size.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Per the HCI spec it is not possible to send the
HCI_LE_Create_CIS command while an outstanding request
is pending. To avoid failing the command we can
check and verify if any ISO connections are in the
pending state.
Since multiple ISO channels can be connected
in a single request, the solution implemented was
to iterate over all ISO connections and see if there was
any unicast ISO channels in the connecting state.
It also checks for the encryption pending state, as
we should not start the encryption procedure if we know
that the connect ISO command cannot be completed afterwards.
This adds a new return value to bt_iso_chan_connect,
and decided to properly document the return values the
function can return.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT is defined by default and the
value ranges from 1 to 255.
So, checking if this parameter is defined seems to be redundant
Signed-off-by: Ahmed Moheb <ahmed.moheb@nordicsemi.no>
Swaps response scheme for Fault_get & Fault_clear command so that it
aligns with description of the documentation.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
MCC need to check characteristic properties before subscribe as not all
MCS characteristics support notify.
Signed-off-by: Hang Fan <fanhang@xiaomi.com>
As per ASCS_v1.0
If a client requests a Config QoS operation for an ASE that would
result in more than one (Sink/Source) ASE having identical CIG_ID
and CIS_ID parameter values for that client, the server shall not
accept the Config QoS operation for that ASE.
The server shall send a notification of the ASE Control Point
characteristic to the client, the server shall set the Response_Code
value for that ASE to 0x09 (Invalid Parameter Value), and the server
shall set the Reason value for that ASE to 0x0A
(Invalid_ASE_CIS_Mapping).
Fixes: ASCS/SR/SPE/BI-{15,16}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Currently, if a bluetooth peripheral sends a connection parameter update
request to a Zephyr central while the central is in the process of
disconnecting and has sent a connection terminate command in the same
connection interval, the central will try to reply, resulting in an
error being printed in the console.
This commit adds a check in le_conn_param_update_req that catches this
state before the central considers this request, preventing the unneeded
error being printed.
Fixes#48813
Signed-off-by: Ivan Herrera Olivares <ivan.herreraolivares@uantwerpen.be>
Extended Advertising is no longer experimental, it has been now
extensively tested and is fully qualifiable and usable in production.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The LE Audio related profiles define specific security requirements that
client have to met to gain access to related characteristics. This
introduces internal wrapper API for GATT characteristics and CCC
descriptors to ensure the security.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This makes the server endpoint to store the ASE pointer instead of
handle. This way, there will be no need to "mock" attribute when
notification is sent.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This extends the bt_conn_info with security information. This is needed
by LE Audio profiles to check if security requirements are met.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The bt_conn_get_security and bt_conn_enc_key_size do not
modify the conn thus the parameter can be guarded with const modifier.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Adds flag indicating the pairing that was completed using OOB method.
The flag is needed for checking 128bit entropy pairing required by LE
Audio services.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This fixes crash that happened when client initiated Release operation
on ASE in Idle state. In such case the operation shall be rejected with
Invalid ASE State Machine Response_Code.
Fixes: ASCS/SR/SPE/BI-10-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Setting the new LLCP as default exposed errors in CI tests, which
are fixed here
Note that advanced scheduling needs to be disabled. Work is in
progress for implementing this for the new LLCP
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Per spec, the CCCD doesn't necessarily have to be located immediately after
the characteristic value. This commit fixes that assumption when checking
for subscriptions.
Fixes#48880.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Change increases long workqueue stack size to prevent stack
overflows while processing GATT database hash.
CONFIG_BT_HCI_ECC_STACK_SIZE is removed, because the configured
stack was removed.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Change fixes value returned by db_hash_commit. Returning positive
value leads to settings load failure.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Change introduces authentication callbacks used only for specified
BLE connection. The feature can be used by devices that require
reporting specific bonding capabilities only when pairing using
vendor-specific procedures.
If per-connection authentication callbacks are defined for given
connection, they are used instead of global authentication
callbacks. SMP latches authentication callbacks during the first
access to prevent updating the callbacks while pairing.
Fixes: #38336
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
This fixes state transition to QoS Configured state triggered by
client-initiated Receiver Stop Ready operation on ASE that has no ISO
attached.
Fixes: ASCS/SR/ACP/BV-12-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The def command Indicates that a comment block contains documentation
for a #define macro. This is useful if the comment block documents a
macro not adjacent to it, e.g.
```c
/**
* @def MAX(x,y)
* @brief Computes the maximum of @a x and @a y.
*/
#ifdef XXX
#define MAX(x,y) ...
#endif
```
However, it is not necessary if the comment is adjacent to the
definition, e.g.
```c
/**
* @brief Computes the maximum of @a x and @a y.
*/
#define MAX(x,y) ...
```
This patch removes all unnecessary def entries in-tree.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
If LPN lost Friend node (all Poll attempts didn't succeed)
no reason to send Friend Clear to the Friend node.
This makes LPN powersupply inefficient usage.
During Friend Clear sending LPN rejects any frame from
primary subnetwork.
Specificastion doesn't mandate that LPN would send Friend Clear
if polling didn't succeed.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Fix SMP check of existing local keys when attempting to start security
with required security mode 1 level 4. The logic for checking the
conditions was wrong, leading to a situation where encryption would be
attempted to be started by the central instead of initiating a new
pairing procedure. This would fail when the connection was encrypted and
the connection would be disconnected.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This fixes sending invalid ATT Request Not Supported error code as a
response to Control Point write request.
ATT Request Not Supported error code is used to inform that
"ATT Server does not support the request received from the client",
so it should not be sent in this case.
If the requested opcode is unsupported, ASCS mandates to send ATT
Notification from Control Point with Unsupported opcode Response_Code
only. If the request received from the client is properly formatted,
ATT Write Response can be sent to complete the ATT transaction.
Fixes: ASCS/SR/SPE/BI-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
BT_ERR() should really be reserved for local errors only,
thus BT_WARN() is the right choice whenever a remote peer
sends something invalid that we cleanly handle.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
As per ASCS_v1.0
"A client-initiated ASE Control operation shall be defined as an
invalid length operation if the Number_of_ASEs parameter value is
less than 1".
Fixes: ASCS/SR/SPE/BI-{02,03,04,05,06}-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Clear pointer to the le_adv_recv() stack frame before returning to the
calling function. This fixes a potential compiler warning newer gcc
versions.
zephyr/subsys/bluetooth/host/scan.c: In function ‘le_adv_recv’:
zephyr/subsys/bluetooth/host/scan.c:463:20: error: storing the address
of local variable ‘id_addr’ in ‘*info.addr’ [-Werror=dangling-pointer=]
463 | info->addr = &id_addr;
| ~~~~~~~~~~~^~~~~~~~~~
zephyr/subsys/bluetooth/host/scan.c:439:22: note: ‘id_addr’ declared here
439 | bt_addr_le_t id_addr;
| ^~~~~~~
Fixes#48459
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The prpa cache is now exposed through the ull_filter_lll_prpa_cache_get()
function (as the resolve list already is). This is needed to be
able to reply to AUX_CONNECT_REQ within the required time when
using SW-based RPA resolving
Signed-off-by: Troels Nilsson <trnn@demant.com>
Scanner was disabled after Friend Clear command. LNP didn't have
chance to receive Friend Clear Confirmation command back.
If option BT_MESH_LPN_ESTABLISHMENT is off then scanner is left
disabled and next Friend Offer after Friend Request
cannot be received.
PR fixes this.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Direction finding functionality does antenna switching during CTE
reception in AoA mode and CTE transmission in AoD mode. Antennas are
switched according to user provided antenna switch pattern. If a CTE
length is enough to exhaust all antenna ids in a switch pattern then
Radio should loopback to reference antenna and continue from switching
from it.
Current implementation loops back to wrong antenna due to wrong index
used in GUARD_REF_ANTENNA_PATTERN_IDX. It was set to one instead of
zero. Zero is the index of reference antenna in Host provided antenna
switching pattern array.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Added define PDU_AC_EXT_AD_DATA_LEN_MAX, maximum AD data
length possible in AUX_ADV_IND when all Common Extended
Header Format fields are populuted.
Updated function description to explain the added ADI and
Aux Ptr fields support in updating the auxiliary PDUs.
Remove the redundant CTE info population code unnecessary
for new chain PDU as a result of AD data overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use minimal time reservation for auxiliary and sync PDU
reception. A peer device could be scheduling multiple
advertising sets in a short duration with small PDUs hence
using the minimal time reservation would avoid skipping
closely scheduled reception of multiple auxiliary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor DF implementation to add aux offset in the aux
pointer field of the parent PDU when chain PDU is added
and/or is duplicated when PDU contents are updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to support Extended Scan Response Data
fragment operation of first, intermediate, last, unchanged
and complete data operation using the HCI LE Set Extended
Scan Response Data Command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactor of scan response implementation to rename sr_pdu
to sr_pdu_prev, and aux_pdu to sec_pdu_prev etc.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to support Extended Advertising AD Data
fragment operation of first, intermediate, last, unchanged
and complete AD data operation using the HCI LE Set Extended
Advertising Data Command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename Kconfig BT_CTLR_ADV_PDU_BACK2BACK to
BT_CTLR_ADV_AUX_PDU_BACK2BACK to represent use of
back-to-back for Extended Advertising PDU chaining support
similar to BT_CTLR_ADV_SYNC_PDU_BACK2BACK that is used to
represent the use of back-to-back for Periodic Advertising
PDU chaining support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update ull_adv_sync_pdu_set_clear() to return aux_ptr
reference so that aux_ptr field for chain PDUs can be
pupulated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor PDU chaining implementation to add aux offset in
the aux pointer field in the parent PDU when duplicating
chain PDUs.
By adding the aux offsets in the ULL execution context the
LLL prepare execution in Extended and Periodic Advertising
does not need to have a O(n) while loop in LLL execution
context.
This will reduce CPU use in the highest priority ISR
compared to current implementation where chain PDUs where
duplicated in ULL execution context and aux offset populated
in LLL execution context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Cleanup Periodic Advertising Chain PDUs auxiliary pointer
population, populate the back to back auxiliary pointer
field in thread context. Also, removed an unused code for
filling data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the ull_adv_aux_hdr_set_clear function so that the
caller of the function will enqueue the auxiliary PDU when
enqueuing the primary PDU.
This change is required to support chaining of AD Data where
parent auxiliary PDU will be added with aux ptr fields when
chain PDUs are appended.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Synchronization from being
preempted by an overlapping Auxiliary PDU scan event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix skipped Periodic Advertising Sync radio events due to
increased CPU use during pre-emption in LLL from a Scan
radio event to Periodic Advertising Sync radio event by
increasing EVENT_OVERHEAD_START_US value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to prevent a transmitted CONNECT_REQ PDU from being
aborted mid-air when initiator is using continuous scan
window that do not use time reservation. A different state
or role that overlaps the connection initiation requesting
for an abort should be denied when CONNECT_REQ PDU has been
enqueued for tranmission by the radio.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When directed advertising and continuous scanning are
simultaneously active, and a connection request is received
by the directed advertising state then the connection was
not established due to the done event not being generated.
Done event from the directed advertising state was not
generated because the prepare pipeline only had resume
event which does not get scheduled when there is prepare
event of the continuous scan state.
The fix is to explicitly abort all pending prepare and
resume event in the pipeline for the directed advertising
state when connection request is received.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Nordic Radio Direction Finding Extension provides 12 bits wide IQ
samples. The Bluetooth Core Specification 5.3 Vol 4, Part E sections
7.7.65.21 and 7.7.65.22 limits IQ samples to be 8 bits wide.
There are other way to convert 12 bits IQ samples into Bluetooth Core
specification compliant 8 bits IQ samples than ordinary 4 bits right
shift. If one is sure that samples will never go over 10 bits or 8
bits then, it is allowed to use 2 bits right shift or even 8 least
significant bits of 12 bits IQ samples.
The commit introduces a possibility to choose which approach is used
for IQ samples conversion in HCI layer while Host IQ report events
are created.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Boolean options are not allowed to start with "Enable...".
BT_HCI_VS_FATAL_ERROR started with "Enable..." making some PRs fail due
to compliance checks.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Provide common helper functions to create extended extended Zephyr
Fatal Error functionality in HCI common code.
Use the implementation in hci_rpmsg sample.
The sample didn't provide an information about Controllers assert
or system fatal error to an application code while run with nRF5340
SoC. The goal for hci_rpmsg sample change is to enhance user experience
for conformance testing of the Bluetooth Controller while executed with
nRF5340.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Review rework of the fix to remove the jitter in aux offset
and sync offset values.
Force select BT_TICKER_REMAINDER_GET and BT_TICKER_LAZY_GET
features when Extended Advertising and Periodic Advertising
is supported.
Rename ticks and microsecond offset value struct members
for primary PDU event offset (to auxiliary PDU event).
Converted HAL_TICKER_REMOVE_JITTER and HAL_TICKER_ADD_JITTER
macro to functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use remainder value in scheduling the periodic auxiliary
PDUs and use the ticker next slot get interface with
remainder value to fill the auxiliary offsets with
microsecond precision in the primary channel PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated ticker implementation to return remainder value for
a ticker when enumerating active tickers with time
reservations.
This is required to find offsets and to use the remainder
value to correctly calculate auxiliary offsets to the
microsecond resolution.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix overlapping 1M and Coded PHY scanning that caused idle
radio time when both PHY use same scan interval and sum of
their scan window duration equals the interval.
Implementation now will use continuous scanning and offset
the start of Coded PHY by the window duration of the 1M
scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The initialisation of DLE parameters for the peripheral
was done before the intialisation of the PHY settings.
Since the DLE parameters depend on PHY settings this
can result in incorrect parameters for tx/rx time and
octets
One scenario is where a previous connection set the PHY to
2M or CODED, then when a new connection is established
it uses the same memory-locations for connection settings as the
previous connection, and the (uninitialised) PHY settings will be
set to 2M or CODED, and thus the DLE parameters will be wrong
This PR moves the initialisation of DLE parameters after
that of PHY settings
EBQ tests effected include LL/CON/PER/BV-77-C.
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Now that we properly destroy the tx context in `bt_conn_process_tx`, we
need to make sure the context is really valid.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Symptoms were that a disconnect happening when a buffer was enqueued but
not sent resulted in a meta-data memory leak.
This is problematic because it seemed (as per the OP) that it resulted in
the whole host getting locked up when a device sending long L2CAP packets
was prone to disconnect-reconnect cycles (e.g. in a bad RF environment).
Fixes#47649
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The expression for the condition for using host-based RPA resolution now
simplifies to "Use host-based when we need to resolve more identities
than the controller can handle.".
Proof:
X=((bt_dev.le.rl_entries > 0) && (!bt_dev.le.rl_size ||
bt_dev.le.rl_entries > bt_dev.le.rl_size))
X=(a > 0) && (!b || a > b)
a>=0, b>=0, because they are cardinal / size_t.
If a=0:
// X evaluates to false. (0 > b)=(a > b) also always evaluates to false.
X=false=(0 > b)=(a > b)
If a>0:
X=(!b || a > b)
If b=0: X=true=(a > 0)=(a > b)
If b>0: X=(false || (a > b))=(a > b)
The expression is equivalent with (a > b) for all values of (a,b).
QED.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Mesh Profile Specification errata 11310
Section 4.4.4.1
"This model shall support model publication, as defined in Section
4.2.2 of the Mesh Profile specification and model subscription,
as defined in section 4.2.3 of the Mesh Profile specification."
Signed-off-by: Michal Narajowski <michal.narajowski@codecoup.pl>
The mandatory minimum PDU length conformance test was failing
because the LLCP did update the effective rx/tx times (and
corresponding notification to host).
This was due to a missing test condition.
This PR adds the missing conditions.
Note that with this change the refactored controller code is
similar to the legacy code; relevant code is in ull_conn.c,
in the function event_phy_upd_ind_prep
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Secure Connection Only mode requires use of LE Security mode 1 level 4
which mandates 128 encryption key size.
Defaults in Kconfig are set from top-to-bottom and this resulted in
7 bytes key being forced. What is worse, user cannot override this
from prj.conf file since BT_SMP_MIN_ENC_KEY_SIZE is hidden config
if BT_SMP_SC_ONLY is enabled.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This fixes issue where the ASE state stuck in Releasing state instead of
going to Idle/Codec Configured as test requires.
Looks like there was a race condition possible where the ASE
notification work was run before the stream was detached, so there was
no transition to idle state triggered.
Fixes: ASCS/SR/ACP/BV-24-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The server should not perform Release operation on ASE in Releasing
state. This fixes crash that might happen in ASCS when ACL gets
disconnected while ASE is in Releasing state so that server tries to
dereference NULL stream.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Add support in Bluetooth Host to enable Periodic Advertising
ADI support feature when supported in the Controller to
include ADI in Periodic Advertising AUX_SYNC_IND PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
According Mesh Spec 1.0.1:
Upon receiving and successfully authenticating to
Secure Network beacon for a primary subnet whose
IV Index is 1 or more higher than the current known IV
Index, the node shall set its current IV Index and its
current IV Update procedure state from the values in
this Secure Network beacon.
Look like test_iv_index.c:81
``` C
(bt_mesh_net_iv_update(TEST_IV_IDX + 1, BCN_IV_IN_IDLE));
```
This test case already exists, but the wrong testcase
to test wrong code.
Move `is_iv_recovery` into `bt_mesh_net_iv_update`.
First check whether it is IV recovery, and then carry out
the subsequent IV normal update procedure.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix redundant node rx reservation when receiving Periodic
Advertising Sync chain PDUs. Only the reception of first
pdu in chain, AUX_SYNC_IND PDU, needs extra node rx
reservation to be allocated for generation of incomplete
data status in case of incomplete reception of chain PDUs.
Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix hang on chain PDU allocation by replacing K_FOREVER use
by a timeout. Hang occurs when configured number of
advertising data buffers is low.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
PHY update control procedure has to send a notification towards
Host when the PHY is actually changed, when the instant happens.
Control procedures are handled in a prepare phase of a connection
event, hence notifications are send towards host to early.
The fix for that is to postpone send of a notification.
New state has been introduced to remote requested PHY update
control procedure: RP_PU_STATE_WAIT_INSTANT_ON_AIR.
Also new event has been introduced: RP_PU_EVT_NTF, that is used
to inform the PHY update state machine that notification may
be send.
There are two places where the notification events may be generated
ull_conn_rx, just before first received PDU is send towards Host
or ull_conn_done, in case there were no PDU received.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
If the device was not paired, the conn->le.keys is NULL, so
conn->le.keys will cause NULL pointer dereference.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Starting the pasive scanner so host can resolve addresses
shouldn't be nessesary when the resolving list is empty.
Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
The `name` parameter is redundant, as the `name` and `name-ad` options are
available already as `adv-create` and `adv-param` command parameters.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Change doc of CONFIG_BT_PRIVACY to explicitly say it's needed for both
generating and resolving RPAs.
Disable host-based RPA resolution in `bt_conn_le_create` when
!CONFIG_BT_PRIVACY.
Update doc of `bt_conn_le_create` to document that CONFIG_BT_PRIVACY is
a requirement for resolving RPAs. Also explictly say that this function
will resolve private identities. Also explain the expected effect of
Network Privacy on this function.
Reduce coupling to `bt_le_create_conn_ext` and
`bt_le_create_conn_legacy` in `bt_conn_le_create` by just use
`resp_addr` when it's set, instead of "knowing" when it had been set.
The alternative would be to also update `bt_le_create_conn_ext` and
`bt_le_create_conn_legacy` to have `(IS_ENABLED(CONFIG_BT_PRIVACY) &&
(!bt_dev.le.rl_size || bt_dev.le.rl_entries > bt_dev.le.rl_size))`
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The unicast client will now read the PACS location value
during the discovery procedure, as well as subscribing to
it.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The code in unicast_client.c was guarded by
CONFIG_BT_AUDIO_UNICAST_CLIENT but the file is only
compiled if CONFIG_BT_AUDIO_UNICAST_CLIENT is enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the cache from "cache" to "pac_cache" to avoid
name clashes with local cache variables.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added possibility to enforce that a LE Secure Connection is required
for reading and writing characteristics, i.e. providing a more fine
grained check that allows services that requires secure connection
to co-exists with those that doesn't.
Signed-off-by: Lars Knudsen <larsgk@gmail.com>
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Extend the `vcs init` command with optional parameters to set the
initial VCS state including volume level, mute state and step size.
This is needed to pass qualification test cases listed below:
VCS/SR/CP/BV-01-C,
VCS/SR/CP/BV-02-C,
VCS/SR/CP/BV-02-C,
VCS/SR/CP/BV-04-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Shell command "bt init sync" now correctly enables Bluetooth
synchronously, and "bt init" enables Bluetooth asynchronously.
Fixes#47860.
Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
The sys_snode_t nodes are used internally, and we use the
convention of the "_" prefix to indicate that this is
an internally used value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the broadcast sink to use a list of streams instead
of an array. This removes the requirement that the array
of stream pointers shall be static, and makes the
broadcast sink API and implementation more similar
to the unicast group and broadcast source.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify from array to list. The list approach is easily
implemented as it is used for the unicast groups, and
using the list approach instead of an array does not
require the array to be static.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths
Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
This fixes bt_pacs_context_available so that it gets available
contexts from capabilities that hold the value.
This removes redundant available_context that were held
(and not updated) in pacs.c.
Fixes: HAP/HA/STR/BV-01-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This API now becomes a low-level API, in the sense that it should only be
used if the app developer knows what he is doing and wants to ensure a
ATT_MULTIPLE_HANDLE_VALUE_NTF PDU goes on-air.
For the other 99% of use cases, `bt_gatt_notify` should instead be used, as
it will automatically upgrade to ATT_MULTIPLE_HANDLE_VALUE_NTF when
possible.
One can disable the batching of notifications when using `bt_gatt_notify`
by setting CONFIG_BT_GATT_NOTIFY_MULTIPLE_FLUSH_MS=0 .
This API doesn't support lookup by UUID any more.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
In the case a call to `bt_gatt_notify_cb` gets its attribute data
batched with others to form an ATT_MULTIPLE_HANDLE_VALUE_NTF PDU, the
application developer would still expect one callback per API call.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Sending ATT_MULTIPLE_HANDLE_VALUE_NTF containing only one handle doesn't
seem forbidden by the spec, but peers might find it unexpected.
This change morphs a ATT_MULTIPLE_HANDLE_VALUE_NTF into a
ATT_HANDLE_VALUE_NTF right before sending it, if it detects this
condition.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The intended behavior is that calling `gatt_notify_mult` in a loop will
result in a `BT_ATT_OP_NOTIFY_MULT` containing all the handles and their
data.
What was happening instead is that the caller thread was a lower priority
than the system workqueue, and thus multiple `BT_ATT_OP_NOTIFY_MULT` PDUs
were being sent over the air instead of one.
Submitting the work item with a delay side-steps this particular issue.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
`bt_gatt_unsubscribe` was pending a write to the CCC and then immediately
canceling it.
Fixes#47682 .
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This fixes an issue where IV index stage counting timer is not
started after the node is provisioned. This would have prevented node
from performing IV index updates.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
This change makes the optional procedures in the TBS Client optional
and configurable through Kconfig.
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Mayfly by design uses a memq for storage of its jobs. The memq
requires head and tail to track the content. It is considered
empty is head equals tail.
When memq instance is initialized then there is a new link
instance stored in head and tail, nevertheless the memq is
still empty.
When new job is enqueued to a memq, the inilial link is used
to store the job. New link, provided by enqueue call, is stored
in the tail for future enqueue.
When enqueued job was served and is dequeued, the link it was
assigned to is returned and stored in the job object.
That link will be used in future for call to enqueue.
Now lets consider a situation when we are just after initalization.
Some default initial link is in empty memq. We enqueue and dequeue
a job. After dequeue, the job object stores the initial link object.
The one that was put into the memq during initialization.
Next Bluetooth stack is disabled and enabled again.
The job is enqueued again, but it still stores the initial link
address. After enqueue the memq head points to initial link object,
that stores new job. Tail points to link deliveded by enqueue call,
that is also the initial link object. The memq is considered to be
empty, nevertheless there was a successful enqueue operation.
The issue is casued by lack of re-initialization of a job object
on init. In most cases these objects are static members of some
functions, hence there is no re-initialization after bt_disable
and bt_enable calls.
The problem is fixed by re-initialization of mayfly only once
on bt_enable() call. Then it doesn't matter what links are stored
in dequeued objects and there is no need to re-initialized mayfly
job objects.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The problem is visible after call to bt_disable when there was
a connection. On a next bt_enable call when hc_tx_thread starts
it is possible that the conn_change object internals are not
re-initialized entirely and the function fails during k_poll call.
The commit changes explicit assignment conn_change object to
a k_poll_signal_init that does proper initialization.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
While execution of bt_disable there is missing de-initialization
of per_adv_sync_pool. If there was a sync in progress, (flags set
to BT_PER_ADV_SYNC_SYNCING) before bt_disable, then when the stack
is re-enabled by bt_enable new sync create fails.
The commit fixes the issue by new function that clears flags for
all per_adv_sync_pool entries. The function is executed by bt_disable.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Struct bt_mesh_send_cb.end is called from the mesh advertiser thread.
bt_mesh_reset now requires more stack size, thus can't be called from
the advertiser thread. k_work instance requires less memory than needed
for bt_mesh_reset.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Upon bt_mesh_reset call, all mesh modules has to clear the privisioning
and configuration data. None of the modules store or erase in settings
subsystem immediately, but put this on the mesh settings work. After the
settings work is scheduled, all stored data will be removed and the
device will eventually be unprovisioned. Until then, the device is not
completely unprovisioned, thus calling bt_mesh_prov_enable,
bt_mesh_provision (and bt_mesh_cdb_create) should not be allowed.
Struct bt_mesh_prov has a reset callback stating that after this
callback is called, the device has been reset and can be re-provisioned
again. Also, bt_mesh_reset API description states that after calling
bt_mesh_reset API, the device needs to reenable the provisioning layer
to be provisioned again. But this is not correct since the settings has
to be cleared before the device can be reprovisionined.
This commit makes bt_mesh_reset flush pending settings so that the
device can be reprovisioned immediately and the API will behave as
written in the description.
The same applies to bt_mesh_cdb_clear.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
In the broadcast sink `scan_recv` which is called when we
scan for broadcast source, we now also provide the entire
AD struct to the application.
The reason for this is that the advertising data may
contain other information that is useful for the application
like the broadcaster device name or any other
vendor/application specific data.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify how the ISO channels are allocated for the audio streams,
as well as how the CIG is allocated for the unicast group.
This fixes an issue where the unicast group could not be
fully allocated before _after_ the bt_audio_streams had been
configured by bt_audio_stream_config, thus making it impossible
to create a unicast group before the connections have been established.
This leaves us with 3 basic data types:
1) Streams allocated by the application
2) Endpoints that represent ASEs
3) Audio_iso which is used to couple streams and ISO channels.
The Unicast Group for the unicast client will now have the same
lifetime as the ISO CIG for the central.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add commands to connect to an l2cap channel using Enhanced Credit-based
Flow Control, and to reconfigure it.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
When invoked without parameters, `bt connect` will now attempt to connect
to the last scanned device. Used in conjunction with the RSSI filter, this
makes the connection process somewhat scriptable.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This adds an RSSI cutoff, so any scanned devices that are below the given
value (in dB) will not get printed out. Very useful in noisy environments.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Add two MEDIA_PROXY group type defines corresponding to the MCS ones.
Update the mpl.c to use the newly added names.
The purpose of the exercise is to get a complete set of MEDIA_PROXY
defines, so that the media player can be made fully independent
(define-wise) of the MCS.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the media player to use the MEDIA_PROXY_* defines rather than the
BT_MCS defines. The media player should not know about the MCS (media
control service).
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
If the characteristic is non-writtable, the BT_GATT_CHRC_WRITE property
flag shall be unset. Moreover, threre is no point to set
BT_GATT_PERM_WRITE_ENCRYPT permission flag as well if the attribute has
no `write` callback set anyway.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
When switching from Extended Scanning by Extended
Advertising HCI commands back to Legacy Scanning after a
HCI reset it is required that the coded PHY scanning
context is reset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Scanning Address Resolution that incorrectly
checked for Bit Count Comparison which is not to be checked
when explicit resolution is performed in the Rx ISR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the maximum advertising PDU size time reservation
consider the Advertising Data could be updated from zero to
maximum support size. If maximum time reservation is
disabled then time reservation corresponding to the
Advertising Data present at the time of the start/enable
of Advertising is used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When multiple advertising sets are support then use advanced
scheduling implementation to place multiple auxiliary PDUs
and periodic advertising PDUs in a non-overlapping schedule.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing recv fifo reset on HCI reset. This fix handles a
scenario where in Rx Prio thread has enqueued a node rx, Tx
thread handles HCI Reset Command, and Rx thread wakes up
from call to k_fifo_get to handle invalid node rx. The
changes here ensure Rx thread does not get any invalid node
rx post HCI Reset Command handled in Tx thread.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a new callback to the Bluetooth Extended Advertising callback
structure. It notifies the application that the RPA validity of the
advertising set has timed out. The user can use this callback to
synchronize the advertising payload update with the RPA rotation.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Synced the start of the advertising sets after each RPA rotation
in the Bluetooth identity module.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Instead of rejecting metadata at the BAP layer, we now
expect the higher layer to provide the verification.
The reason for this is that the higher layer may be better
equiped at determining which metadata it supports.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CAP acceptor can now be a set member. This allows
the CAP acceptor to register a CSIS instance and include
it in the CAS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add bt_cap_acceptor_ccid_exist that verifies that CCIDs
from the CAP initiator are valid on the initiator based
on what we have previously discovered.
Verification from MCS is still a TODO.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the CAP acceptor role is enable, ASCS will verify
that the stream context type supplied by the client
matches the PACS available context.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Verify the metadata before copying it. This will allow the
unicast server to verify the data and potentially
reject it without modifying existing metadata.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding the CAP Acceptor role, which is a quite simple
role. The role instantiates the Common Audio Service (CAS)
The role will later be expanded to properly support
the use the Coordinated Set Member role via CSIS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the CONFIG_BT_AUDIO_DEBUG_STREAM_DATA Kconfig option
to better debug bt_audio_stream without drowning the log
in the data being sent.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BT_DEBUG_ISO_DATA so that ISO can easier be debugged
without the logs being drowned in the ISO data being sent
and received (which is typically at a low interval like 10ms).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the same function at discovery complete, whether discovery failed
or succeeded.
Rename the discovery_failure() to discovery_complete(), and use that
also when discovery completes successfully.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The media control client used to subscribe to GMCS characteristics as
the characteristics were discovered, in effect queuing ATT requests.
Since then, the ATT MTU exchange has become automatic, leading to
larger ATT MTUs and more discovered characteristics per ATT response,
which again lead to the client enqueuing more subscriptions and
running out of buffers, with discovery failing as a result.
This commit moves the subscription to GMCS characteristics to a
separate sequence, so that it happens serially after discovery, rather
than in parallel with the discovery.
- Remove separate discovery parameters for the characteristics - they
are no longer needed.
- Add a subscription callback and a couple of subscription functions
The subscription for characteristics for the included OTS has not been
modified. Only two of these are subscribed to, and doing that is
currently not a problem. And I need to better understand the
interaction with OTS and how these subscriptipons are used.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Refactor subscription to get chaining into callback
Move the start of discovery of included services to a separate
function, in preparation for rewriting discovery.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
When bool is typedef'ed to for instance char the cast from 64 bits
is not so good. Now using an explicit 'cast' to true/false
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Implements PDU flow and unittest of CIS Create on Peripheral
Hooks CIS Create into the controller and fixes a few minor
things in ull to allow for running with NEW LLCP
Also handles CONFIG based comilation of CIS Create
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Hooks the CIS terminate into the controller and fixes a few minor
things in ull_conn(_iso).c
Also handles CONFIG based comilation of CIS_TERMINATE
also fixes a minor issue in helpers_pdu
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
It is possible to open provisioning link again after being provisioned.
Though this has no immediate consequences, the node shall not open
provisioning after being provisioned.
Reset link.cb so that any following provisioning advs are dropped.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
cmd_pb_adv and cmd_pb_gatt are only used when provisionee role is
supported. They should not be compiled if provisionee role is disabled.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
llcp_tx_pause_data() calls ull_tx_q_pause_data() for each pause_mask,
while llcp_tx_resume_data() only calls ull_tx_q_resume_data() when
conn->llcp.tx_q_pause_data_mask == 0 leading to an unbalanced number of
calls to ull_tx_q_pause_data()/ull_tx_q_resume_data() which can leave
the data path of the TX Q paused.
Fix such that only the first call to llcp_tx_pause_data() will pause the
data path of the TX Q.
Add unit test to verify correct pause/resume behavior.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
The uart_pipe driver is not dependent on any console driver,
however a serial driver is required.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add the state transition from connecting to disconnecting
as a valid transition for ISO. This can occur if a ISO channel
is disconnected before it is fully connected, of if a BIG
or a BIG sync is terminated before established.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is a brief period between the bt_iso_big_create
and when the ISO channels are established. In this state
it should be possible to call bt_audio_broadcast_source_stop
to stop the BIG from being created.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Added sequence number and timestamp to the bt_audio_stream_send
function. This allows an application to better
control the audio transmission, as it can schedule
one or more audio streams to send a buffer in a specific
SDU interval (ensuring that e.g. left and right is sent in
the same SDU interval).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fix removes the Streaming_Audio_Context LTV from the LC3 Codec
helper macro, and subsequently a faulty exposure of this LTV in the
PAC records used.
Signed-off-by: Fredrik Danebjer <fredrik@danebjer.com>
Made it more clear that the disable functionality is to
disable the mute functionality, but and not disabling
the microphone device itself.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename struct bt_micp to bt_mic_ctlr as it is only
used ofr microphone controller now.
This also allow cleanup of the bt_micp struct, thus
removing the common internal micp_internal.h header file
and reducing the size of the implementation by not
using a union of the structs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the existing bt_micp API for the
MICP Microphone Device to be more specific
by adding mic_dev as an infix. This follows
the naming scheme used for the MICP microphone
controller (mic_ctlr).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The AICS functionality is also possible via the bt_aics
API, and this was just a way to ensure that the AICS
instance was part of a MICS.
Removing makes MICP much simpler, and we can expect user
to know the context of a AICS.
This also fixes a few bad/missing guards.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename mics => micp_mic_dev (MICP Microphone Device)
Rename mics_client -> micp_mic_ctlr (MICP Microphone Controller)
This does not change any lines in the code.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the profile abbreviation, MICP, instead of the
service abbreviation, MICS, for the MICP implementation.
The server implementation will use MICP and the client
implementation will use MICP_CLIENT for now, as that will
be updated in a future commit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The syncable callback was called whenever we received the BIGInfo
The BIGInfo is, however, received even while synced (as per the
HCI spec). Add a check to stop calling syncable when synced,
and keep the sink->big value updated based on the ISO states.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This reverts commit f3444ce00b.
The check is not needed anymore, as the EATT channels are available on
encrypted link only.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Core Vol 3, Part G, Section 5.3.2 Channel Requirements states that
"The channel shall be encrypted". It does not mention any additional
security requirements that can be specified bt higher layer profiles.
This enables link encryption requirement for EATT channel.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The CSIS SIRK should only require encryption,
as mandated by the CSIS spec, and authentication.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
We attempted to simply store the UUID in a local variable
before sending it to bt_gatt_notify_uuid, but evidently
the `bt_uuid` struct does not work that way, and it
ended up giving errors.
Fixed by providing the BT_UUID_PACS_X UUIDs directly as
arguments, instead of storing in a local variable first.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If we change PACS while not connected, notifying the
change, we would warn about notification not being sent
out, however if not connected that is to be expected.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In the current implementation of segmented messages transmission, the
transport layer will put as many segments as it can into the advertiser
buffer. If a long segmented message is transmitted, there is a chance
that an ack will be received before the transport layer finishes sending
the first batch of segments. This will trigger retransmissions of those
segments that are marked as missing in the ack, that are also the
segments that are scheduled (or about to be scheduled), but not sent
out by the advertiser yet. Thus, the receiver may receive already
received segments.
This commit changes 2 things:
- it prevents rescheduling transmission of missing segments upon
reception of ack. Thus, ack doesn't cause segments duplication in the
advertiser buffer;
- it doesn't put all segments to the advertiser buffer. Thus, ack that
acknowledges all segments can immediately stop rescheduling segments as
they are already received;
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The control flow around the irq-lockout used for fetching from
`tx_complete` has been simplified so that there is exactly one
line with irq_unlock that is unconditionally called.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The cast from `sys_snode_t` to `struct bt_conn_tx` assumes `node` is the
first field in `struct bt_conn_tx`. It's better to future-proof this by
using `CONTAINER_OF` to locate `node`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
bt_dev.sent_cmd is unreferenced and assigned NULL within hci_cmd_done().
Calling net_buf_unref() again causes a null pointer dereference
Signed-off-by: Grant Ramsay <grant.ramsay@hotmail.com>
The codec (or rather codec configuration) is now taken from the
previously received BASE. This also means that the BASE (with
the codec configurations) is now also stored statically.
When the application attempts to synk to the broadcaster
the stack will lookup the codec configuration based on the
bis index, as a BASE may have multiple subgroups
with multiple codec configurations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The shell module will now use BT_AUDIO_CONTEXT_TYPE_ANY
instead of BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED as that provides
a more flexible solution.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If CONFIG_BT_PAC_SNK or CONFIG_BT_PAC_SRC was not enabled, the
function would not build due to missing Kconfig
(CONFIG_BT_PACS_SNK_CONTEXT or CONFIG_BT_PACS_SRC_CONTEXT).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The HAS depends on the unicast server, and should be
disabled in the `no_unicast_server` as well as depend
on the CONFIG_BT_AUDIO_UNICAST_SERVER config.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Some functions are only used for the unicast server
but was guarded by CONFIG_BT_AUDIO_UNICAST instead of
CONFIG_BT_AUDIO_UNICAST_SERVER.
Some parts of the unicast-server-only code also had
client specific code that would never be called.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for using PACS and/or capabilities for
the broadcast sink role. PACS and capabilities were
originally only supported for the unicast server
role, so the PACS callbacks were moved their own
struct, as if a device supports both the unicast
server role and the broadcast sink role, it will
only have a single PACS instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the number of CSIS instances on a device is
above 1, then each shall be included by another
service.
This creates a bit of a chicken and egg issue,
as we can't really register the "parant" service
before the CSIS instance has been registered,
and we thus can't verify if the parent service
pointer is actually another primary service on this
device. The best we can do is add the proper
type and a NULL check.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix radio_tmr_start_now from returning delayed start time
under race conditions where the capture time has elapsed but
the compare has triggered at the same time.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This adds sending Active Index notification and Preset Changed
notifications on connection to previously bonded client.
Fixes: HAS/SR/CP/BV-03-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The implementtaion supports dynamic presets i.e. changing it's name,
registration and unregistration of the presets, thus Dynamic Presets
feature flag shall be set.
Fixes: HAS/SR/FEAT/BV-05-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This handles Write Preset Name operation that is used to change the
preset name. This covers as well changing the preset name by server.
Fixes: HAS/SR/CP/BV-04-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
If preset synchronization is not supported, Preset Sync
Not Supported (0x82) shall be sent in error response.
Fixes: HAS/SR/SPE/BI-04-C, HAS/SR/SPE/BI-05-C, HAS/SR/SPE/BI-06-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Send long-running tasks to a dedicated low-priority workqueue.
This shouldn't increase memory usage since by doing this, we get rid of the
ECC processing thread.
This should fix issues like #43811, since the system workqueue runs at a
cooperative priority, and the new dedicated one runs at a pre-emptible
priority.
Fixes#43811
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Workaround for nRF52 anomalies 102, 106, and 107 was applied also for
SoCs that were not affected with those, namely nRF52811 and nRF52840.
Since the side effect of this workaround is reduction of sensitivity,
this was highly undesirable.
This commit uses dedicated functions provided by MDK for checking if
a given anomaly applies to the used SoC (and its actual revision) so
that the workaround is applied only when it is really needed.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The change in this commit is required to avoid regression errors
on EBQ test for the PHY update procedure
When in the peripheral role transmission of data must be resumed
while waiting for the PHY IND response from peer.
In other words: in the LP_PU_STATE_WAIT_TX_ACK_PHY_REQ state
data transmission must resume when acting as peripheral,
but not when in the central role
Following tests are effected
LL/CON/PER/BV-49-C
LL/CON/PER/BV-50-C
LL/CON/PER/BV-52-C
LL/CON/PER/BV-53-C
LL/CON/PER/BV-54-C
LL/CON/PER/BV-55-C
LL/CON/PER/BV-56-C
LL/CON/PER/BV-58-C
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
This PR fixes the PHY update procedures for conformance tests when
being a Central
The problem was that data was in the LLL tx queue and was still being
queued before the PHY IND was queued (with a given instant).
As a result by the time the PHY IND was transmitted over the air the
instant was in the past.
The fix is to ensure that the LLL tx queue is empty, and to stop
queueing new data before queueing the PHY IND
Following tests are fixed:
LL/CON/CEN/BV-49-C
LL/CON/CEN/BV-50-C
LL/CON/CEN/BV-53-C
LL/CON/CEN/BV-54-C
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The BT_CODEC_LC3_CONFIG_* macros had a hardcoded location
and context, which makes them a lot less usable.
Updates the macro, and the macros that used them.
This also removes the BT_CODEC_LC3_CONFIG and instead
just uses the BT_CODEC_LC3_CONFIG_N macro, which has
then been renamed to BT_CODEC_LC3_CONFIG.
As an addition, the macros and their input has
also been better documented.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Complete the remote initiated version exchange if a LL_VERSION_IND is
received while already having responded in an earlier version exchange
procedure.
Clarify comment regarding how to handle this invalid behaviour.
This has been seen when running the LL/CON/CEN/BI-12-C test on EBQ.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Calculation of the DLE related parameters (rx/tx octets and time) depend
on the actual phy in use. For this reason the PHY settings must be
initialised before doing the DLE parameter calculations
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
On remote terminate on central the conn clean-up would happen before ack
of terminate ind was sent to peer.
Now clean-up is 'postponed' until subsequent event.
Also now data tx is paused on rx of terminate ind to ensure no data is
tx'ed after rx of terminate ind
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
On disconnect with refactored LLCP, if data tx is paused,
possibly 'waiting' tx nodes would not get released.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Only apply change to effective DLE times if current max times are too
small to accommodate. Similar to legacy implementation
Update unit tests to new DLE ntf behavior
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
pb gatt server starts fast advertising for the first 60 seconds.
After that, server goes into slow mode.
When pb gatt and pb adv work in parallel pd gatt changes fast to
slow modes after the first tx frame in pd adv (about 110ms)
since they both are handled in the same thread.
Actually, pb gatt never worked in fast mode
if pb adv was enabled (in most configuration cases).
Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
Renaming objects which had 2 in the name to indicate that
it is v2 specific. Once logging v1 has been removed such
suffixes are redundant.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The iso_rx_qos is only used for unicast audio, as
we do not set the RX QOS for the broadcast sink, nor
can a broadcast source set RX QOS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
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>
`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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
`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>
The open source controller did not expose support for shutting it down
via the close() API in the HCI driver. Add support for it, which
completes the support for disabling and enabling the Bluetooth stack in
Zephyr.
Closes#3192.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Allow the controller to be deinitialized, adding the whole chain of
calls:
- ll_deinit()
- lll_deinit()
- lll_clock_deinit()
in order to be able to turn everything off, including the controller's
refcount of the LF clock.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When bt_disable() was introduced, some of the global variables that
handle key aspects of Bluetooth were not converted to be also
re-initialized every time that the stack was disabled and the enabled
again. This meant that the FIFO and semaphore in the device structure
were not reset whenever the corresponding threads using them were shut
down and then restarted.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The current PHY is read only when automatic PHY
update procedure is enabled, 2M PHY is supported and
extended advertising is enabled and this is done after
application is notified about connection. This leads
to invalid connection info PHY data which always returns
1M PHY because when using extended advertising the connection
can be established on different PHY and host does not read
this value from the controller in most cases. In order to
have a current PHY value updated we need to read it in
connection complete event before the user application
is notified about connection.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
The automatic elevation of security and retry of ATT requests interferes
with some tests that expect authentication failures.
Affecting GATT/CL/GAR/BI-42-C
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
EATT is not a requirement for the Multiple Variable Length Read
procedure, but previously one had to enable CONFIG_BT_EATT to enable
support for it.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This fixes Kconfig that allowed to build PACS without support for sink
or source PACS. Few conditionals that no longer apply were removed.
Enabling ASCS support in specific direction enables related PACS
support.
Since PACS does `depends on` anything, it's safe to make use of `select`
statement.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This renames the UUID to follow the same naming scheme as for
BT_UUID_PACS_SUPPORTED_CONTEXT.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The unicast audio group can not have streams removed after the
CIG has been created as part of the QoS set procedure.
The bt_audio_unicast_group_remove_streams function may
leave the unicast group without streams, and thus the
check for "free" group was not correct, and has been replaced
with a simple boolean value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The unicast client and server will attempt to use a
bidirectional CIS instead of two unidirectional CIS
whenever possible.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the return type of bt_audio_codec_qos_to_iso_qos to
void as it cannot fail, and this will make it easier to use.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add supporting for referercing either a sink endpoint,
a source endpoint or both in the bt_audio_iso struct.
This way a single bt_audio_iso can have references to up
to 2 endpoints.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moves the bt_iso_chan and bt_iso_chan_qos structs
out from the bt_audio_ep struct, and instead use a
reference.
This is due to the fact that an endpoint can ever
only be unidirectional, and a CIS can be bidrectional.
The support for using a single bididrectional CIS
for two audio streams/endpoints is not implemented
in this commit.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the NULL-check for the iso_server to an earlier point.
There's no need to do anything on the device if no iso_server
has been registered.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The "iso connect" now also takes a security level option like
"iso listen", so that the central can easily encrypt
and connect a CIS in a single command.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The ISO security implementation works by verifying
against the acl (bt_conn) sec_level field. The
bt_conn sec_level field is only available
if CONFIG_BT_SMP is enabled, so this commit
adds guards for all ISO security checks as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the required_sec_level is lower than the
conn->sec_level, the central will now initialize the
security procecure to ensure that the CIS is encrypted
properly.
The algorithm implemented is as follows:
1) Check security levels for each (acl, iso) pair
2) For those with insufficient security,
call bt_conn_set_security
3) For those with sufficient security, connect the CIS
4) Once the ISO from 2) has been encrypted, connect the
CIS for the specific ACL
The idea behind this was to implement similar support
for autonomous encryption as we have for L2CAP.
It is more complex for ISO as we are dealing with
an array of (acl, iso) pairs, meaning more can go
wrong.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add check for connection and server security
levels, and reject the CIS if the ACL security
level is too low.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The API is documented as being blocking. Making it nonblocking was an
unintentional API change.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The L2CAP channel ops->sent callback was required to call the
l2cap_chan_sdu_sent callback.
Previously, the only difference between the l2cap_chan_sdu_sent and
l2cap_chan_seg_sent callbacks was that l2cap_chan_sdu_sent called
ops->sent. This is no longer true and l2cap_chan_sdu_sent should always
be called when an SDU is sent.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
error: 'CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH' undeclared (first use
in this function); did you mean
'CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH'?
292 | CONFIG_BT_TBS_MAX_PROVIDER_NAME_LENGTH);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| CONFIG_BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH
etc.
This fixes build errors that were seen while building call control
client without server side (`CONFIG_BT_TBS`) enabled.
The options like BT_TBS_CLIENT_MAX_URI_LENGTH and
BT_TBS_CLIENT_MAX_PROVIDER_NAME_LENGTH have been removed because those
were not used in the code. In fact the client implementation used the
common options for BT_TBS_MAX_URI_LENGTH and
BT_TBS_MAX_PROVIDER_NAME_LENGTH that were moved in this patch to the
common Kconfig section.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The macro was remove for the GATT discover callbacks,
as only 2 out of 5 parameters for
BT_GATT_ATTRIBUTE were used.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix Data Length Request CMD parameter checking to not
restrict invalid maximum Tx time values. This addresses
conformance test cases that provide maximum Tx time values
of 2128 us when not supporting Coded PHY in the Controller
implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The request timer started on the first l2cap channel when doing an MTU
reconfiguration has to be stopped when the response is received. Else the
channel will get into a bad state.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
If there is a PHY change on a connection it may happen that effective
RX and TX time changes also. That change is applied after an instant.
Implemented handling of effective time calculation is based on the
maximum PDU length, new PHY and local (default) maximum TX or RX time.
The maximum TX value is set to default one that corresponds to PHY 1M
during the Controller initialization. It can be updated by host to other
value. By default Zephyr Host updates it to max possible TX time for all
supported PHYs. If PHY CODED is enabled, it is the longest possible TX
duration 17040 us.
The maximum RX value is set to default during connection creation.
In case of use of legacy advertising, the value is also related with
PHY 1M. It can be updated by data length extension procedure.
If the maximum RX value is set to some value and there is a change
of a PHY to one that requires more time to send a PDU with the same
length, then the maximum RX value is wrongly calculated.
Function pu_calc_eff_time returns a value that is the default_time
argument. The problem is that the default_time should be adjusted
to new maximum RX time required for a new PHY.
To solve that there should be an evaluation of a new maximum RX and
TX time based on new PHY.
The commit adds missing evaluation.
The problem occurred in DF tests that check collision mitigation
between PHY update control procedure and CTE request control procedure.
There was missing CONFIG_BT_CTLR_PHY_CODED option in CTE request
unit tests. The code was working because the ULL implementation of
PHY change control procedure does not verify if PHY CODED is supported.
When missing support was enabled, tests showed wrong evaluation of
maximum RX time. It also unveiled error in CTE request unit tests
implementation. The default_tx_time was set to wrong value 2120 us
as if PHY CODED was not supported. To fix it, the value was changed
to PDU_DC_PAYLOAD_TIME_MAX_CODED.
There was also added a mock for a feature exchange procedure done
during unit tests setup step. That allows to correctly calculate
maximum TX time by ull_dle_max_time_get function.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix filter accept list and privacy feature Kconfig default
based on whether host has them enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing BT_CTLR_PRIVACY conditional compilations that
included redundant HAL code when Controller privacy is
disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix PHY update procedure to handle unsupported PHY requested
by peer central device. PHY update complete will not be
generated to Host, connection is maintained on the old
PHY and the Controller will not respond to PDUs received on
the unsupported PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixes issue re. sending packets after sending TERMINATE_IND.
Fixes issue re. erroneous error code on 'timed out' termination (ie
when peer does not ack terminate_ind)
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
On a completion of feature exchange the max DLE times needs to be
updated if Coded PHY has become supported.
For this now also keep a separate store of the default_tx_octets/time
for the sake of re-calculation of local versions of DLE values
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Fix prepare pipeline from not resuming non-resume events
in pipeline when more than one resume events are present
before a non-resume event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Core v5.3, Vol 4, Part E, 7.8.38
Controller has the option to accept or reject when the same device
is added to RL.
If a remote device has been added to RL before, then local device
change it's advertsing address, and the remote device tries to pair
with the new address, we could end up trying to add the same data to RL.
If a remote device's public/static address is known, this patch deletes
the old entry from RL before adding it.
Signed-off-by: Azizah Ibrahim <azizah.ibrahim@nordicsemi.no>
When host issue HCI Reset controller should clear LE Static Random
address. Otherwise controller may incorrectly use one from before
HCI reset insread of rejecting HCI commands.
This was affecting following qualification test cases:
HCI/CCO/BI-51-C
HCI/CCO/BI-53-C
HCI/CCO/BI-54-C
HCI/CCO/BI-56-C
HCI/DDI/BI-06-C
HCI/DDI/BI-07-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
At least one supported PHY bit shall be set and none of
non-supported or RFU bits should be set.
This was affecting HCI/DDI/BI-05-C qualification test case.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Removes label experimental for direction finding feature in
Bluetooth Controller.
The feature stays disabled by default because it requires additional
dedicated hardware to be used. Besides that it significantly enlarges
amount of memory used by the Controller.
End user has to enable the feature explicitly by use of configuration
options.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix preempt timeout scheduling to not skip first prepare in
pipeline when there are no previous preempt timeout
scheduled already.
Fix related to commit 27b8beaa22 ("Bluetooth: Controller:
Fix to handle relative short preempt timeout").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Maximum number of CTE to be send in a periodic advertising chain is
limited by BT 5.3 Vol 4 Part E, section 7.8.80 and is 16.
Maximum number of samples CTE in a periodic advertising chain is
limited by BT 5.3 Vol 4 Part E, section 7.8.82 and is also 16.
Both values are limited by amount of memory reserved in Controller
by Kcofigs, respectfully: CONFIG_BT_CTLR_DF_PER_ADV_CTE_NUM_MAX and
CONFIG_BT_CTLR_DF_PER_SCAN_CTE_NUM_MAX.
Functions ll_df_set_cl_cte_tx_params and ll_df_set_cl_iq_sampling_enable
check limits against Bluetooth specification provided values.
That can end with memory overwrite if number of requested CTEs is
greater that number provided in configuration.
The commit changes mentioned functions to validate HCI commands
parameters against configuration values.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In case there are pending two control procedures: local and remote,
and remote device sends LL_REJECT_IND PDU then assertion happened.
ull_cp_rx function triggers assertion because LL_REJECT_IND is
considered as expected packet for all local and remote control
procedures.
That is not correct. It does not allow local procedure to handle
a response and stops a device on assert.
A remote device should not send LL_REJECT_IND PDU for locally initiated
control procedures, hence local device should not expect to receive
LL_REJECT_IND PDU to be expected one for pending remote control
procedure.
Remote device is allowed to send LL_REJECT_EXT_IND PDU for a locally
initiated control procedures. The LL_REJECT_EXT_IND PDU has a Reject-
Opcode that identifies rejected control procedure, hence is may be
expected by local device.
The commit provides changes that prevent the Controller assertion
in described case.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CCM during on-the-fly decryption of a received packet starts decryption
when Radio triggers EVETNS_ADDRESS. In case there is possibility a
packet may include Constant Tone Extension, on-the-fly parsing of a
received packet for CTEInfo is enabled.
If there is a PHY 1M enabled the Radio stores received bits with a
delay, that is equal to time required to receive 3 bits. CCM TASKS_CRYPT
related with packet decryption should be delayed by the time the Radio
needs to store received data.
The commit provides changes required to delay start of the CCM
TASKS_CRYPT. It uses NRF_RADIO Bit counter feature. The Bit counter is
configured to trigger NRF_RADIO->EVENTS_BCMATCH on reception of 3rd bit.
The event is connected through PPI with CCM TASKS_CRYPT.
The PPI used is shared with Radio Rate override. That is possible because
direction finding feature is not allowed on PHY Coded and CCM needs a delay
only when used PHY 1M.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
lll_conn_rx_pkt_set function is called before one of radio_switch-
_complete_XXX functions calls in lll_peripheral.c. That prevents
lll_conn_rx_pkt to call any Radio setup related function that touches
NRF_RADIO->SHORTS. NRF_RADIO->SHORTS are assigned in radio_switch_-
complete_XXX functions, hence any change operation on the register done
before is overwritten.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add initial support for Periodic Advertising Data fragment
operation support.
This commit is limited to detection of partial data if used
before Periodic Advertising is enabled, which will lead to
HCI error reason of command disallowed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the deprecated BT_WHITELIST Kconfig option. Also,
remove a mention of the deleted bt_conn_create_auto_le API.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When resolving collision if ticks_slot_window is set for
either of the ticker then skip and such ticker be
rescheduled outside the collision within the
ticks_slot_window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
[140/235] Building C object zephyr/subsys/bluetooth/controller/
CMakeFiles/subsys__bluetooth__controller.dir/ll_sw/ull_sched.c.obj
In file included from zephyr/subsys/bluetooth/controller/ll_sw/
ull_sched.c:28:
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:
In function 'lll_adv_pdu_linked_next_get':
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:8:32:
warning: implicit declaration of function 'MROUND'
[-Wimplicit-function-declaration]
8 | #define PDU_ADV_MEM_SIZE MROUND(PDU_AC_LL_HEADER_SIZE + \
| ^~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:12:11:
note: in expansion of macro 'PDU_ADV_MEM_SIZE'
12 | PDU_ADV_MEM_SIZE - \
| ^~~~~~~~~~~~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv_pdu.h:197:9:
note: in expansion of macro 'PDU_ADV_NEXT_PTR'
197 | return PDU_ADV_NEXT_PTR(pdu);
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Rework instant based procedure complete event generation to be
held until after the on-air instant has elapsed, to have
conditional compilation around the code where the event
generation be held or immediately dispatched so that it
improves readability.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix instant based procedure complete event generation to be
held until after the on-air instant has elapsed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The L2CAP channel section is sorted lexicographically. Make sure
that ATT fixed channel will be placed as the last one to ensure
that SMP channel is properly initialized before bt_att_connected
tries to send security request.
Fixes#45820
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
If peer sents invalid value in DLE request or response just ignore
those and keep using old values when calculating effective DLE.
This was affecting following qualification test cases:
LL/CON/PER/BI-10-C
LL/CON/PER/BI-11-C
LL/CON/PER/BI-12-C
LL/CON/CEN/BI-07-C
LL/CON/CEN/BI-08-C
LL/CON/CEN/BI-09-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Terminate connection when Connection Update with instant in the past
Fix type re. win_offset calc in conn update ind pdu decoder
Remove feature bit on unsupported in peer
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Upon collision either the error code for different procedure
collision or same procedure collision must be transmitted,
which is fixed in this PR. Previously always the error code
for same procedure collision was sent
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Add Extended Advertising Type validation when associated
Periodic Advertising is enable, and Extended Advertising
set is re-configured to other advertising types.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There is an error. CTE request control procedure can be run in single
shot or periodic mode. In case of run in single show, it is not
disabled after completion.
The code responsible for the disable was deleted by commit:
ac7d0506f88508e7440288c1ec4319a9f7d0ad44.
The cte_req.is_enabled should be set to zero if the CTE request
completes and cte_req.req_interval is zero.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There was missing code responsible for handling of unexpected response
for CTE request. The commit adds code that will terminate connection
in case a peer device reposnes with unexpected control PDU that is not
a remote procedure reques.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The CTE request procedure should be enabled only if a peer supports
CTE response feature. That information can be obtained by feature
exchange procedure. If there were no feature exchange then CTE
request feature may be disabled if a peer responses with LL_UNKNOWN_RSP
for a CTE request.
The implementation of ll_df_set_conn_cte_req_enable was checking if
CTE response feature is supported only when there was feature exchange.
There was missing possibility to stop CTE request if a peer responded
with LL_UNKNOWN_RSP for an earlier CTE request.
The commit changes the implementation of ll_df_set_conn_cte_req_enable.
The CTE response feature check is moved to ull_cp_cte_req function,
because it belongs more to control procedure than to function that
handles Host request to start the procedure.
Second change is related with use of conn->llcp.fex.features_used.
It stores information about features supported by peer. It does
not depend on execution of the feature exchange control procedure.
By the way, there were removed else statement in ll_df_set_conn_cte_-
req_enable because it was not needed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There was missing handling of LL_UNKNOWN_RSP in CTE request control
procedure.In case there is a pending CTE request and peer responses
with LL_UNKNOWN_RSP then Host should be notified with HCI_LE_CTE_-
Request_Failed event. The pending CTE request procedure should be
completed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix handling of AD Data set with operation type of
unchanged data with respect to invalid parameter and
state of Periodic Advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix nRF51x series advertising channel PDU S1 byte
configuration regression, that causes corrupted advertising
PDUs being reported to Host, by adding the missing bits_s1
local variable initialization.
Regression introduced in commit 1dcbe73cc8 ("Bluetooth:
controller: radio: add setting of S1 byte in radio packet").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Current implementation of ll_sync_create_cancel does not allow to stop
synchronization after ull_sync_setup is called. When that is done,
sync->timeout_reload is not zero and the ll_sync_create_cancel will
return BT_HCI_ERR_CMD_DISALLOWED. That means the Controller is able to
cancel periodic advertising synchronization only in period between
call to ll_sync_create and reception of AUX_ADV_IND that has SyncInfo
field.
The Controller should be able to cancell synchronization until first
AUX_SYNC_IND PDU is received and host notified about synchronization
established.
Complete information about synchronization status is provdied by two
ll_sync_set members: node_rx_sync_established and timeout_reload.
These two members of the structure were used in ll_sync_create_cancel
function to do a proper cancel and cleanup.
The node_rx_sync_established member was not cleared when sync was
established or expired. That was required to get a proper information
about synchronization state.
Besides that, to avoid race condition between ll_sync_create_cancel
and ull_sync_established_report, the latter function was extended
to check if cancel operation or sync lost has happened.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove experimental label from Advertising Extensions and
Periodic Advertising features in the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This PR sets the refactored LLCP as the default instead of legacy
so that more people will use this, giving us more feedback
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Enable HAS shell only if preset support is enabled. Otherwise there are
no functions yet that can be exposed if the preset support is disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fix unused `ccc_cfg_changed` function warning that shows up when
preset support is disabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Introduce invisible helper symbol that could simplify and make more
readable condiitional code checks.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Update the users of the "write" callback in the
bt_gatt_subscribe_params to use the new "subscribe" callback instead.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Add a "subscribe" callback in the bt_gatt_subscribe params, and
deprecate the "write" callback.
The purpose of this is to be able to return the subscription
parameters in the callback. The write callback
- (in principle) returns write parameters
- in fact returns nothing - the pointer is set to NULL
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Direction finding functionality does antenna switching during CTE
reception in AoA mode and CTE transmission in AoD mode. Antennas are
switched according to user provided antenna switch pattern. If a CTE
length is enough to exhaust all antenna ids in a switch pattern then
radio should loopback to reference antenna and continue from switching
from that. Current implementation loops back to antenna that is just
after reference antenna in the switch pattern.
The commit fixes that by insertion of the reference antenna
at the end of switch pattern. Radio will operate as it was before,
it will restart switching from the same index in a switch pattern.
At the same time reference antenna will be inserted into the loop
if switching pattern is exhausted. That also means, the maximum
number of antenna ids in a switch pattern has to be decreased by
one.
The commit also fixes lower bound in the BT_CTLR_DF_MAX_ANT_SW_PATTERN-
_LEN that should be equal two. It was set to three, because in the
past the antenna at index zero was used for reception of a PDU.
Now this antenna ID is provided by device tree configuration.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The SYNC_STAT_READY_OR_CONT_SCAN state into two: SYNC_STAT_READY
and SYNC_STAT_CONT_SCAN. The connected state was used for two
cases:
- synchronization with periodic advertising is already established,
- CTE type is wrong but periodic advertising list is used to filter
synchronized devices.
In the past states were connected because there was only one difference
between them. In case of sync already established, Controller generated
sync report notification to host.The sync was not terminated when
Controller was about to continue search for other periodic advertiser.
The state was split because now Controller terminates sync ticker and
continues search for other periodic advertised. The split improves
readability and makes code easier to understand.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In case of use of filtering based on: periodic advertising list and
CTE type, the synchronization can hang. That is possible if a periodic
advertiser uses wrong CTE type. In such situation the sync is not
released in ull_sync_done call. What more the sync->timeout_reload
is not cleared and Host is not able to cancel the synchronization.
The periodic advertising is in a semi-sync-established state.
There are no reports send to Host. Host can't use the sync set to
synchronize with other device. It is only able to terminate the
sync (call to ll_sync_terminate).
To fix the issue following changes should be applied:
- isr_rx_adv_sync_estab should call isr_rx_done_cleanup
with sync_term parameter in case the sync_ok isn't SYNC_STAT_ALLOWED.
In any case the CTE type is wrong, no matter is the periodic
advertising list filtering is enabled or not.
- ull_sync_established_report should set sync->is_term to true
in case the CTE type is not allowed. That change is required for devices
that do not support Direction Finding Extension. For those devices CTE
type based filtering is done in ULL by ull_sync_established_report
function. The sync->is_term should be set unconditionally, hence is
moved up in the function.
With these two changes done, ull_sync_done function will execute
sync_ticker_release in case the CTE has wrong type. ULL, depending on
notifications prepared by ull_sync_established_report, will follow up
on sync termination if required.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Modify the function slightly to take a different
argument, and add more debugging to the function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Ensure that we don't attempt to send any data to the
controller if `can_send` is not set, and return an
error code to the application instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Besides checking for the rx/tx pointer, we now also validate
the can_send and can_recv values to ensure that we do
not setup a useless data path.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Set the can_send to true and can_recv to false for broadcaster.
Set the can_send to false and can_recv to true for the sync
receiver.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of relying only on the `tx` and `rx` qos pointers,
we extract further information from the
bt_hci_evt_le_cis_established event to properly determine if we
can actually send or receive data.
This is useful to help determine which data paths to setup,
and whether to reject requests to send.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove call to bt_audio_stream_iso_listen which
calls bt_iso_server_register for the unicast client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bluetooth ISO shell module now supports the newly
added central and peripheral ISO configs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move a few unicast functions around so that we reduce the number
of #if defined guards. No code has changed, but a single
prototype has been added.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add two new Kconfigs: BT_ISO_CENTRAL and BT_ISO_PERIPHERAL
that is used to do central or peripheral only builds,
similar to the BT_CENTRAL or BT_PERIPHERAL Kconfigs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This extends client implementation with Read Presets Request operation
support.
The implementation can maintain up to BT_L2CAP_TX_BUF_COUNT control
point requests so that user could perform/queue another Control Point
Operation if one is ongoing. E.g. preset can be selected from Read Preset
Response notification context or perform multiple operations if EATT
enabled.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The periodic CTE_REQ disable command, requested by Host, may be locked
until connection is dropped due to missing CTE_RSP from peer device.
That is caused by implementation of CTE_REQ disable and CTE_REQ
control procedure handling.
The procedure is marked as active when CTE request was send to peer
device. It is marked as inactive after completion of the procedure.
That caused locking of CTE disable on a semaphore.
The BT 5.3 Core Spec, Vol 4, Part E, section 7.8.85 says the HCI_LE_-
Connection_CTE_Request_Enable should be considered active on a conne-
ction from when Host successfully issues the command with Enable=0x1
until a command is issued with Enable=0x0 or single LLCP CTE request
has finished (CTE_Request_Interval=0x0). Also there is a clarification
from BT SIG that the command with Enable=0x0 does not affect any
initiated LLCP CTE request. That means Controller is allowed to finish
already started procedure and it is not allowed to start new LLCP CTE
request procedure after completion of the command with Enable=0x0.
Taking that into account, there is no need to synchronize ULL and LLL
in regard of disable the LLCP CTE request while the procedure is
pending. Controller is free to complete the procedure or terminate it.
The change removes all code related with cte_req.is_active, disable
callback and waiting of ULL for LLL to finish the LLCP CTE request.
The ULL will complete the HCI_LE_Connection_Request_Enable with
Enable=0x0 immediately. In case the procedure is disabled in before
the response arrives, then further processing of the response is
dropped and the procedure context released.
The context is not released by the code responsible for disable
handling, to have single place where it is done.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There is an error in the condition that checks if new CTE_REQ should
be started after end of connection event. The condition verifies if
counter req_expire is set to zero. Then new CTE_REQ is started
irrespectively to CTE_REQ being disabled.
req_interval is used to store information if the CTE_REQ is:
- periodic, then value doesn't equal zero,
- single shot or disabled, then value equals zero.
The condition should verify if the req_interval is not zero and
req_expire is not zero. The second part of the if condition is
required to avoid starting next CTE_REQ until last one has been
completed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Some of control procedures has set ctx->rx_opcode in rp_comm_tx
function to values that state there is an expected PDU.
This is not always true. In case of procedures that do not expect
any response from remote device, the ctx->rx_opcode should be set
to PDU_DATA_LLCTRL_TYPE_UNUSED.
In the worst cases scenario, when the same control procedure
is executed locally and remotely, correct response PDU may
cause an assertion in ull_cp_rx. It could happen because
of wrong ctx->rx_opcode value. A packet with opcode that is
set in remote and local control procedure context rx_opcode
will be treated as expected value for both. That is a situation
that cannot happen.
The commit changes the assignments of rx_opcode to fix the problem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This commit fixes the build errors for the testcases in
the tests/bluetooth/init folder
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The tests/bluetooth/ctrl_user_ext test fails due to
compilation errors, which are fixed with this PR
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Previous check in the if-statement would never allow to send last
segment if msg->len + 2 == MTU * x.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The audio stream receive callback now contains a
recv_info struct, which contain crucial information
such as timestamps and packet validity.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The values represent an enum, and it makes sense for the
enum values to follow the enum type name, so an
_DIR_ infix was added to the values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The PAC_TYPE_UNUSED would be breaking
enum rules, as it is setting and comparing
a value outside the enum range.
Instead we check if the `dir` field has been
set to SINK or SOURCE.
The reason why this still works, is that
we memset the struct unicast_client_pac
causing `dir` to become 0. This still
does not really follow the rules of enums, but
it is the best we can do without adding another
value to determine if a struct unicast_client_pac
is unused or not, without adding another value to
public enum struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Many functions and struct fields had the directory/type
value, but named in different ways and stored in different ways.
This change updates all uses of it to use the same name
and type.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The enum bt_audio_pac_type does not fully
represent the what the value is used for.
The typical use of it is not for just published
audio capabilities (PAC), but rather describes the
type, or direction, of audio endpoints.
For the unicast client, the type/direction is
relative to the unicast server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The unicast_client_ep_init took a ID value that was
always 0. Moved the initialization to the value to
the function, instead of an argument. The value
is only used for the unicast server, so it can
probably be removed from the endpoint
struct for unicast clients only. To be optimized later.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The endpoint.type field was unused as it was
always LOCAL for the unicast server and always
REMOTE for the unicast client, and the few places
where we actually checked it, we already had a
check for acl->role which gave the same value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The PSM of the first channel in the connection request is used, but the
PSM value is used for all of them on the receiving side.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
There were some errors in the detection of ECRED connection collisions,
so the retry was triggered incorrectly.
The number of channels requested in the retry was wrong in some cases,
using the number of channels from the received request instead of the
sent request.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Strictly restrict AD Data length to BT_CTLR_ADV_DATA_LEN_MAX
when there can be free bytes in Advertising PDU with common
extended header format of less that the maximum 64 bytes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Change bt_audio_broadcast_sink_sync to use an array of pointers
to bt_audio_streams, instead of an array of streams. This makes
the API more flexible, as well consistent with the broadcast
source and unicast APIs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_audio_broadcast_source_create function will now
take an array of stream pointers, instead of an array
of streams. This is to make the API more flexible as
well as more consistent with the unicast API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In bt_audio_unicast_group_create, bt_audio_unicast_group_add_streams
and bt_audio_unicast_group_remove_streams to use an array
of pointers, instead of an array of streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This extends implementation with sending Preset Changed
notification/indication when preset changes its availability or is
added or deleted.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
In a function pu_prepare_instant there is a condition that
checks if there is actual change of a PHY. That condition
was based on ctx->data.pu.tx and ctx->data.pu.rx.
These members store PHY that is or will be used, hence
the condition is wrong. Even there is no actual change in
the PHY, values could be not equal to zero. In such case
the instant value would be set to wrong value.
What more the condition be an 'or' not an 'and' because
one of the values must be different than zero to have the
PHY change and instant different than zero.
After update of the condition, the function call places
must be changed. The ctx->data.pu.c_to_p_phy and
ctx->data.pu.p_to_c_phy are set in pu_prepare_update_ind
function, hence pu_prepare_instant should be called after
that.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
- ISO TX data path for HCI and support for vendor path
- ISO-AL segmentation of framed PDUs
- Insertion of segment headers
- Reconstruction and storing of CIG reference point in ULL
- Calculation and insertion of of Time-Offset
- Exit error spooling in ISO-AL on detecting start
- ISO-AL TX unframed fragmentation
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add implementation to generate node rx for missing ISO PDUs
and set the status as invalid. This is required for ISOAL to
correctly track the sequence numbers for every SDU interval.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Kconfig to limit the Primary Advertising Interval and
Periodic Advertising Interval maximum supported values in
the Controller implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The bt_audio_stream_qos function checked if stream->ep was
NULL before checking if the stream were even valid for this
QoS procedure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When create the CIG for a unicast group, we did not
verify whether stream->iso was NULL before attempting
to use that to create the CIG.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
None of the common DF configs should depend on using BT_LL_SW_SPLIT.
Added dependencies to it where this was the case.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
These configurations are tighlty coupled to the implementation,
so these should be hidden when not using BT_LL_SW_SPLIT.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Some controllers may support only TXing or RXing CTE.
As all DF features are guarded by BT_CTLR_DF, we need to ensure
that it is possible to select those when only TX or RX is available.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This updates the documentation of bt_gatt_is_subscribed function that
can take a bitfield of BT_GATT_CCC_NOTIFY and BT_GATT_CCC_INDICATE.
This might be useful if one wants to test if peer is subscribed, but
does not matter which method was used.
The gatt.c implementation handles API usage already, because it performs
bitwise AND:
if (bt_conn_is_peer_addr_le(conn, cfg->id, &cfg->peer) &&
(ccc_value & ccc->cfg[i].value)) {
return true;
}
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
In case a connection is encrypted received PDU is decrypted by CCM.
CCM does not encrypt/decrypt S1 byte that stores CTEInfo.
In case of reception of a PDU by encrypted connection there is missing
CTEInfo in a memory where CCM stores decrypted PDU.
The CTEInfo data must be copied from scratch packet.
The commit adds code responsible for copying of the CTEInfo into
target PDU memory.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Previously, the att_mtu_updated callback was only called on initial
connection of the channel or during the MTU Exchange procedure. There
was no way for the application to know that the MTU increased in the
case where the peer initiated the reconfiguration.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Bluetooth Host calculated authentication value correctly only
for data smaller than 255 bytes. If data is larger then
authentication transformation used wrong flags.
Since the issue was symmetric two Zephyr
based devices were able to understand each other. Hence,
other devices like Android or IOS smartphones weren't able
to authenticate large frames and broke communication.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
The peripheral is configured to update the connection
parameters for 5 seconds by default.
There is an abnormal situation with a very low probability.
The central actively disconnects or abnormally disconnects the
Bluetooth connection at the same time.
At this time, the connection disconnection event will be
handled by BT RX.
At this time, sysworkq has sent a parameter update request and
will receive a reply with status = 0x02, because the handle is
invalid at this time.
We can not just cancel work, because work->flag may be
in K_WORK_RUNNING, so work->flag is set to K_WORK_CANCELING
and subsequent conn_cleanup will unable call k_work_rescheduler
successfully.
According submit_to_queue_locked will return ret = -EBUSY.
if (flag_test(&work->flags, K_WORK_CANCELING_BIT)) {
/* Disallowed */
ret = -EBUSY;
As a result, the connection cannot be cleanup correctly.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The audio stream should be detached from the endpoint
when the endpoint goes into the releasing state, instead
of the idle state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
ase_process had a check for the IDLE state, but the
check did not do anything, so was removed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The releasing state does not trigger any stream ops,
but will be a no-op case to avoid the error log
message.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Terminate connection with a MIC failure if an unexpected control PDU
is received during the Encryption Start procedure.
Add a greedy option to pdu_is_expected() to make sure the procedure
processes all unexpected control PDU in all cases.
Add unit test inspired by Bluetooth Qualification test
LL/SEC/CEN/BV-14-C,
Central Receiving unexpected PDU during encryption start
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add support for both LL_REJECT_IND and LL_REJECT_EXT_IND when waiting
for the the response to the LL_ENC_REQ and LL_START_ENC_REQ.
Add unit test to test both LL_REJECT_IND and LL_REJECT_EXT_IND as
responses to LL_ENC_REQ.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Chose correct rejection PDU based on features supported on remote peer
when rejecting due to missing LTK.
Update unit test setup with faking that a feature exchange procedure
has run.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Terminate connection with a MIC failure if an unexpected control PDU
is received during the Encryption Start procedure.
Add unit test inspired by Bluetooth Qualification test
LL/SEC/PER/BI-05-C,
Peripheral Receiving unexpected PDU during encryption start
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
This adds suport for validation of received PDUs before they are
pass further to LLCP state machines. If PDU size is invalid it is
rejected with LL_UNKNOWN_RSP.
This was affecting following qualification test cases:
LL/PAC/PER/BI-01-C
LL/PAC/CEN/BI-01-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
When receiving Transaction Start PDU, assure that number of segments
needed to send a Provisioning PDU with TotalLength size is equal to SegN
value provided in the Transaction Start PDU.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Instead of waiting one connection interval, as a result of the state
change, perform the check for instant already on reception of
CONNECTION_UPDATE_IND
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Compile out misc. members not used when Connection Parameter Request
is not supported.
Implement missing tests re. unsupported features in CU/CPR procedure
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Bluetooth Mesh uses tinycrypt library for security related
algorithms. This PR encapsulates tinycrypt dependency within
one file to make the current implementation more portable.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
When a running procedure receives a REJECT or UNKNOWN_RSP PDU that is
not an expected part of the procedure flow this leads to termination
of the connection
This affects procedures:
CU/CPR, CTE, PHY, PING, DLE, FEX, VEX, CHMU
Unit tests are updated to cover the updated behaviour.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Add all information from the ISO established events
and provide the information in the get_info function.
The use cases of each field heavily depends on what
the ISO streams are used for.
Most, if not all, of the field can be used by the
higher layers to improve quality and/or reliability
of e.g. audio streams that use ISO.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is potential buffer overflow in pb adv.
If Transaction Continuation PDU comes before
Transaction Start PDU the last segment number is set to 0xff.
The current implementation has a strictly limited buffer size.
It is possible to receive malformed frame with wrong segment
number. All segments with number 2 and above will be stored
in the memory behind Rx buffer.
Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
Rewrite the entire Procedure Response Timeout mechanism.
Use two separate timers for local and remote initiated procedures.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
As per bluetooth spec Vol. 6 part B section 5.3 we need to terminate
the connection under given situation
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
BT Core spec 5.3 Vol 6, Part B section 2.4.23 LL_PHY_UPDATE_IND says:
"If both the PHY_C_TO_P and PHY_P_TO_C fields are zero then there is no
Instant and the Instant field is reserved for future use."
Fields that are reserved for future shall be filled with zeros.
New LLCPs implementation didn't handle this case and set the instant
as if there were a PHY change. That caused qualification tests to fail.
The commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Previously, if a callback was set for notifications, they would always be
sent over unenhanced ATT.
The nfy_mult_data was bigger than the buffer user_data and we were this
overflowing the buffer when setting the tx callback user_data. Now the
data is stored separately and only a pointer to it is added to the
buffer user_data.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Validate `id` so that `bt_dev.irk[id]` cannot result in an out-of-bounds
access.
This fixes coverity report 239569.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The Tx interval is now calculated at the beginning
of the Tx test and the next transmission is
triggerd by the switch timer instead of event
timer. This fixes a corner case issue when
timer rollover.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
When Host calls HCI_LE_Connection_CTE_Request_Enable with cte type
set to AoD with 1us slots or AoD with 2 us slots, the Controller
verifies if peer device supports Antenna Switching During CTE
Transmission (AoD) feature.
That is wrong because the feature is marked as optional when send
to peer, so it shall be igonerd by remote device.
There are no means to check if peer device supports particular
CTE type, hence the check has to be removed.
The check causes enable CTE REQ procedure to fail after feature
exchange has happened.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The CTE request procedure can be run in periodic and non-periodic mode.
In periodic mode it stays enabled until Host call HCI_LE_Connection_CTE-
_Request_Enable(Enable=0x0).
In non-periodic mode the command is disabled after completion,
LL_CTE_RSP is successfully received.
There is missing disable of the procedure in the current code,
so Host is not able to run the command HCI_LE_Connection_CTE_Request_-
Enable(Enable=0x1) again without explicit call to HCI_LE_Connection_-
CTE_Request_Enable(Enable=0x0).
The commit adds missing code responsible for disable of the procedure.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There is errata clarification (Errata ID:18700)
about subscriptions on fixed group addresses.
It is possible to subscribe models on non primary elements
on any fixed group address except all nodes address.
Devices should be able to receive messages on fixed addresses
even if they do not support the feature
to which the fixed group address belongs.
Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
Increase the default TX stack size for BT_CTLR && BT_LL_SW_SPLIT,
as we have seen applications/samples nearing and even reaching
the stack size, causing stack overflows. This is especially
true if CONFIG_FPU=y which takes 96 bytes of the TX stack.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix assert on LL BIG terminate call before BIG sync is
established. Assert was caused due to duplicate calls to
release stream contexts, once in LL BIG terminate function
then when releasing the HCI BIG sync failed to be
established node rx was being released.
Use iso_broadcast and iso_receive samples, power cycle the
iso_broadcast device when iso_receive sample is waiting for
BIG sync to be established, iso_receive sample will perform
a BIG sync terminate that leads to the assert.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This updates the default proxy filter size to 16. Previous value of 3
is too less for the most practical uses and demos. The default proxy
filter type is accept list type and in this mode proxy server rejects
incoming messages from source addresses not in the accept list. The
addresses are added to the accept list when proxy client sends
messages to unicast addresses or manually adds certain addresses to
the accept list. Once this list is full more addresses cannot be added.
This also updates the default network message cache size to 32. The
network message cache helps in preventing duplicate messages getting
repeatedly relayed and helps in reducing unnecessary network traffic.
Previous value of 10 is quite less for most usecases and makes the
node appear to generate much more traffic in mixed network. The
updated value should suffice for most use cases.
Additional explannation is added in Kconfig to help users understand
the significance of this setting.
These two changes result in 176 bytes of additional RAM usage in mesh
samples.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
The "Database Out Of Sync" error response shall only be sent once on
each channel after a client becomes change-unaware.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
This fixes the case where the client reads the DB hash without reading
another attribute first after becoming change-unaware.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Changes the media_proxy API to pass structs by reference instead of by
value.
Also pass structs by reference in internal functions in media player
and in media controller test.
Add pointer checks to the public API implementation where
user/application code provides structs by reference.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the search parser to not modify the supplied parameter.
This will allow the parameter to be made 'const'.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Commit dc812539b8 ("Bluetooth: MPL: Fix use of uninitialized
command.param value") fixed the use of a potentially un-initialized
variable, by
- splitting a log statement, so that the variable is only
logged (=used) if in use (and therefore hopefully also initialized)
- setting the variable to zero if not in use
The second part is not required, as all other code in the module
checks whether the variable is in use before using it. And this
second part also prevents the parent struct from being made 'const'.
This commits removes the zeroing of the variable, so that the struct
can be made 'const'.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Changes the media control client API to pass structs by reference
instead of by value.
Also change internals of test to pass struct by reference.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the definition of the set extended advertising data command to be
a variable array instead of hardcoded to the maximum length. This
conforms to the definition from the Bluetooth specification and allows
the corresponding code to be slightly cleaner.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Adds a Kconfig option for setting the Config Client and Health Client
timeout. Updates updates the default for Config Client to allow
reception of full sized message from a similar peer device at zero hops.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
This adds initial support for presets that includes API functions
to register/unregister presets and Read Preset Request control point
handler.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
HCI_LE_CTE_Request_Failed may be generated in case received LL_CTE_RSP
PDU didn't contain CTE or if peer rejected the request. HCI function
encode_data_ctrl responsible for dispatching received control PDUs
should not expect a PDU with PDU_DATA_LLCTRL_TYPE_CTE_REQ opcode.
It should never happen. The correct opcode here is PDU_DATA_LLCTRL_TYPE-
_CTE_RSP.
Result of this issue is an assert when LL_CTE_RSP PDU is received
but it does not include CTE.
The commit fixes the problem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In the case that the peer responds with fewer dcid values than the
number of scid values in the connection request, we would assert or read
past the end of the buffer.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
It is possible that LE CoC channel is in disconnecting state (eg due
to peer sending too many packets) but application is not yet aware
of this (ie disconnected callback was not called) and thus may call
bt_l2cap_chan_recv_complete() to return credits. In this case it
leads to assert in l2cap_chan_send_credits.
It looks like PTS 8.2.1 is able to trigger this scenario when
executing L2CAP/ECFC/BI-02-C test.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
PR44014 introduced new pause logic for procedures but PR44297
was merged without being update to use it.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Now refactored Connection Parameter Request procedure supports
parameter checking, and implements reject_ext_ind on invalid parameters
Updates to TODO description for remaining work
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
The event counter value for connection and periodic advertising
events is updated to next value during event preparation (in one
of prepare_cb functions in LLL).
IQ report is prepared after event preparation, so value of event
counter is ahead of the current event value by one, hence it has
to be subtracted.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
HCI_LE_Connectionless_IQ_Report and HCI_LE_Connection_IQ_Report
events has fields that store event counter values: Periodic_Event_-
Counter and Event_Counter, respectively.
Values assigned to this HCI events are taken directly from
lower link layer objects. In case of too slow processing of
HCI events values provided by LLL contexts could be changed before
HCI sends events to Host. That can happen e.g. in case of short
periodic advertising interval and slow UART baudrate.
In such situation event counter values will be corrupted.
To prevent that situation, event counter values connected with
IQ sample reports, has to be stored in node_rx_iq_report when
a report instance is filled in LLL.
This commit introduces required changes.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In order for the code to be more understandable, invert the logic to
decide when to re-trigger the RX work queue and document the approach.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
There is no need to use a k_fifo object to queue the items that are
passed to bt_recv() now that we are using a work queue instead of a
thread, since there is no need for blocking on the actual queue, instead
relying on the fact that work is triggered to know that an item is ready
for processing.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Change CONFIG_BT_RECV_IS_RX_THREAD into a
choice:CONFIG_BT_RECV_CONTEXT with the following options
(names can be discussed further of course):
CONFIG_BT_RECV_BLOCKING
CONFIG_BT_RECV_WORKQ_BT
CONFIG_BT_RECV_WORKQ_SYS
This way users would be able to choose what to run most of
the BLE stack on, they wouldn't be forced to a single model.
We would default to CONFIG_BT_RECV_BLOCKING so that we wouldn't
need to change the system workqueue stack size by default, instead
asking users to do so if they select the CONFIG_BT_RECV_WORKQ_SYS option
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Use shell_print_ctx macro when printing to shall from callbacks.
ctx_shell may not be initialized when callback is called.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix null pointer dereference in Controller when receiving an extended
advertisement and CONFIG_BT_LOG_LEVEL_DBG is enabled.
Signed-off-by: Pieterjan Camerlynck <pieterjan.camerlynck@gmail.com>
This change augments the application object name change notification to
occur prior to the actual name change done by the OTS layer.
Notifying prior to the actual name change makes it possible to inform the
application of the current name of the object as well as the new name.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Add implementation in Controller to set radio high voltage
to enable support for +3dBm Tx Power in nRF53 Series SoCs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add radio_stop interface that will be called on radio event
done. This interface can be in turn used to perform H/w
dependent cleanup for every Radio event done.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Core spec version 5.2 introduced EATT, and multiple ATT channels on one
connection is now possible. The requirements for when a client
becomes change-aware were updated to reflect this.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The CIG was improperly handled by the unicast
client. It attempted to remove the CIG when an ACL
was disconnected, and did not properly use the
cig_reconfigure function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The endpoint will likely be in the idle state when
we first read the ASE state. In that case we have
not yet attached a stream to the endpoint, and
thus should not request the stream to be released when it
is NULL.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds initial support for Hearing Access Service client. The client
performs GATT discovery to find and read HAS related characteristics and
subscribe for characteristic value notifications/indications.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The above mentioned fix attempts to detect the situation when
bt_att_req_alloc() is invoked on the same thread that runs
att_handle_rsp. It attempts to do so by noting the thread that
first ran bt_recv, assuming the same thread will house all calls
to bt_att_req_free. This turns out not to be correct. It is
evident from the call stack provided below that bt_att_req_free
can be called from other threads than the one that runs bt_recv.
Fixes: #43448
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Making sure struct bt_l2cap_chan has absolutely no members related
to dynamic channels.
That way we ensure that there is no overhead for a build where only
fixed channels are used.
It's not enough that the dynamic channel-related members are put behind
ifdefs - they should be completely moved out from the struct definition.
Furthermore, the public l2cap.h header file already has a struct
that's meant to be used for dynamic channels: struct bt_l2cap_le_chan!
However, currently dynamic channel support is a mess - it's a mix
between these two structs. The bt_l2cap_le_chan struct should really
be an extension of the bt_l2cap_chan struct, i.e. the former should
contain as a member the latter.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When an int16_t I or Q value was input to IQ_CONVERT_12_TO_8_BIT
the compiler would not make the correct comparison with
IQ_SAMPLE_STATURATED_16_BIT causing saturated IQ samples never
being found.
Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
This is the opesite of the macros to build codec configurations.
As some information was not up-to-date with the adopted
specification this change also includes alignment of the assigned
numbers in the Generic Audio section.
The codec config macros currently in lc3.h have moved from LC3
codec config parameters in the older specification to generic
codec configuration parameters in the adbpted specification.
This is why these additions have been made in the audio.h API
file rather in lc3.h. It is the expectation that lc3.h will be
merged into audio .h at some point.
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
Add a flag that is set when the timestamp is supplied
by the controller when receiving ISO packets.
Previously we used 0 to indicate this, but a timestamp
value of 0 is a valid value, and should not be used
to indicate that it is not present.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the receive flags in the struct bt_iso_recv_info
to a bitfield instead of a single value. This will allow
us to extend the flags with more options.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix Extended Scan disable and Periodic Synchronization
terminate to cover scenarios where chain PDU reception could
complete while thread context is waiting for the radio event
to be done.
Changes here ensure auxiliary context is not released twice
which is caught as an assertion in flush() when checking for
validity of aux->parent pointer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing return value check when Periodic Synchronization
Auxiliary PDU reception has already been stopped, this can
be due to PDU reception in LLL completing while stop has
been requested.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add additional assertion check in the control path leading
to auxiliary context release to catch regressions that may
lead to duplicate auxiliary context release.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing execution of Tx demux for LOW LAT ULL variant
which caused connection events not being maintained to
transmit the latest Tx Data enqueued while being inside a
connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Changes parsing of input string args to provide error checking.
This is to prevent unintentional command execution on garbage input
strings.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
There was an extra call to llcp_lr_init and llcp_rr_init, which is
removed in this commit
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
llcp_lr_pause()/llcp_rr_pause() only pauses currently pending procedures
in their respective request machines, any future initiations are not
paused, thus they are allowed to run, when the opposite was expected.
Change the procedure pause logic into a global pause on the request
machines them self, this is essence what the per-procedure pause
flag was trying to achieve.
Add new query function llcp_?r_ispaused() to not expose the logic behind
the pause functionality.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Change LLCP TX data pause into using mask to allow for pausing from
multiple different sources - but only once per source
(the underlying TX queue still just has an integer counter).
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
The PHY update procedure may trigger a DLE update in certain
situations
When a limited number of rx buffers is available there may not be
enough for doing the phy update and dle update notifications
at once.
Fixes#41788
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Rewrite ull_cp_rx to handle the following cases:
(1)
Local active procedure
Unexpected local procedure PDU
Remote active procedure
Unexpected remote procedure PDU
=> Invalid Behaviour
(2)
Local active procedure
Unexpected local procedure PDU
Remote active procedure
Expected remote procedure PDU
=> Process PDU in remote procedure
(3)
Local active procedure
Expected local procedure PDU
Remote active procedure
Unexpected remote procedure PDU
=> Process PDU in local procedure
(4)
Local active procedure
Expected local procedure PDU
Remote active procedure
Expected remote procedure PDU
=> This cannot happen
(5)
Local active procedure
Unexpected local procedure PDU
No remote active procedure
=> Process PDU as a new remote request
(6)
Local active procedure
Expected local procedure PDU
No remote active procedure
=> Process PDU in local procedure
(7)
No local active procedure
Remote active procedure
=> Process PDU in remote procedure
(8)
No local active procedure
No remote active procedure
=> Process PDU as a new remote request
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
If the Kconfig BT_EATT_AUTO_CONNECT is enabled (on by default), the
host will try to connect BT_EATT_MAX EATT channels when a connection
to a peer is established.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
bt_eatt_connect may now send multiple credit based connection requests.
Previously it would only send one and thus only allow 5 EATT channels to
be connected.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Fix connectable advertising to not use uninitialized
secondary PHY value to set the max_tx_time and max_rx_time
for a non-extended connectable advertising context.
The symptoms being Data Length Update event being generated
when peer central initiated Data Length Update Procedure
does not change from default 27 byte 328 us values.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Offset the Coded PHY scan window by 1M PHY scan window
duration so that when 1M PHY scan window is less than
scan interval then Coded PHY scan window can utilize the
radio thereafter for its scan window duration. For
example, with 20 ms interval and 10 ms window there can
be 10 ms 1M PHY followed by 10 ms of Coded PHY scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Introduce a timeout to get HCI event buffer when preparing
Extended and Periodic Advertising reports. This will prevent
silent hanging of Controller in case of insuffient Rx buffer
configurations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes Radio Rx when switching back-to-back is
used and device support CTE. For the CTE reception we need to use
PHYEND->DISABLE short instead of END->DISABLE short.
Using NRF_RADIO_SHORTS_PDU_END_DISABLE short handles
both cases.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
Increase the supported maximum simultaneous connection to
250, tested under BabbleSim simulations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update Controller to use uint16_t instead of uint8_t to
allow buffer counts to exceed beyond 255. Also fix pointer
arithmetic from being restricted to uint16_t that prevented
calculating the memory index for large offsets. This will
now allow support for 250 simultaneous connections, limited
by ticker_id type being uint8_t.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Kconfig dependency to disable use of Force MD feature
when using LOW LAT ULL variant of the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
NULL structure fields before releasing memory back to pool.
Add assertion check to prevent NULL pointer dereferencing of
node rx.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Getting rid of TODOs that are fairly straight forward to resolve
* introduce role checks in ENC API
* Remove ASSERT on re-rx of LL_VERSION_IND, ignore instead
* in tests/.../ctrl_chmu: rename variable and initialize initial ch map
* in tests/.../mock_ctrl/util.c: Changing TODO into FYI
* in tests/.../helper_features.h update mask and remove TODO comment
* in ull_llcp_remote.c: re-order cases in proc_with_instant switch
* in ull_conn_upd.c: PARAM REQ only uses REJECT_EXT_IND
* in ull_llcp_common.c: in CENTRAL on rx of LL_MIN_USED_CHANNELS_IND
chose to do nothing re. channel map. Update unit test accordingly
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Instead of selecting appropriate HAS_HW_NRF_* options for particular
nRF SoCs (and simulated nRF52 target), set their values basing on
information from devicetree.
Correct also semantics of those options so that they are set only when
a corresponding DT node is enabled. This allows using them directly in
Kconfig dependencies of Zephyr drivers for nRF peripherals. Update
appropriately these dependencies.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Whenever we disable Bluetooth we need to clear the supported commands
array, because there are several functions that check whether a
controller is ready to receive a particular command by testing a bit on
that bitfield.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to get rid of the duplication of the code that we had until now
in the tree, consolidate the handling of multiple calls to
bt_hci_cmd_send_sync(BT_HCI_OP_LE_RAND, ...) in a single location,
namely in hci_core.
This allows all of the users of this HCI command to use a single
implementation of the iterated sending of the HCI command to fill a
buffer with random bytes.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The `bt_conn_index` simply returns the index
of a `bt_conn` struct. There is no reason why
such a function should not use `const`.
Not using `const` will make other lookup/index
functions that perhaps relies on the bt_conn index
unable to use `const` as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When PHY is set to 1M, due to missed "break" statement of switch/case
the sample_offset will be set to the corresponding values of 2M
which causes improper function of sampling CTE signals.
By adding "break" statement the problem has solved.
Fixes: #44296
Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
The unicast client takes a reference to the ACL, but did
not return the reference when the ACL disconnected, but
rather just reset everything.
Modified to detach the stream, ensuring
a bt_conn_unref on ACL disconnect.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Considering that in most scenarios, bt_rand will not be called
frequently, but the current implementation of tinycrypt will
occupy more than 300 bytes of RAM space. Its existence is to
optimize the frequent call of bt_rand.
Therefore, it is considered to put it into a config
(`BT_HOST_CRYPTO_RANDOM`), when this config has been selected,
will use tinycrypt library for random. Otherwise will call bt random
hci command.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Truncate strings being notified to fit the ATT_MTU, to prevent
notifications from not being delivered due to being too long.
For now uses the minimum ATT_MTU, as the MCS does not yet track
connections.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Allocating a buffer to hold the entire directory listing consumes a very
large sum of memory when a large number of OTS objects are supported.
This implementation minimizes the memory footprint of the directory
listing by only allocating the minimum necessary buffer size to allow
for efficient over the air transfer. The contents of the transferred
buffer are built incrementally and upon request.
The directory listing manipulation upon object creation and deletion can
be removed since the directory listing content is never constructed
until it is requested.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Add the telephone bearer service server implementation.
This support multiple service instances as well as the
generic telephone bearer service, but is still a work in
progress and should be treated as such.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the duplicated pairing_complete, pairing_failed
and bond_deleted informational callbacks from bt_auth.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new callback structure for Bluetooth authentication
This struct is meant to replace the information-only
callbacks in bt_conn_auth_cb. The reason for this is that
due to the nature of bt_conn_auth_cb, it can only be registered
once. To allow mulitple users gain information about pairing
and bond deletions, this new struct is needed.
Samples, tests, etc. are updated to use the new struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The lll_filter is used for rl_filter and fal_filter. Size of bdaddr
must be big enough for the worst case.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Add `ing` to the `BT_ISO_CONNECT` and `BT_ISO_DISCONNECT`
states, so that the name better matches the actual state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add `ing` to the `BT_CONN_CONNECT` and `BT_CONN_DISCONNECT`
states, so that the name better matches the actual state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a state field in struct bt_conn_info that is a simplified
version of the internal state value (bt_conn_state_t).
This should provide an application to better determine the state
of the connection whne calling bt_conn_get_info, in case the
application does not keep track of the state itself.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Conditional compile ISOAL implementation to support ISO
Broadcast only and ISO Receive only application builds.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compile error, compiling the connectionless direction
finding samples, due to missing include file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Synchronization time reservation
updated when enabling/disabling direction finding IQ
sampling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixes errornous arg index for new identity in cmd_node_id.
Fixes errornous arg index for uuid in mod_pub_set.
Fixes errornous arg index for net_idx in hb_pub_set.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Fixes errornous arg index for new identity in cmd_node_id.
Fixes errornous arg index for uuid in mod_pub_set.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Move variables to innermost scope - do not define the variable (and
read the value) until it is clear that the receiving callback exists.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Change return value from calls to player(s) to EINVAL.
These functions are guarded, so that if neither local nor remote
players are supported, the functions will not be accessible.
So no need to return EOPNOTSUPP. If the functions reach these
returns, it will be because the pointer provided does not match any
registered player.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The calls to the players were guarded by "_LOCAL_PLAYER_CONTROL".
This was incorrect for two reasons:
- the second part of each function uses the remote player, not the
local one
- the first part of each function is for local control (only) of the
local player
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This enables automatic MTU exchange for services that require MTU size
bigger than default ATT MTU to operate.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds support for automatic ATT MTU Exchange that will be done right
after the connection has been established.
Fixes: #43946
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This implements Core 5.3 recommendation to skip MTU Exchange procedure
if already performed by peer.
Core 5.3 | Vol 3, Part F 3.4.2.2:
If MTU is exchanged in one direction, that is sufficient for both
directions.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The MTU can be exchange once during the connection by the client.
This ensures the ATT MTU Exchange request will not be sent again.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Move the media control client callbacks into the media proxy instance
struct, as requested in earlier PR review.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
In case the CTE request was executed as a single shot and Controller
successfully received LL_CTE_RSP PDU there was an assertion.
The assertion was caused by not completely prepared notification PDU.
The notification PDU was send towards Host by CTE request handling code
due to an error in lp_comm_complete function. If the CTE request was
single shot it went into wrong if-else statement, despite that the
LL_CTE_RSP was correctly received.
A check if-clause if the procedure is periodic should not affect the
procedure completion. It should affect whether req_expire counter has
to be restored.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
ARRAY_SIZE was recently changed to a size_t instead of
a long. Update the log statement to use correct
string format.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The antenna number returned by controller if antenna switching is not
enabled was zero. That is not compliant with BT 5.3. Core Spec Vol 4.
Part E section 7.8.87. In this situation returned value should be 1.
There is always single antenna available that is responsible for PDU
reception and transmission.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The broadcast sink would continously register the PA sync callbacks,
effectively creating an infinite loop. Fixed by correctly
setting the boolean to prevent this.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the broadcast sink receives a BASE it will now
properly check if the BIS indexes are valid.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Once a broadcast source is stopped, the endpoints
should go into the same state before it was
started (BT_AUDIO_EP_STATE_QOS_CONFIGURED), instead
of idle.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There was a missing break statement for the
BT_AUDIO_EP_STATE_QOS_CONFIGURED state, so the
broadcast source could never go into the streaming state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a (initally hidden) Kconfig option for broadcast source
used to determine the size of the advertisable BASE.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The broadcast sink will now not attempt to decode BASEs with
more subgroups than what the broadcast sink can
actually decode.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the unicast guard for bt_audio_codec_qos_to_iso_qos
and bt_audio_stream_attach as they are also used for
broadcast sink and broadcast source.
Also allow broadcast source to use bt_audio_stream_send.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the Kconfig options for BT_CODEC out of the
BT_AUDIO_UNICAST guard, as these are used for broadcast sink
and broadcast source as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since the default syswork thread priority = `-1`.
`adv_send` will call when controller report advertising
sending completed, due to this process by BT RX task, will
maybe process this before `buf_send`, since, sysworkq will be
used by other place and defer by any place.
Note: secure beacon will be 40ms, and friend and lpn will be 20ms.
This problem is very easy to reproduce, especially in native posix.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When pb-gatt advertising enabled, after extablish connect,
will call `cb->connected` and `cb->adv_send`.
In previous connected also clear `ADV_FLAG_PROXY` flag, but
in `adv_send` will attempt unref null point buffers.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
bt_audio_valid_stream_qos() is used to validate the QoS parameters
set by a client. It did a check of a preferred setting which is
ok to exceed (mandatory in some cases).
This change removes the statement that causes the check to fail,
but keeps the check for debug purposes.
Fixes#43359
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
Fix implementation to be able to establish synchronization
when scan filter accept list is in use and periodic
synchronization needs to be established using specified peer
address or using periodic advertiser list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The CTE request has two parts: transmission of a CTE request and
reception of a CTE request. The outcome of reception of a CTE request
is transmission of CTE response.
In the new_proc_lut table for allowed remotely requested control procedures
the CTE request was quarded by CONFIG_BT_CTLR_DF_CONN_CTE_REQ.
In case of a build where CTE request is not enabled but CTE response is
the receiver part of CTE request should be enabled also.
The entry in the new_proc_lut should be quarded by CONFIG_BT_CTLR_DF_CONN_-
CTE_RSP.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The ARRAY_SIZE macro uses sizeof and thus the return
type should be an unsigned value. size_t is typically
the type used for sizeof and fits well for the
ARRAY_SIZE macro as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a simple boolean check of whether the Bluetooth subsystem has been
enabled. This allows users outside of `subsys/bluetooth` to check
whether they can send HCI commands.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The Kconfig function "dt_node_has_prop" was using label as its
parameter, where other functions use either chosen or path.
The documentation says that the parameter is path, so this patch
makes the function as documentation says and as other functions
in the file.
The additional nodelabel functions were added as counterparts that
are using nodes labels instead of paths.
Signed-off-by: Michał Barnaś <mb@semihalf.com>
Fix scan aux context release when (ULL) ticker scheduling
fails due to overlapping events (example a new scan window)
and aux context being released before scan aux done event is
processed, caused assertion when processing the done event
with corrupt ULL reference count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase the event done max count when supporting Extended
Scanning with Coded PHY support, wherein prepare queue will
hold an extra resume prepare when both 1M and Coded PHY
are enabled in continuous scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We expect the address type to be set to PUBLIC or RANDOM always, even
if the controller reports that it was able to sync to a resolved
addresss.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/44110
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Use ticker yield interface to allow chain PDU reception that
overlaps with currently reserved time for received PDU.
Without the yield ULL scheduling to receive auxiliary PDU
fails to be scheduled using ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing use of EVENT_TICKER_RES_MARGIN_US and receive
chain delay in the calculation of overhead value that
determines if ULL or LLL scheduling to be used to receive
auxiliary PDUs.
Also, fix missing use of EVENT_TICKER_RES_MARGIN_US when
ULL scheduling for reception of auxiliary PDU.
See also commit 544acb9804 ("Bluetooth: controller: Fix
missing EVENT_TICKER_RES_MARGIN_US").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Guard media proxy instance members.
As a consequence, change guarding for functions using remote player
member.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Change the default URL length value to something that can contain the
default URL string.
Increaste the default track title length.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the media proxy to use the new Kconfigs to include/exclude the
various parts of the implementation. This replaces existing guarding
using other Kconfig values.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Add Kconfig file for the media proxy, for high-level media control
configuration.
The media proxy did not have a Kconfig file, it was relying on the
Kconfigs for GATT media control client and server.
The purpose is to unify the media control configurations, to make the
different media control functionalities available separately, and to
separate the high-level media control from the bluetooth media control
server and client.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The media controller internal header file does not need to depend upon
the media proxy header.
Requires one piece of spec info here, but the media player already
needs to adhere to the media control service spec, so situation no
worse than before.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Do not initialize the media control service if it is not configured.
This is a temporary fix, there is an issue to fix this properly:
https://github.com/zephyrproject-rtos/zephyr/issues/42965
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Separate out the Kconfig for the media player.
Also removes some unused MCS configs.
The media player has been using MCS configs, while it should be the
other way around.
Also, this will make it easier to move the media player elsewhere, as
has been discussed.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Use the back-to-back receive of PDU with a
configurable inter frame spacing. This fixes an issue
when nRF53 was able to receive only one Rx PDU and
was not able to switch to next Rx.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
Add Radio interface to perform back-to-back receive of PDU
with a configurable inter frame spacing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This command is used to obtain 'Implementation eXtra Information for Test'
(IXIT) values that are required to proceed with BT qualification tests.
Signed-off-by: Tim Sørensen <tims@demant.com>
With BT_SETTINGS disabled, or when using an indefinite
RPL_STORE_TIMEOUT and not storing the RPL, the device will not be able
to follow the replay protection required by the spec. This adds a
warning about this.
Signed-off-by: Ludvig Samuelsen Jordet <ludvig.jordet@nordicsemi.no>
Fix uninitialized param field when generating incomplete
no more data to come periodic advertising report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix generating periodic advertising reports post sync
terminate under race condition when disabling reporting or
terminating the sync or while performing HCI reset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added BUILD_ASSERT definition to check for safe access to
memory pool allocated memory structure member after the
memory has been released back to mem pool.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This fixes issue where, the ASE went directly to QoS Configured state
when in Releasing state and the ISO link has been disconnected.
To not change the current behavior, the transition from Streaming state
has been unchanged, but rather fixed depending on the ASE direction.
Fixes: #44004
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This reverts commit 6bb75a53d1.
This fixes GATT that was uninitalized when application received
bt_conn_cb->connected callback. As the result, the bt_gatt_is_subscribed
was not working as expected when called from bt_conn_cb->connected.
The _bt_gatt_ccc->cfg_changed callback does not carry information about
the device that subscribed for notifications but rather is says the
app when it should start/stop broadcasting notifications.
This leads to the conclusion that the bt_gatt_ccc->cfg_changed can be
called before bt_conn_cb->connected callback.
Fixes: #42829
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Use menuconfig in order to give a better grouping of HAS related
settings with separate subpage.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
- Implemented ISO-AL TX interface functions for fragmentation of
unframed PDUs
- Implemented ISO-AL source construct and its creation for an input
data path
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Use the received coding scheme when receiving Periodic
Advertising PDUs for correctly calculating the receive
chain delay and on-air PDU time.
Relates to commit 6911e7e1d8 ("Bluetooth: Controller: Use
the received coding scheme when scanning").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the received coding scheme when receiving Extended
Advertising PDUs for correctly calculating the receive
chain delay and on-air PDU time.
Relates to commit 6911e7e1d8 ("Bluetooth: Controller: Use
the received coding scheme when scanning").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compile error when debug pins are enabled for nRF53
Series SoCs.
Regression introduced in commit 743b0583fc ("Bluetooth:
controller: Enable debug pins with TF-M enabled").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing assignment of SID in the Periodic Advertiser
Accept List. This cause advertisers with SID 0 only to be
accepted when using list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Tx Power field in Extended and Periodic Advertising
for chain PDU reception. Tx Power shall be from the
current PDU containing the AD Data, Scan Response Data and
from first PDU of Periodic Advertising Data be used to
prepare the HCI report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The header file radio_df_vendor_hal.h was conditionally copiled in.
There were a dependency on a CONFIG_BT_CTRL_DR. The dependency is
removed because radio_df_vendor_hal.h and radio_df.h hasn't got any
DF related type dependencies. What more it allows to use IS_ENABLED
for code that uses types and functions defined in radio_df.h.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The EVENTS_CTEPRESENT is available when radio peripheral has
direction finding support. The event is set if received
PDU has CTEInfo and there were collected IQ samples during
CTE reception.
The event should be cleared always when other events are cleared.
That guarantees that the event is not set when use of radio for
following activities.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The radio_df_cte_ready function returns state of EVENTS_CTEPRESENT.
The function may not be used in create_iq_report function, because
it is called after lll_isr_rx_status_reset. The lll_isr_rx_status-
_reset clears EVENTS_CTEPRESENT value.
The result of this calls chain is lack of IQ sample report no matter
if the PDU has CTEInfo and radio has collected IQ samples.
To fix the problem, state of EVENTS_CTEPRESENT has to be get when
e.g. rssi_ready is get.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
As Extended Advertising primary PDUs do not use ticker
remainder value for fine scheduling of radio events, do not
use the remainder value for auxiliary PDUs. This fixes the
jitter in the aux_offset value that caused the auxiliary PDU
being observed to be late compared to the aux_offset value
filled in the primary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Core Specification 5.3 clarified security requirements for GATT client
when handling incoming notifications and indications.
Vol 3: Part C: 10.3.2.2:
"...Since the configuration is persistent across a disconnection and
reconnection, the client shall check the security requirements against
the configuration upon a reconnection before processing any indications
or notifications from the server. Any notifications received before
the security requirements are met shall be ignored. Any indications
received before the security requirements are met shall be confirmed
and then discarded. ..."
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This adds bare minimum implementation of Hearing Access Service.
The GATT HAS service contains one Hearing Aid Features mandatory
characteristic.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This adds support for the following Direct Test mode
commands:
- HCI LE Receiver Test [v3]
- HCI LE Transmitter Test [v3]
- HCI LE Transmitter Test [v4]
Those commands set add a possibility to test an CTE
reception and transmission. The HCI LE Transmitter
Test [v4] commands allows also setting a transmit power.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
If peer sends invalid data length in response IUT should fix those
when calculating effective data length.
This was affecting following qualification test cases:
LL/CON/PER/BI-10-C
LL/CON/PER/BI-11-C
LL/CON/PER/BI-12-C
LL/CON/CEN/BI-07-C
LL/CON/CEN/BI-08-C
LL/CON/CEN/BI-09-C
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Using a const-qualified object in a static initializer is implementation
specific in C, and it does not work in GCC 7.
Before this change, `write_appearance` was a pointer object if
CONFIG_BT_DEVICE_APPEARANCE_GATT_WRITABLE was disabled. This change
removes that object in favor of a macro `GAP_APPEARANCE_WRITE_HANDLER`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Avoid pre-empting scan window when extended active scanning.
If a scan request has been transmitted, then avoid being
pre-empted at the end of window when in continuous scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix power amp for transmitting of chain scan response
wherein capture of PDU end timestamp was missing causing
power amplifier from not being enabled for first chain PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The EATT support is optional for BAP. The specification mandates the
minimum MTU supported to be 64 bytes.
As per BAP_v1.0
"The Unicast Server shall support a minimum ATT_MTU of 64 octets for
one Unenhanced ATT bearer, or for at least one Enhanced ATT bearer
if the Unicast Server supports Enhanced ATT bearers."
The same applies for other BAP roles.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fix auxiliary context from being flushed when scanner or
periodic synchronization is stopped, to avoid using the
disable_cb by both. Fixes an assertion when this race
condition happens.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not enqueue NODE_RX_TYPE_RELEASE into Auxiliary context
when stopping scanner, as this type is not to be passed to
HCI processing, which would lead to assertion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix auxiliary context leak on stop, under race condition
where ULL High execution context does not release the
auxiliary context as stop has been requested, and done
has decremented the auxiliary context's reference count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the order of Periodic Synchronize reset during HCI
Reset Command. Perform scan reset last after Periodic
Synchronize reset to avoid resetting the auxiliary
context which may be in use by Periodic Synchronize.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Users will usually not want to browse through these. Therefore it is
better to hide them a bit.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This prevents GATT service selection being selectable when compiling
controller only builds.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
There are no more context defines specific to metadata, the ones
coming from Assigned Numbers shall be used.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Instead of including from nrfx_glue.h a specific Zephyr Bluetooth
controller header file that defines PPI and GPIOTE resources to be
reserved for exclusive use by the controller, include a file with
only a fixed name and expect the chosen Bluetooth controller to
provide the location of this file in include paths. This way, when
a different Bluetooth controller implementation is used downstream,
a different file can be easily pointed to.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This fixes data path configuration that was done for both directions
even if CIS was unidirectional. To ensure the data path shall be
configured, the QoS SDU is checked.
Fixes: #43190
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Rename
BT_CTLR_LLCP_PROC_CTX_BUF_NUM
to
BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM
to match naming scheme of
BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add a separate procedure context pool for remote initiated procedures.
Make it configurable in size by BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM.
Fix all unit tests referring to the amount of free context buffers.
Fixes#41823
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Move the mem_pool structure to the internal header for wider access.
Introduce a mem_pool owner in the proc_ctx, sch that multiple mem_pool
could be used for memory management of proc_ctx, also static 'foreign'
allocated proc_ctx would be supported by this.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Start of the antenna switching and sampling CTE is configured by use
of DFECTRL2 register in Nodric Radio peripheral. As of now the
configuration was set to defaults, so antenna switching has started
immediately after CTE procedure was started (end of CRC).
Sampling was started at the very beginning of a sampling slot.
It should be delayed for at least 125 ns from beginning of sampling
slot and not more than 125 ns to the end of sampling slot. This is a
requirement from BT 5.3 Core specification Vol 6, Part B section 2.5.4
IQ sampling.
Although it seems to me that when samples are taken depends on
implementation and used hardware. Taking that into account
there is provided a set of KConfig options to configure samples
offset for PHY 1M, PHY 2M and sapling slots 1 us and 2us separetely.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
If there is enabled support for ADI in periodic advertising and
periodic advertising uses chained PDUs there is an assert when
periodic advertising is re-enabled.
There is missing a code that will set a chain for PDU with
updated ADI field.
The commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Refactor the PAC location read and write. Instead
of storing the location in the service, the
location is now stored in the application, and
is retrieved by the service via callbacks.
Similarly, if a client writes the location, this
request is being sent to the application.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a sent callback that is used to notify applications
using the audio API when a SDU has been sent over HCI.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Changes ERR to WARN message when relay buffers
run out, as this is not really an error but a
consequence of high traffic.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Whenever a stream is attached to an endpoint, the
stream's operation callbacks will be called for the
unicast server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This patch fixes ISO data path setup that shall be done for enabled
directions only and removes usage of Path ID = 0xFF which is RFU value.
As per Core 5.3 Vol 4, Part E, 7.8.109
"If the Host attempts to set an output data path using a connection handle
that is for an Isochronous Broadcaster, for an input data path on a
Synchronized Receiver, or for a data path for the direction on a
unidirectional CIS where BN is set to 0, the Controller shall return the
error code Command Disallowed (0x0C)."
Fixes: #43190
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The capabilities callback did not provide information about
the type of the endpoint being configured, making it
impossible for the application to determine if it is a
sink or source endpoint.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The unicast client would set the QoS reversed, as the
client should configure it TX parameters for SINK
and RX parameters for source, where it did it the other
way around.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove functions and and macro uses that otherwise
determined the direction of an audio stream, and instead
use the direction (dir) field of the endpoint instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Audio streams as defined by the BAP spec does not
support bidirectional audio streams. This commit
updates the API and implementation to match that.
The use a bidirectional CIS with 2 audio stream will
be added in a future commit.
This removes the _IN_ and _OUT_ and _INOUT_ QOS
values, as well as the direction of the codec QOS
struct.
To keep direction for internal use, the direction
has been added to the endpoint struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BASS client implementation
This is a standalone implementation that
needs to be (heavily) modified for the
broadcast assistant role in the future.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BASS as a standalone service. The service is
used for the scan delegator role, which has not been
fully implemented yet.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make it consistent for audio.h and capabilities.h that the
array size parameter appear after the array parameter.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Check if the CTE was discovered by Radio peripheral should be
done with use of CTEPRESENT event. Samples count should not
be used for that purpose. If samples count is a value different
than zero for PDUs that don't have CTE, unwanted IQ samples
report will be generated. CTEPRESENT event is set only in case the
CTEInfo filed was correctly parsed by Radio peripheral during
PDU reception.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Don't replace destination of segmented message when acknowledgement is
received from a friend node, otherwise, when segments are retransmitted,
the destination will be used and the friend node will treat it as a new
segmented message.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
BT_ATT_OP_READ_MULT_VL_REQ, BT_ATT_OP_READ_MULT_VL_RSP, and
BT_ATT_OP_NOTIFY_MULT were missing.
Because of this, multiple variable length reads did not time out.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Heartbeat publication sent callback can be used
as a watch mechanism to determine whether
the mesh stack is still capable of sending messages or not.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Fixes#42306
Attach bt_att_chan objects to bt_att when creating them so that the
check in att_chan_new() works. Use the flag ATT_CONNECTED to signal that
a channel is connected instead of attaching it.
The flag ATT_DISCONNECTED was not set anywhere and is replaced by
ATT_CONNECTED.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Add `remaining_size` in struct ad_stream.
By calculating the actual space required instead of
using the maximum space.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:
sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Fix Extended Advertising implementation to setup Power
Amplifier (PA) GPIO toggle for transmission instead of
incorrect Low Noise Amplifier (LNA) setup which is for
reception.
Relates to commit 4e5290948e ("Bluetooth: Controller: Fix
Periodic Advertising to setup Power Amp").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not implicitly allocate Rx buffers for maximum chain PDU
reception. Instead let applications increase as required the
Kconfig CONFIG_BT_CTLR_RX_BUFFERS.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The LE Audio clients will now do more and proper cleanup
during disconnects. Furthermore, the will also
take a proper bt_conn_ref when the conn pointer
is assigned locally.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix missing configure of Device Address Matching when
receiving auxiliary PDUs.
This fixes some privacy related conformance test cases.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing RPA timer start in Broadcaster only controller
builds.
Without the fix private resolvable addresses where not
updated at RPA timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to update private resolvable
address in auxiliary PDUs on RPA timeout.
Without the implementation the controller asserted on RPA
timeout when AdvA is not present in the primary channel PDU
of Extended Advertising set.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing reset of sync create association with scan
context when associated with both 1M and Coded PHY contexts,
and sync create cancel is called.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix address resolution when trying to match the maximum
entries in the resolving list.
Wait for address resolution AAR peripheral to complete with
checking with all the entries in the IRK list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The extended advertiser would fail to build due to a missing kconfig
option dependency when relay was disabled.
Fixes#43172.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When local node poweroff and power on again, will
receive iv update but within 96hours.
When 96h after, due to cache, we can't process this
beacon any more.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
According Mesh Profile 3.10.6 IV Index Recovery procedure
Upon receiving and successfully authenticating a Secure Network
beacon for a primary subnet whose IV Index is 1 or more higher
than the current known IV Index, the node shall set its current
IV Index and its current IV Update procedure state from the
values in this Secure Network beacon.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When pac_notify is called it will notify the
actual PAC records for the specific type (sink/source).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds function get_pac_records that will retrieve the PAC
records from the application. The pac_read callback
will then call this to get the value, before returning
it to GATT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix k_sem_give() from being called from Zero Latency IRQs
when the Controller is configured with BT_CTLR_ZLI=y.
Kernel features shall not be used from Zero Latency IRQs as
these IRQs cannot be locked by the kernel to maintain
context safety of the kernel objects.
Relates to commit 92e017fd70 ("Bluetooth: controller:
split: Support Zero Latency IRQs") and
commit c842eef3ae ("Bluetooth: controller: Add semaphore
to indicate free AD data buffers").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
sw_switch implementation uses two parallel groups of
PPIs connecting radio and timer tasks and events.
The groups are used interchaneably, one is set for
following radio TX/RX event while the other is in use
(enabled).
The group should be disabled by timer compare event that
starts Radio to TX/RX a PDU. The timer is responsible for
maintenance of TIFS/TMAFS. The disabled group collects
all PPIs required to maintain the TIFS/TMASF. After
the time is reached Radio is started and the group is
disabled. It will be enabled again by software radio
swich during next call.
If the group is not disabled then it will work in parallel
to other one. That causes issues in correct maintenance of
instant when radio shoudl be started for next TX/RX event
e.g. radio may be enabled to early.
In case the PHY CODED was enabled and periodic advertising
included chained PDUs, that are transmitted back-to-back,
there was missing group delay disable. The missing case was
sw_switch function called with dir_curr and dir_next set
to SW_SWITCH_TX.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Since `CONFIG_BT_MESH_PB_GATT` represent to pb-gatt-srv.
We use `CONFIG_BT_MESH_PB_GATT_COMMON` to represent common.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Rename the data and metadata callbacks to _read(), for consistency
with the corresponding function calls.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Move the instance as the first parameter of the client function calls
and callbacks, for consistency with the server implementation.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Merge the metadata types for client and server.
This is part of merging the ots_client and ots header files.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Move the metadata request bitfields to the common header files.
This is part of merging the ots_client and ots header files.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Merge Kconfig file for OTS server and client.
Rename the client config from _OTC to _OTS_CLIENT
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the Object Transfer Client to use OTS defines and types instead
of the ones left over from the previous "le-audio local" object
transfer service:
DIR_LIST, object ID size, OACP and OLCP
Remove the no longer used defines and types from the OTC header file.
Exception: The OLCP sort order defines have not been removed, but
moved to the olcp internal header file, for expected later use.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Move the directory listing size defines to the OTS directory listing
internal header file.
This removes an implicit dependency upon users of
ots_dir_list_internal.h to also include ots_internal.h.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The media control client shell must include the OTC header file.
(It is currently indirectly included via otc_internal.h.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update the OTC to use the existing ots_l2cap code rather than its own
implementation.
- Add an ots_l2cap struct and register it
- Add ots_l2cap callbacks, reuse most of old l2cap_recv callback in
the ots_l2cap rx_done callback
- Remove old l2cap code
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Update configuration so that the OTS l2cap file can also be used for
the OTC.
(The plan is to merge the OTS and OTC config files later.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Add an l2cap connect() function to OTS. This is a function for
clients, added to prepare for the upcoming OTC client (re)using the
ots_l2cap module.
As part of this, factor out an internal function to find a free l2cap
context.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Remove L2CAP server registration. The object transfer client does not
need to register an L2CAP server.
OTS spec: "It is always the responsibility of the Client to open the
Object Transfer Channel, regardless of the direction of transfer, and
is never the responsibility of the Server."
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Preparations for making OTC "official"
Move remaining content of old ots header fil into the otc header file,
and remove the old ots header file.
(Another ots header file already exists in the ots folder.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is the first in a series of commits to make the OTC
(Object Transfer Client) implementation that exists in the audio
folder "official". That is, the client implementation will be updated
and refactored to be aligned with the OTS (Object Transfer Service)
implementation that exists in subsys/bluetooth/services/ots, and moved
to that folder.
Preparations for making OTC "official":
Move remaining content of old ots_internal header fil into the
otc_internal header file, and remove the ots_internal header file.
(Another ots_internal header file already exists in the ots folder.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This change adds the kconfig option
BT_DEVICE_APPEARANCE_GATT_WRITABLE_AUTHENTICATED. When enabled, GAP
apperance is writable by authenticated peers.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Extend the command "bt appearance" to take an optional argument, which
is used to set the appearance.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Introduces new kconfig option CONFIG_BT_DEVICE_APPEARANCE_DYNAMIC.
New API `bt_set_apperance` allows dynamic setting of apperance. The
dynamic setting is saved in the settings subsys. `bt_set_apperance` is
analogous to `bt_set_name`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The new command "bt appearance" prints out the current Bluetooth
Appearance Value.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The this change is a step towards make the GAP appearance runtime
settable and ATT writable.
The new function bt_get_appearance() wraps CONFIG_BT_DEVICE_APPEARANCE
and should replace all its uses in code.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
When Proxy advertising or PB-GATT Advertising Enabled and use a same
advertising sets.
As `adv_start` will call multi HCI Command will cause syswork_q yield.
At same time, if another thread(BT RX) all `schedule_send` will cause
unable send mesh message, because `ADV_FLAG_ACTIVE` was be set, but
`ADV_FLAG_PROXY` not set currentlly.
Add `ADV_FLAG_SCHEDULE_PENDING` indicate mesh buf has been pendings
but not scheduled, so when proxy advertising enable, let's take again,
as we can't break or terminated `adv_start`, so we must waiting proxy
advertising enabled.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix missing call to ISOAL sink instance destroy interface,
without this there is leak in ISOAL sink instances when
removing ISO data path.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
[*] Fixed setting of SDU production status when exiting the
ISOAL_ERR_SPOOL state for framed PDU consumption when receiving the
start of the next SDU
[*] Changed condition identifying a padding PDU to include padding PDUs
with errors received after the end fragment is seen and expanded
unit tests to cover new condition
[*] Changed definition of ISOAL_PDU_STATUS_xxx errors to match value of
similar errors defined for the SDU status
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Improvement to generate Tx ack early when the event close
compared to being done at the start of the next event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising conditional compiles in header files.
Do not conditional compile declarations, definitions of
functions in source files only be compiled out.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to include ll_adv_cmds_set when broadcast role is not
enabled in the Controller but advertising extensions is
enabled (Extended Scanning is used).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
sys_le16_to_cpu is a macro, and not big endian the value
is referenced twice, which would incorrectly increment the
value.
Modifed to extract the value to a variable before calling
sys_le16_to_cpu.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of relying on a single globally increasing (but never
resetting) packet_sequence_number, it is now correctly
reset and incremented for each ISO channel.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding the same BT callback struct twice can cause
an infinite loop when iterating the callback_list,
so register the gatt callback just once early.
Signed-off-by: Peter Johanson <peter@peterjohanson.com>
Rename the use of mstr word in advanced scheduling
implementation to cen as a representation for Central
role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use connection interval units of 1250 us for periodic
scheduling of Extended Advertising auxiliary PDU events so
that auxiliary events can be periodically grouped alongwith
the Periodic Advertising Events. This will permit
mitigating overlaps amongst them.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to find free slot after Periodic
Advertising event, to place the BIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Make the Periodic Advertising time reservation calculation
function internal public so that advanced scheduling can
use it to scheduling the BIG event after the Periodic
Advertising radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the implementation to get free slot after a
state/role so that it is easy for reused for scheduling
Broadcast ISO events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix scheduling of Periodic Advertising events to be after
the group of Auxiliary set events. Do not reduce the slot
offsets as time reservations in ticker for non low latency
variant of controller does not include the slot offsets in
the reservation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the implementation to get free slot after a
state/role so that the code depth is reduced.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Guards the `recv` callback for just unicast and broadcast sink
builds, and removes the usage of it in broadcast_source.c
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The callbacks were implemented to notify the application
about the state of the ISO. However, since then, callbacks
such as `started` and `stopped` have been implemented,
and as such the `connected` and `disconnected` callbacks
no longer server any purpose.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add `ing` to the `BT_L2CAP_CONNECT` and `BT_L2CAP_DISCONNECT`
states, so that the name better matches the actual state.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The L2CAP channels were removed from the bt_conn channels list. They
were thus not found in the ecred connection response handler.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
We keep the behavior for legacy advertising data as the controller will
ignore such scenarios when using legacy advertising commands.
Extended non-scannable advertising sets don't support scan response
data. Extended scannable advertising sets don't support advertising
data.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The command.param may not always be set in send_command
depending on whether command.use_param is set.
If command.use_param is not set, the command.param is
not logged, and is set to 0.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix Periodic Advertising PDU ACAD set and clear interface to
support updating ACAD when previous and new PDU buffer are
same (i.e. when previous new PDU not consumed yet by LLL).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update implementation to have assertion when not finding the
Channel Map Update Indication field in ACAD.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
LE Audio builds on top of the BT Host stack, and will
thus require a higher amount of stack size. Even simple
applications using BAP will likely reach the 1024 default
size with the default BAP configurations, and when
we start adding CAP and even TMAP/HAP on top of it, it
will likely increase even further.
The default value of 2048 is unlikely to be reached,
and applications that want to optimize can likely
reduce it, depending on the configuration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
As use for simple message with no-segment send or receive.
This will be useful for ram-resource-constrained device.
such as bbc-microbit-v1.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Remove the BT_AUDIO_DEBUG Kconfig option.
Given that all the audio modules are guarded by the BT_AUDIO config,
it seems excessive to also have a separate guard for audio module
debug. It is sufficient that this is turned on/off module by module.
Note that the BT_AUDIO_DEBUG was also located in the wrong file - the
babs Kconfig file, not the main Kconfig file.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Remove the check for BT_AUDIO from the Kconfig files that had it, for
consistency (some files did not have it).
This check is not required - all Kconfig.* files are sourced from the
main Kconfig file _only_ if BT_AUDIO has been configured. As long as
this is the case, it is not required to check in the files themselves.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Before this change, enabling CONFIG_BT_SETTINGS and calling
settings_load(), but delaying / not calling bt_enable would trigger an
assertion error due to a timeout. The fault is that the settings load
handler for the Bluetooth host assumes bt_enable has already been called
and sends HCI commands to the controller. This times out if HCI is not
running.
The fix is to skip loading Bluetooth settings before bt_enable. The doc
is updated to guide the user on how to enable Bluetooth after settings
have been loaded before.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
- Prevent double callback with ADV re-scheduling
For configurations using CONFIG_BT_CTLR_JIT_SCHEDULING, when last
ADV before initiating connection is re-scheduled with a small delay,
the disabled_cb would be called a second time. This would unexpectedly
invoke a second conn setup with illegal parameters.
To avoid this JIT scheduler phenomenon, clear the ADV disabled_cb
when invoked.
- Add priority to LLL header. This allows the conn priority to be
associated with the object. Used in vendor LLL implementation.
Signed-off-by: Morten Priess <mtpr@oticon.com>
After PR: https://github.com/zephyrproject-rtos/zephyr/pull/38296
If we receive the second recovery after 192 hours after the first
recovery, we may still not be able to perform any recovery, even
if the IV Index differs by 42, because the `ivi_was_recovered` flag
will only be cleared during the iv update.
But still May lose iv update, as we did the first iv recovery.
This patch by checking the iv duration, if 192h later, auto clear
`ivi_was_recovered` flag.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Added a missing assert statement for validation of the preferred
supervision timeout parameter which can be configured by the user
via Kconfig.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Minor improvement: Use already existing variable, rather than finding
the same value again. It is clearer, and simpler, to use the variable
everywhere this value is needed.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Avoids copying the address and assigning the SID if the
PA list is used, as the values are ignored by the
controller, and thus there is no reason to copy
or assign the values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This solves the following issues:
- Auto-initiation of commands is aborted if one of the issued commands
fails
- The controller return value for a PHY update or DL update is not
made available to the application.
As a result, the host no longer prevents the application from calling
bt_conn_le_data_len_update() and bt_conn_le_phy_update() before the
auto-initiated procedure completes. Now the controller may or may not
accept the additional command issued by the application.
It also simplifies the code:
- We no longer need to keep track of if the auto-phy update
or auto-dl update has completed. If the controller receives
another LE Set PHY while the procedure is pending in the LL, it can
decide if wants to accept another procedure initiation or not.
- We no longer need to auto-initiate auto-initiation of commands in
multiple places
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
There were some references to slave and master left in the unittests
for the refactored LLCP.
These are changed in respectively peripheral and central
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Tests that when a collision happens, the connection attempt is retried
and that it succeeds.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The iso_rx_pool did not use the correct buffer size due to
a missing BT_ISO_SDU_BUF_SIZE, causing it to be too small.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This fix a typo where incorrect member of bt_keys was used for
checking if LTK is present. This was resulting in bogus results
depending on connection role and current identity used.
This was affecting L2CAP/LE/CFC/BV-25-C qualification test case.
Fixes: #42862
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Periodic advertising sync may be created with CTE type filtering
enabled. When received AUX_SYNC_IND, there are HCI_LE_Periodic_-
Advertising_Sync_Established and HCI_LE_Periodic_Advertising_Report
events generated. In case received AUX_SYNC_IND has wrong CTE type,
HCI_LE_Periodic_Advertising_Sync_Established event is generated.
There may not be HCI_LE_Periodic_Advertising_Report event generated.
In this case node_rx, prepared by LLL, was not released in ULL.
It was lost in ull_sync_established_report.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CONFIG_BT_CTLR_DF_CTE_RX is enabled by default if CONFIG_BT_CLTR_DF
is enabled and there is support for DF in given SOC.
If CONFIG_BT_CTLR_DF_SCAN_CTE_RX is disabled then the CONFIG_BT_CTLR-
_PER_SCAN_CTE_NUM_MAX is not available.
It causes build errors if that particular configuration is used by
an application. It was a case for example in split builds of direction
finding connectionless TX sample application were periodic advertising
was enabled but perddioc advertising sync was disabled.
The commit fixes the problem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Previously the data was set incorrectly when the data was set in
multiple operations. It did not take the previous state into account.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/42648
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
There were used an uninitialized variable to set antenna identifiers
length. The value should be set with use of params argument, not
by cp pointer that is not yet initialized.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix to use non-discardable Rx buffer for handling Extended
and Periodic Advertising Report.
Regression introduced in
commit 18171bc774 ("Bluetooth: Host: Non-discardable event
buffer size is 255 for ext adv"). The default discardable Rx
buffer size was reduced causing increased fragmentation and
deadlock trying to get more free discardable Rx buffers to
generate HCI Extended and Periodic Advertising reports.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixes issue #39989.
Save CCC data on pairing complete by replacing private addresses
for the just bonded device with its public address in CCC attributes'
CFG arrays. This is then followed by calls to bt_gatt_store_ccc
and bt_gatt_store_cf for the just bonded device.
Signed-off-by: Jim Benjamin Luther <jilu@oticon.com>
Fix race condition in setting up ISR callback and parameter
caused between ULL_HIGH and LLL context. As LLL IRQ is not
disabled the parameter and ISR callback would get out of
sync causing incorrect parameter supplied to callback and
hence leading to development assert in ull_scan_done().
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing use of auxiliary context to generate done event
which caused leak in release of auxiliary context being not
release when reference count that should decrease to zero.
Regression in 'commit 665a8d2c6e ("Bluetooth: Controller:
Fix repeated per sync drift compensations").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix reset of is_aux_sched flag when closing the primary and
auxiliary PDU reception. Without this fix when scan window
is closed there would be duplicate auxiliary release message
generated causing memory corruption.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add development assert to check the validity of auxiliary
context allocation. This is to ensure that primary PDU
reception does not have an auxiliary context allocated until
ULL has processed the node rx.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add development assert to check the validity of auxiliary
context's parent. This is to ensure a released auxiliary
context is not reused without allocation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixes bug where Host sends L2CAP Flow Control Credit after receiving a
L2CAP Disconnect Response.
The when the callback in l2cap_chan_le_recv_sdu is handed a Disconnect
Reponse, the connnection becomes disconnected, as illustrated by the
asserts. The function should now trigger sending credits if the
connection is disconnected after the callback returns.
Fixes#42112
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Fix Periodic Advertising Synchronization lost implementation
to avoid processing done event twice in cases of overlapping
events or race between sync terminate being requested.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add code comment related to sync context field used to
indicate the sync established event being generated towards
HCI Layer.
Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update implementation to generate Periodic Sync Failed to be
Established when Sync Established message could not be
generate due to lack of free node rx buffers and when there
is sync lost before sync established message could be
generated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In case of error in hci_df_prepare_connectionless_iq_report function
e.g. due to wrong periodic advertising sync handle, uninitilized
per_adv_sync and IQ report object were passed by cte_report_cb callback
to an application.
Correct behavior in such situation is to not to cal cte_report_cb callback.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix any stray Extended Auxiliary PDU from being scanned
when disabling Extended Scanning.
Updated Extended Scan disable implementation to find any
active auxiliary scan context and stop them.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix advertising pdu latest get to defer release of stale
PDU chain buffers. Returning NULL after some buffers where
released causes LLL to assert when chained PDUs are
switched.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Nordic Semiconductor Radio peripheral provides IQ samples as
12 bits signed integer with sign extended to 16 bits.
Where out of range IQ samples (saturated) have value -32768.
Due to conversion of IQ samples to 8 bit signed integer, required by
BT 5.3 Core Vol 4, Part E sections 7.7.65.21 and 7.7.65.22 the
saturation information was lost.
The PR fixes that issue by use of value -128 to mark saturated
IQ samples. Note that BT 5.3 Core does not give any particular
value of IQ sample a special meaning.
This is a vendor specific solution and does not affect other
implementations of lower link layer.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
After https://github.com/zephyrproject-rtos/zephyr/pull/41337, extended
advertising reports are no longer discardable. Ensure the
non-discardable events are large enough.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The conn pointer is still valid / not reused at this time and can be
used further up the stack as an identifer. This simplifies the API of
ATT, and fixes callbacks in GATT that pass on this value directly since
their API does not allow conn to be NULL.
Fixes#41794
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
HCI/GEV/BV-01-C tries to send 255 bytes over HCI, as part of sending
an unknown/unsupported command, but the default buffer size
is 65, which results in a buffer overflow and undefined behaviour.
Instead of crashing hard we now check the buffer length.
In order for EDTT tests to pass we set the buffer size to 255
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Fix Periodic Sync Terminate implementation for race
conditions with ULL scheduling by using a flag to stop any
new ULL scheduling to receive chain PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There was missing a PDU initialization. CP bit in data channel
PDU heder was not cleared. Also cte_info byte was not crelader.
That lead to malformed control procedures PDUs and issues
with connection maintenance.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In direction finding connected mode there is a CP bit that is set
data PDU header. The bit was initialized only if CTE transmission
was enabled. In case of reception of a CTE the bit was available
in PDUs but not initialized.
That caused issues in connection maintenance if PDU memory buffers
were reused. PDU were malformed and connections were lost.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix missing offset adjust field assignment in the Periodic
Advertising's sync_info struct that is present in the
Extended Advertising PDU.
When the sync offset is equal or over 2.4576 seconds from
the Extended Advertising PDU, then the sync offset has to
be reduced by 2.4576 seconds and the offs_adjust flag be
set in the sync_info field.
This fixes a bug where Periodic Synchronization could not
be established for Periodic Advertisings with intervals
greater than 2.4576 seconds as the sync offset was
incorrect due to rollover in the 13-bit offset field.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Exchange MTU sub-procedure shall only be supported on the
LE Fixed Channel Unenhanced ATT bearer.
This was checked when receiving, but sending was allowed.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The directory listing's record length should not reflect the size of the
directory listing object. This field is only the size of the directory
listing entry in the directory object and is intended to help a client
find the next record entry in the list.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Constant Tone Extension may not be transmittied with PHY CODED.
There were check to avoid situation that controller tries to
transmit or receive CTE when PHY is set to CODED.
These check were not conditionally compilated, hence when
PHY Update feature is disabled code did build.
The commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In case the direction finding RX is enabled but without Angle
of Arrival functionality enabled, there HCI command buffer
had wrong command length assigned. It didn't take into account
two dummy antenna IDs provided to fulfil requirement from
BT 5.3 Core Vol 4, Part E sections: 7.7.82, 7.7.85.
HCI driver when received such command buffer, didn't handle it
due to wrong command length.
The commit fixes the problem.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
BT_BUF_EVT_RX_SIZE size by default was set to 68 bytes.
In case of build with direction finding connected mode receiver
enabled the size of event buffer was not enough to store all
IQ samples. In such situation IQ samples reports were not delivered
to Host.
The commit changes default size of event RX buffer to 255 in
case the BT_DF_CONNECTION_CTE_RX is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction finding samples had dependency on KConfig option defined
in Controller. That caused a problem for split builds where
an application and host are not part of the same binary as
controller. The code dependend on the Kconfig option
was always disabled.
To fix that issue new Kconfig options were introduced to
Host. The dependency is removed. Unwanted features may stil be
disabled and samples binaier will be smaller.
The commit aligns all direction finding samples code.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
A common pattern here was to take the work item as the subfield of a
containing object. But the contained field is not a k_work, it's a
k_work_delayable.
Things were working only because the work field was first, so the
pointers had the same value. Do things right and fix things to
produce correct code if/when that field ever moves within delayable.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Fix duplicate incomplete data status generated for Periodic
Advertising Report when LLL scheduling is used but auxiliary
context failed to be allocated in ULL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix duplicate release of auxiliary context when scanning
uses LLL scheduling for reception of auxiliary PDU but the
reception fails.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the same peer periodic sync check to after check for
existing periodic sync create on both 1M and Coded PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing progression of the rx_last pointer when
appending rx buffers before flushing them towards Host.
Under continuous scanning, as the disabled_cb would only
be called when reference count reaches zero, the rx_last
pointer needs to progress when appending the rx buffers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing Periodic Advertising Report with incomplete
data status when ULL scheduled chain reception is aborted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing Periodic Advertising Report with incomplete
data status when LLL scheduled chain reception is aborted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Controller implementation to release auxiliary context
when there is no node rx buffer available to receive
Periodic Advertising Sync AUX_CHAIN_IND PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Report data status when ULL
scheduling to receive auxiliary PDU fails. Defer the
dispatch of Periodic Advertising Report until ULL
scheduling status is comfirmed and assign the correct
value to aux_sched flag.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There were no wait for free notification buffer (pdu object
used to send notifications to Host).
That may cause assertion in lp_comm_ntf function.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Accodring to BT 5.3 Core Vol 4, Part E section 7.8.85 the CTE request
procedure has to be disabled as if Host issued the HCI_LE_Connection-
CTE_Request_Enable with enable property set to 0. It means a Controller
should automaticall disable the procedure.
There were no handling of this part of specification.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were missing pause of CTE request in case remote PHY change
was handled. That may end in violation of BT 5.3 Core Vol 6, Part B
section 5.1.10.1 Packet transmission restrictions.
Without the change there was a possibility to transmitt CTE when
PHY is about to change to PHY CODED.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add handling of complete event in idle state of localy innitiated
control procedures.
The transition will be used by CTE request disable if PHY changes
to CODED while the procedure is waiting in the waiting queue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTE request may not be enabled when actual PHY does not support
transmission of constant tone extension. In case a connection is
asymetric, receive PHY is required to support transmission of CTE.
Receive PHY will be used by a device to get PDU with CTE.
In ll_df_set_conn_cte_req_enable was checking TX PHY type.
It should check RX PHY type.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add a function that is responsible for set CTE request disabled.
It is a refactoring, to have a single place where CTE request
is_enabled and req_interval are zeroed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were missing set of is_enabled member of CTE request.
That allowed host to run HCI_LE_Connection_CTE_Request_Enable
command with enable parameter set to true sequently.
That violates BT 5.3 Core specification Vol 4 Part B section
7.8.8.85.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Enable debug pins when TF-M has been enabled for the image.
This would otherwise produce an error message as the DEBUG_SETUP would
not have been defined for the non-secure image.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix missing ISO Data packet received by Synchronized
Receiver due to incorrect check on sink handle that did
not permit handle value of 0.
Fixed function to get ISO stream context to check for
valid ISO sync context, i.e. not being terminated.
Regression introduced in commit 7c89f1fe9f ("Bluetooth:
controller: Support for separate ISO RX data path").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to check for empty ADV_EXT_IND and
ADV_SYNC_IND PDUs, and not parse them incorrectly.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to limit Periodic Advertising data to a
configurable maximum length when generating HCI reports.
Bluetooth Test Specification defines Scan_Max_Data value
in IXIT. When HCI LE Periodic Advertising Report events are
generated by assembling the chain PDUs, the test cases
expect that if the data length is no more than
Scan_Max_Data, then at least once the IUT shall not
truncate the data in the advertising report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove redundant parameter pass of lll_aux to isr_done as
the auxiliary context use is always for scan context as the
parent.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor refactor of auxiliary scanning implementation to use
consistent variable naming and assignment close to its
locality of reference.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename per_scan field in scan context to periodic field to
avoid confusing with abbreviation for peripheral.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When the periodic advertiser list is used,
the address and SID may not be identical to those passed in by
the application.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
`gatt_req_alloc` will wait until a `req` is free (or until timeout).
`req`s are freed on the BT RX thread in calls into bt_att_recv.
When `gatt_req_alloc` called on the BT RX thread itself when there are
no free `req`s, it will block the BT RX thread and deadlock. The
deadlock lasts until timeout.
This change detects this condition and returns the failure early.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/39624 where
if `bt_gatt_write` is called from BT RX thread (as can happen if it is
called from a bluetooth callback), the BT RX thread can be blocked and
prevented from processing the request responses and unblocking itself.
This was the cause of a soft 30s deadlock until gatt_req_alloc timeouts.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
`gatt_write_ccc` may fail if it is unable to allocate a `bt_att_req`.
This change adds handling of this case to `bt_gatt_unsubscribe`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Fix Periodic Advertising implementation to setup Power
Amplifier (PA) GPIO toggle for transmission instead of
incorrect Low Noise Amplifier (LNA) setup which is for
reception.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Define EVENT_SYNC_B2B_MAFS_US to use the Kconfig option
used to configure the MAFS between Periodic Advertising
chain PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising ADI Support feature bits so that
it is return back in the Read Local Supported Features.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Sync LLL scheduling flag to not be
set when chain PDUs use LLL scheduling, only set when
primary AUX_SYNC_IND PDU received use LLL scheduling.
Without the fix, spurious EVENT_DONE_EXTRA_TYPE_SYNC would
be generated when chain PDUs are failed to be received. This
can cause Sync Lost message to be generated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The lll_scan_aux.c file does not compile when the new LLCP is
selected due to missing conditional compiles.
Conditional compile and proper tx_times are selected with this
commit
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
If any specific stream callback is attempted
to be called but is missing, a BT_WARN log statement
is added.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for the BAP broadcast sink role. This role
allows a device to sync to a broadcast ISO stream.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BAP unicast client implementation. This role
can discover BAP unicast server services and initiate
BAP audio streams.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the Basic Audio Profile (BAP) unicast server
functionality. This allows a device to act as the
unicast server role, which can accept unicast streams
initiated by a unicast client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add implementation to limit Extended Scanned data to a
configurable maximum length when generating HCI reports.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When hashing attributes for the UUID cases:
BT_UUID_GATT_PRIMARY_VAL
BT_UUID_GATT_SECONDARY_VAL
BT_UUID_GATT_INCLUDE_VAL
BT_UUID_GATT_CHRC_VAL
BT_UUID_GATT_CEP_VAL
where (handle || UUID || value) is to be hashed, the worst case size of
attribute value can be deduced from the associated union that describes
all the attribute values in the given cases.
Update the data array to accommodate for the worst case size.
Fixes#39131
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Function bt_buf_get_tx(), which is used to allocate buffer from
fixed-size pool, does not check size argument before copying
the data with the length size into fixed-size buffer, wich may
not be large enough.
Check immediately before copying if the tailroom of the buffer
is large enough.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The CP bit is read in DF connected mode while interpreting
LL_CTE_RSP PDU, hence it must be available in struct pdu_data
type.
There were missing two Kconfig options in new LLCP tests.
They were reponsbile for disable of CP bit instruct pdu_data.
That caused tests to fail during compilation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add missing implementation for disabling CTE request and resposne
control procedures.
If any of these commands is active in LLL then ULL context has
to wait before return. The wait mechanism is based on semaphore.
The semaphore is initialized in ULL context and given by code
responsible for command completion.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When there is pending local control procedure that has instant
it should be possible to run remote control procedure without
instant because there is no collision.
There were missing code to run this case in rr_st_idle() of
refactored LLCPs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There are packet restrictions imposed by PHY update procedure
for PDU that includes CTE (BT Core 5.3 :
- central/peripheral can't send PDU with CTE after receive or send
LLPHY_UPDATE_IND until instant if the PHY after instant is CODED
- peripheral can't send PDU including CTE after it sends LL_PHY_REQ
PDU until receive LL_PHY_UPDATE_IND, LL_UNKNOWN_RSP, LL_REJECTED_EXT_-
IND_PDU if there is a CODE PHY in TX_PHYS
- peripheral can't send PDU including CTE after it sends LL_PHY_RSP
PDU until receive LL_PHY_UPDATE_IND if there is a CODED PHY in TX_PHYS
of LL_PHY_RSP PDU or RX_PHYS of LL_PHY_REQ PDU.
The BT 5.3 Core spec defines only one PDU that may include CTE, that is
LL_CTE_RSP PDU. To avoid a situation that there is such PDU enqueued
for transmission in LLL when packet transmission restrictions should
be applied, both procedures in almost all cases will not be executed
in parallel.
Current implementation always handles remote procedurerequest first.
There are possible three scenarios:
1. Remotely requested PHY update. Locally initiated CTE REQ.
In this case there is no problem with LL_CTE_RSP waiting in a TX
queue in LLL. Both procedures may be executed one after another.
2. Remotely requested CTE REQ. Locally initiated PHY update.
In this case the CTE REQ is handled first and it will pause the
PHY update procedure until LL_CTE_RSP PDU is acknowledged by
remote. Then the CTE REQ procedure will be completed and PHY update
continued.
3. Locally initiated PHY update is pending. Arrives remote CTE REQ.
In this case the CTE REQ will be paused until localy initiated PHY
update is completed. Then the CTE REQ will be continued.
Thanks to that there should be no PDU including CTE in LLL TX quueue.
That releases us from a situation there is a LL_CTE_RSP PDU in the
LLL TX qeueue that must be changed into LL_REJECT_EXT_IND PDU due to
change of PHY to CODED PHY after PHY update procedure completes.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In peripheral role when:
- data length update is enabled
- the CONFIG_BT_MAX_CONN is set to 1
the PHY update control procedure after reaching instant sends two
notifications to host. It notifies host about PHY update and data
length change. Both notifications are send one after another, so two
free node rx are required. The number of available node rx in
provided conditions is one. The PHY update FSM is stalled in waiting
state for enough empty node rx. At the same time remote device is
allowed to send new remote control procedures. Received request are
handled by PHY update FSM that asserts due to unknown procedure opcode.
The commit changes number of allocated nodes to be two times a number
of LLCP connections.
This is a workaround for the issue. The best solution seems to be
sharing nodsx between connections. Though this solution requires
buffering remote control procedures until host notification is done.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Macros responsible for preparation of packet configuration flags in
regard of PHY and CTE were wrong. PHY flags are not used as regular
integer values but bits in a bitfield, hence size of the field in
packet configuration flags is three instead of two.
In such case CTE presen filed should be moved to bit 4th.
The problem was spot when testing implementation with CODED PHY
enabled. When device was sending PDUs that had attached CTE the
radio was configured to use CODED PHY due to wrong bit set in
packet configuration flags variable (overlapping of CTE bit
with CODED PHY bit).
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were no handling of HCI_LE_CTE_Request_Failed event.
The commit adds missing implementation. An application will
be notified about failed request by cte_report_cb. It is the
same callback that is used for reporting collected CTE IQ
samples. The same callback was used to avoid creation new callback.
To give an application possibility to distinguish between regular
IQ samples report and request failed additional member err was added
to bf_df_conn_iq_samples_report structure.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTE request control procedure may failed due to rejection by
peer device or due to receive of LL_CTE_RSP PDU without CTE.
These events has to be reported to host by HCI_LE_CTE_Request_Failed.
The commit adds missing functionalit.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Integrate existing CTE request control procedure code in ULL with
implementation of refactor LLCPs.
The commit includes code responsible for:
- enabling CTE request and scheduling its execution by refactored
LLCPs framework,
- running CTE request periodically
- disabling CTE reqest in case it is running periodic
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There are data received from peer device with CTE request.
These data are not part of local CTE request procedure and
they don't belong to CTE response configuration, hence separate
storage was provided.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
ant_sw_len and ant_ids members of the structure llcp_df_rsp_cfg
were not used. These data are stored in lll_df_conn_tx_cfg
that is member of lll_conn. Unused members are removed.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Part of the CTE request procdure that is related with handling of
remote request should be compiled when CTE RSP is enabled.
Withouth it CTE response will not work. Local CTE request does not
need code reponsible for handling of remote reques.
The commit changes conditional compilation guards.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were missing initialization for CTX request and response conotrol
procedure related variables. The variables were zeored on system
startup but not initialized when a connection is established.
In case of re-use of connection instance for new connection it was not
possible to setup procedures again.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Request interval is a number of connection events that
is used to periodically run CTE request control procedure.
BT 5.3 Core Specification defines it as 2 octets long.
It had wrong type uint8_t. Changed to correct one uint16_t.
The commit also changes type of cte_rsp_en field of lll_df_conn_tx_cfg
to state that it is a boolean flag.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTE type and length parameters in connected mode are dependent
on remote CTE request procedure. These parameters are required
to setup radio to correctly transmit CTE. The same parameters
are also included in CTEInfo byte of data channel PDU header.
The parameters were provided to LLL with PDU to be transmitted
and by lll_conn::df_tx_cfg, hence it was redundant.
The PDUs CTEInfo has to be set before transmission anyway.
The contents of the PDU are set in ULL by CTE RSP control
procedure. To remove redundancy CTE length and type from lll_df_-
conn_tx_cfg were removed from ll_df_conn_tx_cfg. It was better
option becuse it saves instructions in LLL.
Radio in connected mode was configured by lll_df_conn_cte_tx_enable.
The function just unpacked the lll_df_conn_tx_cfg mebmers and
called static function df_cte_tx_configure.
Instead of extending parameters list of lll_df_conn_cte_tx_enable,
the function was removed and df_cte_tx_configure was changed to
be global function - lll_df_cte_tx_configure.
Now LLL directly passes all parameters from pdu_data::cte_info
and ll_df_conn_tx_cfg to lll_df_cte_tx_configure.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The llcp_pdu_encode_cte_rsp functio didn't set pdu_data fields related
with CTE transmission. The commit fixes that.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were wrong conditions in rp_comm_tx function for CTE request
that vefiry if:
- PHY is allowed one,
- CTE length is within allowed value.
The commit fixes it.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The CTE reception and sampling in connected mode was enabled
with CONFIG_BT_CTLR_DF_CONN_CTE_REQ. This is a separate fearure
tha can be enabled when CTE reqest procedure is disabled.
What more the CONFIG_BT_CTLR_DF_CONN_CTE_REQ is dependent
on CONFIG_BT_CTLR_DF_CONN_CTE_RX, not other way around.
The commit adds separate Kconfig to provide such possibility.
Also changes compilation guards for code related with the
CTE reception and sampling.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The implementation of the ll_df_set_conn_cte_req_enable function was
based on former implementation of LLCPs. The CTE request and response
control procedures are not implemented in former LLCPs framework.
The code has been updated to use data structues from refactored
implementation of LLCPs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were missing code responsible for execution of HCI_LE_Connection_-
CTE_Response_Enable HCI command.
The commit adds missing implementation into hci and upper link layer.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Updated hci_init function to call HCI vendor-specific Setup function
(bt_dev.drv->setup()) on beginning of HCI initialization.
This feature need when the BT Controller requires execution of the
vendor-specific commands sequence to initialize the BT Controller before
the BT Host executes a Reset sequence. To enable this feature the
CONFIG_BT_HCI_SETUP should be enable.
Fixes#41140
Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
Skip re-initialization of statically initialized PDU struct
fields that are not modified at runtime.
When supporting connection oriented CTE, the cp bit and
resv field used for CTE info are modified, hence
re-initialized these and accordingly reset the values
when just-in-time HCI Tx Data fragmentation is performed
in the Lower Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The application may want to want the type of an
ISO channel, and take action based on what the type is.
It has been implemented as a get_info to be
consistent with other get_info functions in the
Bluetooth subsystem.
The bt_iso_info struct can be expanded with more information
later as required.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If a central disconnects an ISO, then the `chan` pointer
will become NULL before attempting to call the
disconnect callback.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds clause so that the LPN must have a established friend
connection for the connection terminate callback to trigger
upon clearing a friendship.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Merges bt_csis_client_discover and
bt_csis_client_discover_sets, as they should be done
together for the discovery procedure from the CSIP
spec.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename struct bt_csis_client_set to
struct bt_csis_client_csis_inst, as that is more descriptive
of the actual content of the struct.
This also avoids the confusion about what a "set" is,
which is clearly not a single instance of CSIS
on a single remote server.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Several APIs worked on the bt_csis_client_set struct,
which not only included information about a set, but
also a reference to a specific CSIS instance.
A specialized struct only for the set information
is more useful in those scenarios.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify bt_csis_client_get_lock_state to be the Ordered Access
procedure, which means that instead of reading a single lock value
on a single device, it will read the lock value for all
set members supplied in the function, and return true if any
of them is locked, or false otherwise.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The verify_members_and_get_inst can be used for more than just
locking the set, so checking the specific handle in that
does not make sense.
The handle is furthermore already checked in
csis_client_write_set_lock.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename bt_csis_client_lock_get to
bt_csis_client_get_lock_state. `get` could be
misunderstood as acquire, i.e. that `get` would
mean that the lock was taken by this device.
The new name should make it more obviously that it
is just a read procedure.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the addr struct from bt_csis_client_set_member as that
was only used by the upper layers and not the CSIS client
itself, and as such should only reside in the
upper layers.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change how the SIRK is exposed to the upper layers.
The SIRK will always be the unencrypted 16 octet
SIRK now, instead of a struct.
This not only allows us to avoid having a
__packed struct in the API, but also gives a better
API as we don't expose encrypted data to the upper layers.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the error code BT_CSIS_ERROR_SIRK_ACCESS_REJECTED
as it no longer exists in the specification.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor the bt_csis_client_lock_get function to use a
pointer to a member and a set instead of a bt_conn
pointer and an index.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor the bt_csis_client_lock_read_cb callback to use
a bt_csis_client_set pointer instead of conn and index.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor bt_csis_client_discover_sets to use the
bt_csis_client_set_member struct instead of a bt_conn.
The bt_csis_client_set_member represents a remote server
(set member), and make it possible to avoid sending indexes
of instances around instead of bt_csis.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove the lock and release sets functions, as well
as the discover member function as they have been removed
from the implementation a while ago.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the bt_csis_client_set_member struct to store the individual
bt_csis client struct. This way they are exposed to the
client application.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Use the bt_csis struct instead of the
bt_csis_client_svc_inst struct for the CSIS client.
This makes it more similar to not only the CSIS
implementation, but also the other LE Audio
client implementations.
Furthermore, this change will make it easier to use
bt_csis in the API in the future.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the array to a more descriptive name and change the type
to bt_csis, as well as renaming the individual variables
when accessing the array.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the struct definition to the internal header file,
and add it to the bt_csis struct.
This also renames the csis_instance to
bt_csis_client_svc_inst to use the bt_csis prefix.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds state check to the friend_req_sent CB to ensure
that the CB does not alter the LPN state if it is in a
disabled state. This resolves behavioural issue for lpn_set(false).
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
Reduced logging mode selection to deferred, immediate, minimal and
frontend. Decoupled logging version from mode and created CONFIG_LOG1
which can be used to explicitly select deprecated version.
From now on, chosing CONFIG_LOG_MODE_{IMMEDIATE,DEFERRED} will result
in version2.
Deprecated CONFIG_LOG2_MODE_{IMMEDIATE,DEFERRED} with cmake warning.
Codebase adapted to those changes.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
bt_mesh_subnet_find calls a callback for every subnet, and returns the
subnet that got a non-zero return code from the callback. As pointed out
in #41693, the callback should return a boolean, not an int.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds fix so that a node running with extended adveriser is able to
enable GATT proxy correctly. This fixes a corner case issue where a
device with no other ongoing message sending is unable to advertise
the GATT proxy through
bt_mesh_gatt_proxy_set(BT_MESH_FEATURE_ENABLED) .
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
If the advertiser is not running, the host can now set
periodic advertising data in multiple operations.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Provides interface, data structures and demuxing capability for ISO RX
PDU allocation and transport from LLL to HCI.
Uses the RXFIFO composite for simplicity and reduced overhead.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Validate the OACP and OLCP procedure sizes as the procedure is parsed.
This is in contrast with the current implementation which first parses
the procedure and then validates its size and is prone to accessing
invalid memory when the procedure is malformed.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Add a way to filter scan results by name and/or
address. The idea is that this can be further expanded
by also scanning the content for specific UUIDs, PHY,
RSSI, etc.
This is particularly useful for cases where there are many
devices advertising at once.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If there were local LLCP pending and connection lost happened there
were no release of allocated control procedure context.
It caused to exhaustion of available procedures.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Default value for CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM was set to
CONFIG_BT_CTLR_LLCP_CONN, so the value was 1. That caused a problem
if a device had started a local control procedure and remote procedure
request was received. Ther there were no free context for remote
procedure.
The commit changes the range of allowed value to start from 2.
Also the default value is set to two if CONFIG_BT_CTLR_LLCP_CONN
is 1. In other case default value is set to number of CONFIG_BT_-
LLCP_CONN.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Implementing the final parts of procedure pause mechanism
This is needed to bar procedures from generating pdus during encryption
procedure handling
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
wip
`bt_gatt_cancel` takes a `bt_gatt_.._params` pointer. The `params`
pointer is mistakenly passed on to `bt_att_req_cancel`, which expects a
`bt_att_req`.
This change makes bt_gatt_cancel locate the `req` and pass that to
`bt_att_req_cancel`.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
This structure can be reused to set periodic advertising data.
The structure tries fills the buffer as much as possible.
Later this can be reused for setting advertising data in other cases
as well.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
bt_le_stop() previously did the same restting as bt_scan_reset(). After
the recent changes they were out of sync.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
How the conversion worked was unclear. Moving the conversion out to a
separate function and documenting how it works makes the code easier to
understand.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
The host reassembles fragmented advertising reports from the controller.
Non-complete advertising reports from different advertisers may not be
interleaved. If non-complete advertising reports from an advertiser
is received while advertising reports from another advertiser is
reassembled, an error message is logged and the advertising report is
discarded. Future scan results may be incomplete.
Advertising reports from legacy PDUs or complete extended advertising
reports may be interleaved as these do not require reassembly.
If the controller sends more advertising data than fits in the
reassembly buffer, the data is truncated. Further advertising reports
from the advertiser are discarded until the final complete advertising
report is received and discarded.
Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Only consider negative statuses returned from a L2CAP server as error.
This makes the status check done here consistent with the check done in
l2cap_chan_le_recv_sdu.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
The signature of bt_mesh_app_key_resolve expresses pointer to a 16 byte
array as a const uint8_t *app_key[16], which is actually an array of 16
byte pointers. The intended type is equivalent to a double pointer to
const uint8_t, but trips up GCC 11, which actually checks this.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The crypto.h declaration of the bt_mesh_beacon_auth function declares
the net_id parameter to be a 16 byte array, but the function definition
says 8 bytes. This breaks compilation in GCC 11, which feeds an 8 byte
array into this API, triggering a warning. Change the header declaration
to 8 bytes, which is the right size.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Reset duplicate filtering of Periodic Advertising Reports
when Periodic Advertising Sync is created again after a
terminate or sync lost.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to use correct data status when
detecting duplicate Periodic Advertising Report data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing data status reset when DID change, based on
whether the data status is complete or not, the entry needs
to maintain the correct data_cmplt flag value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The CTE type is used in two ways by HCI layer:
1) single value representing particular CTE type: AoA, AoD 1 us,
AoD 2 us
2) bit-filed where bits 0-2 represent particular CTE types AoA
AoD 1 us, AoD 2 us
The bit-field is used to inform Controller about allowed types
of CTE, hence single value carries more than one value.
To avoid confusion between these use cases in code that refers
to case 1) all named cte_type (singular form). For case 2)
cte_types (plural form) is used.
There is an enumeration that is used for both cases:
bt_df_cte_type. For cte_type only single value from the
enumeration may be assigned to variable except
BT_DF_CTE_TYPE_NONE and BT_DF_CTE_TYPE_ALL.
For cte_types all enum members may be used. Ocasionally
BT_DF_CTE_TYPE_NONE may be excluded. If that is true,
it is described in code documentation.
Thanks to that applications are released from requirement
to include hci.h header file.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were no implementation for HCI_LE_Connection_CTE_Request_Enable
command from BT 5.3 Core specification.
The PR adds implementation and API to be used by applications.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Code that is part of radio_df_cte_inline_set_enabled may be not
compilable for targets that do not have Direction Finding Extension
in Radio peripheral. Added condition with IS_ENABLED to execute
the code only for those SOCs that have the extension.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were changes done to controller code that cause
tests to do not build and fail during execution.
Changes are related with:
- modified code related with extended advertising ADI
field handling
- added generic double buffer data structure that is
used in controller
- moved code that was building only when DF is enabled
- added EVENTS_PHYEND that is not available in nrfbsim
board
The PR addresses those issues.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Connectionless mode of direction finding was based on assumption
that PDU ends when EVENTS_END is generated.
Advertiser added CTE length to IFS duration to correctly maintain
IFS between consecutive PDUs.
Scanner was using separate API to configure radio to configure
software TX/RX mode switch to use PHYEND event instead of END.
Currently every SOC that has Direction Finding Extension in
Radio peripheral uses PHYEND event to mark end of PDU.
There is no need for separate API to configure software switch.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Radio peripheral that includes Direction Finding Extension is
able to generate EVENTS_PHYEND at very end of received PDU.
In case there is a Constant Tone Extensions in received packet
the EVENTS_PHYEND event is generated after end of CTE reception.
If the CTE is present in received packet, the EVENTS_PHYEND
event is generate in the same instant as EVENTS_END.
If CTEINLINE is enabled then Radio will do a runtime packet parsing
to check if CTEInfo is present in received packet. In case there
is no CTEInfo the EVENTS_PHYEND event will be generated with
16 us delay after EVENTS_END.
To maintain the IFS, additional EVENT_COMPARE is used that
will timeout earlier than regular EVENT_COMPARE for EVENTS_PHYEND
generated withtou delay. That additional EVENT_COMPARE will start
software switching of radio mode to TX. In case there is a CTEInfo
present in the packet, additional PPI wiring will cancell
EVENTS_COMPARE set for delayed EVENTS_PHYEND.
The commit provides changes to support delayed PHYEND for nRF53 SOCs.
Besides that there are small formatting corrections due to extended
max line length.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
In connected mode when Receiving Constant Tone Extensions feature
is enabled, controller shall be able to receive CTE in any
data channel packet.
The commit adds required changes to allow receive of CTE for
all data channel packets in peripheral role.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTEInfo may be stored in S1 byte for BLE1M or BLE2M data channel
packet or in payload of advertising channel packet. To allow
selection of where to expect the CTEInfo to be Radio and
DF lower link layer API has to be changed. New parameter
cte_info_in_s1 was introduced.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There are multiple places where double buffer is used in controlers
code. This commit adds generic implementation of the double buffer.
It can be used in future in all places where the data structure is
in use.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Radio peripheral that includes Direction Finding Extension is
able to generate EVENTS_PHYEND at very end of received packet.
In case there is a Constant Tone Extensions in received packet
the EVENTS_PHYEND event is generated after end of CTE reception.
If the CTE is not present in received PDU, the EVENTS_PHYEND
event is generate in the same instant as EVENTS_END.
If CTEINLINE is enabled then Radio will do a runtime packet parsing
to check if CTEInfo is present in received packet. In case there
is no CTEInfo the EVENTS_PHYEND event will be generated with
16 us delay after EVENTS_END.
To maintain IFS, additional EVENT_COMPARE is used that
will timeout earlier than regular EVENT_COMPARE for EVENTS_PHYEND
generated withtout delay. That additional EVENT_COMPARE will start
software switching of radio mode to TX. In case there is a CTEInfo
present in the packet, additional PPI wiring will cancell
EVENTS_COMPARE set for delayed EVENTS_PHYEND.
The commit add support for delayed PHYEND event for nRF52 SOCs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To make possible to correclty receive PDUs that optionally include
Constant Tone Extension after CRC the PHYEND event must be used
instead of END event. PHYEND event is generated by Radio peripheral
for actual end of a PDU. In case there is a CTE the PHYEND event
is generated at end of the CTE. If PDU does not have CTE, then
PHYEND event is generated at end of CRC. In this case it is the
same instant as END event.
Use of PHYEND event is required only when BLE 5.1 Receiving Constant
Tone Extensions feature is supported. Because it is the same event as
END for SOCs that supports Direction Finding Extension, it is always
used for that SOCs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add the BT_GATT_WRITE_FLAG_EXECUTE flag that indicates
whether a write callback is from an ATT execute write.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The current implemenation of GATT long write
(ATT prepare + exec write) worked by sending
each segment individually to the application.
This was a simple and effective method, but
the application had no indication of when the
last segment had been written.
This commit reassembles all the prepare writes
for a specific handle, and then sends the combined
write data to the application.
The prepare+exec write may include multiple handles,
so the implementation has taken that into account,
and will loop over the prep_queue multiple times.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the type of the prep_queue to a linked list
instead of a fifo. The main reason for this, is
that we can then iterate over the content in it,
without popping it.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add host API to allow execution of HCI_LE_Set_Connection_CTE_Transmit_-
Parameters HCI command.
The commit also provides a refactored version of hci_df_set_conn_cte_tx-
_param function. The function was aligned to other hci_df_XXX functions
structure with separated parameters validation and preparation of
command object before it is send to controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
Update Controller implementation of Advertising Extensions
to inherit the set dynamic Tx power values of the primary
channel PDU transmissions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename the variable drop to accept to avoid multiple use of
negations in the implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use DUP_FILTER_DISABLED define instead of magic value to
represent duplicate filtering being disabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update support for Periodic Advertising Synchronization
Receive Enable command, so that PDUs are received so that
contents of Extended Common Payload Format is parsed and
process for information like Channel Map Update and BIGInfo.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Period measurement should be started right after a message is updated.
That is because `struct bt_mesh_send_cb.start` callback is called from
the advertiser thread which is not necessary to be scheduled immeditely
and a user may see some delays between update handler calls.
The publication timer still needs to be scheduled after a message being
actually sent out to the air so that access layer doesn't overflow the
advertiser's buffer. To achieve some specific use cases, where a
published message needs to be retransmitted with 50ms interval, a user
has to switch off network retransmissions to make the legacy advertiser
sleep for the shortest possible time.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Wrong variable was passed when isr_done was registered. It lead to
memory faults and exceptions. It should be a pointer to lll_adv_sync
instance instead of lll_adv.
The commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix Periodic Advertising Synchronization Auxiliary context
leak when failing to receive chain PDUs.
Auxiliary context has not being associated with sync context
when ULL scheduling was used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Periodic Advertising Synchronization Reports do not use a
list for the received chain PDUs, remove the stale code that
free extra list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Synchronization to private address
when public and static identity address is supplied as peer
device address to synchronize to.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising Report's AD data and Scan Response
total data length type to use uint16_t.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix HCI fragment of Extended Advertising Report when chain
PDUs are received. Implementation was missing HCI event
generation for last frag of each PDU when there was a next
chain PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As EVENT_OVERHEAD_START_US offset is used in ticks unit in
LLL, ULL scheduling using ticker should also use ticks unit
for EVENT_OVERHEAD_START_US when reducing the first Periodic
Advertising event preparation.
Relates to commit 858dc7fab4 ("Bluetooth: controller: Fix
EVENT_OVERHEAD_START_US jitter").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix undefined reference to radio start time in FEM support
in ISO Synchronized Receiver implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the ISO Data the payload number shall be the value of
bisPayloadCounter for the PDU containing that payload.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add configuration of transmission of CTE in connected mode.
The transmission is enabled only for PDUs that have CTE present (CP)
bit set to 1.
Radio peripheral is configued by df_cte_tx_configure to transmit CTE.
The same parameters are set for connected and connectionless mode.
The function was changed to re-use the same code for configuration
of CTE in both modes.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To transmit CTE with data channel packet the CTE configuration must
be stored in S1 field, that is placed just after length field.
The commit changes radio_pkt_configure function to allow configuration
of S1 field. When S1 field is used to store information about CTE
then its length is 8 bits. The content of the field is filled with
CTEInfo data. The same as the one used in periodic advertising.
The signature of the radio_pkt_configure function was not changed.
There were not used bits in flags parameter of the function.
From now on, bit 3 of the flags parameter will be used to store
information whether CTE will be added to the packet.
Besides that changed, the commit provides set of macros that
help in preparation and validation of the flags parameter content.
Macros provide information about bits that are currently used.
Ther are also macros that help to retrieve particular information
stored in the flags parameter.
Every place of code where the radio_pkt_configure function occurs
was changed to use provided macros.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
HCI_LE_Set_Connection_CTE_Transmit_Parameters host command was
not completely implemented in controller. There were missign
storage of TX parameters in ll_conn instance.
The commit adds missing part of the command handling.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
If the CTE is attached to data channel packet, the packet must
include information about CTE. The information is stored in
CTEInfo structure that is available in S1 byte of a packet.
Radio checks if the S1 byte is present by verification of
CTE present (CP) bit in byte S0.
The commit add these data to pdu_data structure declaration.
That allows to prepare packet before it is parsed and send
by Radio peripheral.
Besides that there added a new function ull_pdu_data_init that
initlializes fields in pdu_data object that are read only by
lower link layer. CP bit in S0 byte and content of S1 bytes
are examples of such fields.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When PDU has CTE added to the end, the PHYEND event must be used
to correclty switch between TX and RX. END event is triggered just
before start of CTE.
The commit adds new function that configures radio to disable after
PHYEND is generated and then swtich to RX.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
this entry is already defined in subsys/bluetooth/Kconfig. let's keep
that one since it's used by the controller as well.
Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
Adds a buffer to the host to reassemble potentially fragmented
periodic advertising reports.
The buffer size is configurable through BT_PER_ADV_SYNC_BUF_SIZE.
Reports that cannot be reassembled because there is no buffer or because
the buffer is full will be dropped.
Signed-off-by: Bernhard Wimmer <bernhard.wimmer@nordicsemi.no>
Period measurement should be started right after a message is updated.
That is because `struct bt_mesh_send_cb.start` callback is called from
the advertiser thread which is not necessary to be scheduled immeditely
and a user may see some delays between update handler calls.
The publication timer still needs to be scheduled after a message being
actually sent out to the air so that access layer doesn't overflow the
advertiser's buffer. To achieve some specific use cases, where a
published message needs to be retransmitted with 50ms interval, a user
has to switch off network retransmissions to make the legacy advertiser
sleep for the shortest possible time.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The previous PR was not fully baked, so this PR fixes issues by:
- Adding checks when dereferncing pointers stored in params.
- Clearing ack context if a return argument is NULL to not block and
wait for response.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Set the number of L2CAP TX buffers suffiently high if MCS (media
control) is enabled.
Add BUILD_ASSERT if number is too low.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Storing CCC right after it's written reduces risk of inconsistency
of CCC values between bonded peers. The option should be enabled by
default. The developer could explicitly disable it to reduce memory
usage. After disabling the option explicitly, the developer is
aware of related potential issues.
Fixes: #40758
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
CONFIG_BT_LOG_SNIFFER_INFO allows print of LTK for debugging.
If CONFIG_BT_SMP_SC_PAIR_ONLY is set a non-existing struct
entry was printes, which caused a compile-time error.
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
Fix all instances in the controller of -Waddress-of-packed-member by
casting through an intermediate variable and verifying the alignment
with an assertion.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add reception of IQ sample report from controller.
Add applications notification about received reports.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add enable of CTE reception and sampling in connected mode.
The implementation allows an application to decide what type
of CTE is expected to be reported. Bluetooth Core specification
does not provide such functionality, so it is provided as part
of host implementation. Host will filter out all reports for not
enabled CTE types.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The BT_BUF_RX_SIZE did not take the CONFIG_BT_ISO_RX_MTU
into account. Add BT_BUF_ISO_RX_SIZE which
depend on CONFIG_BT_ISO and use that for the
BT_BUF_RX_SIZE macro.
Furthermore, move the BT_BUF_RX_COUNT macro definitions
into buf.h and update that to account for ISO RX as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Bluetooth callbacks are now registered dynamically again. When Bluetooth
callbacks were registered statically, they could be invoked before the
Bluetooth shell (ctx_shell) is initialized. The callbacks try to
shell_print(ctx_shell, ...), which results in a fatal error if ctx_shell
is undefined.
Fixes#40881.
Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
Add new Kconfig BT_CONN_TX which is true if the ACL and
ISO configuration allows for sending data. This is mainly
used to avoid initialization of the tx_complete_work
for ISO sync receiver only builds.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If CONFIG_BT_ISO_BROADCASTER=y and CONFIG_BT_CONN=n, i.e
an ISO broadcaster only build, then the handling of the
TX callback was not properly initialized, causes a fatal
issue when sending.
This commit moves the tx_complete_work out from the ACL group
and into the common area, so that it will be enabled
for connected ISO as well as broadcaster ISO.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactor implementation to use a single common ISO PDU
node rx type for ISO Synchronized Receiver.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds reassembly of framed PDUs to ISO adaptation layer.
Reference times are also computed based on anchor points,
transmission latency components and a PDU specific time offset.
Some partial preparations for ISO broadcast can be found for
convenience. This needs to be properly merged, and currently will not
work with both CONFIG_BT_CTLR_CONN_ISO and CONFIG_BT_CTLR_SYNC_ISO
enabled.
Includes fixes and improvements for unframed mode.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
The GATT Server should wait with clearing Service Changed
indication configuration data until the response callback is
called. Otherwise the indication may not be properly delivered
to a given GATT Client.
Fixes: #40761
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
- Do not ignore unsolicited status messages to allow for the API to be
- used asynchronously
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
- Add optional callback to receive status messages even when using async
API
- Split acked and unacked API
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
As per the GATT documenation, the conn pointer may actually
be NULL in the notify callback, indicating that the connection
is being unpaired.
Add a check for conn == NULL to avoid calling bt_conn_index
on a NULL pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The CCC update should be done after the connection is encrypted.
Before the connection is encrypted, the GATT Server does not know
if the reconnecting peer was actually bonded.
Fixes: #40759
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
In bt_iso_chan_disconnected we did not check for role before
we started to get the CIG and setting the CIG state.
Mmove the CIG code to the central part of the if statement.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
By use of the new macro RXFIFO_DEFINE, a complete set of data
structures for supporting a MEMQ'able FIFO with data pool backing is
created. This is intended for RX nodes such as done-events, RX PDU-
and ISO PDU events. The purpose is to simplify the data management
and code complexity, and provide re-usability.
This commit implements the existing done structures (MFIFO, mem pool,
mem link pool) as an RXFIFO. ISO is the next customer, and later the
pdu_rx_free MFIFO- and related pools may be refactored.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Move all defines that specifies (D)PPI resources which are used
to dedicated files which have no include dependencies. This allow
to use them in nrfx_glue.h to specify fixed (D)PPI channels used
by the bluetooth.
Additionally, added mask with GPIOTE channels used by the bluetooth
controller. It was previously not defined which could lead to
conflicts since same channels could be allocated by the nrfx_gpiote
user
Updated nrfx_glue.h to use new approach.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This PR add multi advertising sets for bluetooth mesh adv bearer.
At the present, the local mesh network occupy single advertising.
And GATT Services Advertising use a single advertising, if support.
One or more advertising sets maybe used by relay node.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When populating bt_df_per_adv_sync_iq_samples_report the
rssi was not wrapped in sys_le16_to_cpu.
Signed-off-by: Jakob Krantz <jakob.krantz@u-blox.com>
ll_adv_set stores poitner to direction finding TX configuration.
When ll_reset is executed the pointer was not NULL assigned.
That lead to erroneous behavior e.g. df_cfg->is_enabled was set
to TRUE even the functionality was not enabled.
DF configuration is stored in memory pool. The memory pool uses
free elements to store its internal data. On reset whole pool is
expected to be free, so ll_adv_set->df_cfg may not point to any
element allocated from memory pool.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
ull_tx_queue.h needs to be included before ll_sw/ull_conn_types.h
zephyr/zephyr/subsys/bluetooth/controller/hci/hci.c
In file included from zephyr/zephyr/subsys/bluetooth/controller/
hci/hci.c:52:
../../subsys/bluetooth/controller/./ll_sw/ull_conn_types.h:453:18:
error: field 'tx_q' has incomplete type
453 | struct ull_tx_q tx_q;
| ^~~~
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Fix implementation to use ADI flag in Periodic Advertising
enable command to add ADI field in Periodic Advertising
PDUs.
Related to commit 6433a6aac1 ("Bluetooth: Controller:
Add Periodic Advertising ADI support").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use nrfx_gpiote and nrfx_ppi allocators to allocate channels
at runtime instead of fixed, device-tree based allocation which
is harder to maintain.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The define for PDU_AC_LL_SIZE_EXTRA was removed in main, but not in
the topic-branch. The merge of topic/branch erroneously reintroduced
this define, so it needs to be removed
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
During work on the new LLCP the assignment to
phy_aux_flags_rx was by accident deleted.
This reverts that deletion
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
When multiple notify feature is enabled, notifications are pushed
twice. Host sends multiple notify with BT_ATT_OP_NOTIFY_MULT and
then continues to send regular notification with BT_ATT_OP_NOTIFY.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/40546
Signed-off-by: Ilhan Ates <ilhan.ates@nordicsemi.no>
Initial attempt at integrating the ISOAL datapath with ISO
Synchronized Receiver implementation to generate HCI ISO
data packets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement ISO Synchronized Receiver connection handle
representing the streams in the BIG Sync. Add implementation
to return these handles on Sync Established event, and to
release these on Sync Lost.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement ISO Broadcaster connection handle representing the
streams in the created BIG. Add implementation to return
these handles on BIG complete event, and to release these on
BIG terminate.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As EVENT_OVERHEAD_START_US offset is used in ticks unit in
LLL, ULL scheduling using ticker should also use ticks unit
for EVENT_OVERHEAD_START_US when reducing the first ISO
Broadcast and Synchronized Receiver event preparation.
Relates to commit 858dc7fab4 ("Bluetooth: controller: Fix
EVENT_OVERHEAD_START_US jitter").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increases the size-limit of ACL packets, to accomodate for using Zephyr
as a host for controllers which support ACL packets larger than 251
bytes.
Signed-off-by: Frode van der Meeren <frode.vandermeeren@nordicsemi.no>
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Zephyr device that is not a GATT Client, should ignore indication.
An Android device may send an indication even if Zephyr
device does not support GATT Client role. In that case, the sent
error response was improperly matched to subsequent GATT request
of the Android device which caused issues.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Fix the dummy ISO Broadcast PDU for correct LLID when
testing with burst number, immediate repetition count and
pre-transmission offset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing link buffer allocation for ISO Broadcaster role.
Without this allocation, create BIG will fail.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO Broadcast only supported related conditional compile
so that data path setup does not return command disallowed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix PTC iteration value calculation for pre-transmission
subevents to consider multiple BIS events in the BIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use memcpy to access the reference to AD data passed in the
list of length encoded parameters used to construct the
Common Extended Payload Format in AUX_SYNC_IND PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to send ISO Sync payload number and
timestamp from LLL to HCI/ISOAL layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the iso_interval field from ULL to LLL context to
facilitate calculation of timestamp when there is PTO in
the BIG events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of ISO sync control procedure
variables.
Without this initialization, after synchronization the sync
is lost.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ISO Sync implementation to use the CRC ok status of
anchor point PDU, and not the last PDU receive, when
generating the event done message.
Without this fix, ISO sync is lost if there is continous
CRC error in the last PDU before the event is done.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Per prf spec 7.2.2.2.1, "A node that does not support
the Proxy feature or has the Proxy feature disabled
shall not advertise with Network ID".
The PR aligns implementation with the specification.
Signed-off-by: Aleksandr Khromykh <Aleksandr.Khromykh@nordicsemi.no>
Adds configuration BT_CTLR_SCHED_ADVANCED_CENTRAL_CONN_SPACING to enable
per-application preferred central connection spacing. This is an
extension of feature BT_CTLR_SCHED_ADVANCED, which when enabled, adds
user defined spacing between existing, and new central initiated
connections.
This is crucial for ensuring that centrals acting as ACL connection
based multi-channel streaming sources do not get overlapping
connections, and that spacing allows full frame transfer without
scheduling collision.
Due to the simple, compile-time configuration, use is limited to
specific applications in which the specified spacing is required.
Signed-off-by: Morten Priess <mtpr@oticon.com>
A user may want to control message parameters (for example, delay
parameter) on every retransmission of a published message (for example,
see section 1.4.1 of the mesh model specification). This is essential
for lighting messages as time gap between messages retransmitted via
the publish-retransmit mechanism introduces unwanted jitter/pop-corn
when such retransmissions are received by a large 'group' of lights.
This commit adds an option to `struct bt_mesh_model_pub` to make the
access layer call `bt_mesh_model_pub.update` callback on every
retransmission. This also addes few macros and functions that can be
used for further calculations.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This change is supposed to fix the issue of incomplete acl mtu
initialization in the absence of BREDR. Find further information here:
https://github.com/zephyrproject-rtos/zephyr/issues/39549
Signed-off-by: Tobias Scharnowski <tobias.scharnowski@rub.de>
Remove LOG_MINIMAL kconfig option which was confusing
since LOG_MODE_MINIMAL existed. LOG_MINIMAL was used to
force minimal mode but because of invalid dependencies
it was leading to issues.
Refactored code to use LOG_MODE_MINIMAL everywhere and
renamed LOG_MINIMAL to LOG_DEFAULT_MINIMAL which has impact
on defualt logging mode (which still can be later changed
in conf file or in menuconfig).
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Limit the maximum ACL Tx buffer size to 251 octets due to
implementation restricted use of uint8_t for PDU len field,
also used as the Tx buffer size data type.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix compile warning filling 24-bit value in 3 octets using
sys_put_le32, used sys_put_le24 instead.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove misplaced declaration of ll_tx_ack_put in
ull_internal.h file while it is already present in
ull_conn_internal.h.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use defines for AD data format field sizes and offsets when
populating AD data format in advertising PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As ISO interval is to be returned in the HCI LE BIG Sync
Established event, store it in ULL context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is initial commit towards integration of ISOAL Rx for
Broadcast/Synchronized Receiver ISO support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ULL reference count is checked in ULL_LOW context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL HIGH execution context which can
prevent the set `disabled_cb` function not being called due
to no pending event to produce the done events.
Fixed by checking the reference count in the ULL HIGH
execution context using a mayfly to schedule the check.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix side effect in assertion when checking a volatile
variable inside assert check.
Fixes#32904, #32923.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation of BIG Sync to use any succussful
received subevent to calculate the anchor sync. Also, use
window widening on subevents if previous subevent did not
sync.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation of ISO Synchronized Receiver data subevents
and control subevent. Implementation of terminate procedure
in the receiver side.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update ISO Broadcaster subevent implementation for incorrect
calculation and use of PTO.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the ISO Synchronized Receiver Terminate and context
release handling to check for prepares in pipeline and
accordingly call lll_disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the ISO Broadcaster Terminate and context release
handling to check for prepares in pipeline and accordingly
call lll_disable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When BIG events are close such that their prepares overlap
and are placed in the pipeline, then more than one done
complete event is generated, ignore them.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation of ISO Broadcast data subevents and control
subevent. Implementation of terminate procedure in the
broadcaster side.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Broadcast ISO BigInfo structure to be filled with
correct payload counter value considering accumulated
latency and ticker lazy value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing use of EVENT_TICKER_RES_MARGIN_US in Periodic
Synchronization and Synchronized Receiver implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the order in which the ISO context is associated with
the Periodic Advertising and Extended Advertising context.
This is done so that the Periodic Advertising does not try
to calculate offset to BIG event before the BIG event is
scheduled by ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the LE BIG complete event generation to not use the
Sync Established structure to access the status value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the BIG Sync Lost event generation to not use the Sync
Established structure to access the reason value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation of BIG Create Sync in LLL. Generation of
LE BIG Sync Established event and LE BIG Sync Lost event
notifications from the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to generate the Create BIG Complete
event after the first empty BIS PDU has been transmitted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to populate the aux, sync and ISO offset
in the latest PDU. If both the current and latest of the
double buffer has been filled and LLL did not pick the
latest PDU, then the offset should be filled into the latest
PDU (and not into the first/current PDU).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing traversal of ADI field in advertised Common
Extended Payload Format. This will cause invalid offset used
for other fields and BigInfo field following the ADI when
Periodic Advertising ADI feature is supported.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing traversal of CTEInfo field in advertised Common
Extended Payload Format. This will cause invalid offset used
for other fields and BigInfo field following the CTE Info
when Extended Directed Advertising is used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to fill the BIG Offset, calculate the
BIS Access Address and CRC init, scheduling and transmission
of BIS empty PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Construction of BIGInfo with mandatory parameters and
placing it in the ACAD of Periodic Advertising PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to release Broadcast ISO Sync, Sync Lost
event and ISO instance allocations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Handling of HCI_LE_Periodic_Advertising_Sync_Established didn't
have implemented handling of possible failures of periodic
advertising synchronization.
There are two situations definded by BT 5.3 Core spec:
- There is no AUX_SYNC_IND pdu within 6 periodic advertising events.
If that happens, status of the command is set to (0x3E) Connection
Failed To Be Established / Synchronization Timeout.
- Periodic advertising has wrong CTE type while periodic advertising
list is not used to determine the advertiser to listen.
In this case status of the command is set to (0x1A) Unsupported
Remote Feature.
The commit provides missing functionality.
In case of error, the periodic advertising will be deleted and
application will be notified by call to terminated callback.
The callback data were extended by err member. It provides
information why periodic advertising was terminated.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Avoid runtime warning in bt_enable when CONFIG_BT_SETTINGS
and CONFIG_BT_DEVICE_NAME_DYNAMIC is not set.
This warning was intoroduced in
commit d76bba4b5e
("Bluetooth: host: Device name handling of invalid length")
Signed-off-by: Martin Tverdal <martin.tverdal@nordicsemi.no>
Pushes all work done in the topic-ble-llcp branch into main branch
This is a refactoring of the LL control procedures; the refactored
control procedures are hidden behind a KConfig option and
per default disabled
Goal of the refactoring:
close issue Link Layer Control Procedure overhaul #15256
make it easier to add/update control procedures
Refactoring consists in principal of writing explicit state machines
for the control procedures.
To reduce the risk of regression errors unit-tests have been added
Following control procedures are implemented:
Connection update procedure
Channel map update procedure
Encryption procedure
Feature exchange procedure
Version exchange procedure
ACL termination procedure
Connection parameters request procedure
LE Ping procedure
Data Length Update procedure
PHY update procedure
Min. nr. Of channels used procedure
Constant Tone extension request procedure
This is a joined work by the people listed in the signed-off-by
list (in alphabetical order)
Signed-off-by: Andries Kruithof Andries.Kruithof@nordicsemi.no
Signed-off-by: Erik Brockhoff erbr@oticon.com
Signed-off-by: Piotr Pryga piotr.pryga@nordicsemi.no
Signed-off-by: Szymon Janc szymon.janc@codecoup.pl
Signed-off-by: Thomas Ebert Hansen thoh@oticon.com
Signed-off-by: Tommie Skriver tosk@demant.com
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Fix Periodic Advertising Synchronize implementation to
generate Synchronization Failed to be Established event
when 6 AUX_SYNC_IND PDUs are not received when establishing
synchronization.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a state to the bt_iso_cig struct. This makes
checks for the CIG state easier, and follows the
state machine in the core spec.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the validation of specific CIG parameters to its
own function. This is mainly to be able to reuse it for
validationg CIG refconfiguration parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Renames the struct from bt_iso_cig_create_param to
bt_iso_cig_param as the same struct can, without
modification, be used to update the CIG as well
(function to support that will come in a later commit).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the verification of the individual cis/bis checks to
an earlier point, because we actually start allocating
resources for the groups.
This removes a double check for NULL, while also
allows us to terminate earlier if there were any
issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A CIG may be updated later to include more CIS, and thus a slist
makes more sense.
The BIG doesn't need the change, but it makes more sense to
have similar handling for both.
This change also removes the requirement that the arrays
used to create the CIG/BIG need to static.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The print specifier for `atomic_t` should be updated
to `%ld`, `%lu`, or `%lx` to account for the type
change of `atomic_t` to `long`.
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Add a macro to retrieve the iso data load length (the
length stored in the iso header) with a bit mask that
ensures that we only take the first 14 bits.
This is to remove any RFU bits that may have been set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add implementation to check Periodic Advertiser
Synchronization to already synchronized peer and same SID.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove now-unused Kconfig options used for specifying radio front end
module configuration.
These are now handled in devicetree.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
A FEM in this case is an external Front-End Module. This is basically
a range booster with some extra amplification in the TX and RX paths.
This feature is supported for the Nordic open source controller. See
the changes to the ubx_bmd345eval_nrf52840 board for a quick summary
of what you have to do to take advantage of this.
(This patch doesn't actually remove the feature in the openisa HAL,
though, because that never implemented the required GPIO handling
routines.)
We are using the 'fem' property previously added to the
nordic,nrf-radio's devicetree binding, which points to the FEM that is
in use. If you have this property and the node it points to is
enabled, the controller subsystem respects it. Otherwise, FEM support
is disabled.
This obsoletes the following Kconfig options, which are now unused:
- CONFIG_BT_CTLR_GPIO_PA
- CONFIG_BT_CTLR_GPIO_PA_PIN
- CONFIG_BT_CTLR_GPIO_PA_POL_INV
- CONFIG_BT_CTLR_GPIO_PA_OFFSET
- CONFIG_BT_CTLR_GPIO_LNA
- CONFIG_BT_CTLR_GPIO_LNA_PIN
- CONFIG_BT_CTLR_GPIO_LNA_POL_INV
- CONFIG_BT_CTLR_GPIO_LNA_OFFSET
- CONFIG_BT_CTLR_FEM_NRF21540
- CONFIG_BT_CTLR_GPIO_PDN_PIN
- CONFIG_BT_CTLR_GPIO_PDN_POL_INV
- CONFIG_BT_CTLR_GPIO_CSN_PIN
- CONFIG_BT_CTLR_GPIO_CSN_POL_INV
- CONFIG_BT_CTLR_GPIO_PDN_CSN_OFFSET
The PA and LNA pins are now specified via fem-specific devicetree
properties in the FEM node:
- The "generic" PA/LNA case is handled with the ctx-gpios and
crx-gpios properties of the generic-fem-two-ctrl-pins compatible,
respectively.
- If the fem is an nRF21540, use the tx-en-gpios and rx-en-gpios
properties instead (and also respectively). This allows us to specify
FEM properties in a way that makes sense for the hardware datasheet,
while still handling them in a uniform way within the controller.
We support this in the nRF5 HAL with a new radio_nrf5_fem.h
sub-header, which pulls in radio_nrf5_fem_generic.h or
radio_nrf5_fem_nrf21540.h depending on the fem node's compatible, if
one is defined. These in turn let us replace the implementation
routines in radio.c with DT equivalents.
Keep in-tree users and devicetree binding documentation up to date.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Introduce an intermediate macro for use detecting that we have a FEM
node, and it's an nRF21540. This is also prep work for converting the
FEM configuration mechanism to devicetree.
No functional changes expected.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Add indirection macros for the ifdefs that test for the existence of
PA and LNA pins.
This will be convenient when the pins are configured in devicetree,
and the Kconfig symbols will no longer be around.
No functional changes expected.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Hide the CONFIG_BT_CTLR_GPIO_..._OFFSET Kconfig macros behind
equivalent ones in the HAL_RADIO_ namespace. This removes any direct
usage of the Kconfig macros from the controller HALs.
That will be convenient when we are getting these values from
devicetree properties instead.
Notice that the "PDN/CSN offset" is dropping the "CSN" portion of the
name: CONFIG_BT_CTLR_GPIO_PDN_CSN_OFFSET is now
HAL_RADIO_GPIO_PDN_OFFSET. This is because the DT binding for nRF21540
has a pre-existing 'pdn-settle-time-us' property we're going to use to
replace the Kconfig option.
Other than that, the name changes are self-explanatory.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Hide the CONFIG_BT_CTLR_GPIO_..._POL_INV Kconfig macros behind
equivalent ones in the HAL_RADIO_ namespace. This removes any direct
usage of the Kconfig macros from the controller HAL ifdeffery, except
for the usage in radio.c where the actual work is done.
Add "NRF21540" in the macros that are specific to that FEM.
That will be convenient when we are getting the GPIO polarity from
devicetree GPIO flags instead.
No functional changes expected.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
The GPIOTE channels used to manage radio front end module GPIOs are
configured with invisible Kconfig symbols. They are therefore not user
visible. Remove them by redefining them in terms of equivalent macros
defined in radio_nrf5.h. This lets us get rid of a couple of ifdefs
that are no longer needed as well.
This is because these invisible symbols depend on the
CONFIG_BT_CTLR_GPIO_* pin configuration symbols. We would like to move
all of that pin configuration to devicetree, because it's hardware
description. It is therefore inconvenient to have the GPIOTE channel
configuration set via Kconfig in a way that depends on something we
would like to remove.
No functional changes or user impact expected: invisible symbols
cannot be set in .conf files.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Recently there was added ADI support to periodic advertising.
There was missing implementation of ADI for periodic advertising
chained PDUs and direction finding. Also unit tests for periodic
advertising chains required update to handle ADI field.
The commit provides missing implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add missing parameter to shell_print call
(The bug exists in the topic-le-audio branch also, but was not
discovered there. In the upmerge branch, it causes build failure.)
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds shell commands for the media control client, the
media player and the media proxy. This is a part of the upmerge of
the le-audio media control files.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with these exception:
- some include paths have been modified to correspond to new locations
of files.
- some instances of the shell variable has been renamed to not be the
same as the name of the shell struct tag.
- spaces have been replaced with TABs a couple of places
- remove cplusplus guards
- changed a debug dependency for MCC from MCS to MCC
- changed log name for the media controller shell
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
mcc.c shell - replace name of shell variable
tmp
f
shell
This commit adds the Media Control Service, and a dummy media player,
from the topic-le-audio branch. This is a part of the upmerge of the
le-audio media control files.
This service has been developed and maintained over a couple of years
now, and is mature. During the development it has passed both
IOP-testing and PTS qualification testing.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
other locations
- copyrights have been updated
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds the media proxy from the topic-le-audio branch.
This is a part of the upmerge of the le-audio media control files.
The media proxy adds a common API to register and access local media
players, and to discover and access remote media players over
bluetooth using the media control client and a remote media control
service.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
other locations
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds the Media Control Client from the topic-le-audio
branch. This is a part of the upmerge of the le-audio media control
files.
This client has been developed and maintained over a couple of years
now, and is mature. During the development it has passed both
IOP-testing and PTS qualification testing.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
other locations
- a macro for debug output of Object ID values has been (temporarily)
added to mcc.h, to avoid a dependency
- a blank line added after a declaration and an overlong line split,
to pass check_compliance
- copyrights have been updated
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds the Object Transfer client from the topic-le-audio
branch. This is a part of the upmerge of the le-audio media control
files. Media control depends upon Object Transfer for feature
completeness.
This client works, and has been used for IOP- and PTS-testing of the
media control server and client. It does, however, need an overhaul
before being made "Zephyr official", so for now it will be kept as an
internal file to the le-audio code.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
an include path updated as a consequence
- a sa consequence, CMake files and Kconfig files updates are done in
other locations
- In otc.c a superfluous semi-colon has been removed to please
check_compliance
- Kconfig.ots has been renamed to Kconfig.otc, as there is only
otc-content left in that file
- copyrights have been updated
- add TODO that these files are to be cleaned up and moved
The Object Transfer Client in this commit was originally written by
Leif Aschehoug <Leif-Alexandre.Aschehoug@nordicsemi.no>.
It has later been updated and maintained by
Emil Gydesen <emil.gydesen@nordicsemi.no> and
Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
ots
The RSSI measurement was not enabled while receiving periodic
advertising. The function responsible for enable the feature
in radio was called, but it was done too early.
It was overwritten by radio_switch_XXX function that assigns
a value to RADIO->SHORTS register.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
If an LTK or an STK is available and encryption is required
(LE security mode 1) but encryption is not enabled, the
service request shall be rejected with the error code
"Insufficient Encryption".
This is affecting L2CAP/LE/CFC/BV-25-C and L2CAP/ECFC/BV-32-C
qualification test cases.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This was affecting L2CAP/LE/CFC/BV-26-C, L2CAP/LE/CFC/BV-27-C,
L2CAP/ECFC/BV-33-C and L2CAP/ECFC/BV-34-C qualification test cases.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This comment was previously associated with a stand-along net_buf_ref
call. Now it's not clear what exactly it's referring to, and the
additional reference to net_buf_put() is fairly self explanatory.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Move the header file csis.h from the internal location to
the public include directory. This file is supposed to provide
the public API for CSIS and the CSIS client, but is not fully
complete yet.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds the coordinated set identification service (CSIS) client.
This is still a work in progress and thus there are no public
API for it yet, and some code changes will still be needed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds the coordinated set identification service (CSIS) server.
This is still a work in progress and thus there are no public
API for it yet, and some code changes will still be needed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding a KConfig to allow for disabling of the passing of invalid SDUs
through the ISOAL HCI data path.
Defaults to keeping current behavior.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
The mesh shell module owns the composition data for the shell
application, which makes it impossible to use it outside of the
application itself. To support the shell as a generic debugging
component that can be added to any application, we have moved the
composition data out of shell.c, and into the application.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
bt_ccm_encrypt only works when encrypting in place. To fix this
ccm_auth() inside bt_ccm_encrypt() must take plaintext instead of
enc_data, to not rely on assumption that plain and cypher data are the
same memory.
Signed-off-by: Ilya Makarov <ilya.makarov.592@gmail.com>
Fixes: #40069
Fix missing auxiliary context release when reception of
Periodic Advertising Chain PDU fails due to header complete
timeout, i.e. no reception of on-air PDU. Also, fix missing
generation of auxiliary reception failure notification when
no auxiliary context was allocated for chain PDU reception.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When an CIS is connected, the peripheral did not have
any information about the QoS settings. This commit
adds information about the PHY and SDU. For some reason
the peripheral won't ever have information about the RTN.
The remaining values in the event (interval, delay and
latency) are still not exposed, nor is framing or
packing, the latter of which are not part of the event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When Device use pb-gatt bearer provisioning, and first
provisioning failed due to some reasons(invalid oob etc..).
Which cause `proxy:gatt_disconnectd` incorrected write `conn_count`
Cause this var euqals `-1`.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix Advertising LLL header initialization to be done early
so that other functions like Periodic Advertising Parameter
set functions can use LLL context to reference ULL conttext.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move Periodic Advertiser List option check in LE Periodic
Advertising Create Sync command to HCI.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Scan Duplicate Filtering to consider different
advertising mode and multiple advertising set id from same
advertiser Bluetooth device address.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use function to get the set/clear AD data parameter to
populate the common extended payload format field.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated the implementation to allow population of auxiliary
pointer field as necessary to append PDU chains.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing traversal of TargetA field in advertised Common
Extended Payload Format. This will cause invalid offset used
for fields following the TargetA when Extended Directed
Advertising is used.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ASSERTION FAIL [!hdr->disabled_cb] @ ull_conn.c:882
When initiating a connection using continuous scan window
if there is preemption by the next window then the ISR
callback was overwritten to switch to next scan window
instead of the initiator event being closed.
Fixed by not aborting the initiating state when requested
by the next continuous scan window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use define for maximum number of primary advertising radio
channels used while scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In HCI event, PHY indices start at 1 compare to 0 indexed in
aux_ptr field in the Common Extended Payload Format in the PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor changes to remove redundant whitespaces and to use
uint8_t instead of uint32_t to return true or false.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing reset of LLL scheduling flag when auxiliary PDU
scan scheduled in LLL is aborted due to preemption.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix continuous skipping of Extended Scanning of Auxiliary
PDUs. Due to duplicate prepare events of continuous scanning
present before the auxiliary scanning prepare, preemption
schedules only the primary scan prepare and auxiliary scan
infinitely is postponed.
This is a revert of commit 190532bcc4 ("Bluetooth:
Controller: Only remove duplicate resume events").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to fragment the list of received Extended
Advertising PDUs into HCI LE Extended Advertising report
events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to setup the PDU radio end
timestamp capture for Scan Response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use variable names lll and lll_aux for struct lll_scan and
struct lll_scan_aux respectively.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to check auxiliary PDU device address
match by comparing the address in the AUX_ADV_IND PDU with
the addresses in the filter accept list.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the filter check function so that it can be reused
for the Extended Auxiliary PDU filtering.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor move of lll_scan_aux_isr_aux_setup function alongwith
other global functions in the file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement setting the correct directed advertisers address
type in the Extended Advertising Report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to filter using access list the received
extended auxiliary PDUs. Use resolving list addresses when
resolving list is enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended scanning filter implementation to permit
ADV_EXT_IND PDUs without AdvA so that AUX_ADV_IND PDU can
be received and to filter that PDU based on whether AdvA
is present.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising Report data status to have
"Incomplete, data truncated, no more to come" when data
length is more than "Scan_Max_data".
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Cleanup the scan event LLL done handling for abort on late
schedule, preemption pipeline abort, preemption current
event yield, duration expire, and connection establishment.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use 32-bit value variables when calculating Extended
Advertising and Periodic Advertising radio event time
reservations to consistently use 32-bit variables for
microsecond time units when calculating radio event where
there is possibility to reserve for scheduling of back to
back chained PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Previously, if the AD field length was greater than the maximum
fragment size - 2 bytes, an out of bounds access would occur.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/39852
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Updates to the CCID module for upmerge to Zephyr main
- add bt_ prefix to the ccid_get() function, add explaining comment,
use defined value for limit
- update copyright statement
- update Kconfig to current practice
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit adds the content control ID (CCID) module from the
topic-le-audio branch. This is required to the le-audio media control
files and call control files, which depend upon CCID.
The commit is a pure copy of the files and content in the
topic-le-audio branch, with the following exceptions:
- files are in bluetooth/audio instead of bluetooth/host/audio, with
some include paths updated as a consequence
- as a consequence, CMake files and Kconfig files updates are done in
other locations
The CCID module is written by
Emil Gydesen <emil.gydesen@nordicsemi.no>
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
make sure channel request reference is cleared if send fails. without
this change this could happen when att_handle_rsp was called:
1. reqs before call:
head: 0x2000f8e8, tail: 0x2000f8c0, elements:
- addr 0x2000f8e8, function pointer NULL
- addr 0x2000f8c0, function pointer 0x35c1d
2. att_handle_rsp called, calling bt_att_req_free with address
0x2000f8e8
3. reqs after call:
head: 0x2000f8e8, tail: 0x2000f8c0, elements:
- addr 0x2000f8e8, function pointer NULL
- addr 0x2000f8d4, function pointer NULL
- addr 0x2000f8ac, function pointer NULL
- addr 0x2000f898, function pointer NULL
- addr 0x2000f884, function pointer NULL
- addr 0x2000f870, function pointer 0xd92b7e7c
- addr 0x2000f85c, function pointer 0x462a03a9
- addr 0x2000f848, function pointer 0xf77b2f4b
- addr 0x2000f834, function pointer 0x33714775
- addr 0x2000f820, function pointer 0x31ba37f8
- addr 0x2000f80c, function pointer 0x5fda8494
- addr 0x2000f7f8, function pointer 0xbcff174e
- addr 0x2000f7e4, function pointer 0x341393f
- addr 0x2000f7d0, function pointer 0xbcfee8b8
- addr 0x2000f7bc, function pointer 0x1e73d9e5
which obviously is broken.
closes#39506.
Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
Dequeue and scheduling IQ samples report towards host
was working by accident. IQ samples were casted to
pointer to struct pdu_adv. Then type of PDU was checked.
Fortunately the IQ samples hadn't got PDU_ADV_TYPE_EXT_IND
in memory pointed by struct pdu_adv->type.
NODE_RX_TYPE_IQ_SAMPLE_REPORT must have separate execution
path in rx_demux_rx.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There were no assignment to iq_report->hdr.handle in the code
hence all IQ samples reports had the same handle value which
was zero.
Since the handle is related with ll_sync_set pointer the handle
value may not be set in LLL.
The best place to set handle value is thread context where
bt_hci_evt_le_connectionless_iq_report is prepared.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When user only use pb-gatt provisioning, which unable to
send out connectable advertising, due to adv thread not started.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Previously the host would handle disconnecting associated CISes and
invoking callbacks when a host ACL conn was disconnected.
This responsibility has now been moved to the controller, which needs to
send a NODE_RX_TYPE_TERMINATE with the CIS handle for proper
disconnection in the host. This is in accordance with the spec.
As disconnect reason, the CIS uses the ACL reason, which is passed to
the host along with the handle.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix BT_CTLR_LOW_LAT_ULL_DONE synchronization counting so
that done events are processed before pipeline enqueue
decisions are taken in LLL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect Periodic Advertising interval when Coded PHY
support is built, chain PDUs is used and Extended
Advertising is disable while the Periodic Advertising
continues to be active.
Related to commit a379196b48 ("Bluetooth: controller:
nRF5: Back-to-Back Radio Tx interface").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Core Specification 5.3 Vol 3. Part G. 4.2:
The Signed Write Without Response sub-procedure shall only be supported
on the LE Fixed Channel Unenhanced ATT bearer.
This was affecting GATT/SR/GAW/BI-38-C qualification test.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Some shell prints didn't use the correct format for some
values, causing warnings/build errors.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix extended advertising set remove and clear, to reset the
PDU double buffer to keep one initialized PDU. This is done
to prevent common extended payload format contents from
being overwritten and corrupted due to same primary PDU
buffer being used to remove AdvA if auxiliary PDU is
allocated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reset allocated advertising and scan response PDUs to one
initial PDU in the double buffers when advertsing set is
removed or cleared.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all subsys/bluetooth and drivers/bluetooth/hci settings having
`[EXPERIMENTAL]` in their prompt has has been updated to include
`select EXPERIMENTAL` so that developers can enable warnings when
experimental features are enabled.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Fix compilation and logic issues to allow testing OTS functionality with
assert enabled.
The compilation fixes are simple and do not require an explanation.
The assertion in bt_ots_dir_list_init was logically reversed. Its
purpose is to ensure the directory list is not already initialized
and as such should assert that the dir_list is not set (i.e. is NULL).
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
Better group code specific for e.g. ISO broadcaster and
ISO sync receiver.
No code has been changed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Splitt he ISO broadcast config into broadcaster and
sync receiver. This will allow a device that only
wants to one of the roles to have a much more optimized
configuration.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add __printf_like modifier to validate strings used by shell.
Fixing warnings triggered by this change.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
The struct basically only had a pointer to
bt_iso_chan_path as well as duplicating the pid and
the direction.
The commit removes the struct as it was more confusing than helpful,
and instead use the PID for the bt_iso_chan_path and
supply the direction as a argument instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A recent change broke the fallback to using a simple
HCI data path configuration in case that the application
does not provide a data path.
This commit fixes that issue, while retaining the
intended update from the change that broke the fallback,
as well as making the code a bit easier to read
and more documented.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There was an error in handling of max number of IQ reports
generated by controller. Accordin to BT Core Spec 5.1 the host
may request a number of CTEs to be sampled and reported by
controller while enable IQ sampling. The max_cte_count value
set to zero means sample all CTEs in a periodic advertising chain.
The commit fixes wrong handling of the max_cte_count provided
value to generate expected number of IQ reports.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The filtering of periodic advertisements by scanner may be not needed
in certain situations e.g. while use of periodic advertising by BT ISO.
To make the code smaller and avoid execution of not needed code the
functionality will be conditionally compilable. It may be enabled
or disabled by use of CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING
Kconfig option.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
First implementation of periodic advertising sync filtering
requires existence of Direction Finding Extension in Radio
peripheral.
To add the filtering support for other Nodric SOCs software
based PDU traversing for CTEInfo should be implemented.
In case there is no DFE in Radio peripheral, actual filtering
is done in ULL.
The commit provides necessary changes to previous solution.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Follow up on changes in lower link layer to add filtering
of periodic advertisements synchronization by CTE type.
The NODE_RX_TYPE_SYNC is used to transport information that:
- Sync is established. In such situation the node_rx
includes data related with received PDU
- Sync scanning is terminated.
In first case ULL will generate NODE_RX_TYPE_SYNC_REPORT
after sending NODE_RX_TYPE_SYNC.
Also EVENT_DONE_EXTRA_TYPE_SYNC handling has additional
execution path that terminates sync scanning if requested
by lower link layer. In other case it adjusts sync scan
window and maintains timeout as usual.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Periodic advertisement synchronization may be filtered by CTE type.
If particular CTE type is not allowed then depening on filtering policy:
- if filtering policy is off synchronization if terminated
- if filtering policy is on synchronization is continued to
synchonize with another device from allowed adverisements list.
If synchronization is established and peer device changes CTE type
to one that is not allowed, synchronization should be maintained.
There are two new execution paths. First one is executed when
synchronization is created. In this case CTEILINE is enabled
to parse PDU for CTEInfo field. In this execution path CTE
type is verified. Second execution path does not include
parsing PDU for CTEInfo and verification of CTE type.
Information about sync allowed is added to node_rx instance
that transports received PDU data. In case the sync has to be
terminated the node_rx will not hold PDU data.
Also done event is extended with information about sync
termination if CTE type is not allowed and filtering
policy is off.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To enable runtime parsing of PDU to find CTEInfo field CTEINLINE mode
has to be enabled. Thanks to that it is possible to verify if the PDU
has allowed CTE type e.g. for periodic advertising synchornization.
To run CTEInfo parsing other parametrers of CTEINLINE are not relevant.
If Radio is set to disable after PDU END event the CTE sampling
will not be processed.
The commit moves the radio_df_cte_inline_set_enable function to make
it accessible even the direction finding features are disabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add missing code responsible for handling of allowed CTE types
in HCI_LE_Periodic_Advertising_Create_Sync command.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Use __WFE and __SEV for CPU sleep in simulation too to
avoid stalling and to let ISRs execute during CPU sleep.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added weak function for data path dependent ISO-AL sink creation. This
is required for vendor specific ISO-AL data sink operation. Invoke sink
creation for vendor specific data path.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Implemented host function for configuring vendor specific data path for
use with ISO, and fixed passing of path ID in setup.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Introduce Kconfig for Read ISO Link Quality command. Support for the
command is optional according to the specification.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Reorder variable declarations in HCI command handlers of ISO-related
commands to conform to reverse Christmas tree style.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Fix use of handle field in HCI command handling for some ISO-related
commands. The response buffer may reuse the command buffer. Therefore,
the handle field must not be copied directly from the command to the
response.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Set bits for ISO-related supported commands depending on selected
features and adjust compilation guards for the respective handler
functions.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
When reaching the last model in the circular extension linked list, the
walker would abandon the walk before checking the last model. This makes
us skip models when checking the subscription list, potentially causing
incoming messages to be wrongfully ignored.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
bt_mesh_proxy_role_setup() is called conditionally when peer is
connected and gatt_disconnected() is always called. This leads
to unbalance in role->conn reference count and crash.
Instead of hot-fixing this in gatt_disconnected(), this commit adds
proper bt_mesh_proxy_role_cleanup() API that is called by roles
implementations if cleanup is needed.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
When there are radio events with time reservations lower
than the preemption timeout of 1.5 ms, the pipeline has to
account for the maximum radio events that can be enqueued
during the preempt timeout duration. All these enqueued
events could be aborted in case of late scheduling needing
as many done event buffers.
During continuous scanning, there can be 1 active radio
event, 1 scan resume and 1 new scan prepare. If there are
peripheral prepares in addition, and due to late scheduling
all these will abort needing 4 done buffers.
If Extended Scanning is supported, then an additional
auxiliary scan event's prepare could be enqueued in the
pipeline during the preemption duration.
Fixes#36381.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
It seems that if the IV update is missed, a node cannot
recover it until the IV index has increased to a value
greater than Node's Last known IV + 1.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
This allows application to increase channel's MTU and (in some cases)
MPS. When channel gets reconfigured dedicated callback is called to
inform application.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
Refactor out the implementation of Periodic Sync Setup
address check including Periodic Advertiser List and SID.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement support for Periodic Advertiser List to be used
in LE Periodic Advertising Create Sync command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor `ull_filter_adva_get` and `ull_filter_adva_get` to
input resolving index compare to adv context reference.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactoring related to filter accept list, resolving list,
and removed the redundant anon variable.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There are two simmilar functions for unsubscribing from GATT handles.
- `gatt_sub_remove`, which is called on disconnect for every
subscription will free the `subscriptions` entry when the entry
represents no subscriptions.
- `bt_gatt_unsubscribe`, called by the application, which forgets to
free the `subscriptions` entry.
If all subscriptions grouped in a `subscriptions` entry are removed
using `bt_gatt_unsubscribe` before disconnect, there are no
subscriptions left to call `gatt_sub_remove` on. The `subscriptions`
entry is then never freed.
The above results in a resource leak of a `subscriptions` entry.
This fix makes explicit and enforces the invariant that there should not
be entries in `subscriptions` with an empty subscription list.
Fixes#38688
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Add unit tests that will ensure the CTE disable operation does not
cause breaking of LLL operations by too early release of chained PDUs.
The tests verify if numbers of PDUs in free PDUs fifo and free PDUs
memory pool are correct.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When CTE is enabled for periodic advertising and number of CTE is
greater than number of PDUs in a chain, that are needed to transport
advertising data, there are additional empty PDUs used for transport
CTE.
CTE transmission may be disabled when periodic advertising event is
pending in LLL. rem_cte_info_from_per_adv_chain removed CTEInfo field
from extended advertising header in chained PDUs. When there were found
empty PDUs (created to transport CTE only), they were released from
the chain that was currently used by LLL. That caused an assert in
isr_tx handler due to broken advertising chain.
The rem_cte_info_from_per_adv_chain may not relese PDUs that are in
use by LLL. The PDUs may be released by LLL in prepare step when
advertising pdu double buffer is swapped by lll_adv_sync_data_latest-
_get.
This PR fixes that issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix asserted in ULL due to incorrect resumption of scan
window when auxiliary channel chain PDU is LLL scheduled by
a ULL scheduled auxiliary channel PDU reception.
The issue is solved by having `is_chain_sched` flag in the
auxiliary channel scan context and using the already present
`is_aux_sched` in the primary channel scan context to
differentiate if the auxiliary PDU Rx ISR is to return back
to primary channel scan window or to close the auxiliary
chain PDU reception radio event.
Relates to #38146.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to ignore aux pointer struct in scanning advertising, to
avoid ULL scheduling from setting up ticker to receive chain
PDUs while LLL is receiving scan response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Local public key has been logged in little endian but
remote public key in big endian. That has been changed.
Both are logged in big endian to be able to compare in logs.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Debug configuration for prov and prov_device has been split
since prov general modul and it is used for provisioner as well.
It is not necessary to enable prov_device debugging
to debug provisioner.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
When the controller forwards incomplete reports to the host,
the application currently has no way of reassembling them.
Therefore the application may fail to parse the data.
Issue a warning until
https://github.com/zephyrproject-rtos/zephyr/issues/37368
is resolved.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Have separate Bluetooth Device address get and read
functions, remove use of function just to return Extended
Advertising Random address and replace with simple
assignment statement.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation defined channel index in the auxiliary
pointer of the common extended payload format in the primary
channel PDUs and the same be used in the transmission of
auxiliary PDUs.
Fixes#35668.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add FIXME comments for missing use of channel selection
algorithm for Periodic Advertising chained PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to set correct Advertiser's clock
accuracy value in the auxiliary pointer field in the common
extended payload format.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to populate the aux, and sync offset
in the latest PDU. If both the current and latest of the
double buffer has been filled and LLL did not pick the
latest PDU, then the offset should be filled into the latest
PDU (and not into the first/current PDU).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In some HCI packed structures we place non-packed structs inside (in
particular the address structs).
Alignment is not an issue for those because all their members are just
byte-aligned, but size is. If the compiler ever packs those it would
become a real problem, and so detect this at build time.
See the link below for more info:
https://stackoverflow.com/a/66389167
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Change the way the local IRKs are accessed to be consistent with the
all other uses.
Coverity thinks using the pointer to the array is suspicious in this
case.
Fixes: #38130
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Verify that the local identity loaded from the settings key is
valid for the current configuration.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use defines for scanning state types of passive, active,
initiator and synchronization state.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow resolving list update when passive scanning,
otherwise deny if advertising, active scanning, initiating
or periodic sync create is active.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix imprecise data bus error when receiving Periodic
Advertising Report caused due to uninitialized `extra` field
member in the node rx struct passed from ULL to LL thread
context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix repeated periodic sync drift compensation invoked when
receiving chain PDUs which caused memory corruptions and
bus faults.
Use `is_aux_sched` flag in Periodic Sync's LLL context to
differentiate between the first AUX_SYNC_IND PDU followed by
use of LLL scheduling to receive following AUX_CHAIN_IND PDU
versus ULL scheduling being used to receive AUX_CHAIN_IND
PDUs.
Drift compensation to be done only using the AUX_SYNC_IND
PDU and not on reception of AUX_CHAIN_IND PDU using ULL
scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a new struct that provides information to the upper
layer when accepting an connected isochronous stream.
The CIG ID and CIS ID makes it possible for the upper layer
to determine which ISO channels are "together" in a group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Update the VCS client to use the auto CCC discovery
feature instead of expecting it to be a specific place
in the remote server's GATT database.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the BT_ISO_SDU_BUF_SIZE which can be used to declare
the TX buffers for ISO, similar to the BT_L2CAP_SDU_BUF_SIZE
macro for L2CAP.
This also updates the ISO samples to use this as well
updating the SDU check to use
CONFIG_BT_ISO_TX_MTU/CONFIG_BT_ISO_RX_MTU without
subtracting the BT_ISO_CHAN_SEND_RESERVE to make the
API more clear.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Handle the case that setting up the iso data path for a
broadcast (sink or source) bis fails.
As part of this fix, implement the lookup_big_by_handle
function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add seperate config to control whether device name include in
pb-gatt advertising scan response data.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
we will no longer need the additional `disconnect` parameter,
such as we only process gatt database from disconnect handler.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The current implementation has hidden dependencies that break
OOB authentication if provisioner does not have the configured
input or output fields used for device capabilities.
It didn't allow to pass several OOB authentication cases.
After refactoring provisioner behavior is independent to
provisionee settings.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Fix BT_CTLR_FAST_ENC Kconfig help text to reflect the
current Encryption Setup Procedure behavior.
With the split architecture, Encryption Setup Procedure
will take 4 connection events when BT_CTLR_FAST_ENC is
enabled, in comparison to 3 connection events in the
legacy Controller architecture. This is due to split
architecture processes control procedures in the lower
priority Upper Linker Layer execution context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
EAGAIN is used in some other places in the code, e.g. if node is not
provisioned when a model tries to send a message. This change helps to
differentiated if the acknowledged message timed out from other failers.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix deadlock in multiple peripheral connection in a device
due to redundant double reservation of node rx buffer during
crossover scenario in Data Length Update procedure.
Data Length Update resize state was reset back to response
wait state when peripheral received an acknowledgment to
local initiated Data Length Request PDU after having already
transitioned to resize state.
Implementation is designed to transition to resize state
under both Data Length Response reception and crossover
scenario of Data Length Request reception when procedure is
local initiated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add check that can be removed by the compiler since the rest is only
needed when multiple identities have been enabled.
Fixes: #38134
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Removed the bt_conn_unref from the deferred_work function.
For ISO, the conn unref for the peripheral will happen in
the bt_iso_disconnected function. For the central, the
unref shall only happen when the CIG is terminated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Log failure to register authentication handlers since returning errors
from the shell is not visible to the user.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle return value of GATT service register and unregister functions.
Log action to shell.
Fixes: #38013
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Check the return value of bt_rand when creating identities.
Failure to generate a random IRK would result in the privacy feature
being compromised.
Fixes: #38120
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix unexpected control flow in host keys module. A continue in a do
while false act the same as a break. This entire construct can be
replaced with a simple if else control flow.
Fixes: #38014
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Check len is not zero before accessing data pointer, the len variable
is not checked before this point so cannot be trusted to not be zero.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fixes an issue whereby the application is configured for extended
advertising mode but advertises in legacy mode with a large device name
which should be limited to 31 bytes
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Ignore the return value of the bt_gatt_change_aware function when the
client is reading the database hash characteristic value. This is the
point where the client becomes change-aware, so nothing else should be
done if the client is change-unaware.
Fixes: #38012
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This is a regression introduced in b8770acc28 when
aligning with BT Core Spec 5.3 naming convention.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
When CONFIG_ARM_MPU is explicitly unset in application prj.conf there
were build warnings related with implicit declarations of following
symbols: NRF_DT_GPIOS_TO_PSEL, __WFE, __SEV.
Lack of NRF_DT_GPIOS_TO_PSEL lead to build error due to undeclared
dfegpio0_gpios symbol.
The cause for the warnings and error were missing soc.h includes in
few source files. The missing includes were added in this commit.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When falling back to L2CAP for connection parameter updates, the
interval min and maxes should also be saved.
Fixes#38613.
Signed-off-by: Eric Johnson <eric@liveathos.com>
When calling ull_conn_iso_cis_stop with no pending LLL events,
cis_disabled_cb may be called recursively if more than one CIS is
associated with a disconnecting ACL connection.
To prevent ticker_stop being called more than once, it shall be
registered at entry of cis_disabled_cb whether this is the last CIS.
Only then shall ticker_stop be called.
Signed-off-by: Morten Priess <mtpr@oticon.com>
CIS LLL events pending was checked incorrectly using a
mayfly incorrect set to be called from ULL LOW context,
but the actual call was from ULL HIGH context.
Beside this, the code was refactored to have file static
functions after global scope functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace the old master and slave prefixes with the new central and
peripehral ones from the Bluetooth spec v5.3.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Replace the old whitelist-related terms with the new filter accept list
one from the Bluetooth spec v5.3.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Align with the new inclusive naming terms in the v5.3 spec in the
Bluetooth Host implementation.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Align with the new inclusive naming terms in the v5.3 spec in the
Bluetooth shell implementation.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
To avoid hitting the following violation:
Violation to rule 5.7 (Tag name should be unique)
Replace the use of "shell" in the shell as an instance of a pointer to
const struct shell.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Align with the new inclusive naming terms in the v5.3 spec in the
controller's HCI implementation.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Add an array similar to the bt_conn (ACL/L2CAP)
tx sent callback, and initialize it.
This increases the number of bt_conn_tx available
such that ISO does not take any of "L2CAP's" buffers,
but also ensures that the sent callback is called
for a broadcast iso only build.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The new inclusive naming terminology changes in v5.3 of the Bluetooth
specification affect the HCI layer, so apply all relevant changes to
align with it.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix the definiion of Common Extended Payload Format data
field in the PDU definitions to be zero-length array,
because PDU size are configurable and to avoid allocations
being made using these PDU structs.
Corrected the extended scan response length check code to
use the correct define instead.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising stop on duration by using the
ticks_drift which now includes the random delay and any
ticker rescheduling of advertising radio events due to
collision with other radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The ticker `ticks_drift` is propagated via the ticker
elapsed callback, in order to provide necessary information
to correctly calculate total elapsed durations by states and
roles that use ticker extensions to mitigate scheduling
collisions by drifting within a permitted window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising Sync Establishment to accept
synchronization establishment to device listed in the
Periodic Advertisers List when filter policy was used.
Fixes#38520.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect calculation of received common extended header
length. Due to this a zero length advertising data is
reported in Extended Advertising and Periodic Advertising
report as one byte AD data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add #defines for the maximum and minimum allowed values for object
IDs.
Moves the #define for the directory listing object ID to the public
header file
Having these limits available is useful for applications wanting to
ensure they pass in (or handle) valid object ID values.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
The Bluetooth Core Specification, version 5.3, has introduced multiple
changes to several widely-used terms in order to make them inclusive.
Update the public API to reflect this, excluding hci.h, which will be
done in a subsequent commit.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Implements the Bluetooth appropriate language mapping for the Bluetooth
mesh subsystem.
Changes the following terms:
- Master security credentials -> Flooding security credentials
- Whitelist filter -> Accept filter
- Blacklist filter -> Reject filter
- Removes CDB's NODE_BLACKLISTED, which was not in use.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Extracted new Kconfig file for the Extended Advertising
and for the Bluetooth Isochronous Channel from the
Bluetooth subsystem Kconfig.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
The BAS serivce Kconfig uses now a log template instead of
defining logger configuration itself.
Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
If one of AUX_CHAIN_IND is not received properly we need to send an
extra report over HCI to indicate that data are incomplete.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
When the application sets more than 251 bytes of advertising data,
the data is sent over multiple HCI commands.
This is only allowed if the advertiser is not running
as defined by the HCI specification.
The data is sent to the controller one AD-field at the time.
If an AD-field is larger than BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN,
the data is split over two commands.
This introduces some additional complexity.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
To test fallback to remaining bearers PTS might request IUT to
disconnect one of the connected EATT channels, while the others remain
intact. Test function must be added, because we cannot create L2CAP
server on EATT PSM and manage this server as normal and have EATT
enabled at same time.
This is affecting GATT/SR/GAW/BV-14-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Th Configuration Server should respond with and Invalid AppKey Index
status code when the AppKey identified by AppKeyIndex is not known to
the node or is not bound to the model identified by the ModelIdentifier.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
A check for valid_chan_io_qos in big_init_bis was missing
a negation when checking for invalid parameters.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix assert at line 1085 in ull_adv_aux.c due to auxiliary
offset calculation scheduling on ticker timeout under must
expire which can happen for overlapping multiple advertising
sets without previous calculation not complete, a single
mayfly instance is used hence the assertion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
cte_info_clear function is responsible for remove of CTE from
periodic advertising PDUs, including remove from optional chained
PDUs. The function uses subortinate function rem_cte_info_from_per_-
adv_chain to remove CTE from chained PDUs.
The rem_cte_info_from_per_adv_chain had pdu_prev and pdu as arguments.
After return from the function the pdu_prev should point to last
PDU from previously used periodic advertising data and pdu should
point to last new periodic advertising data.
The rem_cte_info_from_per_adv_chain function removes CTEInfo from
all but last one PDU. Last PDU must have removed AuxPtr field also.
Remove of CTEInfo and AuxPtr from last PDU is done explicitly in
the cte_info_clear function.
Unfortunately rem_cte_info_from_per_adv_chain had wrong type of
parameters for pdu_prev and pdu. These parameters were pointers
instead od double pointers.
That caused cte_info_clear function to remove CTEInfo and AuxPtr
from first PDU in a chain, which is AUX_SYNC_IND.
Changed parameters pdu_prev and pdu in the rem_cte_info_from_per_adv_-
chain to be double pointers.
Added small corrections in comments.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
Zephyr Bluetooth Mesh move adv send cb to buf destructor
callback, There are two net_buf_pool define, one to adv.c
and ore to friend.c, we are missing destructor in friend.c.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Two checks reported wrong value if the value was invalid.
CIS parameter check would always fail on correct values
due to missing negation of valid_chan_qos.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When Public Key field is set to RFU value then we should send
Provisioning Fail with Invalid Format error.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Fix MPU fault due to incorrect EV_COUNT, `conn_change`
signal was not accounted for in the array used by k_poll.
Relates to commit 7854088116 ("Bluetooth: ISO: Fixes
missing handling of broadcast ISO TX").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Instead of disconnecting ISO channels on ACL,
we put them in a non-connected state, and wait for
the ISO disconnect events.
This ensure that the controller has free'd the
ISO channels when the iso disconnect callbacks
are received. It will thus be possible to e.g.
terminate the CIG on the ISO disconnect callback.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When an ISO channel is disconnect on the central, it is
not deallocated, but merely disconnected. This is because,
as per the HCI spec, the CIS handle lives on in the CIG.
Instead of unref'ing the bt_conn to 0, we simply put the
channel and connection in the disconnected state.
This also fixes a few missing returns for
terminating a CIG.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a sent callback to bt_iso_chan_ops so that the application
can be notified when an SDU has been sent. This can help the
application decide whether to queue up multiple, or only
have a single ISO PDU enqueue for reduced latency.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
On native_posix_64 we get the following compile error in CI:
error: format %u expects argument of type unsigned int
Fix by using %zu instead of %u as type is of size_t.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The HCI spec defines the BIS index range as starting from
index 0x01. We had previously implemented it such that it
starts from 0x00, and then simply adding 1 to the index
when sending over HCI. However, this may cause issue with
other HCI, or other SIG defined specification, commands
and events, and thus it is probably simpler if we just
use the HCI defined range.
This commit disallows BIT(0) (representing the BIS
index 0x00) to be set, and removes the addition
of 1 when sending over HCI.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix null pointer deferencing in Periodic Synchronization
when ULL execution context could not assign an auxiliary
context when in LLL scheduling to receive chain PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix null pointer dereferencing in Extended Scanning when
there are more peer devices than the allocated auxiliary
contexts.
When LLL scheduling does not get an auxiliary context
assigned in the ULL execution context, then further chain
reception is aborted, access to `lll->lll_aux` which is
NULL causes null pointer dereferencing in
`ull_scan_aux_release`.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Extended Initiating a connection, release auxiliary
context memory referenced by the lll_aux pointer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update Periodic Advertising Synchronization's drift
compensation to save radio ready and address capture on
AUX_SYNC_IND reception, restore and apply at the end of
reception of all AUX_CHAIN_IND PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Instead of checking `if (iso == NULL)` it simply checked
`if (iso)` which is the opposite of what it should have done.
This completely blocks iso from connecting channels.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Timeout cancel should only be done for connections established in
peripheral role.
Enhanced connection complete event could still be delivered without
extended advertising support (i.e no advertising set terminated event)
so this handling should be moved to the common conn complete function.
Fixes#37467
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
PR #35774 introduced a uuid field in the bt_mesh_cfg_mod_pub structure.
The shell does not initialize this pointer before passing it to the
access layer. Add a line to initialize this pointer.
Fixes#38016.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
param can never be NULL here, so the check is redundant. Coverity is
complaining because param is accessed before the NULL check.
Fixes#37949.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
param can never be NULL, so this check is redundant. Coverity complains
about this, as the param variable is accessed before the check, which
would be wrong if param could be NULL.
Fixes#37948.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When Extended Scan Response data of length zero is set, the
Scan Response do not have the Common Extended Payload Format
and hence no ADI field. Fix uninitialized pointer to Scan
Response Data's ADI to avoid copy of ADI from primary
channel PDU.
Fixes#38015.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When call bt_gatt_indicate with param->attr set to null.
and attr->uuid set to given uuid, the internal notify will
search uuid, but not assigned to param->attr, which cauce
null point reference when:
notify --> gatt_indicate --> bt_gatt_check_perm
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When call `bt_gatt_notify_cb` with param->attr set to null.
and attr->uuid set to given uuid, the internal notify will
search uuid, but not assigned to param->attr, which cauce
null point reference when:
notify --> gatt_notify --> bt_gatt_check_perm
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Advertising might stop when:
- it was stopped by application
- device connected to a peer
- extended advertising reached stop condition
defined in BT_LE_EXT_ADV_START_PARAM - this is handled in ll
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Call bt_le_adv_stop() if adv == bt_dev.adv (Meaning it is the legacy
advertiser and was started with bt_le_adv_start()), otherwise use
bt_le_ext_adv_stop(), because it was started with bt_le_ext_adv_start().
Failing to stop advertising shouldn't result in assert.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
'err' is already defined in parent scope, we can use. Just need to set
it back to 0 before returning from function.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This was changes when sync chain handling was done in lll_scan_aux, we
can now revert to original code.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We need more RX nodes when scanning either extended/periodic advertising
trains and CTE samples so pudate those values based on observer and DF
features enabled.
The number of nodes for non-DF allows to scan complete chain for each
aux scan set (assuming max data length and optimal fragmentation by
advertiser), for DF it allows to scan max possible PDUs and CTE samples.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Periodic advertising train scanner implemented in lll_scan_aux adds lots
of branches that cannot be compiled out with periodic advertising sync
disabled.
This commit moves sync parts of the code from lll_scan_aux to lll_sync.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Periodic advertising PDUs are now dispatched immediately one by one
(i.e. without list of PDUs as when flushed from aux context) so we
do not need to iterate such a list.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
AdvA, TargetA, ADI and SyncInfo are RFU in periodic advertising PDUs so
we should ignore them when present in PDU.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Periodic advertising reports can be reated directly from single PDU
as they do not require any information from superior PDU, so we can
dispatch them immediately instead of buffering in aux context and
flushing at the end of chain.
This also resolves proper order of Periodic advertising and IQ reports.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We use 1st node enqueued in aux context to retrieve lll scan/sync
struct, but that only works if we buffer PDUs in aux context. It's
better to store parent lll struct as explicit member in aux context
as this also works if we skip buffering.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds complete support for scanning for periodic advertising trains.
AUX_SYNC_IND is always scheduled from ULL as usual, then code for aux
scanning is reused to allow for AUX_CHAIN_IND scanning scheduled from
both ULL and LLL, depending on AuxPtr.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
aux->rx_last cannot be NULL since it's always set after acquire to a
valid node so the flow in flush() can be simplified.
rx parameter is only used to update PDU chain, then it's overwritten,
so we can instead update PDU chain in caller since there's only one
place when this should happen.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We should decide on flush immediately vs. from disabled_cb based on
ull_hdr reference count instead of last rxd node - if ull_hdr has
non-zero ref, then done event is still pending and we should flush
from there.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Periodic advertising reports can have 255 bytes of payload so need to
use that value by default if periodic advertising is enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Update the name of the bt_conn pointers to make it clear
whether the connection pointers are ACL or ISO connections.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make the name of the internal bt_conn pointers explicit as to
whether they point to an ACL or ISO bt_conn.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Ignore received Extended Advertising PDU with RFU field set
in the Common Extended Advertising Payload Format of the
PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use defines to access hdr_data fields used by interfaces to
populate the Common Extended Advertising Payload Format in
the PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use defines for event instant and event instant latency
maximum values of 65536 and 32767 respectively.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation in Periodic Advertising Synchronization
to support Channel Map Update Indications present in the
ACAD fields of the AUX_SYNC_IND PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Make the block of code that is used to release node rx with
type NODE_RX_TYPE_RELEASE to be conditionally available for
other Kconfig selectable features like Extended Scanning.
Previously it was only available for CONFIG_BT_CONN, but now
Extended Scanning with LLL scheduling releases node rx when
radio event is closed due to failure to receive an auxiliary
PDU.
Relates to commit 2feffaf719 ("Bluetooth: Controller:
Release LLL scheduling aux on incomplete data").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing reset of connection handle in the LLL context.
During a central connection, if LL reset is called, then
disabled connection context's handle has to be reset
otherwise new connection creation will fail by detecting
that there exists a connection to same peer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to initiator to check and reject
connection requests to already connected peer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ULL reference count is checked in ULL_LOW context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL HIGH execution context which can
prevent the set `disabled_cb` function not being called due
to no pending event to produce the done events.
Fixed by checking the reference count in the ULL HIGH
execution context using a mayfly to schedule the check.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This ensures that all mesh settings were removed from persistent storage
after node reset.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix maximum radio packet size configuration to use 255 bytes
for Extended Scanning and Periodic Synchronization.
Add a Kconfig option so that application can reduce RAM
usage if a specific user scenario can live with smaller PDU
receptions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the calculation of auxiliary PDU offset for periodic advertising
AUX_CHAIN_IND PDUs there were used old macro that was removed.
The code didn't compile.
Also there were no support for S2 Coded PHY in the offset calculation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The channels list were originally meant to be used
for multiple bt_iso_chan per iso connect (bt_conn), but
that is not the case for the current API, and won't be
going forward, so the use of the list has been removed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for setting initial values in bt_vcs_register_param
when registering a VCS service
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In case that creating a BIG fails due to missing
ISO channel, cleanup_big would try to access a
NULL pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Do not include ULL header in LLL, instead values and fields
required in LLL shall be declared in LLL contexts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Removed implementation that used memcpy of received PDUs and
instead using the free Rx buffers; use the scratch PDU for
transmitting scan requests and connection requests.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add the lll_prof_reserve and lll_prof_reserve_send profiling
functions to use when profiling active scanning and
initiator.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
llcp.conn_param.ack was reset on tx of conn param rsp, however this
should only be done once the expected conn update ind is received
and sets the cu.ack flag to indicate cu procedure 'takes over'.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing implementation to release Auxiliary PDU chains
and then resume back to scanning on primary channel.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add PDU time calculation macro for S2 and S8 Coded PHY.
Rename PKT_AC_US to PDU_AC_MAX_US.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add missing range delay value when calculating the header
complete timeout value for the reception of extended scan
response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the received coding scheme when scanning for correctly
calculating the receive chain delay and on-air PDU time.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After 31045c7 was merged, it was possible to use broadcast
iso without CONFIG_BT_CONN, but it did not properly handle
TX as there were missing support to read the buffer
size from the controller, as well as missing support
for handling the number of completed packets event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change so that num_completed_packets event handling is also
enabled for broadcast ISO only builds. This is because sending
data on a broadcast ISO still generates this event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the function out of the ACL group as it may be used
for broadcast ISO only builds.
er 31045c7 was merged, it was possible to use broadcast
iso without CONFIG_BT_CONN, but it did not properly handle
TX and RX as there were missing support to read the buffer
size from the controller, as well as missing support
for handling the number of completed packets event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Follow up on commit bfd45e5b8c
("drivers: remove Kconfig option CONFIG_UART_CONSOLE_ON_DEV_NAME")
Remove Kconfig options
CONFIG_BT_UART_ON_DEV_NAME and CONFIG_BT_MONITOR_ON_DEV_NAME
since all UART drivers are converted to devicetree and we can just use
DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_uart)) and
DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_mon_uart)).
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
There were missing commands in local supported commands list that
are related with connectionless direction finding.
The commands are implemented but they haven't been added
to HCI_Read_Local_Supported_Commands list.
The commit fixes that.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Move the implementation of scan trains after call to LLL
prepare, so that LLL prepare executes without any latency.
To increase radio utilization, LLL prepare should be
scheduled as early in the `ticker_cb` of the radio event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the return value use to indicate unassigned auxiliary
context when scanning is using LLL scheduling. This can
happen only under LLL scheduling where in LLL auxiliary
channel PDU reception has been spawn from LLL primary
channel scanning and on completion will join back to resume
primary channel PDU scanning.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Keep the default AD Data length to Bluetooth Specification
defined minimum of 31 octets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the connected ISO API to be more
similar to the broadcast ISO API as well
as the HCI spec.
This updated API allows for more flexibility
and will better support scenarios such as true
wireless setup, as ISO channels and connections
are more independent now.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix implementation to not to put back the primary channel
scanning to resume state when Extended Scan has used ULL
scheduling which pre-empts the scan window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Simplify implementation that clears extended scan response
data by moving the length check after the new PDU buffer
has been correctly initialized.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add check to validate PHY value in the Auxiliary Pointer
structure in the common extended header format.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>