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>
The bt_sdp_get_add_proto_param is used to get the protocol
parameter from Additional Protocol Descriptor List.
In order to implement it, one parameter
(proto_profile_index) is added to sdp_get_uuid_data_index
to get the indexed item.
Fix one bug in sdp_get_uuid_data because there may be more
than 2 consequent "seq len item".
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Add a build assert if the device name has been misconfigured. The device
name has a max length of 248. When configured as dynamic make sure that
the initial device length can fit in the dynamic max length.
This prevents us from having to handle length overflow when setting
device name in advertising data which has an 8-bit length field.
Log a warning if failing to set the device name in bt_enable.
Remove unused defines in the shell.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix adv-data command when given arbitrary advertising data in
hexadecimal format. The data_len field should contain the length of the
data which does not include the data type. Instead the AD len field in
the data was given. This caused the AD len field to be increased by 1
in the advertising dat.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In the case where keys are distributed on an unencrypted link,
we got the following call trace:
- bt_smp_recv()
- smp_error()
- smp_pairing_complete()
- bt_conn_security_changed()
- smp_pairing_complete()
- bt_auth->pairing_failed()
- smp_reset()
- bt_auth->pairing_failed()
- smp_reset()
To avoid the second call to bt_auth->pairing_failed()
we validate the that smp flags before calling the callback.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
(Re)setting the connection handle in hci_disconn_complete
should not be done as the handle are used for
logging/debugging purposes after this, and makes it
impossible to lookup the handle of disconnected
connections.
The connection handle is set to 0 during bt_conn_new
in any case.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
No initialisation will lead to undefined behaviour in check for
BT_L2CAP_RECONF_INVALID_MPS.
This is affecting L2CAP/ECFC/BV-23-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Fix missing synchronization when stopping primary and
auxiliary PDU scheduling.
Added implementation to ensure primary and auxiliary event
count match when terminating extended advertising on maximum
number of events or on duration.
Fixes#37571.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Max events and duration parameter are not used in high duty
cycle directed, hence correctly initialized them and not
depend on the caller of advertising start API to set them
to zeroes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
unseg_app_sdu_decrypt decrypts messages in place using a single net_buf.
While this is safe in terms of data access, the buffer state is
manipulated with the assumption that they're two different buffers, and
the output buffer's length field is increased at the end. When
assertions are enabled and the pdu length is 11 or 12 bytes, this
triggers the net_buf length assert, as the decrypt function attempts to
add the pdu length to the out buffer, with the assumption that it was
reset before decryption was started.
Create a separate output buffer with len = 0 to avoid triggering the
assert. Improve readability of the unseg_app_sdu functions to highlight
the need for the additional buffer.
Fixes#37519.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Allow the application to configure the advertiser as scannable when it
does not provide scan data in the call to bt_le_adv_start. This makes it
possible for the application to later add scan response data in the
bt_le_adv_update_data call.
This aligns the legacy code path with the extended code path which
already had this behavior.
This also stops a directed connectable advertiser from being marked
internally in the host as scannable. This appears to not have been
causing any issues.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix non-connectable advertiser configured as ADV_SCAN_IND when
configured by application to have the device name appear in the
advertising data instead of the scan response data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Disallow creating an extended scannable advertiser with the device name
configured to appear in the advertising data.
This would fail in either the call to bt_le_ext_adv_start or
bt_le_ext_adv_set_data when the host would try to set advertising data
in the controller.
Instead this now fails in the bt_le_ext_adv_create call.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
There is a problem with the previous method, that is,
we use the same label(bt_mesh_subnet_cb_subnet_evt) and
put it in the same section, which is not friendly for debugging.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When device is first provisioned with IV Update
flag is set to 0, it should wait for minimum of
96 hours before going into IV Update In Progress
state. Such limit does not apply, if device is
provisioned with IV Update flag is set to 1.
Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
This commit adds missing API that allows to discard the Subscription
List of a vendor model.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Name length can't be longer than 8 bytes. This needs to be clarified
in the bt_mesh_model_data_store() documentation.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Change the fail handling of setting the CIG parameters
(or when allocating the CIS) to unref the ISO conns
instead of calling cleanup on them directly.
This fixes an issue that if the CIG parameters failed,
then the iso conns would not be unref'ed and we could
not try again.
Unref'ing an iso conn will call cleanup once it hits 0
refs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A channel should only be allowed to unbind when in
the BT_ISO_BOUND state. If it is in a disconnected state,
then it the function would have meaning. If it is a connected
state, unbinding it would generate an error when removing
the CIG, which would fail silently.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
LE Set Connection CTE Receive Parameters HCI command size may not fit
into HCI TX command buffer size, which default value is 65 bytes.
For platforms other than Nordic there may be up to 75 antenna IDs
put into the command.
Added new default value for SOCs not compatible with Nordic to
extend default TX buf size to 83 bytes (75 bytes for antena IDs,
5 bytes for other command parameters, 3 bytes for command header).
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add functions that handle enable CTE request control procedure
request from host.
Implementation of ll_df_set_conn_cte_req_enable in ULL is partial.
It will be integrated with refactored implementation of control
procedures.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add struct ll_df_conn_rx_params sturcutre to struct lll_conn.
This is storage for parametrers required to configure radio
for CTE reception in connected mode by lower link layer.
Add required includes to make the controller code compilable
after change struct ll_conn.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
HCI_LE_Set_Connection_CTE_Receive_Parameters handling is required to
enable sampling of Constant Tone Extension in connected mode.
The commit adds handling for HCI_LE_Set_Connection_CTE_Receive_-
-Parameters command.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add struct ll_df_conn_rx_params sturcutre to struct ll_conn.
This is storage for parametrers required to configure radio
for CTE reception in connected mode.
Add required includes to make the controller code compilable
after change struct ll_conn.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add new strcture type for storage of CTE receive parameters.
The structure will be used in to store parameters for connected mode.
The parameters provided by HCI commands for receiving CTE
in connected mode and disconnected mode are a bit different.
There is common subset of parameters but extraction of those
into common structure would increase of size of other stuctures
that aggregate them.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Code related with connected mode was in middle between connectionless
RX and TX. Moved to the bottom of the file.
Added missing compilation guards for ll_df_set_conn_cte_tx_params.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add features: connection CTE request, connection CTE response
and receiving constant tone extensions; to HCI and features
supported by controller.
The features are not enabled yet.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The way we currently handle direction finding extension (DFE) support
on Nordic nRF5 controllers relies on required devicetree properties
related to DFE in the "nordic,nrf-radio" node.
That doesn't make sense on radios without DFE support, though.
Any .dtsi for an SoC without DFE support which has such a node would
require extraneous DFE related properties like dfe-antenna-num.
Instead of making the properties required, mark them optional. We
indicate the presence of DFE support via a new 'dfe-supported' boolean
property which the SoC .dtsi files can set (or not) depending on
support.
This gives us the opportunity to do some cleanup in the Kconfig,
removing CONFIG_HAS_HW_NRF_RADIO_BLE_DF since we know from the
devicetree whether DFE support is available.
Handle that change appropriately in radio_df.c. This gives us an
opportunity to improve readability in the devicetree-related macro
magic in that file.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Fix scan_data_status value from being incorrected OR-ed with
the advertising data status.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Simplify the implementation deciding the use of LLL
scheduling for scanning PDUs with close auxiliary offsets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to release Auxiliary Context on failure
to receive auxiliary chain being in LLL scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We need to alloc node prior to calling lll_scan_aux_setup, otherwise
the same node will be peeked inside that function and it will overwrite
some data in our node (e.g. "extra" field).
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to use LLL scheduling for close auxiliary
offsets when active scanning and initiating connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to resume primary PDU scanning window
after use of LLL scheduling to receive auxiliary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Auxiliary PDUs are scanning by the primary scan's LLL
scheduling, then flush the Auxiliary PDUs when processing
them in the ULL instead of using the disabled callback.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This can be used to check if pointer is a valid lll_scan_aux pointer,
e.g. if we need to decide what kind of struct is attached to RX node
for further processing.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We need to reset isr status before returning as otherwise irq will be
triggered over and over again.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to traverse the Extended Active Scanned
advertising PDUs, generate the Scannable Advertising and
Scan Response Advertising Report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Extended Active Scanning hold back the received PDUs in
a linked list and send it to HCI together so that fields
present across these PDUs can be aggregated for generating
the LE Extended Advertising Report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Flush the scanned advertising PDUs to HCI while receiving
the scan response PDU when Extended Active scanning.
This reverts earlier implementation to remember the
advertising PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Extended Active Scanning and generation of
Extended Advertising Report with Scan Response event type.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reverting Extended scanning with LLL scheduling as this is
causing unresolvable merge conflict with the commits that
is implementing the Extended Active Scanning support.
Subsequent commit add the revert implementation back again.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.
Note that the include to subsys/bluetooth has been
moved from under drivers/bluetooth to subsys/bluetooth,
as it is actually the subsystem's job to make sure
the include directories are correct.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Make subsys/bluetooth/audio build as a static library.
This is in preparation to enable building the bluetooth
drivers as a static library. That would change the line
"zephyr_include_directories(subsys/bluetooth)" where
this include path is applied to all code compiled.
Its removal will result in subsys/bluetooth/audio not
able to find subsys/bluetooth/common/log.h. So change
subsys/bluetooth/audio to be built as a static library
so it can link to the subsys/bluetooth library where
it can find "log.h" there.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Fix a race condition that caused the Controller to deadlock
waiting for a semaphore that be given when LLL events have
been disabled.
ULL reference count is checked in thread context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL execution context which prevents the
set `disabled_cb` function not being called due to no
pending event to produce the done events.
Fixed by re-checking if reference count is zero and avoid
waiting to take the semaphore.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
While RADIO_DFECTRL1_TSAMPLESPACING and RADIO_DFECTRL1_TSAMPLESPACINGREF
has similar values, but they are logically different.
As expected by "radio_df_ctrl_set" function, TSAMPLESPACING should be
passed to this function not TSAMPLESPACINGREF.
Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
When events are placed back into pipeline as resume events,
only remove duplicate resume events and not new prepare
events that may have been enqueue between the start of the
pre-empt ticker and its timeout.
Due to new prepare events that was removed, extra done
events generated cause the number of enqueued done events
to overflow and assert.
Fixes#36381.
Fixes#37597.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the incorrect iterator index being reset when flushing
duplicate resume events in the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the AD data race condition handling with explicit
revert of `pdu->last` value after detecting the race.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce the Rx window swithch overhead for continuous scan by
using radio interfae `radio_tmr_start_now` that accounts for
any minimum ticker offset requirement.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the radio software switch from Rx to Tx when in
passive scanning, as there is no transmission requirement
after reception of a PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The new JIT scheduler does not have slot reservation, which means that
the ticker extension feature for automatically re-scheduling a colliding
non-anchored event, e.g. ADV, cannot be used.
This implementaion reacts to ADV envent done with result ABORTED or
TOO_LATE, and in those cases attempts to re-schedule the ADV event again
within the 10 ms pertubation window.
As the original scheduling, the re-scheduling is randomized, so there
is no absolute predictability as to how many attempts will be made. The
advertiser will attempt with randomly delayed re-schdules until the
window is exhausted.
If re-scheduling is unsuccessful, the weight of the ADV event is
increased, improving it's chances of success in the next event.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This migrates all the current iterable section usages to the external
API, dropping the "Z_" prefix:
Z_ITERABLE_SECTION_ROM
Z_ITERABLE_SECTION_ROM_GC_ALLOWED
Z_ITERABLE_SECTION_RAM
Z_ITERABLE_SECTION_RAM_GC_ALLOWED
Z_STRUCT_SECTION_ITERABLE
Z_STRUCT_SECTION_ITERABLE_ALTERNATE
Z_STRUCT_SECTION_FOREACH
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Currently, with EATT enabled, when bt_gatt_read is called with multiple
handles first it'll try to use gatt_read_mult_vl, and if it fails
gatt_read_mult will be used to try again. Add option to skip
the gatt_read_mult_vl and use gatt_read_mult right away. This is needed
by tests that expect BT_ATT_OP_READ_MULT_REQ but support variable
lenght, thus don't return BT_ATT_ERR_NOT_SUPPORTED.
Removed fallback from read multiple vl to read multiple on
BT_ATT_ERR_NOT_SUPPORTED error.
This was affecting:
GATT/CL/GAR/BV-05-C, GATT/CL/GAR/BI-18-C, GATT/CL/GAR/BI-19-C,
GATT/CL/GAR/BI-20-C, GATT/CL/GAR/BI-21-C, GATT/CL/GAR/BI-22-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Fix the node rx memory pool corruption regression introduced
due to same peer connection being rejected.
Regression introduced in commit 30f260dfaa ("Bluetooth:
controller: Fix adv/scan context access post release").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When a new radio event is scheduled with a relatively short
preempt timeout while there is already a started preempt
ticker, then stop the ticker, abort the previous event that
requested the preemption, and request to start ticker with
the new relatively short preempt timeout.
Fixes#30245.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When there are multiple events in prepare pipeline then fix
the implementation so that only one preempt ticker start
or stop operation is enqueued towards ticker_job for
processing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If HCI LE Set Extended Advertising Enable command is sent
again for an advertising set while that set is enabled, then
any change to the random address shall take effect.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Permit enabling already enabled advertising. Enabling
advertising when it is already enabled can cause the
random address to change, as specified in the Bluetooth
Specifications.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The latest MESH.TS 1.0.1.2 4.15.10 Appkey List Procedures
MESH/NODE/CFG/AKL/BI-04-C
Verify that the IUT can respond to an Config AppKey Add
message with NetKeyIndex and AppKeyIndex already stored.
6. Repeat step 1 with the same AppKey, the same
AppKeyIndex, but NetKeyIndex field set to 0x001.
7. The Lower Tester expects the IUT to respond
with an Config AppKey Status message with the
Status field set to 0x04 (Invalid NetKey) and
the NetKeyIndex and AppKeyIndex values equal to
those sent in step 5.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix the missing resumption of connectable advertising and
release of received connection complete buffers from LLL
after detecting connection from same peer.
Relates to commit 010c5c2f20 ("Bluetooth: controller:
Ignore connections from same peer").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a check for the mandatory channel receive callback when the
application provides the L2CAP channel operations.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds defines for ECC public keys, private keys, DH keys and key
coordinates. Replaces raw numbers throughout.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Remove compilation warning about adv_sync_pdu_ad_data_set function
that is defined but not used.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction finding functionality allows to send a number of periodic
advertising PDUs in a chain that have CTE.
Disable sending CTE requiers additional steps while removing
cte_info from periodic advertising chains.
Removal of cte_info fields may be just delete of that filed
from extended advertising header. In case the PDUs are empty
PDUs created just to transport CTE. Those PDUs should be removed
from a periodic advertising chain.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add release of chained PDUs by lll_adv_pdu_and_extra_data_-
latest_get function. It is requier to release unused
PDUs from a chain to avoid PDUs leakage.
It maight happen when chained PDUs were used by Direction
Finding, then lll_adv_pdu_and_extra_data_lates_get is used
instead of lll_adv_pdu_lates_get.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To check if advertising PDU is empty we can compare its length to 1.
To avoid use of magic number, the commit provides a macro for that
purpose.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction finding functionality allows to send a number of periodic
advertising PDUs in a chain that have CTE.
ll_df_set_cl_cte_tx_enable function was changed to update periodic
advertising chain to include cte_info field. If the chain is too short,
there is less PDUs in the chain than requested number of CTEs,
the function will add new empty PDUs to the chain end.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Enabling or disabling transmission of Constant Tone Extension with
periodic advertising PDUs requires update of a PDU content.
CTE_INFO field of periodic advertising PDU must be filled with
appropriate data. That operation may be done for periodic
advertising PDU (or chain of PDUs) filled with other payload that
wasn't enqueued towards LLL. In that situation PDUs are updated
in place, to avoid increase of memory consumption.
The commit changes ull_adv_sync_pdu_set_clear function to
make possible update of the advertising PDU in place.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Some functions, provided to handle changing content of periodic
advertising PDUs, were defined as static.
Code responsible for handling direction finding updates periodic
advertising PDUs also. For that purposes, those functions were mede
globally accessible.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add configuration of CTE for periodic advertising chain transmission.
The commit provides configuration of radio in prepare stage and
in handle of Tx ISR. CTE is configured only for PDUs that
have cte_info field in extended advertising header.
During prepare of periodic advertising event there are updated
aux_ptr fields in extended advertising header in other PDUs from
a periodic advertising chain. aux_ptr offset value also depends
on CTE length. CTE configuration is always the same for every
PDU in periodic advertising chain.
CTE may be added to requested number of PDUs in periodic
advertising chain. Although it is possible that there are PDUs
that don't have CTE. PDUs that have CTE are alsways at the beginning
of a periodic advertising chain.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Configuration of CTE for transmission is stored in extra_date member
of a lll_adv_sync object. PDUs in periodic advertising chain share the
same CTE configuration, so there is single instance of the extra_data.
To configure CTE transmission for every PDU in periodic advertising
chain a new function was introduced to peek extra_data instance without
peeking new PDU.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Transmission of Constant Tone Extension is done after END event
triggered by radio. To correctly switch from TX to TX (back 2 back
TX) after transmission of CTE PHYEND event must be used instead of
END event.
The commit provides required function that allows LLL to correctly
setup radio to do back to back switch of TX when CTE transmission
is enabled.
The radio_switch_complete_and_phy_end_b2b_tx cannot be implemented
in radio.c source file. It will fail build of unit tests targeted
for NRFBSIM simulator board. There is no RADIO_SHORTS_PHYEND_DISABLE_Msk
macro defined in bsim_hw_models module.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Amount of memory allocated for advertising PDUs (including
periodic advertising) depends on two factors:
- maximum advertising data length
- maximum number of CTE in a periodic advertising chain.
Maximum advertising data length is divided by maximum size
of a single fragment (number of payload bytes that single
advertising PDU may hold) to get required number of fragments.
Actual number of PDUs allocated for advertising is maximum
of acutal number of advertising payload fragments and maximum
number of CTEs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add possiblity to configure maximum number of PDUs with Constant Tone
Extension in a single periodic advertising chain.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
We had added a break in a switch statement that stopped
ISO channels from setting the BT_CONN_CLEANUP flag
which in turn stopped them from disconnecting (in the
eyes of the upper layers) properly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of just writing "err" we make it clear that it is
the ISO server that failed to accept.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add implementation to resume primary PDU scanning window
after use of LLL scheduling to receive auxiliary PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Auxiliary PDUs are scanning by the primary scan's LLL
scheduling, then flush the Auxiliary PDUs when processing
them in the ULL instead of using the disabled callback.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This can be used to check if pointer is a valid lll_scan_aux pointer,
e.g. if we need to decide what kind of struct is attached to RX node
for further processing.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We need to reset isr status before returning as otherwise irq will be
triggered over and over again.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in adv timeout for limited advertiser when extended advertising
features has been enabled. The advertiser was only stopped when
configured as an extended advertiser. It should be stopped when
configured as a legacy advertiser also.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the received Extended Advertising PDU's address
resolution latency due to missing reset of pending IRQ in
the NVIC which caused the wait loop from not exit correctly.
Fixes#30243.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When generating LE Extended Advertising Report the device
address can be either in primary or auxiliary channel PDU,
do not overwrite resolving list index if present in primary
channel PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix key distribution not calling pairing complete callback when
distributing encryption information when not bonding.
Encryption information is only distributed in legacy pairing so issue
was only seen during legacy pairing.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The existing extension tree does not support all the features that are
defined by the specification (e.g. multiple parents).
This patch approaches this problem by defining a circular single-linked
list of extension models. So for a given model, all models that are on
the same list as that model are in some extension relationship with that
model. All models on a list represent a single connected component of an
extension graph but without defining specific relationships between each
pair of models. This list is used to manage a shared subscription list
as per the Mesh Profile Specification:
```4.2.4 Subscription List
Within an element, each model has a separate instance of a Subscription
List, unless the model extends another model on that element. Instances
of models that extend other models (i.e., all models within an extension
relation tree) shall share a single instance of a Subscription List per
element.
```
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
The Bluetooth Core spec 5.2 requires to provide CTE type in
periodic advertising report.
The implementation of le_per_adv_sync_report assigned
value zero to be default CTE type. The assigned value
in Bluetooth Core spec 5.2 means "AoA Constant Tone
Extension". In case there is no CTE attached to periodic
advertising PDU, CTE type should contain value 0xFF.
This commit fixes the issue.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix compilation warning in hci_df_set_cl_cte_rx_enable function.
The struct bt_hci_cp_le_set_cl_cte_sampling_enable *cp variable
was used just to evaluate size in bt_hci_cmd_create call.
The variable is moved to prepare_cte_rx_enable_cmd_params
function and size of the buf is evaluated directly from type.
Code is simpler and prepare_cte_rx_enable_cmd_params does not
require passing additional argument.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
It is desirable to have the read and write like functions follow the
POSIX read and write parameter types.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
There were missing calls to periodic advertising functions:
lll_adv_sync_init() and lll_adv_sync_reset() corresponding
functions in lll_adv.c.
Lack of those calls didn't introduce any harm.
I've added them to have complete init and reset patch,
similar to extended advertising implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There is missing handling of periodic advertising reset for
HCI_Reset command. That makes impossible to execute e.g.
qualification tests without rebooting of the DUT
for periodic advertising and direction finding.
This commit adds missing implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
There was an issue with receiving CTE packets when the time
slot has changed from 2us to 1us. After receiving the packets
when it tries to enable receiving of CTE, the validator
returns EINVAL error.
Source of the problem is "validate_cte_rx_params" function,
it calls DF_AOA_RX_1US_SUPPORT(df_ant_info.switch_sample_rates)
which is expanded to:
((df_ant_info.switch_sample_rates) & BIT((BT_HCI_LE_1US_AOA_RX)))
And due to definition of BT_HCI_LE_1US_AOA_RX in hci.h it will be:
((df_ant_info.switch_sample_rates) & BIT(BIT(2)))
So the BIT operation has executed two times.
Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
When in le_ecred_reconf_req multiple CIDs are received host should
return 0x0002 error (Reconfiguration failed - reduction in size of
MPS not allowed for more than one channel at a time).
This affects test L2CAP/ECFC/BI-04-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
In limited advertising advertising should end after certain timeout.
Previously, limited advertising was just general advertising with
BT_LE_AD_LIMITED flag set. Now, if this flag is set the work is
scheduled, that will disable advertising after timeout.
This affects tests GAP/DISC/LIMM/BV-03-C and GAP/DISC/LIMM/BV-04-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Flush any pending Tx PDUs in the lower link layer before
enqueueing PHY_UPDATE_IND PDU with instant to ensure the
PDU is transmitted before the instant occurs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement the advanced scheduling for Extended Initiator to
group central connections established to Extended
Advertisements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
To be consistent in how order header flags are handled when
updating the common header format fields, explicit check
for ADI flag in previous auxiliary PDU buffer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remember last used DID for each SID, so that DID value used,
when updating the advertising PDU fields, change between
consecutive changes to PDU fields.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Make the Extended Advertising DID value updated to be unique
for every new advertising set created.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix corrupt AD data used after directed advertising by
storing a backup of the AD data before switching to directed
advertising. Restore back the AD data with switching to non-
directed advertising.
The fix also addresses AD data backup when switching between
Legacy and Extended Advertising.
Fixes#18850.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to resolve AdvA in the received
AUX_CONNECT_RSP PDU before generating the connection
complete.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If BT_ISO is enabled we now compile conn.c which contains a
lot of functionality used by BT_ISO, even for broadcast-iso
builds, i.e. builds that do not require BT_CONN.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the guard such that the iso_mtu and iso_pkts are
not guarded by BT_CONN as they should be available for
iso broadcast-only builds.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add the bt_acl_recv function that works similar to
bt_iso_recv but for ACL data only, simplying the
generic bt_conn_recv function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the bt_conn_disconnect and conn_disconnect functions
to the ACL group.
Also adds a guard in the iso.c file for connected ISO.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the notify_le_phy_updated, notify_le_data_len_updated,
notify_le_param_updated, notify_remote_info,
notify_disconnected and notify_connected functions
to the ACL group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the deferred_work callback function to the ACL group.
This also moves the static function conn_lookup_iso
which is only called form deferred_work.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the bt_conn_lookup_state_le, bt_conn_lookup_addr_le and
bt_conn_is_peer_addr_le functions to the ACL group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the bt_conn_get_tx_power_level and
bt_conn_le_get_tx_power_level functions to the ACL group.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Start a group of functions guarded by CONFIG_BT_CONN
that are for connected-only functions. This is a
preparation step for allowing compilation and usage of
conn.c for ISO broadcast-only builds.
Moving all connected-only functionality into a single
group will also allow a possible move of all those
functions into an connected (ACL) only file.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add missing API:
- Delete all group addresses in a SIG model's subscription list
- Update a network key
- Update an application key
- Get/Set Node Identity parameters
- Set virtual addtess for a SIG model
- Get/Set Key Refresh Procedures
Signed-off-by: Agata Ponitka <agata.ponitka@codecoup.pl>
The functions to check advertising and target address in a
PDU are used only inside the same file, hence make them file
static functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add target address check to extended scanning implementation
to detect invalid target address present in primary and
auxiliary channel PDU. Implementation is reuse of the check
used in the initiator after refactoring to pass parameter to
differentiate, its use for primary or auxiliary channel, and
for scanning or initiating.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added bt_mesh_msg_send() which can be used by the application to
directly send model layer messages without local instantiation of
related models. Also added bt_mesh_msg_cb_set() which allows the
application to recieve mesh model layer messages without local
instantiation of related models.
Added bt_mesh_has_addr() which returns a bool. For unicast addresses,
this returns whether or not bt_mesh_elem_find() was successfull. If the
above mentioned bt_mesh_msg_cb_set() has been used by the application to
set a message callback, this returns true so that the stack attempts to
push every model message up to the application via the callback. If no
callback has been set, group addresses are searched to see if the stack
should pass the message up the stack to an instantiated model.
These changes allow applications that do not or can not instantiate
models to interface with models in a mesh network. This is applicable to
applications which act as a Bluetooth mesh gateway, sniffer, debugger,
network monitoring, non-mesh relay/extender, etc.
In app_keys.c friend.c net.c bt_mesh_elem_find() is used only to
determine the existance of an address. The full return value of
bt_mesh_elem_find() is unecessary and so was replaced by the above
mentioned bt_mesh_has_addr() function in these instances.
Simplified bt_mesh_elem_find() by removing the search through group
address. Since the above mentioned bt_mesh_has_addr() function handles
instances where group addresses must be searched, it was no longer
necessary to preform this search in this function.
Signed-off-by: Bud Wandinger <bud@budkoembedded.ca>
Because we use the extended kconfig, we have already
supported relative paths, and it is clearer to use
relative paths in the bluetooth submodules.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Zephyr Bluetooth Low Energy Controller for mesh stack
uses pre-emptible continuous scanning, allowing advertising
events to be transmitted without delay when advertising is
enabled. No need to compensate with scan window duration.
Zephyr Bluetooth Low Energy Controller built for nRF51x
SoCs use CONFIG_BT_CTLR_LOW_LAT=y, and continuous scanning
cannot be pre-empted, hence, scanning will block advertising
events from being transmitted. Increase the advertising
duration by the amount of scan window duration to compensate
for the blocked advertising events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Disable use of BT_CTLR_SCAN_UNRESERVED with BT_CTLR_LOW_LAT.
nRF51x SoC needs to block any CPU use inside radio events,
hence use of radio without time reservation is required for
proper functioning of Controller in nRF51x.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds length defines for all provisioning PDUs and uses them to split
prov_link.conf_inputs into separate fields.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add guards to the structs. This has two purposes:
1) Reduce size of only one of them are enabled
2) Fix a compile issue if only one of them were enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add guards to the structs. This has two purposes:
1) Reduce size of only one of them are enabled
2) Fix a compile issue if only one of them were enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If either AICS or VOCS clients were not enable, then the VCS
client could not be enabled as there was a compile error
in the function that registered callbacks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix HCI Reset Command from asserting when there is pending
connection creation requested on coded PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of legacy advertising PDU length
when advertising sets are reused between extended and legacy
advertising modes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use CONFIG_BT_CTLR_BROADCAST_ISO when CONFIG_BT_CTLR_ADV_ISO
or CONFIG_BT_CTLR_SYNC_ISO Kconfig option is supported.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added Bluetooth Specification references to the
implementation of Channel Selection algorithm #2 in the
Controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implement the functions required to calculate the SubEvent 1
and SubEvent n mapped channel indices.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add the check for mixed use of Legacy vs Extended HCI
commands for Periodic Advertising related HCI commands.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix extended advertising report to set the directed bit in
the event type when receiving directed non-connectable
advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix extended advertising PDUs seen after the advertising
duration has elapsed, by considering the events skipped
due to overlap with other events which is provided by
the ticker lazy parameter.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add checks for invalid PHYs supplied to HCI LE Extended Scan
Parameters and LE Extended Create Connection commands.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After extracting from ull_adv_sync_pdu_set_clear functions:
ull_adv_sync_pdu_alloc, ull_adv_sync_extra_data_set_clear
Use of ull_adv_ext_hrd_data structure became unnecessary.
The extra_data member of the structure was never used
due to separate function responsible for setting extra_data
content.
In all cases content for extended advertising header fields
may be passed to the ull_adv_sync_pdu_set_clear directly
as void * pointer, instead of pointer to ull_adv_ext_hdr_data.
This simplifies use of ull_adv_sync_pdu_set_clear as well
as removes unneccesary code to handle special structure type.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
extra_data is not used by ll_big_create and ll_big_terminate.
extra_data_prev and extra_data_new are optional arguments for
ull_adv_sync_pdu_alloc.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
ull_adv_sync_pdu_alloc function was extracted from ull_adv_sync_pdu_-
-set_clear function. The arguments list of ull_adv_sync_pdu_alloc
was derived from source function but the acutal functionality is
only part of what it was before.
The ull_adv_sync_pdu_alloc does not change extended advertising
PDU header fileds. The hdr_add_fields and hdr_rem_fields arguments
were used to allocate or not allocate memory for extra_data related
with new periodic advertising PDU. Also hrd_data pointer was
not used by the function.
The function arguments list was simplified.
New enum ull_adv_pdu_extra_data_flag was introduced to provide
named flags for extra_data memory management.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Refactor Periodic Advertising time update function to use
caller supplied Periodic Advertising PDU to calculate the
time reservations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Apply suggestions from code review, and change to using
BT_HCI_ERR_SUCCESS instead of returning 0.
Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended and Periodic Coded PHY time reservation. The
define earlier used does not have calculations for Coded
PHY.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to update Periodic Advertising time
reservations when advertising data and/or CTE length is
updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add check for already enabled and started Periodic
Advertising when HCI LE Set Periodic Advertising Parameters
command is called.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out Periodic Advertising time calculations so that
it can be reused when PDU length is updated as part of
advertising data updates.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to update Extended Advertising time
reservations when advertising and scan response data are
updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Export the function calculating the primary channel
advertising event time reservation, so that Extended
Advertising implementation can reuse it.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out Extended Advertising time calculations so that
it can be reused when PDU length is updated as part of
advertising data and scan response data updates.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation to update legacy advertising time
reservations when advertising and scan response data are
updated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out advertising time calculations so that it can be
reused when PDU length is updated as part of advertising
data and scan response data updates.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use a conservative turnaround time of 150us covering slower
nRF51 and faster nRF52 CPU that influence the turnaround
timing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The Bluetooth 5.3 specification was recently released, and
has a new version identifier (12) assigned to it in the
Bluetooth Assigned Numbers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There was an issue with wrong length of CTE send in connectionless
mode, with periodic advertising PDUs. Radio peripheral was not
configured to send CTE with correct length while PDU had CTEInfo
field informing receiver that CTE is attached to the PDU.
Source of the problem was in ll_df_set_cl_cte_tx_enable function.
Order of parameters in ull_adv_sync_pdu_alloc was wrong.
ULL_ADV_PDU_HDR_FIELD_CTE_INFO was speficed as hdr_rem_fields.
Because of that extra_data, memory used to provide CTE configuration
to LLL, was not allocated. PDU content is prepared in ULL, so CTEInfo
field included correct information, while Radio was never configured
by LLL to send CTE.
ull_adv_sync_extra_data_set_clear received a pointer to hdr_data,
instead of a direct pointer to df_cfg structure. When extra_data
was allocated correclty, wrong CTE configuration was provided
copied there and LLL received invalid CTE length. It was different
than the length in PDUs CTEInfo field.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
According to spec we should ignore messages with incorrect msg size.
This patch adds a check to every opcode handler.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
```
3.7.3.4 Message error procedure
When receiving a message that is not understood by an element, it shall
ignore the message.
Note: A message can be falsely identified as a valid message, passing
the NetMIC and TransMIC authentication using a known network key and
application key even though that message was sent using different keys.
The decryption of that message using the wrong keys would result in a
message that is not understood by the element. The probability of such a
situation occurring is small but not insignificant.
A message that is not understood includes messages that have one or more
of the following conditions:
• The application opcode is unknown by the receiving element.
• The access message size for the application opcode is incorrect.
• The application parameters contain values that are currently
Prohibited.
Note: An element that sends an acknowledged message that is not
understood by a peer node will not receive any response message.
```
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Align the capitalization of the term "Bluetooth Mesh" to Bluetooth mesh"
in the documentation. This is done to to match the new updated naming
convention done in Bluetooth SIG. In the upcoming spec versions, it its
used "Bluetooth mesh" with the lower case convention.
Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Fix Periodic Synchronization setup when handling invalid
number of channel count in Periodic Advertising's Sync Info
structure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use macros to access SCA and Channel Map fields in the Sync
Info structure in advertising PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Based on review comments, refactor out sync_info population
to be performed by the caller of the function that prepares
the extended advertising PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the set/clear function to modify the common extended
header format in the PDU to add/remove ACAD.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to add/remove ACAD field in the common
extended header format of the periodic advertising PDU on
create/terminate BIG.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add CMake warning message when building experimental
features like Advertising Extensions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
adv_sync_hdr_set_clear was just wrapped by ull_adv_sync_pdu_set_clear
so we can merge both into single function.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds simple helper to update CTEInfo. It assumes proper periodic
adv PDU as input to simplify code.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds some initial support to update AD in chain. We still only
support placing AD in 1st PDU, but this will properly copy any linked
PDUs that may be added due to e.g. CTEInfo present.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds adv_sync_pdu_init helper which initializes pdu_adv buffer
with contents of AUX_SYNC_IND/AUX_CHAIN_IND PDU. Extended header flags
can be specified to reserve required space for corresponding fields if
necessary.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This enables chaining ota for periodic advertising. AUX_CHAIN_IND PDUs
will be sent automatically if AuxPtr is detected in preceding PDU.
AuxPtr offset is always set to achieve minimal required frame spacing,
i.e. 300us (T_mafs). AuxPtr in all PDUs in advertising train are
updated on enqueue since PDU spacing is already known at that time so
we do not need to waste time in LLL.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds support to allow advertising PDUs to be linked which is
required to send advertising trains, i.e. AUX_CHAIN_IND.
PDUs are linked with a simple single-linked list, the pointer to next
PDU is stored at the very end of PDU buffer. This prevents it from
being overwritten if PDU is modified and allows for build time offset
calculation.
There are few helpers added to make handling easier, e.g.:
- get next linked PDU
- get last linked PDU
- link one PDU to another
- link PDU at the end
- release all linked PDUs (except for 1st)
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This function is the same as lll_adv_pdu_alloc except it also allocates
extra data at the end - it can just use lll_adv_pdu_alloc call to avoid
extensive c&p.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds helper to always allocate advertising PDU either from memory
pool or pdu_free queue and does not reuse existing PDU in adv_pdu.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Advertising channel packets do not have MIC, there's no need to have
extra parameter which always has to be set to 0 anyway.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We previously removed the iso data path when the iso channel
disconnected. Since the iso data path is unique for a given
iso channel (by handle), it does not make sense to remove
it for a disconnected channel, as the channel is, in
a sense, not existing anymore.
This update is to better comply with the bluetooth
core spec, and to avoid getting errors from the
controller on disconnect.
Rather than removing the implementation of being able
to remove the data path, the function was made non-static
and moved to the internal header file, in case we ever
want to use it. This should not affect compile size.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the function from scan.c to hci_core.c.
When in scan.c, the function is only available if
CONFIG_BT_OBSERVER was enabled. Since the function
can be used in other scenarioes where we need to parse
LTV data, it has been moved to a more generic place.
hci_core.c might not be the ideal place, but it is
where most other common bluetooth functions
are located.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The Bluetooth proxy feature includes proxy client and proxy server.
In addition to the proxy pdu message used above, pb-gatt also uses
the same proxy pdu message.
Currently zephyr bluetooth mesh couples them in one file.
A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service and
Mesh Proxy Service.
Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.
Also according to Trond's suggestion:
Rename CONFIG_BT_MESH_PROXY to CONFIG_BT_MESH_GATT.
Create an additional promptless entry CONFIG_BT_MESH_GATT_SERVER
that selects CONFIG_BT_MESH_GATT and is selected by
CONFIG_BT_MESH_GATT_PROXY or CONFIG_BT_MESH_PB_GATT.
Create additional CONFIG_BT_MESH_PROXY used to represent
proxy feature (also include proxy client).
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The Bluetooth proxy feature includes proxy client
and proxy server. In addition to the proxy pdu
message used above, pb-gatt also uses the same
proxy pdu message.
Currently zephyr bluetooth mesh couples them in one file.
A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service and
Mesh Proxy Service.
Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.
Also according to Trond's suggestion:
Rename CONFIG_BT_MESH_PROXY to CONFIG_BT_MESH_GATT.
Create an additional promptless entry CONFIG_BT_MESH_GATT_SERVER
that selects CONFIG_BT_MESH_GATT and is selected by
CONFIG_BT_MESH_GATT_PROXY or CONFIG_BT_MESH_PB_GATT.
Create additional CONFIG_BT_MESH_PROXY used to represent
proxy feature (also include proxy client).
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The Bluetooth proxy feature includes proxy client
and proxy server. In addition to the proxy pdu
message used above, pb-gatt also uses the same
proxy pdu message.
Currently zephyr bluetooth mesh couples them in one file.
A file at the separation is called gatt_services.c,
which is used to contain Mesh Provisioning Service
and Mesh Proxy Service.
Another file in the separation is called proxy_msg.c,
which is used to process Proxy pdu messages.
Also according to Trond's suggestion:
Rename `CONFIG_BT_MESH_PROXY` to `CONFIG_BT_MESH_GATT`.
Create an additional promptless entry
`CONFIG_BT_MESH_GATT_SERVER` that selects
`CONFIG_BT_MESH_GATT` and is selected by
`CONFIG_BT_MESH_GATT_PROXY` or `CONFIG_BT_MESH_PB_GATT`.
Create additional `CONFIG_BT_MESH_PROXY` used to represent
proxy feature (also include proxy client).
see #36343
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Use defines for offset unit and for calculation of Periodic
Advertising window widening using clock accuracy value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix clock accuracy value used in the calculation of window
widening applied when scanning for auxiliary PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a configuration of characteristic access permissions for
Bluetooth Heart Rate service.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Add the ability to perform a write on the object name GATT
Characteristic with a notification callback to the application
that the name has been written.
In order for this operation to work the memory backing the
object name must be modifiable. To prevent forcing the user
to always allocate 120 bytes for the name, the maximum name
length is changed from a define to a configuration parameter.
Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
In case of non-recoverable errors (e.g. the connection breaks while
transmitting), the l2cap_chan_tx_process deques the net_buf but does
not unreference it. As this is inside a work queue thread, the sending
thread gets no information on this error, relying on the tx_process to
ultimately free the buffer.
Signed-off-by: Patrick Rathje <git@patrickrathje.de>
Fix an auxiliary scan context leak when initiator
establishes a connection while there is another pending
auxliary PDU scheduled to be received. In this case, the
pending auxliary scan LLL context does an early abort
without generating a scan aux done event. Missing scan aux
done event caused the auxiliary scan context leak.
Fixes#36131.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit fixes an issue where bt_mesh_reset() call just erases all
mesh flags set at the initialization instead of restoring them and
thus disabling some features until the board reboot.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Minor update to calls to get Tx chain delay in extended
advertising and scanning to use S8 encoding delays.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We need to take RX chain delay and PHY used to receive
CONNECT_IND into account when calculating 1st connection
event offset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the Tx to Rx switch, fix the delay which should be the
Rx ready delay plus the Tx chain delay and plus 4 us active
clock jitter compensation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor cleanup of the implementation of mutual exclusion
of LE Connection Parameter Request amongst active
connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Bluetooth Mesh Vendor model hava company id field.
Accordin MeshPRFV1.0.1 3.7.3.1 Operation codes.
The 3-octet opcodes are used for manufacturer-specific opcodes.
The company identifiers are 16-bit values defined by the
Bluetooth SIG and are coded into the second and third octets of
the 3-octet opcodes.
Therefore, we can speed up the search process by checking whether
CID fields match, rather than comparing opcodes one by one.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Reserve a minimum node rx of 2 that can happen when local
central initiated PHY Update reserves 2 node rx, one for PHY
Update complete and another for Data Length Update complete
notification. Otherwise, a peripheral only needs 1
additional node rx to generate Data Length Update complete
when PHY Update completes.
Relates to #36381.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace the post decrement in loop's conditional into
explicit decrement inside the loop so as to avoid
decrementing the maximum count without enqueueing free rx
buffers into the free rx buffer MFIFO.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The hci_le_remove_cig command shall only be sent as the
master/central. Implemented this by early termination in
bt_iso_cleanup as the slave/peripheral.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix peripheral maximum transmit time, maximum receive time
and radio event length time reservations when connection
established using Extended Advertisements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix central maximum transmit time, maximum receive time
and radio event length time reservations when connection
established using Extended Advertisements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After #35702, the provisioner is unable to mark a link as closed, as
it depends on the send_end callback to be called, so it can start its
timer. PB-Adv keeps a reference to the buffers of reliable messages,
which prevents this callback to be invoked, as the buffer destructor is
never called.
Move scheduling of the retransmit timer to the initial transmission, and
replace the timer based LINK_CLOSE message tx duration with a message
counting solution.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Remove the bt_conn pointer from the AICS API, as the
instance pointer is enough to determine if it is a client
and perform client operations on the cached connection pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Initializes proxy_send's attr pointer, which in theory could be
uninitialized if neither gatt proxy or PB GATT is enabled while proxy.c
is enabled.
This scenario is not really possible with the current kconfig structure,
but is reported as a potential error by Coverity, and should be fixed
for future proofing purposes.
Fixes#36314.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The mute_val pointer could be NULL when dereferenced in the
callback. Change to be a simple value which is just assigned
instead.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a function for the VCS client that gets the bluetooth
connection pointer if a given VCS client instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Update the VCS API to use the bt_vcs struct instead
of the bt_conn. This is create a more simple API
that uses a, remote or loca, instance pointer, rather
than a specified connection (for remote) or NULL (for
local) operations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change to use the generic bt_vcs struct instead of the bt_vcs_client
struct, to align better with the future API change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the type of the vcs_inst in vcs.c to bt_vcs instead
of bt_vcs_server to align better with the future API change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add return of instance pointer in bt_vcs_discover so that a client
will get a bt_vcs pointer when doing discover, which will be
used going forward in the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a bt_vcs struct that represents a VCS instance,
either a local (server) or remote (client) instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Update the MICS API to use the bt_mics struct instead
of the bt_conn. This is create a more simple API
that uses a, remote or loca, instance pointer, rather
than a specified connection (for remote) or NULL (for
local) operations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change to use the generic bt_mics struct instead of the
bt_mics_client struct, to align better with the future
API change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change the type of the mics_inst in mics.c to bt_mics instead
of bt_mics_server to align better with the future API change.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add return of instance pointer in bt_mics_discover so that a client
will get a bt_mics pointer when doing discover, which will be
used going forward in the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a bt_mics struct that represents a MICS instance,
either a local (server) or remote (client) instance.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
- Coverity think it is out-of-bound writing
because the codes write two bytes to address (&hdr->length)
that hdr->length is uint8_t. Coverity doesn't think about
the one more byte after the hdr->length.
- Use net_buf_push to resolve this issue.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Expose a helper function to the application that searches the local
database for the given attribute from its UUID.
Provide arguments to limit the search that matches the service
declaration to make it easy to limit the search to a specific service.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow to pass attribute as NULL pointer when using notify or indicate by
UUID. This will use the entire handle value range to search for an
attribute with a matching UUID.
Document optional parameters, and clarify attr and uuid usage in the
variable declaration in the struct for clarification.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Increase the ticker operations count in ULL high context
when Extended Advertising Connection Establishment on Coded
PHY is supported.
This fixes assertion in Controller when initiating a
connection on Coded PHY, wherein two scan instance ticker,
one window stop ticker, and a new connection instance
ticker operations needs to be enqueued.
Relates to commit a6b8eba7c5 ("Bluetooth: controller:
Implement disabling the other PHY initiator").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a new Kconfig option, BT_ISO_UNICAST, to make it possible
either configure unicast only, broadcast only or both.
This results in some code being moved, but not modified, and
should not effect anything.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
BT_DEVICE_NAME_MAX can be up to 248 bytes. This may exceed ATT MTU size,
which will cause the offset in write_name() to be non zere, resulting in
BT_ATT_ERR_INVALID_OFFSET. However, device name should be writable up to
it's defined size, using subsequent prepare write requests. Error should
be returned if offset exceeds size of device name, and if total size of
new value exceeds BT_DEVICE_NAME_MAX, BT_ATT_ERR_INVALID_ATTRIBUTE_LEN
shall be returned.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Modify the check from checking the feature bit to
checking the command bit. This ensures that we
don't send the read buffer size V2 to a controller
that does not support it.
This also moves the entire ISO init procedure into
a separate function to avoid having a large
ISO-only block in `le_init`.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This check is present in att_read_rsp(), but att_read_mult_req and
att_read_mult_vl_req do not use it. Add this check to these functions.
This was affecting GATT/SR/GAS/BV-08-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
If all connections were refused, we haven't reached part of
le_ecred_conn_req with connecting channels - thus i was never
incremented. PDU shall be created always with the length containing
full size of scid array - we always respond with all of the CIDs filled,
they just will be all zeros when all connections were refused.
This was affecting L2CAP/ECFC/BV-26-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
When an ACL connection with active CISes terminates, inject CIS/CIG
teardown to ensure CIS is stopped before ACL disconnection completes.
This includes stopping CIG ticker when last CIS has stopped.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Maintaining the cis_handles array in ULL/LLL ISO group data amounts to
double book-keeping. This commit eliminates the array and introduces a
'getter' for obtaining CISes owned by a specific CIG, and iterate
through them.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When an ACL changes state to disconnected, all associated ISO channels
must be disconnected and cleaned up. This commit ensures that.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Use ticker_yield_abs interface to make scan window on
primary channel to yield when trying to scan auxiliary PDUs.
Fixes#30244.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add ticker_yield_abs interface to reduce ticks_slot_previous
value when radio events yield/stop earlier than their time
reservations.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The old default of 1 makes provisioner devices useless, as they can only
provision themselves before they run out of space.
Increase the default value for CONFIG_BT_MESH_CDB_NODE_COUNT to 8.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Modify aics.c to use the bt_aics struct instead of the
bt_aics_server struct. This is done so that there is less
difference between the internal struct usage and the struct
type used in the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the struct from bt_vcs to bt_vcs_included, and
rename bt_vcs_get to bt_vcs_included_get as that is more
descriptive of the value returned.
Furthermore, this will also allow us to use bt_vcs as
an opaque pointer to a VCS service instance (local
or remote) to match the service instance pointers of
AICS and VOCS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rename the struct from bt_mics to bt_mics_included, and
rename bt_mics_get to bt_mics_included_get as that is more
descriptive of the value returned.
Furthermore, this will also allow us to use bt_mics as
an opaque pointer to a MICS service instance (local
or remote) to match the service instance pointers of
AICS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Zephyr Bluetooth Mesh did not check whether the proxy message
was actually sent out, so that the response message could
not be received during reset. It did not solve the status
callback of the proxy sending message, so a new problem was
introduced after PR(#28457) merged.
bt_mesh_prov_send(&buf, public_key_sent))
This PR will try to solve the above problem, and will fix
the problem due to thread competition, and PR(#26668) will
not be necessary.
Compared with PR(#30138), it no longer consumes extra RAM
space and supports synchronization of group addresses
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix wrong channel index send by controller in connectionless
IQ samples report. Former implementation reported value from
lll->data_chan_id which is not valid channel index.
Updated implementation reports value stored in IQ samples receive
node during periodic scanning event preparation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fixes ticker_by_next_slot_get for JIT scheduler by allowing iterating
through ticker nodes without ticks_slot information, and improves
performance for legacy ticker scheduling use.
To reduce the processing and context switching overhead, a new feature
is introduced via BT_TICKER_NEXT_SLOT_GET_MATCH, by which an operation
callback may be added via the ticker_next_slot_get_ext interface, and
the match function is then called when the ticker_job is processing the
request.
By returning true in this callback, iteration stops and normal operation
callback is invoked. If the match function returns false, node iteration
continues. This reduces the number of ticker_job executions for node
iteration.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Use UUID encode macro fro 128-bit UUIDs for readability. This makes
it easier to see which service you are working with as the
bt_uuid_to_str prints the 128-bit UUIDs in this format.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add the packet status flag value to the iso receive info
struct. This will allow an application to handle potential
lost or erroneous messages.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The current approach with storing RPL by timeout doesn't solve all
issues as the node may loss power before the timer is fired.
In addition to that this may wear out flash quickly if short timeout is
used.
This change adds an API to store the pending RPL entry upon user
request. Additional Kconfig option allows to completely disable timer
so that the whole storing relies on the user.
The mesh stack still stays responsible for outdating RPL entries in case
of IV Index update as this happens implicitly for the user.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This aligns provisioner and provisionee APIs in terms of endianess
of public key provided by an application.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit allows an unprovisioned device to exchange its public key
using out-of-band techology (see MeshPRFv1.0.1, table 5.19 and section
5.4.2.3).
For in-band public key exchange, the mesh stack uses HCI commands to
generate public and private keys, and DH key. This, however, doesn't
work for OOB public key exchange since there is no command to generate
DH key with a private key provided by an application. Therefore, this
commit adds direct usage of TinyCrypto into the mesh stack for DH key
generation for OOB public key support.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Moving the key check after checking that no pairing or encryption
procedure is started fixes a race condition that is seen in some PTS
tests:
GATT/CL/GAR/BI-04-C
GATT/CL/GAR/BI-16-C
GATT/CL/GAR/BI-21-C
GATT/CL/GAW/BI-05-C
GATT/CL/GAW/BI-12-C
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Some centrals deal poorly with receiving a security request immediately
after reconnection whenever reconnecting with characteristics that are
notifiable or indicatable and requiring security. In particular,
Android 9 and earlier devices may lose bond information when this
happens, some Microsoft Surface devices will enter an invalid state
and, on top of that, Apple's Bluetooth Low Energy guidelines explicitly
discourage this behavior.
In order to allow interoperability with those devices, make the GATT
automatic security request sending as a peripheral optional by
introducing a new Kconfig option, BT_GATT_AUTO_SEC_REQ.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When the Bluetooth stack is configured for CONFIG_BT_MAX_CONN > 1
the oldest key might currently be in use. Fix the logic to ensure the
oldest key overwritten is from the set of keys currently not in use.
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/35999
Signed-off-by: Faisal Saleem <faisal.saleem@setec.com.au>
Signed-off-by: Nick Ward <nick.ward@setec.com.au>
This commit address Erratum E10395 and Errata Correction E16350
to ensure that public keys exchanged between Provisioner and
a device aren't identical.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Unmask events related with CTE report for Direction Finding
working in connected mode.
The feature is enabled conditionally, depending on KConfig
configuration provided.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Kconfig option that will enable support for CTE reception
in connected mode. Thanks to that it will be possible to
conditionally enable or disable support of the feature and
decrease code size if the feature is not required.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove the bt_conn pointer from the VOCS API, as the
instance pointer is enough to determine if it is a client
and perform client operations on the cached connection pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Modify vocs.c to use the bt_vocs struct instead of the
bt_vocs_server struct. This is done so that there is less
difference between the internal struct usage and the struct
type used in the API.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added an API to the HCI header that can be used to retrieve
advertising handle information from a given advertising set.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Remove unneccesary limit of host to controller packets by the host ISO
buffers and host pending buffers with TX callback.
The host always allocates the buffer before taking the semaphore so this
is already handled by the size of the host buffer pool and the
functionality of the buffer pools to wait for buffers.
In addition the ACL max limit is using the wrong define, as
CONFIG_BT_CONN_TX_MAX is the maximum amount of callback contexts for
transmitting. So the host can have more pending packets than this value.
This is also inconsistent with how the host would handle the V1 reply.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit implements the microphone input control service
(MICS) and client, The implementation supports and uses the
Audio Input Control Service (AICS) secondary service.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a new callback structure to `<gatt.h>` for receiving notifications
of ATT MTU updates. This callback is called regardless of whether the
MTU update was initiated locally or remotely.
Fixes#32035.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Fix incorrect and redundant use of ticker user id ULL_LOW
instead of ULL_HIGH when setting up a connection using a
mayfly to disable LLL context. Also, the LLL context pointer
is invalid, where node rx is passed instead of LLL context.
Use the ULL disabled callback when done event has not yet
been processed, or a direct connection setup in ULL_HIGH
context when ULL is already disabled (reference count is
zero) is sufficient.
Regression introduced in commit 30f260dfaa ("Bluetooth:
controller: Fix adv/scan context access post release").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix CCC store on write feature for multiple connections. CCCs are only
enqueued for storing when going from no connections subscribed to any
connection subscribed.
The CCC should be stored when its value is changed for the specific
connection.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix Extended Advertising PDU population from incorrectly
populating new PDU when there is no common extended header
flags being set in the previous PDU and or the new PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising PDU population from incorrectly
populating new PDU when there is no common extended header
flags being set in the previous PDU and or the new PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Periodic Advertising data population from corrupting
the PDU by populating fields when there is no flags in the
common extended advertising header.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a status check for the BIG sync established and
BIG sync created events such that we don't log a warning
of invalid BIS count when it is an error event.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix a regression for cleaning up BIGs added by
80c824f18ee80caa5bd162b9d2957dde1639add6 where the way
ISO connections were unref'ed was changed.
bt_iso_cleanup has been changed to only effect CIS
(as the unref from that has been removed), so instead
of calling bt_iso_cleanup we just call
bt_conn_unref directly.
This also removes some unref's from the BIG complete
and BIG Sync complete event handlers as the BIS bt_conns as
they don't increase the ref counter before anymore.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
BT_L2CAP_LE_ERR_INVALID_PARAMS shall be returned instead of
BT_L2CAP_LE_ERR_UNACCEPT_PARAMS.
This was affecting test case L2CAP/ECFC/BV-26-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
For more than one requested channels in le_ecred_conn_req only result is
overwritten in every iteration. This causes an issues if after failed
l2cap_chan_accept occures successful one: returned result will be
BT_L2CAP_LE_SUCCESS, where in reality should be returned error
and non-zero Destination CIDs will signal "Some connections refused".
Now, overwrite error only if the last one failed. If no errors occur,
result will remain BT_L2CAP_LE_SUCCESS.
This was affecting test cases L2CAP/ECFC/BV-20-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Fix missing 0x0000 CIDs in response for ecred_conn_req. Previously,
when one of "All connections refused" error i variable was set to 0,
thus no CIDs were copied to response.
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Check correctness of returned sync_handle value while requesting
HCI_LE_Set_Connectionless_IQ_Sampling_Enable in controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix bug of missing sync_handle parameter in return data in
HCI_LE_Set_Connectionless_IQ_Sampling_Enable commnad
handling function.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Log failure to initiatet security for bonded peer when GATT wants to
initiate security for CCCs for the remote.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Notify application about prepare write error when continueing the write
procedure fails when RX thread is processing responses. It is possible
that this operation fails, either because of disconnection or ATT
timeout on the ATT bearer. Notify the application in case it needs to
clear up resources, e.g. the write parameters.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Result to send was overwritten by BT_L2CAP_RECONF_SUCCESS just after
exiting while loop. This caused to send success response even if
reconfiguration failed. Now, result is initialized to success value,
and if reconfiguration fails, this value will be overwritten with
appropriate one. Added BT_L2CAP_RECONF_INVALID_CID (0x0003) for invalid
cid in request. Added BT_L2CAP_RECONF_OTHER_UNACCEPT (0x0004) to return
if MPS is to small. Reordered checks for mps/mtu as
BT_L2CAP_RECONF_OTHER_UNACCEPT is expected to be returned if both mps
and mtu are to small.
This was affecting L2CAP/ECFC/BI-05-C and L2CAP/ECFC/BI-05-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
This makes connections of type BT_CONN_TYPE_ISO use BT_CONN_CLEANUP to
cleanup so the TX and RX queues are properly cleanup.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This prints information about the role and id along with connection
parameters in case the connection is of LE type.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The state shall be set before calling the callback as it could be check
code behind would expect the channel to be in connected state.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When handling CIS Requested event CIG and CIS IDs must be set in order
for the channel to be properly accepted.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes bt_conn_cleanup to be automatically called when the last
reference to a connection of BT_CONN_TYPE_ISO is dropped.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The current iso commands in the shell only supports setting up
a bidirectional stream or unidirectional for central role.
Adding rx/tx/rxtx option to iso listen command to allow for
peripheral side configuration of an iso connection.
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
The sequence number is needed in the appliaction layer to detect lost
packets in the ISO stream in cases where the timestamp is not included.
(Sequence number is mandatory to include where timestamp is optional).
The API for the public metadata have been moved to a public header file.
As the size of the ISO meta data exceeds the default 4 octets net_buf
user_data the public ISO metadata have been moved into a seperate array.
The internal metadata is still stored in net_buf user_data.
This also fixed the user_data overflow on 32 bit systems, caused by
writing the ts into user_data on index 4 to 7, which is outside the 4
allocated bytes.
Signed-off-by: Casper Bonde <casper_bonde@bose.com>
Fix CONFIG_BT_EXT_ADV_LEGACY_SUPPORT option which optimizes the host
to skip checking the feature bit of the controller to check for
extended advertising commands.
This was broken because of how this was implented using an undef of the
feature bit, which was not replicated in scan.c, adv.c and id.c once
this was split out from hci_core.
Instead of doing this wierd way of redefining the feature check macro
do it in a proper way by defining a new macro.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue is host handling of connected and disconnected event.
Since the host wants the disconnected event to be processed as a
priority event as well as in reguler event context while the connected
event is always in reguler event context we can end up in a situation
where the disconnected priority event is processed before the connected
event.
Since the disconnected priority event is there to release unack'ed TX
pending on the connection in case the RX thread is blocked waiting
for TX resources, we need to keep this behavior. Otherwise this would
be a potential deadlock of the RX thread waiting for resources that can
only be released by the RX thread.
When this situation happens we know that there cannot be any pending TX
on this connection so we can safely skip releasing of unack'ed TX.
The second thing the disconnected priority event does is marking the TX
path on the connection as disconnected. We need to do the same in this
situation, so we make sure that the TX path is already marked
disconnected when providing the connected callback to the application.
This fixes a regression from 4be66bd33d.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When receiving the L2CAP sent callbacks the dynamic L2CAP channel may
have been disconnected already. The user of the dynamic channel should
have received the disconnected and released callbacks for this channel
to release any resources for the data being sent, so simply ignoring
this sent callback is enough.
Fix sent callbacks by providing the CID to the callback instead of a
pointer to potentially released memory, and lookup the CID to check that
it is still valid.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add check for the advertising already being enabled when attempting to
start the advertising set.
Document that the advertising set cannot be started from the connection
connected callback, and instead has to be started from the advertising
set connected callback.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix multiple advertisers with different ID support, this was added
in 98321c61fb but the guard was never
removed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix to avoid an assertion when processing an acknowledgment
in the first connection event in peripheral role.
Ensure that empty flag reflects the state of the Tx queue,
as a peripheral the first connection event has no prior PDU
transmitted, an incorrect acknowledgment by peer should
not dequeue a PDU that has not been transmitted on air.
Relates to assert added in commit 2bfaadffb8 ("Bluetooth:
controller: Add Tx fragmentation assertion").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deadlock when db_hash_commit has to wait for the delayed work to
finish. This creates a deadlock if the delayed work for database hash
calculation needs to store the hash since the settings API is locked
when calling the commit callback.
Remove call to k_work_cancel_delayable_sync from db_hash_commit in order
to avoid the deadlock. Instead move comparing of the stored hash to the
delayed work and reschedule the work with no wait.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Coverity detected that a zero divisor can be passed to
ll_create_connection() without parameter sanitization. Conditionally
check the connection creation parameters according to spec.
Fixes#35343.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
On sending write request we should check write response.
If data prepaired to be written by peer or offset are not equal
to the data and offset we sent, we shall send Execute Write
Request with Request Flag set to 0x00 (Cancel All Prepared Writes).
This was affecting GATT/CL/GAW/BI-32-C and GATT/CL/GAW/BI-37-C
Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
Fix the missing HCI event data len limit check when encoding
incomplete advertising data report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Max data length has to be adjusted for subevent code, otherwise we'll
hit an assert when trying to add data to event due to insufficient
free space.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
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
connection event preparation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Revert the strict preempt ticker start failure check.
Preempt ticker start can fail when enqueuing prepares into
already filled pipeline which has preempt ticker already
started for the first prepare that was added in the
pipeline.
Regression introduced in commit 5b75bdf589 ("Bluetooth:
controller: nRF5: Check preempt event on timeout").
Fixes#35476.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
From le_ext_adv_param_set we will occasionally attempt
to call bt_addr_copy where the `addr` and &adv->random_addr.a
are the same pointer. Doing a memcpy where source and destination
is the same pointer is undefined behavior and should not be
done.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The VCS client shell was never compiled before, and thus
the implementation had a few undetected errors.
This commit adds the VCS client to the shell CMakelists
as well as fixing the issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The common API functions in VCS had dead code in specific
configurations, causing coverity issues. Fixed by this
commit.
Signed-off-by: Emil Gydesen <emil.gydesen@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>
The send_reliable function was reused in multiple places as part of the
k_delayed_work changes for Bluetooth Mesh in #33782. This function
contains a line that resets the start timer, causing prov_retransmit to
continously move the goal post for when to give up sending.
Extract this line out of the send_reliable function, and put it along
with the other link.tx initialization in bearer_ctl_send and
prov_send_adv.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Change the return value from -ENOTCONN to -EINVAL as that
is a more appropriate return value for checking a NULL
pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Change from -ENOTCONN to -EINVAL as that is a more appropriate
return value for checking a NULL pointer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of return -ENOTCONN they will now return -EINVAL as
that is a more appropriate return value for checking if
the pointer is NULL.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit fixes a bug where outdated RPL entries might not be removed
properly from the persistent storage making those entries dead.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
According to Bluetooth core specification v5.2, if Host set
random address when any of scanning (passive or active), the
Controller shall return the error code Command Disallowed (0x0C).
Signed-off-by: Freddie Yang <freddie.yang325@outlook.com>
This commit fixes a bug where incorrect pointer passed to publish_sent
in access.c caused bus fault.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The network layer previously decided to use the friend credentials if
there was an established friendship. During the friendship setup phase,
the friendship is not considered established until the LPN receives the
first friend poll. Before this happens, the LPN should send a friend
poll message, encrypted with the friendship credentials. This wrongly
gets encrypted with the master credentials.
Change the decision point to whether the LPN has selected a friend,
which happens after the friend offer, and before the friend poll. This
will remain set for the duration of the friendship.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This adds BT_MESH_SETTINGS_VA_PENDING to GENERIC_PENDING_BITS
as it should be stored by CONFIG_BT_MESH_STORE_TIMEOUT.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This bug was introduced in PR #31176, where setting's flags were
moved out from bt_mesh.flags to pending_flags.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix regression in PPIs use for nRF52805 SoC, which has
fewer of them. And the regression was introduced in
commit e603b9d59e ("Bluetooth: controller: Adjust PPI
used for nRF51x and nRF52x").
Fixes#35204.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The naming and documentation of the parameters was inconsistent with
their actual meaning and the implementation - enc_data and plaintext
were swapped.
Also, the parameter names in the file aes_ccm.c were completely
different from the ones in the header. Since all functions in the
header file are consistent in their parameter naming, I chose to make
the implementation follow the header and not the other way around.
Signed-off-by: René Beckmann <rene.beckmann@grandcentrix.net>
Fix advertiser and scanning context being accessed on done
event when connection complete node rx that is processed
earlier has release them.
Relates to #30735.
Fixes#35013.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace the use of LL_FEAT define with ll_feat_get() so that
feature set value can be updated at runtime with host
feature bit values.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit implements the volume control service (VCS) and
client, The implementation supports and uses the
Audio Input Control Service (AICS) and
Volume Offset Control Service (VOCS) secondary services.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix radio event scheduling stall when using BT_CTLR_LOW_LAT
feature.
Performing a Connection Update Procedure on an ACL
connection while simultaneously having continuous scanning
causes the ACL connection to drop in nRF51 series which uses
BT_CTLR_LOW_LAT by default.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added Kconfig option to configure the maximum Broadcast and
Synchronized Receiver ISO PDU length.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The amount of needed done events changes when using the "must expire"
logic.
Make the amount vendor configurable (via ull_vendor.h)
Defaults to the original amount of 3.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
The HCI specification creates additional complexity to allow this
configuration:
- When a connection gets established, we need to know which
identity the HCI_LE_Connection_Complete event corresponds to.
- The identity is a property of the advertising set.
Therefore we need the advertising handle.
- The advertising handle is part of the
HCI_LE_Advertising_Set_Terminated event and is not part of
the HCI_LE_Connection_Complete event. Therefore
the information of both events needs to be combined.
By spec the LE_Connection_Complete comes first. Therefore we cache
this event until the identity is available.
The event is only cached when a connection gets established as
that is the only case where we need to resolve the identity.
As the caching requires more resources, it is only enabled if the
application requires multiple advertising sets and multiple
identities.
The host maps the HCI_LE_Advertising_Set_Terminated event with
the HCI_LE_Connection_Complete event by comparing the connection
handles.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Added function ull_conn_iso_resume_ticker_start to enable LLL ISO
peripheral/central to start the one-shot resume ticker.
At timeout the common lll_resume handler is called, and based on the
LLL state, the peripheral/central is able to resume the CIG event.
The resume acts exactly like a normal event resume from the prepare
pipeline, with the exception that the LLL must provide specific
lll_event instances.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add BT_CTLR_ISO_TX_BUFFER_SIZE depends on Broadcast ISO
and/or Connected ISO feature being enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename LE Read Buffer Size v2 struct members to related to
Bluetooth Specification use Length and Number terminology.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Only accumulate latency when event has not been prepared but
has been aborted while being enqueued in pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Sometimes it may be needed to know device name when proxy feature is
enabled.
This commit adds an option to include device name in scan response.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Change use of dedicated memory pool for linked list nodes for
node_rx_iq_report to common mem_link_rx. Former solution had
a drawback. Released link nodes may be enqueued to wrong memory
pool. E.g. link related with nopde_rx_iq_report went to common
link memory pool, whereas link nodes from common pool were enqueued
to dedicated list.
The solution was working because links have the same memory layout,
just different memory pools they originated from.
The problem may occur if one of those link memory pools is reset.
Then the same link may be used by node_rx and node_rx_iq_report
at the same time, causing controller failure.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction finding is implemented only for Nordic link layer.
Build was failing due to missing header files for Openisa (RiskV).
Added dummy lll_df_types.h header file to OpenISA lower link layer.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The function get_per_adv_sync is used by HCI events to get
reference to periodic advertising sync object related with
handle available in handled events. Due to implementation
of Direction Finding event handlers in separate source file,
direction.c instead of putting in hci_core.c the function
get_per_adv_sync has to be globally accessible.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add functions that give possibility to enable or disable
CTE receive and sample in connectionless mode.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Kconfig option that will enable supprot for connectionless
CTE reception. Thanks to that it will be possible to conditionally
enable or disable support of the feature and decrease code size
if the feature is not required.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Set BT_CTLR_DF_ANT_SWITCH_RX enabled by default.
There is already added implementation that supports
this feature in controller, so it may be enabled by
default.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add connectionless CTE RX feature to list of features supported
by controller. Add direction finding initialization in hci_core
if the feature is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Disable of CTE sampling for periodic advertising sync PDUs may be
interrupted by radio event. In such situation, TX thread will be
handled before RX thread delivers IQ samples report to host. In
this case RX thread would deliver IQ samples report after CTE
sampling was disabled.
To avoid such situation RX thread has to check if:
- CTE sampling is not disabled,
- CTE sampling was not requested to be disabled after start of radio
event.
CTE sampling configuration is double buffered. Updated configuration is
swapped at the beginning of radio event.
If CTE sampling is diabled or requested to disable (next radio event
didn't start), the IQ samples report should be dropped by RX thread
and should not be delivered to host.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add reporing of IQ samples collected for CTE attached to periodic
advertising PDUs with bad CRC.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Kconfig option that will enable possiblity to sample CTE attached to
PDUs that have bard CRC. Sampling is based on CTEInfo field available
in received PDU. If radio is able to parse the field correclty then
it will start sampling even the CRC is wrong.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add function that enables or disables CTE sampling attached to received
periodic advertising PDUs.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
ULL may request LLL to start receiving and sampling CTE attached to
end of periodic advertising PDUs. When the CTE is successfully sampled,
LLL should report collected samples to ULL.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Nordic Radio perihperal provides possiblity to get value of CTEInfo
field parsed from received PDU. It is faster to get the information
from Radio register than parse a PDU content.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add function to enable CTE receive and sampling. The function
is aimed to be used by code in lll_sync.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To enable or disable CTE sampling during periodic advertising sync evnet
it is requireq to change the event duration. To make it possible new
function was added that handles the operation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
lll_sync object is used to store information for LLL to enable
or disable CTE sampling. The commit adds initialization of
lll_df_sync member of lll_sync.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To enable or disable CTE sampling in periodic advertising scanner LLL
implementation lll_sync is extended by lll_df_sync member.
The lll_df_sync is a double buffer for lll_df_sync_cfg.
It will be used by LL thread to enable or disable CTE sampling and
provide configuration for sampling CTE in AoA mode.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add handling of Direction Finding node_rx_iq_report type in ULL.
This is required to correctly deliver IQ samples collected by
LLL during receive of PDU including CTE.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
CTE sampling enable or disable requests should be provided to LLL.
Double buffer of lll_df_sync_cfg is added to lll_sync for that purpose
Thanks to that:
- there is no need to synchronize LLL with LL thread
- LLL has always access to valid configuration (new or former)
The configuration is stored in double buffer as instances
of lll_df_sync_cfg, not as pointers. This is the only
difference between double buffer pattern used to store adverising PDU.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add new structure lll_df_sync_cfg to store DF configuration
for periodic advertising synchronization.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add functions that will allow to mangage IQ reports memory pool
e.g. allocate or relase new IQ report nodes.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add new kind of node_rx type that will store IQ samples report.
The structure includes node_rx_hdr and may be used by the same
queues that are used to forward regular node_rx_pdu objects
between LLL and ULL.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction Finding support requires possibility to receive and sample CTE
attached to periodic advertising PDUs. New option will be used to enable
or disable the functionality. New option is introduced to avoid using
double statements checking if BT_CTLR_DF_CTE_RX and BT_CTLR_SYNC_-
-PERIODIC are enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
To avid enabling HCI drived debugging, like in other controller source
files, Direction Finding has its own option BT_CTLR_DF_DEBUG_ENABLE.
This gives fine grained control deubgging output.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Set to disabled not yet implemented Direction Finding features.
The features will be enabled by default when they are implemented.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
IQ samples report requires information about antenna switch pattern
that was used to measure RSSI. RSSI is measured during PDU receive.
For Nordic Radio peripheral the PDU antenna is selected by first antenna
switch pattern set in SWITCHPATTERN register. That pattern is providded
by device tree. This information is already available in radio_df.c.
The information is required by LLL, that has access to functions
provided in radio_df.c. New function was provided to return PDU antenna
switch pattern.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Check whether the preempt event matches with the head of the
pipeline before aborting the currently active event.
This is required to avoid preemption of events that became
active due to done event and there has been a race in
stopping the preempt ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Check whether the preempt event matches with the head of the
pipeline before aborting the currently active event.
This is required to avoid preemption of events that became
active due to done event and there has been a race in
stopping the preempt ticker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Sync up with missing LLL changes done related to moving the
handling of pipeline handling into LLL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update the L2CAP channel send command to correctly reserve the number
of bytes needed for an L2CAP SDU.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the L2CAP OTS implementation to use the correct reserve
defitition. By not using the correct definition the stack always
allocates a new segment for the packet, which puts more stress on the
stack buffers.
Update TX data size to be more intuitive by adding the overhead, instead
of subtracting it. This increases the default MTU of the implementation.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add argument to the L2CAP channel send command so that the user can
determine the length of the packet to send, this is useful for testing
various segmentation scenarios.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the documentation for L2CAp Connection oriented channel send
function to include better description of the L2CAP PDUs (Basic frames)
and L2CAP SDUs (Credit-based frames) so that the application can better
understand how to size the buffer pools and setting the RX mtu.
Document stack behavior on RX path and how the application has to
set up the channel in order to receive segmented packets.
Document stack behavior on TX path for reserving either mandatory or
optional header bytes.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor and simplify the bluetooth buffer configurations to improve the
easy of configurations and eliminate invalid ones.
By moving configurations out of host and controller specific
configurations and into a common one it becomes easier to configure
the host and controller separately as the same configurations can be
used as would be for a combined build.
All HCI configurations are now given exluding the matching HCI header,
which eases the configuration as the application don't have to know the
different header sizes.
The BT_RX_BUF_LEN is split into ACL and Event, as well as the suprising
use of Command size.
BT_L2CAP_RX_MTU is removed as the stack does not support reassembling of
HCI ACL data to larger L2CAP PDUs. The application will have to set
ACL RX size and account for the L2CAP PDU header itself.
BT_EATT_RX_MTU was removed as it is only used for setting a different
default value for another option which leads to the stuck kconfig symbol
problem.
The configurations can be updated according to the table below:
** New configuration | ** Old configuration
All configurations
BT_BUF_ACL_RX_SIZE | BT_L2CAP_RX_MTU + 4
BT_BUF_ACL_RX_SIZE | BT_RX_BUF_LEN - 4
BT_BUF_EVT_RX_SIZE | BT_RX_BUF_LEN - 2
BT_BUF_CMD_TX_SIZE | BT_RX_BUF_LEN - 3
BT_BUF_CMD_TX_COUNT | BT_HCI_CMD_COUNT
BT_BUF_EVT_RX_COUNT | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT | BT_RX_BUF_COUNT
BT_BUF_ACL_RX_COUNT | BT_ACL_RX_COUNT
BT_BUF_EVT_DISCARDABLE_SIZE | BT_DISCARDABLE_BUF_SIZE - 2
BT_BUF_EVT_DISCARDABLE_COUNT | BT_DISCARDABLE_BUF_COUNT
Controller-build
BT_BUF_ACL_TX_SIZE | BT_CTLR_TX_BUFFERS_SIZE
BT_BUF_ACL_TX_COUNT | BT_CTLR_TX_BUFFER
HCI-bridge
BT_BUF_ACL_TX_SIZE | BT_HCI_ACL_DATA_SIZE
BT_BUF_ACL_TX_COUNT | 6
Fixed invalid configurations setting either BT_L2CAP_RX_MTU or
BT_CTLR_DATA_LENGTH_MAX larger than BT_RX_BUF_LEN could lead to buffer
overruns.
Fix advertising report max data length calculation.
This always used the BT_DISCARDABLE_BUF_SIZE macro but this feature
can be turned off and advertising reports will be allocated from the RX
buffer in that case. Also controller-build does not have this buffer
(in hci_raw.c). Also the wrong HCI header was used in the calculation,
HCI event header should have been used instead of HCI ACL header.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the L2CAP TX MTU default to fit the public key packet in a single
L2CAP fragment. This matches the configuration for RX buffer lengths
being set with this configuration.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove discardable buffer dependency on the specific implementations
except for HCI raw.
All of the in-tree Host-side HCI drivers have implemented discardable
buffer behavior.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add macros for calculating buffer sizes, accounting for the various
L2CAP and HCI headers needed as well as the reserved bytes needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added radio interface to save and restore radio ready
timestamp. This will be saved between ISO Subevents and
used in done event for anchor point synchronization and
drift compensation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update shell L2CAP to use the new delayable work API for the delayed
received confirmation response.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update GATT to use the new delayable work API for the delayed
calculation of the database hash and the service changed indication.
When the database hash characteristic is read the hash work needs to be
canceled if in progress and if currently executing wait for it to
complete so that the threads don't both write to the stored value.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the connections to use the new delayable work API for the
deferred work host timer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update AVDTP to use the new delayable work API for the send host timer.
The AVDTP protocol is incomplete, there is no cancelation of the timer
but it is also never started, as there is no users of the internal
functions, and no public functions exists.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the implementation of controller based privacy to use the new
delayable work API for the RPA timer. Always use schedule for the
timer since RPAs should not be used more than the configured RPA
timeout.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update RFCOMM to use the new delayable work API for the RTX host timer
used for disconnecting and idling.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the SMP channel context to in order to simplify the memset of
the struct in smp_init. This makes the code easier to read, and easier
to add more structs that should not be reset by memset.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update the RPA timer to the new delayable work API.
Checking for submitted RPA timer no longer needed with the schedule
function, which does not change the deadline.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
`write_stats` functionality implementation is guarded by
`BT_GATT_CLIENT`, but is also called from commands defined when
`BT_GATT_DYNAMIC_DB` is set. This means that now application will not
build with `BT_SHELL` used, when we set `BT_GATT_DYNAMIC_CB` solely.
Move this functionality to top of the file without guarding
ifdefs, so it can be used in all gatt shell commands.
Signed-off-by: Marek Metelski <marek.metelski01@gmail.com>
There is a choice to log btmon logs over UART or RTT.
You can choose number of RTT buffer, set its name and size.
Replaced CONFIG_BT_DEBUG_MONITOR with CONFIG_BT_DEBUG_MONITOR_UART
for UART usage and CONFIG_BT_DEBUG_MONITOR_RTT for RTT.
Signed-off-by: Magdalena Kasenberg <magdalena.kasenberg@codecoup.pl>
Renamed offset and offset_units to offs and offs_unit to be
consistent with rest of the other structures.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ULL reference count decrement to be performed before the
done events are handled, so that correct reference count is
used to determine if events are pending in the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update HCI driver implementation in the controller to
process a list of controller events by traversing net buf
frags.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reorder Channel Selection Algorithm #2 and Minimum Number of
Used Channels Procedure bits.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in central initiated terminate introduced in
commit 3a80785947 ("Bluetooth: controller: Fix connection
terminate to happen on event done").
The regression caused an additional central connection event
transmitting PDU after the previous connection event had
received acknowledgment for the terminate_ind PDU from the
peripheral.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not report auxiliary PDUs as advertising reports when in
initiator state on auxiliary channels.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Ensure that the advertiser address type and address is setup
in both 1M and Coded PHY scanning instance when extended
create connection is enabled on both the PHYs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When connection is initiated in one of either 1M or Coded
PHY initiating scan instance then the other scanning
instance's scheduling and memory allocation needs to be
cleaned up.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reserve an additional node rx buffer when Extended Initiator
is supported as the received ADV_EXT_IND PDU is being
buffered in the auxiliary channel scanning instance and is
only released/flushed in the done event of the initiating
auxiliary channel radio event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed incorrect LLL context used to generate done event for
auxiliary channel scanning. Other minor comments and fixes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reset the scanning context for the PHY not selected in the
Extended Create Connection command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This allows to initiate a connection on secondary advertising channels,
i.e. when advertises uses advertising extensions.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
When in initiating state we need to handle ADV_EXT_IND as in regular
scan sice we always want to scan AUX_ADV_IND in order to be able to
connect.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We need to take RX chain delay and PHY used to send CONNECT_IND into
account when calculating 1st connection event offset.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
On secondary advertising channel transmitWindowDelay depends on PHY
used to create connection so we need to adjust it.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We will need the same checks for AdvA and TargetA/InitA in lll_scan_aux
so let's make them public and use address explicitly instead of passed
via pdu.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We can use the same code to create both CONNECT_IND and AUX_CONNECT_REQ
since they are basically that same PDUs.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
When broadcasting with ISO it would wrongly use the tx_pool
defined for CIS, instead of the broadcast TX pool.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix buffer leak in L2CAP and SMP when attempting to send over a
a connection that has been disconnected.
Both L2CAP and SMP now have ownership of the buffer in case of failure
to send it and need to unref it in case of send failure.
Change the return type of bt_l2cap_send since the user of this function
has to handle releasing of the buffer when this fails.
Regression from: a77f809faa47ff9922692d2b4eab33062b8a2b4d
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove the comment about bt_l2cap_send_cb not being able to fail when
called from RX thread. It will fail in the case where the connection
has been disconnected.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Improved the documentation for the ISO data paths, as well
as making the bt_iso_setup_data_path function a bit more
clear.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Since we are only setting up a single data path for
broadcasters (either receive or transmit), we should
only remove that same path.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The BIGinfo reports were almost identical to the
periodic advertising reports when printet. Updated to
mark the start of the line with BIGinfo.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When setting the iso data path for a BIS, it shall only be set for
one direction (depending on whether we are a broadcaster or
a receiver).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add Radio configuration API that gives possiblity configure
reception and sampling of CTE.
Part of alrady implemented API was re-factored to comply
with new API and do complete initialization of registers:
DFECTRL1 and CTEINLINECONF.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
When PROVISIONER and CDB is enabled then IUT couldn't be a NODE.
This patch fixes this by not returning an error when CDB is not
configured. This is useful especially in testing environment, when all
the features are compiled in and we can choose role in runtime.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Adds missing handling of the m_interval and m_latency if tx QOS is
not set, and handling of the s_interval and s_latency if rx QOS is
not set.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Switch to the new API. Adds early exits for the ack and retransmit
timers, and replaces a remaining_time() + submit() call with schedule().
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API. Adds check for a pending buffer in the SAR
timeout handler.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API. Adds a link check to the protocol timeout to
ensure the link is still active.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API. Consolidates reliable sending logic for the first
transmission and the retransmit into one. Adds check for link active in
protocol timeout.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API in Mesh's extended advertising handler.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new API in friend, net and main.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Friend structure allocaction logic is implemented over and over
throughout the friend module. Move it into a static utility function for
readability.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The error check was removed earlier as it was assumed that
we would either get an error, or the data would be valid.
However, without an error check, we are not guarded
against bad reads.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If the output description of the server is empty (legal by the
spec), then we should not return an error to the application
when read. Also added some debug statements when the value is
truncated.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixes 2 issues:
1) The write callback always returned an error
2) The auto-read of the offset state did not, unlike what the
comment suggested, retry only once and fail on the second attempt,
but rather keep retrying.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a security checks when notifying or indicating, such
that we don't send notifications for characteristics that
require encryption on an unencrypted link.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moves the callback structure for VOCS to the register function
which is renamed from init, as there's no reason to register
the callbacks separately.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Avoid possibly overflowing maximum interval when calculating interval
with preferred periodicity.
Changed calculation to round down from maximum interval and reset to
maximum in case of underflowing minimum interval.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Perform null check of default_conn in call cmd_conn_update()
and cmd_conn_data_len_update() in ./subsys/bluetooth/shell/bt.c
Signed-off-by: Kai Ren <renkaikaiser@163.com>
Add the BT_GAP_PER_ADV_MIN_INTERVAL and BT_GAP_PER_ADV_MAX_INTERVAL
macros in gap.h that are also reference in bluetooth.h and
used for parameter validation in adv.c.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moved sdu_interval struct members from llcp_cis to cis group,
to match spec and enable access by ULL
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
When selecting a random count for blink, beep or vibrate, the Bluetooth
Mesh Profile Specification v1.0.1, section 5.4.2.4 states: "the device
shall select a random integer between 0 and 10 to the power of the
Authentication Size exclusive".
This means that if size is 1, the integer should be in the range 1-9,
while the implementation chose an integer in the range 0-9. Reduce the
range and add 1 to the num to correct this for these actions.
Fixes#34209.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix undefined referenc to bt_le_adv_lookup_legacy in bt_le_oob_get_local
when bt_le_oob_get_local is used in a central only application.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add Radio interface to perform back-to-back transmit of PDU
with a configurable inter frame spacing.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
nRF53 implementation of sw_switch always requires Radio End
event, hence optimize out redundant code due to explicit use
of radio_tmr_end_capture.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor indentation change and replaced if-then-else-if clause
with toggle implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds name length checks. The OTS spec does not
explicitely specifiy a maximum name length, but the
maximum name length in the directory listing object
shall be less or equal to 120 octets.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds additional length checks for the OTS directory listing
implementation. This will check the object name length and
the total length of the object when encoding,
as well as the length of the objects when removing objects
from the directory listing.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fixes a typo where the BT_GAP_PER_ADV macros had MAX twice,
as well as adding a MIN timeout macro and check.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix ECC thread stack size which is to small to account for the worst
case scenario. When an interrupt happens at the point where the ECC
thread is at the highest stack size usage pushing the thread context
to service the ISR causes a stack overflow.
Increase the ECC thread stack size by atleast the size of the basic
stack frame of 32 bytes aligned on 8 byte for ARM architectures.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This aligns the error handling of send function to never unref the
buffer in place so the caller retain the ownership of the buffer
whenever there is an error.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a new flag, BT_LE_ADV_OPT_FORCE_NAME_IN_AD, which can be used
to force the Bluetooth GAP device name to appear in the advertising
data rather than the scan response data of an advert with scan response
data.
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Logging v2 is using _Generic keyword for detecting type of
log message arguments. Apparently, it does not support handling
of pointers to forward declared structures. Added casting to void *.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix a missing encryption procedure state check which allowed
out of order receive of START_ENC_RSP PDU, which made the
controller to believe its already in an encryption procedure
in progress state.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Do not make the first object added to the object transfer server the
current (=selected object). This leads to the server having no
current object until one is selected by the client.
This solves a startup issue where the selected callback is not called
by the server if the first object selected by the client happens to be
the same object as the object that was first added to the server. In
that case, the user of the OTS does not know which object is selected,
and therefore may not be able to supply the correct data later.
Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
Avoid using sizeof to access ULL and LLL struct members.
Based on the alignment requirements of structures, due to
padding between structure members, use of sizeof of previous
struct member to access next struct member is incorrect.
Continue to use explicitly stored parent pointer to access
ULL context. Combine event header and ULL header so that
the parent pointer point directly to the combined ULL
struct.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of reference count in
ull_hdr_init function.
This has not caused issues so far, but when the ref member
of the struct ull_hdr if placed in the beginning of a
context that is allocated using mem_acquire function then
first few bytes used would make the ref member to have
uninitialized value when such context is allocated by
mem_acquire. First few bytes are the next pointer and free
count stored by the mem module.
The issue was discovered in subsequent commits that
restructure the ULL context structures.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the auxiliary scan context release to be performed in
the disabled_cb callback after the ULL reference count is
decremented.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix conn_cleanup to be performed in the event done. The
regression was introduced in
commit 5412f61ac6 ("Bluetooth: controller: Introduce
separate done memq").
Now that done event is handled asynchronously outside the
handling of the terminate node rx type, it is necessary that
terminate node rx type is generated after the done event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Consolidate Kconfigs for ISO roles to make compilation guards more
concise. Just introduces aliases, does not change functionality.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Moves the beacon_enabled check in the beacon work handler to check the
beacon flag before sending anything, in case a cancel call fails.
Split out from #33782.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Ignore peer keypress notifications as a responder, allowing the pairing
procedure to continue instead of being aborted.
The Bluetooth LE specification does not specify a behavior, the
implementation has the choice of ignoring or aborting.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The Transport layer implements some checks surrounding the
lpn_msg_received call, with an accompanying comment that explains the
logic. Move this inside the msg_received call instead.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Switch to the new delayed work API. Puts the scheduling for the next
poll in the response_received function instead of cancelling it, then
optionally scheduling it again later.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Changes lpn_timeout_get behavior in the config server to report the
configured LPN timeout, instead of the currently remaining timeout time.
According to the Bluetooth Mesh Profile specification, section 4.2.21,
the PollTimeout list is a list of the PollTimeout timer values, and
according to table 4.32 in this section, values 1-9 are prohibited.
Although this is not explicitly stated, this indicates that the
PollTimeout value is the configured poll timeout time - not the time
remaining until the timeout value expires. This patch changes the
implementation to reflect this.
Split out from #33782.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The Transport layer would previously rely on the access layer to check
whether there's room for the full message and a MIC in the available
buffer space, and its own checks would ignore the MIC. This should be
handled by the Transport layer checks, so the access layer doesn't have
to.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Periodic publication would previously build and send the first
publication inside the bt_mesh_model_pub() function, before cancelling
and rescheduling the next publication. The timer handler would only
handle retransmissions, and would abandon the rest of the publication
event if one of the packets failed to send.
This design has three issues:
- If the initial timer cancel fails, the publication would interfer with
the periodic publication management, which might skip an event or
send too many packets.
- If any of the messages fail to publish, the full publication event
would be abandoned. This is not predictable or expected from the API.
- bt_mesh_model_pub() required 384 bytes of stack to build the message,
which has to be factored into all calling threads.
This patch moves all transmission into the publication timer by
replacing k_work_cancel with a single k_work_reschedule(K_NO_WAIT). It
also changes the error recovery behavior to attempt to finish the full
publication event even if some of the transmissions fail.
Split out from #33782.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
First design towards ISO adaptation layer, this PR introduces
data-structures and framework for Rx unframed PDUs (BT RX ingress).
Two callbacks are defined for the SDU production (BT RX egress), one for
SDU allocation as well as a callback for emitting a reassembled SDU.
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
chan_send does restore buffer state in case of an error which is
different than how bt_l2cap_send_cb works as it does always unref in
case of an error.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes a regression introduced by
10841b9a14 as it did remove a call to
net_buf_ref which was used not only to keep a reference for resending
but also to prevent bt_l2cap_send_cb to unref the buffer in case it
fails.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In the time between a NODE_RX_TYPE_CONNECTION node is sent from LLL and
demuxed in ULL, an ADV role disable may be executed.
This makes the LLL data referenced in the node NULL/invald, and
ull_conn_setup would operate on invalid data.
This commit introduces a check in ADV disable to disallow the operation
(including conn invalidation), if a connection has been initiated.
To prevent pipeline-queued prepares from advertising after disable has
been initiated, set 'cancelled' flag for immediate signalling to LLL.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This option enables BT_TICKER_SLOT_AGNOSTIC which eliminates
priorities and collision resolving in the ticker.
Event scheduling states are stored in the lll_hdr, and event priority
is passed from LLL implementation, and runtime priority calculated.
LLL implementation decides whether to program radio, start preemption
timer, and/or queue prepare in the prepare pipeline.
Event arbitration is made possible via the common LLL, but not yet
implemented in Nordic LLL.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Priority in the legacy stack has been unused and "work in progress" for
some time. With this commit, the priority passing/handling is cleaned
up, preparing for the new JIT scheduling priority handling.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Split lll_prepare and lll_resume from Nordic LLL to common file for
reuse by all vendors. The split also supports new JIT Scheduling by
defining a common place to calculate event prepare priority.
The module may also house other common parts of the LLL currently
re-implemented identically by vendors.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The ticker 'force' flag is propagated via the ticker elapsed callback,
in order to provide necessary information for collision resolving in the
link layer.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Added config BT_TICKER_SLOT_AGNOSTIC which configures the ticker in
a "slot agnostic" mode, in which no collision resolving or slot
reservation is possible or used. In this mode, the ticker acts as a
simple timer.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Renamed to BT_TICKER_LOW_LAT in ticker, and changed selected
conditionally compiled code to use IS_DEFINED macro.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This commit implements the secondary service
Audio Input Control Service (AICS) server and client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Move the LLL done event handling from ULL to LLL, this
reduces CPU utilization and reduces overhead between radio
events.
Fixes#21993.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Defer the event early abort so that lll_done does not get
recursively invoked when called inside prepare callback.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There is a race between the pipeline enqueue by the ULL
context when processing the LLL done event, and the
pipeline queue by the ticker timeout for a new radio
event. This caused an already enqueued event prepare to be
placed after the newly arrived request to enqueue a prepare
by ticker timeout.
Fix this race by placing the new prepare in the pipeline
instead of starting the event, when ULL is still processing
the LLL done event.
As ticker timeout and ULL processing of LLL done event are
in the same ULL_HIGH context, the pipeline handling is safe
with the order of prepares maintained correctly.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Commit d6c34c4644 changed the behavior
slightly but didn't update the documentation. The callback will now be
reset to NULL once the key is generated. Calling bt_pub_key_gen()
multiple times before the key is finished would result in creation of an
infinite loop. This could happen when an application calls mesh_init()
and mesh_reset() in quick succession. Clarify the behavior of the API in
the documentation.
Also passing a NULL argument would result in an undefined behavior, so
add a check to match the behavior described in documentation.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Change to use the BT_ATT_FIRST_ATTTRIBUTE_HANDLE and
BT_ATT_LAST_ATTTRIBUTE_HANDLE instead of the literal values where
applicable.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The bt_iso_chan_disconnected assumes a CIS, but was
also used for BIS, so whenever it was called it attempted
to get a non-existing ACL connection.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The implementation of blocking calls is common for all the client
models.
This change reduces the code duplication by introducing new API that
helps to manage acknowledged messages.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The check for NULL was on the pointer to the pointer,
rather than the pointer. The pointer of the pointer would
always be non-null, but the pointer might not be.
Moved from using a pointer of a pointer to just a
pointer to make it easier to read and understand.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds two functions:
1) Lookup periodic adv sync object by address
2) Get information about a periodic adv sync object.
These can be useful for the application verify if there is already an
existing sync to an periodic advertiser.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add discovery of standard descriptor values. This provides a shorthand
instead of doing a read by UUID, allowing the application discovery
procedure to re-use the discover parameters for simple descriptors.
Fixes: #21489
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds a parsing mechanism for Composition data page 0 in the Config
Client API, and uses it in the shell module to parse the incoming
composition data.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The first byte of the composition data status message is the returned
page index, not the status of the request. This is now reflected in the
API.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Make bluetooth.init tests for nRF platform pass again by adding ULL/LLL
stub functions, and fixing minor compile issues.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Adds a Kconfig option to set the minimum key size accepted
by this device. This can be used to e.g. enforce 128-bit keys.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix packet reordering in ATT when putting the host under high load.
In certain conditions a packet can be transmitted while there is
elements in the TX queue in bt_att_send. This means that the packet will
skip ahead in the TX queue leading to packet re-ordering.
Fix by always appending to the queue, and then initiate sending of the
HEAD of the queue.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the calculation of event delay when starting a radio
event. The calculation and check was incorrect causing
event abort when radio event was setup before the preempt
timeout by the lll_done when the next prepare was already
in the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When a CIS indication is received and CIG ticker is already started,
calculate the absolute time of the first subevent of the new CIS,
and validate the handle. This will allow the LLL prepare to see a new
valid CIS, and calculate the offset within the CIG event, where the new
CIS should start. This offset is then valid for all following events for
the duration of the CIS.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Add missing #if defined(CONFIG_BT_CTLR_DF_ADV_CTE_TX) statements
to fix build errors of Direction Finding code when
the CONFIG_BT_CTLR_DF_ADV_CTE_TX Kconfig entry is not set.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Enable possiblity to use debug pins for controller debugging
purposes with nrf52833dk_nrf52833 board.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Splits the file into radio_nrf5_ppi.h and radio_nrf5_dppi.h
and moves the nRF53 DPPI to radio_nrf5_dppi.h.
Signed-off-by: Aurora Sletnes Bjørlo <aurora.sletnes@nordicsemi.no>
Rewrite to use subscribe and publish functions for the
different peripherals. This will make it possible to test
the controller in a simulator.
Signed-off-by: Aurora Sletnes Bjørlo <aurora.sletnes@nordicsemi.no>
The ID validation check would always fail with IDs less than
OTS_OBJ_ID_START_RANGE, where the intention was that it should
allow the OTS_OBJ_ID_DIR_LIST (0) value as well if
CONFIG_BT_OTS_DIR_LIST_OBJ was enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix missing big_disconnect in hci_le_big_complete when the number of
BIS in the event is invalid.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Validate the big_handle before received from the controller before
using it as an array into the bigs array.
Discover by coverity: Insecure data handling (TAINTED_SCALAR)
Using tainted variable "big_handle" as an index into an array "bigs".
Cleanup state of BIG in pending or syncing state if it exists.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix parsing BIG handle which is just one octet as a two octet field,
which could have caused problems on big-endian systems.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the BIG initialized atomic handling to use bits instead of a
single atomic.
This allows for more bit flags to be added.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix race conditional when create connection cancel is called
and actually a connection did get setup while initiator is
being stopped.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Conditional compile adv_addr which is only used by
controller when supporting initiator/central role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the initiated bit flag into role specific union, so that
other role specific bit flags can share bit space in the LLL
context structure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix flash driver sync regression introduced due to changed
default ULL_HIGH in the commit 30634334a8 ("Bluetooth:
controller: Fix ULL_HIGH priority to be lower than LLL").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated ticker implementation to return lazy value for a
ticker when enumerating active tickers with time
reservations.
This is required to find offsets and to use the lazy value
to correctly calculate event and payload counter values that
needs to be filled into SyncInfo and BigInfo structures.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
LL_CIS_IND starts a ticker for the created CIG, using the event_counter
and offset provided. Ticker generates callbacks to
lll_peripheral_iso_prepare. Event done with ISO (extra) type is demuxed
and done handled for CIG including ticker update with drift
compensation.
TODO: Handle multiple CISes as well as pause/resume and scheduling
latency.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Implemented LL_CIS_REQ/RSP and LL_CIS_IND handling to allow a central
to establish a CIS connection. Implementation is temporary, for
test/development purpose and should be re-implemented in the new LLCP
framework when ready.
Signed-off-by: Morten Priess <mtpr@oticon.com>
In the file gatt.c, GAP service contains the Device Name
characteristic. If writable, authentication and authorization may
be defined by a higher layer specification.It means that GATT
clients can write to device name GAP characteristic without
bonding. So we add a configuration for writable name without
bonding.
Signed-off-by: Jun Huang <huangjun6@xiaomi.com>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds a check for the BT_LE_FEAT_BIT_PER_ADV bit for each
function related to periodic advertising, including sync and
PAST transfer.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix undefined reference to bt_key_foreach when BT_LOG_SNIFFER_INFO has
been enabled but BT_SMP is not enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Configuration Client doesn't check the address in a received
response. This means that a response from any device will be accepted.
This change ensures that the correct response will be accepted.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Fix bluetooth audio compilation issue when BT_AUDIO is enabled but
no Bluetooth host services has been enabled.
This leads to an empty library file.
Instead of creating a new library for audio add the sources to the
parent library, similar to how bluetooth services are added.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
VOCS does not support the write long procedure, and thus
should not accept any offset in write requests.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This adds bt_conn_iso function to safely access the struct bt_conn_iso
within a bt_conn.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Channel direction was actually a source of confusion since the spec does
actually define the data path direction from controller point of view
meaning input actually means transmit and output receive, also direction
can be configured with different QoS settings.
To make these APIs less confusing and allow QoS to be configured
independently they are now split into RX (receiving) and TX
(transmission) settings including its data path.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
CHECKIF is preferred as it handles full runtime error handling in
addition to just asserts.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes bt_iso_cleanup when there are still channels bound to the
ACL connection.
On top of it introduce bt_iso_chan_unbind which can be used to unbind
channels and thus release the reference to the ACL connection if that
has not been disconnected in which case the channels are unbind
automatically.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When the channel has just been bound but is not connected yet there is
no need to send any command over the air but the disconnected callback
shall still be called in order to notify the channel owner that it has
reached disconnected state.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When initiating a disconnection conn_disconnect would be called to send
HCI_Disconnect but the controller may be quick enough to send Disconnect
Complete event before setting BT_CONN_DISCONNECT which will then cause
the invalid transition from BT_CONN_DISCONNECTED to BT_CONN_DISCONNECT
and the connection won't be freed properly.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes a regression introduced by 4350021f09 which prevents
references to be properly release when there is an ISO connection.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit implements the secondary service
Volume Offset Control Service (VOCS) server and client.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix control Tx buffer leak into data Tx pool that happens
after a cross-over control procedure response was paused due
to currently active encryption setup procedure, and a new
control Tx PDU in addition to the paused one is enqueued
thereafter.
When the control tx PDUs is resumed but not yet enqueued
towards the radio, if there is a new control Tx PDU enqueued
then the paused control Tx PDU is not set as the head of the
control PDUs in the Tx queue. This caused the paused control
Tx PDU to be associated with data Tx pool, hence causing the
incorrect release into data Tx pool.
Relates to the commit bff76b4cce ("Bluetooth: controller:
split: Fix control tx queue handling") and to the
commit 6991d09977 ("Bluetooth: controller: Fix control tx
queue handling").
Fixes#32898.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the redundant connection initiated check as the event
is closed on connection initiated and it is sufficient to
check in the prepare_cb function to abort any events in the
pipeline after the connection has been initiated.
Relates to commit 5ce5dc055e ("Bluetooth: controller:
Avoid race between ULL and LLL when initiating conn") and
commit 18f5fb99c1 ("Bluetooth: controller: Remove use of
lll_stop").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the channel identifier calculation function in the
central and peripheral implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added function to calculate channel identifier value
required for Channel Selection Algorithm #2.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A bunch of commands were missing from the bitmap in the Read Local
Supported Commands response. Add them accordingly.
Fixes#33324.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Ignore connection indications from peers that are already
connected. This is to bring the behavior of the controller in
accordance with [5.2, Vol 6, Part B, 4.5 Connection state]:
"If an advertiser receives a connection request from an initiator it
is already connected to, it shall ignore that request."
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Rename the peer's address in the advertising set struct from `id_addr`
to `peer_addr` to clarify what the address refers to.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Fix regression is central only builds when CONFIG_BT_PRIVACY and/or
CONFIG_BT_EXT_ADV is enabled, or the functions bt_id_reset or
bt_id_delete is called from application.
This resulted in build error for undefined functions
bt_le_ext_adv_foreach and bt_le_adv_lookup_legacy since the definition
for these functions are now only compiled in when CONFIG_BT_BROADCASTER
has been enabled.
Regression from:
53cea4719d
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix CONFIG_BT_HCI_ACL_DATA_SIZE default value set to 0 when data length
feature in the controller is not enabled. In this case the default value
will be set to 0 which is outside of the range specified for the option.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move access to volatile variable out of assertion to avoid warnings
about side effect in assertion.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Add hci_driver.h to include files in id.c to ensure that prototype for
bt_read_static_addr is visible. This fixes builds that define
CONFIG_BT_CTLR but not CONFIG_BT_HCI_VS_EXT.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Moved the call to obj_id_to_index such that we can check for valid
ID before getting the index.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds a ots_obj_manager function that returns true if the object is
in the object manager, or false otherwise.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The directory listing object is an internal object which
content is the aggregation of all the metadata of all objects
(including the directory listing object itself). The client
can read this value to get a list of all objects with names,
lengths, and other metadata.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The order of Destination CIDs shall correspond the order of Source CIDs
including its amount so errors that don't result in all connection being
refused shall not break the order of CIDs.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
For errors that means all connections have been refused there is no need
to add dcids since none will be valid.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When receiving L2CAP_CREDIT_BASED_CONNECTION_REQ the remote may request
more channels than allowed so this checks if amount of channel surpasses
the maximum channels (5) and return an error.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Adds a Proxy callback structure with a callback for Node ID enable and
disable. This API follows the Friend and LPN API pattern in mesh/main.h,
and can be expanded with more callbacks later.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix an assertion when disabling Extended Advertising with
auxiliary PDUs. Stop the auxiliary PDU scheduling after the
primary PDU scheduling is stopped first. This will avoid the
assertion caused due to a search for a stopped auxiliary PDU
offset by the primary PDU scheduling that is being stopped.
Fixes#32866.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace a development assertion in the implementation of
Connection Parameter Request Procedure with an internal
comment and handle transaction violation be ignoring the
PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the leak of node rx buffer used to generate the
connection complete and CSA#2 event introduced in the
commit 4a5f263e5a ("Bluetooth: controller: split: Validate
chan map and hop value") and the
commit 94d5f0854e ("Bluetooth: controller: fixing error
re. all zero chmap in conn-ind").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Instead of silently closing the link we should send a Link Close message
three times before resetting provisioning state.
From Mesh Profile Specification v1.0.1.:
```
5.3.1.4.3 Link Close message
The Link Close message is used to close a link.
```
```
5.3.2 Link Establishment procedure
The device shall start the link timer, set to 60 seconds, when the link
is open. When the link timer expires, then the device shall close the
link.
```
```
5.3.3 Generic Provisioning behavior
If the sender does not receive a Transaction Acknowledgment message
within 30 seconds after sending the first message in a transaction,
the sender shall cancel the transaction, cancel the provisioning
process and close the link.
```
From Mesh Profile Test Specification p6:
```
MESH/PVNR/PBADV/BV-01-C
Test Procedure:
[...]
6. The IUT is induced to send a Link Close message with the Reason field
set to 0x02 to terminate the link. The message is sent at least three
times to ensure the message is received by the Lower Tester.
```
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Refactor out the BR/EDR handling from hci_core.c to its own source file
in br.c.
BR/EDR consists of inquiry and discovery roles in addition to
initialization. SSP is still kept separate.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Align the SSP HCI event handlers with the rest of the functions in using
the bt_ prefix. In order to avoid name conflict with the HCI struct
definitions the infix _evt_ has been dropped.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation error with BR/EDR is enabled but the feature
CONFIG_BT_KEYS_OVERWRITE_OLDEST is disabled.
This caused compilation error because the field aging_counter is not
defined in the keys struct.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor out the advertiser roles handling from hci_core.c to its own
source file in adv.c.
Advertising roles consists of legacy and extended advertiser, and
periodic advertiser.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor out the scan roles handling from hci_core.c to its own source
file in scan.c.
Scan roles consists of regular scanning and synchronization to
periodic advertiser.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Don't include checks for advertiser is enabled when the broadcaster role
is not enabled. This makes it possible to have bt_le_ext_adv_foreach
be excluded from the compilation.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor out the identity handling from hci_core to its own source file
in id.c
Identity consistes of managing the identities of the device, the privacy
feature which hides the identities. And handling of the identity
resolving list in the controller, needed to support privacy-enabled
remote devices.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the code so that bt_adv_lookup_legacy is always called after
the IS_ENABLED(CONFIG_BT_BROADCASTER) configuration has been checked and
the code path will be excluded.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor command state state handling to one function.
When setting state outside of hci_core the cmd macro is not available,
so in order to assign the buf pointer to state the function is needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add the option CONFIG_BT_HCI_ACL_DATA_SIZE which allows the user
to configure the max HCI ACL data payload. This is needed for platorms
where the BLE LL, HCI uart and host run on three different cores.
Fixes: #30441
Signed-off-by: Johan Stridkvist <johan.stridkvist@nordicsemi.no>
Overwrite the existing bond when the IRK of the existing bond could not
resolve the RPA of the peer. This would happen if the peer has deleted
the bond and replaced the IRK that was used.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor update_keys_check helper function to operate on input keys
input. This allows the function to be re-used on a keys structure that
is not the current connection keys.
This also avoids the helper function changing the connection state.
The conn->le.keys pointer should at this point always have been
assigned, as central when sending the pairing request, and as peripheral
when receiving the pairing request at the very latest.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Health Fast Period Divisor is stored within
the model publish parameters on the access layer.
The opposite part for divisor restoring has been missed.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Adds the const qualifier to the internal api for adding and removing
virtual addresses, to allow them to accept const hardcoded values in
tests.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Moves the debug log printing the transport packet metadata to after the
keys are resolved, so that the subnet pointer is valid.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds a "polled" function to the friend callback structure, that gets
called every time the friend receives a poll message. The polled
callback is called before the establish callback, to match the LPN
behavior.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The SCA (sca) field of bt_iso_chan_qos did not give much
information about the expected values or what they meant,
nor any information about what the value perhaps should be.
Updated the description and the ISO shell.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
To prevent the transport layer from accepting duplicate or out of order
segmented messages, add an RPL-like check for the SeqAuth of the
segmented messages when their context is allocated. This prevents
duplicate receives of the same segmented messages in the case where a
single source address sends two segmented messages in parallel (to two
different addresses):
Previously, when receiving two segmented messages, the first message
would go through to the access layer, then the second. Then, if the
transport layer received any repeated segments for the first message, it
would fail to identify the SeqAuth as old, as all its segments were of
new sequence numbers, and the "already complete SDU" check would only
look at the second message. Thus, the segmented message got processed
again and passed to the access layer, even though it was a duplicate.
To solve this, we need a mechanism like RPL, but only for the segmented
messages' SeqAuth. We cannot re-use the actual RPL mechanism, as it
can't support the scenario provoked by the "blocking tx" mechanism in
transport. This mechanism allocates the SeqAuth when the message is
first passed to the transport layer. The ongoing message that caused the
block would keep sending segments with higher sequence numbers than
the blocked message got, which will cause the blocked message to fail
the RPL check.
This patch adds a parallel SeqAuth mechanism to the RPL module, which
only deals with the SeqAuth of the segmented messages. This list gets
checked when the segmented message is first allocated, in the same
manner as the general RPL mechanism. The storage gets hooked into the
RPL mechanism, by adding a separate seg field to each RPL entry.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When Extended Advertising terminated due to duration or
maximum number of events, the auxiliary PDU scheduling
is now correctly stopped.
Fixes#31254.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace the legacy delayed work API with the new delayable work API.
Avoid cancelling work and manually notifying when the subscription is
disabled; instead allow the work item to do this.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Replace the legacy delayed work API with the new delayable work API.
Use a zero period as a flag value to ensure that the work handler is a
no-op of the publish operation is disabled.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Switch to new work API, taking advantage of the difference between
schedule and reschedule to force an update if the new deadline is
sooner, and retain any previous deadline (or use the new deadline) if
it isn't. Do not leave a path out that could, due to races, fail to
schedule necessary work.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Switch to new work API. Avoid a racy cancel by allowing the work
handler to deal with an immediate off when the time remaining changes
to zero.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Added initial support for BIS (broadcast ISO stream), which
adds support for creating BISes as both broadcaster and receiver,
as well as managing and creating BIGs.
Extends PA sync to handle BIGInfo adveritising reports.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
k_work_pending is now called k_work_is_pending.
These two uses are correct assuming the functions that invoke them are
not involved in race conditions: that the work is not pending is an
allowed condition for modifying state that will be used by the work
handler.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The error code from gatt_service_register is being ignored to ensure
that repeated actions still complete. Do this explicitly by adding
(void) casts, resolving coverity warnings on accidental error code
ignores.
Fixes#33051.
Fixes#33074.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
If CONFIG_BT_MESH_SEQ_STORE_RATE is 1, the check in store_seq can be
reduced to a simple if (false), and the modulo code does not need to be
included in the build.
Fixes#33036.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Moves the if !(pub) check to happen before it gets used in the
initialization of the message context in bt_mesh_model_publish.
Fixes#5116.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Include virtual label's pending_store function in the LABEL_COUNT > 0
compile guard to avoid including dead iteration code in the compilation.
Fixes#32928.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Check that the assigned subnet hasn't been removed in heartbeat_send to
avoid potential NULL defererence in transport's ctl_send.
Fixes#32907.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Added comments to explain the re-use of allocated same
connection context to both 1M and coded PHY scanning context
when both PHY is enabled for initiating connection.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Initial work in progress implementation of Create Connection
Cancel for Extended connection initiation.
Adds implementation to teardown connection initiated at ULL
layer and gracefully release allocated resources.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use an "initiated" flag in the lll_conn struct to guard the processing
of PDUs related to connection initiation (CONNECT_IND,
AUX_CONNECT_RSP). This avoids races between ULL and LLL when creating
a connection.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Currently there is no way to distinguish between a caller
explicitly asking for a semaphore with a limit that
happens to be `UINT_MAX` and a semaphore that just
has a limit "as large as possible".
Add `K_SEM_MAX_LIMIT`, currently defined to `UINT_MAX`, and akin
to `K_FOREVER` versus just passing some very large wait time.
In addition, the `k_sem_*` APIs were type-confused, where
the internal data structure was `uint32_t`, but the APIs took
and returned `unsigned int`. This changes the underlying data
structure to also use `unsigned int`, as changing the APIs
would be a (potentially) breaking change.
These changes are backwards-compatible, but it is strongly suggested
to take a quick scan for `k_sem_init` and `K_SEM_DEFINE` calls with
`UINT_MAX` (or `UINT32_MAX`) and replace them with `K_SEM_MAX_LIMIT`
where appropriate.
Signed-off-by: James Harris <james.harris@intel.com>
Log the security keys that the sniffer needs in order to sucessfully
decrypt the connection.
This option allows the sniffer to work in the cases where enabling
using the SMP debug keys is not wanted, either because it changes the
way the peer behaves or is denied by the peer.
It also enables the sniffer to decrypt a connection where the bond
already exists.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Convert allowed_cmds to an array of atomic_t of size 1.
This makes it future proof in case more commands are added.
Possibly silences coverity false positives on array vs singleton usage.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix some format warning in cfg_cli.c.
Fix use CID_VNAL as param when use vendor models.
This is a resubmission of PR (#30086)
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fixed some undesired or incorrect macros, which
can cause build error.
This is a resubmission of PR (#30086)
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Correct format errors, such as oob action 2-octers
should use 0x%04x, and action in prov capalilities pdu
big-ending. When every call `bt_mesh_auth_method_set<*>`
should also clear auth value, otherwise will case confirm
failed.
Provisioner role expect peer public key should be sent
immediately, instead of requiring ACK. After all, ACK may
be lost, and the other device’s public key will be sent
over, and provisioning procedure will be failed..
This is a resubmission of PR (#30086)
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Move the ticker job_guard reset to after
ticker_job_compare_update, so that the ticks_current and
ticks_slot_previous are updated before ticker_worker gets
to execute. Without this fix, there is a possibility that
ticker_worker will use incorrect ticks_slot_previous and
ticks_current value under race conditions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker job to defer itself to avoid recursive
invocation to itself due to ticker interface calls from
inside the ticker operation callbacks.
The recursive use was exposed when using ticker stop
operation callback of stopping an auxiliary PDU to stop
the primary PDU scheduling as part of generation of
Advertising Terminate event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove inclusion of vendor specific internal LLL include
files in ULL source code.
Prefix `lll/` include file path to correctly include vendor
defined types and function implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow NULL pointer to be passed to bt_id_get function so
that only count can be fetched.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
There's a prompt to set the TX stack size, that's documented as an
advanced setting, but attempts to override it it are rejected unless
you add another setting that allows it to be change. Tell the user
how to make changes work.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Remove compilation warning caused by currently not used
hci_df_set_conn_cte_tx_param function.
Code is sorrounded by #ifdef CONFIG_BT_CTLR_DF_CONN_CTE_RSP.
The CONFIG_BT_CTLR_DF_CONN_CTE_RSP is changed to be disabled
by default (until complete implementation of the feature is
provided).
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Change dfe-ant-num propert name to dfe-antenna-num.
The change is conde to keep the same naming style
for all properies, like dfe-pdu-antenna property.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add initialization of GPIOs that are used for antenna switching.
GPIOs provided to DFE extension in Radio peripheral, to drive
antenna switching, should be initialized in GPIO peripheral beforehand.
The initialization is optional and may be disabled by Kconfig.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Antenna switching done by Radio with use of GPIOs provided in
PSEL.DFEGPIO registers. Registers were initialized once during
controller initialization.
At preparation of new radio event, Radio peripheral is powered
down and up to resset its registers. It is related with multi
protocol handling and possible leftovers in Radio registers.
Due to that, PSEL.DFEGPIO registers should be initialized
at the preparation of every event that will transmit
or receive CTE and run antenna switching.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Anternna switching should be disabled when CTE Rx is not supported
or disabled. Added missing dependency on BT_CTLR_DF_CTE_RX.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add missing declarations of functions that are compiled in when
CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY is selected
Add missing include of header file.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix duplicate include of lll_test.c file under the
unsupported ISR profiling feature in OpenISA port.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use `#if defined(...)` instead of `#if IS_ENABLED(..)` when
conditional compilation of definitions in source code.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We should verify that the buffer has sufficient data before attempting
to parse the SDU length field. If we get a too short packet just
disconnect the channel.
Fixes#32497
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix array overrun of client features bitset, where CF_BYTE_LAST was
incorrectly defined as 2 using module instead of divide.
Also fix additional bit-logic when number of bits would exceed a byte:
- Inner for loop iterates from 0 to number of bits on a single byte.
- Same bitmask used for all bytes.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Don't auto-update the device name in the advertising data as that
would clear any other scan-response data set by the application.
Document the behavior of the advertise with device name option
and the need to update data by the application to make sure
advertising data does not get cleared.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix endianness issue in reading CPF descriptor not converting from
native endianess to little-endian on the 'unit' and 'description'
fields.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use the definitions of UUID values instead of magic constants with
explanation in comment.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Check for associated Extended Advertising set to determine
whether Broadcast ISO Group instance has been already
created.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add association between extended advertising, periodic
advertising and broadcast ISO instance, so that attempts to
create and terminate BIG can detect error conditions.
Error conditions being, trying to create BIG without a valid
periodic advertising train, or terminating BIG without prior
creation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When ticker job is disabled inside radio events then all
advertising, scanning, and slave latency cancel ticker
operations will be deferred, requiring increased ticker
thread context operation queue count.
Relates to #32430.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Consistently use the internal BT_CTLR_ADV_SET value in the
controller's implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add missing offset_adjust filed to pdu_adv_sync_info.
Add handling of the field when sync_info is added to advertising PDU.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix the tertiary PDU and extended header length value after
the refactoring in the commit c8475b9a3e ("Bluetooth:
controller: ULL: enable TX of CTE with per. adv. PDU").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rearrange the LL interface functions in the ll.h file to
group functions use by HCI separate from other buffer and
control flow related functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the controller version define into ll_feat.h file to
keep the version number and featureset bitmaps together.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move LLL header files for all roles to common folder. Move
vendor-specific content to internal header files, in particular ADV
buffer handling. Define the vendor-specific type lll_adv_pdu in a
separate header file lll_adv_pdu.h to avoid cyclic dependency when
moving ADV buffer handling to internal header file. Make sure all
internal header files are in vendor-specific folders.
The goal is to have a more consistent structure for LLL header files
and allow unconditional inclusion of non-internal LLL header files.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Remove the depency on host emulation of ECC for the Use debug keys
option.
This allows the application to use debug keys without shifting the
ECC from the controller to the host, which could potentially alter
the behavior of the application and make debugging this way less useful.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the ECC emulation setting the supported command bits in order
to group the supported commands together with the implementation of
these commands.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In order to avoid stalling LLCP procedures blocking done event
processing, done events are now put in a separate memory queue,
and processed by own mayfly function.
This ensures prepare/done refcount balancing and prevents assertion
due to lack of done events.
Signed-off-by: Morten Priess <mtpr@oticon.com>
We need to make sure aux is cleared on reset, otherwise we may end up
with legacy advertising with aux.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Set #0 is used for legacy advertising when legacy HCI commands are used
and in such case it's possible to enable advertising without any prior
configuration. This means we should better always have PDUs in set #0
initialized with default empty data.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We should remove all advertising sets when resetting controller. It's
enough to just clear is_created flag for each set.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Removes the 3 byte padding at the end of each proxy connection's rx
buffer.
Fixes#18509.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add compilation guards for the feature_rsp_send function to avoid
compilation errors for some configurations.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
It was decided that the Bluetooth audio subsystem should
be in subsys/bluetooth/audio instead of subsys/bluetooth/host/audio.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add support for ISO feature bits. This includes extending fields that
hold features to 64 bits to be able to handle the host-controlled
"Isochronous Channels" feature.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Added Tx fragmentation implementation assertion to check
invalid offset use due to any memory corruptions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the vendor specific ticker resolution margin in the
central connection initiation offset calculation.
Related to commit 89ab68f242 ("bluetooth: controller:
Vendor specific ticker resolution margin").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the redundant advanced scheduling event margin used
while finding a free space between existing active central
connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the initial connection event length calculation to
when initiating connection so that initiator with advanced
scheduling to place central connections in a non-overlapping
timeline has the correct ticks slot value available.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add checks to detect ACL data lengths greater than the
configured maximum Tx buffer size in the controller.
The Host should conform to the LE_ACL_Data_Packet_Length
returned by the LE Read Buffer Size command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Optimize LOW_LAT_ULL scheduling by avoiding redundant
rx_demux mayfly enqueue. Only schedule after checking for
node rx or tx ack presence in the memq.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the Subsystem defined BT_PER_ADV_SYNC_MAX Kconfig in the
controller implementation of Periodic Advertising Sync Sets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
A line of code was guarded by CONFIG_BT_L2CAP_TX_FRAG_COUNT instead
of CONFIG_BT_ISO_TX_FRAG_COUNT.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
ISO is a building block for BT_AUDIO but it is not only
useful for AUDIO, and as such should be possible to
enable without enabling BT_AUDIO.
This commit moves iso.c and iso_internal.h to the
host directory (from host/audio) and removes
the CMakeLists.txt.
The /audio directory is left intact for the Kconfig options
it provides, and as a directory for future BLE Audio
content.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit moves the BT_ISO to a common (host and controller)
Kconfig and fixes the ISO buffers in hci_raw.c
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add release of memory acquired for periodic advetising sync. set
when:
- advertising set is removed
- advertising parameters are changed and past PDU type was
extended advertising PDU
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove LL_ASSERT from functions that return latest advertising PDU.
The LL_ASSERT was raised in situation that there is no memory to
store unused PDUs memory in a pdu_free queue or extra_data_free queue
Those functions return NULL in such sitation. The returned value is
verified by callers by LL_ASSERT. That gives better context if lack
of memory issue issue occurs.
Besides that there was removed a LL_ASSERT from lll_adv_pdu_and_extra_-
data_alloc. The reasons is the same as above, to give better context
when the lack of memory issue occurs.
This function is used in ULL context (ll_adv_sync_ad_data_set).
If it returns NULL the caller will return BT_HCI_ERR_MEM_CAPACITY_-
EXCEEDED to Host.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add set of functions that will make possible to configure
radio Direction Finding Extension to transmit CTE for periodic
advertising.
Some of the new Radio API functions are provided as separate
functions changing the same Radio peripheral registers, e.g.
radio_df_mode_set_aoa, radio_df_mode_set_aod. This is done on
purpose and is related with lack of DFE in nrf52_bsim.
To avoid use of conditionally compiled constants to represent
e.g. CTE mode; separate functions were introduced.
Thanks to that DF unit tests are able to compile successfully
without changes in nrf52_bsim platform. Also if DFE is added
to nrf52_bsim there is no need to change the code until it is
desired.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
The storage for extra data is required for implementation of
CTE transmission with periodic advertising.
Data required to transmit CTE correctly are compound of two parts:
- PDU field CTEInfo
- radio configuration to transmit actual constant tone at the end
of PDU.
Extra data is a storage required for radio configuration data.
Nevertheless it must be in compliance with content of CTEInfo field.
Because of that extra data is stored as part of lll_adv_pdu and
is double buffered like PDU memory.
Bluetooth 5.1 spec. allows to enable or disable CTE TX
and change CTE TX parameters when periodic advertising is
enabled. Besides that CTE TX settings may be set before periodic
advertising parameters are set. In such situation ll_adv_sync_set
may be not yet created.
To overcome these constraints ULL should store CTE TX
settings and forward them to LLL only when CTE TX is enabled.
Because of above reasons ULL stores CTE TX settings in ll_adv_set.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Directin Finding related features:
- transmission of connectionless CTE,
- antenna switching during CTE transmission (AoD),
to list of features supported by controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove support for nRF5340 PDK in the BLE controller.
The controller will now support only the nRF5340 DK.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Fix cancel of Periodic Synchronization on Coded PHY. Reset
the association of periodic sync instance after validation
of command disallowed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When address resolution is disabled, an identity address has
been added into the resolving list with peer IRK, and device
privacy has not been selected for the peer device then
connection indication shall not be sent to the peer that is
advertising using its identity address.
Fixes#24731.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fail after pairing request and response have been exchanged if the
selected pairing method would not result in the required security level.
This avoids the case where we would discover this after having encrypted
the connection and disconnect instead.
This was partially attempted but lacked checking for authentication
requirement when L3 was required, as well as skipping the check if L4
was required but remote did not support Secure Connections since the
check was after we had taken the legacy branch.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the error in the security changed callback when the encryption has
not reached the required security level.
Terminate the pairing procedure in SMP on failure to avoid the security
changed callback being called twice in this case.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Terminate the pairing procedure when disconnected while this was in
progress. This notifies the application that security has failed and
removes the key entry.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the SMP flag encryption pending in the case where a bond exists
with ediv and rand equal to zero, i.e LE Secure Connections bond.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When receiving unexpected SMP PDUs with no pairing procedures in
progress don't treat it as a pairing procedure that has failed.
This causes unexpected SMP PDUs to trigger the pairing failed and
security changed callback at unexpected times.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add status only pairing failed callbacks (complete and failed) so that
these handlers can be added without providing the ability for MITM
pairing procedures.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename auth_err_get to security_err_get which better reflect the
error namespace it converts to. Also update to using the enum definition
instead of uint8_t for local variable holding returned value.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
when BT_PASSKEY_INVALID was set, it never updated the fixed
passkey which made its use ineffective
Signed-off-by: Faisal Saleem <faisal.saleem@setec.com.au>
The ATT request buffers are held until the ATT response has been
received. This means that the ATT request buffers are released by the
RX thread, instead of the from the RX priority context of
num_complete.
This can cause a deadlock in the RX thread when we allocate buffers
and all the available buffers are ATT requests, since the RX thread is
the only thread that can release buffers.
Release the ATT request buffers once they have been sent and instead
handle ATT request resending by reconstructing the buffer from the
GATT parameters.
Also re-order the order of resource allocation by allocating the
request context before the buffer. This ensures that we cannot
allocate more buffers for ATT requests than there are ATT requests.
Fixed a buf reference leak that could occur when the ATT request buffer
has been allocated, but GATT returns an error before handing the
responsebility of the buffer to ATT, for example when bt_att_req_alloc
fails.
This is fixed by moving the functionality of att_req_destroy to
bt_att_req_free.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove the ATT request destroy callback which is never assigned
by any of the ATT requests.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix indicate without func not working properly, when sent as a
non-req by GATT this has two propblems:
- The indicate would not be treated as a transaction, and back
to back indicate would be sent without waiting for the confirm
- The destroy callback would not be called on the indicate parameters
since the indicate_rsp callback would not be called.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
ATT channels do support queueing buffer so it no longer need to block
waiting the tx_sem besides the buffer allocation already serves the
same purpose as the application will not be able to have more requests
than there are buffers available.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Allow to request a higher security level during the key distribution
phase.
This is required by ATT and L2CAP since they only react to the encrypt
change event where they resend the current request.
The current request might require a higher security level still and
might have to request a higher security level before the pairing
procedure has been finished.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When ATT resends an ATT request it is sent as a "response" instead of
as a request. This causes the ATT request buffer to be released and
the ATT request cannot be resent one more time.
This causes a problem when the ATT request requires authentication
but the elevation of security is not enforcing MITM protection.
In this case the ATT will first require security level 2 and then resend
the request once this has been reached.
This will lead to a new ATT error response and ATT will require security
level L3.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the update keys check allowing to overwrite the keys when using
debug keys. Instead the check disallowed overwriting keys made using
debug keys.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix gatt write command returned "write in progress" when either
hex2bin or bt_gatt_write returned an error.
The write_params.func should not be set if the write command was not
successful.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Sets the sequence number when re-encrypting messages from the friend to
the lpn.
This is a regression from #28511.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Set app_idx and net_idx in the msg_ctx before calling
bt_mesh_keys_resolve when re-encrypting friend messages, as they'll be
referenced inside the function.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix missing advertising PDU length initialization which
prevented advertising PDU to be transmitted by Radio. This
issue was reproduced when connectable undirected advertising
was enabled without setting an advertising data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After #31176, the network would get stored immediately in
bt_mesh_net_create, causing the address and devicekey to get stored as
their zero-initialized version, as they're only being set in the
bt_mesh_comp_provision call, which fires after.
Fixes#32067.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Reduces some user confusion regarding whether it is related
to "Connection ID", "Channel ID", or "Company ID" for the
uninitiated.
Signed-off-by: Emil Hammarstrom <emil.hammarstrom@assaabloy.com>
Fix OpenISA port to include compiler memory barrier as in
commit 1a14f8b3a6 ("Bluetooth: controller: Use DMB instead
of DSB").
Relates to commit 1af2b91c23 ("Bluetooth: controller: Fix
Tx Buffer Overflow") and to commit ef2ece82c0 ("Bluetooth:
controller: openisa: Fix sanitycheck failures") and to
commit c2fc629dd2 ("Bluetooth: controller: 255 byte AD
payload support").
Fixes#31937.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for OpenISA rv32m1_vega_ri5cy board not supporting
different IRQ Priority levels for LLL, ULL_HIGH and ULL_LOW
execution contexts.
Fixes#31937.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_ULL_HIGH_PRIO default value to equal
BT_CTLR_LLL_PRIO value if BT_CTLR_LOW_LAT is enabled, else
default ULL_HIGH to lower IRQ priority level in comparison
to LLL IRQ priority level. If BT_CTLR_ZLI is enabled,
BT_CTLR_ULL_HIGH_PRIO can default to a priority level value
of 0 and still be lower priority level than the LLL which
is placed at Zero Latency IRQ priority level (highest
priority in the CPU).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As network_decode needs a target buffer for decoding, the max PDU length
must be checked to prevent overflow on the target buffer. When receiving
a proxy configuration message with excessive length, there's no previous
check for this.
Also pulls the NET PDU length defines out into net.h, so they can be
used when defining the target buffers.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix Tx Buffer Overflow caused by uninitialized node_tx
memory being used by ULL ISR context due to Compiler
Instructions Reordering in the use of MFIFO_ENQUEUE.
The MFIFO last index was committed before the data element
was stored in the MFIFO due to Compiler Instructions
Reordering.
This is fixed now by adding a Data Memory Barrier
instruction alongwith a compiler memory clobber.
Fixes#30378.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use of Data Memory Barrier instruction with memory clobber
in ARM Cortex M architectures is sufficient in the
controller implementation to keep compiler data access
instructions in order so that an ISR vectoring has memory
accesses in the correct order as intented by design.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Mark the option BT_FIXED_PASSKEY as an insecure option.
During Legacy pairing the passkey is used as encryption key, and
brute-forcing this is easy.
During LE Secure Connections the passkey is checked one bit at a time,
so when it is fixed the passkey can be deduced with series of pairing
attempts.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Bluetooth SMP protocol depends on the BT_ECC for the LE Secure
Connections pairing. Since this feature cannot be disabled we must
select this dependency.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix fixed passkey for legacy pairing. The pairing procedure fails
because the temporary key (TK) has not been set for this pairing
procedure.
Fix this by always requesting the legacy TK.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix misleading message in the bluetooth shell when the id-create
command returns en error code. In this case both failure and success
messages are printed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add options to control the behavior of the init command.
Option no-settings-load allows the user to create identities
with the id-create command after bt_enable() but before settings_load().
Option no-ready-cb allows the user to test using synchronous enable,
since this sometimes leads to different behavior of the stack.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Prevent the bt_rand function from being called before bt_enable.
Depending on the implementation of bt_rand this function cannot
be called before bluetooth has been initialized. With host supplied
crypto functions the HCI LE rand command is used for example.
The use case for calling bt_id_create before bt_enable is meant for
when the application has storage for the identity instead of the stack.
So we add the requirement that the application has to have storage
for the identity resolving key (IRK) in addition when the local
device is privacy-enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the default ULL_HIGH execution priority to be lower than
LLL execution priority to reduce Radio ISR service latency.
Also, default to Zero Latency IRQ for Radio ISR if enabled
in the kernel.
Fixes#29994.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
ad_len parameter is not length of complete advertising data, but number
of bt_data structs passed to bt_le_per_adv_set_data - we pass only one.
Also memset target buffer before converting hex string so data shorter
than specified will be right-padded with zeroes instead of some
leftovers.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Fix the mayfly callee id for the rx_demux scheduling under
the LOW_LAT_ULL implementation. This could be causing
undefined mayfly execution behavior in nRF51x SoC.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the deprecated bt_conn_create_slave_le function.
This was deprecated in the 2.3.0 release.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Conform to Bluetooth Specification, if the LE_Scan_Enable
parameter is set to 0x01 and scanning is already enabled,
any change to the Filter_Duplicates setting shall take
effect. Disabling scanning when it is disabled has no
effect.
Fixes#31019.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in adding the state for Connection Parameter
Request being rejected where in Connection Parameter Request
Procedure state machine was prematurely reset before the
reject PDU was enqueued.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing initialization of ticks_to_offset value on
instantiation of new peripheral context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix repeated offsets in LE Connection Parameter Request PDU
due to rounding errors. Use tick units of connection
interval to calculate the offset units.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deferred Connection Parameter Request offset population
by introduction of explicit states waiting for the offset
calculations to complete in the ULL_LOW context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix deferred Connection Update offset population by
introduction of explicit states waiting for the offset
calculation to complete in the ULL_LOW context.
Fixes#29636.
The problem was, in an encrypted connection the enqueued PDU
to be transmitted is encrypt in the prepare callback by the
hardware and swapped to a different buffer for transmission;
the deferred offset population did not reflect in the
transmitted PDU as it was filled in the cleartext buffer
while encryption completed into the encrypted buffer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix error introduced by pull request:
https://github.com/zephyrproject-rtos/zephyr/pull/31591
Zephyrs CMake extension function zephyr_library_sources_ifdef()
does not allow to use complex conditions to toggle if
sources should be included in build or not.
It allows to use only single variable as an input for
feature_toggle argument because it is double-expanded
in contition statement in the function.
In case there is a requirement that source file is included
when more complicated condition is true we have to fall-back
to reqular if() statement and zephyr_library_sources().
The fix is required because without it radio_df.c source
is never compiled. If DF functionality is enabled build
will fail because of missing functions implementation.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix implementation to run local peripheral initiated control
procedure with instant in parallel with remote initiated
encryption procedure.
Relates to #28887.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If a PHY update is waiting for the instant to be reached and the master
starts the encryption procedure, store the pending PHY update procedure
and handle it simultaneously with the encryption setup.
This fix prevents the encryption setup from stalling and thereby timing
out after 40s, after which the master drops the link.
The ll_conn::llcp::encryption can not longer be unioned with the
ll_conn::llcp:phy_upd_ind as one would overwrite the other.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Add conditional compilation on peripheral and central
specific control procedure implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BIG Sync Terminate Command to generate Sync Established
event if Sync initiation is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added missing allocation of node rx buffer required for
generation of Broadcast ISO Sync Established.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The net_buf was never unref'ed when the host received an
ISO package that was a SINGLE.
Also adds a few additional debug messages.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
`iso send` may take an optional "count" parameter but the
number of optional arguments was incorrect.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The DF tests are implemented to be executed with nrf52_bsim platform.
The nrf52_bsim platform does not include Direction Finding Extenstion.
Due to that, radio_df.c compilation failed with error about missing
antenna configuration in DTS.
To solve the problem, I've changed nrf.cmake to include radio_df.c
file when CONFIG_BT_CTLR_DF is defined and CONFIG_SOC_SERIES_BSIM_NRFXX
is not definded.
Thanks to that any other platform is not affected. The file will not
build if there is no appropriate configuration or there are missing
features in a hardwared.
Unit tests have provided stub imlpementation or radio functionality.
If nrf52_bsim has implemented Direction Finding Extension, the
DF unit tests code will stil work and will not require additional
changes. Also content of the file is not affected by contional
compilation entries.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove ATT modifying the L2CAP channel state by unassigning the
the connection pointer on timeout.
Unassigning this pointer does not prevent the ATT channel from receiving
since bt_l2cap_recv does not inspect this pointer before calling the
channel receive function.
This prevented the disconnected callback from being called on the
channel after the channel had timed out, but since the disconnected
callback now handles this case this workaroun is no longer needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle ATT timeout on disconnected ATT channel.
When the ATT channel is disconnected with a pending request the ATT
timeout is canceled and the response processed with an error code.
However canceling of delayed work is not guaranted to succeed, e.g:
"Work queue thread has removed the work item from the queue but has not
called its handler"
This could lead to timeout handler being invoked after the disconnected
handler.
Fixes: #29098
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation error caused by use of wrong header file:
nrfx/hal/nrf_radio.h instead of hal/nrf_radio.h.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Coded PHY is only enabled by default if the application is using
BT_HCI_RAW.
Coded PHY is not needed in most applications.
By disabling Coded PHY, most applications will:
* Get smaller in terms of flash and ram usage
* Not get vurnerable to devices trying to switch to Coded and
thereby increasing power consumption.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Fix compilation error if CONFIG_BT_CTLR_DF is not defined.
If DF was not enabled, there was missing CONFIG_BT_CTLR_DF_MAX_-
ANT_SW_PATTERN_LEN and undeclared symbol was found.
Split ll_df.h into two parts:
- ll_df.h that is generally includeable and allows to successfully
compile sources when DF is not enabled.
- ll_df_internal.h to be used in soucres that are compiled when
DF is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Direction Finding requires initalization of a set of registers
in Radio peripheral. Also it requires information about antenna
matrix unit that are provided by end user in DTS overlay.
Implemented initialization step is responsible for validation of
hardware information delivered by DTS and setting up DF related
registers in Radio.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add support for Direction Finding antenna configuration in
Nordic hal of Bluetooth controller.
Add handling of response for HCI_LE_Read_Antenna_Information
HCI command in controller (upper and lower link layer).
Handling of response to the command requires antenna matrix
configuration.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
After nrfx glue code was decoupled from nrfx sources, it is no longer
feasible to use those inclusions in the <nrfx/hal/nrf_*.h> form (there
is no point in adding the main directory of the hal_nordic module as
an include path solely for this reason). Remove then the nrfx/ part.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Fix size of L2CAP disconnect request buffer pool which did not include
the size of the L2CAP signal header.
Regression from: 3346aa4d39
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Defined 625 and 1250 as context specific interval common to ULL and LLL.
Checked with bluetooth sanity checks.
Fixes#23314.
Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Some proprietary protocols that reuse the Bluetooth LLCP logic requires
that the CPR interval has a valid range that differs from the Bluetooth
specification defined.
Vendor must implement the function (ull_vendor.h)
uint16_t ull_conn_interval_min_get(struct ll_conn *conn)
that returns the valid limit for the given connection.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Allow vendor specific increase of user operation capacity for LLL, to
support queuing additional ticker operations from lower link layer
context. These would typically take place in lll_xxx_prepare.
Signed-off-by: Morten Priess <mtpr@oticon.com>
For Bluetooth Mesh, counter shall be increasing by one when
every try to establishing friendship.
Counter to be used when create friendship security material.
So this value shall be consist between friend and lpn.
Due to zephyr bluetooth mesh send previous counter, after that
it will automatically increase one, which will result in the
incorrect generation of friend key when key rephase.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The mesh settings.c module is a giant piece of code responsible for
storing the mesh stack configuration. Such approach makes it difficult
to control the data to be stored, breaks the stack modules'
encapsulation by forcing them to reveal the internal kitchen, which
leads to unpleasant issues such as #19799.
This commit moves the responsibility of storing the configuration
to corresponding modules while keeping control of the moment of storing
the configuration and of starting the stack after the settingss loading
is completed.
This doesn't introduce any abstraction between the mesh settings.c and
other modules as it will add more complexity and overhead than necessary
for the actual task.
Fixes#19850
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Add public function to set Constant Tone Extension transmission
enabled or disabled for periodic advertising.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Enable CTE HCI command requires update of a state of its
execution after receive command completion response from
controller. Host has already implemented such functionality
but it was used only internally by hci_core.
This commit changes it to be accessible from other sourece files
in host.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add implementation of HCI_Set_Connecitonless_CTE_TX_Enable
command to HCI. Add scratch implementation of command handling
functions to controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Fix compilation error caused by missing header files.
Reorganized order of header files include.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Correct names of kconfig entries to mach to style of other entries.
Style correction in hci.c. Use the same approach of checking if
Kconfig entry is enabled.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
MESH/NODE/CFG/HBS/BV-01-C expects the MinHops to be 0x7f after
disabling subscription, but 0x00 for subsequent Get requests.
MESH/NODE/CFG/HBS/BV-02-C expects us to return previous
count value and then reset it to 0.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
This is a pairing function with bt_le_scan_cb_register()
to used for remove the scanner callback from callback list.
Signed-off-by: chao an <anchao@xiaomi.com>
Fixed misalignment of bitflag in ll_conn type causing unintentional
overwrite between unions. Common flag must be present in master/slave
uinons as well. Problem is only present when enabling feature
CONFIG_BT_CTLR_CONN_META, which is default disabled.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Reserve two link rx buffer for each supported Broadcast ISO
sync instance, for establishment and for sync lost node rx
generation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For tx_power_max_get and tx_power_floor, only allow for
positive values of txpower if they are defined.
Signed-off-by: Aurora Sletnes Bjørlo <aurora.sletnes@nordicsemi.no>
Rename Kconfig BT_CTLR_SCAN_SYNC_ISO_MAX to
BT_CTLR_SCAN_SYNC_ISO_SET, to be consistent with other
Kconfig naming.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
AUX_CONNECT_RSP PDU static buffer definition was missing one
byte required for the Extended Header Flags.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Document with comments, the explanation of node rx count and
the design of the free rx PDU management.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for scenarios where in active PHY Update Procedure or
Connection Update Procedure could cause temporary depletion
of the free Rx PDUs in the queue between LL/HCI thread
context to LLL context. Symptoms being on-air NACKing during
the above said procedures, causing supervision timeouts due
to procedures not completing at instants.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the implementation of PA/LNA PPI configuration
which was done on every Tx or Rx as common code to be
executed once per radio reset. And only setup the timeout
and enabling of PPI at every Tx or Rx.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For PA/LNA implementation use NRF_P0/P1 defines instead of
the deprecated NRF_GPIO to reference GPIO Port 0 registers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the missing GPIOTE channel disable when GPIOTE channel
is alternately used between PA and LNA use.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in PA/LNA support wherein the GPIO pins where
left in undefined state after each radio event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression, add back missing call to radio_setup HAL
interface. This is needed to setup the initial PA/LNA GPIO
states.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix crash in ATT when the response for a request is received after
the ATT timeout has fired and the ATT channel has been detached.
Add similar handling for all ATT channel operations.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
SWI IRQ line mapping for nRF5340 shall use
CONFIG_SOC_NRF5340_CPUNET for conditional compilation
instead of the board define, so as to allow new boards to
use the BLE controller implementation.
Fixes#30488.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add publicly accessible function to set Constant Tone Extension
parameters for CTE transmission with periodic advertising.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add implementation of a wrapper for HCI_LE_Set_-
Connectionless_CTE_Transmit_Parameters send command.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Direction Finding to host initialization sequence.
It allows to get information about Direction finding
optional CTE settings supported by controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove is_enabled flag in LLL of BIS events context, as the
status returned from ticker_stop interface is sufficient to
determine if the Broadcast ISO Sync was established or not.
HCI Command Disallow as reason is to be returned if sync was
not established or sync was loss prior to call of HCI LE
BIG Terminate Command was called.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move lll_sync_iso.h as common to all vendors, as currently
there is nothing that is vendor specific.
Fixes#31044.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When using BT_GATT_AUTO_DISCOVER_CCC if the ccc_handle is not set
bt_gatt_subscribe would initiate a discovery to locate the CCC handle
but instead of awaiting it to complete the code does proceed to call
gatt_write_ccc even with ccc_handle being 0x0000 which is invalid.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
We have convenient PHY_1M, PHY_2M and PHY_CODED symbols defined but
they are not used too much in the code. This replaces all usages of
magic numbers and other symbols as PHY constants with those symbols.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Adds an assert on the "old" ref counter when doing unref, that
checks if there indeed is a reference to unref. This prevents
any underflows of the ref counter.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements the ull_sync_iso_setup function which starts the
ticker for ISO sync. Furthermore, ll_big_sync_terminate
will not stop the ticker as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements handling of the BIG sync commands in the ULL.
LLL support and handling of ACAD (biginfo) remaining.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adjust the PPI used by nRF51x and nRF52x so that PPI 0-5 is
available for application's use or for SW PWM driver use.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Under CONFIG_BT_TICKER_EXT configuration, the ticker interface has been
extended to support enabling/disabling must-expire scheduling. This
means that conn and slave ticker start calls can now omit must-expire
default-on configuration, relying on LLL updating the mode as needed.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Align bt_le_per_adv_sync_get_index, bt_conn_index and
bt_le_ext_adv_get_index in use of uintptr_t.
This fixes an issue where the cast to uint8_t happened before the
assert for a valid index, which could lead to invalid pointers passing
this assert.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Improve logging of pairing procedure when it fails with error code
unspecified. Since this is returned in many places debugging this
failure is not easy without adding additional debugging.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix parallel pairing procedures using LE SC requiring the DHKey
calculation at the same time. This would otherwise end all other
pairing procedures with the SMP error code "unspecified" since
the call to bt_gen_dh_key would fail.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the allowed command bitmask before sending the SMP packet. This
avoids a race-condition in case the sending of the PDU made the
current thread not ready and would not be scheduled back in time
to set the bit before receiving the next SMP packet.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Improve multiple DHKey handling by allowing the next DHKey calculation
to be started in the dhkey ready callback.
Return error code EALREADY if the provided callback is the current
callback generating the DHKey.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
We allocate nodes on receiving AUX_CONNECT_REQ, but we can only use
them if AUX_CONNECT_RSP is sent successfully. If that fails, we need
to release those nodes.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
If we allocate a node in LLL and it turns out that we don't need it
(e.g. allocated connection on AUX_CONNECT_REQ, but connection handshake
did not complete and we don't need it) we still need to send it to ULL
to be released. We can use existing NODE_RX_TYPE_DC_PDU_RELEASE node
type for this purpose, but we just need to make sure it's passed from
LLL to ULL properly.
Also, since this now does not only release DC PDUs, let's change its
name to a more generic one.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
After slave connection is created only adv instance is stopped, we also
need to stop aux separately if enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Make sure phy is properly initialized to 1M when ext adv is supported
and legacy advertising instance is being enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds handling for received AUX_CONNECT_REQ PDU which enables slave
connection with extended advertising.
Once AUX_CONNECT_REQ is received, standard checks are performed to
determine if we have resource to create connection, however unlike for
CONNECT_IND an rx node is temporarily kept in LLL until AUX_CONNECT_RSP
is successfully sent. This is to prevent creating a connection in case
response PDU was not sent for whatever reason.
A separate scratch buffer is created for AUX_CONNECT_RSP since default
radio scratch buffer is already used by received AUX_CONNECT_REQ.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Connection structs need to be initialized when advertising is enabled
on connectable extended advertising instance.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Connection created from extended advertising instance uses the same phy
as on secondary channels.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
transmitWindowDelay is either 2.5ms or 3.75ms when AUX_CONNECT_REQ is
used (for 1M/2M and Coded respectively). It also uses the same unit
as transmitWindowOffset (1.25ms) so we can just simply add both.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
The same helper will be used for legacy and extended advertising so we
better pass AdvA and TargetA directly instead of complete advertising
PDU. This is because those fields are at different locations in legacy
and extended advertising PDUs so caller can figure them out.
Also, we can now check for directed advertising using TargetA since it
will be only supplied for such advertising (NULL otherwise).
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Release the LF clock requested in blocking mode used to wait
to settle, which has already been asynchronously requested.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix lll_clock_wait function to wait for LF clock to settle
only once after power up.
Regression introduced in commit 2b4763076e ("bluetooth:
controller: Adapt to onoff clock control").
Fixes#30480.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Clean up included header files, remove including
zephyr/types.h and other deprecated or redundant
header files.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If the SRC field of the received message is a unicast
address of an element of the Low Power node, then the
message shall not be stored in the Friend Queue.
Otherwise, lpn will discard this message, eventually
it breaks friendship.
Fixes: #30657
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Validate the disconnect reason in the disconnect command, according
to the the core specification.
7.1.6 Disconnect command:
Authentication Failure error code (0x05), Other End Terminated Connec-
tion error codes (0x13 to 0x15), Unsupported Remote Feature error code
(0x1A), Pairing with Unit Key Not Supported error code (0x29) and Unac-
ceptable Connection Parameters error code (0x3B).
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Return the error code from the disconnect command to the application
when an invalid disconnect reason has been provided.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add implementation of HCI_LE_Set_Connectionless_CTE_-
Transmit_Parameters command in HCI.
Add implementation of command handling in controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Sets the LPN state to WAIT_UPDATE when waiting for the initial poll
response when disabling LPN_ESTABLISHMENT. Previously, the LPN node
would stay in the wait offer state even after the offer was processed,
which led to it aborting the friend establishment completely if it
failed to receive the first poll.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
While the friend node considers the friendship established as soon as it
sends the friendship offer, the LPN only considers the friendship
established once it receives the first update after its poll. This
update is encrypted with the friendship credentials, which aren't
available, as they're protected by an if (lpn_established()) check.
Changes the check to lpn_waiting_update(), which makes the LPN check its
friendship credentials only when it's expecting a response to a poll
message. This is the only time the friend will send messages encrypted
with the friendship credentials.
This is a regression from #28511.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Explicitly sets the LPN credentials when sending a friend request.
This fixes a regression from #28511.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Do not abort pairing when peer sends a SMP command with an opcode
reserved for future use, as per spec.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Add a dummy SMP command handler for keypress notification, that does
nothing (yet). This allows the next commit to work properly.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Fix TIMER0 and RTC0 being selectable when using out-of-tree Bluetooth
controller.
Generalize the Kconfig to have the features that use the HW peripheral
select them as reserved to make the dependencies more manageable.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Bluetooth Mesh require minimum limit time to enter iv update
state or return to iv nornal state.
For Zephyr bluetooth mesh implementation, use`ivu_duration`
type `uint8_t` to represent current time, but if the time is
more than 255 hours, there will be problems due to the
overflow of 8-bit unassigned variables.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The K_MSEC macro evaluates its argument twice, which causes double
evaluation of some function calls in the mesh stack.
This removes all instances of function calls inside K_MSEC macros in the
mesh stack.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Added a new Bluetooth API that can be used to read the current and
maximum transmit power level of the radio. The reading operation is
performed over HCI.
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
Previously, if the peer address was not set, the host would
do undirected advertising even if the application applied
options only applicable to directed advertising.
Adding this additional parameter validation reduces the confusion
of application developers when they have configured something wrong.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
`POLL_TIMEOUT_MAX` should use `CONFIG_BT_MESH_LPN_POLL_TIMEOUT`
instead of `CONFIG_BT_MESH_LPN_INIT_POLL_TIMEOUT`. The described
algorithm to grow the poll timeout implemented in function
poll_timeout does not work with this implementation.
It's a regression in 3b4d58a
Bluetooth: Mesh: optimize performance for lpn node
Fixes: #30338
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Release the CUI/CPR lock if the connection owning the lock is
terminated.
This can happen if a device performing a CUI/CPR procedure gets a LSTO
before the procedeure completes or the procedure itself TO.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
`app_key_del` first param should be key_app_idx,
not key_net_idx.
The effect is that app_key_del is broken.
It's a regression in eca014115
Bluetooth: Mesh: Isolate cryptographic material
Fixes: 30468
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Adds support for extended advertiser commands in the mesh. This doubles
throughput for common packet sending, and significantly improves timing
accuracy for the Friend and Low Power features.
The proxy module's advertisement control has been moved inside the adv
module to abstract away the different advertiser modes.
The extended advertiser mode does not need an advertising thread to
operate, and ends up with a net reduction in RAM usage.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This tiny header uses non-builtin types but includes no headers that
would define them. Recent header motion seems to have exposed a case
where this file can get built before its dependencies are included.
Add the header directly.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
When CONFIG_BT_CTLR_CONN_META is enabled and the ticker "must_expire"
feature is used, collisions may cause incorrect decrement of the
supervision_expire counter, resulting in a too early link supervision
timeout.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix incorrect initiator window offset used when in continous
initiator scanning. Calculated window offset to free time
space after existing central connections is not decremented
correctly when there is change in window at every initiator
scan interval.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix corruption of ftr auto-variable due to reuse to insert
new node rx into the received auxiliary PDU chain, which can
cause corrupt reference used later in the implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix PHY Update control procedure to accept the preferred Tx
coding options (S2 or S8) requested even if there is no
actual PHY change happening on procedure completion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Both AdvA and TargetA have constant offset in extended header so it
makes sense to have dedicated definitions for those numbers.
AdvA is always placed at the beginning on extended header while TargetA
follows AdvA directly. There are no PDUs without AdvA and with only
TargetA.
Offsets of other fields depends on extended header contents and thus
are non constant.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
'ext_hdr' member only covers extended header part of 'ext_hdr_adv_data'
and with addition of 'data' member to 'pdu_adv_ext_hdr' those can be
used to quickly access both extended header flags and data directly
from 'pdu_adv' without need for extra local variables and casts.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
pdu_adv_hdr name is quite confusing since it suggests some generic
header for advertising PDUs while this in fact is extended header
which is a part of common extended advertising payload and only applies
to extended advertising PDUs.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
The 'adi' part of that member name does not make sense since ADI is
already part of extended header, so we only have 'extended header' and
'advertising data'.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
If handle mapping is enabled, we need to use proper advertising set
handle in HCI event.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
When legacy set is configured we need to make sure scan response is
properly initialized with empty data. For extended sets we should not
touch scan response on configure since data for those sets have to be
set explicitly, e.g. we cannot enable scannable advertising set if no
data was set.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
AdvA in extended advertising PDUs was only set if random address was
used. This patch enables proper support for AdvA/TgtA in those PDUs
also with LL Privacy enabled.
On enable, we always update advertising PDU (i.e. ADV_IND, ADV_EXT_IND
or ADV_AUX_IND, depending on advertising set parameters) as well as
scan response PDU.
On RPA timeout, we simply copy old PDU as-is and update AdvA in new
PDU, since both PDUs are exactly the same (except AdvA) so no need to
recreate it step-by-step.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Guards the functions with CONFIG_BT_CTLR_HCI_ADV_HANDLE_MAPPING
and added a non-HCI inline function for them.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Removed the node_rx argument for the BIG create/terminate
functions. The event should not be sent right after the
command, but needs to wait for transmissions of
empty BIS packets or BIG terminate indications.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Moves the ISO tx pool and functions from ull_adv_iso.c to
ull_iso.c as the pool and functions will be shared between
BIS and CIS.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Rearranged the functions so the order of functions match
the common pattern in other ULL files.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements the BIG terminate command that terminates a
BIG and returns the appropriate events.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When a BIG is create, it will now start sending empty BIS PDUs;
at least from an ULL perspective, as the LLL support is still
missing.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Implements handling of the BIG create command in the upper link layer.
Does not yet handle sending any BIS events.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix Extended Scanning on Coded PHY, auxiliary PDUs on Coded
PHY where not received due to redundant conditional code
only applicable in connection role being copy-pasted during
the development of Extended Scanning feature.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use memmove to copy overlapping memory when populating the
Common Extended Advertising Header Format in the advertising
PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix maximum PDU len configuration when advertising and/or
scanning on primary channels.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Change type of advertising set handle to 8 bit to comply with
Bluetooth Core spec. type.
Fixes wrong usage of adv. set handle variable in function
bt_le_per_adv_set_param.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Remove irq_lock around connection lookup, this is no longer needed
now that the lookup functions always have a valid reference.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make the connection lookup functions thread-safe by re-using the
bt_conn_ref returning NULL mechanism and keeping a valid reference.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make bt_conn_ref return NULL if the reference count has reached zero.
This makes it possible to re-use bt_conn_ref internally to re-use the
reference count mechanism to check if the reference is in use.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use common definitions of HAL_USED_PPI_CHANNELS and HAL_USED_PPI_GROUPS
macros that will provide (through z_bt_ctlr_used_nrf_ppi_* variables)
information about either PPI or DPPI (depending on the SoC) resources
used by the Bluetooth controller.
Update also the hal_nordic module revision, to make the related nrfx
allocator aware of those reserved DPPI resources.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Remove no longer needed definition of NRFX_PPI_CHANNELS_USED_BY_PWM_SW
(after recent changes in the nrf_hw_models models, also for simulated
nRF boards the nrfx_glue.h file is processed, so this symbol is always
defined).
Remove also a couple of *_PPI_x_INCLUDE macros, to make the code a bit
clearer and to avoid things like a build assertion (also removed here)
that checks if HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_0_INCLUDE is indeed
defined as BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(0)).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Put infrastructure for the following HCI commands/events in place:
* LE Read ISO Link Quality command
* LE Read ISO TX Sync command
* LE Set Host Feature Command
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Since first poll request send by lpn use friend security
credentials, so, friend nodes should be able to decrypt with
friend security, even if they have not yet established a friendship.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When friend node key refresh phase to stage_1, there
are need to add friend update message to friend queue,
but, when friend KR phase to stage_2, must add friend
update to queue.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Friend node cache segment message for lpn, message with
sequence number can't change, since could cause lpn replay
attack.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix field names of bt_hci_cp_le_setup_iso_path in le_setup_iso_path to
make CIS central/periphal compile and adjust parameter names for
ll_setup_iso_path accordingly.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
A single-shot ticker in requested state beyond the elapsed
duration or skipped due to collision shall generate an
operation callback with failure status.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
In the case where a BLE connection ticker node collides and does not
trigger a callback to ULL, and at the same time the same node receives a
ticker update request, the update causes the node to be scheduled for
execution a second time. This has the consequence of event_counter going
out of sync, and BLE connection is ultimately lost.
The solution is to mark collsions and re-scheduled nodes as expired, and
use the increased lazy count to identify its state instead of req/ack.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Implement HCI commands to read information about supported codecs and
controller delay.
* Read Local Supported Codecs command (v1 and v2)
* Read Local Supported Codec Capabilities command
* Read Local Supported Controller Delay command
The following functions are implemented as "weak" symbols and should
be overridden to fill in vendor-specific information into the above
commands.
* hci_vendor_read_std_codecs
* hci_vendor_read_vs_codecs
* hci_vendor_read_codec_capabilities
* hci_vendor_read_ctlr_delay
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Add defines and structs for reading information about supported codes,
codec capabilities and controller delays. Return parameter structs for
commands that return multiple variable-length fields only model the
fixed-length fields to minimize inconsistencies.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Legacy functionality in ull_conn will force scheduling of a connection
which has missed an anchor point due to lost RX. This kicks in either
for previously skipped events (latenzy_event != 0) or at random
depending on the randomness of the AA bit pattern.
This behavior is good at ensuring that a connection with errors or
aborted RX gets prioitized, and helps break locked round-robin
patterns with lost sync, but it also breaks the predictability of
the round-robin ticker scheduling.
With "must_expire" enabled, this feature also kicks in for scheduling
collisions, which may not be desirable.
This commit adds a configuration flag, BT_CTLR_CONN_RANDOM_FORCE, which
is default enabled (legacy behavior).
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix missing initialization of periodic interval value in
advertising report info structure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Clarify that the acl_data struct includes the bt_buf type as the
first variable in the user data struct.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor out implementation of functions defined in buf.h to its own
source file buf.c
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add implementation of HCI_LE_Set_Connection_CTE_Transmit_Parameters
for Bluetooth 5.1 Direction Finding.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add separated Kconfig file for Bluetooth 5.1 Direction Finding.
Enable controller support for:
- transmission of CTE
- 2us antenna switching
- 1us antenna switching
if build for nRF52833 SOC.
Add HAS_HW_NRF_RADIO_BLE_DF to nrf52833 SOC configuration.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add partial implementation for handling Bluetooth 5.1 Direction
Finding HCI command HCI_LE_Read_Antenna_Information to controller
Upper Link layer.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Add Bluetooth 5.1 Direction Finding HCI command:
HCI_LE_Read_Antenna_Information handling to Host.
Add wrapper function to handle send the command
and receive response from Controller.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Adds a cli_reset to mod_sub if no status response was requested. This
adds a non-blocking mode to the mod_sub calls, matching the behavior of
other cfg_cli functions.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Missing copy net_idx to ctx, this cause tx subnet not found
or different with rx subnet, when rx subnet net_idx not zero.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Nothing in the API description the delayed work structure sanctions
direct reference to internal fields. Do not assume that a delayed
work item can be submitted without delay by invoking k_work_submit()
with a reference to the contained work item. Instead submit with the
delayed API and no wait.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Fix node rx buffer leak if extended advertising and/or
periodic sync reports are masked out by the host.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added code comments to explain the reasons to drop
incomplete advertising and sync report.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising Report generation that skipped
population of AD data when there was no extended header.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Put infrastructure for the following HCI commands/events in place:
* LE Setup ISO Data Path command
* LE Remove ISO Data Path command
* Configure Data Path command
* LE Set CIG Parameters Test command
* LE ISO Read Test Counters command
* LE ISO Receive Test command
* LE ISO Test End command
* LE ISO Transmit Test command
Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
Periodic Advertising Set Info Transfer depends on Extended
Advertising and connections hence enclose the LE Periodic
Advertising Set Info Sync Transfer implementation inside
CONFIG_BT_PER_ADV and CONFIG_BT_CONN conditional
compilation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Periodic Advertising Sync Transfer depends on connections
hence enclose the LE Periodic Advertising Sync Transfer
Received Event code inside CONFIG_BT_CONN conditional
compilation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the debug key-set comparison for debug keys comparing the
generated key in big-endian format against the debug private
key in little-endian format.
Fix this by converting the private key to big-endian format for
convenience.
Use the _be suffix for all variables to make the mixing of the
endian formats easier to read.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Two ull_adv_sync function declarations, ull_adv_sync_reset and
ull_adv_sync_init was guarded by a #if causing CI issues.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The same code block for marking an object with
ull_disable_mark, stopping the ticker and then unmarking
the object appeared multiple places; often with a regression
bug where instead of unmarking it in case of error, it would
be "remarked".
This commit fixes the bug, and moves the functionality to
a common function.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Wrong use of function `find_msb_set(~link.rx.seg)`,
uint8_t type is implicitly converted to uint32_t.
As a result, it always returns 32 instead of the
expected value, resulting in abnormal processing
of prov segment.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
The structure pointer was wrongly cleared before,
`bearer` and `role` in `bt_mesh_prov_link` structure
resulting in illegal pointer access.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
When kr phase to `BT_MESH_KEY_REVOKED`, should also call beacon
authentication, since beacon flag has change(0x01-->0x00).
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
DIS module builts fine when BT_DIS_SETTINGS is selected, but SETTINGS is
not. However no settings handlers are executed, just like with
BT_DIS_SETTINGS disabled, which might confuse user.
Select SETTINGS, so settings handlers are properly selected and executed
in runtime.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Currently BT_DIS_SETTINGS and BT_SETTINGS are independent in
Kconfig. This seems fine, because BT_SETTINGS pulls a lot of
functionality, which is not really needed to implement DIS with values
configured in runtime (from settings subsystem).
Drop BT_SETTINGS conditional compilation and leave check on
BT_DIS_SETTINGS only.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
In architectures supporting more than 8 WL entries, e.g. pure
software implementations, it is desirable to be able to increase the
WL size. This change increases the range to 1..16 for SOCs other than
nRF5x and OpenISA.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix sanitycheck failures when building
samples/bluetooth/peripheral_hr for rv32m1_vega_ri5cy
platform.
Updates from nRF platform related to 255 byte AD data
support have been directly copied into openisa port to
fix build failures.
Relates to commit c2fc629dd2 ("Bluetooth: controller:
255 byte AD payload support").
Fixes#29967.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow vendor specific increase of user operation capacity for
THREAD, to support queuing additional ticker operations.
Relocate TICKER_USER_<XXX>_VENDOR_OPS to before TICKER_USER_<XXX>_OPS.
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
Fix regression in connection radio event close in central
role introduced in commit 222dca5598Fixes#29957.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Change adds missing TX power dependencies. nRF52833 and nRF52820 SoCs
also support higher TX power values.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Adds support for using the periodic advertiser list.
This list allows the application to rely on specific
devices when creating periodic advertising syncs.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds support for the periodic advertising sync transfer
(PAST) feature, which allows a synced device, or an
advertiser, to transfer synchronization of a periodic
advertising train to a connected device.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix use of deprecated scan parameter filter_dup.
Should have been changed to options as part of:
be57dfbe2a
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
pdu->len is only 8 bits and CONFIG_BT_CTLR_ADV_DATA_LEN_MAX
can be upto 1650 bytes. Fix the implementation to use 16
bit auto variable to check AD data length overflow.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Extended Advertising Data population when there is no
Extended Header to be filled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
.../ll_sw/nordic/lll/lll_scan.c: In function 'isr_tx':
.../ll_sw/nordic/lll/lll_scan.c:483:19: error: unused variable 'lll'
[-Werror=unused-variable]
483 | struct lll_scan *lll = param;
| ^~~
cc1: all warnings being treated as errors
This fixes https://github.com/zephyrproject-rtos/zephyr/issues/29968.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Since ADV_EXT_IND is received on primary channel, the AR is configured
to resolve AdvA in legacy PDU (assuming on 1M) and it will not resolve
AdvA properly. In such case, we should resolve AdvA manually in LLL.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This allows to synchronously resolve any address using AAR. The AAR
has to be configured prior to calling this function.
The intended use for this function is to resolve AdvA in a PDU on
primary channel when AR was configured for different PDU type. That
means AR was configured to resolve in legacy PDU, but extended PDU
was received and we need to resolve AdvA manually. In such case, AAR
is already configured so just need to trigger it again with proper
ADDRPTR.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This patch allows to configure AR for resolving AdvA in extended adv
PDUs. The extra 'flags' field provides a hint from caller on how to
setup AR:
- if legacy PDU is expected, AdvA is set after PDU header,
- if extended PDU is expected, AdvA is set with +2B offset due to
common extended advertising header,
- if Coded PHY is used, AdvA is set with extra +5b offset due to CI and
TERM1 fields.
Note that AUX_SCAN_REQ and AUX_CONNECT_REQ are also considered legacy
PDUs here since they are exactly the same as SCAN_REQ and CONNECT_IND.
If neither legacy nor extended PDU is specified, it's derived from PHY,
i.e. 1M means legacy, non-1M means extended. Since it is still possible
to receive different type PDU in such case, it's up to LLL to detect
this and resolve AdvA when RX is done.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Instead of guarding the NODE_RX_TYPE_USER cases with
CONFIG_BT_CTLR_USER_EXT we guard them with
CONFIG_BT_CTLR_USER_EVT_RANGE > 0 as that is the actual value that
enables/disables the NODE_RX_TYPE_USER values.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of having explicit values for each entry in the enum that
has to be updated for each new entry (thus requiring manual work
which can also be error-prone), the enum will now be
self-incrementing, to make it easier and safer to add new
entries.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Removed the #ifdef's for the node_rx_type enum. Since the
savings, they just make the enum harder to read.
Furthermore it will also ensure that all the enum values
will have the same value once the enum entries are no
longer manually defined.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
lll->conn is only defined valid when BT_CENTRAL is enabled.
Also ull_sched_mfy_after_mstr_offset_get is only used when BT_CENTRAL
is enabled.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Adds check for TTL max in the transport send functions, and moves
setting of default TTL to transport.
Fixes#29855.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Change the advertising option that controls if the directed advertiser
will use an RPA or the identity address of the peer for the initiator
address.
This option currently has two issues:
- It behaves differently if the privacy feature has been enabled,
which can be confusing for application to use.
- It cannot start a directed advertiser towards a peer that is not
privacy-enabled and has distributed an IRK.
This commit includes the following changes:
- When privacy has been enabled in order to advertise towards a
privacy-enabled peer the BT_LE_ADV_OPT_DIR_ADDR_RPA option must now
be set (same as when privacy has been disabled).
- It is now possible to start a directed advertiser using the identity
address of the peer when privacy-enabled.
- When privacy has been enabled the advertising option combination
of using the local identity address and an RPA as the initiator
address is now disallowed and will return an error code.
This is done because this combination did not actually work and would
have used the identity address of the peer instead.
- If the controller does not support controller-based privacy then
using the option BT_LE_ADV_OPT_DIR_ADDR_RPA will return ENOTSUP
because this behavior cannot be done with host-based privacy.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Host can discard scan response data by setting empty data. We simply
set PDU length to 0 to indicate this, it will make future check easier.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Align the PDU buffer reference in struct node_rx_pdu so that
node rx type specific parameters, like, terminate and sync
lost reason can be accessed without any memory alignment
issues.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix maximum Advertising Channel PDU payload size calculation
by including the Common Extended Advertising Payload Format
overload alongwith the AD data maximum size supported.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation using mfifo to return stale AD data PDU
from LLL to Thread context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Kconfig option to configure maximum number of buffered
AD data PDUs across enabled advertising sets.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Put infrastructure for the following HCI commands/events in place:
* LE Set CIG Parameters command
* LE Remove CIG command
* LE Create CIS command
* LE Accept CIS Request command
* LE Reject CIS Request command
* LE CIS Established event
* LE CIS Request event
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Adds a `destroy` callback to the `struct bt_gatt_indicate_params` which
is used to signify to the application that the indication operation has
completed and the struct instance can be freed/destroyed.
This is required as the number of indication value callbacks that will
be triggered is not known by the caller when the `conn` parameter is
`NULL`.
Tracking when this callback should be run is mananged by a private
reference counter inside the struct.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Update the signature of the `bt_gatt_indicate_func_t` callback type by
replacing the attr pointer with a pointer to the
`bt_gatt_indicate_params` struct that was used to start the indication.
This allows the callback to free the `bt_gatt_indicate_params` instance
if it was allocated from storage, while still allowing the
`bt_gatt_attr` value to be accessed through `params->attr`.
Allocating the `bt_gatt_indicate_params` instance from storage is
desirable as multiple indications can be queued, however each instance
must be valid until the callback is run.
Implements API update from #29357
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Allow application to enable L2CAP dynamic channels without support
for Enhanced Credit Based Flow Control (CBFC).
Since these are separate features in the qualification it should
be possible to qualify L2CAP connection oriented channels without
also having to qualify L2CAP enhanced credit based flow control.
The L2CAP/LE/REJ/BI-02-C conformance test will fail when enhanced CBFC
has not been selected in the ICS.
The lower tester expects that since the Enhanced CBFC is not supported,
the command L2CAP_CREDIT_BASED_CONNECTION_REQ should be met with an
L2CAP_COMMAND_REJECT_RSP and not an L2CAP_CREDIT_BASED_CONNECTION_RSP.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Moves mesh feature configuration to a separate module, deprecating the
bt_mesh_cfg_srv structure. The initial values for the features should
now be enabled through KConfig, where new config entries have been added
for each feature.
This removes the upward dependency on the config server from the core
stack, and makes the config server a pure frontend for the configuration
states, as all spec mandated behavior around the feature states is now
encapsulated.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Encapsulates the Heartbeat state and functionality in a separate
heartbeat module, removing all manipulation of the heartbeat state from
the transport and config server modules.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Places definition of lll under the ADV_EXT #ifdef in lll_adv.c:isr_tx,
to silence build warnings for non-AE builds.
Follow-up from #29753.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
We need to use actual phy wherever required to make sure radio delays
are calculated properly. This is especially important for LE Coded
since delays for that phy are significantly higher than on 1M and 2M.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
ull_adv_data_set() is only used for legacy advertising data (either via
legacy HCI command or as fallback for extended advertising set which
uses legacy PDUs) so there is no need to check for extended advertising.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
We handle secondary channel only for extended advertising sets, that
means we always have ADV_EXT_IND on primary channel so there is no need
to support non-ext PDUs here.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Replaces all existing variants of value clamping with the MIN and MAX
macros with the CLAMP macro.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The decision to set aszmic = 1 in the net_tx structure was made after
the variable was passed to the crypto context, creating a discrepancy
between the two when aszmic is 1.
Extracts transport encryption to a separate function.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The PA sync callbacks would have been registered for each new
PA sync, which would cause the callbacks to be called multiple times
if multiple PA syncs were created.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The sync established event caused by a cancel by the host
was not properly handled. When cancelling the sync established
event is created, and the sync object should not be deleted
before that event is received.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Only set friend_cred to true when friendship established and
use friend cred security material decryption successfully.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Fixes bug where applications that disable model extensions end up in an
infinite loop, and adds support for walking model subtrees, as opposed
to forcing root to be unextended.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add generation of Advertising Set Terminated event on High
Duty Cycle Directed Advertising Timeout.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce the use of ARG_UNUSED on auto variables and try to
use conditional compilation where appropriate.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
`bt_mesh_model_tree_walk()` was too simplistic and did not track visited
nodes which caused it to fall into infinite loop. Moreover the double
next jump could skip a level causing depth value to be invalid.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
../zephyrNew/subsys/bluetooth/mesh/prov.c: In function
'bt_mesh_prov_reset_state': ../zephyrNew/subsys/bluetooth/mesh
/prov.c:61:2⚠️ '__builtin_memset' offset [52, 292] from
the object at 'bt_mesh_prov_link' is out of the bounds of referenced
subobject 'dhkey' with type 'uint8_t[32]' {aka 'unsigned char[32]'}
at offset 19 [-Warray-bounds] 61 | memset(&bt_mesh_prov_link.dhkey, 0,
Fixes: #29634
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
If chan->conn is already NULL do not call bt_conn_unref as that will
likely cause a crash, also this make sure that if channel has been
disconnected using bt_iso_chan_disconnect it removes the channel from
connection list before setting the chan->conn to NULL.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Document and validate advertising parameters for the disallowed
advertising mode high duty cycle directed connectable advertising
using extended advertising PDUs.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue where the encrypt change has an error code, but the
encrypt change request was unrelated to the current ATT request.
This lead to the current ATT transaction being interpreted as finished
an the ATT client would proceed with the next ATT request, which would
fail since the ATT client is now violating the ATT single transaction
rule.
Updated similar if statement checking for the opposite to improve
readability.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Moves the virtual address labels to the transport layer, disconnecting
them from the configuration server.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
If low power node publish with unicast address other
than friend address, the friend node should relayed
this message to all network interface.
When Proxy feature enabled, message from gatt bearer should
relay to adv bearer even relay feature disabled.
Fixes: #29544
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Currently all provisioning procedure into common source
files call `prov.c`, that will not compile separately.
Add `BT_MESH_NODE` to control whether nodes are supported
and device provisioning is supported, this will be used in
provisioner role.
Add more provisioner OOB authentication method.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Fix arguments unused when not enabling Extended Scanning
which was introduced in
commit 0cef1e43c9 ("Bluetooth: controller: Extended
Scanning Coded PHY duration and period").
Fixes#29442.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix application conn param update submitted before the timeout of
CONFIG_BT_CONN_PARAM_UPDATE has expired being ignored when
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename the update_work handler to deferred_work since this handler
is being multiplexed for different kinds of deferred work, not just
updating the connection parameters.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move auto-initiation of the peripheral connection parameter update,
this handling would only submit the delayed work with the timeout once
all other auto initiated procedures had completed. This behavior means
that the delay would not be set on when the connection was established
but instead relative to the previous procedures.
Based on the connection interval used, the instant(s) used, and the
number of auto procedures this delay becomes indeterminate.
Submit the work once connected, the constraint that existed in the
zephyr link layer earlier about requesting only one control procedure
at a time has been removed.
This also brings all the handling of the timeout work to the connection
state handling, which makes it easier to track this behavior in code.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Document the behavior of the bt_conn_le_conn_update API when the
local device is the peripheral role.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add Queue Size and Receive Window information to lpn
callback function to notify upper layer to determine
currently friend node information, which may be used
in future.
Add Callback structure to notification application which friendship
has been changed.
Add function `bt_mesh_friend_terminate` let's app layer determine
terminate friendship manually.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Fix ifdef in command inclusion, in practice this meant that
CONFIG_BT_LL_SW_SPLIT and CONFIG_BT_CTLR_ADV_EXT switched meaning.
Added blank lines so that the commands in shell/ll.c are more
easily visible as group.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Introduce a support kconfig for controller ECDH command support.
Default to host ECDH emulation in combined host controller build
where the controller does not support these commands.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This is a major refactoring of the handling of the cryptographic
material of both the network and transport layers. The aim is to
encapsulate the key object manipulation, and improve overall modularity.
Pulls Applications and Subnets out of the bt_mesh and into separate
modules, with static storage types on the data. This has several
side-effects:
- The Config Server no longer operates directly on the bt_mesh.subs and
bt_mesh.apps lists, but goes through a public configuration interface,
following the pattern set in #27908.
- All iteration through the keys is done through iteration APIs
- Key resolution on RX and TX is centralized.
- Changes to the keys triggers events the other modules can register
handlers for.
- Friendship credentials are stored in the lpn and friend structures.
Part of #27842.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This makes it possible to pass different byte arrays to gatt write
making it usable to test attributes that take more than a single byte.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This prevents any work to be submitted until the stack is initialized
thus avoiding pointless hash generation, etc, while initializing the
system.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Adds support for enabling/disabling PA sync receive,
which allows applications to control when to receive data
while a sync is established.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
If an ACL connection is disconnected while there is an ISO connection
associated with it the ACL connection will not be cleanup properly as
the code attempt to cleanup the ISO connection and breaks without
proceeding to cleanup the ACL as well.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The callbacks has been moved from being local to each
bt_le_per_adv_sync object, to being global. The
removal of the pointer in bt_le_per_adv_sync was
missing from that update.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix shell build errors when building with combined host and controller
but the selected controller is not the in-tree zephyr controller, i.e
CONFIG_BT_CTLR=y, CONFIG_BT_LL_SW_SPLIT=n and cmd_scanx and others
are not defined.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use conversion macros to convert Extended Scan duration and
period to radio event counts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to support simultaneous 1M and Coded
PHY Extended Scanning duration and period. Also, added
implementation to support update to duration and period of
an active scanning instance.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the ll_scan_enable interface signature, place duration
before period parameter to reflect the order as in the HCI
LE Set Extended Scan Enable command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix scan done to be generated when the window is closed
both under abort and graceful window close.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the implementation to set scanning channel to
isr_window function where the next window is started,
instead of being at the abort of the previous continuous
window.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix scanning state and is_adv_ind flags to be common to both
isr_done and isr_window code path.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactoring of conditional compilation related to extended
scanning with duration and period.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rework implementation handling the disable and the error
handling when failure to start Periodic Advertising
instance.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect use of unint32_t instead of a sufficient
uint8_t for the returned HCI error code.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Decouple updates to primary and secondary AD Data PDU such
that primary PDU changes can be committed on successful
scheduling of secondary PDU radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit makes sure the string generated by bt_uuid_to_str is correct
if the architecture is big-endian.
Signed-off-by: François Delawarde <fnde@demant.com>
Remove the range on the setting the bluetooth BT_RX_STACK_SIZE.
This range prevents setting the RX stack size lower than 1024,
which depending on the application is too high.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
According Mesh Spec 1.0.1 Section 7.2.2.2.1 Advertising
A node that does not support the Proxy feature or has the Proxy
feature disabled shall not advertise with Network ID.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Be consistent in the permission handling of the discovered attribute
in the temporary object given in the discovery callback.
For characteristics the permission field was set to READ, while for
all other attributes it was set to 0.
Fixes: #29083
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update check in the bt_gatt_attr_value_handle API function to use the
UUID of the function, in case the attribute has been declared with a
different read handler, or the attribute is a temporary object
where the read attribute has not been set.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor use of 16-bit common GATT UUID types where a complete UUID
object is declared on the stack only to use the 16-bit value.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Reduce the size of the disconnect pool required the full MTU
for a disconnect request.
Also completely remove the pool when not needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the missing return statement when Auxiliary PDU
transmission is aborted because Primary PDU does not have
the aux pointer setup. Also, directly stop clocks and
post LLL done, like being done in other state/role LLL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor Extended Advertising conditional compilation reorder
to better reflect the order Observer->Extended Scanning
dependency.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
NODE_RX_TYPE_EXT_ADV_TERMINATE is generated in ULL context
and shall not increment received PDU quota value.
Fixes#29101.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Port minor anchor point synchronization drift implementation
changes.
Relates to changes in commit 732de50f67 ("Bluetooth:
controller: Refactor out drift compensation code").
Fixes#29062.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add assert check to detect failure to enqueue ticker
operations. This will avoid HCI thread from stalling
forever on k_sem_take.
This assert will trigger on design fault, not defining
enough queued ticker operations count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a missing NULL pointer dereference check and made the
structure member scan->per_scan.sync and timeout_reload as
volatile, as they are modified in ISR context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added link structure allocation explanation related to HCI
event generation by the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Experimental keyword to LE Periodic Advertising in
Advertising and Synchronization state Kconfig title.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the auxiliary pointer and sync information offset and
offset unit population. Offsets are 13-bit value, use 300 us
offset unit when offset value using 30 us offset unit does
not fit in 13-bits.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Minor print format update, updated format for Periodic
Advertising Interval, and added SID to be printed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add the missing resources like ticker instances, Rx PDU
buffers and memory queue link buffers, that are required
for Periodic Advertising Sync creation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove the redundant ticker update check, ticker is not
stopped and started in Periodic Advertising unlike in a
Connection Update Procedure in connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Replace printk in ISR with BT_WARN to avoid problems with
co-existing with logging subsystem.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove generation of Periodic Sync Lost HCI event generation
that is not needed as per BT Spec. v5.2 Vol.4 Part E.
Section 7.8.69.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix uninitialized rl_idx value for the Extended Advertising
PDU received in the auxiliary channels. This caused
uninitialized rl_idx to be used by HCI layer and fail an
assert check in ull_filter.c file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing periodic advertising start due to missing
allocation of auxiliary context when no Extended
Advertising PDU on auxiliary channels.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove conditional compilation on structure definition in
pdu.h so as to allow inclusion of header files with
function prototypes that use those structures. I.e. to
avoid conditionally including the header file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to perform Periodic Sync Terminate,
generation of Sync Lost on terminate and on remote device
termination of Periodic Advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to handle Periodic Advertising clock
drift in the created Periodic Advertising Sync instance.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix auxiliary channel scanning to capture the PDU end
timing that is need to correctly setup Periodic Sync.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fill the correct local clock accurracy in the Sync Info
structure in the Periodic Advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out drift compensation implementation so as to
reuse it for Periodic Sync feature.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added initial implementation of setting up of Periodic Sync
and scheduling the Radio Events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out common lll_abort_cb function so that it can be
used across Periodic Advertising and Periodic Advertising
Sync creation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out clock ppm interface so that it can be reused
for Periodic Advertising Sync feature.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Don't use the ATT structs that has contains only a flexible array
member. This is not supported by C99 standard, only through GNU C
extension with zero length array.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix implicit declaration warning for peripheral_latency_cancel
by moving it to ull_slave file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The BT code uses co-op thread priorities to implement some
critical sections. This won't work with SMP turned on.
Express this in our configuration ontology, so that it's
not possible for the end user to set up the system in this
way and get crashes or odd behavior.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Added a check for adv->lll.aux before starting extended advertising to
fix observed NULL pointer dereference when updating AD data of legacy
advertising.
Fixes#28544.
Signed-off-by: Jordan Montgomery <montytyper@msn.com>
Changes the callbacks for periodic sync callbacks such that multiple
applications can register callbacks, similar to the connection and
scan callbacks.
This change will make it easier to support the PAST feature, as
PA syncs make be created by the controller which then notifies
the host, and thus the application (if callback registered).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Replace all calls to the assert macro that comes from libc by calls to
__ASSERT_NO_MSG(). This is usefull as the former might be different
depending on the libc used and the later can be customized to reduce
flash footprint.
Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
The scan callbacks may be NULL, which would cause an error if
e.g. the timeout callback wasn't set and the scan terminates after
a timeout.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix conditional compilation to allow building test shell
with Periodic Advertising Sync alone.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix controller implementation to cancel peripheral latency
when initiating new control procedures.
Fixes#28699.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add checks to abort connection radio event preparation and
start, if the connection terminates with a race condition
with new radio event being prepared or being in prepare
pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix undeclared CONFIG_BT_CTLR_DATA_LENGTH_MAX when Force
MD bit automatic feature is enabled in nRF51 Series.
Fixes#28774.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added automatic runtime calculation of Forced MD bit count
based on incoming Tx buffer throughput.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add Force MD bit feature wherein connection events can be
extended to match the rate at which applications provide
new Tx data. MD bit in Tx PDUs is forced on if there has
been CONFIG_BT_CTLR_TX_BUFFERS count number times Tx/Rx
happened in a connection event. The assumption here is,
if controller's tx buffers are full, it is probable that
the application would send more Tx data during the
connection event, and keeping the connection event alive
will help improve overall throughput.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add force Md bit feature wherein connection events can be
extended to match the rate at which applications provide
new Tx data.
Fixes#27981.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the check that decides to close a connection event,
which was missing a check on MD bit being set for empty PDU
to be Tx-ed out.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Optimize the Tx PDU preparation, empty PDU only needs MD bit
to be modified, other fields be initialised only at power up.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix premature connection event close due to the new Tx
buffers not being de-multiplexed and routed to connection's
Lower Link Layer context when they arrive while being
inside the connection's radio event.
Also, fix master prepare to demux and enqueue two Tx buffers
so that MD bit can be set correctly.
Relates to #27981.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor ull_conn_tx_ack function as it no longer needs to
return the connection context back to caller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds check for provisioning random values that are identical to our own,
and terminates the provisioning procedure.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
In bt_set_name we already get name length so let's use it in strncpy
Also fix warning with enable -Wstringop-truncation
Signed-off-by: Ilya Averyanov <a1ien.n3t@gmail.com>
The sync create and sync delete dit not have the correct
amount of mandatory and optional parameters set in the
SHELL_CMD_ARG declarations.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The sync terminate callback did not set any entries in the
PA sync array to NULL, thus not allowing the shell to
reuse them in case that the sync was lost unexpectectly.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Instead of doing slow (non-fast) scan when syncing to
a PA, it will now do a fast scan, which drastically reduces the
time it takes to create the sync. The application may
still do explicit slow scan if wanted.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
When the application cancels the PA sync, it would update
the scan before clearing the BT_PER_ADV_SYNC_SYNCING flag
which cause the scan to always start again.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix the redundant PDU transmission when the new Tx PDU
buffer is enqueued after MD bit value of zero was
transmitted previously in a connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bt_le_oob_get_local and bt_le_ext_adv_oob_get_local stuck forever
waiting for the sc_local_pkey_ready semaphore when SC HCI commands
are not supported in the controller.
By using the le_sc_supported helper function the runtime check of HCI
commands and the feature check of CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY
is combined to be handled int the same way.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move the le_sc_supported helper function up in the source file so that
it can be re-used in other places without a forward declaration.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
If hannel don't have alloc_buf and the RX MTU is configured to require
segmentation this warn the user and truncate the RX MTU.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In case where ull_adv::disable() is disallowed, disable_mark is
erroneously re-mark instead of un-marked
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Accourding to the spec the CCC descriptor may occur in any position
within the characteristic definition after the Characteristic Value.
Fixes#28324
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix for handling REJECT_IND PDU received for PHY Update,
Connection Parameter Request and Data Length Update control
procedures.
If a link layer control procedure collision occurs, example
with local initiated PHY Update Procedure, and peer sends a
REJECT_IND PDU, then the PHY Update Procedure is stalled.
Fixes#28282.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
According Mesh Profile Spec 5.4.2.4 Authentication, if device
use Input OOB Authentication method, should send input complete
pub after local public key has been acked.
`bt_mesh_input_string` or `bt_mesh_input_number` directly send
`input_complete`, however does not check whether the pub key has
been sent.
Mesh Provisioning timeout set to `60` seconds, so even this
probability is extremely low, it does not mean that there is no
such probability.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Fix bug in device name shortening handling leading to memory
corruption.
This is triggered by an underflow in the length field of the shortened
name when set_data_len + 2 > set_data_len_max.
Fixes: #27693
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Ignore error when failing to set the passive scanner private address.
This can happen because in between the time we checked if the
advertiser was enabled and the time we execute the set random address
command the state of the advertiser could have changed in the
controller, and we only set the state once the command has completed
in the controller.
Fixes: #25672
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix not setting NRPA before starting scanner.
Occurs with BT_PRIVACY=n and BT_EXT_ADV=y
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Re-structures the `bt_conn_recv()` to support more generic appending of
new ACL data. This also handles the possibility of receiving 0-length
ACL_START and ACL_CONT fragments, whilst maintaining existing
error-checking functionality.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Fixes issue #26900.
A controller may fragment an L2CAP SDUs in any way it sees fit,
including fragmenting the L2CAP header. Likewise, the receiving
controller may send the fragmented header as ACL data to the host.
The Zephyr host assumed that a `BT_ACL_START` was at least 2 bytes long,
and consequently read the two-byte length field from the buffer without
length checks.
This commit allows the `BT_ACL_START` to be less than two bytes,
updating the `conn->rx_len` onces the `BT_ACL_CONT` with the remaining
part of the length field has been received.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Fix Kconfig dependencies for enabling the controller PHY options
for LE 2M Phy and LE Coded Phy. These options should be selectable
without connections enabled when extended advertising has been enabled.
The issue affects out-of-tree controllers that wish to use the
BT_CTLR_PHY_CODED and BT_CTLR_PHY_2M options.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Select the controller feature support for data length and LE 2M PHY
based on the SoC hardware capabilities instead of relying on SoC
family.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When attempting to bind a channel if it fails the code will attempt to
cleanup calling bt_iso_cleanup which expects connections of
BT_CONN_TYPE_ISO.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
ISO connection does not initialize its tx_complete_work nor it uses for
anything so calling into tx_notify will likely cause a crash.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Now that CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE defines a stack size, allow
for it to be configurable from a .conf file just like the rest of the
threads in Bluetooth.
Fixes#27768.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Replaces the current zero length array for provisioner data with
ifdefs, to silence new gcc 10 warnings about array element access.
Fixes#28371.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
the adv instance should be delete correctly if advertise fail,
Otherwise the instance will unable to allocate if start the legacy again
Signed-off-by: chao an <anchao@xiaomi.com>
Fixes a memory leak when a virtual address subscription is added for a
model that either has this VA already, or the model has no more space
for subscription addresses.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add back call to LE Write Suggested Default Data Length
command so that new connections, receiving Data Length
Update procedure before local device can auto initiate, can
respond with the suggested default data length Tx octets
and Tx time.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When controller is built with extended advertising support but without
LL Privacy build fails due to issue with code that sets TxAdd in aux
PDU:
.../ll_sw/ull_adv_aux.c: In function 'ull_adv_aux_hdr_set_clear':
.../ll_sw/ull_adv_aux.c:502:25: error: 'struct ll_adv_set' has no
member named 'own_addr_type'
502 | sec_pdu->tx_addr = adv->own_addr_type & 0x1;
|
We need own_addr_type value if an advertising set with aux but without
AD is created since we cannot get TxAdd value from other PDU.
ull_adv_aux_hdr_set_clear() can now be called with a flag to explicitly
set AdvA field and pass own_addr_type in 'value' parameter. This allows
to set proper TxAdd when creating new advertising set.
On aux updates, we use TxAdd from other PDU:
- if primary PDU has AdvA, we use TxAdd from that PDU
- if previous secundary PDU has AdvA, we use TxAdd from that PDU
In other case we just return an unpsecified error since this should not
happen in any valid scenario.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Added a Kconfig option to enable scanner with unreserved
scan window when in continuous scan mode. This will permit
scanner to be always pre-empted by other roles, making it
the lowest in priority when it comes to using the radio.
Fixes#27414.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This introduces bt_gatt_attr_get_handle which can be used to resolve
handles of static attributes.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Make it actually give the original pointer to the attribute and its
resolved handle so static attributes don't need an extra lookup.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This optimizes the lookups to skip ahead when attribute pointer is not
located within service array.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds iso shell module which we can be used to exercise ISO related
APIs:
iso - Bluetooth ISO shell commands
Subcommands:
bind :[dir] [interval] [packing] [framing] [latency] [sdu]
[phy] [rtn]
connect :Connect ISO Channel
listen :[security level]
send :Send to ISO Channel
disconnect :Disconnect ISO Channel
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds supports for ISO packets so then can be transmitted and
received with hci_raw driver.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Some logging configuration are compatible with software-base Link
Layer. Currently only one configuration is supported:
RTT back-end in drop mode and no clean output
Signed-off-by: Guillaume Lager <guillaume.lager@gmail.com>
Add the command add-subscription to the shell to test the
bt_gatt_add_subscription API.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow the application to add subscription without resubscribing.
This is needed for persistent bonds that can go to deep sleep and
turn of the RAM or power-cycle.
In this case the application as a GATT client must have a way to add
the subscription callbacks back to the stack before the GATT server
sends notifications.
This should preferable be able to be done before even connecting
since the notifications can arrive immediately after connecting to
the peer.
The stack cannot persist this on it's own since it must remember the
function pointers for the callback functions. Storing these in
persistent storage would not be compatible with a Device Firmware
Upgrade (DFU) solution.
Fixes: #21798
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the gatt_sub_add function to be similar in structure to how
find_cf_cfg is implemented. This is so that a subscription can be added
without an active connection.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove the BT_LL_SW_SPLIT dependency for
BT_CTLR_DEBUG_PINS_CPUAPP when building CPUAPP application
that is using Zephyr BLE HCI controller on the CPUNET core.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The _gatt_ infix was determined to be unnecessary as
GATT is implied by it being a Bluetooth service.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The _gatt_ infix was determined to be unnecessary as
GATT is implied by it being a Bluetooth service.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The _gatt_ infix was determined to be unnecessary as
GATT is implied by it being a Bluetooth service.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add handling of the HCI_Hardware_Error event to log the hardware code.
This event was unmasked in set_event_mask.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add a name to the Kconfig choice that selects the controller TX power.
This allows board `*.defconfig` files to change the default TX power
as their certifications warrant. For example:
```
choice BT_CTLR_TX_PWR
default BT_CTLR_TX_PWR_PLUS_4
endchoice
```
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Preserve the TX power set with the `BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL`
command for advertising and scanning procedures. As the TX power is no
longer overwritten on procedure start, the TX powers can now be set
before starting the procedure. This eliminates the chance for the first
transmissions to use the default TX power instead of the request TX
power.
Similar changes are not made to the connection advertising powers as
changing the TX power for a connection to device A should not change
the TX power for a future connection to device B using the same
`struct lll_adv` instance.
Fixes#27921.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
ADI field is optional in AUX_SCAN_RSP so by default it's disabled, but
now we'll have an option to include it.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
When aux is upated, DID is changed and unlike SID it's only stored in
aux PDU. To allow quick access to new DID value, let's just optionally
return current ADI value after aux was updated. It will be useful e.g.
when updating scan response data if we want to put ADI there.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This enables processing of AUX_SCAN_REQ and sending back AUX_SCAN_RSP
on non-connectabe scannable advertising instances. Similar path will
be used for AUX_CONNECT_REQ so there are few references for connectable
as well, but this is not supported as for now.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This adds restrictions for setting scan response data as specified by
Core spec:
* on legacy, only complete data can be set
* on legacy, data cannot be longer than 31 octets
* on ext, if non-scannable, data can only be discarded
* if ext enabled, only complete data can be set
* if ext enabled, data cannot be discarded
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
This allows to set scan response data using ext adv commands.
New AUX_SCAN_RSP can be created without analyzing previous PDU since
the only value that need to be copied from previous PDU is AdvA which
is placed at fixed location. TxPower is omitted since, if enabled, it
is already present in AUX_ADV_IND and does not need to be presed in
other PDUs. ADI support is to be added later.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
AdvA in aux is mandatory for any connectable and scannable set so make
sure it's always added.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Connectable and scannable instances always have aux so we need to force
AuxPtr to be included in primary PDU and have aux allocated even if no
data are set.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Connectable and scannable instances always have AuxPtr so we can return
error immediately if controller is configured with no aux.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Prevent redundant collision resolves and potential incorrect and harmful
increment of lazy_current.
During collision scenarios with high CPU load, the ticker_worker may be
called a second time before the ticker_job gets to run. This will cause
ticker operations on the previosly expired node (expected), and in some
cases increment lazy_current, even though the node was not sceduled to
execute via the req/ack mechanism.
By moving the request check before collision resolve, CPU time is saved,
and lazy_current will not incorrectly be incremented if node is in
collision.
The problem may be seen as a connection suddenly not receiving packets,
or MIC error on master, because the event counter goes out of sync.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Use a helper config BT_CTLR_CONN_RSSI_SUPPORT so that it is only
enabled when supported by the controller.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Those APIs are used for deleting appkey, unbinding an application
from SIG model, unbinding an application from vendor model on the
target node, with matching shell command.
Signed-off-by: YanBiao Hao <haoyanbiao@126.com>
When lazy loading of CCCs are enabled there is no settings set handler
register for the 'bt/ccc' key, this means that the settings set handler
for 'bt' key is called instead. This handler does not know what to do
for the 'ccc' subkey, and returns -ENOENT for the entry.
This results in an error message logged by the settings subsystem.
"E: set-value failure. key: bt/ccc/f8c39e2f98210 error(-2)"
Fix this by providing an empty handler for the 'bt/ccc' key when
Lazy Loading feature is enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix periodic advertising delete implementation, to not
NULL the callback pointer when deleting the instance so
that the application's terminate callback can be called
thereafter.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.
A coccinelle rule is used for this:
@r_const_dev_1
disable optional_qualifier
@
@@
-struct device *
+const struct device *
@r_const_dev_2
disable optional_qualifier
@
@@
-struct device * const
+const struct device *
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Many #ifdefs can be removed, but the UNPROV_BEACON_INT Kconfig
variable needs to be also made available also. This is done by making
its prompt (user selectability) optional rather than the option
itself. This approach is fine for "parameter style" options, but
should probably not be used for feature enabling options.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
A build assert in dummy.c lists the following requirement:
[...] receive thread priority shall be higher than the Bluetooth
Host's Tx and the Controller's receive thread priority.
This is required in order to dispatch Number of Completed Packets
event before any new data arrives on a connection to the Host threads.
The drivers uses a priority that is equal to the Host TX thread,
and since they don't use the CONFIG define that is only available
to the controller then this BUILD_ASSERT will not catch the
requirement.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds a Config Client API for deleting netkeys on the target node, with
matching shell command.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Added a callback that lets an application get write error
(if any) when subscribing to a gatt characteristic.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
Fix option USE_IDENTITY for bt_le_ext_adv_* API.
The random static identity address that was set in bt_le_ext_adv_create
was overwritten in bt_le_ext_adv_start in the call to
le_adv_set_private_addr.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add the nRF52805-specific file with radio related defintions.
Use also specific configurations for certain PPI channels used by
the controller, as this SoC has limited number of programmable PPI
channels.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Change hard-coded (D)PPI channel bitfield values to the BIT() macro
calls with the corresponding channel base value supplied as parameter,
to make it possible to actually change this base value if needed.
Remove unused *_EXCLUDE macros.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
nRF5340 does have SWI peripheral, hence use it instead of
the single available EGU peripheral. Use of SWI will allow
controller's LLL, ULL_HIGH and ULL_LOW execution context to
be independently configured to different interrupt priority
levels.
When ULL_HIGH priority equals ULL_LOW priority, only SWI2
is used by controller. Otherwise, SWI3 is used for ULL_LOW.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Detect and handle AD data set race condition between thread
and ISR context.
Fixes#27637.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add cpu_dsb() hal interface so that data synchronization
barrier be used in ARM Cortex M4 and M33 architecture
implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Set the AD data double buffer first index as volatile
because it is modified in LLL ISR context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out into function the filling of sync info
structure in the common extended advertising payload format
header.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out into function the filling of aux ptr structure
in the common extended advertising payload format header.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out into functions the calculation of common
extended advertising payload format header length.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Moved the assignment of PDU length out side of a conditional
so that code to calculate PDU length can be reused.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor out sync info field population into a utility
function with set and clear interface to add or remove
the common extended advertising header format fields.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Changes the local network interface to exclusively handle packets for
the local interface, duplicating the buffers in the process.
The loopback mechanism now operates its own packet pool for the local
interface queue. The loopback is moved ahead of encryption, allowing the
local interface packets to go back up the stack without network crypto,
saving a full round of encrypt/decrypt for self-send.
Packets for group addresses the local node subscribes to are now
duplicated, with one unencrypted variant going into the network
queue, and the network bound packets following the regular path to the
advertiser.
Introduces one new configuration for setting the number of loopback
buffers.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
enable CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY:
In function `bt_le_oob_get_local':
subsys/bluetooth/host/hci_core.c:8878:
undefined reference to `bt_smp_le_oob_generate_sc_data'
Signed-off-by: chao an <anchao@xiaomi.com>
It fixes:
../../../../include/toolchain/gcc.h:169:30: warning: statement will
never be executed [-Wswitch-unreachable]
169 | #define __fallthrough __attribute__((fallthrough))
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
The PA sync is now "deleted" (i.e. flags reset) before
the terminated callback is called, so that is
possible to create PA sync in the callback. One flag
was already cleared before for this reason, but one
other flag is also required, so we just clear
everything now.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
Removed the check for explicit scanning, such that
an application may create a PA sync while explicitely
scanning.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
Fix conditional compilations that fail when combinations
of Broadcaster, Observer, Peripheral and/or Central are
selected to build an application.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix conditional compilations that fail when combinations
of Broadcaster, Observer, Peripheral and/or Central are
selected to build an application.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If `CONFIG_BT_CENTRAL` was enabled and the device was not scanning
or connected, then `bt_le_per_adv_sync_create` would not start
scanning for periodic advertisers.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
Mark the ram version of the ccc_cfg as free after ccc has been
stored when a bonded device disconnects.
If the device use lazy loading of settings then ccc_cfg was not
cleaned up properly when a bonded device disconnects. This
resulted in the ccc system ran out of ccc_cfg resources after
having disconnected CONFIG_BT_MAX_CONN times.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
Step1: Move bt_gatt_disconnected() to avoid forward declarations which
otherwise would be needed by a fix to lazy loading cleanup on
disconnect in step 2.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
Since bt_l2cap_send_cb can fail returning its error is not enough as
the buffer has been modified to add the headers, so this save the state
before calling bt_conn_send_cb and takes a reference so it can be
restored its original state in case of error.
Fixes#27434
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
-Wimplicit-fallthrough=2 requires a fallthrough comment or a compiler
to tells gcc that this happens intentionally.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Elevate connections always to security mode 1 level 4 when
Secure Connections Only Mode has been enabled in the Security Manager.
Elevate connections always to security mode 1 level 3 when
Legacy pairing with OOB only has been enabled in the Security Manager.
Fixes: #27338
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Return BT_HCI_ERR_INVALID_CONN_ID if an invalid handle is
given by the HCI; currently sometimes BT_HCI_ERR_CMD_DISALLOWED
is returned
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Removed the check for selected_per_adv_sync as it was unused by the
create/delete functions (which take the index as parameters), and
caused the shell not to print any values.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
The `free_per_adv_sync` pointer in `cmd_per_adv_sync_create`
did not work as intended, as it didn't actually update the
pointer in the array, which caused the
`cmd_per_adv_sync_delete` to not function as intended.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
If CONFIG_BT_EXT_ADV was enabled but
CONFIG_BT_EXT_ADV_LEGACY_SUPPORT was disabled and
CONFIG_NO_OPTIMIZATIONS was enabled, then there was a
maybe-initialized warning. Fixed by adding additional
checks.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Core 5.2, Vol 4, Part E, section 5.3.1 clarifies that advertising set
handle is assigned by host when advertising set is created and this
happens only on LE Set Extended Advertising Parameters.
An advertising set handle is an arbitrary number within allowed range,
i.e. 0x00-0xEF and not 0..max_supported-1.
This patch adds option to enable advertising set handle mapping from
HCI range as defined by Core specification to zero-based handles used
by LL. If enabled, HCI handle will be remapped to LL handle for each
command, otherwise HCI handle will be used as an LL handle. The latter
effectively skips mapping logic and should be used with Zephyr host
which uses zero based indexes.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
There's not need to mark advertising set as created by either legacy
or advertising command since this is determined by current so-called
HCI advertising mode which determines whether host uses legacy or
extended advertising commands.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
As per Core 5.2, Part B, section 3.1.1 controller should not allow
mixing of legacy and extended advertising commands. Once 1st command
is received from host, we should only allow commands of the same type
and return an error on other commands.
If legacy advertising interface is selected by 1st command received,
we need to make sure that set with handle=0 is created since it's
used by all legacy commands.
When not using external host, we assume that only extended advertising
interface will be used thus all checks can be skipped (optimized and
compiled-out).
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
A lot of commands return CC event with status parameter only, especially
when error is returned. This patch adds a helper to create such event,
similar to cmd_status.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Proper error code should be returned if advertising set with given
handle does not exist instead of generic "invalid parameters" one.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
AdvA in extended advertising PDUs is put at different offset than in
legacy PDUs thus it's better to let caller calculate and pass AdvA and
TxAdd explicitly. This way we won't need to check whether scan request
was on legacy or extended PDU every time.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
When a connect indication contains a channel map of all zeros, the
adv->conn is left NULL'ed after return and next connect attempt leads
to a crash.
This was identified via the Sweyntooth test suite executing the script
re. issue 6.14 towards an Oticon target.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Move call to reset_pairing to bt_conn_security_changed, since this
should always be done at the same time, and should be done in the same
order for all calls. For auth_complete this was reset after the
callbacks, which is inconsistent with the other events.
Also call it even if not connected anymore, the disconnection complete
event will be delivered after this event. Callback should alway be
called if security was initiated.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added support for syncing to periodic advetisements.
The API and usage is heavily inspired by the extended advertisement
and connection APIs.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
Added the ext adv report interval to bt_le_scan_recv_info which
denotes whether or not there is periodic advertisement data
associated with the advertisement report.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
Added API to set periodic adv parameters, periodic adv data
and to enable/disable periodic advertisement.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
It does not auto-initiate the DLE procedure if the default data length
parameters are not equal to the initial parameters.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Some controllers do not follow the recommendation of auto-initiating
a data length update if the host writes default data length parameters.
If the controller follows this recommendation, calling
LE Write Suggested Default Data Length command is sufficient
to ensure that the LL will auto-initiate the DLE procedure. Performing
a second procedure is unecessary.
In Core v5.2, Vol 4, Part E, Section 7.8.35:
The HCI_LE_Write_Suggested_Default_Data_Length command allows the
Host to specify its suggested values for the Controller's maximum
transmission number of payload octets and maximum packet
transmission time for packets containing LL Data PDUs to be used
for new connections. The Controller may use smaller or larger values
for connInitialMaxTxOctets and connInitialMaxTxTime based on local
information.
In short, this command sets connInitialMaxTxOctets
and connInitialMaxTxTime.
In Core v5.2, Vol 6, Part B, Section 4.5.10:
For a new connection: connMaxTxOctets shall be set to
connInitialMaxTxOctets and connMaxRxOctets shall be chosen by the
Controller. If either value is not 27 then the Controller should
initiate the Data Length Update Procedure at the earliest practical
opportunity.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Fix issue with bt_gatt_service_unregister not clearing CCC information.
If the service is unregistered while an unbonded peer is connected and
subscribed then this CCC would be restored again when registering the
service even if the peer is now disconnected.
If the service is unregistered with bonded peers CCCs stored in settings
then this value would never be cleared. If the service is registered
again then the peer would receive a service changed for this service,
but it's CCC value would still be enabled.
Fixes: #26924
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Extract enqueue of GATT CCC when CONFIG_BT_SETTINGS_CCC_STORE_ON_WRITE
is enabled to a helper function gatt_ccc_conn_enqueue so that it can be
reused.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move the clear_ccc_cfg function further up to be re-used without a
forward declaration in bt_gatt_service_unregister.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Starts the periodic heartbeat publish period at the end of the
publication, instead of at the ordering time. This ensures that the
heartbeat period doesn't get shortened by other enqueued messages.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When performing node reset over a proxy connection, the disconnection is
asynchronous, and will finish after the reset callback goes to the
application. If the application restarts provisioning in this callback,
the disconnected-event is triggered after PB GATT is reactivated, and
this error is printed without any faults actually occurring.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Notify L2CAP when pairing procedure fails during SMP pairing
process. L2CAP needs to be notified so that it can cancel
ongoing connection-oriented channel requests.
Rename bt_l2cap_encrypt_change to bt_l2cap_security_changed and
call it from bt_conn_security_changed always, so that L2CAP
is informed when changing security fails.
This also fixes security_changed conn callback not called when
auth_complete returns an error.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Avoid warning in att_handle_rsp, only call this when there is a
pending ATT request. This avoids a warning happens when elevating
security fails but higher security had not been requested by an
ATT request.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
squash! Bluetooth: ATT: Remove warning when no ATT process pending
Elevate the security level before sending the connection request if
the application has set a required security level on the channel.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Elevate the security level of the connection when the l2cap channel
connect request is denied with encryption or authentication error
code.
The l2cap channel required_sec_level was used, but this is not
correct as this is set by the user of the API. This resulted in
the call to bt_conn_set_security seeing that the current security
level was already set, decide there is nothing to be done and return
success.
Fixes: #27220
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use safe for-each loop in bt_l2cap_encrypt_change since dynamic
channels with pending connection-oriented channel requests will
be canceled and removed from the list if the encryption change
failed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove dependency on CONFIG_BT_ACL_FLOW_CONTROL and use
CONFIG_BT_L2CAP_RX_MTU always to set L2CAP RX MTU.
The ATT MTU is set from two different KConfig options depending
on if CONFIG_BT_ACL_FLOW_CONTROL is enabled, which makes it
a confusing option and hard to provide a conf file that
supports multiple board configurations.
This changes the behavior when CONFIG_BT_ACL_FLOW_CONTROL and
CONFIG_BT_BUF_RX_LEN was used to set the L2CAP RX MTU, and by
extension the ATT MTU.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix incorrect use of LLL ticker user id in ULL_LOW execution
context.
Regression introduced in commit 23ef75f6d9 ("Bluetooth:
controller: split: Fix Low Latency Prepare Done").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
EATT channels use bt_l2cap_chan_send which does return the number of
bytes sent on success not 0 as bt_l2cap_send.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fill the referenced event counter of the Periodic
Advertising SYNC_IND PDU into the sync info struct in the
Common Extended Advertising Header Format.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fill the missing Periodic Advertising interval in the
Extended Advertising Report when Auxiliary PDUs contain
Sync Info fields.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reject the security request immediately when receiving a security
request that does not support LE Secury Connections pairing.
This would have been rejected during the pairing procedure, but
PTS testing expects the security request to be rejected.
Ref: GAP/SEC/SEM/BV-29-C
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When using CONFIG_BT_CONN_DISABLE_SECURITY bt_gatt_check_perm would
ignore not only the security sensitive permissions but also access
related ones causing crashes since the callback would be NULL.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Move implementation of hci_driver.h exposed functions to a common file.
The functions exposed by hci_driver.h header file is implemented in
either hci_core.c, or hci_raw.c. But since these functions would be
identical for both implementations have them in a new file that is
included for both.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Defined struct in node rx for passing event parameters of
Advertising Set Terminated Event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Implementation of Advertising Set Terminated Event on
duration sans use of additional variable in advertising
set context structure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This adds CONFIG_BT_CONN_DISABLE_SECURITY which can be used to disable
security checks for incoming requests enabling to test accessing GATT
attributes and L2CAP channels that would otherwise require
encryption/authentication in order to be accessed.
It depends on BT_TESTING to indicate to the users that this is a
testing feature which shall not be used in production.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
It should be possible to identify whether advertising set uses legacy
or extended advertising to avoid performing operations that are not
supported on either of them.
For example, scannable advertising can have advertising data set only
if legacy PDUs are used.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
Fix a crash in the persistent advertising handling.
This occurs because the callstack of the RX thread overflowed
due to an infinite recursion between bt_conn_unref and
bt_le_adv_resume.
This happens when starting a new advertiser is denied by the
controller, then the conn object reserved will be released again
and the host will attempt to resume advertising in the bt_conn_unerf
at the end of bt_le_adv_resume.
This situation can happen if the host supports more connections
than the controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Follow Bluetooth specification recommendation of setting the output
of the DH_Key field in the LE Generate DHKey Complete event when the
public key is invalid.
If the Remote_P-256_Public_Key parameter of the HCI_LE_Generate_DHKey
command (see Section 7.8.37) was invalid (see [Vol 3] Part H, Section
2.3.5.6.1), then all octets of the DH_Key event parameter should be
set to 0xFF.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds a high-level documentation page for the Bluetooth Mesh Shell
subsystem, documenting all available commands and their parameters.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Updated implementation to have consistent initialization of
ret_cb use when passing it to ticker function calls.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove cmd_ull_reset command, as this would put the host out
of sync. Also, this command is seldom used/required.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a feature that allows an application to request
automatic discovery of the CCCD handle when subscriping
to a characteristic. In order to preserver RAM, the application
is expected to provide the discovery parameters, and it's up
to the application whether or not it wants to reuse the
discovery parameters or use one for each characteristic.
Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
By splitting it out to a separate file, it will become easier to
separate generic and non-generic controller features.
This commit only contains the simple extraction.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Fixed memory corruption when using uninitialised previous
PDU to populate current PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Resolves a corner case where the segmented sending would be rescheduled
before the segments were done sending. This would happen if the
processing of each segment took longer than the retry delay. The
consequence of this was that some segments were resent multiple times at
the cost of other segments, occasionally causing a loss of transfers.
Rearranges, realigns and documents seg_tx structure bitfields in
transport.c. Removes bitwidth of counter fields, and collecting all flag
fields into one byte.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Enforce support for Read RSSI command if BT_CONN and BT_HCI_RAW are
selected. According to the Bluetooth specification, support for the
Read RSSI command is mandatory if the Connection State is
supported. BT_HCI_RAW indicates that the controller is an
independently qualifiable module and not part of a combined
host/controller build. This change avoids a configuration that cannot
be possibly qualified.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Change fixes storing subscriptions in settings. CCC write can interrupt
the ccc_delayed_store. Without the change, new CCC was not stored in
non-volatile memory and the work that stored CCC was not resubmitted.
That resulted in lost subscription after reboot.
Fixes: #26862
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Refactor implementation to perform enable and started state
updates at consistent places in code.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add bond_deleted callback so that the application can keep track
of when bond information is deleted in the stack.
Bond information can be deleted by the application through bt_unpair
or automatically by the stack in some cases, e.g when
CONFIG_BT_KEYS_OVERWRITE_OLDEST is enabled and the oldest bond
is overwritten.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add advertising option for undirected one-time advertising, and
directed advertising using identity, and peer direct is RPA option.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow calling bt_le_adv_start with no connection object available
when not the option BT_LE_ADV_OPT_ONE_TIME has been set. In this
case the advertiser will be restarted once there is a connectable
advertiser object available.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added implementation to acquire and initialize auxiliary
channel instance on use of periodic advertising.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When CONFIG_BT_GATT_NOTIFY_MULTIPLE is selected and the remote has
enabled support for using its procedure data can sometimes not fit
into the buffer since the multiple variant has a bigger header, so
instead of failing immediatelly this attempts to send the data using
the legacy PDU instead so those using bt_gatt_get_mtu - 3 can still be
sent.
Fixes#26106
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Enable Advertising Extensions by default if supported by the controller.
That is, do not enable it by default for BT_LL_SW_SPLIT.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Change sets default value of Kconfig option BT_CTLR_LLCP_CONN to
BT_MAX_CONN. The default value should properly handle the worst case.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Fix missing recalculation of skip value of the ticker being
inserted into ordered list, when it collides and is being
attempted to be inserted at next periodic interval.
This fix is for ticker compatibility mode which is used as
default for nRF51 series.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds idle wait callback to proxy by counting the number of pending
notifications.
Ensures that all connected nodes have received messages before resetting
the mesh stack.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix flash operation timeout due to incorrect use of
secondary ticker to abort any radio in use. Ticker id 0
is reserved for split controller's pipeline preempt timeout.
Using the same ticker id caused the secondary ticker to
not be started if controller is using the same ticker id
for pipeline preempt timeout.
Fixes#26333.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reverse the order of these checks because invalid PDU type will
never be expected. If PDU type is invalid we should respond with
error 0x0002 - Invalid format.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Turn the GATT notify multiple feature off as default value.
This feature changes the behavior of the bt_gatt_notify API in a way
that might not be backwards-compatible.
This is because the notify multiple header is larger, and therefore
limits the amount of bytes that could otherwise have been sent in a
normal notify PDU for a given ATT MTU.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix use of conn_handle in LE Advertising Set Terminated event not
converting from serial Little Endian to native CPU endianness.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use an unspecified reason when disconnecting a connection that did not
have a pending connection in the host.
We don't allocate connection objects in the connection complete anymore
so using memory-capacity-exceeded is misleading.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This patch fixes an issue with the advertiser not resuming connectable
advertiser if the last bt_conn_unref happens from something other
than the disconnected callback.
In this case this last bt_conn_unref was from gatt.c notify_cb called
from application main thread.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix host RX thread being deadlocked. The deadlock occurs because the
RX thread is stuck waiting in conn_tx_alloc with K_FOREVER but if the
connection is disconnected only the RX thread can unblock it in the
handling of the disconnect event.
This commit fixes this deadlock by splitting the processing of the
disconnected event into two parts.
The part needed to unblock the RX is to release resources held by
unack'ed TX packets and mark the connection state as not connected
anymore.
The RX thread waiting for free_tx fifo and the TX thread waiting for
the bt_dev.le.pkts semaphore will both check the connected state after
having acquired them and will abort if disconnected.
The rest of the processing will be handled at normal RX thread
priority like normal.
Move the bt_recv_prio handling to the Bluetooth host when the host
has defined its own RX thread (CONFIG_BT_RECV_IS_RX_THREAD=n).
If the HCI driver has the RX thread (CONFIG_BT_RECV_IS_RX_THREAD=y),
then the responsibility to call bt_recv and bt_recv_prio correctly
falls to the HCI driver.
The helper function bt_hci_evt_is_prio() is replaced with
bt_hci_evt_get_flags() so that the HCI driver can do this correctly.
This decision to replace was made so that existing HCI drivers
maintained out-of-tree will fail at compile time with the new system.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Bluetooth: host: Move bt_recv_prio to host when RX thread is defined
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Save link key to settings_subsys, no need to re-pair after restart.
Overwrite old pairing records with aging counts.
Signed-off-by: ZhongYao Luo <LuoZhongYao@gmail.com>
The hci-cmd currently accepts only a 1 byte parameter. This
disables use of commands that requires more than 1 byte,
for ex. the feature exchange that requires a 16 bit parameter.
This commit allows a datafield parameter up to 65 bytes long.
65 bytes comes from the nr. of parameters for the
HCI_LE_Generate_DHKey command
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Friend Request is also transmitted over local queue and
if both Friend and LPN features are enabled then we would
try to establish friendship with ourselves.
Fixes MESH/NODE/FRND/LPN testcases.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
The hardcoded value was arbitrary and interfered with message cache
mechanism causing invalid behavior and PTS test to fail.
Fixes MESH/NODE/RLY/BV-02-C.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
According to Mesh Profile Test Specification we should still
relay messages with DST address that is RFU.
Fixes MESH/NODE/RLY/BV-01-C.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Key refresh procedure was ignored on non-primary subnet.
Mesh Profile Specification v1.0.1:
3.10.4 Key Refresh procedure
"This procedure is used when the security of one or more network
keys and/or one or more of the application keys has been compromised
or could be compromised."
"It is possible to update each NetKey independently of all other
NetKeys. A Key Refresh procedure for one NetKey can be in a different
phase to another Key Refresh procedure for other NetKeys."
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Reset provisioning bearers when bt_mesh_reset() is called. Accept
another provisioning attempt after link close.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
This value was used quite often in the file so adding a
descriptive name should improve readability.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
The comparison of a current tx link transaction id caused
us to not send ack and in effect fail provisioning.
Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
Fix the advertise object not release when a high-duty cycle directed
advertiser timeout happens. If the extended advertising feature has been
enabled in the host, but not supported by the controller then the
advertising object must be released in the connection complete event
since there will not be a advertising set terminated event.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue with directed advertiser not accepting connection request
from non-privacy enabled peer that has given us a non-zero IRK.
When device privacy is enabled then ull_filter_lll_rl_addr_allowed will
return true, and update the rl_idx to entry in the resolving list.
When the directed advertiser is not privacy enabled then lll->rl_idx is
set to FILTER_IDX_NONE and will not use RPA for the target address.
The check rl_idx != lll->rl_idx will then fail (0 != 0xff) and the
connect request is denied, even though all addresses matches on-air.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Removes the memset of the prov_bearer_cb in PB-GATT during resets. This
allows the provisioning link to disconnect and reconnect again without
having to call pb_gatt_open.
Fixes#26343.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add explicit opcode check when handling received unknown
response PDU.
Without this, for example, an in progress Data Length Update
procedure state was reset when receiving an unknown response
to slave initiated feature request.
Fixes#26252.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add options for phy update procedure. User can now set no preference
option for a particular PHY as well as preference for LE Coded PHY
coding scheme.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
These functions don't work with buffers that do have fragments, instead
this replaces their usage with net_buf_{put,get}.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
ATT_PENDING_SENT does severely impact the throughput since multiple
packets no longer can be scheduled at same time, so instead of always
setting it regardless of the bearer/channel it is now only used for
EATT since that cannot set its own callbacks.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
bt_l2cap_send_cb may fail if there are no context available which means
that the request would not be sent, also due to the use of custom
callback it cannot be queued either so the only option is to return the
error and let the application handle it.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since the TX semaphore is used for all types of PDUs a request may have
to be put on the request list while there is no pending request pending
which means no response will be generated to trigger att_process,
previously this condition was handled by setting the request as
currently pending and append its buffer to tx_queue but this is no
longer efficient since there could be more than one channel active the
code should try all of them before queueing back to request list.
To fix this the request list will now be processed each time a PDU has
been sent.
Fixes#26070
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
ATT channel sent callback shall not be overwritting until the
operation completes as it can result in breaking flow control when
CONFIG_BT_ATT_ENFORCE_FLOW is enabled.
Fixes#25964Fixes#26071
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Disable the controller advertising extension feature default setting
until the feature is complete. The zephyr host requires the
LE Advertising Set Terminated event to function.
Without this event a peripheral connection cannot pair because the
local on-air address is not set, and the advertising state will not be
cleaned up, so advertising cannot be started again.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The frnd->last buffer can potentially be NULL if friend_clear is called
after the adv.c buf->busy check, but before the adv_start callback.
The current design is based on the adv.c thread being cooperative, and
therefore not yielding between the busy check and the adv_start
callback, but as the bt_le_adv_start call has to acquire a semaphore,
there's a possibility for friend_clear being called inbetween.
Fixes#26177.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add warning about enabling the options below so that users are
aware that this is a security risk.
- CONFIG_BT_DEBUG_SMP
- CONFIG_BT_DEBUG_KEYS
- CONFIG_BT_OOB_DATA_FIXED
- CONFIG_BT_USE_DEBUG_KEYS
- CONFIG_BT_STORE_DEBUG_KEYS
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Use the NRF RNG entropy device as the entropy device for bt_rand and
controller internal functions when LLL is Nordic.
Using an entropy source with a significant increase in stack usage
will invalidate all stack size configurations in the system and lead
to stack overflow issues.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation regression due to addition of const
qualifier to tx_pwr_lvl parameter of ll_tx_pwr_lvl_set
function. Support for BT_CTLR_TX_PWR_DYNAMIC_CONTROL
needs the tx_pwr_lvl to be updated and returned.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
For some reason GCC 9.x doesn't seem to be able to realize that set_num
will always be > 0 and so the local variable status will always be
initialized. Use a do {} while instead to keep it happy.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix missing implementation of initialization of common
advertising header bit fields when new auxiliary channel PDU
is instantiated. This caused corrupt invalid Bluetooth
Device address being copied from uninitialised previous
auxiliary PDU instead of copying from primary channel PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Review rework, added comments, TODOs, FIXMEs and converted
magic number use in advertising set state flags to defines.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added comments and code to make note that disabling all
advertising sets is not yet implemented.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor pdu.h defined in anticipation of reused in
Advertising Extensions implementation. To reuse in
calculating ticks_slots etc.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix segmentation fault detected by BabbleSim test due to
incorrect number of tickers being allocated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Avoid ticker from null pointer dereferencing when storing
operation callback functions to be called during collision
resolution.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix scan set allocation using BT_CTLR_SCAN_SET instead of
an incorrect duplicate BT_CTLR_SCAN_MAX.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Integrate the generated extended adv report PDU list into
HCI layer to generate the HCI LE Extended Advertising Report
event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Change the implementation of extended scan PDU rx list to use
the extra pointer as the next field in the linked list node.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing Auxiliary PDU when primary PDU is calculating
the offset. Schedule the auxiliary PDU ticker before primary
PDU ticker is scheduled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the Low Latency Prepare Done that disables ULL_LOW
context executions inside a radio event, so that
ticker_job_idle_get is invoked from ULL_LOW instead of LLL
context so that its enqueued alongwith others scheduled
in ULL_LOW. This is avoid premature disable of ULL_LOW
context executions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When Privacy is not supported in the build and Advertising
Extensions is enabled, HCI LE Enhanced Connection Complete
event was missing. This is fixed now.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect adv_addr type in auxiliary PDU when address
is removed from primary and added to auxiliary PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to calculate the window widening for
the reception of auxiliary PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to avoid a crash due to missing aux_ptr in current
primary PDU constructed by LE Set Extended Advertising
Parameter Set, while aux_ptr was populated by LE Set
Extended Advertising Data Set in the latest double buffered
PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to handle updates to adv mode and event
properties of an already created advertising set.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix collision resolution to consider single-shot ticker,
current single-shot with ticks_slot as older that a next
periodic or single-shot ticker with ticks_slot.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker to correctly generate the operation callback if
single-shot ticker fails to be scheduled and does not
expire.
As the collision resolution is deferred to the worker, if
a single-shot ticker is cancelled, then appropriately call
the operation callback with failure status. This is allow
the user to take necessary actions, like release resources
allocated that need to be release on the failure to schedule
the single-shot ticker expiry.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the definition of PKT_US into pdu.h so that it can be used
by Advertising Extensions implementations too.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove us_radio_rdy field in the footer structure as its always
a constant value which can be obtained using a functional
interface to HAL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix legacy advertising started using Extended Advertising
sets to use the set advertising random address.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing reset of phy struct member for scan set that is
not being enabled by use of LE Extended Scan Parameter Set
command.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Allow use of HCI LE Set Random Address cmd when advertising
is enabled using Extended Advertising commands.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix, use phy variable instead of type to determine if
scanning on Coded PHY is to be enabled.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to generate LE Extended Advertising
Report for received legacy PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing reset of scanner state which could cause a
spurious SCAN_RSP packet without a prior SCAN_REQ being sent
to be reported.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to support setting of legacy
Advertising Data and Scan Response Data using Extended
Advertising Data set functions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Differentiate call to ll_adv_params_set, whether used by
legacy LE Set Advertising Parameters or LE Set Extended
Advertising Parameters.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable Advertising Extensions features in the controller
when enabled in the Host in combined host+controller based
applications.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update implementation of periodic advertiser's LLL to
correctly handle event counter values when latencies
introduced due to sync events cancelled by active events
operating in unreserved time space.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Update implementation of master and slave LLL's to correctly
handle event counter values when latencies introduced due to
connection events cancelled by active events operating in
unreserved time space.
When an active radio event extends into unreserved time
space, and a connection event prepare is scheduled but at
the time of pre-emption timeout if the connection event is
cancelled then the event count and latencies needs to be
continiued to get acummulated.
In the current controller usecases the above scenarios does
not get exercised, the changes in this commit is needed for
future roles that can extend into unreserved time space and
would cancel a scheduled connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix conditional compilation of advertising extensions and
periodic advertising do that platforms with not support in
their LLL can be built without advertising extensions.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix conditional compilation of piggy back implementation.
This code should be deleted once periodic advertising
implementation is complete.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor to reuse common repeated code in ISR that reset
status, and performed abort, done and cleanup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add implementation to support ADV_EXT_IND PDU with AuxPtr.
Changes in this commit only prepares the ADV_EXT_IND PDU
in the primary channel.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Updated the shell commands related to Advertising Extensions
to call the LE Set Extended Advertising Data command
functional interface for testing purposes.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added debug information print outs in HCI code related to
Advertising Extensions events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Bluetooth Controller GPIO Debug Pins for
nRF5340 PDK board. GPIO Pin toggling can be captured on the
P3 pinhead of the PDK.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Previous mode store function only can store single data,
change this to store as KV model, let's app-layer to manager
model data, other than by stack when node reset.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Port advanced scheduling implementation from legacy
controller.
This implementation schedules
- non-overlapping scan window when there are simulataneous
central connections active
- central connection establishment with similar connection
intervals be placed in a non-overlapping group, temporally
- connection parameter request with calculated window offset
hints to have non-overlapping BLE radio events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add a function to reset the variable holding the connection
context of the currently active Connection Parameter Request
Procedure.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Address the nRF5340 Engineering A Errata 16, RADIO: POWER
register is not functional.
This affects the dependency of controller's HAL
implementation that expected correct reset values being
set in the Radio peripheral.
As the SUBSCRIBE_TXEN and SUBSCRIBE_RXEN where not in their
reset value, Radio transmission and reception start using
DPPI was broken.
Fixes#25942.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The bt_l2cap_le_conn_rsp struct in l2cap_internal.h has not been
declared __packed. This can cause alignment problems on some
platforms if the struct is placed on an unaligned address.
A __packed declaration solves this issue by forcing the compiler to
use store instructions that do not required alignment.
Signed-off-by: Jim Luther <jilu@oticon.com>
Implemented an intermediate decrypt buffer to cover the CCM
overrun under CRC error conditions. The workaround is
applicable to nRF52832 SoC only, which is missing the
MAXPACKETSIZE register in the NRF_CCM peripheral.
Fixes#21107 for nRF52832 SoC.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds propagation of error returns from the model init callbacks in
Access, and removing any other checks for successful init in the
foundation models.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix missing assignment of NRF_CCM->MAXPACKETSIZE register
for PDU sizes smaller than 251 bytes. If there is CRC errors
causing PDU length fields to be higher than configured PDU
buffer sizes in the controller, without the MAXPACKETSIZE
register set to correct PDU size, CCM module could overrun
the PDU buffer and cause memory corruption. This fix is
applicable for all nRF52 Series SoCs except nRF52832 SoC.
Fixes#21107.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
After removal of legacy controller ll_adv_aux.h does not exist anymore.
This is fixed in this PR by including ull_adv_aux.h instead.
The error only shows up when Advertisement Extensions are enabled
in the LL (CONFIG_BT_CTLR_ADV_EXT=y)
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
CC: mesh/access.c
mesh/access.c: In function 'model_has_dst':
mesh/access.c:483:10:
warning: returning 'u16_t *' {aka 'short unsigned int *'} from
a function with return type '_Bool8' {aka 'unsigned char'} makes
integer from pointer without a cast [-Wint-conversion]
483 | return bt_mesh_model_find_group(&mod, dst);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: chao an <anchao@xiaomi.com>
The existing feature exchange procedure does not give the proper
response as specified in the BT core spec 5.0.
The old behaviour is that the feature-response returns the logical and
of the features for both peers.
The behaviour implemented here is that the feature-response returns the
featureset of the peer, except for octet 0 which is the logical and of
the supported features.
Tested by using the bt shell, and having different featuresets
on the 2 peers.
This fixes#25483
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Some Kconfig defined devices may be defined using dt_chosen_label
function. Since there is no way to ensure a device enabled in dts
is also defined in Kconfig, it may happen that instance is not
actually defined.
In this case device_get_binding might return 0, leading to undefined
behavior in the function that calls it.
When not already done, systematically check return of function
device_get_binding on devices defined through dt_chosen_label macro.
Trigger ASSERT when required and return error when possible.
Fixes#20068
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commits fixes the loading of bt/cf settings into memory. Only data
was loaded and not the address.
Signed-off-by: François Delawarde <fnde@demant.com>
build breakage if SMP is disabled
In function `bt_unpair':
bluetooth/host/hci_core.c:2640: undefined reference to `bt_foreach_bond'
Signed-off-by: chao an <anchao@xiaomi.com>
The transport segmented TX nack and seg_pending fields must be at least
6 bits to avoid overflow for 32 segment messages. This change rearranges
the seg_tx fields to gather all state flag fields in one byte, while
making the counter fields whole bytes.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix missing transmit buffer demutiplexing before checking if
slave latency needs to be maintained or cancelled.
This bug was detected when new transmit buffer was enqueued
overlapping with on-air radio transmission of empty PDU
preceding the handling of radio event done.
Symptoms of this bug being data transmission latency of upto
slave latency plus one times connection interval.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increases the transport segmentented tx seg_o counter to 6 bits to avoid
overflow when sending 32 segments. The check in the send loop would
previously never be false, which causes segments to repeat
unnecessarily.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fixes bug where the transport segmented tx would decrement the attempt
counter every time it ran out of buffers. If transport ran out of
buffers 4 times before the sending could complete, the transfer would
end prematurely.
Moves the attempt decrement to only execute when all segments have been
sent.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Ensures that friend messages are enqueued, even if the packet is
received with an appkey is unknown to the friend. Previously, sdu_recv
would return EINVAL if the appkey was unknown, which would prevent the
lower transport layer from adding the packet to the friend queue. This
is irrelevant for the logic in lower transport, and should not be
returned as an error.
Fixes#24014.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
If LE Read PHY fails the code was still trying to parse the buffer as a
valid response.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix extended advertiser not using correct set random address command
to set private (NRPA) address when privacy feature has been disabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix Service Changed configuration stored in flash not deleted in flash
when calling bt_gatt_clear from bt_unpair.
When clearing the check for "is bonded" should not be made. If the
bond information is already removed this check will fail.
When clearing the check for "modified" should not be made, clearing
is in itself a modification, and should always be made.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix CCC cfg not cleared when overwriting oldest bond. Calling
bt_unpair with a pointer to the key will result in the key addr being
memset to zero and bt_gatt_clear is called with an zero-set address.
This happens because unpair (hci_core.c) calls bt_keys_clear before
calling bt_gatt_clear.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
get_phy is referenced by BT_EXT_ADV only when BT_OBSERVER is also
selected. Avoid defined-but-not-used warnings in that situation.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit adds support for bluetooth in nRF52820 SoC.
Bluetooth radio related files created and added to Zephyr.
Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
When using extended advertising the connection can be established on
different PHY. In order to have an updated value of the current PHY
we need to read the PHY of the connection in the connection complete
event.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add application control of initiating phy change procedure and it's
parameters.
The reasons for allowing the application control over the PHY:
- Allow changing to Coded PHY.
- Application may change PHY to react to changes in environment
to balance throughput and range.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add application control of initiating data length procedure and it's
parameters.
The reasons for allowing the application control over the data length:
- Bandwidth control adjusted based on number of active connections.
- Changing data length before switching to coded phy.
- Applying workarounds for interoperability problems.
- Controlling order of ATT MTU and data length procedures.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add Kconfig option so that the application can disable automatic
initiation of the data length procedure. This is symmetric with the
PHY auto initiation kconfig option.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor setting the maximum data length parameters supported on in
auto data length procedure. This makes setting the data length of the
connection a re-usable function.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
With BT_CTLR_USER_TICKER_ID_RANGE it is possible for vendors to add a
number of ticker nodes for proprietary purposes. The feature depends on
BT_CTLR_USER_EXT.
Signed-off-by: Morten Priess <mtpr@oticon.com>
The numbers should have been the sum of HCI commands count and ACL TX
buffers but instead the buffer size was used which makes the pool holds
substatially more buffer than necessary.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add control over the use name option to advertise shell parameters as
an optional argument.
The argument count for extended advertise parameters had not been
updated for the maximum directed advertise parameter count.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Implement the BT_LE_ADV_OPT_USE_NAME when using bt_le_ext_adv_* APIs
to start the advertiser.
When starting an extended connectable advertiser the name must be
included in the advertising data, since scan response data is
not allowed in this configuration.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove setting state flags in bt_le_adv_start_ext since they are set
by le_ext_adv_param_set, except for BT_ADV_PERSIST flag.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Only persist advertising when the bt_le_adv_start API is used to start
the advertiser. For multiple advertising set a connectable advertiser
can only be started if there is a connection object available for the
advertiser. Leave the decision on which advertising set should be
advertising up to the application instead of suspending advertising
when no connection object is available.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove the BT_LE_CONN_OPT_2M option and update documentation.
This was a misunderstand about the init PHY HCI parameter.
The init PHY in the extended connection create command does not
determine which PHYs are accepted as the initial PHY of the
connection. This is instead determined by the secondary PHY of the
extended advertiser.
The init PHY parameter only specifies which conn parameters are
provided, and since we only provide one conn parameter this option
has no effect.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The last parameter to hci_cmd_done() is expected to be a valid net_buf
since the function immediately tries to dereference it. Fix this by
passing the appropriate buffer reference to the function.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This adds a new flag to track if the L2CAP channel is pending waiting
for encryption to be changed to resume connecting.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support for ATT_MULTIPLE_HANDLE_VALUE_NTF,
ATT_READ_MULTIPLE_VARIABLE_REQ and ATT_READ_MULTIPLE_VARIABLE_RSP.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support for EATT bearer which was introduced in 5.2, they work
as extra channels to have GATT traffic, at the moment it is completely
transparent to application when they are in use since the allocation
happens automatically.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the definitions for Enhanced ATT along with new PDUs and UUIDs
introduced in 5.2.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a callback to indicate when the stack has released all
references to a given channel so the owner free up any resources
associated with that.
This is requires since EATT channels cannot rely on the destroy callback
as it does not use a fixed channel like ATT.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This leaves only channels on the dynamic range to be offloaded to the
system queue so ATT and EATT handling are handling in the same context.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the initial implementation of ECRED mode which can connect up
to 5 channels simultaneously and is required by EATT.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces new Enhanced Credit Based Flow Control PDUs and related
definitions which were introduced in 5.2.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Split BT_CTLR_CONN_RSSI option into two, the base option enables the
Read RSSI command, while the new BT_CTLR_CONN_RSSI_EVENT enables the
connection RSSI events. There is no handling of RSSI events, only a
BT_INFO log.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The bluetooth subsystem is now fully compatible with the new timeout
API, so remove the selection of the legacy API.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Convert bluetooth mesh to using k_timeout struct. Many of the mesh
modules uses timeout calculations, so it is most practical to keep
the s32_t type and only initialize a k_timeout_t struct when
calling the kernel.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Convert bluetooth host to using k_timeout_struct for the timeout values.
This is mostly replacing s32_t with k_timeout_t.
In l2cap the handling of no timeout in send channel request was removed
since the timeout is both documented as minimum of 1 second and never
given any no timeout value.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Convert bluetooth controller to using the new k_timeout_t API so that
CONFIG_LEGACY_TIMEOUT_API can be turned off.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove logging of individual threads spread out throughout the
bluetooth subsystem. The stacks can be analysed by enabling the
following options.
CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_ANALYZER_AUTO=y
CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
Optional:
CONFIG_THREAD_NAME=y
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Include the RPA addresses in the enhanced connection complete debug
log. This makes it easier to debug privacy failures.
Use a new debug statement so that the debug print will work correctly
when log_strdup does not copy the string.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix local RPA field for the legacy controller. This failed without
compilation errors because of blind pointer cast between two
structs of similar definition.
Set the local RPA field of the enhanced connection complete event only
when the address was generated by the controller. If the host has
set an RPA and this one was used the controller should return all
zeroes.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Set the local RPA field of the enhanced connection complete event only
when the address was generated by the controller. If the host has
set an RPA and this one was used the controller should return all
zeroes.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation issue for extended advertising beacon. Adv pool was
mistakenly put under BT_OBSERVER define.
Both observer and broadcaster use the bt_lookup_id_addr. SMP cannot
be enabled without connections, so for broadcaster and observer there
will not be a lookup.
Fix compilation warning for extended scanner-only build.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
According to the BT Core spec. The local RPA field in the enhanced
connection complete event should be set if the own-address type was
set to 0x02/0x03 and the controller generated an RPA using a non-zero
IRK, otherwise the controller should return all zeroes.
In the case where we generate the RPA in the host instead we need to
handle set the on-air RPA address based on the random address set by
the host.
If this is not handled then pairing will fail because the on-air
addresses are used as input to the pairing procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Remove handling of extended advertising from connection complete
event. If extended advertising has been enabled and is supported by
the controller then enhanced connection complete must be supported.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This is a rework for OpenISA SW LL of
"b7220cef86 Bluetooth: controller: split: Fix densely scheduled event
preemption"
Fix LLL implementation handling preemption of currently
active radio event with densely scheduled events in the
pipeline.
Preempt timeout was stopped without consideration to there
being more queued events in the pipeline. Also, added
chaining of preemption timeouts one after the other expiry
so as to preempt currently active events by the densely
scheduled events in the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
This is a rework for OpenISA SW LL of
"b0826a7f65 Bluetooth: controller: split: Reduce time to setup tIFS
switch"
Refactor to reduce the setup next tIFS switch within tIFS
period of the Radio ISR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
This is a rework for OpenISA SW LL of
"4547bfb452 Bluetooth: controller: split: handle latency for cancelled
conn events" as well as subsequent fixes
Update implementation of master and slave LLL's to correctly
handle event counter values when latencies introduced due to
connection events cancelled by active events operating in
unreserved time space.
When an active radio event extends into unreserved time
space, and a connection event prepare is scheduled but at
the time of pre-emption timeout if the connection event is
cancelled then the event count and latencies needs to be
continiued to get acummulated.
In the current controller usecases the above scenarios does
not get exercised, the changes in this commit is needed for
future roles that can extend into unreserved time space and
would cancel a scheduled connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
This is a rework for OpenISA SW LL of
"62c1e1a52b Bluetooth: controller: split: Fix assert on invalid packet
sequence"
Fix to remove assertion failure check on detecting invalid
packet sequence used by peer central and that no non-empty
packet was transmitted.
Fixes#22967.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
User of bt_buf_get_rx may attempt to push their own headers, e.g. ACL
headers, so move the H4 header logic to bt_recv after logging into the
monitor since otherwise the buffer would contain H4 headers which is
not expected by the monitor.
Fixes#24646
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
According Mesh Profile 1.0.1. A application key shall
binding single network key. And Device key shall bind all
network key, and dev key only known by cfg_cli and node self,
only used by cfg_cli & cfg_srv.
Fixes: #21088
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Fixes bug where the config client's net_key_status handler would attempt
to pull two key indexes from a message which only holds one.
Fixes#24601.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
After #22013, bt_le_adv_param got additional fields which were passed to
the bluetooth API uninitialized in the BT Mesh module. This
zero-initializes the entire structure in all usages to avoid passing
uninitialized data now and in the future.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add support for multiple advertising set. Move the advertising state
flags to be per advertising set and loop over advertising sets instead
of looking up legacy advertiser set or handle 0.
Since it is not certain that the advertising set terminated event can
arrive directly after the connection complete event there is currently
a limitation that there can only be one local identity used by
connectable advertisers at a time. This guarantees that we know
the local identity being used in the connection complete event.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Only attempt to restart the background scanner in connection complete
event when the new connection is a master role connection or the
initiator was successfully canceled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Enable enhanced connection complete when extended advertising has been
enabled. This event is mandatory if extended advertising is supported.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This makes hci_raw to manage RX and TX buffers so its logic don't have
to be replicated on each an every driver/application, it also makes it
simpler to deal with extra headers for H:4 mode since that then can be
done at earlier at buffer allocation.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support for registering a command extention table which is
used to match incoming commands and then pass the buffer to its
function handler.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds 2 config options which enables hci_raw to work in
H:4 mode and enable it by default automatically.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds USB_PID_BLE_HCI_H4_SAMPLE along with it driver which uses H4
over bulk endpoints.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When legacy advertising enable command is issues,
the BT_ADV_ADVERTISING has to be set, because this
flag is checked in many scenarios to see if the
advertising is ongoing or not.
Signed-off-by: Ahmed Shokry <ahmed.shokry@synopsys.com>
When receiving an unknown command send the unknown command response
as a command status event instead of a command complete event.
A command complete event has no status field, although by convention
all command parameters has a status field as the first parameter the
command status event seems like the more fitting option.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add option for low power node automatically subscribe
all-nodes-address to friend sub list.
Fixes: #24009
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Give NULL pointer when ad_len or sd_len is zero, this stops the host
from setting a zero length advertise data or scan response.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the advertise command not setting the peer address parameter to
NULL, this could turn it into a directed advertiser.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This patch adds the selection of the necessary CONFIG_*
options for allowing the use of privacy on VEGA platform
Signed-off-by: Jeanina Dragusin <ancajeanina.dragusin@nxp.com>
The radio on the VEGA platform will now be able to resolve Resolvable
Private Addresses through the use of the CAUv3 hardware. With this
patch the RPA feature is now fully supported on the Controller:
RPA addresses are generated with local IRK and resolved with
previously exchanged peer IRK.
Signed-off-by: Jeanina Dragusin <ancajeanina.dragusin@nxp.com>
When disconnecting att_reset is called and all requests are notified
but instead of passing req->user_data like it should it pass the req
itself which nowdays comes from a k_mem_slab, rather than being a
contiguous memory that would contain the request and its user data,
which would likely cause invalid access.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add shell options to configure an extended advertiser for directed
advertising.
Add shell options to provide arbitrary advertising data as well as
giving scan response data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This patch introduces two major changes to the directed advertising
feature of the bluetooth host.
Deprecating the bt_conn_create_slave_le, and removing
bt_conn_le_create_slave which has never been released. This behaviour
has now been moved by to providing the peer direct address into the
advertising parameters.
Introducing directed advertising support for nonconnectable
directed extended advertising, both scannable and non-scannable.
A bug was also fixed in the the directed-adv command in the shell
when the argument "low" was given. The advertiseng parameter pointer
declared with BT_LE_ADV_CONN_DIR_LOW_DUTY was declared in a scope that
was no longer valid when it was used to start the advertiser.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Makes a common link_closed function for PB-GATT, getting rid of a bug
where cb_data is reset before the link closed callback. Also ensures
that the link close and reset order is the same in both scenarios.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Replace CONFIG_ENTROPY_NAME with DT_CHOSEN_ZEPHYR_ENTROPY_LABEL. We now
set zephyr,entropy in the chosen node of the device tree to the entropy
device.
This allows us to remove CONFIG_ENTROPY_NAME from dts_fixup.h. Also
remove any other stale ENTROPY related defines in dts_fixup.h files.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
The LE Connection Complete HCI event, unlike its Enhanced counterpart,
only uses 0x0 and 0x1 for Peer Address Type. Fix it so that it reflects
the specification correctly.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This PR fixes#23482. The preamble size for a 2M phy was incorrect.
There is a bug in calculation of time for the DLE procedure:
the preamble size is incorrect for the 2M phy
Fixes#23482
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
When PB-GATT Procedure timeout, func `bt_mesh_pb_gatt_close`
will also dumplicated with `link_closed()`
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Check the return value of LE Set Extended Advertising Parameters
command when starting an advertiser from bt_le_adv_start with
CONFIG_BT_EXT_ADV enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The LE Set Extended Advertising Set Random Address command may be
issued at any time after an advertising set identified by
the Advertising Handle parameter has been created using the
LE Set Extended Advertising Parameters command.
This commit fixes the advertising set issueing the set random address
command before the advertising set is created in the controller.
Since the le_adv_set_random_addr function has is used to get the the
own address parameter for the it could not simply be moved, and
moving the own address parameter handling out of this function
would create a potentioal maintaince problem.
Also this function is used for both with and without advertising
extension feature so changing it is not trivial without breaking all
the previous random address handling already put in place.
The simplest solution was therefore to postpone the command until the
parameters has been set using 2 flags.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use bluetooth assert on HCI command send error since this assertion is
always enabled and we should not continue after this has failed.
Log command status failure with information in order to make it more
visible as the HCI status code is more interesting than the -EIO error
code returned by the function.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add BT_ASSERT_MSG assert mechanism that can print assertion messages
when verbose bluetooth asserts are enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix seg_tx occupy when no segment not send
and allocate rx_seg when receive such message.
Fixes: #24101
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
For the ll code we know the exact entropy device as its the one for the
SoC that we are on. So use the new DT macro's to get the entropy device
via DT_INST rather than using CONFIG_ENTROPY_NAME.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Fix the pending slave set connection latency and timeout values not used
in the connection update procedure when
CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS has not been enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The board target for emulation of nRF52810 on nRF5DK, so far
known as nrf52810_pca10040, is renamed to nrf52dk_nrf52810.
Its documentation and all references to its name in the tree are
updated accordingly. Overlay and configuration files specific to
this board are also renamed, to match the new board name.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
The board name for the nRF52 DK, so far known as nrf52_pca10040, is
renamed to nrf52dk_nrf52832. Its documentation and all references
to its name in the tree are updated accordingly. Overlay and
configuration files specific to this board are also renamed, to
match the new board name.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Extends the bt_conn_le_create_param struct to provide the option
to set a custom timeout for the initiation of the connection.
The logic for the default values of window_coded and interval_coded
were moved to conn.c in order to resolve all defaults for the
create_param struct at a single location.
Timeout is not added as a parameter to the BT_CONN_LE_CREATE_PARAM
macro due to the expectation that CONFIG_BT_CREATE_CONN_TIMEOUT
will be the typical value that users will expect.
Fixes#23468
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Fixed overflow risk when `poll_timeout` is 1s,
although it is not recommended to use it like this,
when it is used like this, `POLL_TIMEOUT_MAX`
will overflow.
When the poll timeout set like above, the default `6`
req_attemps for first pull request lost,
may cause this procedure bigger than poll_timeout,
Well, stop scanning when lpn terminated friendship,
this will save lots of energy, when lpn mode enable,
the scanning will be start after `FRIEND_REQ_RETRY_TIMEOUT`
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Fix an an issue where established bonding information in the peripheral
are deleted when the central does not have the bond information.
This could be because the central has removed the bond information, or
this is in fact not the central but someone spoofing it's identity, or
an accidental RPA match.
This is a regression from: a3e89e84a8
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The net_buf subsystem is now fully compatible with the new timeout
API, so move the selection of the legacy API to those specific
subsystems that use net_buf and still need converting.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Update implementation of master and slave LLL's to correctly
handle event counter values when latencies introduced due to
connection events cancelled by active events operating in
unreserved time space.
When an active radio event extends into unreserved time
space, and a connection event prepare is scheduled but at
the time of pre-emption timeout if the connection event is
cancelled then the event count and latencies needs to be
continiued to get acummulated.
In the current controller usecases the above scenarios does
not get exercised, the changes in this commit is needed for
future roles that can extend into unreserved time space and
would cancel a scheduled connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add additional build configurations to the shell to catch build errors
when enabling extended advertising.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation issue when extended advertising is enabled but privacy
is disabled. In this case the rpa_update work is compiled out.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Run the int_literal_to_timeout Coccinelle script to fix places where
it is clear that an integer duration is being passed where a timeout
value is required.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Most places used an int so that should have handled most cases but
keys_set was using an unsigned int, which meant that checking len > 0
is an expression that is always false, and the error handling is not
working.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The publication context is checked for NULL in bt_mesh_model_publish()
however it was dereferenced before that. Move the assignment to
ctx.send_rel to the same place where other ctx members are set.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix regression in cancelling slave latency during Connection
Update Procedure.
Slave latency should not be applied between the ack of a
Connection Update Indication PDU and until the instant.
When caching was introduced, implementation missed this
consideration.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Ticker is now fixed to avoid catch up of periodic timeout under
large ISR latencies.
Revert commit a749e28d98 ("Bluetooth: controller: split:
nRF: Use ticker compat mode as default").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If must_expire is set for a ticker instance, then ticker
expiry shall still perform catchup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reset ticker state in ticker_job for ticker instances that
have been skipped in the ticker_worker.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker to avoid catch up of periodic timeouts in case of
large ISR latencies like in case of flash erase scenarios.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in cancelling slave latency during Connection
Update Procedure.
Slave latency should not be applied between the ack of a
Connection Update Indication PDU and until the instant.
When caching was introduced, implementation missed this
consideration.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Simplify the Data Length Update Procedure state check when
processing incoming LENGTH_REQ/RSP PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Simplify the Data Length Update Procedure state check when
processing incoming LENGTH_REQ/RSP PDUs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add validation of channel map and hop increment value
received in CONNECT_IND PDU.
Zero bit count leads to controller assert or divide-by-zero
fault.
Hop increment shall be between 5 and 16 by BT Specification.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add validation of channel map and hop increment value
received in CONNECT_IND PDU.
Zero bit count leads to controller assert or divide-by-zero
fault.
Hop increment shall be between 5 and 16 by BT Specification.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix high-duty cycle directed advertising when extended advertising
feature has been enabled. The duration parameter when starting extended
high duty cycle directed advertising has to be set to a non-zero value
less than or equal to 1.28 seconds.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Avoid removing identity keys from the controller during the pairing
procedure. During the pairing procedure the keys will be cleared before
they are updated. This causes an unnecessary warning from HCI core where
it tries to remove an IRK key-set from the controller that has has not
been added yet.
While this is not an issue, the warning from HCI core is misleading and
might lead to unnecessary questions and investigations.
Warning appeared after: 6c6bd8c49e
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move the pending ID keys add and delete flag out of keys storage area.
These flags are runtime flags and should not be stored in persistent
storage.
Due to struct alignment storage start has to be aligned so that
variables added before storage start does not affect the storage bytes
by introducing padding in the storage area
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
Add shell advertise set info get command to print advertiser set local
identity and TX power selected by the controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Skip feature testing of controller features when legacy advertising
commands are not supported. For combined builds or builds where the
capability of the controller is known it is not required to have runtime
check of controller extended advertising support.
This gives the following size reduction for hci_core.c:
Without legacy support
hci_core.c 19980 7.75%
total 257679
With legacy support
hci_core.c 21816 8.41%
total 259519
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle updating the identity keys in the controller while a scanner
limited by timeout or advertiser limited by number of events or timeout
is active in the controller. For this case we mark they keys as pending
and handle the update of the resolving list ones the roles are stopped.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add RPA handling for scan limited by timeout. The scan limited by
timeout has no information about elapsed time when stopped. So pausing
the scan at RPA timeout has no new scan timeout value to set.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add shell command to retrieve advertising set OOB information for the
selected advertising set.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add error code to API for starting directed advertiser. Also rename the
API in order to follow the established naming pattern.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add advertising sent connected and scanned callback and print the
information available.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add shell arguments to control scanning phys for scanner and initiator.
This allows to scan on coded or create connections on coded.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add scan recv callback and print extended scan information available.
Add scan timeout callback to print when scanner has stopped.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Print the error codes in hex so that it is easier to lookup, error
codes are usually given as hex.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add support for creating and advertising with an advertising set.
This has support to advertise with extended data and with long range
feature on Coded PHY.
Limited to only supported one advertising set.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add support to use the extended conn create options to establish
connections on LE Coded PHY or 2M. This uses the connection options
set by bt_conn_set_scan_params.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add API to set the scan parameters used in the LE Create Connection
HCI command used by bt_conn_create_le and bt_conn_create_aute_le.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add support for the new scan options and use the LE Extended Scan
HCI commands if they are available in the controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor scan and initiator random address handling to a helper function
so that it can be re-used.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add reference count old to new value transition in the debug print, this
makes it easier to interpret the printed line when debuggin reference
count bugs.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Extract setting advertising filter policy parameter from the adv params
options field to a helper function.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use the scan types defined in bluetooth.h instead of the hci defined
ones. Although they have the same value it is best to avoid using the
hci.h header in applications.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update buffer sizes needed when advertising extensions is enabled. Since
BT_RX_BUF_LEN is used for the HCI command as well we need to fit the
full 255 bytes of the Set Extended Advertising Data or Scan Response
Data plus the 3 byte header of an HCI command.
For the discardable buffer size we need to fit the LE Extended
Advertising Report event, which can be a maximum of 255 bytes plus the
2 byte header of an HCI event.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add Kconfig options to enable extendend advertising and scanning
support.
Include option to support both types of advertising
commands in case the controller capabilities is not know or the
controller is pluggable.
Include option to only support legacy advertising API, this is to
support the use-case of advertising using different identity than the
scanner or initiator.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Deprecate BT_LE_ADV defines in hci.h that are expected to be used by the
application in the scan received callback to identify the advertising
PDU type. These defines are mixing HCI input parameters and advertising
PDU types. Internally it is acceptable to mix these, but at the API we
should to mix in them.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename filter_dup parameters used for scanning filter options to the
more generic name options, and make scan filter options follow same
naming patters as advertising and initiator scan options.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Deprecate bt_create_conn_le and rename it to in order to add return
code, new arguments and to follow the established naming convention.
Add API for the application to control the scan parameters of the
initiator role. This allows the application more scheduling control
of the initiator in multi-role scenarios. Also provides options to
configure the initiator for LE Coded PHY for long range support.
We deprecate the old way of creating connection to make the name more
consistent with the rest of the API.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Minor optimization to use a local variable instead of a
deferencing of a struct member.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The nRF52840 DK board target, so far known as nrf52840_pca10056,
is renamed to nrf52840dk_nrf52840.
Its documentation and all references to its name in the tree are
updated accordingly. Overlay and configuration files specific to
this board are also renamed, to match the new board name.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Update the ticks_current value on last stopped ticker
instance, so that when a new ticker instance is started
the anchor ticks calculation uses the correct current tick
with respect to supplied anchor ticks.
Fixes#23805.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Remove use of k_cpu_idle in controller, and refactor the
implementation used to start, wait and stop clocks needed
by the controller.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We rename the nRF51 Dev Kit board target (nrf51_pca10028)
to nrf51dk_nrf51422. We update all associated references
in the supportive documentation and all nRF51-related
cofigurations and overlay files in the samples and tests
in the tree.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Fix directed advertising from privacy disabled peer. In this case we
need to have the local IRK in the controllers resolving list in order to
have the controller resolve the initiator address of the directed
advertising pdu (ADV_DIR_IND).
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix directed advertiser using the wrong local IRK when doing directed
advertising when the identity of the advertiser is not the default
identity.
This is only an issue for the directed advertiser because it is only
for the directed advertiser that we use the controllers local IRK
to generate the Advertisers RPA.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add header definition for bt_read_static_addr function. Declaring it
without a header definition will not give any compilation error when
function definition changes.
Refactor nRF SoC specific code into nRF specific source files and
provide weak definitions when these are not implemented. This will make
it easier to add handlers per vendor.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When using BT_LE_ADV_NCONN_NAME then the advertising name will not be
included in the advertising data. This is because the host always puts
the device name in the scan response. But since the scan data was
otherwise empty the advertising type was set to ADV_NONCONN_IND.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Splits PB-ADV and PB-GATT into separate modules with a common interface
to modularize prov.c.
Additional trivial fixes from testing:
- Reduces warnings for normal occurances like repeated packets.
- Makes link ack a non-reliable packet to prevent it from being repeated
until prov invite.
- Provisioner does not send link fail, but closes the link (as per spec
section 5.4.4). This prevents lingering zombie links on both sides.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
This reverts commit 8739517107.
Pull Request #23437 was merged by mistake with an invalid manifest.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Replace all occurences of BUILD_ASSERT_MSG() with BUILD_ASSERT()
as a result of merging BUILD_ASSERT() and BUILD_ASSERT_MSG().
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
Allocates segmented message buffers as slabs in a common pool for RX and
TX. This reduces memory requirements for both TX and RX, as TX messages
can be stored without the network and advertising buffer overhead, and
RX can use only the slabs it needs, instead of allocating a full size
segmented message. This approach also removes the need for decrypting
the segments for each retransmission, reducing overall processing load.
Slab based segmentation for tx also introduces queuing of segmented
messages, which allows the application layer to send multiple messages
to the same destination without violating Bluetooth Mesh specification
v1.0.1, section 3.6.4.1. This mechanism is provided through a flag that
blocks segmented messages to a destination which a message is already
being sent to until the previous message finishes.
This changes the SDU size configuration to a symmetrical
RX_SEG_MAX/TX_SEG_MAX pair of configurations, plus a new segment pool
side configuration. It also removes the binding between the TX_SEG_MAX
config and the advertising buffers, reducing the minimum advertising
buffer count from 6 to 3.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
The Friend queue uses the message SeqAuth to determine whether the
message is already in the queue. To facilitate this, the SeqAuth is
passed around as a pointer throughout the transport modules. In the
bt_mesh_ctl_send functions, this parameter is also exposed in the API,
but the internal usage is inconsistent and buggy. Also, no one actually
uses this parameter.
- Removes seq_auth param from bt_mesh_ctl_send, instead passing NULL
directly to the friend module, to enforce its addition to the queue.
- Makes the seq_auth pointer const throughout the friend module.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
A bug in the PKT_US resulted in wrong calculations for the 2M phy.
Fixes the bug, verified on EBQ.
Also adds some defines for improved readability.
Fixes#23482
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Fix LLL implementation handling preemption of currently
active radio event with densely scheduled events in the
pipeline.
Preempt timeout was stopped without consideration to there
being more queued events in the pipeline. Also, added
chaining of preemption timeouts one after the other expiry
so as to preempt currently active events by the densely
scheduled events in the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in handling invalid packet sequence in the
first packet in a connection.
This relates to commit 62c1e1a52b ("Bluetooth: controller:
split: Fix assert on invalid packet sequence")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in handling tx pool corruption in relation to
commit 7a3e29af06 ("Bluetooth: controller: legacy: Fix Tx
pool corruption").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix response to unexpected LL_FEATURE_RSP for the case that
BT_CTLR_SLAVE_FEAT_REQ is disabled. Fixes LL/PAC/SLA/BV-01 for such a
configuration.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Fixes#23485
When we create a GATT table dynamically, we also create a hash
identifying this table. This hash can be stored in persistent memory and
we can thus determine after recreating the GATT table whether the
services have changed or not from before the reboot.
When these hashes are identical, it implies that the table has not
changed, wherefore a service changed indication should not be sent to
any bonded clients. The method for achieving this was to remove the
gatt_sc.work entry from the work queue. This work queue entry was to
send an indication to the clients when the table had been allocated.
If the final entry then caused the hashes to match, the indication
would be cancelled.
On unit testing this behaviour in simulation and in practice, we found
that the indication was sent nonetheless, and the issue was located to
be tied to the SERVICE_RANGE_CHANGED flag which is set when the services
are changed and is cleared when the indications are being sent out.
It was the job of the work queue entry to clear this flag, and as the
entry was never serviced, the flag was never cleared, and when
sc_commit() is called at the end of the process, it believes that there
is a new service change pending and therefore starts the job over, thus
creating a redundant indication to the clients.
This commit fixes the issue by clearing the flag when the work entry
is removed due to a hash match. This has been unittested in a live
environment, in a simulation environment, and sanitycheck has been run
on it.
Signed-off-by: Dan Erichsen <daee@demant.com>
The commit e85dd8af5d changed the way the BT_ECC Kconfig option
is enabled, however it got the dependency wrong. The dependency should
only look at BT_SMP_OOB_LEGACY_PAIR_ONLY if BT_SMP was also enable.
This broke e.g. the build of the mesh_demo app for the BBC
micro:bit since the memory consumption jumped up by roughly 2k.
This patch fixes the issue, and in the same go makes the Mesh handling
consistent by also using a conditional default rather than select.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Allow to get local OOB data while advertiser, scanner or whitelist
initiator is active. If direct initiator is active or the advertiser
is using the random address as a random static identity address then
the function will return error.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When OOB callbacks are present it is possible to achieve authenticated
pairing without having the remote OOB data present. Using OOB with
LE Secure Connection only one side of the pairing procedure is required
to have the OOB data present. If we have given the remote our OOB data
then pairing can proceed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update LLCP handling during PHY update and Data Length update to not
start the LL control procedure if the remote has already indicated that
the procedure is not supported.
This fulfills the following requirement from the BT Core Specification
(Core_v5.2, Vol 6, Part B, Section 4.6):
Except where explicitly stated elsewhere in this specification, if the
peer Link Layer has indicated either during a feature exchange procedure
or by responding with an LL_UNKNOWN_RSP PDU that it does not support a
procedure, then the Link Layer shall not use that procedure.
Re-use the connection parameter request handling for PHY and
data length update procedures.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix missing first connection event due to first connection
event ticks_slot overlapping with the initiator window
ticks_slot.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add ticker_stop_abs interface, similar functionality as to
ticker_stop interface to stop a running ticker but with a
supplied absolute tick reference value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added the functions to turn on/off the radio from LLL.
Added WAKE_IRQ to start radio after it's out of DSM.
Signed-off-by: George Stefan <george.stefan@nxp.com>
Added the functions to turn on/off the radio.
Deep Sleep Mode (DSM)
Signed-off-by: Ionut Ursescu <ionut.ursescu@nxp.com>
Signed-off-by: George Stefan <george.stefan@nxp.com>
This patch adds the selection of the necessary CONFIG_*
options for allowing the use of the 2Mbps BLE PHY on
VEGA platform.
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
The radio on the VEGA platform supports both 1Mbps, as well
as 2Mbps BLE PHYs. It does not support coded BLE PHY. This patch
adds the necessary callback, as well as timings to enable the 2 Mbps
PHY support in the SW LL HAL for VEGA.
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
Add command to input the legacy pairing OOB TK during the pairing
procedure.
Fixed shell build with CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY defined.
Print error code when passkey input failed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added CONFIG_BT_SMP_OOB_LEGACY_PAIR_ONLY option that completely disables
all legacy and SC pairing modes(except for Out of Band) and frees the
memory previously used by these.
Added CONFIG_BT_SMP_DISABLE_LEGACY_JW_PASSKEY option that force rejects
pair requests that lead to legacy Just Works or Passkey pairing.
Signed-off-by: Iván Morales <ivan98ams@gmail.com>
Changes the behavior of the message cache to optimize for cache
capacity. Previously, the message cache's primary function was to avoid
decrypting messages multiple times, although the cache's main function
in the spec is to avoid message rebroadcasting. Optimizing for minimal
decryption causes us to fill the network cache faster, which in turn
causes more cache misses, potentially outweighing the advantage.
Now stores src + seq in message cache instead of field hash value. This
cuts cache size in two, while including more of the sequence number than
before.
Adds messages to the cache only after the packet is successfully
decrypted. This reduces noise in the cache, and ensures that no
invalid deobfuscations are added.
Additionally, this fixes a bug where multiple calls to net_decrypt with
the same packet failed, as the message cache found its own entry from
the previous call.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Refactor old state handling in bt_conn_set_state to use switch statement
instead of if statements.
This will give us warning about enum values not covered.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix connection complete event handling when the local RPA is not valid.
This can happen when the controller was not instructed to use an RPA
address, or the local IRK was set to an all zero IRK.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In Core v5.2, Vol 6, Part B, Section 4.6.9 it is stated that it is
mandatory to support the PHY procedure if any PHY other than 1M is
supported.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
For the time being this 2M is only selectable for !nRF51 platforms.
Coded PHY is only selectable for nRF platforms supporting Coded PHY.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
According to the Zephyr VS HCI specification:
Only Read_Version_Information and Read_Supported_Commands commands are
mandatory.
Check for supported Read Supported Features command before issuing this
command to the controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make BT_CTLR_OPTIMIZE_FOR_SPEED option so that it is not
user selectable for nRF51x series SoC with encrypted
connections support.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix to return the max tx/rx time back to set default time
after using mandatory minimum PDU length and time while
switching back from Coded PHY to 1M PHY.
Also fixes#23109.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Data Length Update transmit and receive time calculation
on PHY update procedure completion.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix host resolving the peer identity address in enhanced connection
complete event when the resolving list in the controller is full and
resolution is done in the host.
Move the handling from legacy connection complete into enhanced
connection complete event so that it is done for both connection
complete events.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Implements several changes to the transport layer segmented tx to
improve group message performance:
- Moves retransmit counter to tx context instead of per packet. As every
unacked packet is sent every retransmit, the retransmit counters would
be the same in each segment. This makes it easier to control progress.
- Delays the scheduling of the retransmit until the completion of the
last segment by adding a seg_pending counter. This is essentially the
same as the old behavior, except that the old behavior might retrigger
the sending before all segments are finished if the advertising is
slow.
- Allows the group transmits to stop as soon as all retransmits have
been exhausted, instead of timing out waiting for acks that won't
come. This allows group tx to finish without error.
- Fixes a bug where a failed TX would block IV update.
- Cancels any pending transmissions of acked segments.
- Reduces log level for several common group tx scenarios that aren't
erronous.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When available, the shell will use the CDB when configuring. This
replaces the default key for configuration and self-provisioning,
ensuring that there aren't multiple key values for the same indexes.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
If the application has used bt_le_oob_get_local to retrieve the OOB
RPA address and OOB authentication information the central role should
use this RPA address for the next RPA timeout period.
The central role always refreshes the RPA address for the initiator,
this will make the OOB information not usable as the peer cannot
recognize the central role since the RPA address is changed.
Check if the initiator can use the address for the duration of the of
remaining RPA period.
Fix central role using the advertiser identity when setting the private
address. The central role should only use the default identity.
Regressions from:
fbe3285bfa
and
4876a8f39a
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix possible NULL dereference in BT_DBG statement when
bt_mesh_friend_get is called before a successful cfg_srv init
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix conditional compilation error when enabling
BT_CTLR_FAST_ENC for central only application builds.
Also added additional compilation to code exclusive to
central or peripheral role.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When building the tests/bluetooth/shell application without
the BT_CENTRAL feature, compilation fails:
subsys/bluetooth/shell/bt.c:1642: undefined reference to
`bt_conn_create_auto_le'
Signed-off-by: Vinayak Kariappa Chettimada <vinayak.kariappa@gmail.com>
Fix problem of not checking if the remote device key is actually our
own. This bug was intruduced in
46a95f12ad and causes failure of models
that use app_idx BT_MESH_KEY_DEV_REMOTE. Since this is used by cfg_cli,
it was not possible to do self-configuration.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
Add Kconfig option to support building the controller
optimized for speed.
Fixes#21601.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix local initiated Data Length Update procedure from being
stalled when a remote initiates a procedure with instant.
Fixes#23069.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Tx pool from being corrupted when rough central device
uses invalid packet sequence numbers, causing NULL pointer
to be released into free data Tx pool.
Fixes#22968.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If the client is change-unware and disconnects the spec requires that
the stack still sends the error out of sync for the next request:
'The ATT_ERROR_RSP PDU is sent only once after the client becomes
change-unaware, unless the client _disconnects_ or the database changes
again before the client becomes change-aware in which case the
ATT_ERROR_RSP PDU shall be sent again'
Fixes#23110
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Resend transport segments for groups on the advertiser interface, even
if a connected proxy node holds the group.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Update help text of `bt init` command which says address could be
provided. This feature was removed by:
d22b7c9f2d
As a replacement the `bt id-create` command can be used instead.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When a must-expire ticker callback is executed, it is important not to
call the LLCP state machine, as the lazy state is unavailable. The code
must rely on the next proper event to call ull_conn_llcp with an updated
non-zero lazy count.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix EBQ tests for the Max Tx Time and Max Rx Time parameter.
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Bluetooth: controller: split: fixed for endianness
Added conversion to correct endianness
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Fix local initiated Data Length Update procedure from being
stalled when a remote initiates a procedure with instant.
Fixes#23069.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix issue where a new connection with the same peer would use the CCC
from from first connection, despite different local identity.
Since there is no CCC for the new connection yet this caused the
application to think that CCC was enabled but the remote device had not
yet subscribed.
Fix this issue by making the id as an input to the peer address check
function. This will force us to make the check every time. This commit
might also fix similar issues not yes discovered as the ID check was
missing in a few other places as well.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename the acl buf context id to index since to avoid confusing it with
the conn object ID parameter. Especially the bt_conn_lookup_id function
was creating confusion.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix ticker resolve collision implementation for incorrect
ticks accumulation and the calculation of next period.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix a race condition in radio abort requested by flash
driver. It is possible that during abort function execution,
PPI setup to start radio fires. Hence, check explicitly in
cleanup function for radio being in use and disable it.
Fixes#22945.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the old ticker compatibility mode implementation as
default for nRF5x Series SoCs.
Fixes#22926.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Avoid the HCI-USB race condition where HCI data and HCI events can be
re-ordered, and pairing information appears to be sent unencrypted.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix to remove assertion failure check on detecting invalid
packet sequence used by peer central and that no non-empty
packet was transmitted.
Fixes#22967.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix issue where an invalid (all zeroes) hash was written to settings
storage on reset. This caused the old value to written to zeroes, before
being written back to it's original value again immediately after.
This causes excessive flash wear.
This happens because the check if (k_delayed_work_remaining) returns the
amount of time until the work will execute. When that time has run out
the time is zero, but the work has not yet been executed.
We then write the invalid hash to flash, and then once the work-item
executes it will write the correct value.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
- avoid spourious radio interrupts by fixing ISR set,
waiting for idle, command configuration
- adjust counter to account for missing increment
- change preemption instant to avoid missing the deadline in LLL
- decrese EVENT_JITTER_US and
EVENT_TICKER_RES_MARGIN_US (same as Nordic)
Continuous scanning and connections are working fine now.
Signed-off-by: George Stefan <george.stefan@nxp.com>
Created unit tests for the encryption and decryption functions.
Tested with the peripheral and with central_hr samples.
Due to latency of CAUv3 when used as CCM inline accelerator
only one of the PDU can be encrypted/decrypted within an
bilateral exchange M->S + S->M in a connection event.
If the RXed PDU is encrypted, the TXed PDU must be empty
with More Data if there is data in the LLL queue.
The TXed PDU will be encrypted when an empty PDU is RXed.
Signed-off-by: Cristi Caciuloiu <cristian.caciuloiu@nxp.com>
Fix regression due to addition of conditional compilations
while porting the privacy feature from legacy to split
controller.
Fixes#22801.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Backport of https://github.com/apache/mynewt-nimble/pull/724
Mesh spec 1.0.1 changes proxy disabling behavior to only affect the
relaying from proxy nodes. Previously, disabling proxy would shut down
all proxy and node activity.
Tweaks from the original commit:
- Removed redundant call to bt_mesh_adv_update() in gatt_proxy_set()
- Removed invalid ref to 4.2.11.1 in node_identity_set()
---
According to Mesh Profile Spec 1.0.1, Section 4.2.11:
"If the Proxy feature is disabled, a GATT client device can connect
over GATT to that node for configuration and control. Messages from
the GATT bearer are not relayed to the advertising bearer."
Moreover some notes have been removed from the spec compared to
version 1.0:
Mesh Profile Spec 1.0, Section 4.2.11:
"Upon transition from GATT Proxy state 0x01 to GATT Proxy state 0x00
the GATT Bearer Server shall disconnect all GATT Bearer Clients."
"The Configuration Client should turn off the Proxy state as the last
step in the configuration process."
Mesh Profile Spec 1.0, Section 4.2.11.1:
"When the GATT Proxy state is set to 0x00, the Node Identity state
for all subnets shall be set to 0x00 and shall not be changed."
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
SC config data is no longer stored within the CCC config itself
therefore it must be cleared separately.
Fixes#22539
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
GATT data shall not be considered conditional to BT_SETTINGS since
the data is stored in RAM it must also be cleared when unpairing.
Fixes#22514
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
smp_pairing_complete does actually clears flags so setting
SMP_FLAG_TIMEOUT must come after that.
Fixes#22786
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix bt_gatt_indicate using the wrong attribute pointer when a uuid was
provided as input.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename the scan recv callback info struct so that it reflects that it
is part of the scan recv callback. This will make it consistent with
future plans for advertising callbacks.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the scanner using the advertiser identity instead of the scanners
identity, scanner always use BT_ID_DEFAULT.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Corrected configuration of BT_HCI_RESERVE for the RPMsg HCI driver.
This change fixes the following assert:
[net_buf_simple_headroom(buf) >= len] @ ZEPHYR_BASE/subsys/net/buf.c:881
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This can happens if for example the remote peer have the initial credits
set to 0 which would cause bt_l2cap_chan_send to fail instead of just
queue the packets until more credits are given.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Data transmission was paused when PHY update request control
PDU was enqueued in ULL. If there was pending data PDU in
ULL that was not enqueued towards LLL, this caused
transmission to stall.
Move the tx pause due to PHY update request/response being
enqueued to pre_tx_ack callback, this way all pending PDUs
in ULL is enqueued to LLL.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
I think people might be reading differences into 'if' and 'depends on'
that aren't there, like maybe 'if' being needed to "hide" a symbol,
while 'depends on' just adds a dependency.
There are no differences between 'if' and 'depends on'. 'if' is just a
shorthand for 'depends on'. They work the same when it comes to creating
implicit menus too.
The way symbols get "hidden" is through their dependencies not being
satisfied ('if'/'depends on' get copied up as a dependency on the
prompt).
Since 'if' and 'depends on' are the same, an 'if' with just a single
symbol in it can be replaced with a 'depends on'. IMO, it's best to
avoid 'if' there as a style choice too, because it confuses people into
thinking there's deep Kconfig magic going on that requires 'if'.
Going for 'depends on' can also remove some nested 'if's, which
generates nicer symbol information and docs, because nested 'if's really
are so simple/dumb that they just add the dependencies from both 'if's
to all symbols within.
Replace a bunch of single-symbol 'if's with 'depends on' to despam the
Kconfig files a bit and make it clearer how things work. Also do some
other minor related dependency refactoring.
The replacement isn't complete. Will fix up the rest later. Splitting it
a bit to make it more manageable.
(Everything above is true for choices, menus, and comments as well.)
Detected by tweaking the Kconfiglib parsing code. It's impossible to
detect after parsing, because 'if' turns into 'depends on'.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The existing stack_analyze APIs had some problems:
1. Not properly namespaced
2. Accepted the stack object as a parameter, yet the stack object
does not contain the necessary information to get the associated
buffer region, the thread object is needed for this
3. Caused a crash on certain platforms that do not allow inspection
of unused stack space for the currently running thread
4. No user mode access
5. Separately passed in thread name
We deprecate these functions and add a new API
k_thread_stack_space_get() which addresses all of these issues.
A helper API log_stack_usage() also added which resembles
STACK_ANALYZE() in functionality.
Fixes: #17852
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
If CONFIG_BT_CTLR_CONN_RSSI is enabled, then lll_conn.h should
be included as well. Otherwise, struct lll_conn is unknown
at the compile unit level. This has been reproduced by
compiling the hci_uart sample, where the following error occurs:
lll_adv.c: In function 'isr_rx_pdu':
lll_adv.c:722:13: error: dereferencing pointer to incomplete
type 'struct lll_conn'
lll->conn->rssi_latest = radio_rssi_get();
^~
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
Until now the choice of reliable sending (segmented messages with
acks) was implicitly dependent on the size of the payload. Add a new
member to the bt_mesh_model_pub to force using segment acks even when
the payload would fit a single unsegmented message.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix uninitialized advertiser rl_idx used to check own identity
in CONNECT_IND received for directed advertisements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the handling of network nodes and their keys into a separate
Mesh Configuration Database (CDB). This, not only creates a separation
of the local node and the other nodes, but also makes it possible to
implement functions to manage the whole, or at least parts of the mesh
network.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
This API will be deprecated in favor of the new API that clearly
specifies whether it works on logical or physical levels.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Some compilers can't resolve the conditional if/else/else construction
in ull_conn event_len_prep function, and fail with an 'uninitialized
variables' error. The change has no functional impact.
Signed-off-by: Morten Priess <mtpr@oticon.com>
BT_CTLR_SETTINGS should not depend on BT_SETTINGS as this will prevent
using settings system in the controller in a controller only build.
(BT_SETTINGS depends on BT_HCI_HOST)
Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
This commit adds a new option CONFIG_BT_SMP_USB_HCI_CTLR_WORKAROUND
to support USB HCI controllers that sometimes send out-of-order HCI
events and ACL Data due to using different USB endpoints.
Enabling this option will make the master role not require the
encryption-change event to be received before accepting
key-distribution data.
It opens up for a potential vulnerability as the master cannot detect
if the keys are distributed over an encrypted link.
Fixes: #22086
Signed-off-by: François Delawarde <fnde@oticon.com>
Directed advertising timeout was dropped in the host due to
not being able to find a pending connection. Host used the
role parameter from the error event parameters which has
been earlier zero-ed out.
Regression introduced in commit a0349689ff ("Bluetooth:
host: Fix conn object assigned to wrong connection")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When starting a non-connectable advertiser and an active scanner is also
using NRPA address then this use-case should be supported. A new
advertiser that is non-connectable should have a fresh NRPA address
every time it is started, so we must refresh the NRPA used by the active
scanner.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When advertiser is disabled we should update the random address for both
passive and active scanner back to an NRPA. But this command will fail
because the if the scanner is an active scanner, we must disable and
re-enabled the active scanner after setting the random address.
This behavior should not be there when scanner is configured to scan
with identity address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Document why a privacy-disabled scanner will not notify about directed
advertising reports. This is the default behaviour of the
privacy-disabled scanner. In order to receive the reports the option
BT_SCAN_WITH_IDENTITY must be enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Prevent the advertiser from overwriting the passive scanners identity
address when the scanner has been configured to scan using the identity.
In this case the LE Set Random Address command would not prevent the
address from being overwritten. So instead we explicitly stop it in the
host.
Also fix original code function not working at all since the first
if statement was should had a bad check. Resulting in it always
returning success.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Drop directed advertiser reports when the passive scanner should have
been using the NRPA address. The advertiser has overwritten the NRPA
with it's identity address instead and a peer is sending directed
advertiser packets to it.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When privacy is disabled by default the scanner still protects it's
identity with the use of NRPA addresses. We should not set the identity
address for the passive scanner unless the Kconfig option to scan with
the identity has been enabled.
This makes passive scanner behave the same way as an active scanner
since none of them will report directed advertising reports towards
the scanners identity.
This also enables the advertiser to switch out the random address which
is needed for the Bluetooth Mesh LPN case.
Fixes#22088.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Add pairing support callback to print remote pairing features when this
option is enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Similar to pairing_confirm this callback is called each
time a peer requests pairing, but for all types of
pairings, except SSP. The pairing req/rsp information is
passed as a parameter so the application can decide
wheter to accept or reject the pairing.
Fixes: #21036
Signed-off-by: Martin Rieva <mrrv@demant.com>
In a combined build where bt_rand functions is implemented in the host
the RPA module should not use the bluetooth rand function since the RPA
module is common for host and controller.
Having the controller call the the host only to go through HCI back into
the controller would not be a good idea.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix infinite recursion in host-based bt_rand function. This would call
HCI LE Random Number command, which would in turn call bt_rand, causing
an infinite recursion.
bt_rand -> prng_reseed -> BT_HCI_OP_LE_RAND -> le_rand -> bt_rand
To solve this issue the controller should avoid doing calls into the
host, so all calls to bt_rand in the controller should be replaced with
a call to a controller function.
Fixes#22202
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix LE Create Connection command giving out of range parameters to the
controller, this came back as 0x30 (Out of Range Parameters) status code
on the command from the controller.
This appears to be the min and max CE parameters in the command.
Revert back memset from 137f704064
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix problem where application was notified about a new connection being
established, but no connection has actually been made.
This occurred because the LE Create Connection command failed directly
from the API, in which case the state transition thinks the err is valid
and always notifies the application.
Introduced by:
6c1f52dff7 for bt_conn_create_le
e9eebf0c40 for bt_conn_create_auto_le.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix an issue where a slot in the key pool was considered free when
either the address was cleared or no keys were written in the entry
(enc_size == 0). This caused a problem with simultaneous pairing
attempts that would be assigned the same entry.
This patch makes it so a a slot is considered free even when keys are
not yet present in the entry, and makes sure the address is cleared in
case of pairing failure or timeout so to mark the slot as free.
Signed-off-by: François Delawarde <fnde@oticon.com>
SW based privacy is an implementation detail in the zephyr link layers.
Therefore it should not be visible when selecting an out-of-tree
controller.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Since a peer MIC failure closes the event, it does not allow a terminate
acknowledge. For that reason a peer MIC fail for central role must force
a conn_cleanup.
Signed-off-by: Morten Priess <mtpr@oticon.com>
This fixes the EBQ tests 129 and 130. These tests check behaviour for
the DLE procedure when Encoded PHY or 2M PHY are not supported.
See also BT core spec. Version 5.1, Vol6, Part B, Section 5.1.9
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
When clearing the whitelist, possible white listings in resolve list
were left. These are now also cleared.
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Moves the Mesh AES-CCM module out into a separate module, to make it
accessible from other subsystems. Adds the new CCM API in
include/bluetooth/crypto.h along with the bt_encrypt functions.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When PB-GATT support has been enabled the provisioning code "borrows"
the buffer from the proxy code. However, the way that initialization
was happening the proxy buffers were initialized only after
provisioning initialization, resulting in a corrupted buffer with
buf->data pointing to NULL. Reorder the initialization calls so that
proxy is done first and provisioning only after it.
Fixes#22207
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Clean up the nRF cmake include file to remove redundant
check for BT_LLL_VENDOR_NORDIC inside the file.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
SMI TX is different than other controller features in that it does not
necessarily imply any software changes; whether SMI TX is supported
may be simply a matter of hardware calibration. This change supports
using the same software on chips that do or do not support SMI TX
depending on calibration.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Move reset of channel status from after the destroy callback since the
after the destroy callback the memory should be assumed to be released.
Instead clear the channel status when the channel is created in
l2cap_chan_add. This way we don't rely on the memory given being set to
the correct value.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix ATT releasing the att structure back to the memory slab allocator
before the structure is actually ready to be released. The memory slab
allocator will write context data inside the freed slab which is
currently being overwritten by l2cap during channel teardown.
This manifests as an "Unable to allocate ATT context for conn" when
reconnecting with multiple connections.
Since the l2cap channel is embedded inside of the ATT context and l2cap
still has a valid referenc to the l2cap channel we need to release the
ATT context at a later time.
This should be fixed by implementing the channel destroy function and
releasing the channel there.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add the option to provide the destroy callback to the fixed channels.
This can be used to free the memory for the L2CAP channel context which
is provided by the fixed channel in the accept callback.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
As a part of a ticker extension interface, it is now possible to specify
a slot_window when starting a ticker. When setting the
ticks_slot_window to a non-zero value, it is requested that the node
timeout is re-located to a position within the window, where the node
does not collide with other nodes - aligning to the end of the window.
The solution takes into consideration if a node has already been
updated with drift correction (e.g. ADV randomization), subtracting this
from the window.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Updated the lll_conn_flush interface to pass the connection
handle while the LLL connection context stored handle has
been invalidated.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The callback function may modify the att->req and it has to be
called after the att_process. The att_process does not re-check
if att->req is still NULL.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
The CONFIG_ prefix was missing.
Found with a work-in-progress scripts/kconfig/lint.py check.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Fix assert in net_buf triggered on att encrypt change event.
ASSERTION FAIL [net_buf_simple_headroom(buf) >= len] @
ZEPHYR_BASE/subsys/net/buf.c:881
This happens because when the att request was allocated, it was not
properly initialized and req->retrying was left as true.
This caused the att encrypt change handling to assume an att request
needed to be resent, starting resending with an invalid request and
request buffer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fixes some selects with unsatisfied dependencies. FLASH_SHELL depends on
FLASH_PAGE_LAYOUT, but only FLASH_SHELL is selected. The select was
introduced in commit 3aa2a1c6db ("flash: make flash shell generic").
Spoke to Johan Hedberg. The BT_SHELL code does not depend on
FLASH_SHELL. He didn't think people would assume that BT_SHELL by itself
enables the FLASH_SHELL commands either.
Just remove the select.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Zephyr aims to enable supporting of multiple SW defined
BLE LL. There is a complex hierarchy of defines in the
CMake files controlling the compilation units that part of
the final library. Adding another SW LL implementation
from a different SoC provider will make the main controller
CMake file unmaintable.
As such, split the into vendor-specific CMake files for
easier additions.
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
Change adds missing Kconfig dependency.
The CONFIG_BT_CTLR_FILTER is used only for SW Link Layers.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Refactor use of #ifdef to IS_ENABLED() pattern for handling cancellation
of outgoing connection attempt. Reduce the amount of indentation by
combining outer if-statements.
Move handling of canceled create connection into a helper function.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix advertiser requested to use the identity address while privacy
feature is enabled will change to using RPA address when advertise is
resumed or when RPA timeout occurred.
RPA timeout does not need to run when advertiser is using identity.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add shell command for advertise with identity option to have the
possibility to temporarily disable privacy feature in the advertise from
the shell.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle initiator role when RPA timeout expires. For direct connect
establishment procedure we make sure the RPA is refreshed when starting
initiator and limit the timeout to the RPA timeout.
For auto establishment procedure we cancel the initiator and restart it
again in the connection complete event that is generated when canceling
an initiator.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle starting of advertiser and scanner or initiator when advertiser
is using a different identity than the default identity to generate the
random resolvable address in the controller.
We need to handle this only for the privacy case because the random
address is set in the RPA timeout handler and not from the API.
When privacy is disabled we can return error code from the LE Set Random
Address HCI command instead.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix RPA timeout handling when the scanner is active. An active scanner
must be restarted at RPA timeout otherwise the Set Random Address
command will fail.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the handling of sending the LE Create Connection command and
for whitelist and direct initiator to use the same host state flag
and common handling of the privacy address.
Also simplify the way we check if the procedure has already been started
when application tries to start it again.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle a possible race condition in the host connection state.
Set the conn state of the connection object before command is sent. This
is in case the calling function is not scheduled again before the
connection complete event arrives. In this case find_pending_conn will
not find the connection object.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Starting a background scanner for auto-connection is an API that is only
available when whitelist API is not enabled.
There is currently no way to set this bit when the whitelist API is
enabled so there is not any issues with the current code, but it is
still not correct.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When receiving a connection complete event but no connection object are
available in the host something strange has happened. In this case
the controller might have a connection that cannot be controlled by the
application. It would then be sensible to disconnect this connection in
the controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
generated_dts_board.h is pretty redundant and confusing as a name. Call
it devicetree.h instead.
dts.h would be another option, but DTS stands for "devicetree source"
and is the source code format, so it's a bit confusing too.
The replacement was done by grepping for 'generated_dts_board' and
'GENERATED_DTS_BOARD'.
Two build diagram and input-output SVG files were updated as well, along
with misc. documentation.
hal_ti, mcuboot, and ci-tools updates are included too, in the west.yml
update.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Moving struct definitions into header file and adding API to
allow accessing data-structures from lll context
Signed-off-by: Erik Brockhoff <erbr@oticon.com>
Fix unable to select the Zephyr Vendor-Specific HCI commands support in
host-only build. Set VS HCI support as default on if it is known that
the controller supports it. Otherwise set it to off, this means that
VS HCI support will be default off in host-only builds.
Fixes: #21996
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The path to include/drivers should not be in the compiler include path
list, only include/. In order to make this possible, always explictly
refer to hci_driver.h via the drivers/bluetooth/ path and not only
bluetooth/.
Fixes#21974.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Bluetooth sample with controller crypto, requires sys_rand32_get that
used to be linked with Tinycrypt. The selection, within Kconfig of
Tinycrypt, that has been enabling compilation of the symbol has
been removed and thus preventing controller crypto to link.
This commit moves the selection to BT_CTLR_CRYPTO.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow models to skip a periodic publish interval by returning an error
from the publish update callback.
Previously, an error return from publish update would cancel periodic
publishing. This can't be recovered from, and as such, no valid model
implementation could return an error from this callback, and there was
no way to skip a periodic publish.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Under race conditions it is possible that there is no call
to k_sem_give to the waiting k_sem_take in the ull_disable
function.
ull_disable function checks for reference count before
using a mayfly to schedule lll_disable, which in turn
would close requested currently active role event leading
to done event being propogated to ULL. Done event would
then call the set disabled_cb callback when the reference
count is zero, giving the semaphore to the waiting
k_sem_give in the ull_disable.
Under race conditions if the reference count reached zero
after the reference count check and before the disabled_cb
was assigned in the ull_disable function, then there are
chances that a k_sem_give is not called while ull_disable
proceeds to waiting using k_sem_take.
Fixes#21586.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Guard calls to bt_conn functions in bt_le_adv_start_internal with
IS_ENABLED(CONFIG_BT_PERIPHERAL) to avoid undefined symbols in builds
that do not support that role.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Fix CONFIG_BT_CTLR_TX_BUFFER_SIZE value range to 251 Bytes
due to implementation limitation in use of u8_t for PDU
length fields in controller Tx buffers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix controllers address check in cases of controller-based
privacy is supported but not used to start advertising.
This fixes regression introduced in
commit 896619ad40 ("Bluetooth: controller: Fix
controller address check").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the event_len_prep routine to increase readability without
affecting code size
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
There is an obscure bug in the case that CFG_BT_CTLR_PHY is not defined;
when a feature-exchange already has happened the lr->max_tx_time and
lr->max_rx_time are not calculated.
This bug is fixed by this commit.
Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
Fix error in calculation of the minimum discardable buffer size. For
the LE Advertising Report the maximum payload is 31 bytes plus
additional data in the event gives an event size of 41 bytes (given that
num_reports is 1). Since this is a meta event we need to include the
sub-event code, plus the event header of 2 bytes. Total of 44 bytes.
This is a regression from afa9c42d75 where we forgot th 1 byte for the
RSSI that is appended after the data. Easy to miss since it is not part
of the struct.
Fix error in calculation of the num complete buffer size. Here we forgot
to include the 2 byte event header.
This is a regression from 89981b07c8.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This change prevents zephyr LL specific configurations to show up when
using an out of tree BLE controller.
BT_CTLR_ASSERT_HANDLER is used outside the controller as well,
so this is kept as is.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Remove re-using connection objects in disconnected state when creating
directed advertiser or establishing a connection as a central using
direct connection procedure.
This makes the API mores consistent it terms of which connection roles
can be started from the disconnected callback.
This also avoids a central connection object being re-used for a
connection as a peripheral instead and vice versa.
When attempting to create a new connection the API would returning
a valid connection object if there is already an existing connection
object.
This existing connection object could be either in the process of
establishing the connection or already connected.
Returning the connection object in this would give the false impression
that the stack has initiated connection procedure, when in fact it just
returned an existing connection object.
The application has the ability to check for existing connection objects
using the bt_conn_lookup_addr_le API.
Add warning plus comment possible scenarios why the a valid connection
object might exists. Most important is to explain why a valid connection
object exists during the disconnected callback.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Reserve conn object for undirected connectable advertiser. This means we
won't have a situation where we start a connectable advertise but will
fail to allocate a connection object for it in the connection complete
event.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Reserve a connection object when starting the auto-initiator using the
controller whitelist.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bt_conn_create_aute_le returning the wrong error code when bt_init
has not been called yet. This is inconsistent with the rest of the API
functions.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor stopping directed advertiser to disconnect the state object
when calling advertise stop. This follows the same pattern as
bt_conn_disconnect.
Remove returning conn objects in BT_CONN_CONNECT state, this state could
only be an initiator starting a connection in the central role.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make sure that the auto-conn state is cleared correctly when we might
fail to allocate a new connection object.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix conn object assigned to the wrong controller connection in the
connection complete handler. This could happen when running a
directed advertiser and establishing a connection at the same time to
the same peer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add option to set the size of the discardable buffer pool. This saves
memory for the MESH use case where we expect a large number of advertise
reports.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Adds a way to register listeners for incoming scanner packets, in
addition to the callback passed in bt_le_scan_enable.
This allows application modules to add multiple scan packet listeners
without owning the scanner life cycle API, enabling use cases like
beacon scanning alongside Bluetooth Mesh.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Change assertion messaged printed from printing expression to printing
the line and file name. This provides more context as the same
expression could be asserted upon multiple times and would then not
provide enough clarity in the message.
Also using a formatted string would save code space as we can use the
same string for all messages instead of creating a unique one for each
condition.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The function bt_mesh_ctl_send() used to support maximum length of
11 bytes. The segmentation complies with the BLE Mesh Standard.
The ack is disabled in case of non unicast address.
Signed-off-by: Ahmed Hussein <ahmed_hussein_@hotmail.com>
Replaces the Mesh model settings_commit callback with a start callback,
indicating that the mesh model behavior is ready to start. Everything
that was previously done in the settings_commit callback may be moved to
this callback, which gets called just after mesh settings are committed,
instead of in the middle of the process.
This resolves an issue where models had no context in which to start
their behavior, as the previous settings_commit call fired before the
mesh was declared valid, making access APIs inaccessible.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Current implementation of application's cfg_write callback only has the
possibility of returning boolean status, which in case of failure only
allows for one error code; BT_ATT_ERR_WRITE_NOT_PERMITTED.
This change makes the application able to add own security check on
characteristic subscription in the cfg_write callback and report a more
relevant error code (e.g. BT_ATT_ERR_AUTHORIZATION).
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
Remove toggling the advertise enable state when the advertiser name has
been updated. Advertise and scan response data should be used by the
controller on subsequent advertising events.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
If bt_gatt_subscirbe fails value_handle must be reset since otherwise it
will not possible to subscribe again as the parameters will be consider
in use.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This further reduce the overhead on each subscription at expense of
having a dedicated array to store subscriptions, the code now maintain
a separate list for each peer which should also scale better with large
number of subscriptions to different peers.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This should reduce the footprint on applications that do a lot of
requests i.e have a lot of subscriptions.
Fixes#21103
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix controllers address check in cases of controller-based privacy.
When controller has been instructed by the host to use privacy
the controller should look up the peer identity address and generate
an address based on the local IRK. In the case where no match
is found or the local IRK is all zeroes the controller shall use
the fallback address. If the fallback address is not valid the
controller shall return invalid params.
This commit fixes these issues:
- Starting a private advertiser without valid random address set
but a valid local IRK exists. In this case the advertiser should
be able to advertise using the RPA regardless of a valid random
or public address.
- Starting a private advertiser with a fallback to the public
address type or an adveriser using public address does not
check if a valid public address exists. The host cannot
advertise with an all-zero public address.
Signed-off-by: Joakim Andersson <joerchan@gmail.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug when connecting using whitelist and split controller.
The peer address was set to an all zeroes address.
Bug using shell:
bt init
bt wl-add <addr>
bt wl-connect on
Connected: 00:00:00:00:00:00 (public)
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Providing 'tmp', which was never updated, resulted in removeal of
subscriptions from the beginning.
Using the updated 'prev' resolves this.
Signed-off-by: Marco Sterbik <madbadmax00@gmail.com>
Start initiator immediately instead of scanning for device first.
If the host resolving list is used we need to go via scanner to resolve
the address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added Kconfig option to conditionally compile in HCI command
parameter validation code.
When building a combined host plus controller application,
only validations in the host at the top level close to the
API caller is sufficient.
The controller validations are included in controller only
builds.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Instead of having all (=addr NULL or BT_ADDR_LE_ANY to bt_unpair) as a
special case, iterate over all connected peers and unpair them the
regular way. This means bt_gatt_clear is called too. Doing this way
allows us to remove a lot of (now) unused code as well.
Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
Pass the scanner LLL context in the generated connection
complete event with unknown connecion id for HCI Create
Connection Cancel Command Response.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Directed advertising timeout released PDU Rx quota which it
should not be.
Relates to assert in #21006.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
hdr->length is the length of the payload, it should be
buf->len - sizeof(*hdr) - 1 or buf->len - (sizeof(*hdr) + 1)
Signed-off-by: ZhongYao Luo <LuoZhongYao@gmail.com>
The upper transport layer is using big endian ordering. The
PreviousAddress field of a Friend Request message should therefore
be converted to native endianess using sys_cpu_to_be16().
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Add comment that explains why a different byte order is used for the
3-byte opcode on the CID part of the opcode.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use 24-bit functions for byteorder and net_buf in order to make the
byteorder used more readable.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix tx_time calculation for the case that BT_CTRL_PHY is defined and
there has not been a feature exchange.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix tx_time calculation for the case that BT_CTRL_PHY is defined and
there has not been a feature exchange.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Credits are 2 octects long so an s16_t positive portion can only half to
the theorical maximum number of credits, so instead this uses u16_t and
do a bound check instead of checking for negative values.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With the changes that introduced a queue k_sem is only used with
K_NO_WAIT which means it is no longer possible to wait/block for credits
so the usage of k_sem is no longer needed and can be safely replaced
with atomic_t just to count the available credits at a given instant.
Fixes#19922
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add printing of the remote version information whenever the new
CONFIG_BT_REMOTE_VERSION option is enabled.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Make remote features and remote version accesible to the application
through the bt_conn_get_remote_info object. The host will auto initiate
the procedures. If the procedures have not finished with the application
calls bt_conn_get_remote_info then EBUSY will be returned.
The procedures should finish during the first 10 connection intervals.
Signed-off-by: Sverre Storvold <Sverre.Storvold@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Refactor the handling of the host auto initiated LL procedures.
This makes it easier to add new auto initiated procedures as well as
reduced the maintenance by reducing code duplication.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit reverts the change that moved the remote version event from
a priority event to a normal event. This is done because the strategy
for using this event has been changed and will be used with a callback
instead of a semaphore that could be locked from the RX thread.
This commit retains the infrastructure that was added in the controller
so that moving events to priority processing is still possible.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
A single menu within an if like
if FOO
menu "blah"
...
endmenu
endif
can be replaced with
menu "blah"
depends on FOO
...
endmenu
Fix up all existing instances.
Also remove redundant extra menus underneath 'menuconfig' symbols.
'menuconfig' already creates a menu.
Also remove the menu in arch/arm/core/aarch32/Kconfig around the
"Floating point ABI" choice. The choice depends on FLOAT, which depends
on CPU_HAS_CPU, so remove the 'depends on CPU_HAS_FPU' too.
Piggyback removing a redundant 'default n' for BME280.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Always check that the length of the returned command complete
event for a vendor specific command matches the expected length
when the support for Zephyr VS HCI commands are uncertain.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix multiple issues related to the way the host handles
Identity Information related to privacy
1. If the controller provided a public address the IRK
for this identity would be randomly generated but not
stored persistenly.
2. Fix the handling of the above issue which was fixed
for the random address but would initiate settings save
ID on every boot.
3. Fix the host not using the Vendor Specific HCI commands
related to retrieving the Identity Root (IR) from the
controller and using the key diversified function d1
to generate an IRK as specified in the BT Core spec.
Make sure that a Host generated ID is only saved when it is first
generated.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Return the IR defined in FICR as the Identity Root for the static
address through the read static addresses command instead of providing
it through the Read Key Hierarchy Root command.
This is following the recommendations in the Zephyr HCI extension
document in doc/reference/bluetooth/hci.txt
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix controllers address check in cases of controller-based privacy.
When controller has been instructed by the host to use privacy
the controller should look up the peer identity address and generate
an address based on the local IRK. In the case where no match
is found or the local IRK is all zeroes the controller shall use
the fallback address. If the fallback address is not valid the
controller shall return invalid params.
This commit fixes these issues:
- Starting a private advertiser without valid random address set
but a valid local IRK exists. In this case the advertiser should
be able to advertise using the RPA regardless of a valid random
or public address.
- Starting a private advertiser with a fallback to the public
address type or an adveriser using public address does not
check if a valid public address exists. The host cannot
advertise with an all-zero public address.
Signed-off-by: Joakim Andersson <joerchan@gmail.com>
The test_and_set_bit() should be checking if the flag was *not*
already set, since that's the scenario where we want to call the
status callback.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The ch pointer is the result of a CONTAINER_OF() operation, so
checking it for NULL is pointless. Additionally, there's no place that
calls this function with chan set to NULL.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Make the channel ops struct const since there really isn't anything
there that needs to change at runtime. The only exception is the L2CAP
shell which was playing with the recv callback, however that can be
fixed by introducing a simple bool variable.
With tests/bluetooth/shell this reduces RAM consumption by 112 bytes
while adding only 16 bytes to flash consumption.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Remove the 4us advanced radio reception, the implementation
passes all timing conformance tests without this.
This change should reduce some radio power consumption by
avoiding redundant reception duration.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Low frequency and high frequency clocks had separate devices
while they are actually handled by single peripheral with single
interrupt. The split was done probably because opaque subsys
argument in the API was used for other purposes and there was
no way to pass the information which clock should be controlled.
Implementation changes some time ago and subsys parameter was
no longer used. It now can be used to indicate which clock should
be controlled.
Change become necessary when nrf5340 is taken into account where
there are more clocks and current approach would lead to create
multiple devices - mess.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix LENGTH_RSP and PING_RSP to be send after Encryption
Setup under the cases where LENGTH_REQ or PING_REQ cross-
over with ENC_REQ in the same connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Overlapping Feature Exchange requested by host with
Encryption Setup requested by the application caused the
controller to corrupt its Tx queue leading to Tx Ctrl PDU
buffers from leaking from the system.
Relates to #21299.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit targets solving issue #17731 over the Nordic LL LEGACY
arch of the BLE stack in Zephyr. This functionality is exposed
to the user as HCI Zephyr Command extensions
- BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL
- BT_HCI_OP_VS_READ_TX_POWER_LEVEL
which enable Tx power read/write operations within BLE radio events
on a per role/connection basis.
The functionality is enabled upon the Kconfig advanced configuration
triggered by
- BT_CTLR_TX_PWR_DYNAMIC_CONTROL
depending on the enablement of Zephyr HCI vendor-specific command
extensions.
Signed-off-by: Andrei Stoica <stoica.razvan.andrei@gmail.com>
This commit targets solving issue #17731 over the LL_SW_SPLIT
arch of the BLE stack in Zephyr. This functionality is exposed
to the user as HCI Zephyr Command extensions
- BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL
- BT_HCI_OP_VS_READ_TX_POWER_LEVEL
which enable Tx power read/write operations within BLE radio events
on a per role/connection basis.
The functionality is enabled upon the Kconfig advanced configuration
triggered by
- BT_CTLR_TX_PWR_DYNAMIC_CONTROL
depending on the enablement of Zephyr HCI vendor-specific command
extensions.
Necessary low-level radio HAL functionality and power definitions
are also supplied to address the high-level functionality of
controlling the Tx power.
Signed-off-by: Andrei Stoica <stoica.razvan.andrei@gmail.com>
Fix LENGTH_RSP and PING_RSP to be send after Encryption
Setup under the cases where LENGTH_REQ or PING_REQ cross-
over with ENC_REQ in the same connection event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Overlapping Feature Exchange requested by host with
Encryption Setup requested by the application caused the
controller to corrupt its Tx queue leading to Tx Ctrl PDU
buffers from leaking from the system.
Fixes#21299.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix leak of the node_rx buffer when processing the LL version ind as a
priority event. This leak meant being able to establish new connections
was no longer possible, because there weren't enough events to process
the all the events during connection establishment. And instead the LL
ignored the connection request sent by the peer.
Removed the inline extern declaration of a function which had a proper
header included.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This documents the special cases where -EAGAIN is returned which leads
the buffer to be queued.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Now that bt_l2cap_send_cb can fail the buffer state needs to be save
and restored otherwise the data stored on it would be lost.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduces BT_L2CAP_STATUS_SHUTDOWN which is used to indicate when
a channel has been shutdown.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This offloads the processing of tx_queue to a work so the callbacks
calling resume don't start sending packets directly which can cause
stack overflow.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Drop packets received while disconnecting since they would most likely
be flushed once peer respond there is no gain in keeping them on a
queue.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This prevents disconnect request packets to not being sent due to lack
of buffers normally caused by flooding or congestion.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If NET_L2_BT is enabled we need enough acl_in_pool needs to be big
enough to contain a full IP packet since that is no longer processed by
RX thread buffer would be queued to syswq to reassemble the SDU.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When NET_L2_BT the memory pressure for fragments can be quite high
since that would be transfering IP packets which are considerable big
so this makes our frag_pool to be of the same size as NET_BUF_TX_COUNT.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This enable chaning the function and line number making it easier to
debug where a buffer allocation is blocking.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When a segment could not be allocated it should be possible to resume
sending it later once previous segments complete, the only exception is
when there is no previous activity and we are unable to alocate even the
very first segment which should indicate to the caller that it would
block since that only happens on syswq the caller might need to defer to
another thread or resubmit the work.
Fixes#20640
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add command to print all existing connections. Useful for verifying that
connections are actually released when debugging.
More information can be retrieved with `bt info <addr>` using the
address printed by this command for each connection.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add command to print all existing bonds. Useful for verifying that bonds
are actually cleared when debugging.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix implementation for the missing reset of version
information procedure request state value.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The whitelist API uses the controller directly through HCI commands.
Bluetooth device must have been initialized before sending HCI commands.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move invalidation of connection handle when flushing TX buffers into
LLL context. Otherwise, LLL may or may not see invalidated handle
depending on mayfly scheduling.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
If the duration to publish is roughly the same as the period, we might
end up with elapsed == period, which returns 0 and cancel the periodic
publication. Instead 1 should be returned, just like when the elapsed
time is greater than the period.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Unifies the Mesh CCM implementation parts for encryption and decryption
into a crypt and an auth step, reducing stack usage and code size.
This change also brings several performance improvements, most notably
reducing copying of the nonce and unrolling the 16 byte XOR operations.
Performance for the Mesh worst case of a 382 byte payload with 16 bytes
of additional data (full transport encrypt with virtual address) goes
from an average of 889us to 780us on nRF52840 with default optimization
flags.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.
Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.
Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Handle invalid ACL flags in HCI transport.
Only Point to Point is supported over HCI in both directions.
Fix flushable start HCI ACL packets not allowed on LE-U connections
from Host to controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In bt_l2cap_br_chan, rx.cid is the local cid and tx.cid is the
remote cid. According to Core-5.0 Vol3.Part A 4.6-4.7,
l2cap_br_remove_tx_cid should be searched using tx.cid
Signed-off-by: ZhongYao Luo <LuoZhongYao@gmail.com>
According to BT Spec v5.1 Vol 2 Part E Section 7.8.16, if the
device is already in the White List, the controller should not
add the device to the White List and should return success.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
According to BT Spec v5.1 Vol 2 Part E Section 7.8.16, if the
device is already in the White List, the controller should not
add the device to the White List and should return success.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If the whitelist already exists in the controller then the controller
should not add the device tot the whitelist and should return success.
In that case the counting of entries in the whitelist in the host will
be wrong.
Remove all whitelist counting in the host, and instead rely on the error
reported by the controller for this.
The controller should return error if the whitelist is full.
The controller should return error if use of whitelist was requested but
the whitelist was empty.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When Friend node tries to send Friend Clear message to other
Friend nodes, it should use the subnet information based on
the net_idx from friendship.
Fixes#21165
Signed-off-by: Maximus Liu <maximus.liu@gmail.com>
Expose the bt_uuid_to_str function as an API to the application.
This aligns this function with the bt_addr_to_str function call. This
allows the application to use this function without having to enable
the BT_DEBUG option.
Move the in-place bt_uuid_str to internal logging, this is mainly done
due to the limitation in the log_strdup that shouldn't be exposed to the
application.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Bool symbols implicitly default to 'n'.
A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.
Also replace some
config
prompt "foo"
bool/int
with the more common shorthand
config
bool/int "foo"
See the 'Style recommendations and shorthands' section in
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Check that the bluetooth device has in fact been initialized before
continuing with public API calls. This could lead to crashes when using
state that has not yet been initialized.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When set, the BT_GATT_SUBSCRIBE_FLAG_NO_RESUB flag indicates that the
subscription should not be renewed when reconnecting with the server.
This is useful if the application layer knows that the GATT server
persists subscription information.
Signed-off-by: François Delawarde <fnde@oticon.com>
Added configuration for accepting pairing requests only if both devices
has bonding flag set in order to reject other devices at an early stage,
thus leaving more chance for devices expected to bond.
With the CONFIG_BT_BONDING_REQUIRED flag the device only accept pairing
requests if it has CONFIG_BT_BONMDABLE set and the device requesting
pairing has Bonding_Flags field set to Bonding (0x01) in its AuthReq.
Note: When using bt_set_bondable(false) pairing requests will be
rejected when CONFIG_BT_BONDING_REQUIRED is set.
Signed-off-by: Martin Rieva <mrrv@demant.com>
Fix issues that surfaced when trying out GCC 9.2, official release name
gcc-arm-none-eabi-9-2019-q4-major, both related to invalid pointers in
GATT when declaring UUIDs in if-scope.
1. Fix the discovery callback giving an invalid pointer in the discovery
callback in two instances.
2. Fix gatt_find_type sending invalid data during discovery procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Send connection parameter update request only if it contains the valid
range of values for connection intervals, latency and timeout.
Signed-off-by: Kiran Paramaswaran <kipm@oticon.com>
Fix ATT MTU size of length variables resulting in wrong length values
reported to the user. Communicating with an Android device using an MTU
of 517 resulted in write commands reported as length 2 instead.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Since bt_conn_send_cb can fail to send buffer causing it to unref this
may cause buffer leaks as the caller is not aware of the error assuming
the buffer could be sent.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Processing of data received on dynamic channels is still done via syswq
so the buffer shall not be unrefed when they are queued.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Now that the TX callbacks happen from the system workqueue but fixed
channels get processed from the RX thread there's a risk that the
ordering of these gets messed up. This is particularly bad for ATT
when it's trying to enforce flow control.
To fix the issue store the completed TX packet information in a
per-connection list and process this list before processing any new
packets for the same connection. We still also schedule a workqueue
callback, which will simply do nothing for this list if bt_recv()
already took care of it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This define is not of use anymore since there's a global net_buf user
data Kconfig variable and its definition already guarantees a
sufficient minimum for Bluetooth.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The "sent" tracking doesn't have to be a signed integer. Use a fixed
size so that the consumed size doesn't change between different
architectures. Use a u16_t since bigger sizes are needed and because
this is mapped to an int function return higher up in the stack.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixed handling of HCI events in the HCI driver over RPMsg. Now,
the driver makes use of discardable buffer pool when allocating
memory for certain HCI event types (e.g. Advertising Report Event).
Applications that are flooded with Advertising Reports will run
much better after this change (e.g. Mesh applications).
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
If LL Connection Parameter Request or LL Connection Update
or LL PHY Update procedure is started by the local device
while a LL Length Update Request PDU has been sent by peer
then a Rx node has been stored in the llcp_rx place holder
for generation of Length Update procedure complete.
The failing assert check is incorrect in the above scenario
hence remove. Instead a missing append of the allocated Rx
node to the llcp_rx list has been added to the controller
implementation.
This issue relates to commit d12c53f89f ("Bluetooth:
controller: split: Fix missing data len update event").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Now that the TX path and TX context (bt_conn_tx) has been redesigned
to free the contexts always in the system workqueue, it means the
system workqueue is the only context where their allocation may also
fail. This is particularly problematic with us having all L2CAP
channels (fixed & CoC alike) deferred to the system workqueue. It is
especially bad for fixed channels where being able to send responses
for SM, L2CAP signaling and ATT is critical to avoid timeouts for the
connection.
This patch moves the processing of all fixed L2CAP channels back to
the RX thread, thereby making it possible (and safe) to block while
waiting for a TX context to become available.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that we've removed the TX allocation dependency from the TX thread
we no longer have the need to do special-casing for the system
workqueue when allocating buffers. Instead, we do have to special-case
the system workqueue when allocating TX contexts since the system
workqueue is the only place where they get freed up.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is a moderate redesign of the pending TX packet handling that
aims to eliminate potential deadlocks between the TX thread and the
system workqueue thread. The main changes are:
- TX context (bt_conn_tx) is allocated during buffer allocation, i.e.
not in the TX thread.
- We don't allocate a TX context unless there's an associated
callback. When there's no callback simple integer counters are used
for tracking.
- The TX thread is no longer responsible for TX callbacks or
scheduling of TX callbacks. Instead, the callbacks get directly
scheduled (k_work_submit) from the RX priority thread.
- CONFIG_BT_CONN_TX_MAX defaults to CONFIG_BT_L2CAP_TX_BUF_COUNT,
and in most cases wont need changing. The value now only indicates
how many pending packets with a callback are possible.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The `node` and `work` members are never used simultaneously.
Additionally k_work already has built-in support for being in a linked
list, however a union makes this change a bit cleaner.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In seg_tx_reset() in transport.c, set the busy flag to 0U
before doing adv buf unref, which will avoid sending
unnecessary adv packets in case the adv buf is already put
in the mesh adv_queue.
Fixes#20970
Signed-off-by: Maximus Liu <maximus.liu@gmail.com>
A recent patch increased struct cmd_data from 8 to 12 bytes, which is
more than the default user data for Bluetooth. We generally don't want
the core stack to require more than 8, so instead of increasing the
requirement, move the data out from the buffer into its own array with
the help of the net_buf_id() API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix race condition in bt_conn_create_le for the state of the scanner in
the Host. This leads to the host issuing a create connection command
without stopping the scanner first. This leads to command disallowed and
failing to establish connection. As well as inconsistent state in the
host which does not allow to stop the running scanner.
The race condition exists because the processing of le_adv_report
handler is done before the thread that called bt_conn_create_le was
woken up to continue after the command_complete event.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the initiator so that connection request PDU is not abort
mid-air by preemption by the overalapping first connection
event.
If the connection establishment is in progress, then the
first connection event trying to abort the initiator will
wait the connection request to be transmited completely.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable ticker job mayfly as soon as possible when
establishing connection. This is required so as to not miss
the first connection event in slow CPU like in nRF51 series.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix command status for LE Command Param Update HCI command silently
dropped by the host without notifying the application that this command
has failed. This happens because the host does not wait for the command
status event to check the status code returned.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix deadlock in Bluetooth Host. Deadlock could happen from the SMP
callbacks when calling Bluetooth API functions. This is because the
callbacks was given directly from the HCI TX thread. If the calling
API function resulted in trying to send a new HCI command it would post
this HCI command to the HCI TX thread and then wait for command complete
event. This would result in the HCI TX thread blocked waiting for the
itself to process the command.
Example:
Calling bt_conn_le_conn_param_update from pairing_complete callback.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
There are some changes that were introduced to the Nordic SW LL,
and as such, in order to maintain compatibility, propragate them
to the OpenISA SW LL as well.
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
In nRF51 which uses CONFIG_BT_CTLR_LOW_LAT, the advertising
PDU tend to get aborted in directed advertising at event slot
durations.
Dont not use continuous directed advertising event in nRF51
where CONFIG_BT_CTLR_LOW_LAT scheduling design alternative
is used. Instead close the event after each triplet of PDU
has been tx-ed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the directed advertising event interval calculation.
When CONFIG_BT_CTLR_LOW_LAT is used then prepare duration
has to be included in the event slot reservation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The HCI transport implemented by an application using the HCI raw
interface may have its own buffer headroom requirements. Currently the
available headroom gets completely determined by the selected HCI
driver. E.g. most of the time this is the native controller driver
which doesn't reserve any headroom at all.
To cover for the needs of HCI raw users, add a new Kconfig variable
for the apps to set to whatever they need. Correspondingly, use the
maximum of the HCI driver and HCI raw headroom requirements for the
buffer pool definitions and the headroom initializations.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix the implementation of slow encryption setup design
alternative to send ENC_RSP PDU before sending REJECT_IND
or REJECT_EXT_IND PDU.
Fixes#19917.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix dependency on the Host to include the PHY update procedure and the
data length update procedure. In a host-only build this feature should
be possible to select without relying on the supported features of the
controller. The host will check support using HCI command to read
attached controller features and commands supported.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix GCC9 warning "warning: taking address of packed member of
'struct sc_data' may result in an unaligned pointer value"
Issue is that the on-air structure of sc_data was re-used for the gatt
service changed data.
Added build assert because data is stored in settings, so the structure
should be the same size to be compatible.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the regression introduced as part of
commit 57d9411837 ("bluetooth: kconfig: disable some
options for openisa/RV32M1").
Also, prior to PR that introduced this regression, the Coded
PHY support selection was incorrectly depending on PHY update
support Kconfig BT_PHY_UPDATE. This was already fixed as part
the previous PR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The BT_HCI_TX_STACK_SIZE is carefully calculated from other
options. When those options change, e.g. from a menuconfig update, it
is important that the stack size is re-calculated, but it is not when
there is a prompt.
Therefore, make the prompt conditional such that the previously set
value is only used when it has been explicitly configured to be so.
Now users can still change the value through menuconfig and prj.conf,
by also enabling <option>_WITH_PROMPT, but when the value is
calculated by the defaults, it will continue to be calculated by
defaults instead of inheriting the intial value.
This is AFAIK a novel approach, but testing has shown that it gives
the users the behaviour they want, at the cost of some boilerplate of
course. This pattern can be applied to other options if it proves to
work as intended.
Alternatively one could remove the prompt, but then it would no longer
be possible to override the value through menuconfig.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
When Config client model send publish message, app_idx will
be need, however, currently code clear this value use `&`,
this will be generate error when app_idx not zero.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
This commit adds support for bluetooth in nRF52833 SoC.
Bluetooth radio related files created and added to Zephyr.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
The code was not properly taking into account CONFIG_BT_HCI_RESERVE,
which would cause buffer underruns for any HCI driver where this value
defaults to non-zero. Also, all the allocation functions use the same
pool, so we can map them simply to bt_buf_get_rx() instead of
repeating the same code.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use semaphore to synchronize lll_reset completion with HCI thread for
returning (command complete) only when all is done.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix connection update procedure to be cacheable if any other
local or remote control procedure is in progress.
Relates to commit 9c14567ce2 ("Bluetooth: controller: Fix
conn update to be cacheable").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Non-direct ISRs are supposed to take a void pointer as an argument,
unliike direct ones, which take no arguments. Since the radio ISR is not
declared as direct, the void pointer argument was missing, likely due to
a copy-paste mistake from the nordic LLL, which indeed uses a direct ISR
for the radio ISR.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
bt_conn_create_pdu_timeout() may return NULL if no buffer
is available, l2cap_chan_create_seg() does not check the
subsequent return value.
Fix possible null pointer dereference in l2cap_chan_create_seg()
and l2cap_chan_le_send().
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
An issue with DT generation where instance defines are not determinstic
generating values that collide with existing IRQs.
Fixes#20558
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move functions in order to avoid function prototype and use IS_ENABLED
instead of #if defined where possible.
Signed-off-by: François Delawarde <fnde@oticon.com>
This commits adds a BT_SETTINGS_CCC_LAZY_LOADING option to allow for
CCC settings to be loaded on demand when a peer device connects in
order to reduce memory usage.
Signed-off-by: François Delawarde <fnde@oticon.com>
Maintain Service Changed entry as long as the peer device is subscribed
to SC indications and bonded. This allows to save indication data for
disconnected peers peers when CCC settings are not available (loaded
on-demand).
Signed-off-by: François Delawarde <fnde@oticon.com>
This commit provides the DPPI configuration for the Radio
driver for nRF5340 SoC, supporting LE Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit provides the DPPI configuration for the Radio
driver for nRF5340 SoC.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Add the require #ifdef blocks in radio.c, in order to support
building for nRF53 SoC series (and, in particular, for nRF5340
CPU1 SoC).
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Conditionally include nrf5340_radio.h when building the
BLE controller for nRF5340 SoC. Introduce the header for
nrf5340.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit adds a string representation of the
nRF53 variant in bluetooth host.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit enables support in bluetooth/controller/Kconfig
for nRF53 series of SoCs.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
nRF5340 does not support a Radio TX power of 4dBm, so we
introduce a dependency for the respective Kconfig option
for TX power, so the option is never defined for nRF5340.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Define the nRF53 HW variant in include/bluetooth/hci_vs.h
and pass the define in hci_vendor.h
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
The Company ID concept is not restricted to the controller, and should
be part of the wider Bluetooth scope, so it can be used on a
controller-less device. It's used in multiple host level modules, most
notably the Bluetooth Mesh and Device Information Service.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Some Bluetooth options are currently not supported by the experimental
BLE SW LL implementation done on VEGABoard. As such, hide them from
the user altogether.
The full list of disabled config options is as follows:
- CONFIG_BT_PHY_UPDATE
- CONFIG_BT_DATA_LEN_UPDATE
- CONFIG_BT_HCI_VS
- CONFIG_BT_CTLR_LE_ENC
- CONFIG_BT_CTLR_CONN_PARAM_REQ
- CONFIG_BT_CTLR_EXT_REJ_IND
- CONFIG_BT_CTLR_SLAVE_FEAT_REQ
- CONFIG_BT_CTLR_LE_PING
- CONFIG_BT_CTLR_PRIVACY
- CONFIG_BT_CTLR_EXT_SCAN_FP
- CONFIG_BT_CTLR_CHAN_SEL_2
- CONFIG_BT_CTLR_ADV_EXT
- CONFIG_BT_CTLR_XTAL_ADVANCED
- CONFIG_BT_CTLR_SCHED_ADVANCED
- CONFIG_BT_CTLR_TIFS_HW
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
This patch updates the config files required to enable the
BLE SW defined controller to be built on RV32M1 SoCs. Only the split
version is supported.
Signed-off-by: George Stefan <george.stefan@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Ionut Ursescu <ionut.ursescu@nxp.com>
This commit takes the Nordic LLL and adapts it for RV32M1 SoCs, using
the blocks that are specific to this SoC: the GenFSK & LPTMR IP
blocks.
Signed-off-by: George Stefan <george.stefan@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Ionut Ursescu <ionut.ursescu@nxp.com>
This commit adds the HAL layer needed for the BLE controller
LL on RV32M1 SoCs on OpenISA boards. Specifically, the controller
makes use of the the GenFSK and LPTMR IP blocks.
Signed-off-by: George Stefan <george.stefan@nxp.com>
Signed-off-by: Radu Alexe <radu.alexe@nxp.com>
Signed-off-by: Ionut Ursescu <ionut.ursescu@nxp.com>
Having a pin toggle when the code reaches a certain point
is really useful for debugging; the infrastructure is already
in place for Nordic boards, so just build upon and enable the
mechanism on the Vega board as well.
Signed-off-by: David Leach <david.leach@nxp.com>
Update calls to nrfx HAL functions to reflect API changes introduced in
nrfx 2.0.0. All these functions are now called with the first parameter
pointing to the structure of registers of the relevant peripheral.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Fix Data Length Procedure to use Feature Exchange values to
send correct parameters based on whether Coded PHY is
supported by remote peer.
Relates to BT TS.5.1.1 tests:
LL/CON/MAS/BV-129-C
LL/CON/MAS/BV-130-C
LL/CON/SLA/BV-132-C
LL/CON/SLA/BV-133-C
Relates to commit fca32e41e6 ("Bluetooth: controller: Fix
DLE for remote unsupported Coded PHY").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the implementation of slow encryption setup design
alternative to send ENC_RSP PDU before sending REJECT_IND
or REJECT_EXT_IND PDU.
Fixes#19917.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix feature exchange event generation to be correctly
deferred to wait for Rx node availability for cases when
the procedure has already been performed on air.
Without this fix, remote feature request from host may not
get back a HCI event back.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Port missing implementation of the slave latency break
when there is data to be sent to peer master. Without this
initial data send from slave is delay by upto the slave
latency number of connection events.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is a port of the commit 4135fb55f1 ("Bluetooth:
controller: Fix rejected enc procedure not terminated") and
commit 4d59ef306b ("Bluetooth: controller: Check if enc
procedure is in progress").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Disallows all unauthenticated pairing attempts made by the
peer where an unauthenticated bond already exists.
This would enable cases where an attacker could copy the peer device
address to connect and start an unauthenticated pairing procedure
to replace the existing bond. Now in order to create a new bond the old
bond has to be explicitly deleted with bt_unpair.
Added option to disable this rule in order to maintain backwards
compatibility in case this behavior is accepted.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Mark the old time conversion APIs deprecated, leave compatibility
macros in place, and replace all usage with the new API.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Adds the model extension concept to the access layer, as described in
the Mesh Profile Specification, Section 2.3.6. Extensions are
implemented as a tree, using two pointers in each model:
The extends pointer points to the first extended model, and the next
pointer points to the next sibling or (if the NEXT_IS_PARENT flag is
set) the parent model in the tree, forming a cyclical "Left-child
right-sibling" (LCRS) tree. The tree root can be obtained by calling
bt_mesh_model_root_get(), and the extended models can be walked by
calling bt_mesh_model_tree_walk().
According to the Mesh Profile Specification Section 4.2.3, all models in
the same extension tree share one subscription list per element. This is
implemented by walking the model's extension tree, and pooling the
subscription lists of all models in the same element into one. If the
config server adds a subscription to a model, it may be stored in any of
the model tree's models' subscription lists. No two models in the same
extension tree and element will have duplicate groups listed. This
allows us to increase extended models' capacity for subscriptions
significantly.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix missing log_strdup when loading bt/name setting. It should be done
on every string which is not in read only memory.
Signed-off-by: François Delawarde <fnde@oticon.com>
Reduces the severity of warnings that happen from normal behavior, or
can't be prevented by the user:
- "No ID address" in hci_core.c: Reduced to an informational warning, as
this will always output with the expected usage. This isn't useful
information for 99.9% of users, and pollutes the output of all samples
using the module.
- "Composition page %u not available" in cfg_srv.c: According to the
Mesh Profile Specification section 4.4.2.2.2, the client is expected
to send page=0xff. Reduced to a debug message.
- "Connectable advertising deferred" in proxy.c: Gets logged every 10
seconds when in a Mesh Proxy connection. This is not useful
information unless the user is debugging the proxy module. Reduced to
a debug message.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
A single connections may take up to 4 buffers at the same time. Make
number of connections that support this worst-case number
configurable.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Added implementation to cache Data Length Procedure when
another control procedure is in progress.
Relates to commit 26317491e04b ("Bluetooth: controller: Add
data length procedure queueing").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix MIC failure on re-encryption procedure when responding
at the same time to peer initiated feature request.
Relates to commit 560d6ddb964c ("Bluetooth: controller: Fix
Re-encryption procedure").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix dropped ENC_REQ PDU when retransmitting, if slave was
not listening or nack-ed it.
Relates to commit 31256568a283 ("Bluetooth: controller: Fix
ENC_REQ PDU retransmission").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix control tx queue handling to correctly pause control PDU
responses during encryption setup.
Relates to commit 4b4b650174bf ("Bluetooth: controller: Fix
control tx queue handling").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to correctly cache the control procedures
initiatable by local and peer. And, fix feature exchange and
version information procedures from being disallowed by
having then as cached requests to the controller.
Relates to #15256 and commit 0dcfa3853782 ("Bluetooth:
controller: Fix cmd disallowed and collision disconnects").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix check in start encryption to disallow new encryption
setup while there is one already in progress.
Relates to commit 120eba45f81b ("Bluetooth: controller: Fix
start encryption in progress check").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix a bug where in tx data PDU enqueued, while a ctrl PDU is
deferred due to Encryption setup being in progress, is
leaked causing HCI Tx Buffer Overflow crash.
Relates to commit 671ccc4b0ee6 ("Bluetooth: controller: Fix
data PDU leak during ctrl PDU defer").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in Data Length Update procedure that caused the
connection to drop due to the implementation sending bigger
PDU before the peer has acknowledged the receipt of Length
Response PDU.
Relates to commit ffbbec7a89ca ("Bluetooth: controller: Fix
DLE during data transmission").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We use the nRFx API nrf_get_irq_number(.) to retrieve the IRQ
line of the CCM peripheral, instead of the hard coded enum
value from MDK. We do this for portability, since these
enums may be different for different nRF SoC series.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Fix conditional compilation error in building the central
only samples as all peripheral structure member accesses in
the controller where not correctly compiled out.
Regression introduced in commit 6d8b12468e ("Bluetooth:
controller: split: Refactor LLL conn structure").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use this short header style in all Kconfig files:
# <description>
# <copyright>
# <license>
...
Also change all <description>s from
# Kconfig[.extension] - Foo-related options
to just
# Foo-related options
It's clear enough that it's about Kconfig.
The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)
git ls-files '*Kconfig*' | \
xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
We make a minor simplification in the way we define
RADIO_PDU_LEN_MAX in Nordic nRF LE radio driver; as
nRF51 SoC series is the only series where the LL PDU
max length representation is limited to a 5-bit field,
we simplify the conditional preprocessor expression,
to avoid having to list all nRF5x SoCs with PDU LEN
MAX is represented by an 8-bit integer field.
In addition, we modify the preprocessor conditional,
that compiles in the CCM support for 8-bit length field,
PDUs to be an #ifndef CONFIG_SOC_SERIES_NRF51X, instead
of #ifdef CONFIG_SOC_COMPATIBLE_NRF52X; this will
simplify the expression when adding nRF53X series
support.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
GATT parameters need to remain valid while the procedure is active.
Disallow GATT commands while the procedure is active to avoid asserting.
Fixes: #20232
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add the missing initialization of master role terminate_ack
flag. This caused slave initiated remote termination as
procedure timeout.
Fixes#20135.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor the LLL connection context to move out the member
fields not accessed in LLL execution context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
C++ does not allow chaining of data members when identifying the
designator. Since the generic structure has only one member remove
the designator from its internal initializer.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Move calculation of max_tx_octets from Nordic lll_conn.c to ULL, to
allow usage by other vendors and prevent duplicate code.
Signed-off-by: Morten Priess <mtpr@oticon.com>
With sub-microsecond resolution in ticker, it is not necessary to add a
precision margin to the conn_offset. A macro is created to allow setting
the margin to something other than the hard coded 2 * EVENT_JITTER_US.
Signed-off-by: Morten Priess <mtpr@oticon.com>
TX pdu buffers may need to be augmented for fragmentation or other
purpose, depending on vendor LLL implementation. Introduced define to
add extra bytes to TX buffer size, defaulting to 0 if unused.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).
Go for the most common style:
- Indent properties with a single tab, including for choices.
Properties on choices work exactly the same syntactically as
properties on symbols, so not sure how the no-indentation thing
happened.
- Indent help texts with a tab followed by two spaces
- Put a space between 'config' and the symbol name, not a tab. This
also helps when grepping for definitions.
- Do '# A comment' instead of '#A comment'
I tweaked Kconfiglib a bit to find most of the stuff.
Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Make it possible to provision devices over advertising bearer (PB-ADV).
Many messages in the provisioning protocol are the same for provisioner
and device so much of the code could be reused by only changing when
they are expected to arrive.
This introduces to concept of local and remote device keys. The models
for cfg_cli and cfg_srv have been updated to reflect this concept. Both
the send and receive path in the transport layer have been updated to
support encrypting/decrypting with local and remote device keys.
When a node has been provisioned it is stored in bt_mesh_net.nodes. If
CONFIG_BT_SETTINGS is enabled, they are also saved to settings. If the
callback node_added in bt_mesh_prov has been set, it will be called for
every node that gets provisioned. This includes when they are retrieved
from settings.
The configuration CONFIG_BT_MESH_NODE_COUNT controls how many nodes that
can be provisioned.
Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
Remove ifdef guard around inclusion of nrf_clock_control.h in bluetooth
controller as the defines in this header are needed anyway.
Signed-off-by: Solveig Fure <solveig.fure@nordicsemi.no>
Since the LE (Enhanced) Connection Complete that comes as part of
cancelling a connection does not come through the priority rx thread in
hci_driver.c, the event class was not being calculated and cached.
Hence, calculate and cache the class whenever an event is received as
part of invoking a command.
Fixes#20110.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit adds an macro to allow UUID 128
to be written in more user-friendly form.
UUID in 128 bit form requires an array creation.
To complicate the whole thing - it requires the array to start from LSB,
so using the readable form, we have to write it down backwards.
Old way to declare example UUID 6E400001-B5A3-F393-E0A9-E50E24DCCA9E:
0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0,
0x93, 0xF3, 0xA3, 0xB5, 0x01, 0x00, 0x40, 0x6E
A form provided by this commit:
BT_UUID_128_ENCODE(0x6E400001, 0xB5A3, 0xF393, 0xE0A9, 0xE50E24DCCA9E)
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
On connection callback generated by host, application
reading the RSSI value by using HCI LE Read RSSI Command
received -127 dB as the first connection event has not
occured yet in order to measure the RSSI value.
Fix this by using the RSSI value of received advertising
PDU by the initiator, and using the RSSI value of the
received CONNECT_REQ PDU by the connectable advertiser as
the initial value at connection setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
On connection callback generated by host, application
reading the RSSI value by using HCI LE Read RSSI Command
received -127 dB as the first connection event has not
occured yet in order to measure the RSSI value.
Fix this by using the RSSI value of received advertising
PDU by the initiator, and using the RSSI value of the
received CONNECT_REQ PDU by the connectable advertiser as
the initial value at connection setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix connection update procedure to be cacheable if any other
local or remote control procedure is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
MD bit was set based on whether a memq link's next pointer
being NULL, instead the check should be that the memq has
more elements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix regression in porting slave latency, slave latency
enabled was not used, cause slave latency to be applied
before first packet being acknowledged by the master.
Regression in commit 5dff214d57 ("Bluetooth: controller:
split: Fix missing slave latency impl.").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The CONFIG_* prefix was missing, making the #ifdef always false.
Found with a script (CONFIG_BT_SETTINGS_USE_PRINTK was unused).
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Fix GATT buffer leak when bt_att_send returns error the allocated
buffer is never freed. Discovered case where the link was disconnected
during the function call, so when GATT checkd the link was still
connected, but ATT checkd the link was disconnected.
Fixes: #19889
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added in commit 1475402d41 ("Bluetooth: controller: Introduce ULL LLL
architecture"), then never used.
Found with a script.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Key overwrite feature allows to overwrite old pairing key
records when key storage is full and a new pairing request occurs,
or new keys are distributed. If enabled when key storage is full and
a keys storage slot is requested, the oldest keys added will be
removed. So new devices can be paired with no limitations and no need
to determine, which devices should be unpaired to free key storage
space explicitly in application. To enable the feature set
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y.
Oldest keys are determined by minimum value of up-counting aging
counter. If you set CONFIG_BT_KEYS_SAVE_AGING_COUNTER_ON_PAIRING=y
aging counter values will be updated each time the secure connection
is established. This might increase flash wear out if at least two
secure connections are established and shut down periodically. When
the option disabled aging counter is still updated on each new secure
connection, but not stored to flash.
Signed-off-by: Sergiy Nikolayenko <sergiy_nikolayenko@jabil.com>
Remove the
# Omit prompt to signify a "hidden" option
comments that appear on some symbols. They seem to have been copy-pasted
at random, as there are lots of promptless symbols that don't have them
(that's confusing in itself, because it might give the idea that the
ones with comments are special in some way).
I suspect those comments wouldn't have helped me much if I didn't know
Kconfig either. There's a lot more Kconfig documentation now too, e.g.
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.
Keep some comments that give more information than the symbol having no
prompt.
Also do some minor drive-by cleanup.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The 16-bit format group addresses will be stored,
but we don't store (or restore) the virtual label UUIDs,
i.e. after a power cycle the 16-bit group addresses
would be meaningless.
Fixes#19342
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
Add public API function to get the connection handle of the connection.
The connection handle is needed by applications that intend to send
vendor specific commands for a given connection.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add pre-empt timer stop when a prepare is executed so that
when the pipeline has another event queued, the firing of
the pre-empt timer does not pre-empt the just executed
prepare.
Relates to #19685.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrectly calculated ticks slots for a connection on
connection update. The reservation incorrectly included the
prepare offset.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in bt_gatt_attr_next when given an attribute that has static
allocation. The handle is then 0 and the function would always return
the attribute with handle 1.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix compilation issue when wanting to use whitelist in bluetooth
applications that does not have CONFIG_BT_CENTRAL defined.
These functions are useful even for broadcaster and observer roles.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add public API function in GATT to check if a specific connection has
subscribed to the given attribute.
Without this function the application has to keep track of which
connections has subscribed using the callbacks from BT_GATT_CCC_MANAGED
since the cfg_changed callback of the CCC doesn't carry connection
context.
The other alternative is for the application to parse the information
in the struct _bt_gatt_ccc object. Although this object has structure
information available to the application the structure is marked as
internal, so the application shouldn't rely on this definition.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix Data Length Procedure to use Feature Exchange values to
send correct parameters based on whether Coded PHY is
supported by remote peer.
Relates to BT TS.5.1.1 tests:
LL/CON/MAS/BV-129-C
LL/CON/MAS/BV-130-C
LL/CON/SLA/BV-132-C
LL/CON/SLA/BV-133-C
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for persisted Service Changed data, to fix the case of a
paired device not reconnecting before a reboot and thus not receiving
SC indication. It also enables support for GATT database being changed
during a firmware update.
Move Service Changed data outside of the CCC struct and make it
persistent by adding support for a bt/sc/... setting.
Signed-off-by: François Delawarde <fnde@oticon.com>
The Service Changed characteristic support should also work when the
GATT database has been modified after reboot (firmware update scenario)
This commit introduces a BT_GATT_SERVICE_CHANGED config option that is
independent from BT_GATT_CACHING and BT_GATT_DYNAMIC_DB.
Signed-off-by: François Delawarde <fnde@oticon.com>
Rx nodes are reserved during control procedures for
generation of HCI event on completion. Fix the allocation
and reservation in the form of a linked list per connection
context. Worst case, this list will hold one rx node for
overlapping non-instant control procedure (Data Length
Update) plus two rx node for control procedure with instant
(PHY update with Data Length Update support).
Fixes#19198.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The remote version information event needs to be processed by the
prio_recv_thread() thread in order to unblock the Host RX thread
(effectively hci_driver's recv_thread()) when it blocks waiting for a
response to a remote version information.
Add the same time gate the inclusion of the feature behind a new Kconfig
option: CONFIG_BT_REMOTE_INFO.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
In order to be able to distinguish between connection-related events
that are generated by the controller and others genrated by LL control
procedures, introduce a new class for LLCP.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Cache the result of calling hci_get_class() to avoid repeatedly invoking
it on the same data. In order to cache it we take advantage of the fact
that both radio_pdu_node_rx_hdr and node_rx_hdr are not packed
structures and they currently have a spare padding byte (between type
and handle).
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Hide the details of obtaining a pointer to the PDU data from a node_rx
structure to simplify the code.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Call LLL reset functions when calling ll_reset to avoid carrying LLL
state across HCI resets. Respective functions already exist in LLL but
had not been called from anywhere.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Unless explicitly blacklisted, the Proxy node will forward all messages
for the ALL_NODES address to the GATT proxy client.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fix missing generation of data length update HCI event when
effective tx and rx timings change due to PHY update
procedure.
Fixes BT LL TS 5.1.0 test:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI
Change]
Relates to #17097.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When ULL High and ULL Low are not at same execution priority
level, it is not necessary to disable ULL Low execution when
updating ticker using stop and start. Also, ULL Low need not
be disable inside Radio Events. This commit corrects some of
the conditional compiles.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix Kconfig conditional include of Minimum Channels Used
and Channel Selection Algorithm #2.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix ticker previous slot value with elapsed ticks value from
the time stopped ticker has expired. When a ticker is
stopped, if it was in its reserved time space, then the
currently occupied slot (was set to 0) should be the amount
of time that has elapsed in the expired and stopped ticker's
reserved time space and beyond until the stop.
This is required to ensure that any other new ticker does
not get scheduled over the stopped ticker's reserved time
space.
Fixes#19515.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Creates macros for determining model message lengths based on opcode,
payload length and MIC size. Also adds macro wrapping
NET_BUF_SIMPLE_DEFINE to serve the most common use case.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When running a ticker node as "must expire", the node would invoke the
ticker callback even when programmed with latency. As "must expire" is
intended for scheduled events which are skipped due to collision, and as
such expected by LLL, purposefully skipped events should not generate
"must expire" callbacks.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix ULL implementation that uses conditional compilation by
replacing back to use of #if defined(...) in code accessing
compiled out struct members.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for possible Tx Buffer leak during disconnection when
the buffers are in ULL context and not yet enqueued towards
LLL context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When more than one simultaneous connections are active,
transmitting data packets to peer, a termination causes
host to use the flushed pending number of completed packets
count for other active connections. This is on reception
of HCI disconnection complete event. But the controller has
not yet released any of the pending enqueued Tx buffers
which was happening after the disconnection event was
dispatched to HCI layer.
The fix here is to dispatch the disconnection complete event
from the LLL context after pending Tx buffers have been
flushed and the buffers get returned to Tx pool in the ULL
context. This way buffers are in the Tx pool before host
get to process the disconnection complete event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for possible Tx Buffer leak during disconnection when
the buffers are in HCI thread context and not yet demux-ed
and enqueued towards LLL context.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the mayfly scheduling of the Tx buffer flushing on
connection termination to be immediate (not to tailchain).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Uses net_buf_simple_clone to access the sdu of an unsegmented app packet
for re-encryption.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Local messages are already enqueued for the LPN in the tx path, and
don't have to be added again in the rx path.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Re-encrypts single-segment application messages when the network seqnum
has changed, to avoid encrypting messages with different seqnums in
network and transport. This operation is only required for unsegmented
messages, as segmented messages don't need to use the same seqnum in
network.
Reinstates the special adv data for friend messages to store the app key
index.
Fixes#19265.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Provides a utility function for getting an application key given a
subnet and an app ID. Primary use-case in friendship re-encryption.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Provides utility function for parsing network headers outside of the
network layer. The primary intended use-case is friendship.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Check if the encryption procedure is in progress when receiving
rejection for the procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue in the handling of LL_REJECT_EXT_IND packets, this would look
at the procedures that are enqueued, and not the procedure that was
being rejected. This meant that although a reject was received for the
encryption procedure, the handling for a different control procedure was
run.
This would result in the link being terminated as control procedure
timer would time out for the encryption procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Static variables and functions don't need #ifdefs if the code calling
them is using IS_ENABLED(). If IS_ENABLED() evaluates to false the
compiler will strip out all the static entities.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When aborting radio event, there is a possibility that the
packet timer would start the radio while the packet timer
is being reset. Hence, perform a second radio state disable
with packet timers uninitialised.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing radio status and configurations reset on radio
event abort. This caused under race conditions the radio
being put into active state after being aborted.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix incorrect ticker/mayfly user id used in scheduling the
abort of a radio event. Incorrect use of thread context as
the caller caused the abort function to be scheduled from
thread context while being called from ULL high context
level in reality. This could cause corruption of mayfly
scheduling.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When flash driver requests abort of radio event in unreserved
time space, resume radio events in the pipeline were not
flushed. These resumed events caused flash driver to assert
on the check whether radio was in use.
Fixed by flushing the pipeline of all radio events, resume
and also those events in pipeline with pre-empt timeout
being setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
When multiple simultaneous peripheral connections are
supported, restarting connectable advertising by host on
peripheral connection establishment failed in controller.
This prevented establishing new connections while first
connection was active.
The failure was caused by a bug in the way controller was
using quota for Rx PDU buffers. As the quota count was
release before the connection complete event rx PDU buffer
being released, the Rx PDUs needed to reserve for
connection complete event for new connectable advertising
was not available. This caused the connectable advertising
enable to fail.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in ATT reset handling, not releasing queued notification
buffers when the connection is terminated.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use entropy driver directly in bt_rand instead of stitching together
calls to sys_rand32_get to improve efficiency. The use of
sys_rand32_get could also leak timestamps into keys.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Added support for vendor specific meta data in LLL node_rx_hdr. This
enables vendors to add "footer" data to the RX PDU, for supporting
specialized BLE features.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Immediate logging is not compatible with the software-based controller
due to the additional ISR latency that it introduces. Ensure that
deferred logging is in use whenever using the software-based LL.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Handle case where:
- Peripheral sends security request after master has sent pairing
request or started encryption procedure.
This packet can be ignored, as long as the slave has not already
responded with pairing response.
- Central wants to start security after peripheral initiated security
request, return error code busy in this case
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move initiating security functionality and LTK requesting into the SMP
module so that SMP can track when the connection is in the encryption
process
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move the bt_smp_keys_check function above all usage of the function
in order to avoid prototype declaration when making the function static.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix calling bt_hex and bt_addr_le_str multiple times in the same logging
call could result in string overwritten since log_strdup is not
guaranteed to duplicate the string buffer in all logging configurations.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Added to allow vendor specific increase of user operation capacity for
ULL_HIGH, to support queuing additional ticker operations.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Enabled use of ticker must_expire feature for ensuring ADV timing
randomization, even when ADV doesn't get air-time. This reduces ADV
collisions. Not active for nRF51 platform for now.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Added support for vendor specific meta data in LLL conn object. This
enables vendors to add state data to connection, for supporting
specialized BLE slave features.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix regression introduced in refactoring of use of SWI.
Reduced use of SWI cannot be used in combination with
CONFIG_BT_CTLR_LOW_LAT as additional SWI is required
to split ticker WORKER and JOB contexts in order to
disable JOB but keep WORKER enabled.
Regression introduced in commit 78b461ae3e ("Bluetooth:
controller: Refactor use of SWI").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Calling indicate or notify on a disconnected connection object would
result in the error code ENOMEM when failing to acquire buffers instead
of the expected return code ENOTCONN.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Stop linking interface libraries against zephyr_interface. This is
cargo cult code that in practice does nothing.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
The start timestamp was supposed to signify the starting point of the
clear procedure. The code was incorrectly initializing it to the *end*
point of the procedure.
Fixes#19263
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Some modules use snprintk to format the settings keys. Unfortunately
snprintk is tied with printk which is very large for some embedded
systems.
To be able to have settings enabled without also enabling printk
support, change creation of settings key strings to use bin2hex, strlen
and strcpy instead.
A utility function to make decimal presentation of a byte value is
added as u8_to_dec in lib/os/dec.c
Add new Kconfig setting BT_SETTINGS_USE_PRINTK
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
When not using ticker compatibility mode in legacy
controller, ticker job should not be disabled inside radio
events.
Ticker compatibility mode was introduced in
commit 3a9173afe1 ("bluetooth: controller: Revised ticker
for improved conflict resolution").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This file contains redundant definitions of a bunch of nRF IRQ numbers
(not all, however) that only generates confusion, as enumeration values
provided by MDK can be used instead.
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Header files of nrfx HALs are not supposed to be included directly
but only with their names prepended with the hal/ directory (so that
an inclusion of an nrfx HAL header clearly differs from an inclusion
of an nrfx driver header).
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
The nRF52811 Radio is similar to nRF52840 and exhibits
similar Radio Timings constants. We align the LE Coded
PHY (S2) RX chain delay with that of nRF52840, which,
eventually fixes the TIFS for nRF52811. In nRF52840 we
correct the inline comment only.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
We have introduced option HAS_HW_NRF_RADIO_BLE_CODED, which
reflects that an nRF SoC has a Radio with LE Coded PHY
capabilities. We now modify all #ifdef expressions for
Coded PHY in the nRF controller port, removing SOC_NRF52840
and adding this new option instead. This allows to build
an nRF controller with Coded PHY support for SOCs other
than nRF52840.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Nordic nRF52811 SoC has a 2.4GHx Radio which supports
LE Coded PHY, so we add the option to build a BLE
Controller for nRF52811 platforms with LE Coded PHY
support.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Enable possibility to configure time a slave will wait until
start of connection parameters update procedure after BT connection
is established.
Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
This moves check_perm code under GAT and make use of it to check if CCC
write permission can be attended by the connection security level or if
it needs to be increased.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support to set different permissions to CCCD so security can
be checked when enabling notification which conforms to:
BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part G page 2360:
'3.3.3.3 Client Characteristic Configuration
Authentication and authorization may be required by the server to
write the configuration descriptor.'
In addition to that also ensure that notification are not re-enabled
until the proper security level is reached to conform to the following
statement:
'10.3.1.1 Handling of GATT indications and notifications
A client “requests” a server to send indications and notifications
by appropriately configuring the server via a Client Characteristic
Configuration Descriptor. Since the configuration is persistent
across a disconnection and reconnection, security requirements must
be checked against the configuration upon a reconnection before
sending indications or notifications. When a server reconnects to a
client to send an indication or notification for which security is
required, the server shall initiate or request encryption with the
client prior to sending an indication or notification. If the client
does not have an LTK indicating that the client has lost the bond,
enabling encryption will fail.'
Fixes#17983
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add GATT initializer macro for GATT CCC and allow the
BT_GATT_CCC_MANAGED to accept an already initialized CCC user data.
This allows the application to specify the storage location of the CCC
user data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
CCC storaged is no longer declared separetly so check if ccc->cfg
matches with sc_ccc_cfg no longer works so instead use the cfg_changed
callback and match against sc_ccc_cfg_changed.
Fixes#19267
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When compiling a sample like a beacon, none of the `if defined()`
statements in the switch case are actually compiled in, so the compiler
complains of an orphan mem_release();break; sequence.
Add a type that we know will always be compiled in in order to avoid
this issue.
Relates to commit 76bfea7cf9 ("Bluetooth: controller: Ensure that a
`case` statement is present").
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This makes the identity initialization consistent and actually catches
a few branches where it may not have properly happened.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Make it possible to initiate new connections from within the
disconnect callback. This wasn't completely trivial since there was
connection cleanup done through deferred action using the CONN_CLEANUP
flag.
This patch moves the disconnected callbacks to be run after all
cleanup is done. We can't directly do this in the TX thread, since
that's internal, so we instead take advantage of the deferred work
support and do it using the update_work callback. Since the same
cleanup is needed also for BR/EDR connections the work definition is
moved from the LE-specific struct to the generic struct bt_conn.
A valid bt_conn object in disconnected state is a likely indication of
a connection reference leak, so there's a new BT_WARN() for this case
in bt_conn_create_le().
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Adds additional model callback that gets called on node_reset. Will also
erase any user data when this happens.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds user data file in the model settings, allowing each model instance
to store some application specific data without having to reinvent the
settings path encoding for model element/ID combinations. Exposes the
settings_handler interface in the model callback structure and adds a
data store function.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Adds a structure of callbacks for each model instance. This allows for
more flexible model implementations, that can interact with the Mesh
stack without going through the application.
For now, only an init callback is added, replacing the init mechanism in
the foundation models. The init callback does not provide the primary
flag that used to be in the foundation model callbacks, but replaces
this with an inline function in access.h.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
When both central and peripheral are supported, one each Rx
node will be needed by connectable advertising and the
initiator to generate connection complete, hence
conditionally set the count.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Refactor to abstract the use of software interrupts in nRF5
Series.
Also, reduce the number of SWI used when interrupt priority
level configured is same for ULL High and ULL Low contexts.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit completes the refactoring of radio.c, so it
calls abstract functions for PPI handling for LE Coded
PHY (e.g. enable, disable channels, or configure endpoints),
which, then, call the platform-specific functions for PPI
handling. The abstract functions are simple wrappers,
implemented in radio_nrf5_ppi.h, conditionally, if we
build the controller with support for LE Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Make the definitions of LE Coded PHY-specific macros
and inline functions conditional, i.e. only if we
actually build the controller with support for LE
Coded PHY.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit refactors radio.c, so it calls abstract functions
for PPI handling (e.g. enable, disable channels, or configure
endpoints), which, then, call the platform-specific functions
for PPI handling. The abstract functions are simple wrappers,
implemented in radio_nrf5_ppi.h.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit defines generic macros for the software interrupt
(SWI) IRQ lines that are used for LLL and ULL LOW interrupts.
This is done for both the cases of the legacy and new (split)
controller architectures. In addition, it abstracts some of
the functionality around software-IRQ signals, to generic
functions, which have platform-specific implementations.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Stores friend queue packets unencrypted, removing any out-of-order
issues caused by seqnum allocation. Also moves as much of the metadata
storage as possible into the packet, allowing us to free up some bytes
of net_buf user data for friend packets.
Fixes#18488
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Makes a define for the seqzero 13-bit mask in transport, and exposes it
in the header for use in the friend module.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Convert how we get the various chosen properties like "zephyr,console"
to use the new kconfig functions like dt_chosen_to_label.
Because of how kconfig parses things we define a set of variables of the
form DT_CHOSEN_Z_<PROP> since comma's are parsed as field seperators in
macros.
This conversion allows us to remove code in gen_defines.py for the
following chosen properties:
zephyr,console
zephyr,shell-uart
zephyr,bt-uart
zephyr,uart-pipe
zephyr,bt-mon-uart
zephyr,uart-mcumgr
zephyr,bt-c2h-uart
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Changed documentation in Bluetooth Controller
Kconfig for BT_CTLR_ASSERT_HANDLER
Signed-off-by: Kristoffer Rist Skøien <kristoffer.skoien@nordicsemi.no>
Host shall ignore the unknown ATT PDU that has Command Flag set.
Fixes regression introduced in 3b271b8455.
Fixes: GATT/SR/UNS/BI-02-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit adds an explicit inclusion of toolchain.h from pdu.h.
The endianness preprocessor definitions (__BYTE_ORDER__,
__ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__) are used by pdu.h;
these being not defined can easily go unnoticed and cause unexpected
behaviours, as detailed in PR #18922.
toolchain.h ensures that these preprocessor definitions are defined and
*must* be included in a file that uses these definitions.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
The bt_mesh_fixed_group_match() function is intended to match the
various well-known group addresses, however it was never updated when
Proxy support was added.
Fixes#19015
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
As element addresses are sequential, there's no need for iterating
through the elements to find the one matching a unicast address.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Added ll_rx_link_inc_quota to allow vendor to manipulate
mem_link_rx.quota_pdu when cleaning up nodes via ull_vendor.h.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix a bug where in tx data PDU enqueued, while a ctrl PDU is
deferred due to Encryption setup being in progress, is
leaked causing HCI Tx Buffer Overflow crash.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix check in start encryption to disallow new encryption
setup while there is one already in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix MIC failure on re-encryption procedure when responding
at the same time to peer initiated feature request.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix control tx queue handling to correctly pause control PDU
responses during encryption setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added implementation to cache Data Length Procedure when
another control procedure is in progress.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Workaround, defer peer initiated encryption while local
initiated procedure with instant is not complete. Peer
master has sent CONN_UPDATE_IND in response to
CONN_PARAM_REQ, and also has initiated a Encryption Setup
thereafter. In this case, avoid corruption of the connection
update context by deferring the Encryption Setup.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to correctly cache the control procedures
initiatable by local and peer. And, fix feature exchange and
version information procedures from being disallowed by
having then as cached requests to the controller.
Relates to #15256.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add iterator function to iterate over all connection objects.
Make type a bitmap so that it can be used as a bitmask to select which
conns to receive foreach callback.
Use foreach function internally where possible.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allows the user to pass a provisioning input complete callback to the
provisioning module, letting the application stop displaying its output
OOB value when the other party finishes their OOB input.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Made BT_HCI_TX_STACK_SIZE configurable and added BT_HCI_ECC_STACK_SIZE.
These changes are necessary to allow vendors to adjust for other
achitectures.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Rework the BT_ASSERT infrastructure with the following changes:
- Transition from LOG() macros to printk()
- Allow the BT_ASSERT() macro to map directly to stancard __ASSERT()
- Allow printing of the assert reason to be disabled
- Switch from k_oops() to k_panic() configurable
There are 2 reasons for using printk() instead of LOG():
- BT_ERR uses deferred logging by default, which is problematic with
ASSERTs
- The __ASSERT() macro in Zephyr uses printk()
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Fix issue when checking if SMP pairing procedure is allowed to use the
SMP debug keys. This check did not consider the case where the keys
pointer was assigned, but did not contain a valid LTK key.
This resulted in being unable to pair with debug keys without an
existing bond.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix shell build dependencies, subsys/bluetooth/controller is only added
for CONFIG_BT_LL_SW_SPLIT or CONFIG_BT_LL_SW_LEGACY.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The return code of set_random_address is not always handled. This could
lead to connection using the wrong Identity address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
nrf_timer.h and nrf_ppi.h are included by including
radio_nrf5.h, so we do not need to include them in
radio.c.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
Remove incorrect LL_ASSERT check in Lower Link Layer that
checked for invalid connection handle on reception of PDU.
The assert is not needed as PDUs can be received until the
Upper Link Layer is aware of the acknowledgement of the
terminate ind PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add workaround for advertising data issue in the internal bluetooth
controller. The advertising data must be set after advertising
parameters in order to successfully update the advertising data after
an directed advertiser has been active.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix handling of Rx-ed PDU on termination, do not process
Rx-ed control PDUs and release the PDU buffer back to the
free pool.
Without this fix, Rx-ed control PDU was responded with a
Tx PDU, which did not get acknowledged or released.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Endianness bug fix in bt_uuid_create function.
Replaced bt_uuid_create_le with bt_uuid_create which
handles both UUID from air and internal varaiable.
Fixed bug with endianess in case of big endian targets.
Signed-off-by: Akshatha Harishchandra <akhr@oticon.com>
When an opcode doesn't have a handle that doesn't mean it is unknown
just that it will not be handle as it could have been disabled.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
SMP shall be considered internal TX notify callbacks so they are
allowed to be run from TX thread context like the others.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When CONFIG_BT_GATT_CLIENT is not set att_op_get_type would return
unkown operation instead of properly return the opcode.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since bt_l2cap_create_pdu can return NULL when used under syswq context
the code should always check its result, this also changes the timeout
to have a specific value (RTX maximum timeout) so signalling PDUs still
wait for a buffer to become available.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In certain cases there could be no buffer available which may lead to
NULL being returned by bt_l2cap_create_pdu so instead use
bt_l2cap_create_pdu_timeout to wait with a specific timeout.
Note that this should also ensure the SMP will not be waiting for a
buffer when the remote might have timed out already.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds bt_conn_create_pdu_timeout function which can be used
to provide a timeout when allocating a buffer.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix reset of Encryption Procedure state on reception of
REJECT_IND and REJECT_EXT_IND.
This is a regression in commit 79cb615770 ("Bluetooth:
controller: split: Port Enc setup to be queueable")
Relates to #18578.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to handle data packet
enqueue being pause on Encryption Request be done early in
the ULL when enqueueing packets towards LLL.
Fixes#18645.
Signed-off-by: Vinayak Kariappa Chettimada <vinayak.chettimada@gmail.com>
Rename AUTHENTICATION, to AUTH, since this is a well established short
form of the word.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename bt_conn_security to bt_conn_set_security, this makes the API
naming more consistent.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Rename security level enum, using level and number instead of low,
medium, high and fips.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
A security vulnerability in the Bluetooth BR/EDR Bluetooth Core
specification versions 1.0 through 5.1 has been identified as
CVE-2019-9506. The Bluetooth BR/EDR encryption key negotiation
protocol is vulnerable to packet injection that could allow an
unauthenticated user to decrease the size of the entropy of the
encryption key, potentially causing information disclosure and/or
escalation of privileges via adjacent access. There is not currently
any knowledge of this being exploited.
From Core spec erratum 11838:
A device shall enforce an encryption key with at least 128-bit
equivalent strength for all services that require Security Mode 4,
Level 4. For all other services that require encryption, a device
should enforce an encryption key with at least 56-bit equivalent
strength, irrespective of whether the remote device supports Secure
Simple Pairing.
After encryption has been enabled, the Host should check the
encryption key size using either the HCI_Read_Encryption_Key_Size
command (see [Vol 2] Part E, Section 7.5.7) or a vendor-specific
method.
Fixes#18658
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case sufficient security level wasn't reached the error propagation
was missing, which could lead to incorrect state transitions when
update_sec_level_br() returns. Return true/false and make sure to
abort any further operations in case the update fails.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The storage for the public key is pub_key in hci_core.c.
When the public key event is generated the public key is copied into
this buffer, but the pointer to the event storage of the key is given
in the public key ready callback (bt_smp_pkey_ready).
SMP expects that it is safe to assign a global pointer to this variable.
In smp_init bt_pub_key_get is used to get the pointer to the public key.
In both cases SMP assigns the le_sc_pub_key to the pointer given.
This creates an issue when bt_smp_pkey_ready callback occurs after
smp_init during pairing procedure, SMP will then have a pointer to an
event buffer that has been released and contains invalid data.
Fixes: #18580
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Give the security changed callback when the peripheral initiated
security request and peer attempted to encrypt the connection but no LTK
match was found.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Make sure that a new pairing procedure with an existing bond does not
result in a security with weaker security properties.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add option to force the host to initiate pairing procedure even if the
host has encryption keys for the peer.
This option can be used to pair with a bonded peer that has deleted its
bonding information without deleting the keys. If new pairing results
in weaker keys the pairing will be aborted.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add security error to security_changed callback. Call this callback when
security has failed and provide current security level and error.
Reason for failure can be.
- Pairing procedure failed, pairing aborted before link encryption.
- Link encrypt procedure failed
- Link key refresh procedure failed.
Fix missing bt_conn_unref on encryption key refresh with error status.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Stop the pairing procedure in the request phase if no storage is
available for the keys. This avoids the pairing procedure from failing
during the key distribution phase.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Proved the Authentication callback for pairing failed and pairing
complete when BR/EDR SSP is complete.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow SMP debug keys to behave in the same way as normal keys, in order
to debug with encryption and Bluetooth sniffer the exact way it behaves
when not using debug keys.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix reset of Encryption Procedure state on reception of
REJECT_IND and REJECT_EXT_IND.
This is a regression in commit 79cb615770 ("Bluetooth:
controller: split: Port Enc setup to be queueable")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The period_start timestamp wasn't getting properly initialized in the
case that retransmission was not being used. In the case of
retransmission the timestamp was getting updated in the mod_publish()
delayed work callback. Add a send_start callback and do the
initialization there, since this covers both the retransmission as
well as the no-retransmission cases.
Fixes#17820
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Post Tx pool corruption fix, clean up code and add comments
explaining the use of Tx node next field used to indicate
the Tx node's allocation from Control or Data pool.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the Tx FIFO, queue and pool corruption due to missing
release of link object to Tx link pool and hence missing
reset of the per connection initially allocated Tx link
free pointer.
The bug caused Tx PDUs and associated memory to be lost
leading to missing L2CAP segment transmissions. With lost
control PDU buffers, ULL would stall processing Done events
also leading to controller asserts.
Fixes#18546.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This removes the necessity of registering the storage for CCC and make
it part of the declaration itself.
Fixes#18547
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support to provide an UUID to bt_gatt_indicate so API user
don't need to hardcode the attribute offset by hand.
Fixes#18572
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The code for checking space in the Friend queue was faulty in the case
that we receive a message with more segments than the configured Friend
Queue size. This is not an issue for the default configuration but
still a possible one. Move the check for exceeding Friend Queue Size
to the per-LPN function, so that bt_mesh_friend_queue_has_space()
iterates all LPNs before delivering its verdict. This allows us to
return success in case no LPN matched (which is how the code was
intended to work).
Fixes#18522
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
According to Mesh Profile Specification 1.0.1 Figure 5.17, the
unprovisioned device should send its confirmation value after the
provisioner sends theirs. Previously, the confirmation value would be
sent immediately after OOB input complete. Now it first waits for the
input data, then from confirmation from the provisioner before sending
the confirmation.
Fixes: #18178.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Qualification test case MESH/NODE/FRND/FN/BV-08-C requires that we do
not store more messages than the reported Friend Queue size. The
implementation was so far opportunistic and stored more if it could
(it would later discard if necessary to make sure all queues can store
the required amount). The spec also requires the queues to have new
messages overwrite old ones (in the style of a circular buffer), so we
have to keep track of which buffers are part of the same segmented
message (so we discard all buffers belonging to the same message).
To pass the test case, add APIs to check for space in the Friend
queue, and track the number of buffers for each incoming segmented
message.
Fixes#18090
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The bt_mesh_trans_resend() function had no users, and had in fact not
even a prototype in a header file. Just remove it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When sent solely to the Friend Queue the send callbacks were not
getting called for unsegmented messages.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This fixes the dead code when parsing Find Information response since
the index counter can never be zero, instead it checks there are any
attributes found and if there nothing don't proceed with discovering
which was the original intent of the now dead code.
Fixes#18384
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Due to conditional compile path ending in LL_ASSERT(0), the compiler
sees code following the assert as using uninitialized variables.
Signed-off-by: Morten Priess <mtpr@oticon.com>
When the database changes and a client becomes change unware it should
also clear the out of sync flag as the following request should return
an error:
Core Spec 5.1 | Vol 3, Part G, 2.5.2.1 Robust Caching:
'The error response is sent only once after the client becomes
change-unaware, unless the client disconnects or the database changes
again before the client becomes change-aware in which case the error
response shall be sent again.'
Fixes: #18183
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes the following crash:
ASSERTION FAIL [0] @ ZEPHYR_BASE/subsys/logging/log_core.c:180
argument 2 in log message "%s: Stored CCCs for %s (%s)"
missing log_strdup().
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fix issue unable to connect to bonded peer when host resolution is used
either because the controller does not support privacy, or the
controller resolving list was exceeded.
In this case we need to use the RPA from the advertising report
directly, there is a small chance of the peer cycling the RPA here, in
which case the connection might be unsuccessful.
Bug introduced here: 45da629b24Fixes: #18306
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Disable Advertising Extensions by default, since they are not really
operational and they take RAM.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When compiling a sample like a beacon, none of the `if defined()`
statements in the switch case are actually compiled in, so the compiler
complains of an orphan mem_release();break; sequence.
Add a type that we know will always be compiled in in order to avoid
this issue.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
When in Low Power mode an LPN may receive messages sent by nodes other
than its friend during its brief receive window. These messages get
rejected by the transport layer. At some point in the future the LPN
will receive these messages from its friend, however they will have
already been added to the network message cache earlier.
When the transport layer rejects a message due to it being received from
a non-friend node while in Low Power mode it must be removed from the
network message cache so that it can be correctly received from its
friend in the future.
Fixes#17809
Signed-off-by: Rich Barlow <rich@bennellick.com>
The commit 1c7b668804 tried to fix
resending segments to the GATT bearer, however it got the buffer
refernce counting wrong. The bt_mesh_net_resend() function doesn't
own a reference to the buffer, i.e. it's not responsible for unrefing
it. E.g. bt_mesh_adv_send() takes its own reference.
What was missing however was the handling of the callbacks. Use the
recently introduced send_cb_finalize() helper to make sure they're
called.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There are several places that require the send callbacks to be called
immediately. Reduce the code a bit by introducing a helper for this.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The RPA timer should always be running, even with privacy supported by
the controller. In order to select an IRK to generate the private
the controller is instructed by provided an identity address.
If we want to advertise privately without providing an identity address
the host has to set the private address.
Fixes: #18150
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Mesh Profile Specification states in section 3.10.5 IV Update
procedure: "The IV Update procedure is initiated by any node that is a
member of a primary subnet", meaning if we're not on the primary
subnet we should not try to initiate the procedure.
Additionally this fixes initiating IV Update in all cases where the
sequence is updated, by putting the code into bt_mesh_next_seq().
Fixes#17977
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This branch is inherited from old code that used to start the timer as
soon as a message was queued for transmission rather than when it was
actually transmitted (the case today). It'll also cause a race in case
the publication goes over the GATT layer since the "sent" callback
happens synchronously in that case.
Fixes#17821
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The GATT bearer is a reliable one so there should theoretically never
be a need to resend segments. If however for some strange reason the
proxy client doesn't immediately ack all segments we should do the
resending on the GATT bearer, rather than sending them over
advertising.
Fixes#17907
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was incorrectly bailing out with "return 0" rather than
continue. Also, it was incorrectly making a reference to
tx->seg[seg_o] since when a PDU goes through the friend queue we don't
use the usual retransmission mechanism.
Fixes: #17932
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In case a queued buffer is canceled before sending we have to unref
it, since that's what adv_send() would do as well.
Fixes#17936Fixes#18013
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Mesh Profile 3.6.7.2 Publishing Heartbeat messages:
"
Triggered publishing of Heartbeat messages is enabled by
the Heartbeat Publication Features state (see Section 4.2.17.5):
...
- If the Low Power bit is set to 1, a Heartbeat message shall be
published when the node establishes or loses Friendship (see Section
3.6.6.1).
"
Fixes#18194
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When sending heartbeat messages triggered by feature changes the code
was trying to look up the configured publication subnet, in an
apparent attempt to figure out if publication is enabled or not. A
more appropriate way is to check for the heartbeat publication
destination address, and since we have a helper function this can be
done in a single place.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The heartbeat is a transport layer feature, so move it to transport.c.
This also opens the way to properly fix Friendship-established/lost
triggering for LPN role.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix missing interval min copy in bt_conn_set_param_le. Application is
unable to override BT_GAP_INIT_CONN_INT_MIN for interval_min.
Fixes: #17789
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.
Background from issue #17997:
Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.
Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.
See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Fix the pipeline prepare-resume implementation to correctly
handle multiple continuous events that request resume on
being pre-empted.
Symptoms of the bug being, when having continuous scanning,
and an active peripheral if a directed advertising is
started the peripheral event are not scheduled causing link
supervision timeout.
This is fixed by not having an enqueued resume event
prepared if there is an enqueued new non-resume event in the
pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase pipeline size to accommodate probable multiple
prepare for directed advertising events, with reserved time
which are shorter than prepare duration, being enqueued.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Increase the event start overhead time to accommodate for
processing time for dequeueing pipeline in Upper Link Layer.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Reduce the maximum number of pending event done elements by
decoupling it from the maximum pipeline elements.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This is safer now that bt_conn_create_pdu can return NULL when using
syswq which can prevent things like signalling of L2CAP and ATT layers.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Since TX complete notification are dispatched with syswq blocking on it
can completely deadlock Bluetooth so this attempt to make it safe by
return -ENOMEM if that the current thread happens to be the syswq
thread.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add shell commands to add and remove devices from the shell.
Add commands and options to use whitelist for advertising, scanning,
and creating connections.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add whitelist support in the bluetooth host.
Supported features:
- Advertising with whitelist on scan requests, connect request ,or both
- Scanning with whitelist
- Creating connections using a whitelist (Auto connection procedure).
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Allow Security level HIGH and FIPS to be initiated when we have received
OOB data for the remote device. The security property of MITM is allowed
if out of band authentication data is available.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Update bluetooth help text to include FIPS level in help text.
Also validate input range for the different connection types
Bluetooth security level for LE is from 1-4, while BR/EDR is 0-3
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Authentication using OOB data uses the on-air device addresses used
during connection setup. So we need to check against the on-air
addresses in the info object to see if we have correct OOB data.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix issue with registering authentication callback handlers failing
without notifying the user of the shell.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Use the src and dst naming to refer to the identity addresses of the
connection. Keep the device addresses used during connections but rename
them to local and remote instead.
Update documentation to be more descriptive.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
subsys/bluetooth/host/Kconfig.gatt is already sourced within an
'if BT_CONN' in subsys/bluetooth/host/Kconfig.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Fix the mandatory and optional parameter counts for the
directed adv shell command definition. Also, refactor the
command for consistency.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix assert in the RPA timeout when no resolving entry exists in the
resolving list, and the advertiser was requested to use a local IRK
to generate it's own address.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
If no callback for oob data request is registered, or the user decided
to abort authentication during OOB data request, we should return the
error code for no OOB data available to indicate that the user does not
have the correct OOB, or no OOB interface at all.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix kernel crash if bluetooth authentication handlers has not been
registered. The bt_auth object is then NULL, this dereference caused a
call to an invalid function pointer.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The code was already rejecting the key, however that rejection
happened only after we had already sent our public key as response,
which got interpreted as acceptance by the tester (PTS).
This fixes issue that d4fd267086a56c270a793114e7575afae9a9befa
supposed to fix. The problem is bt_dh_key_gen is async.
Local public key cannot be sent from the same context
the bt_dh_key_gen is called because we don't know yet
if remote key is valid.
Fixes MESH/NODE/PROV/BI-13-C.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Fixed error 'The int symbol BT_DISCARDABLE_BUF_COUNT is being evaluated
in a logical context somewhere'.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
subsys/bluetooth/host/Kconfig.l2cap is already sourced within an
'if BT_CONN' in subsys/bluetooth/host/Kconfig, so BT_DEBUG_L2CAP does
not need a 'depends on BT_CONN'.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Find by type does only accept a UUID with the same length as the UUID
which is stored in the internal list. If a UUID is stored in the short
16 bit format then a request with 128 bit UUID will fail.
Add support for the missing formats.
Signed-off-by: Kim Sekkelund <ksek@oticon.com>
Changed ticker behavior to resolve conflicts in ticker_worker instead of
in ticker_job. This allows better real-time slot allocation, as well as
allowing callbacks even if ticker node doesn't get air-time (for audio
stream housekeeping). A priority property now also allows prioritizing
one ticker node over others.
Compatibility mode enables lagacy ticker behavior if needed.
Signed-off-by: Morten Priess <mtpr@oticon.com>
Fix an issue in the SMP identity distribution where the IRK for the
default identity was always distributed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix an issue with enhanced connection complete event raised by the
advertiser role. The advertiser reported that it has resolved the
the identity address of the peer, even when the peer is connecting
using it's identity address.
The host will not have the correct on-air address type i.e public.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bug introduced by: 45da629b24
Mistakenly set the own address type to the destination address type.
Also this uses the RPA_OR_RANDOM in case local IRKs exists in the
controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The 'registered' flag was not cleared when 'gatt metrics off'
was called so that one was unable to register the service again.
Remove 'registered' variable that is actually not needed as there
is no tracking if service is already registered in similar
cmd_register_test_svc command. If the service is already registered,
the host will log an error.
Fixes: #17882
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
The init addr should contain the on-air address used to establish the
connection. The dst address contains either the current RPA of the
unknown peer, or the identity address after identity information has
been exchanged.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Error codes are listed in header files and in the core spec as hex
values. Always print them in hex in debug for easier error code
checking.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix an issue where the generated identity was not permanently stored.
This resulted in being unable to reconnect after bonding when using
privacy, since a new local IRK was generated on reboot.
When settings is enabled the application is responsible for loading
identities and possible creating its own identities.
When settings_load is called and no identities has been created or found
in persistent storage a new identity will be created.
Since bt init has not been finalized bt_id_create will not make a call
to bt_settings_save_id. So we need to make sure that this identity will
be stored.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Logging module requires strings to be duplicated using log_strdup.
Enabling CONFIG_BT_DEBUG_KEYS caused runtime assertions in the logging
module.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Core 5.1, Vol 3, Part F, 3.3.1
"Multi-octet fields within the GATT profile shall be sent least
significant octet first (little-endian) with the exception of the
Characteristic Value field. The Characteristic Value and any fields
within it shall be little-endian unless otherwise defined in the
specification which defines the characteristic."
Fixes: GATT/SR/GAS/BV-02-C
Fixes: #17857
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
Changes related to Bluetooth TSE 11068.
This is done because the current test suite does not issue
an LE Enable Address Resolution command anymore in RPA
generation tests. Makes sense now that the Bluetooth SIG has
agreed to completely decouple address resolution from
generation.
Fixes BT LL TS 5.1.0 test:
LL/SEC/ADV/BV-03-C [Privacy - Non-connectable Undirected
Advertising, Resolvable Private Address]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The call to bt_conn_security will send a SMP security request for
peripheral, and for central it will initiate LL encryption.
A call to bt_conn_security with no IO capabilities but authenticated
keys has been distributed, would succeed on central side, but fail on
peripheral side with error code -22.
The keys could have been either:
- Preprogrammed
- IO capabilities may have changed.
- OOB bonding may been used.
Fix so that Peripheral can send a security request if the bond
information is already established.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The original creates a pointer to a compiler-generated temporary that is
destroyed when the scope is exited. The pointer is stored in a structure
defined in an enclosing scope and is invalid by the point it's used.
The fix holds the structure in a variable with the same lifetime as
the pointer.
Signed-off-by: Findlay Feng <i@fengch.me>
Fix the pipeline prepare or resume dequeue loop from
overflow. Fixes premature exit of dequeue of done FIFO
which caused the pipeline to overflow due to previously
placed done is not dequeued correctly and next event not
being put back into the pipeline.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This introduces a new flag (BT_GATT_SUBSCRIBE_WRITE_PENDING) which is
set when a write operation requires canceling before the parameters can
be reused.
Fixes#17534
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds a dummy cancel request which is used instead of NULL when
clearing and outstanding request thus prevent new request to take
place before a response is received while allowing the original request
to be reused.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Set advertisers state flags so that previous advertise params does not
affect the current advertiser state.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Enable use of settings system in controller and introduce settings for
company_id and subversion_number.
Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
Make the Upper and Lower Link Layer split architecture
implementation of the controller as the default when
building Zephyr Bluetooth Low Energy controller support
in applications.
Noticeable missing feature (porting) in comparison to old
architecture implementation is, Advanced scheduling of
connection events.
The missing features will subsequently be submitted
upstream.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Rename the controller Kconfig option BT_LL_SW to
BT_LL_SW_LEGACY in preparation towards switch to new Link
Layer implementation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Conditional compile the use of Rx Pool used to dispatch ULL
context generated messages towards LL thread context, which
is presently only used in connections.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the conditional compile of Data Length Update event
generation on PHY Update Procedure when Data Length
Extensions are not supported.
The regression was introduced in
commit 70a89876d0 ("Bluetooth: controller: Fix missing
data length update event")
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added a fix to handle L2CAP start frame with payload length
of zero which otherwise sent zero length data start PDU on
air.
Relates to #17046.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fixed a bug related to missing reset of packet timing
restriction variable.
Fixes BT LL TS 5.1.0 test:
LL/CON/SLA/BV-55-C [Initiating PHY Update Procedure - Packet
Time Restrictions, LE Coded]
Related to #17097.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix bug in Data Length Update procedure that caused the
connection to drop due to the implementation sending bigger
PDU before the peer has acknowledged the receipt of Length
Response PDU.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable the Fast Encryption design and connection RSSI
measurement when CONFIG_BT_HCI_RAW is selected.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the controller implementation to perform connection
event length reservation based on the completed Data Length
Update and/or PHY Update Procedure.
This fix with avoid states/roles from stepping on each
others event length. Connection would have supervision timed
out or have stalled data transmissions due to insufficient
reserved air time.
Relates to #15171.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing generation of data length update HCI event when
effective tx and rx timings change due to PHY update
procedure.
Fixes BT LL TS 5.1.0 test:
LL/CON/MAS/BV-52-C [Master Receiving Data, LE Coded, CI
Change]
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Bluetooth address parsing has been duplicated across the different
sub-shell files. Also missing parsing of identity/resolved addresses.
Move parsing of string close to parsing to string for a symmetrical API
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Move duplicate hex2bin and add bin2hex function so that application can
use the functions and avoid code duplication.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the implementation of initiator to use correct anchor
tick and remainder microseconds when sending out CONNECT_REQ
PDU and then to scheduling the first connection event. This
is a fix when initiator is in continuous scan.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The bt clear command accepts either 'all' or a bluetooth address.
If it is an LE address then type is also needed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix bug in the ported code of the connection update, when
the slave events are skipped due to other overlapping state
or role the connection update at the instant used wrong
latency calculations. This lead to connection disconnection.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Submit GATT database hash as a delayed work to prevent it being run
twice if we register dynamic services.
Signed-off-by: François Delawarde <fnde@oticon.com>
Having this option disabled, MITM flag state can be controlled by
bt_conn_security state. This option is enabled by default to not
change the current implementation behavior.
Related to SM/MAS/SCPK/BV-01-C.
Fixes#17463
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit moves the BLE GATT heart rate service from
samples/bluetooth/gatt to subsys/bluetooth/services and adds a Kconfig
entry to enable and configure the service.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit moves the BLE GATT Battery service
from /samples/bluetooth/gatt to /subsys/bluetooth/services and
adds a Kconfig entry to enable and configure the service;
when enabled, it will register itself automatically.
Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Handle optional argument UUID in bt_gatt_discover with type
DISCOVER_DESCRIPTOR, bt_uuid_cmp doesn't check for NULL pointer.
On system with MMU (nrf52_bsim) this can result in segfault.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix assert in controller checking ticker_id_prepare = 0 when
a scanner and connection are active, and the connection is
skipping events in order to resize Rx buffers.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Move the reset of ticker_id_prepare variable to the early
return in event_connection_prepare function.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
We've already got GATT services in subsys/bluetooth/services so
subsys/bluetooth/mesh is a more natural place. Aditionally this aims
to fix the Kconfig dependencies to be able to use mesh together with
BT_CUSTOM (i.e. a custom, potentially non-HCI, host stack).
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Two sections are needed: bt_l2cap_fixed_chan and bt_l2cap_br_fixed_chan.
However the second one cannot be created using #define as the
preprocessor will expand it to the first before compilation happens,
sending bt_l2cap_br_fixed_chan instances in the wrong section.
This fixes commit 4e8ddfd640 ("Bluetooth: L2CAP: Make use of
Z_STRUCT_SECTION_ITERABLE").
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Port the implementation that does radio event abort due to
ISR latencies. The implementation measures if the ISR could
not meet the hard real time deadline and closes the event
early.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Added interface to get Advertiser and Scanner instance
handle for use in Lower Link Layer module.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix an issue in the gatt_register routine where removing a service and
adding it again would cause the database to have non-ascending
orderdered handles numbers and lead to an incomplete service discovery.
Fix: Go through the database and look for a place where to insert
the new service.
Signed-off-by: Arthur Crepin-Leblond <arthur.crepin@proglove.de>
Renames the "Blueooth Controller Assertion Handler" to "Application
Defined Assertion Handler" to better fit the purpose of the Kconfig
option.
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
Introduce a separate buffer pool for events which the HCI driver
considers discardable. Examples of such events could be e.g.
Advertising Reports. The benefit of having such a pool means that the
if there is a heavy inflow of such events it will not cause the
allocation for other critical events to block and may even eliminate
deadlocks in some cases.
Also update all mesh samples not to specify explicit RX buffer counts
anymore. Instead, create appropriate defaults in Kconfig so that we
only need to override this in the app for cases like the bbc:microbit
with limited memory.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This event is a priority one, so it's not safe to have it use the RX
buffer pool which may be depleted due to non-priority events (e.g.
advertising events). Since the event is consumed synchronously it's
safe to have a single-buffer pool for it. Also introduce a new
bt_buf_get_evt() API for HCI drivers to simplify the driver-side code,
this effectively also deprecates bt_buf_get_cmd_complete() which now
has no in-tree HCI driver users anymore.
Fixes#16864
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>