Commit graph

9523 commits

Author SHA1 Message Date
Rubin Gerritsen
727ea49029 Bluetooth: Fix default event size when periodic adv sync is enabled
Periodic Advertising reports can be up to 255.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-01-13 10:35:13 +01:00
Morten Priess
7c89f1fe9f Bluetooth: controller: Support for separate ISO RX data path
Provides interface, data structures and demuxing capability for ISO RX
PDU allocation and transport from LLL to HCI.
Uses the RXFIFO composite for simplicity and reduced overhead.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-01-13 10:32:37 +01:00
Abe Kohandel
45a693a2a9 bluetooth: ots: validate OTS procedure sizes
Validate the OACP and OLCP procedure sizes as the procedure is parsed.
This is in contrast with the current implementation which first parses
the procedure and then validates its size and is prone to accessing
invalid memory when the procedure is malformed.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2022-01-12 15:47:20 +01:00
Emil Gydesen
df6289d7ec Bluetooth: Shell: Add name and address scan filters
Add a way to filter scan results by name and/or
address. The idea is that this can be further expanded
by also scanning the content for specific UUIDs, PHY,
RSSI, etc.

This is particularly useful for cases where there are many
devices advertising at once.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-12 15:46:23 +01:00
Piotr Pryga
bbf19b24be Bluetooth: Controller: llcp: Missing llcp ctx release when disconnect
If there were local LLCP pending and connection lost happened there
were no release of allocated control procedure context.
It caused to exhaustion of available procedures.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-11 11:52:42 +01:00
Piotr Pryga
3d9784a79e Bluetooth: Controller: change def val BT_CTLR_LLCP_PROC_CTX_BUF_NUM
Default value for CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM was set to
CONFIG_BT_CTLR_LLCP_CONN, so the value was 1. That caused a problem
if a device had started a local control procedure and remote procedure
request was received. Ther there were no free context for remote
procedure.

The commit changes the range of allowed value to start from 2.
Also the default value is set to two if CONFIG_BT_CTLR_LLCP_CONN
is 1. In other case default value is set to number of CONFIG_BT_-
LLCP_CONN.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-11 11:52:42 +01:00
Erik Brockhoff
9698d1f1a1 Bluetooth: controller: fixing up problem in collision handling
Non-instant based procedures not properly handled, when instant
based procedure is ongoing

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-01-10 14:50:14 +01:00
Erik Brockhoff
20e8a06afd Bluetooth: controller: fixing up possible race in data tx pause/resume
Turning the pause flag into a counter, to allow overlapping pause

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-01-10 14:50:14 +01:00
Erik Brockhoff
bc5ca7f5b8 Bluetooth: controller: fixing up struct ll_conn for new LLCP
Missing struct member added for non-legacy LLCP

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2022-01-10 14:50:14 +01:00
Erik Brockhoff
a148635837 Bluetooth: controller: completing procedure pause handling
Implementing the final parts of procedure pause mechanism
This is needed to bar procedures from generating pdus during encryption
procedure handling

Signed-off-by: Erik Brockhoff <erbr@oticon.com>

wip
2022-01-10 14:50:14 +01:00
Aleksander Wasaznik
e97413057a Bluetooth: Host: Fix type mismatch in bt_gatt_cancel
`bt_gatt_cancel` takes a `bt_gatt_.._params` pointer. The `params`
pointer is mistakenly passed on to `bt_att_req_cancel`, which expects a
`bt_att_req`.

This change makes bt_gatt_cancel locate the `req` and pass that to
`bt_att_req_cancel`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
2022-01-07 12:48:52 -05:00
Rubin Gerritsen
acaf4eedaf Bluetooth: Host: Extract out ad_stream to set long adv data
This structure can be reused to set periodic advertising data.
The structure tries fills the buffer as much as possible.
Later this can be reused for setting advertising data in other cases
as well.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-01-07 15:37:01 +02:00
Herman Berget
acd2b8fdcc Bluetooth: Host: Reset scan state on scan stop
bt_le_stop() previously did the same restting as bt_scan_reset(). After
the recent changes they were out of sync.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-01-07 15:35:39 +02:00
Herman Berget
4c110f8f17 Bluetooth: Host: Move ext adv property conversion to separate function
How the conversion worked was unclear. Moving the conversion out to a
separate function and documenting how it works makes the code easier to
understand.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-01-07 15:35:39 +02:00
Herman Berget
6ede31428d Bluetooth: Host: Reassemble extended advertising reports
The host reassembles fragmented advertising reports from the controller.

Non-complete advertising reports from different advertisers may not be
interleaved. If non-complete advertising reports from an advertiser
is received while advertising reports from another advertiser is
reassembled, an error message is logged and the advertising report is
discarded. Future scan results may be incomplete.

Advertising reports from legacy PDUs or complete extended advertising
reports may be interleaved as these do not require reassembly.

If the controller sends more advertising data than fits in the
reassembly buffer, the data is truncated. Further advertising reports
from the advertiser are discarded until the final complete advertising
report is received and discarded.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-01-07 15:35:39 +02:00
Abe Kohandel
56a04a8200 bluetooth: l2cap: receive server error status
Only consider negative statuses returned from a L2CAP server as error.

This makes the status check done here consistent with the check done in
l2cap_chan_le_recv_sdu.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2022-01-05 14:42:33 +01:00
Trond Einar Snekvik
45ef0d2aef Bluetooth: Mesh: Use double pointer in bt_mesh_app_key_resolve
The signature of bt_mesh_app_key_resolve expresses pointer to a 16 byte
array as a const uint8_t *app_key[16], which is actually an array of 16
byte pointers. The intended type is equivalent to a double pointer to
const uint8_t, but trips up GCC 11, which actually checks this.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2022-01-05 14:40:06 +01:00
Trond Einar Snekvik
8417f04d75 Bluetooth: Mesh: Fix beacon_auth header net_id size
The crypto.h declaration of the bt_mesh_beacon_auth function declares
the net_id parameter to be a 16 byte array, but the function definition
says 8 bytes. This breaks compilation in GCC 11, which feeds an 8 byte
array into this API, triggering a warning. Change the header declaration
to 8 bytes, which is the right size.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2022-01-05 14:40:06 +01:00
Sebastian Bøe
ebf7939cf5 Bluetooth: host: use IS_ENABLED instead of ifdef
Use IS_ENABLED instead of ifdef to prevent an unused function warning.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2022-01-04 18:38:21 +02:00
Vinayak Kariappa Chettimada
9c638f727d Bluetooth: Controller: Apply suggestions from code review
Apply suggestions from code review.

Co-authored-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-04 16:21:50 +01:00
Vinayak Kariappa Chettimada
8cdc53e3da Bluetooth: Controller: Reset dup filtering on Periodic Re-sync
Reset duplicate filtering of Periodic Advertising Reports
when Periodic Advertising Sync is created again after a
terminate or sync lost.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-04 16:21:50 +01:00
Vinayak Kariappa Chettimada
88bc1d790c Bluetooth: Controller: Fix filtering data status for Periodic report
Fix missing implementation to use correct data status when
detecting duplicate Periodic Advertising Report data.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-04 16:21:50 +01:00
Vinayak Kariappa Chettimada
5829863460 Bluetooth: Controller: Fix data status reset in duplicate filter
Fix missing data status reset when DID change, based on
whether the data status is complete or not, the entry needs
to maintain the correct data_cmplt flag value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-04 16:21:50 +01:00
Vinayak Kariappa Chettimada
d6a81f120d Bluetooth: Controller: Remove redundant parameter passing
Remove redundant parameter passing as dup_count is global
variable.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-04 16:21:50 +01:00
Piotr Pryga
397101d322 Bluetooth: host: Style correction. Change names validate_** to valid_**
Align to naming convention for function responsible for HCI commands
parameters validation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 16:02:40 +01:00
Piotr Pryga
3b5c1efc16 Bluetooth: host: Align usage of cte_type in DF host implementation
The CTE type is used in two ways by HCI layer:
1) single value representing particular CTE type: AoA, AoD 1 us,
  AoD 2 us
2) bit-filed where bits 0-2 represent particular CTE types AoA
  AoD 1 us, AoD 2 us

The bit-field is used to inform Controller about allowed types
of CTE, hence single value carries more than one value.
To avoid confusion between these use cases in code that refers
to case 1) all named cte_type (singular form). For case 2)
cte_types (plural form) is used.

There is an enumeration that is used for both cases:
bt_df_cte_type. For cte_type only single value from the
enumeration may be assigned to variable except
BT_DF_CTE_TYPE_NONE and BT_DF_CTE_TYPE_ALL.
For cte_types all enum members may be used. Ocasionally
BT_DF_CTE_TYPE_NONE may be excluded. If that is true,
it is described in code documentation.

Thanks to that applications are released from requirement
to include hci.h header file.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 16:02:40 +01:00
Piotr Pryga
b76b5750ee Bluetooth: host: Add API to HCI CTE conn request enable procedure
There were no implementation for HCI_LE_Connection_CTE_Request_Enable
command from BT 5.3 Core specification.

The PR adds implementation and API to be used by applications.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 16:02:40 +01:00
Piotr Pryga
36d67c7692 Bluetooth: Controller: lll: Add IS_ENABLED to prevend build failures
Code that is part of radio_df_cte_inline_set_enabled may be not
compilable for targets that do not have Direction Finding Extension
in Radio peripheral. Added condition with IS_ENABLED to execute
the code only for those SOCs that have the extension.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Piotr Pryga
26a66ee299 tests: Bluetooth: df: Fix not building unit tests
There were changes done to controller code that cause
tests to do not build and fail during execution.
Changes are related with:
- modified code related with extended advertising ADI
  field handling
- added generic double buffer data structure that is
  used in controller
- moved code that was building only when DF is enabled
- added EVENTS_PHYEND that is not available in nrfbsim
  board

The PR addresses those issues.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Piotr Pryga
72fde2ffc2 Bluetooth: Controller: align DF conn less mode to use PHYEND event
Connectionless mode of direction finding was based on assumption
that PDU ends when EVENTS_END is generated.

Advertiser added CTE length to IFS duration to correctly maintain
IFS between consecutive PDUs.

Scanner was using separate API to configure radio to configure
software TX/RX mode switch to use PHYEND event instead of END.
Currently every SOC that has Direction Finding Extension in
Radio peripheral uses PHYEND event to mark end of PDU.
There is no need for separate API to configure software switch.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Piotr Pryga
9a117bde6f Bluetooth: controller: radio: add PHYEND delay compensation for nRF53
Radio peripheral that includes Direction Finding Extension is
able to generate EVENTS_PHYEND at very end of received PDU.
In case there is a Constant Tone Extensions in received packet
the EVENTS_PHYEND event is generated after end of CTE reception.
If the CTE is present in received packet, the EVENTS_PHYEND
event is generate in the same instant as EVENTS_END.

If CTEINLINE is enabled then Radio will do a runtime packet parsing
to check if CTEInfo is present in received packet. In case there
is no CTEInfo the EVENTS_PHYEND event will be generated with
16 us delay after EVENTS_END.

To maintain the IFS, additional EVENT_COMPARE is used that
will timeout earlier than regular EVENT_COMPARE for EVENTS_PHYEND
generated withtou delay. That additional EVENT_COMPARE will start
software switching of radio mode to TX. In case there is a CTEInfo
present in the packet, additional PPI wiring will cancell
EVENTS_COMPARE set for delayed EVENTS_PHYEND.

The commit provides changes to support delayed PHYEND for nRF53 SOCs.

Besides that there are small formatting corrections due to extended
max line length.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Piotr Pryga
578902960d Bluetooth: Controller: Add CTE recv and sample in connected mode
In connected mode when Receiving Constant Tone Extensions feature
is enabled, controller shall be able to receive CTE in any
data channel packet.
The commit adds required changes to allow receive of CTE for
all data channel packets in peripheral role.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Piotr Pryga
bf803514e1 Bluetooth: Controller: LLL: allow setting CTEInfo to be in S1 byte
CTEInfo may be stored in S1 byte for BLE1M or BLE2M data channel
packet or in payload of advertising channel packet. To allow
selection of where to expect the CTEInfo to be Radio and
DF lower link layer API has to be changed. New parameter
cte_info_in_s1 was introduced.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Piotr Pryga
f23fa86449 Bluetooth: Controller: util: Add generic double buffer implementation
There are multiple places where double buffer is used in controlers
code. This commit adds generic implementation of the double buffer.
It can be used in future in all places where the data structure is
in use.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Piotr Pryga
23dd369dd6 Bluetooth: Controller: radio: add PHYEND delay compensation for nRF52
Radio peripheral that includes Direction Finding Extension is
able to generate EVENTS_PHYEND at very end of received packet.
In case there is a Constant Tone Extensions in received packet
the EVENTS_PHYEND event is generated after end of CTE reception.
If the CTE is not present in received PDU, the EVENTS_PHYEND
event is generate in the same instant as EVENTS_END.

If CTEINLINE is enabled then Radio will do a runtime packet parsing
to check if CTEInfo is present in received packet. In case there
is no CTEInfo the EVENTS_PHYEND event will be generated with
16 us delay after EVENTS_END.

To maintain IFS, additional EVENT_COMPARE is used that
will timeout earlier than regular EVENT_COMPARE for EVENTS_PHYEND
generated withtout delay. That additional EVENT_COMPARE will start
software switching of radio mode to TX. In case there is a CTEInfo
present in the packet, additional PPI wiring will cancell
EVENTS_COMPARE set for delayed EVENTS_PHYEND.

The commit add support for delayed PHYEND event for nRF52 SOCs.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Piotr Pryga
0e03ea6577 Bluetooth: Controller: Use PHYEND in SW switch for nRF52 SOCs with DFE
To make possible to correclty receive PDUs that optionally include
Constant Tone Extension after CRC the PHYEND event must be used
instead of END event. PHYEND event is generated by Radio peripheral
for actual end of a PDU. In case there is a CTE the PHYEND event
is generated at end of the CTE. If PDU does not have CTE, then
PHYEND event is generated at end of CRC. In this case it is the
same instant as END event.

Use of PHYEND event is required only when BLE 5.1 Receiving Constant
Tone Extensions feature is supported. Because it is the same event as
END for SOCs that supports Direction Finding Extension, it is always
used for that SOCs.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-04 09:10:05 -05:00
Emil Gydesen
6287ca2dc7 Bluetooth: ATT: Move exec write reassemble code to new function
Move the code to reassembled buffers to a separate
function to make the code more readable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-04 09:05:23 -05:00
Emil Gydesen
b78cd855b8 Bluetooth: GATT: Add BT_GATT_WRITE_FLAG_EXECUTE flag
Add the BT_GATT_WRITE_FLAG_EXECUTE flag that indicates
whether a write callback is from an ATT execute write.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-04 09:05:23 -05:00
Emil Gydesen
88d0ad5b3e Bluetooth: ATT: Reassemble long write before sending to app
The current implemenation of GATT long write
(ATT prepare + exec write) worked by sending
each segment individually to the application.
This was a simple and effective method, but
the application had no indication of when the
last segment had been written.

This commit reassembles all the prepare writes
for a specific handle, and then sends the combined
write data to the application.

The prepare+exec write may include multiple handles,
so the implementation has taken that into account,
and will loop over the prep_queue multiple times.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-04 09:05:23 -05:00
Emil Gydesen
a1ce2d4c83 Bluetooth: ATT: Change prep_queue to slist instead of fifo
Change the type of the prep_queue to a linked list
instead of a fifo. The main reason for this, is
that we can then iterate over the content in it,
without popping it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-04 09:05:23 -05:00
Piotr Pryga
87448f99fe Bluetooth: host: Add host API to run conn CTE TX params set
Add host API to allow execution of HCI_LE_Set_Connection_CTE_Transmit_-
Parameters HCI command.

The commit also provides a refactored version of hci_df_set_conn_cte_tx-
_param function. The function was aligned to other hci_df_XXX functions
structure with separated parameters validation and preparation of
command object before it is send to controller.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Co-authored-by: Emil Gydesen <Thalley@users.noreply.github.com>
2022-01-04 14:12:15 +01:00
Vinayak Kariappa Chettimada
a3127afb53 Bluetooth: Controller: Advertising Extensions dynamic Tx power control
Update Controller implementation of Advertising Extensions
to inherit the set dynamic Tx power values of the primary
channel PDU transmissions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-31 20:18:00 +01:00
Piotr Pryga
3344aee332 Bluetooth: host: df: Correct style for CHECKIF statements
Correct wrong coding style used in couple of plces where
CHECKIF marco is used.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-31 17:45:52 +02:00
Piotr Pryga
61872da64e Bluetooth: host: Add API to run conn CTE response HCI command
Add host API to allow execution of HCI_LE_Connection_CTE_Response_-
Enable HCI command.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-12-31 17:45:52 +02:00
Vinayak Kariappa Chettimada
8660457ec2 Bluetooth: Controller: Apply suggestions from code review
Apply suggestions from code review.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-29 18:01:17 +01:00
Vinayak Kariappa Chettimada
6b9b16f06d Bluetooth: Controller: Minor changes related to review comments
Minor changes related to review comments.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-29 18:01:17 +01:00
Vinayak Kariappa Chettimada
c706a095e8 Bluetooth: Controller: Rename drop to accept to avoid negations
Rename the variable drop to accept to avoid multiple use of
negations in the implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-29 18:01:17 +01:00
Vinayak Kariappa Chettimada
471543e75e Bluetooth: Controller: Use DUP_FILTER_DISABLED define
Use DUP_FILTER_DISABLED define instead of magic value to
represent duplicate filtering being disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-29 18:01:17 +01:00
Vinayak Kariappa Chettimada
a1810425ca Bluetooth: Controller: Update support for Periodic Sync Receive enable
Update support for Periodic Advertising Synchronization
Receive Enable command, so that PDUs are received so that
contents of Extended Common Payload Format is parsed and
process for information like Channel Map Update and BIGInfo.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-29 18:01:17 +01:00
Vinayak Kariappa Chettimada
64eaa52e41 Bluetooth: Controller: Initial support for Periodic Sync Receive enable
Initial support for Periodic Advertising Synchronization
Receive Enable command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-12-29 18:01:17 +01:00