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>