Commit graph

9523 commits

Author SHA1 Message Date
Emil Gydesen
96dfad0eef Bluetooth: host: Add ISO support for num_completed_packets event
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>
2021-08-25 18:06:09 -04:00
Emil Gydesen
24226b0135 Bluetooth: Host: Move bt_conn_create_pdu* out of ACL group
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>
2021-08-25 18:06:09 -04:00
Johann Fischer
9ad610d1a7 bluetooth: remove Kconfig options CONFIG_BT_*_ON_DEV_NAME
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>
2021-08-25 18:05:17 -04:00
Piotr Pryga
0395f46126 Bluetooth: controller: hci: Add missing DF conn-less cmds to supp list
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>
2021-08-25 18:02:39 -04:00
Vinayak Kariappa Chettimada
e4ed1d32be Bluetooth: Controller: Schedule LLL prepare before scan train code
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>
2021-08-24 07:35:59 -04:00
Vinayak Kariappa Chettimada
7d1404a717 Bluetooth: Controller: Fix return value for unassigned aux context
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>
2021-08-24 07:35:24 -04:00
Vinayak Kariappa Chettimada
01393382d7 Bluetooth: Controller: Update AD Data PDU allocation configurability
Update the calculation for configurable amount of shared
PDUs across advertising sets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-24 07:33:48 -04:00
Vinayak Kariappa Chettimada
41bb453948 Bluetooth: Controller: Keep the default AD Data length to 31 octets
Keep the default AD Data length to Bluetooth Specification
defined minimum of 31 octets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-24 07:33:48 -04:00
Emil Gydesen
76091850c5 Bluetooth: sample: Update iso_connected_benchmark to use new ISO API
Update the sample to use the new ISO API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-08-24 07:29:11 -04:00
Emil Gydesen
7037b11e1a Bluetooth: shell: Update ISO shell to new API
Update the ISO shell commands to use the new
ISO API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-08-24 07:29:11 -04:00
Emil Gydesen
c47dae8c6d Bluetooth: ISO: Update connected ISO API
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>
2021-08-24 07:29:11 -04:00
Vinayak Kariappa Chettimada
c74fe1f009 Bluetooth: Controller: Fix scan window resume after extended scan
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>
2021-08-24 07:27:35 -04:00
Johann Fischer
c3313c1dc1 bluetooth: monitor: remove CONFIG_UART_CONSOLE_ON_DEV_NAME
Replace with DT_LABEL(DT_CHOSEN(zephyr_console)).

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-23 18:53:47 -04:00
Vinayak Kariappa Chettimada
14fbcffbc7 Bluetooth: Controller: Simplify clearing of extended scan response data
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>
2021-08-23 08:23:36 -04:00
Vinayak Kariappa Chettimada
c0d569d233 Bluetooth: Controller: Check for invalid PHY in Aux Ptr
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>
2021-08-23 08:22:32 -04:00
Vinayak Kariappa Chettimada
95e0f63bbd Bluetooth: Controller: Use one bit for Extended Scan Filter Directed
Use one bit to represent the Extended Scan Filter Directed
Advertising Report.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-23 08:22:10 -04:00
Mark Wang
c11ef74605 Bluetooth: SDP: add one API bt_sdp_get_add_proto_param
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>
2021-08-23 15:11:24 +03:00
Joakim Andersson
d76bba4b5e Bluetooth: host: Device name handling of invalid length
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>
2021-08-20 18:56:38 -04:00
Joakim Andersson
8672976120 Bluetooth: shell: Fix adv-data command hex data input
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>
2021-08-20 18:56:38 -04:00
Rubin Gerritsen
1aa3a77130 bluetooth: smp: Fix duplicate pairing_failed callback
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>
2021-08-20 18:55:33 -04:00
Emil Gydesen
aa9a2aac0c Bluetooth: host: Remove reset of conn handle on disconnect
(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>
2021-08-20 12:54:39 +02:00
Krzysztof Kopyściński
852656d1ff Bluetooth: host: initialise mps_reduced to false in ecred reconf req
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>
2021-08-20 12:54:29 +02:00
Vinayak Kariappa Chettimada
80f382e51e Bluetooth: Controller: Fix sync of primary and auxiliary adv terminate
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>
2021-08-20 12:49:43 +02:00
Vinayak Kariappa Chettimada
462ac6dcd1 Bluetooth: Controller: Minor refactor of extra done type set function
Minor refactor of extra done memory get and type set
functions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-20 12:49:43 +02:00
Vinayak Kariappa Chettimada
76d7f6364e Bluetooth: Controller: Correctly initialize max events and duration
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>
2021-08-20 12:49:43 +02:00
Trond Einar Snekvik
69fcaaa592 Bluetooth: Mesh: Use separate net_bufs for bt_mesh_app_decrypt in friend
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>
2021-08-20 12:49:28 +02:00
Joakim Andersson
ce2fdd84ff Bluetooth: host: Allow app to set scannable when not providing scan data
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>
2021-08-20 12:49:06 +02:00
Joakim Andersson
750782ba46 Bluetooth: host: Fix non-connectable advertiser configured as scannable
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>
2021-08-20 12:49:06 +02:00
Joakim Andersson
5ab34fab13 Bluetooth: host: Fail create ext scannable advertiser with name in AD
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>
2021-08-20 12:49:06 +02:00
Joakim Andersson
2ad039d9d0 Bluetooth: shell: Add option to set name in advertising data
Add advertising option to set the force advertising name in advertising
data option.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-20 12:49:06 +02:00
Lingao Meng
4a8a1577ef Bluetooth: Mesh: Redefine callback registration
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>
2021-08-20 06:28:12 -04:00
Asbjørn Sæbø
252a9bad9a Bluetooth: ots: Fix output formatting
Fix output formatting after changes in
https://github.com/zephyrproject-rtos/zephyr/pull/36653/
causes Twister build fails in pending le-audio code.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2021-08-19 10:20:37 -04:00
Omkar Kulkarni
f868ca3497 bluetooth: mesh: Fix IVU duration counter update
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>
2021-08-19 10:19:43 -04:00
Pavel Vasilyev
0e9d668970 Bluetooth: Mesh: Add API to discard subscription in vendor model
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>
2021-08-19 10:19:02 -04:00
Pavel Vasilyev
538f97f737 Bluetooth: Mesh: Clarify name length in bt_mesh_model_data_store
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>
2021-08-19 10:19:02 -04:00
Emil Gydesen
03c3a31be9 Bluetooth: Iso: Change set CIG parameters fail to unref
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>
2021-08-19 10:18:28 -04:00
Emil Gydesen
393436c773 Bluetooth: ISO: Add log if cleanup fails to remove the CIG
Add an warning log message if the CIG failed to be removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-08-19 10:18:28 -04:00
Emil Gydesen
a0cec00807 Bluetooth: ISO: Add iso channel state check for unbind
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>
2021-08-19 10:18:28 -04:00
Piotr Pryga
a947d5aa24 Bluetooth: controller: Extend HCI TX cmd buf size for CTE rx param cmd
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>
2021-08-18 20:11:10 -04:00
Piotr Pryga
0b07a7812e Bluetooth: controller: add functions to enable CTE req LLCP
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>
2021-08-18 20:11:10 -04:00
Piotr Pryga
8382d6e5be Bluetooth: controller: Add CTE Rx params struct to lll_conn declaration
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>
2021-08-18 20:11:10 -04:00
Piotr Pryga
52ec547894 Bluetooth: controller: Add handling for HCI set CTE Rx parameters
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>
2021-08-18 20:11:10 -04:00
Piotr Pryga
ee71d95011 Bluetooth: controller: Add CTE Rx params struct to ll_conn declaration
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>
2021-08-18 20:11:10 -04:00
Piotr Pryga
3a9d809d0d Bluetooth: controller: add struct for conf of CTE rx in conn mode
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>
2021-08-18 20:11:10 -04:00
Piotr Pryga
d159646e9b Bluetooth: controller: ull_df.c code re-arrange
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>
2021-08-18 20:11:10 -04:00
Piotr Pryga
6a848ec91b Bluetooth: controller: Add LE features for CTE req and resp
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>
2021-08-18 20:11:10 -04:00
Piotr Pryga
2aa3fbb579 Bluetooth: controller: Add option to enable conn. CTE request feature
Add Kconfig option that enables BT v5.1 Connection CTE request feature.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-18 20:11:10 -04:00
Martí Bolívar
041099f67c Bluetooth: Controller: clean up nRF DFE
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>
2021-08-17 17:52:43 -04:00
Vinayak Kariappa Chettimada
2cbc97d047 Bluetooth: Controller: Extended Active Scanning review rework
Miscellaneous review rework changes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00
Vinayak Kariappa Chettimada
58b07c719a Bluetooth: Controller: Explicitly cast to void memq_dequeue calls
Explicitly cast to void memq_dequeue function calls.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 17:36:19 +02:00