Calling bt_disable in system workqueue context while BLE connected may
lead to calling wait_for_tx_work in this context. Fix check in code to
avoid assertion failure.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
When using the CAP initiator shell AC commands, the channel
allocation were not done correctly, leading to cases where
we attempted to set e.g. 2 LEFT streams for the same device.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make `bt_hci_cmd_send_sync` return `-EACCES` when receiving
`BT_HCI_ERR_CMD_DISALLOWED`.
Update some tests that were expecting `-EIO` when
getting `BT_HCI_ERR_CMD_DISALLOWED`.
Add a warning in `set_random_address` when getting that new error. This
is done in case someone try to set a new random address while legacy
advertising, scanning or initiating is enabled. This is illegal behavior
according to the Core Spec (see Vol 4, Part E 7.8.4).
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Derive BT_CTLR_ISO_TX_BUFFER_SIZE from BT_ISO_TX_MTU to have
optimal Controller memory allocations.
BT_CTLR_ISO_TX_BUFFER_SIZE can be set lower than
BT_ISO_TX_MTU in which case upper layer can send fragmented
SDU to the Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename struct bt_hci_iso_data_hdr to bt_hci_iso_sdu_hdr, and
struct bt_hci_iso_ts_data_hdr to bt_hci_iso_sdu_ts_hdr.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In ull_disable, it is imperative that the callback is set up before a
second reference counter check, otherwise it may happen that an LLL done
event has already passed when the disable callback and semaphore is
assigned.
This causes the HCI thread to wait until timeout and assert after
ull_ticker_stop_with_mark.
For certain compilers, due to compiler optimizations, it can be seen
from the assembler code that the callback is assigned after the second
reference counter check.
By adding memory barriers, the code correctly reorders code to the
expected sequence.
Signed-off-by: Morten Priess <mtpr@oticon.com>
I got some feedback about confusion as to why the bt_addr types are not
packed. This commit adds a note about it.
This commit also adds a check for the alignof of the structs to verify
the statement 'their members are bytes or byte arrays' to thoroughly
prove that the struct is effectively as-if packed.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
MBEDTLS_PSA_CRYPTO_C and MBEDTLS_USE_PSA_CRYPTO are 2 different
things and the former should not automatically enable the
latter. The reson is that the user might want the MbedTLS
PSA crypto toolbox to be built, but at the same time he/she
does not want TLS/DTLS (and other intermediate modules such
as PK, MD and Cipher) to use PSA APIs.
For this reason this commit introduces a new Kconfig option
named CONFIG_MBEDTLS_USE_PSA_CRYPTO to enable the corresponding
build symbol. By default USE_PSA_CRYPTO is disabled. It is
only explicilty enabled in tests/samples that were previously
setting CRYPTO_C (since in those cases USE_PSA was set).
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Implement LL_ASSERT_INFO1 and LL_ASSERT_INFO2 for triggering assertions
with parameter information provided for vendor core dump.
Adds Kconfig CONFIG_BT_CTLR_ASSERT_VENDOR by which the new LL asserts
map to BT_ASSERT_VND macros, which shall be implemented in the
debug_vendor_hal.h of the platform. If not enabled, LL_ASSERT_INFO will
map to existing BT_ASSERT_MSG with parameters printed.
Add use of LL_ASSERT_INFO2 where ull_ticker_stop_with_mark() result may
assert.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When building ISO applications on a device that has the host
and controller on the same core, the application developer
shouldn't have to set controller specific configurations.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
net_buf_alloc(K_FOREVER) can now fail (if run from the syswq). Propagate to
the caller instead of asserting.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The `BT_DEBUG_*` Kconfig symbols have been deprecated for more than 2
versions, remove them.
Update code that was still using them.
Remove the Bluetooth specific `Kconfig.template.log_config_bt` and use
`Kconfig.template.log_config_inherit` from the logging subsystem
instead, now that the legacy symbols can be removed.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
Add the CAP commander reception start procedure which starts reception
on one or more CAP acceptors
With the implementation of broadcast reception start procedure we also need
some mockups for unit testing
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
When calling bap_broadcast_assistant add_pa_sync, it should only
set the BIS index field as optional parameters and not to whatever
is in the BASE.
If setting BIS index which the BASE does not support, then the
command should be rejected.
This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/70835
Signed-off-by: Ping Wang <pinw@demant.com>
When calling bap_broadcast_assistant add_pa_sync, it should only
set the BIS index field as optional parameters and not to whatever
is in the BASE.
If setting BIS index which the BASE does not support, then the
command should be rejected.
This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/70835
Signed-off-by: Ping Wang <pinw@demant.com>
The bt_cap_common_discover function relied on a global variable
used to indicate that a discovery was in process.
This global variable prevented multiple discoveries to take place
on multiple ACL connections, where the intention was to stop
multiple discoveries on the same ACL.
This has been fixed by moving the variable into the
struct bt_cap_common_client, so that it applies per
connection, rather than a global check.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moved the busy flag and the GATT paramters to the
individual CSIP Set Coordinator instances.
This allows to use multiple instances in parallel,
and thus in turn allow CAP to do things in parallel.
This commit has been done with minimal amount of changes,
even if there are multiple pieces of code that could likely
be refactored to be better.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Callback was always called with NULL conn. Now it is called with proper
pointer or NULL conforming to description.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
As documented in bt_le_scan_update(), the host may start scanning
automatically for various reasons.
Until now scanning was only done on 1M PHY, making it impossible
to use auto-connect/sync establishment if the advertiser was using
Coded PHY as its primary PHY.
Auto-connection would never work. Sync establishment would work if
the scanner was started by the application.
This commit fixes this by instructing the controller to scan on
both 1M and Coded PHY if the controller supports Coded PHY.
The application may see increased power consumption as a result
of this change as the controller may now spend 2*scan_window
listening for advertising packets.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Use reschedule margin as minimum ticks_slot when ticker with
reschedule expires. This will ensure not too many unreserved
tickers expire in close proximity that can lead of pile up
of CPU processing time and eventually causing timeout
callbacks to be delayed. This mitigate possible LL asserts
due to overhead in start of radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable use of ticker slow window yield feature under mesh
usecase. This is make sure scan window either slides within
is window or skips to next interval so that it does not
lead to advertising event being skipped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix short prepare preempt timeout start, such that if there
are any normal prepare before a short prepare in the
pipeline, then find the short prepare and start its preempt
timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add prepare pipeline assertion checks to detect faults
like stopping preempt timeout without prior start. Also,
check if the preemptor param is correct when preemption
is performed. Check that the prepare pipeline is not
infinitely looping.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add assertion check for use of scan aux context so that
scan aux context is not assigned again while there is
already an existing LLL scheduling in use by the scan
context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_EARLY_ABORT_PREVIOUS_PREPARE to setup new
shorter preempt timeout irrespective of whether there
is a previous prepare enqueued in the prepare pipeline.
Relates to commit d573951f0d ("Bluetooth: Controller:
Revert back early abort of previous prepare").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit updates models metadata API to simplify the usage and
removes the metadata pointer in health server model context.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
When in the BAP unicast server role, at least PAC sink
or PAC source shall be set.
In order to fulfill this new requirement, a few other Kconfig
options had to be changed to a `depends on` from `select` to
avoid recursive Kconfig requirements. This change may require
some applications to update their configurations according
to the migration guide.
The change from `select` to `depends on` is ideal anyhow
as that is the recommended way to add dependencies.
This can checked via the combined BT_PACS Kconfig value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When building ISO applications on a device that has the host
and controller on the same core, the application developer
shouldn't have to set controller specific configurations.
Without this change the samples iso_receive and iso_broadcast
will fail to run on NRF52 series devices as the samples
try to set up two streams but the controller is configured
to support only one.
Controller unit tests that were previously only enabling the
controller specific ISO configurations now also enable the
top-level ISO configurations to ensure that the default
stream count is properly configured.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Add USB out support for the BAP shell, so that decoded LC3
data can be sent to the host (e.g. a PC).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The volume controller always set the busy flag in
bt_vcp_vol_ctlr_set_vol, where it should only set it
if the GATT operation succeeds.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Send a `READ_MAX_ADV_DATA_LEN` command to the controller at the
initialization of the host to fetch the maximum advertising data length
the host can accept.
This is done because even if the Zephyr controller provide the
`CONFIG_BT_CTLR_ADV_DATA_LEN_MAX` Kconfig symbol, other controllers may
not have such Kconfig symbol. So this is a way for the host to be more
controller-agnostic and provide useful feedback to the users.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
In most cases these were defined as 1. Saving one byte for the rest
doesn't really justify the added complexity that comes with these
options. Removing them also simplifies the interface between HCI
transports/drivers and the host stack, which in turn helps pave the way
for having HCI as a proper Zephyr driver API.
Fixes#71907
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Commit adds using host\controller based random number
generator instead of zephyr driver.
No mesh dependency anymore on zephyr system
random driver.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
This function is used in many places, but just by reading its
name it is not obvious why it is needed.
By adding some documentation it will hopefully become a bit more
clear that this function is mainly used for auto connection
establishment.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This line was clearly intended to check for the value returned by
ad_init(). The ad_len is unsigned, so checking for a negative value
showed up in a recent Coverity run (no GitHub issue for it yet).
Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
Update the documentation of `BT_CTLR_ADV_DATA_CHAIN` Kconfig symbol to
say that it's only supported in *non-connectable* extended advertising.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
We can (and do) open multiple channels with a single L2CAP command. If the
remote doesn't support dynamic channels at all, then it sends back a
REJECT_RSP.
We only destroyed the first channel that matched the command PDU
identifier. Fix that and remove all channels that match.
Also add a test that verifies the patch.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Commit fixes bug if dfu server failed to deliver
apply response it gets stuck in applying phase.
In this phase it skips all further client attempts
to apply image again.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Ignore failure to Broadcast ISO remove data path when
terminating a BIG without a data path being setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When multiple advertisers overlap over time, the random
delay being applied need many ticker operation context.
This causes the ticker_update interface to return error
causing assertion in the Controller.
This is fixed by not applying random_delay value to the
overlapping advertiser that does not get to use the radio.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor only. The surrounding ifdefs are intentionally not changed in
this patch. They will be in the near future.
Rename the pool and generalize the documentation to allow using this
pool for other events that fit the same criteria. This pool can be used
for any buffer that is processed synchronously, without negatively
affecting 'num complete' messages. E.g. 'cmd complete/status' can be put
in this pool already.
We will be working towards making the host process all event buffers
synchronously. This is because events have no dedicated flow control,
and discarding events in the driver without informing the host creates
problems. Discarding should instead happen in the host higher layers
when unavoidable.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
There was a typo in Kconfig check (missing CONFIG_ prefix) which
resulted in not setting OACP_FEAT_BIT_CRC bit in features.
This also resulted in checksum feature being disabled due to check
in bt_ots_init().
This was affecting OTS/SR/OASP/BV-03-C qualificatio test case.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
As per the BAP spec, the scan delegator device should add the BASS service
data in the extended advertising data when it requests a broadcast
assistant to scan for it. For testing purposes that's usually the case
with the shell, extended advertising data shall be populated with the
BASS service data.
Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
Add aux offset population assertion check, to ensure the
aux offset calculation is completed before the primary
PDU is setup for transmission.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Commit fixes behavior when provisioning protocol accepts
incoming transaction before ongoing tx transaction is
still active (device didn't receive acknowledgement yet).
Incoming data are ignored until ack is not received.
Specification:
5.3.3 Generic Provisioning behavior
...
If the sender receives a Transaction Acknowledgement
message, then the transaction has completed.
If the sender receives a message with other PDU types,
then the message shall be ignored.
...
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Change default to using advertising coding in ACL connection
when establishing connections on Coded PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add missing check for Coded PHY support when creating
extended advertising set.
Added a fallback in Controller for upper layers requesting
Coded PHY while Controller is implemented without Coded PHY.
In this case, 1M PHY will be used in extended advertising
for testing purposes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Ignore LE 2M PHY being set in Initiating_PHYs of the
LE Extended Create Connection command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adapts flash writing for BLOB IO to RRAM. The previously used write
block alignment is not needed for RRAM.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
An audio stream is unidirectional, so it's always either
TXing or RXing, so the fields can safely be moved to an
enum.
The struct now has both a is_rx and is_tx field. The reason
why two bools are being used, is that the both of them may
be false (we need 3 states).
All access to the rx and tx structs in the union shall be
guarded by these fields.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
We could start executing the work item after the channel has been
disconnected or destroyed, due to a race condition.
Double-check we are connected before attempting to send data.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This check is repeated many times in `gatt.c`, with various comments.
This patch refactors these occurrences into a named function.
Resolves: https://github.com/zephyrproject-rtos/zephyr/issues/41789
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
We can't just keep blocking the syswq, people be mad.
Override the timeout value so we always have K_NO_WAIT.
Also print a message to whomever's listening.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
OTS requires that indications about state change are sent after
response to ATT Write.
OTS Specification p.4.4.4.: "An OLCP or OACP operation is started
when the ATT Write Response is received from the Object Server as
a result of the Object Client writing an Op Code to a control point
to perform some desired action. The control point operation ends
when the Object Server sends an indication to the Object Client
with the Op Code set to Response Code."
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
To make it easier to understand the code, the following was done:
- Use INITIATING/ADV for state names that are exclusive to central
or peripheral. Previously it was not necessarily clear that the state
BT_CONN_CONNECTING was for central only by just looking at where
it was used. The terms INITIATING/ADV were used in favor
of central and peripheral as these terms also work for SCO connection
establishment.
- BT_CONN_CONNECTING_SCAN -> BT_CONN_SCAN_BEFORE_INITIATING
to make it more clear that we are not scanning and connecting at
the same time. The new name should make it more clear why we are
scanning - only with the intention to start the initiator later.
- BT_CONN_CONNECTING_AUTO -> BT_CONN_INITIATING_FILTER_LIST.
This makes it clear that this state is something different than
BT_CONN_AUTO_CONNECT.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
When initially reading some of the host code it was unclear to me
why they were needed an how they are used.
By adding some documentation,
this can hopefully make it easier for others to understand these.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The following warning is issued by clang:
warning: field within 'struct gatt_chrc' is less aligned than 'union
gatt_chrc::(anonymous at subsys/bluetooth/host/gatt.c:1859:2)' and
is usually due to 'struct gatt_chrc' being packed, which can lead
to unaligned accesses [-Wunaligned-access]
This is due to the fact that the uint16_t uuid field requires 2-byte
alignment but it is not marked as packed. Since the enclosing struct is
indeed packed, the required alignment is not guaranteed and so clang
complains. Fix it by ensuring that the union is marked as packed too.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The advertiser options to automatically add the name in the scan
response and the advertising data will be deprecated.
The Mesh files `proxy_srv.c` and `pb_gatt_srv.c` were using
BT_LE_ADV_OPT_USE_NAME. Add the device name in the advertising data
directly.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
The advertiser options to automatically add the name in the scan
response and the advertising data will be deprecated.
Update the Bluetooth shell and its documentation to not use those
options anymore.
The option of the legacy advertiser run with `bt advertise` and the
behavior hasn't changed. The code has been updated to no longer use the
advertiser option but the original behavior has been reproduced.
The option of the extended advertiser have been updated to be more
explicit. The options `name` and `name-ad` have been removed from the
`bt adv-create` and `bt adv-param`. The option `name` and `dev-name`
have been added to the `bt adv-data` command.
- `name <str>` will advertise the given name.
- `dev-name` will advertise the device name.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
When initially reading some of the host code it was unclear
to me why they were needed an how they are used.
By adding some documentation, this can hopefully make it
easier for others to understand these.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
UBSan was showing the following error:
```
runtime error: left shift of 137 by 24 places cannot be represented in
type 'int'
```
Cast the value to `uint32_t` to make UBSan happy.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
The comment states the reason for this requirement is to detect
violations by a remote peer. The ATT version of this was removed in
ea04fd95f9. TLDR: It's neither possible
for, nor the job of the host to police the remote device.
We remove this requirement to be more flexible about the number of
priority levels in the system, and to avoid the temptation of using
priorities as a synchronization mechanism.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Add support for decoding incoming LC3 data. At this point
we only instantiate a single LC3 decoder, so only one frequency
and duration is supported.
To accomodate for the increased RAM usage, the number of unicast
streams support have been decreased.
Further more, the LC3 handling in the shell has overall been
improved, also for encoding.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
`ret` is the amount sent from the current buffer. `sent` contains the
total amount that was transferred in the while loop.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Modifies the audio configuration (ac) commands for CAP
and GMAP to use the default presets instead of supplying
the preset as arguments. This will allow the user to
use the `bap preset` command to configure everything in the
codec configuration before the AC commands are issued.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When creating a broadcast sink using the auto scan feature,
the call to bt_le_per_adv_sync_create would use a local
PA sync pointer, instead of one from the per_adv_syncs
array, making it impossible to stop the PA sync afterwards.
This commit modifed the auto_scan so that it properly uses
the per_adv_syncs array, while still assigning the PA sync
in the shell broadcast sink struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The print_codec_cfg_chan_allocation did not take the case where
chan_allocation == BT_AUDIO_LOCATION_MONO_AUDIO into account,
in which case it should print "Mono".
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
`bt_recv` is invoked from the BT long work queue, which is preemptible.
The host uses cooperative scheduling to ensure thread safety.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Implement test version of the LE Create BIG command ll_big_test_create
(BT_HCI_OP_LE_CREATE_BIG_TEST) in the controller.
This enables use of CONFIG_BT_ISO_ADVANCED, which supports use of
the following BIG/QoS configuration parameters (otherwise derived):
- ISO_Interval
- NSE
- Max_PDU
- BN
- IRC
- PTO
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix regression in BT_RX_STACK_SIZE use due to
commit b91728619c ("Bluetooth: host: remove
`CONFIG_BT_RECV_BLOCKING`").
Profiling of Controller Rx thread has been mentioned in
commit 586ba9fd13 ("Bluetooth: Controller: Increase
BT_RX_STACK_SIZE for BT_HCI_RAW enabled").
Also, move the TX_STACK_SIZE value as default in Kconfig
from the explicit value being set in hci_ipc sample.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Generic node_rx_hdr struct contains data not used for done event, so this
pdu specific data is moved to node_rx_pdu to minimize memory usage for
MFIFO_done alloc.
This however calls for a considerable write-through replacing the generic
node_rx_hdr with node_rx_pdu when relevant and needed.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Use CONFIG_BT_CTLR_CENTRAL_ISO instead of CONFIG_BT_CENTRAL in
declaring central CIS CREATE procedure context data. In some configs the
size of this data structure is bound by central CIS CREATE, so doing it
correctly will save memory in the procedure context allocation.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
If central initiates incompatible procedure after having replied (with
_IND), peripheral fails to disconnect as spec'ed.
Fix by correctly setting the INCOMPAT flag to reserved on IND receipt to
enforce the disconnect.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
It's needless complexity, and the terminology clashes with
Bluetooth (HCI frags).
It has one user, IPSP, that is going away soon.
Removing frag support will allow a future optimization, removing the
need for HCI and L2CAP fragment buffer pools, saving memory.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Remove IPSP support from the tree.
It has no maintainers, and is regularly broken. The fact that it's
nontrivial to set-up in linux makes it hard to fix reported issues.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
By exposing the underlying iso channel, the application can retrieve
properties of the iso channel.
This can be useful in case the application wants to use the connection
handle for vendor specific HCI commands or to retrieve the particular
parameters used for the given channel.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
The bt_debug_dump_recv_state did not care if the receive
state being dumped to log was active or not, and if it was
not actice, then it may just contain random data.
Added a check to see if it was active.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The cap_initiator unicast_stop command will now stop
all streams by default, without supplying the "all" argument.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Some part of the descriptions were wrong. Also, the description of
`BT_BUF_ACL_RX_SIZE` was too verbose and no longer needed with the
updated L2CAP documentation.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
The buffers for the PBP advertising data as well as the
buffers for the BASE periodic advertising data were
not cleared, so calling the functions multiple times
would simply append the data rather than just setting
the new data.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There are devices that will send empty SDUs instead of
empty PDUs, and while that should be harmless, it is nice
to know what is going on, and we may want to deal with
empty SDUs and empty PDUs differently.
This also modifies the state for TS and PSN to only be
applied for valid ISO packets.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
It is a common occurance that a specific type is not
found in the codec configuration, and the main way of
knowing that is by calling the function.
The debug log does not help debug anything (as it does also
return a specific error code), but rather just clutters up
the log if enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When returning an error code directly to an application
in the API, it should not log as a warning or error.
The lack of PAC records is also reported directly to the
application, and is not an error (in fact it is valid not to have
e.g. sink or source pacs).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add printing of the broadcast ID and whether an existing PA
sync was found in the bap_broadcast_assistant_recv_state_cb
function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bap_broadcast_assistant mod_src command can now take "unknown"
as a value to supply BT_BAP_PA_INTERVAL_UNKNOWN to the scan
delegator.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The documentation for the command
bap_broadcast_assistant broadcast_code
was incorrect and has been fixed.
Additionally, and example of the command has been added
in the shell documentation.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When a PA is synced via PAST, the receive state does not
have a PA sync object, and the address and SID must be
used.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The audio configuration 5 is defined to have 2 sink channels
per stream and 1 source channel per stream.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If pa_sync_past returns 0 then that means we are ready to
sync to past, and the BT_BAP_PA_STATE_INFO_REQ state should be set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds the CAP Commander Change Microphone Mute procedure.
This procedure changes the microphone mute state on one or more
CAP Acceptors.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a check for checking duplication when adding a source in the
broadcast assistant, as per requirement in BAP 6.5.4. It is not
permitted to add a source such that a combination of broadcast_id,
adv_sid and address type would result in same triple of values.
Added a recv_state struct to cache these values when read, and moved
past_avail and srd_ids into this as well.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
For BR/EDR L2CAP, if the function bt_l2cap_br_chan_send_cb
instead of bt_l2cap_chan_send is called, the ACL conn and
L2CAP chennel status will not be checked.
Check conn/channel status before sending data in
function bt_l2cap_br_chan_send_cb.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Change the receive workque name to "BT RX WQ" to distinguish it from the
receive thread, and the long workque one to "BT LW WQ" to make the
format consistent with the other Bluetooth threads.
On an nRF52 now "kernel stacks" looks like:
0x200016c8 BT RX (real size 448): unused 280 )
0x20001780 BT RX pri (real size 448): unused 224 )
0x200012c0 BT RX WQ (real size 2240): unused 1360 )
0x20001208 BT TX (real size 768): unused 408 )
0x20001130 BT LW WQ (real size 1344): unused 408 )
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Added a check for duplication of add source operation in the Scan
Delagator. BAP 6.5.4 states that an assistant may not perform add
source operation if it results in a duplication of a source. While
this is not mentioned for the Scan Delegator, the spirit of the spec.
must be that no duplications can exists in the recv_state, which is
what this commit fixes.
Signed-off-by: Fredrik Danebjer <frdn@demant.com>
This commit removes `bt_hci_evt_get_flags`, and the associated flag
symbols. These symbols no longer serve a purpose in the driver interface
after the removal of `bt_recv_prio` from the interface.
The implementation of `bt_hci_evt_get_flags` is distributed to its
still-existing use sites, `hci_core` and the `hci_driver` in the
controller.
The duplication of code is intentional. This is no longer part of any
interface, and the host-developers expect the host copy of the function
to change or dissapear entierly. This will allow the host implementation
to progress without fear of breaking the controller implementation.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Remove `bt_recv_prio` from the HCI driver interface. It's primary
purpose was to be used in conjunction with `CONFIG_BT_RECV_BLOCKING`,
which has been removed.
`hci_raw.c` provided a adapter implementation to make drivers
implementing the `CONFIG_BT_RECV_BLOCKING` interface useable with
`CONFIG_BT_HCI_RAW`. But since `bt_recv_prio` is being removed from the
HCI driver interface, drivers needing the adapter should copy the
adapter implementation as private internals.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
This config selects a variant of the HCI driver interface that spills
out host internals unto the drivers and even the Zephyr controller. It
will now be removed in favor of driver interfaces that hide the
internals of the host.
The new default is `CONFIG_BT_RECV_WORKQ_BT`.
Any references to the removed kconfig are refactored out.
Any out-of-tree driver using the removed interface can be easily adapted
by copying the following implementations into the driver as private
functions:
- `hci_driver.h:BT_HCI_EVT_FLAG_RECV_PRIO`
- `hci_driver.h:BT_HCI_EVT_FLAG_RECV`
- `hci_driver.h:bt_hci_evt_get_flags`
- `hci_raw.c:bt_recv_prio`
In combination these symbols function as a interface adapter. These
symbols will be removed in this PR in subsequent commits.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Check max_tx_octects and max_tx_time are in the valid range, according
to the BT Core spec 5.4 [Vol 4, Part E, 7.8.46]
Fix#70472
Signed-off-by: Sungwoo Kim <iam@sung-woo.kim>
Commit prevents updating replay protection list on any frame came
from the network layer.
Replay protection cache is updated only if
- transport handles transport command without errors
- access layer handles model message without errors
- transport frame has correct length
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Commit adds analyzing of returned status of element rx.
If at least one element receives multicast message then
access layer will return suceess status.
If option CONFIG_BT_MESH_ACCESS_LAYER_MSG is enabled then
access layer will return success always.
Function bt_mesh_access_recv has been introduced to cover
case when real model statuses should be returned over
oppcode aggregator model despite access returns success.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Enables compatibility of NUS for codebases that are not
Bluetooth-centric (e.g: Non-bluetooth samples that use UART over
Bluetooth LE for Console, Logging, Shell, others).
Signed-off-by: Luis Ubieda <luisf@croxel.com>
Enables usage Bluetooth LE GATT as a serial endpoint to exchange data
using UART APIs. This implementation is compatible with UART Interrupt
Driven APIs and uses the nus-uart device-tree node properties to
configure FIFO buffers for transmitting and receiving. Defining
multiple instances of the driver is possible and it allows implementing
multiple GATT NUS service instances to exchange data as separate serial
endpoints.
Signed-off-by: Luis Ubieda <luisf@croxel.com>
NUS is implemented as a Bluetooth LE service, exchanging data treating
the NUS characteristics as Serial endpoints: RX characteristic to
receive, TX characteristic to send binary packets.
This implementation also enables the ability to define multiple
instances of the NUS Service, analogous to mutliple serial endpoints,
to use each one for different purposes. Unless disabled through Kconfig,
NUS instantiates a default instance, similar to what other services do,
which allows users not interested in using multiple instances, to not
worry about the inherent complexities.
Signed-off-by: Luis Ubieda <luisf@croxel.com>
Recently (during Bluetooth UPF), a lot of developers experience
confusion due to weird errors in SMP, etc, which are actually irrelevant
and caused by the connection never having existed.
As a stop-gap measure, until upper layers properly report lower layer
failures, add a warning in the logs to stop wasting developer time.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Since the cap_common.c rely on CONFIG_BT_MAX_CONN, and is
only used for connected procedures, it should be guarded
by CONFIG_BT_CAP_INITIATOR_UNICAST instead of
CONFIG_BT_CAP_INITIATOR
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Increase the timeouts to be 60 instead of 6.
The reason for this is that some controllers (like the Zephyr
controller) will reserve some of these to ensure stability,
and in fact with skip = 5 and retry = 6, it would still
send the PA reports at every interval.
To accomodate a higher timeout value, the functions used to
convert PA intervals to PA timeouts have been updated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is no need to validate stream_param->data if it is NULL.
Fixes failing PTS BAP/BSRC test cases.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
Remove SCO security management code block.
Currently, security related checks are not
necessary. It can be added if needed.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Call bt_sco_server_register to register SCO
server. Manage the SCO connection request.
Get SCO connect/disconnect status via SCO
channel ops.
Notify the uppper layer of the SCO connection
status changes through bt_hfp_hf_cb::
sco_connected and bt_hfp_hf_cb::
sco_disconnected.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Currently, SCO connections and disconnections
are agnostic to upper-layer.
Add two functions, bt_sco_connected and
bt_sco_disconnected, to notify the SCO
connect changes.
For Central side, pass "struct bt_sco_chan"
object when calling bt_conn_create_sco. it
uses to manage the SCO channel for upper-
layer.
For Peripheral side, two functions
bt_sco_server_register and
bt_sco_server_unregister are added to monitor
SCO connection request for upper-layer. The
upper-layer could accept or reject SCO connect
When the connection request received. If the
connect is accepted, the "struct bt_sco_chan"
object could be passed by "sco_server->accept".
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The codecs used for the bap bt_bap_stream_config was only
valid for the lifetime of the procedure, which meant
that by the end of the procedure the stream->codec_cfg
became invalid.
This is fixed by using the pointer provided to the
CAP API, and documentating the lifetime of the codec_cfg.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When calling `mesh prov beacon-listen on` shell command before
provisioning the local device, the stack won't report unprovisioned
beacons. This is because the scanner has not been started yet. This
behavior confuses users. Print a warning that the device needs to be
provisioned first before it can listen to unprovisioned beacons.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
In the simulated bsim boards there is no jittery delay
from a (D)PPI event until a TIMER starts.
The timer starts instantaneously so we do not need to
compensate for it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The building error is reported in Ubuntu if
CONFIG_NET_BUF_LOG is true.
Change __line__ to __LINE__ to fix building
error.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Use the HAL always when setting the TIMERs CC registers,
(also for coded Phy) to ensure things work properly for simulation.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add HCI input parameter validation according to spec for passing
qualification tests.
- Conditional compile of LE Set PA Receive Enable feature
- Store BIGinfo encryption state and number of streams
- Do not report BIGinfo if phy is invalid or unsupported
- Return disallowed ll_read_iso_tx_sync uses sync recever handle
- Validate BIS indices in ll_big_sync_create
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix CIS accepted by Host being failed in the Controller with
reason 0x20 Unsupported LL Parameter Value, by relaxing the
check that the ACL connection is sufficiently placed such
that the time reservation using in the Controller
implementation does not overlap with the CIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add checks for vendor specific data path in ULL and HCI driver, to
enable use of vendor data path for BIS reception.
Signed-off-by: Morten Priess <mtpr@oticon.com>
- Calculate broadcaster channel for control subevent
- Calculate sync receiver channel for control subevent
- Fix broadcast CSTF only set in first subevent
- Remove ctrl_chan_use from LLL, as there is no longer a reason for
storing it.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Update the legacy low latency variant of the ticker
implementation to skip to next periodic interval when
ticks to expire is behind the current tick. This makes
the low latency variant of the implementation consistent
with the default ticker implementation.
Also, cleanup conditional compiles in the implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
My recent change overlooked this configuration, which is not tested in CI
currently.
If someone had enabled it, they would've just gotten an unfixable assert.
The correct test would be checking if the current thread is the system wq,
but I think the compiler can't know that and can't remove the "dead" code.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Add new commands to manage the Encrypted Advertising Data feature.
Overview of those new commands:
- `bt encrypted-ad set-keys`: set key materials (session key and
initialisation vector) used for encrypted and decryption of EAD;
- `bt encrypted-ad add-ad`: store a given advertising data structure;
- `bt encrypted-ad add-ead`: encrypt the given advertising data
structres and store the generated AD structure;
- `bt encrypted-ad commit-ad`: set the AD of the selected advertiser
with the stored AD;
- `bt encrypted-ad clear-ad`: remove all stored AD;
- `bt encrypted-ad decrypt-scan`: decrypt data using the previously set
key materials when receiving AD with type `0x31`.
The documentation of the Bluetooth Shell has been updated to include
those new commands.
Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
When the AUX_ADV_IND and AUX_SYNC_IND are close to each
other, the duration between them is not sufficient to
schedule a new instance of ticker to establish
synchronization. This processing time introduces latencies
detected by the prepare callback.
When the sync offset is low, schedule the start of the
reception to next periodic interval.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing PPI to timer start compensation and missing
inclusion of range delay in the calculation of packet
header receive timeout value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising Parameter check to exclude legacy
high duty cycle directed advertising from validating the
intervals as advertising interval parameter values are not
applicable for high duty cycle directed advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If no callbacks have been registered then callback_list
is NULL, in which case we can skip searching.
This also fixes a NULL-pointer acces in the while loop
as previous_callback would be NULL when it gets
dereferenced as previous_callback->_next.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The BIGinfo PDU bitsets were not accessed in a portable maner for
endianness independence, and need to be handled as bit-manipulations.
Add utility functions to access PDU bitset variables independent of
endianness. Use macros to abstract the offsets and widths.
Conversion of BIG_Handle to LE in HCI layer incorrectly use
sys_cpu_to_le16, which fail because target type is 8-bit.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When the broadcast sink is stopped, the sink was also
set to NULL via
default_broadcast_sink.bap_sink = NULL;
However the lifetime of the broadcast sink does not
follow the state of the streams, and it still exists
afterwards. The broadcast sink can only be terminated
(deleted) via the term_broadcast_sink command.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds the CAP Commander Change Microphone Gain procedure.
This procedure changes the microphone gain on one or more
CAP Acceptors.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Two places we did not have an error check from calling
bt_bap_ep_get_info before accessing the result. These
have simply been added (without an else), as they are
(very) unlikely to fail.
This was caught by coverity and thus fixes those
coverity issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Currently, the upper layer cannot know
whether the data is successfully sent
through DLC.
Add a field "sent" for RFCOMM DLC ops.
Notify upper-layer of the sending
result through the field "sent".
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The fix is to check if any of the adv set's rpa expired
callback returns false, then all adv sets continues with
the old RPA.
Note: Fix is applicable only to adv sets which shares the
same id.
Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
Commit adds const qualifier to models metadata.
Specification claims: Composition Metadata Page 0
shall not change during a term of a node on the network.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Codecs can be printed at different levels:
level 0: Generic and unicast
level 1: subgroup codec configs
level 2: BIS codec configs
This commit ensures that the indentation level
is correctly increase based on where the codec configuration
data is printed.
This also updates the documentation for the BAP shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
print_codec_cfg and print_codec_cap has been modified to print the
codec metadata in a more human-readable way, so it is easier to read.
This also adds the (final) human readable support when
parsing and printing BASEs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
print_codec_cfg has been modified to print the codec configs in a more
human-readable way, so it is easier to read.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
print_codec_cap has been modified to print the remote caps in a more
human-readable way, so it is easier to read and understand the remote
server's capabilities.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify the broadcast_sink_streams to be an array of shell_stream
instead of bt_bap_stream, so that it can be used in a similar way
as the rest of the streams.
To help the transition, a new helper function,
bap_stream_from_shell_stream, was added.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add additional logging in past_available to easily see the PAST
support of the broadcast assistant and scan delegator devices.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The function did not have a NULL check for the parameters,
and thus did not fail correctly on invalid input.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A few paths used only when there is Coded Phy support were
still setting the subscribe registers directly.
Let's use the nRFx HAL for this so it works properly also
in simulation.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Quite a few paths used only when there is Coded Phy
support were still setting the PPI directly.
Let's use the nRFx HAL for this so it works properly also
in simulation.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
During manual testing with UBSAN enabled, it was found that
bt_le_per_adv_sync_cb synced() callback in application
sometimes gets unexpected different values in
`sync_info.recv_enabled` field.
The UBSAN output contained the following warnings message:
runtime error:
load of value 65, which is not a valid value for type '_Bool'
It tunrned out that struct bt_le_per_adv_sync_synced_info sync_info
inside bt_hci_le_past_received_common() contains uninitialized
recv_enabled member.
Set it to true by default to avoid possible issues.
Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
Invalid values should result in BT_HCI_ERR_INVALID_PARAM
The interval check should only fail with
BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL if the requested range
cannot be fulfilled by the controller (ie. there is no overlap
with the supported range)
Fixes EBQ tests HCI/DDI/BI-53-C through HCI/DDI/BI-61-C and
HCI/CCO/BI-64-C
Signed-off-by: Troels Nilsson <trnn@demant.com>
Some pieces of code were missing proper guards for Kconfig
values, which could cause compile issues
The massive amount of #if in bap.c clearly indicates that the
file should be split, as it contains many things that are specific
for various roles.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
While refactoring the handling of callbacks the setting of past_avail
status got deleted (and it was in the wrong place). Adding it back at
the correct place.
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
The existing implementation allows for only one callback per procedure.
This creates problems when for example adding CAP functionality.
The callbacks are here implemented as an SLIST
Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
Out-of-tree controllers do not necessarily mark the LE Set Host Feature
command as experimantal.
Add an additional entry to solve this like done for other ISO entries.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Add support for vendor specific Set Scan Request Reports command and
Scan Request Received Event, available for legacy advertising.
Signed-off-by: Giancarlo Stasi <giancarlo.stasi.co@gmail.com>
The header file l2cap_interface.h has been included by
tests/bsim/bluetooth/host/* cases.
To avoid potential issue, include full path of header
l2cap_br_interface.h in file l2cap_interface.h.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
`att_req_send_process` is not thread safe.
In the case where the current context is pre-emptible (e.g. when a user
sends something over GATT from the main thread):
The iterator in `att_req_send_process` can get interrupted mid-processing,
breaking the logic and resulting in an assert/crash/data corruption.
Additionally, the connection state check in this fn is also not
thread-safe, the RX thread could pre-empt us and disconnect right before
we attempt to send on an ATT bearer that is on it.
This is a hotfix until we have a generalized solution for the host API
surface. It seems a lot of our logic assumes cooperative priority.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
DFD Server, DFU Server, and DFU Client models are extended models
that extend other underlaying models. If BT_MESH_MODEL_EXTENSIONS
is not enabled, extension hierarchy is not initialized and this
results in issues in subscriptions and errors in representation
of hierarchy in CDP1. Since extensions are spec defined, force
selection of this option here to prevent users forgetting about it.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
Fixes issue where it is possible to store the same appkey
multiple times in CDB implementation.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
This was part of the mega hwmv2 commit. Looks like hpet drivers heavily
relies on soc.h. Reverting this for now while we look for a proper fix
and remove reliance on soc.h for drivers.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The dlc->session is invalid in the callback
hfp_hf_disconnected. The behavior of obtaining
an ACL connection handle through an invalid
pointer is unknown.
Add a field "struct bt_conn *acl" to "struct
bt_hfp_hf". Save acl connect handle to "struct
bt_hfp_hf::acl" in function bt_hfp_hf_accept.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Similar to the can_send, the can_recv field indicates whether
or not this endpoint can receive data.
This commit also slightly refactors and optimized how the
can_send field is set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
For dev key encrypiton, BT_MESH_KEY_DEV_REMOTE should be used instead of
BT_MESH_KEY_DEV regardless of whether the destination is a local element
or remote.
BT_MESH_MSG_CTX_INIT_DEV macro selects correct key.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The FICR is also modelled in simulation, but changing this
conditional compile was forgotten, so it was only being
built for real HW.
A test had provided its own version of this function so it would
avoid a runtime warning due to the lack of static address. But
this needs to be removed as it conflicts with the function
provided now always by the nordic controller SW.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Move the nordic and openisa vendor file under ll_sw and add them back to
the list when building for nRF platforms, this was inadvertently removed
in
7bd2804c24 Bluetooth: Controller: Build vendor LLL as library
and is currently causing a:
<wrn> bt_id: No static addresses stored in controller
and random address on nRF devices.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add 2 new Kconfig promptless options that are shorthand
for whether the ISO configuration can support RX and TX.
This also applies these new options as guards for existing
and missing code pieces.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When using the LC3 codec, all codec configuration are LTV encoded.
The broadcast source did not properly validate this, and it also
uncovered a bug in the bsim test for broadcast sources.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The codec configuration data from the BIS in the BASE was not
properly copied to the stream->codec_cfg, and thus it only
contained the subgroup codec configuration values.
This commit fixes that by first copying the subgroup codec
configuration to the stream, and then setting or overwriting
any fields (if they exist).
This requires that each stream have their own codec configuration
struct allocated, so this will slightly increase memory usage.
This also adds verification of the SDU size from the BIGInfo
in the ISO receive callback.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
* Implement LL/IST/SNC/BV-01-C ISO Test Receive
* Refactor data structure for common code between CIS and BIS
Signed-off-by: Mads Winther-Jensen <mdwt@demant.com>
The transfer byte order of SDP is big-endian.
The transaction ID(tid) should be big-endian before
sending.
And tid needs to be converted to CPU byte order
after receiving.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The cmd_sync_broadcast command now also takes an optional broadcast
code, to support syncing with encrypted broadcasts.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Build vendor LLL as separate library so that independent
compiler flags can be supplied if required.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add length checks local to the parsing function. This removes the need
for a separate data validation step.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Add bt_bap_base_subgroup_get_bis_indexes that gets the BIS indexes
of a subgroup. This work very similar to
bt_bap_base_get_bis_indexes, except that it works for subgroups
rather than BASEs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit allows to suspend the mesh stack from `bt_mesh_send_cb`
callbacks by removing the deadlock caused by `k_work_flush` in the
extended advertiser.
In case of the extended advertiser there are 2 cases:
- when the `bt_mesh_adv_disable` is called from any of `bt_mesh_send_cb`
callbacks which are called from the advertiser work item, or
- when it is called from any other context.
When it is called from `bt_mesh_send_cb` callbacks, since these
callbacks are called from the delayable work which is running on the
system workqueue, the advertiser can check the current context and its
work state. If the function is called from the advertiser work, it can
disable the advertising set straight away because all ble host APIs have
already been called in `adv_start` function. Before sending anything
else, the advertiser checks the `instance` value in `adv_start`
function, which is also reset to NULL in `bt_mesh_adv_disable` call, and
aborts all next advertisements. The `ADV_FLAG_SUSPENDING` tells the
advertiser work to abort processing while `bt_mesh_adv_disable` function
didn't finish stopping advertising set. This can happen if the work has
been already scheduled and the schedler ran it while sleeping inside
the `bt_le_ext_adv_stop` or `bt_le_ext_adv_disable` functions.
When `bt_mesh_adv_disable` is called from any other context or from the
system workqueue but not from the advertiser work, then `k_work_flush`
can be called safely as it won't cause any deadlocks.
The `adv_sent` function is inside the `bt_mesh_adv_disable` function to
schedule the advertiser work (`send_pending_adv`) and abort all pending
advertisements that have been already added to the pool.
In case of the legacy advertiser, if the `bt_mesh_adv_disable` is called
form the advertiser thread (this happens when it is called from
`bt_mesh_send_cb.start` or `bt_mesh_send_cb.end` callbacks), then
`k_thread_join` returns `-EDEADLK`. But the `enabled` flag is set to
false and the thread will abort the current advertisement and the
pending advertisements.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The command would attempt to parse the BASE and enter the
subgroup information in a NULL pointer.
The BASE copy was also done incorrectly, as it did not
properly take the UUID into account (which should be
moved to a helper function if we expect users to do this).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Replaced checks for
CONFIG_BT_ISO_UNICAST || CONFIG_BT_ISO_BROADCASTER with
CONFIG_BT_CONN_TX, as they are effectively the same.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit renames a few variables and changes the
type and adds some additional checks.
It moves stream specific data to the shell stream
struct, but still keeps the global values that were used
to initialize the LC3 encoder
The purpose of this is to better allow for a future LC3 decoder
without any clashes in names or the like.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit adds tx power config options for nRF54Hx and nrf54Lx
SoCs, as well as the new radio defines.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
Using the `bap preset` command it is now possible to set all the
codec configuration data and metadata value at runtime. This will
allow to set specific values for each stream in each direction.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of the default presets being pointers, they are changed to
allocated structs so that they can be modified.
This will allow us to modify the config and metadata in a later patch.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit removes extra rescheduling in the extended advertiser after
the last advertising has been finished. This commit also removes the
`ADV_FLAG_SCHEDULED` flag as not needed anymore.
This extra rescheduling and the flag were needed to delay the next
advertisement by 20ms. Now, when the delay is removed the advertiser can
pick the next advertisement from the pool and push to the host right
away.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This patch allows selecting the combination of `CONFIG_BT_RECV_WORKQ_BT`
and `BT_LL_SW_SPLIT`. The implementation of `bt_recv_prio` is copied
from `hci_raw.c`. This ensures the order of packets is the same as when
the controller's `hci_driver.c` is off-chip and sends HCI over UART.
Without this patch, the Zephyr LL driver will duplicate some events on
behalf of `hci_core`. This duplication is not wanted when
`CONFIG_BT_RECV_WORKQ_BT=y`.
The above mentioned duplication is not sound and is evidenced in logged
warnings, e.g. in `tests/bsim/bluetooth/host/l2cap/stress` with
`CONFIG_BT_RECV_WORKQ_BT=y` logging "no transition".
This patch is a step towards the deprecation of
`CONFIG_BT_RECV_BLOCKING`. `CONFIG_BT_RECV_BLOCKING` is complicated and
tightly coupled to `hci_core`. In the future, removing
`CONFIG_BT_RECV_BLOCKING` will give a cleaner separation between
`hci_core` and the drivers and allow `hci_core` to evolve without
changes spilling out into the drivers.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The goal is to not access `buf` in the non-prio `hci_disconn_complete`
so that the buffer does not need to be retained.
This commit moves the copy of `conn->err` to the prio handler.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Fix CONFIG_BT_CTLR_TIFS_HW conditional compile by replacing
DPPI_PRESENT with CONFIG_BT_CTLR_TIFS_HW.
HAL_SW_SWITCH_TIMER_CLEAR_PPI can be same as
HAL_RADIO_END_TIME_CAPTURE_PPI, and this is ok as same
bit will be used to disable PPI/DPPI.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Always execute tx_notify from a single context. For sanity and ease of
debugging / observability.
The previous behavior was calling from BT_RX thread + system workqueue.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
In the function bt_l2cap_chan_set_state, BR
channel is treated as LE Chan.
The BR L2CAP channel state is updated
incorrectly.
Add a function bt_l2cap_br_chan_set_state
for BR L2CAP channel. For BR/EDR channel,
call bt_l2cap_br_chan_set_state directly.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
In the scan delegator when adding a source, the state was not
marked as active before calling the PA sync callback, which
would prevent applications from requesting PAST in that callback.
This commit also adds and fixes a few log statements.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In current implementation, the upper is not notified when BR ACL
connection is established.
L2CAP does not know that ACL connection has been established.
All fixed channels will not be notified. Then The SDP server
cannot work properly.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The print_sirk function that simply logs the SIRK has been removed,
as the SIRK is now directly accessible to the application via the
get_sirk function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds the CAP Commander Change Volume mute procedure.
This procedure changes the volume mute on one or more
CAP Acceptors.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
CDP1 is mandatory to qualify a mesh device for mesh protocol v1.1.
The dependency on BT_MESH_MODEL_EXTENSIONS is removed because if a node
contains only base models (for example Generic OnOff Server), this API
will consume extra RAM bytes which won't be used.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The LE Secure connection (LESC) mask also require encryption,
and some users have been using e.g. BT_GATT_PERM_READ_LESC
without BT_GATT_PERM_READ_ENCRYPT, and then the encryption
check in bt_gatt_check_perm was never properly applied.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The shift is currently necessary due to a mismatch of the
specs and the API, but the shift should not be done when
the value is BT_BAP_BIS_SYNC_NO_PREF as that is a special value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
In the unicast_client_ep_notify we would always call
bt_gatt_get_mtu, regardless of whether data == NULL.
When there is a disconnection, the notify callbacks are
called with data == NULL to indicate a unsubscription.
In the case of the unicast client, this would also trigger
calls to bt_gatt_get_mtu when there is a disconnect, which
in turn would trigger a warning that ATT is not connected.
Postponing the call to bt_gatt_get_mtu fixes this.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This served no purpose for responces. The minimum MTU is sufficient for
all ATT headers.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
When EATT is enabled, bt_att_create_rsp_pdu used to reserve headroom for
the SDU header even when responding on the UATT bearer.
That subtracted from the room for the ATT payload in the buffers. The
remaining buffer size was insufficient to create a PDU of ATT MTU size,
since the exchanged local MTU is calculated the with the assumption that
the SDU header is not present.
This broke the ATT MTU promise, and e.g. our read response will have two
bytes fewer than promised. This caused a failure in PTS.
The new bt_att_create_rsp_pdu pays attention to the bearer type and only
allocates the SDU header on EATT bearers.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
The unicast_stop command takes either "all" or one or more
stream pointers as argument, but the argument handler did
not allow this.
The documentation for the command was also out of date.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The context had a bug where if GMAP was enabled, the context
was only BT_AUDIO_CONTEXT_TYPE_GAME.
The context should also (per BAP spec requirement) contain the
BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED context.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix LLL ISO stream get by group to return stream context
sorted by CIS offset in ascending order.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Broadcast Assistant API should be fully independent of the scan
delegator. Therefore the new struct bt_bap_bass_subgroup has been
defined to avoid a dependency.
Fixes: #68338
Signed-off-by: Ping Wang <pinw@demant.com>
The warning should only apply for configurations where the
device may actually send ISO data (e.g. not the ISO sync receiver).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_iso_chan_send function could take an optional
timestamp by using 0 as an indicator. The issue with
this approach was that a timestamp value of 0 is valid,
and could cause potential issue with syncing streams
in a group.
To fully support transmitting with and without timestamp,
bt_iso_chan_send_ts has been introduced, which is the only
function of the two (bt_iso_chan_send being the other) that
supports timestamps.
A new function, rather than adding a boolean to the existing,
was chosen as it simplifies the individual functions as well
as making it more explicit what the function does.
Since the bt_iso_chan_send function is used by LE audio, both
the BAP and CAP send functions have similarly been updated.
Likewise, all tests and samples have been updated to use the
updated function(s), and BT_ISO_TIMESTAMP_NONE has been
removed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The calculation for BASE_SUBGROUP_MAX_COUNT was off by one.
The macro did not consider the non-subgroup parameters of
the BASE that take up space. This effectively modifies
BASE_SUBGROUP_MAX_COUNT to be 24 instead of 25.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Disable randomization at the access layer in the Remote Provisioning
server when sending Link Stauts message as a responce on Link Close
message and then sending Link Report message right after it. Because of
the randomization, the report message is sent before the status message
which makes MESH/SR/RPR/PDU/BV-03-C test to fail.
This fixes MESH/SR/RPR/PDU/BV-03-C test.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Disable randomization in the access layer when cancelling update in the
distribution server model. This is needed because the server sends 2
messages in a row and the gets reordered by the access layer
randomization feature making DFU/SR/FD/BV-43-C test to fail.
This fixes DFU/SR/FD/BV-43-C test.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
It is unclear from a cursory glance at the code what the caller of
`send_buf(buf)` should do with `buf` based on the returned error codes.
Document when ownership is and isn't transferred to `send_buf()`.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>