Commit graph

9523 commits

Author SHA1 Message Date
Emil Gydesen
3f247b212b Bluetooth: ISO: Add Kconfig for ISO central/peripheral
Add two new Kconfigs: BT_ISO_CENTRAL and BT_ISO_PERIPHERAL
that is used to do central or peripheral only builds,
similar to the BT_CENTRAL or BT_PERIPHERAL Kconfigs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-13 12:44:47 -07:00
Mariusz Skamra
2747665a2e Bluetooth: has: Fix missing dependency
This fixes missing UTF8 dependency. HAS makes use of utf8_lcpy.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Mariusz Skamra
bc42cbd174 tests: shell: Add Read Presets Request to HAS client shell
This extends shell with Read Presets Request command.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Mariusz Skamra
2d87443a4a Bluetooth: has: Add support for Read Presets Request operation
This extends client implementation with Read Presets Request operation
support.
The implementation can maintain up to BT_L2CAP_TX_BUF_COUNT control
point requests so that user could perform/queue another Control Point
Operation if one is ongoing. E.g. preset can be selected from Read Preset
Response notification context or perform multiple operations if EATT
enabled.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Mariusz Skamra
305d5bc119 tests: shell: Add shell for HAS client
This adds shell module for HAS client with it's initial functionality.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-13 08:46:21 -07:00
Piotr Pryga
e81414d28f Bluetooth: Controller: Fix CTE_REQ disable lock if there is no CTE_RSP
The periodic CTE_REQ disable command, requested by Host, may be locked
until connection is dropped due to missing CTE_RSP from peer device.
That is caused by implementation of CTE_REQ disable and CTE_REQ
control procedure handling.

The procedure is marked as active when CTE request was send to peer
device. It is marked as inactive after completion of the procedure.
That caused locking of CTE disable on a semaphore.

The BT 5.3 Core Spec, Vol 4, Part E, section 7.8.85 says the HCI_LE_-
Connection_CTE_Request_Enable should be considered active on a conne-
ction from when Host successfully issues the command with Enable=0x1
until a command is issued with Enable=0x0 or single LLCP CTE request
has finished (CTE_Request_Interval=0x0). Also there is a clarification
from BT SIG that the command with Enable=0x0 does not affect any
initiated LLCP CTE request. That means Controller is allowed to finish
already started procedure and it is not allowed to start new LLCP CTE
request procedure after completion of the command with Enable=0x0.

Taking that into account, there is no need to synchronize ULL and LLL
in regard of disable the LLCP CTE request while the procedure is
pending. Controller is free to complete the procedure or terminate it.

The change removes all code related with cte_req.is_active, disable
callback and waiting of ULL for LLL to finish the LLCP CTE request.

The ULL will complete the HCI_LE_Connection_Request_Enable with
Enable=0x0 immediately. In case the procedure is disabled in before
the response arrives, then further processing of the response is
dropped and the procedure context released.

The context is not released by the code responsible for disable
handling, to have single place where it is done.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-13 10:25:39 -05:00
Piotr Pryga
1004c30507 Bluetooth: Controller: Fix CTE req periodically after req is disabled
There is an error in the condition that checks if new CTE_REQ should
be started after end of connection event. The condition verifies if
counter req_expire is set to zero. Then new CTE_REQ is started
irrespectively to CTE_REQ being disabled.

req_interval is used to store information if the CTE_REQ is:
- periodic, then value doesn't equal zero,
- single shot or disabled, then value equals zero.

The condition should verify if the req_interval is not zero and
req_expire is not zero. The second part of the if condition is
required to avoid starting next CTE_REQ until last one has been
completed.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-13 10:25:39 -05:00
Piotr Pryga
c167122ce8 Bluetooth: Controller: llcp: Set remote LLCP rx_opcode to type unused
Some of control procedures has set ctx->rx_opcode in rp_comm_tx
function to values that state there is an expected PDU.
This is not always true. In case of procedures that do not expect
any response from remote device, the ctx->rx_opcode should be set
to PDU_DATA_LLCTRL_TYPE_UNUSED.

In the worst cases scenario, when the same control procedure
is executed locally and remotely, correct response PDU may
cause an assertion in  ull_cp_rx. It could happen because
of wrong ctx->rx_opcode value. A packet with opcode that is
set in remote and local control procedure context rx_opcode
will be treated as expected value for both. That is a situation
that cannot happen.

The commit changes the assignments of rx_opcode to fix the problem.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-13 10:23:34 -05:00
Andries Kruithof
a883e77241 Tests: bluetooth: fix build errors for bluetooth testcases
This commit fixes the build errors for the testcases in
the tests/bluetooth/init folder

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-05-13 08:56:12 -05:00
Andries Kruithof
d201055e70 Tests: bluetooth: fix ctrl_user_ext test
The tests/bluetooth/ctrl_user_ext test fails due to
compilation errors, which are fixed with this PR

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2022-05-13 08:56:12 -05:00
Pavel Vasilyev
1efce43a00 Bluetooth: Mesh: Fix segmentation when sending proxy message
Previous check in the if-statement would never allow to send last
segment if msg->len + 2 == MTU * x.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2022-05-13 15:45:22 +03:00
Emil Gydesen
83c7baf34a Bluetooth: Audio: Add recv_info to audio recv callback
The audio stream receive callback now contains a
recv_info struct, which contain crucial information
such as timestamps and packet validity.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:28 +02:00
Emil Gydesen
6191a76f55 Bluetooth: Audio: Add _DIR_ infix to BT_AUDIO_SINK/SOURCE
The values represent an enum, and it makes sense for the
enum values to follow the enum type name, so an
_DIR_ infix was added to the values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
0a4e62addd Bluetooth: Audio: Remove PAC_TYPE_UNUSED
The PAC_TYPE_UNUSED would be breaking
enum rules, as it is setting and comparing
a value outside the enum range.

Instead we check if the `dir` field has been
set to SINK or SOURCE.

The reason why this still works, is that
we memset the struct unicast_client_pac
causing `dir` to become 0. This still
does not really follow the rules of enums, but
it is the best we can do without adding another
value to determine if a struct unicast_client_pac
is unused or not, without adding another value to
public enum struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
19d7420f07 Bluetooth: Audio: Standadize the use of enum bt_audio_dir
Many functions and struct fields had the directory/type
value, but named in different ways and stored in different ways.

This change updates all uses of it to use the same name
and type.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
6b41e9991d Bluetooth: Audio: Rename enum bt_audio_pac_type
The enum bt_audio_pac_type does not fully
represent the what the value is used for.

The typical use of it is not for just published
audio capabilities (PAC), but rather describes the
type, or direction, of audio endpoints.

For the unicast client, the type/direction is
relative to the unicast server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
306d766329 Bluetooth: Audio: Unicast client remove id from ep_init
The unicast_client_ep_init took a ID value that was
always 0. Moved the initialization to the value to
the function, instead of an argument. The value
is only used for the unicast server, so it can
probably be removed from the endpoint
struct for unicast clients only. To be optimized later.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Emil Gydesen
7d134e4e1d Bluetooth: Audio: Remove unused endpoint types
The endpoint.type field was unused as it was
always LOCAL for the unicast server and always
REMOTE for the unicast client, and the few places
where we actually checked it, we already had a
check for acl->role which gave the same value.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-10 18:56:00 +02:00
Morten Priess
e74804c125 Bluetooth: controller: Removed compiler warnings in ull_iso.c
Conditionally declared auto-variables to avoid 'unused' warnings in BSIM
ISO test compilation.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-05-10 18:55:35 +02:00
Herman Berget
874ef53b17 Bluetooth: Host: Assert that all channels in request have the same PSM
The PSM of the first channel in the connection request is used, but the
PSM value is used for all of them on the receiving side.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-10 18:40:36 +02:00
Herman Berget
1069d5fe56 Bluetooth: Host: Fix L2CAP collision mitigation
There were some errors in the detection of ECRED connection collisions,
so the retry was triggered incorrectly.

The number of channels requested in the retry was wrong in some cases,
using the number of channels from the received request instead of the
sent request.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-10 18:40:36 +02:00
Gerard Marull-Paretas
5113c1418d subsystems: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-09 12:07:35 +02:00
Vinayak Kariappa Chettimada
3702f7220a Bluetooth: Controller: Fix cte_info may be used uninitialized error
Fix cte_info may be used uninitialized compile error.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-09 09:28:34 +02:00
Vinayak Kariappa Chettimada
3af3c1237c Bluetooth: Controller: Restrict AD Data to BT_CTLR_ADV_DATA_LEN_MAX
Strictly restrict AD Data length to BT_CTLR_ADV_DATA_LEN_MAX
when there can be free bytes in Advertising PDU with common
extended header format of less that the maximum 64 bytes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-09 09:28:34 +02:00
Emil Gydesen
9defebbfd3 Bluetooth: Audio: broadcast_sink_sync array of stream pointers
Change bt_audio_broadcast_sink_sync to use an array of pointers
to bt_audio_streams, instead of an array of streams. This makes
the API more flexible, as well consistent with the broadcast
source and unicast APIs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Emil Gydesen
5628b29b01 Bluetooth: Audio: broadcast_source_create array of stream pointers
The bt_audio_broadcast_source_create function will now
take an array of stream pointers, instead of an array
of streams. This is to make the API more flexible as
well as more consistent with the unicast API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Emil Gydesen
6e60451e09 Bluetooth: Audio: Change array of unicast streams to array of pointers
In bt_audio_unicast_group_create, bt_audio_unicast_group_add_streams
and bt_audio_unicast_group_remove_streams to use an array
of pointers, instead of an array of streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-09 09:28:14 +02:00
Mariusz Skamra
4730f72fb6 Bluetooth: test: Extend HAS shell with preset availability funcs
This extends shell with commands that can modify the preset
availability.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-09 09:27:09 +02:00
Mariusz Skamra
2314aa2977 Bluetooth: has: Add Preset Changed operation support
This extends implementation with sending Preset Changed
notification/indication when preset changes its availability or is
added or deleted.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-09 09:27:09 +02:00
Piotr Pryga
c18477ad25 Bluetooth: Controller: llcp: fix wrong cond in prepare instant
In a function pu_prepare_instant there is a condition that
checks if there is actual change of a PHY. That condition
was based on ctx->data.pu.tx and ctx->data.pu.rx.
These members store PHY that is or will be used, hence
the condition is wrong. Even there is no actual change in
the PHY, values could be not equal to zero. In such case
the instant value would be set to wrong value.
What more the condition be an 'or' not an 'and' because
one of the values must be different than zero to have the
PHY change and instant different than zero.

After update of the condition, the function call places
must be changed. The ctx->data.pu.c_to_p_phy and
ctx->data.pu.p_to_c_phy are set in pu_prepare_update_ind
function, hence pu_prepare_instant should be called after
that.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-06 11:50:59 +02:00
Vinayak Kariappa Chettimada
4c31f24de7 Bluetooth: Controller: Fix Broadcast and Connected ISO cond. compiles
Fix some of the Broadcast and Connected ISO related
conditional compilations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:32:30 +02:00
Morten Priess
e3342fe01e Bluetooth: controller: ISO TX data path including ISOAL
- ISO TX data path for HCI and support for vendor path
- ISO-AL segmentation of framed PDUs
- Insertion of segment headers
- Reconstruction and storing of CIG reference point in ULL
- Calculation and insertion of of Time-Offset
- Exit error spooling in ISO-AL on detecting start
- ISO-AL TX unframed fragmentation

Signed-off-by: Nirosharn Amarasinghe <niag@demant.com>
Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-05-06 11:32:30 +02:00
Morten Priess
9d4368251e Bluetooth: host: Set ISO type for CIS at request
Set BT_ISO_CHAN_TYPE_CONNECTED as type for connected ISO at CIS_REQ.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2022-05-06 11:32:30 +02:00
Vinayak Kariappa Chettimada
9ff0c5c93d Bluetooth: Controller: Enqueue missing ISO PDUs with invalid status
Add implementation to generate node rx for missing ISO PDUs
and set the status as invalid. This is required for ISOAL to
correctly track the sequence numbers for every SDU interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:32:11 +02:00
Vinayak Kariappa Chettimada
d04f5917bf Bluetooth: Controller: Add Ext Adv Parameter Validations
Add Extended Advertising interval parameter validation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:31:44 +02:00
Vinayak Kariappa Chettimada
371d078654 Bluetooth: Controller: Add Kconfig to limit advertising interval max
Add Kconfig to limit the Primary Advertising Interval and
Periodic Advertising Interval maximum supported values in
the Controller implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-05-06 11:31:44 +02:00
Emil Gydesen
177bdff61b Bluetooth: Audio: Fix order of checks in bt_audio_stream_qos
The bt_audio_stream_qos function checked if stream->ep was
NULL before checking if the stream were even valid for this
QoS procedure.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-06 11:30:37 +02:00
Emil Gydesen
316cc7141c Bluetooth: Audio: Add NULL check when creating the CIG
When create the CIG for a unicast group, we did not
verify whether stream->iso was NULL before attempting
to use that to create the CIG.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-05-06 11:30:29 +02:00
Herman Berget
5b0deb058b Bluetooth: Host: Remove unused nfy_mult_data
After adding the more general ATT meta data, it is no longer used.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-05 14:42:38 -05:00
Rubin Gerritsen
b51353628a Bluetooth: Controller: DF configs should not depend on BT_LL_SW_SPLIT
None of the common DF configs should depend on using BT_LL_SW_SPLIT.
Added dependencies to it where this was the case.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-05-05 14:39:04 -05:00
Rubin Gerritsen
aec5307ac9 Bluetooth: Controller: Make some DF configs specific to BT_LL_SPLIT
These configurations are tighlty coupled to the implementation,
so these should be hidden when not using BT_LL_SW_SPLIT.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-05-05 14:39:04 -05:00
Rubin Gerritsen
b25a2fab79 Bluetooth: Controller: Make it possible to support only TX or RX DF
Some controllers may support only TXing or RXing CTE.
As all DF features are guarded by BT_CTLR_DF, we need to ensure
that it is possible to select those when only TX or RX is available.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-05-05 14:39:04 -05:00
Rubin Gerritsen
e51999e661 Bluetooth: Controller: Document the purpose of BT_CTLR_DF_SUPPORT
I believe it will now be easier to understand how to use it.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-05-05 14:39:04 -05:00
Mariusz Skamra
e6b73b08e6 Bluetooth: gatt: Update bt_gatt_is_subscribed documentation
This updates the documentation of bt_gatt_is_subscribed function that
can take a bitfield of BT_GATT_CCC_NOTIFY and BT_GATT_CCC_INDICATE.
This might be useful if one wants to test if peer is subscribed, but
does not matter which method was used.

The gatt.c implementation handles API usage already, because it performs
bitwise AND:
if (bt_conn_is_peer_addr_le(conn, cfg->id, &cfg->peer) &&
    (ccc_value & ccc->cfg[i].value)) {
	return true;
}

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2022-05-04 18:56:36 -04:00
Piotr Pryga
c98e64921b Bluetooth: Controller: lll: Add missing CTEInfo copy if conn encrypted
In case a connection is encrypted received PDU is decrypted by CCM.
CCM does not encrypt/decrypt S1 byte that stores CTEInfo.
In case of reception of a PDU by encrypted connection there is missing
CTEInfo in a memory where CCM stores decrypted PDU.
The CTEInfo data must be copied from scratch packet.

The commit adds code responsible for copying of the CTEInfo into
target PDU memory.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-05-04 09:48:14 -05:00
Herman Berget
d8357a2216 Bluetooth: Host: Add testing function bt_eatt_reconfigure
The function sends L2CAP reconfigure requests to reconfigure all
connected EATT channels.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-04 10:35:31 +03:00
Herman Berget
addc4a90f0 Bluetooth: Host: Call att_mtu_updated callback on channel reconfigured
Previously, the att_mtu_updated callback was only called on initial
connection of the channel or during the MTU Exchange procedure. There
was no way for the application to know that the MTU increased in the
case where the peer initiated the reconfiguration.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2022-05-04 10:35:31 +03:00
Asbjørn Sæbø
0644d51d2d Bluetooth: Audio: Use existing ATT macros for handle range
Use the existing macros for first and last handle instead of defining
own macros.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2022-05-04 10:30:27 +03:00
Aleksandr Khromykh
0aa0913ca5 Bluetooth: Host: fix aes ccm authentication
Bluetooth Host calculated authentication value correctly only
for data smaller than 255 bytes. If data is larger then
authentication transformation used wrong flags.
Since the issue was symmetric two Zephyr
based devices were able to understand each other. Hence,
other devices like Android or IOS smartphones weren't able
to authenticate large frames and broke communication.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2022-05-03 09:37:17 +02:00
Lingao Meng
2ef96e2f66 Bluetooth: Host: Fix unable cleanup conn
The peripheral is configured to update the connection
parameters for 5 seconds by default.

There is an abnormal situation with a very low probability.

The central actively disconnects or abnormally disconnects the
Bluetooth connection at the same time.

At this time, the connection disconnection event will be
handled by BT RX.

At this time, sysworkq has sent a parameter update request and
will receive a reply with status = 0x02, because the handle is
invalid at this time.

We can not just cancel work, because work->flag may be
in K_WORK_RUNNING, so work->flag is set to K_WORK_CANCELING
and subsequent conn_cleanup will unable call k_work_rescheduler
successfully.

According submit_to_queue_locked will return ret = -EBUSY.

	if (flag_test(&work->flags, K_WORK_CANCELING_BIT)) {
		/* Disallowed */
		ret = -EBUSY;
As a result, the connection cannot be cleanup correctly.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2022-04-29 15:35:10 +02:00