Commit graph

9523 commits

Author SHA1 Message Date
Morten Priess
3617128cf4 Bluetooth: controller: Add vendor operations to TICKER_USER_LLL_OPS
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>
2021-01-15 11:37:23 -05:00
Lingao Meng
c262239680 Bluetooth: Mesh: Fix friendship counter increasing order
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>
2021-01-15 11:36:48 -05:00
Vinayak Kariappa Chettimada
21d9bb6e51 Bluetooth: controller: Remove BIT64 redundant definition
Remove the redundant definition of BIT64 macro.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-15 11:21:25 -05:00
Pavel Vasilyev
561a8e4f0e Bluetooth: Mesh: Break up mesh settings
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>
2021-01-14 16:38:50 +02:00
Piotr Pryga
472febfe69 Bluetooth: host: direction: Add public API to set CTE TX enable for adv
Add public function to set Constant Tone Extension transmission
enabled or disabled for periodic advertising.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-14 15:26:32 +01:00
Piotr Pryga
0a09441e47 Bluetooth: host: Rename and make non-static HCI cmd state update
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>
2021-01-14 15:26:32 +01:00
Piotr Pryga
f36b7a8732 Bluetooth: controller: hci: Add HCI_Set_Connectionless_CTE_TX_Enable cmd
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>
2021-01-14 15:26:32 +01:00
Piotr Pryga
9d711d6e09 Bluetooth: host: direction: Fix compilation error
Fix compilation error caused by missing header files.
Reorganized order of header files include.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-14 15:26:32 +01:00
Piotr Pryga
43a1304e9a Bluetooth: controller: df: Config help corrction correction
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>
2021-01-14 15:26:32 +01:00
Michał Narajowski
419d2aa85b Bluetooth: Mesh: Fix heartbeat subscription tests
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>
2021-01-12 06:49:38 -05:00
chao an
1027b0e4f0 Bluetooth: host: add support for unregister scanner callback
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>
2021-01-12 12:31:00 +02:00
chao.an
bc7e86b9ec Bluetooth: host: Unified namespace of hci event
BT_HCI_EV_LE_REMOTE_FEAT_COMPLETE ->
BT_HCI_EVT_LE_REMOTE_FEAT_COMPLETE

Signed-off-by: chao an <anchao@xiaomi.com>
2021-01-12 12:30:11 +02:00
Morten Priess
907a8377b3 Bluetooth: controller: Fixed conn_meta bitflag misalignment
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>
2021-01-10 15:40:05 -05:00
Vinayak Kariappa Chettimada
e0ff2d0957 Bluetooth: controller: Reserve link Rx buffer to ISO sync
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>
2021-01-10 15:39:42 -05:00
Aurora Sletnes Bjørlo
717687806c bluetooth: controller: radio: Add guards on TXPOWER
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>
2021-01-10 15:39:22 -05:00
Vasilyev, Pavel
d593af30db Bluetooth: Mesh: Fix typo when deleting app key in CDB
This commit sets `net_idx` to `BT_MESH_KEY_UNUSED` when deleting app key in
cdb.

Signed-off-by: Vasilyev, Pavel <pavel.vasilyev@nordicsemi.no>
2021-01-08 13:16:46 +02:00
Vinayak Kariappa Chettimada
8a5154d71c Bluetooth: controller: Add missing initialization of ISO sync
Add missing initialization of ISO sync context to be
established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 18:02:34 +01:00
Vinayak Kariappa Chettimada
c709d4f85f Bluetooth: controller: Rename periodic adv rx enable flag
Rename the Periodic Advertising Rx Enable flag from
is_enabled to is_rx_enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 18:01:44 +01:00
Vinayak Kariappa Chettimada
44492c8324 Bluetooth: controller: Rename supported ISO Sets Kconfig
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>
2021-01-07 18:01:10 +01:00
Vinayak Kariappa Chettimada
32a79dd7e3 Bluetooth: controller: Fix AUX_CONNECT_RSP PDU buffer size
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>
2021-01-07 18:00:35 +01:00
Vinayak Kariappa Chettimada
5d3d9b7522 Bluetooth: controller: Internal documentation of node rx count
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>
2021-01-07 17:59:59 +01:00
Vinayak Kariappa Chettimada
bc71d39d81 Bluetooth: controller: Fix free Rx PDU queue starvation
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>
2021-01-07 17:59:59 +01:00
Vinayak Kariappa Chettimada
2a99857cad Bluetooth: controller: Refactor PA/LNA PPI configuration
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>
2021-01-07 17:59:20 +01:00
Vinayak Kariappa Chettimada
5470444e6a Bluetooth: controller: PA/LNA use NRF_P0/P1 define
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>
2021-01-07 17:58:24 +01:00
Vinayak Kariappa Chettimada
e51295a309 Bluetooth: controller: Fix missing GPIOTE channel disable
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>
2021-01-07 17:58:01 +01:00
Vinayak Kariappa Chettimada
f265b178c3 Bluetooth: controller: Fix regression in PA/LNA support
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>
2021-01-07 17:57:29 +01:00
Vinayak Kariappa Chettimada
e14be4477a Bluetooth: controller: Fix missing call to radio_setup interface
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>
2021-01-07 17:56:57 +01:00
Vinayak Kariappa Chettimada
108d431902 Bluetooth: controller: nRF52811: Errata Id 164 not applicable
nRF52840 Engineering A Errata Id 164 is not applicable to
nRF52811 SoC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-07 17:56:03 +01:00
Joakim Andersson
577cd82b0d Bluetooth: host: Fix crash when receiving response after ATT timeout
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>
2021-01-07 13:51:18 +01:00
Vinayak Kariappa Chettimada
db5270bd93 Bluetooth: controller: nRF53x: SWI mapping should use SOC define
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>
2021-01-06 16:25:52 +01:00
Piotr Pryga
1c493b4a77 Bluetooth: host: direction: Add public API to set CTE TX params for adv.
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>
2021-01-05 09:38:53 +01:00
Piotr Pryga
098f767298 Bluetooth: host: Add set connectionless CTE TX params wrapper function
Add implementation of a wrapper for HCI_LE_Set_-
Connectionless_CTE_Transmit_Parameters send command.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-05 09:38:53 +01:00
Piotr Pryga
9bfc095d4a Bluetooth: host: Add DF to initalization sequence
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>
2021-01-05 09:38:53 +01:00
Vinayak Kariappa Chettimada
0a23b1248f Bluetooth: controller: Remove is_enabled flag for BIS events
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>
2021-01-04 16:27:58 +01:00
Vinayak Kariappa Chettimada
30740b4397 Bluetooth: controller: Move lll_sync_iso.h common to all vendors
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>
2021-01-04 16:27:58 +01:00
Luiz Augusto von Dentz
64cc5a3746 Bluetooth: GATT: Fix BT_GATT_AUTO_DISCOVER_CCC
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>
2020-12-27 18:20:28 +01:00
Andrzej Kaczmarek
f8c8cac714 Bluetooth: controller: Use PHY_xxx symbols consistently
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>
2020-12-20 13:04:13 -05:00
Emil Gydesen
9a3f863637 Bluetooth: host: Assert conn ref counter on unref
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>
2020-12-20 13:02:44 -05:00
Emil Gydesen
47aa17bb5c Bluetooth: controller: Implements ULL Sync ISO ticker
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>
2020-12-20 13:36:50 +01:00
Emil Gydesen
9d4d6d06a0 Bluetooth: controller: Implements BIG sync commands in the ULL
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>
2020-12-20 13:36:50 +01:00
Vinayak Kariappa Chettimada
e603b9d59e Bluetooth: controller: Adjust PPI used for nRF51x and nRF52x
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>
2020-12-20 13:36:09 +01:00
Morten Priess
467fd155a8 Bluetooth: controller: Make must-expire runtime configurable
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>
2020-12-20 13:35:58 +01:00
Joakim Andersson
cc470a2bd6 Bluetooth: host: Use smaller alignment for slab.
The slabs in ATT are using a slab alignment of 16, when only
4 is required on 32-bit.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-18 10:29:59 +01:00
Joakim Andersson
adeca565f8 Bluetooth: host: Use uintptr when checking for valid index
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>
2020-12-17 17:16:34 +02:00
Joakim Andersson
9fee4d7ffd Bluetooth: SMP: Improve logging of unspecified pairing failure
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>
2020-12-17 12:42:22 +01:00
Joakim Andersson
a01a619480 Bluetooth: SMP: Check return value of bt_rand
Add check of bt_rand return value and do not proceed in case of error.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-17 12:42:22 +01:00
Joakim Andersson
d138790826 Bluetooth: SMP: Fix parallel pairing needing DHKey at the same time
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>
2020-12-17 12:42:22 +01:00
Joakim Andersson
ad96ae0398 Bluetooth: SMP: Set allowed commands before sending the SMP packet
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>
2020-12-17 12:42:22 +01:00
Joakim Andersson
d04e19731e Bluetooth: host: Improve multiple DHKey handling
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>
2020-12-17 12:42:22 +01:00
Andrzej Kaczmarek
07bb612875 Bluetooth: controller: Call lll_adv_aux initialization funcs
lll_adv_aux_init and lll_adv_aux_reset were not called anywhere.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00