Commit graph

9523 commits

Author SHA1 Message Date
Piotr Pryga
4a13b8b4c7 Bluetooth: controller: ULL: Add sending of number of CTEs in per adv chain
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>
2021-08-07 20:50:03 -04:00
Piotr Pryga
616ebcf8f7 Bluetooth: controller: ULL: ull_adv_sync_hdr_set_clear update PDU in place
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>
2021-08-07 20:50:03 -04:00
Piotr Pryga
151a32db7a Bluetooth: controller: ULL: Make API for per adv sync PDU change global
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>
2021-08-07 20:50:03 -04:00
Piotr Pryga
2d71b2d82c Bluetooth: controller: LLL: Add CTE confing for per. adv. chain TX
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>
2021-08-07 20:50:03 -04:00
Piotr Pryga
8a5a88ce96 Bluetooth: controller: LLL: Add peek extra_data related with lll_adv_sync
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>
2021-08-07 20:50:03 -04:00
Piotr Pryga
6cc97e7a32 Bluetooth: controller: df: Add const to antenna patterns pointer
Add const qualifier in radio API related with setting antenna
switch pattern.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
2dad068545 Bluetooth: controller: radio: Add back2back TX switch after PHYEND event
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>
2021-08-07 20:50:03 -04:00
Piotr Pryga
1e2ad5a590 Bluetooth: controller: Make per. adv. PDUs count related to max CTE num
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>
2021-08-07 20:50:03 -04:00
Piotr Pryga
f01b77f3c9 Bluetooth: controller: Add conf max num of PDUs with CTE in per adv chain
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>
2021-08-07 20:50:03 -04:00
Emil Gydesen
57fc354f6c Bluetooth: ISO: Fix iso channels not disconnecting properly
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>
2021-08-05 15:08:06 -04:00
Emil Gydesen
b1f4764f4f Bluetooth: ISO: Add clearer error message on iso accept failure
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>
2021-08-05 15:08:06 -04:00
Emil Gydesen
7f3a085a7a Bluetooth: shell: ISO change to use shell_print instead of printk
shell_print is preffered for the shell as printk may appear
in a different terminal.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-08-05 15:08:06 -04:00
Lingao Meng
524d2e2b27 Bluetooth: audio: Fix -Wunused-function
Fix -Wunused-function

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-05 16:07:44 +02:00
Lingao Meng
e0dfdd6723 Bluetooth: Fix -Wunused-but-set-variable
Fix -Wunused-but-set-variable

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-05 16:07:44 +02:00
Lingao Meng
4cbe77dbdb Bluetooth: Fix -Wunused-variable
Fix unused variable but defined, this will be
appear when dbg disabled.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-05 16:07:44 +02:00
Vinayak Kariappa Chettimada
239a663c40 Bluetooth: Controller: Fix tag name should be unique violation
Fix tag name should be unique violation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-05 11:45:41 +02:00
Vinayak Kariappa Chettimada
c091e267ff Bluetooth: Controller: Resume primary PDU scanning after Auxiliary PDU
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>
2021-08-05 11:45:41 +02:00
Vinayak Kariappa Chettimada
9b4e1849f5 Bluetooth: Controller: Flush Aux PDUs being in LLL scheduling
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>
2021-08-05 11:45:41 +02:00
Vinayak Kariappa Chettimada
3ce651fe7b Bluetooth: controller: Extended scanning with LLL scheduling
Extended scanning with LLL scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-05 11:45:41 +02:00
Andrzej Kaczmarek
51173f9f40 Bluetooth: controller: Add ull_scan_aux_is_valid_get helper
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>
2021-08-05 11:45:41 +02:00
Andrzej Kaczmarek
c9fca499b2 Bluetooth: controller: Fix isr_done_cleanup
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>
2021-08-05 11:45:41 +02:00
Lingao Meng
c85640edf3 Bluetooth: adv: Fix wrong assert
Fixes wrong ASSERT usage cause abnormal failed.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-05 11:25:39 +02:00
Joakim Andersson
2a2523ce74 Bluetooth: host: Fix bug in adv timeout for limited advertiser
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>
2021-08-05 11:25:11 +02:00
Vinayak Kariappa Chettimada
4661ae3c21 Bluetooth: Controller: Fix Extended Scanning Address Resolution
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>
2021-08-04 10:37:08 +02:00
Vinayak Kariappa Chettimada
fcc15f713a Bluetooth: Controller: Fix resolving index from being overwritten
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>
2021-08-04 10:36:46 +02:00
Joakim Andersson
72bd8da095 Bluetooth: host: Fix key distribution not calling pairing complete
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>
2021-08-03 18:47:01 +02:00
Lingao Meng
3911ce8d40 Bluetooth: Mesh: Mark as internal function
Marks funcs:`show_faults` as internal, avoiding conflict.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-03 10:21:16 -04:00
Michał Narajowski
e167ca6539 Bluetooth: Mesh: Refactor Mesh Model Extensions
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>
2021-08-03 10:20:52 -04:00
Piotr Pryga
ca26e7a3f7 Bluetooth: controller: Fix wrong CTE type in per adv report
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>
2021-08-03 13:58:51 +02:00
Piotr Pryga
fc7ead4b9f Bluetooth: host: df: Fix compilation warning in direction.c
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>
2021-08-03 13:58:02 +02:00
Abe Kohandel
dcaac1e7af bluetooth: ots: Make OTS Object Reads use POSIX parameter types
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>
2021-08-03 13:16:51 +02:00
Piotr Pryga
2863bbcdd7 Bluetooth: controller: Add init and reset of LLL per adv in lll_adv.c
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>
2021-08-03 13:16:10 +02:00
Piotr Pryga
162691c918 Bluetooth: controller: Add reset of per adv for HCI_Reset command
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>
2021-08-03 13:16:10 +02:00
Abe Kohandel
997bbcb000 bluetooth: ots: Add object write procedure
Add the ability to perform an OTS Write Procedure with only Patch
support configuration.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2021-07-31 23:16:11 -04:00
Saleh Mehdikhani
36f934113f Bluetooth: Host: direction: Fixing the bug to support 1us slot
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>
2021-07-30 19:54:42 -04:00
Lingao Meng
9042f76b8b Bluetooth: Mesh: Add pointer conversion for prov->uri
`prov_sd[0].data` and `prov->uri` have different point type.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-29 10:59:20 -04:00
Lingao Meng
baf0d58a67 Bluetooth: Mesh: Fix wrong use log_strdup
Should use `bt_hex` instead of `log_strdup`.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-29 10:59:20 -04:00
Lingao Meng
cce921dad5 Bluetooth: Fix Wrong format when debug
Fix wformat build warning

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-29 10:59:20 -04:00
Krzysztof Kopyściński
779e67c0fc Bluetooth: host: disallow MPS decrease for multiple CIDs in Reconf Req
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>
2021-07-29 15:21:10 +02:00
Krzysztof Kopyściński
4f80fe814c Bluetooth: host: introduce timeout in limited advertising
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>
2021-07-29 15:20:54 +02:00
Lingao Meng
55145beee0 Bluetooth: Mesh: Add more explain for ADV_STACK_SIZE
Add explanatory statement for config `BT_MESH_ADV_STACK_SIZE`

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-28 15:44:34 +02:00
Lingao Meng
5fe698286e Bluetooth: Mesh: Add kconfig for thread priority
Add Kconfig `CONFIG_BT_MESH_ADV_PRIO`.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-28 15:44:34 +02:00
Vinayak Kariappa Chettimada
97adf875b8 Bluetooth: Controller: Flush pending Tx PDUs before PHY update
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>
2021-07-28 11:38:42 +02:00
Vinayak Kariappa Chettimada
ad1edf1cc4 Bluetooth: Controller: Advanced scheduling for Extended Initiator
Implement the advanced scheduling for Extended Initiator to
group central connections established to Extended
Advertisements.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-28 11:38:29 +02:00
Vinayak Kariappa Chettimada
d8f4759c5f Bluetooth: Controller: Fail on multiple PHY use in PHY_UPDATE_IND
Disconnect connection if peer central uses multiple PHYs in
PHY_UPDATE_IND PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-28 11:38:15 +02:00
Vinayak Kariappa Chettimada
9a1b5c68f5 Bluetooth: Controller: Explicitly check previous auxiliary PDU for ADI
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>
2021-07-26 15:30:04 +02:00
Vinayak Kariappa Chettimada
ad8f4d368a Bluetooth: Controller: Remember last used DID for each SID
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>
2021-07-26 15:30:04 +02:00
Vinayak Kariappa Chettimada
a919e1ba40 Bluetooth: Controller: Make Extended Advertising DID unique
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>
2021-07-26 15:30:04 +02:00
Vinayak Kariappa Chettimada
d19476c3c2 Bluetooth: Controller: Fix corrupt AD data after directed advertising
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>
2021-07-26 15:29:55 +02:00
Vinayak Kariappa Chettimada
4e6357e549 Bluetooth: Controller: Resolve AdvA in AUX_CONNECT_RSP PDU
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>
2021-07-26 15:29:41 +02:00