Commit graph

9523 commits

Author SHA1 Message Date
Andrzej Kaczmarek
07ebf3d06d Bluetooth: controller: Release resources on failed AUX_CONNECT_RSP
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>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
3fc74be7e7 Bluetooth: controller: Allow to simply release node allocated in LLL
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>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
98d7adc30d Bluetooth: controller: Stop aux after connected
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>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
88a8fc1d5e Bluetooth: controller: Make global helper to get aux handle
Just make local function a global one, we need this in other files
as well.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
01448bf378 Bluetooth: controller: Fix phy initialization when enabling adv
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>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
dd102e61c0 Bluetooth: controller: Add support for connectable ext adv
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>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
2709c2c79a Bluetooth: controller: Initialize conn for connectable ext adv
Connection structs need to be initialized when advertising is enabled
on connectable extended advertising instance.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
f5d3a637a4 Bluetooth: controller: Use proper phy when initializing slave conn
Connection created from extended advertising instance uses the same phy
as on secondary channels.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
384b64508c Bluetooth: controller: Use proper channel sel algorithm
Connections created from extended advertising instance always use CSA2.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
6c8c97a26e Bluetooth: controller: Use proper transmitWindowDelay for slave
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>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
68723274da Bluetooth: controller: Use decoded AdvA/TargetA for conn ind helper
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>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
ffb320504c Bluetooth: controller: Add public helper to process connection ind
We will use the same code for auxes so let's make it public.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Vinayak Kariappa Chettimada
a46d090328 Bluetooth: controller: Release blocking LF clock request
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>
2020-12-17 11:24:19 +01:00
Vinayak Kariappa Chettimada
da18345b08 Bluetooth: controller: nRF5x: Fix lll LF clock wait
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>
2020-12-17 11:24:19 +01:00
Vinayak Kariappa Chettimada
35c397fc46 Bluetooth: controller: Remove unused lll scan struct member
Remove the unused LLL scan context struct member,
conn_ticks_slot.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-17 11:23:36 +01:00
Vinayak Kariappa Chettimada
6f22ac2851 Bluetooth: controller: Cleanup included header files
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>
2020-12-17 11:23:18 +01:00
Vinayak Kariappa Chettimada
17c006ce4a Bluetooth: controller: Add extended scan filter duplicates
Added implementation to filter out duplicates in generated
extended advertising reports.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-17 11:23:03 +01:00
Lingao Meng
5b11c053ef Bluetooth: Mesh: Fixes Friend Queue store message
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>
2020-12-16 14:27:12 +01:00
Joakim Andersson
39e14580e9 Bluetooth: controller: Validate disconnect reason in disconnect command
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>
2020-12-15 11:20:34 +01:00
Joakim Andersson
9205fe0a3a Bluetooth: host: Return error code if disconnect has invalid parameters
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>
2020-12-15 11:20:34 +01:00
Vinayak Kariappa Chettimada
62cb9aedc4 Bluetooth: controller: Clean up direction finding Kconfig
Simplify selection of direction finding related Kconfig.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-14 11:23:26 +01:00
Piotr Pryga
1283b136e7 Bluetooth: controller: ull_df: Fix compilation warnings
Remove unused functions to fix compilation warninigs.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-12-14 11:23:26 +01:00
Piotr Pryga
307ac64374 Bluetooth: controller: Add set connectionless CTE TX parameters
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>
2020-12-14 11:23:26 +01:00
Trond Einar Snekvik
2e3de6c5f8 Bluetooth: Mesh: LPN non-low power establishment set state
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>
2020-12-14 11:21:41 +01:00
Trond Einar Snekvik
040b027e00 Bluetooth: Mesh: Check LPN credentials before establishment
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>
2020-12-14 11:21:41 +01:00
Trond Einar Snekvik
a0bb080f8a Bluetooth: Mesh: Set LPN credentials on friend_req
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>
2020-12-14 11:21:41 +01:00
Jonathan Rico
21311c8bc5 Bluetooth: host: Ignore reserved SMP PDUs
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>
2020-12-14 11:21:24 +01:00
Jonathan Rico
98584a4bbc Bluetooth: host: Add keypress notification SMP handler
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>
2020-12-14 11:21:24 +01:00
Joakim Andersson
a7fd4eab5c drivers: counters: Fix TIMER0 and RTC0 with Bluetooth controller
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>
2020-12-13 19:25:49 -05:00
Pavel Vasilyev
347a1ab19f Bluetooth: Mesh: Make access packet sizes defines public
This commit makes BT_MESH_*_SDU_MAX macros public so that applications
can use them.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2020-12-12 14:15:47 +02:00
Pavel Vasilyev
12bcf652e6 Bluetooth: Mesh: Make address defines public
This commit makes BT_MESH_ADDR_IS_* macros public so that applications
can use them.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2020-12-12 14:15:47 +02:00
Lingao Meng
f105455ebe Bluetooth: Mesh: Fix overflow of ivu_duration value
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>
2020-12-11 09:03:05 -05:00
Trond Einar Snekvik
040b14366e Bluetooth: Mesh: Pull all function calls out of the K_MSEC macro
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>
2020-12-10 12:15:04 -05:00
Kamil Piszczek
ac88b86179 bluetooth: services: add tps service
Added Transmit Power Service implementation.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2020-12-10 13:33:12 +01:00
Kamil Piszczek
fd8d03bd8b bluetooth: conn: add api for getting tx power level
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>
2020-12-10 13:33:12 +01:00
Rubin Gerritsen
a8bbe4d1db bluetooth: host: Disallow directed adv options on undirected adv
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>
2020-12-10 14:32:51 +02:00
Lingao Meng
aea9adfc89 Bluetooth: Mesh: Fixes LPN poll timeout gradually grow
`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>
2020-12-10 14:04:19 +02:00
Thomas Ebert Hansen
f0f25cfc32 Bluetooth: controller: Fix CUI/CPR lock during TO
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>
2020-12-10 12:58:35 +01:00
Lingao Meng
779fd135f3 Bluetooth: Mesh: Fixes wrong app_key_idx parameters
`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>
2020-12-10 12:58:20 +01:00
Trond Einar Snekvik
81bf99145a Bluetooth: Mesh: Extended advertising support
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>
2020-12-09 12:57:59 +02:00
Andy Ross
ea7ffbde7d subsys/bluetooth: Add missing stdint.h include
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>
2020-12-07 21:50:14 -05:00
Andy Ross
0c15627cc1 lib: Remove sys_mem_pool implementation
This has been replaced by sys_heap now and all dependencies are gone.
Remove.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-12-07 21:50:14 -05:00
Vinayak Kariappa Chettimada
3f7b4d2877 Bluetooth: controller: Fix cond. compile of conn window offset calc
Fix missing conditional compilation of connection window
offset calculations.

Regression introduced in commit 467173a56646 ("Bluetooth:
controller: Fix incorrect initiator window offset").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-07 15:25:39 -05:00
Andrzej Kaczmarek
f0352500b3 Bluetoth: controller: Fix memory corruption in RPA refresh
memcpy() could overwrite memory adjacent to "pdu" due to invalid
copy size.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-07 13:59:55 +01:00
Morten Priess
392e044548 Bluetooth: controller: Fix ull_conn LSTO for must_expire
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>
2020-12-07 13:36:17 +01:00
Vinayak Kariappa Chettimada
b19747ee11 Bluetooth: controller: Fix incorrect initiator window offset
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>
2020-12-07 11:41:37 +01:00
Vinayak Kariappa Chettimada
0db7e5afb8 Bluetooth: controller: Fix corruption of footer auto-variable
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>
2020-12-07 11:41:29 +01:00
Vinayak Kariappa Chettimada
e6911bc06c Bluetooth: controller: Fix Coded PHY S2 S8 coding use
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>
2020-12-04 23:08:51 -05:00
Andrzej Kaczmarek
e9cece87bb Bluetooth: controller: Add definitions for AdvA and TargetA offsets
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>
2020-12-04 23:08:15 -05:00
Andrzej Kaczmarek
99226e1e95 Bluetooth: controller: Add ext_hdr member to pdu_adv_com_ext_adv
'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>
2020-12-04 23:08:15 -05:00