Commit graph

9523 commits

Author SHA1 Message Date
Emil Gydesen
dc97bbd35f Bluetooth: Audio: Rename bt_audio_codec_qos -> bt_bap_qos_cfg
The QoS structure is not related to a codec, but rather a
stream, and should thus not use the "Codec" name.

The BAP and ASCS specs refer to the QoS as
"QoS configuration" several places, so it is an obvious
choice for a name.

Since the structure is defined and used by BAP, the prefix
was changed from bt_audio to bt_bap.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-04 16:34:22 +01:00
Erik Brockhoff
670bd3bed2 Bluetooth: controller: fixing issue re. assert on overlapping conn upd proc
If a connection update (from central) overlaps a peripheral initiated
conneection param request, then central rejects peripheral request
and continues central procedure. This lead to an assert in peripheral
On instant there would not be an rx_node for notification, as this
would have been discarded by the reception of the REJECT.

This fix ensures that once an rx_node has been 'accepted' for retention
it will not be discarded/overwritten by future rx_nodes

The test will trigger the assert without the fix in.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-10-04 10:46:06 +01:00
Yong Cong Sin
52a202309b zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY
Change instances of:

DT_NODE_HAS_STATUS(<node_id>, okay)

to

DT_NODE_HAS_STATUS_OKAY(<node_id>)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-03 17:06:52 +01:00
Lyle Zhu
0ed8866eb6 Bluetooth: host: Kconfig: Correct help of BT_BONDABLE
Correct the `help` of the configuration `BT_BONDABLE`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00
Lyle Zhu
aaab223574 Bluetooth: SSP: Incorrect bonding status notified
The `bonded` flag of the callback `pairing_complete` is always true,
event if the SSP pairing is non-bondable.

Check the bonding status in SSP complete event instead of in link key
notify event.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00
Lyle Zhu
a00d5089d5 Bluetooth: shell: Add command conn-bondable
Add command `conn-bondable` to enable/disable the pairing bondable
flag of a specific ACL connection.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00
Lyle Zhu
d5160f663a Bluetooth: BR: Improve bt_conn_set_bondable
In current, the bondable flag cannot be configured for each specific
BR connection.
But for LE conn, there is a function `bt_conn_set_bondable` for this
purpose.

Improve `bt_conn_set_bondable` to support BR conn.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00
Lyle Zhu
e772c45e6b Bluetooth: SSP: Support non-bondable mode
If the return value of function bt_get_bondable is false, clear the
bonding flag when controller requiring `Authentication_Requirements`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00
Lyle Zhu
c0ce5b419b Bluetooth: Host: smp: Add function to get bonding setting
Add a function bt_get_bondable to get the bonding setting.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00
Håvard Reierstad
0fe6d34f8a Bluetooth: Mesh: Remove duplicate brg declaration
Removes duplicate declaration of the bridging direction, keeping the
one in the public header file.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-10-02 14:54:13 +01:00
Håvard Reierstad
8049c24994 Bluetooth: Mesh: Add prefix to Subnet Bridge API
Adds the `bt_mesh_brg_cfg` prefix to the public Subnet Bridge API, and
aligns the function and callback naming with the rest of the Bluetooth
Mesh API.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-10-02 14:54:13 +01:00
Lyle Zhu
4c09f5cce3 Bluetooth: BR: Shell: Remove duplicated else statement
Remove duplicate `else` statement if the function is returned from
corresponding `if` statement.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:15:14 +02:00
Lyle Zhu
0270f91c1c Bluetooth: BR: Shell: Return error if command is failed
Return error code if the command is failed instead of `0`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:15:14 +02:00
Lyle Zhu
3b74ed3f54 Bluetooth: BR: shell: Rename int res to int err
Rename `int res` to `int err`. Make variable naming consistent.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:15:14 +02:00
Lyle Zhu
17cfe36195 Bluetooth: BR: Return SHELL_CMD_HELP_PRINTED if calls shell_help
If the function `shell_help` is called, return SHELL_CMD_HELP_PRINTED
instead of `0`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:15:14 +02:00
Lyle Zhu
0b6684d8e3 Bluetooth: l2cap_br: Comment on l2cap->info_fixed_chan
Comment on the l2cap->info_fixed_chan why the size of it is one octet.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:14:18 +02:00
Lyle Zhu
f1d9549a0c Bluetooth: BR: SMP: Check if remote supports CID 0x0007
Add a function bt_l2cap_br_get_remote_fixed_chan to get the remote fixed
channels.

If the fixed channel CID 0x0007 is unsupported, skip the LTK derivation.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:14:18 +02:00
Lyle Zhu
ff39d41034 Bluetooth: ssp: correct pairing failed callback
Current, the callback `pairing_complete` is called
when the pairing is filed. But there is a callback
`pairing_failed` for pairing failed case.

Correct the callback calling if pairing failed.
Call `pairing_failed` instead of `pairing_complete`
if the pairing failed.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:09:00 +02:00
Lyle Zhu
f9c490b7e1 Bluetooth: LE: SMP: Set CT2 bit by default
Set CT2 bit to auth_req field by default if
the BR is enabled.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:08:44 +02:00
Lyle Zhu
c7db41dddb Bluetooth: BR: SMP: Set CT2 bit by default
Set CT2 bit by default.

If CT2 bit is set by both side, set the
CT2 flag `SMP_FLAG_CT2`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:08:44 +02:00
Lyle Zhu
8c8a21a04c Bluetooth: BR_SMP: Add a flag BT_CONN_BR_PAIRED
Due to the BT_CONN_BR_PAIRING is cleared when
receiving ssp pairing complete event. The LTK
key cannot be derived after the BR connection
encrypted.

Add a flag BT_CONN_BR_PAIRED that the pairing
has been done.

Use this flag to indicate whether the LTK
derivation needs to be applied if the BR ACL
connection is encrypted.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:08:34 +02:00
Lyle Zhu
91db52c431 Bluetooth: SSP: clear pairing flag if ssp pairing completed
When the ssp pairing event is notified, clear the pairing
flag.

It is used to support case that the authentication is
started by peer, the link will not be encrypted after
the pairing is completed without any err.
If the local device want to encrypt the link, it could
call `bt_conn_set_security` to start encrypt the link
after the pairing complete callback triggered.

In original implementation, the `bt_conn_set_security`
cannot be called if the authentication has been started.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:08:34 +02:00
Lyle Zhu
08ceb14299 Bluetooth: Host: SSP: Correct BR bonding type
Currently, the bonding type of Authentication
_Requirements parameter is always `Dedicated
Bonding` if the device is pairing initiator.

But if the bonding is performed during
connection setup or channel establishment as
a precursor to accessing a service, the
bonding type should be `General bonding`.

Add a flag BT_CONN_BR_GENERAL_BONDING.
Set the flag if the bonding is performed in
the L2CAP_BR/RFCOMM channel establishment.

Set bonding type depends on the flag when
receiving IO cap request.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:07:09 +02:00
Lyle Zhu
832753b80c Bluetooth: BR: Change the type of resolving to bool
The `resolving` is used to flag the status that the stack is requesting
remote device name.

It is better to use the type `bool` instead of the original type
`uint8_t`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:05:32 +02:00
Lyle Zhu
b1dc7ff242 Bluetooth: BR: Optimize _priv of struct bt_br_discovery_result
Move `struct discovery_priv` to classic.h

Rename `struct discovery_priv` to `struct bt_br_discovery_priv`.

Modify the structure `struct bt_br_discovery_priv` with `@private`.

Change field `_priv` of `struct bt_br_discovery_result` from
`uint8_t _priv[4]` to `struct bt_br_discovery_priv _priv`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:05:32 +02:00
Lyle Zhu
d92bc8ab30 Bluetooth: shell: BR: update device discovery
Due to the update of function bt_br_discovery_start,
register discovery callback by calling
bt_br_discovery_cb_register.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:05:32 +02:00
Lyle Zhu
f670e3a52f Bluetooth: Classic: Remove callback from bt_br_discovery_start
Remove BR discovery callback from bt_br_discovery_start.

All discovery results will be notified through callback
registered by bt_br_discovery_cb_register.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:05:32 +02:00
Lyle Zhu
d0f5b6c351 Bluetooth: BR: Add listener cb for discovery
The results of inquiry and extended inquiry
are only reported from application level
after the inquiry complete event notified.

While the event of inquiry result is notified
by controller in real time.

It is not a good user experience.

Just like scanning of LE, add a listener
cb for discovery.

When the event of inquiry result, extended
inquiry result, or remote name request
complete notified, call listener `recv`
cb to notify the upper layer.

When the event of inquiry complete
notified or no pending of remote name
request , call listener `timeout`
cb to notify the upper layer.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 10:05:32 +02:00
Armin Brauns
fa8d80a15b bluetooth: honor log panic mode in monitor
Once panic mode is entered, the log write functions are called from an ISR,
so must not try to acquire locks.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2024-10-02 10:00:26 +02:00
Andries Kruithof
8295deb966 Bluetooth: Audio: CAP implement broadcast reception stop
Implement the CAP broadcast reception stop procedures and
add unit tests

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-10-02 09:59:23 +02:00
Emil Gydesen
fa4f2ffc47 Bluetooth: CAP: Add support for doing just disable for unicast stop
The unicast_stop function is changed to primarily do a
BAP disable instead of a release, with optional
support for releasing the streams once they have been disabled.

This also adds unittests for the procedure which also
allow us to remove the invalid param testing from the BSIM tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-01 09:54:04 +02:00
Morten Priess
7e892f8c6f Bluetooth: controller: Remove SC-jitter from ISO pause/resume setup
Because timing of the pause/resume for peripheral/sync is based on
central/broadcaster active clock, the sleep-clock jitter shall not be
added.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-09-27 09:03:37 +02:00
Morten Priess
fe83a9dc22 Bluetooth: controller: Fixes and improvements for PTO implementation
- Add next pointer to node_rx_iso_meta for pre-transmission linked
  list (does not increase memory usage as union is larger).
- Fix broadcaster not setting PTC with test configuration
- Refactor stopping of sync ISO tickers to separate function

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-09-27 09:03:37 +02:00
Morten Priess
541b516a3f Bluetooth: controller: Make ISO Pause/Resume common
Share pause/resume functionality by moving resume ticker handling to
ull_iso. Rename interface function to ull_conn_iso_resume_ticker_start,
and provide handles instead of instance pointer.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-09-27 09:03:37 +02:00
Vinayak Kariappa Chettimada
b423941010 Bluetooth: Controller: Remove unused nRF21 FEM SPI CSN control
Remove unused nRF21 FEM SPI CSN control as the Zephyr
Controller does not implementation SPI control for Tx/Rx
nor for Tx gain settings.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-26 17:43:34 -04:00
Babak Arisian
c0cfe49a54 Bluetooth: BASS: Add support for dynamic registration of BASS
Added support for dynamic registration and unregistration of the
Broadcast Audio Scan Service (BASS) within the scan delegator.
This enables both scan delegator and BASS to be registered or
unregistered dynamically at runtime.

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-09-26 17:42:39 -04:00
Emil Gydesen
ec2c5b0c1f Bluetooth: GATT: Replace magic number 0 with macro for auto ccc
Replace the magic number 0 with a #defined value for
the auto CCC discovery feature.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-26 17:41:24 -04:00
Rubin Gerritsen
417a9e81ec Bluetooth: Controller: Add device tree dependency to selection
This commit makes the device tree configuration decide
which link layer is compiled in. We do this to avoid
hard-to-understand linker errors referencing device tree nodes.

The following configuration creates a difficult to parse
linker error:
* BT_LL_CHOICE contains multiple entries, BT_LL_SW_SPLIT
  is selected.
* Each BT_LL_CHOICE has its own unique device tree node with its
  own "compatible".
* Only one of the link layer device tree nodes has status "okay",
  but not the one corresponding to BT_LL_SW_SPLIT.

The linker error indicates that code using the HCI driver fails
to link with the controller. This because the HCI driver device
tree node references the link layer selected in devicetree which
is not compiled in.

By adding a dependendency to the device tree node, this can no longer
happen. Instead, if BT_LL_SW_SPLIT is now selected in a configuration
file, a Kconfig warning will be issued:

```
warning: The choice symbol BT_LL_SW_SPLIT
(defined at subsys/bluetooth/controller/Kconfig:129) was
selected (set =y), but BT_LL_SOFTDEVICE (defined at
/home/ruge/ncs/nrf/subsys/bluetooth/controller/Kconfig:11)
ended up as the choice selection.
```

This should be easier to understand than:

```
...(hci_core.c.obj):(.data.bt_dev+0x16c):
undefined reference to `__device_dts_ord_132'
```

After this commit we should consider getting rid of link layer
selection from Kconfig completely as the link layer is in practice
selected through device tree.

Unit tests have been updated to satisfy the dts dependency.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-09-26 11:10:22 +01:00
Emil Gydesen
fff3ff02c5 Bluetooth: CSIP: Add bonding requirement for set lock/release
The CSIP spec states that the procedures shall only be done
on bonded devices, so a check for that was added.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-26 03:31:47 -04:00
Burak Gorduk
6e3c3f67e1 bluetooth: host: Use consistent API naming for CS
This change adds bt_le_cs prefix to public CS API as well as
adding le_cs prefix to CS related bt_conn callbacks. This is
to ensure consistency within CS API while maintaining the
separation between the Bluetooth LE and Classic features.

Signed-off-by: Burak Gorduk <burak.gorduk@nordicsemi.no>
2024-09-25 12:58:51 +02:00
Burak Gorduk
7b82214d29 bluetooth: host: HCI support for CS configuration
Adds following HCI support for CS configuration:
- LE CS Create Config command
- LE CS Remove Config command
- LE CS Config Complete event

Two callbacks have been added to notify the application
when a new CS configuration is created or an existing
CS configuration is removed.

Signed-off-by: Burak Gorduk <burak.gorduk@nordicsemi.no>
2024-09-25 12:58:51 +02:00
Babak Arisian
d8c1d4d7b6 Bluetooth: Host: BT scan failure when connecting by name in shell
Added a timeout for active scans (instead of using the host's scan
timeout) in the shell by submitting a k_work that stops the scan
after a specified period.

Fixes #78659

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-09-25 12:58:11 +02:00
Olivier Lesage
7538a981c9 bluetooth: host: set BT_BUF_EVT_RX_SIZE to 255 when CS is enabled
Channel sounding frequently produces very large events, so the default
of 68 bytes can lead to buffer overruns / memory corruption.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2024-09-25 04:05:14 -04:00
Lyle Zhu
18d1ca7c78 Bluetooth: classic: Fix LE LTK cannot be derived issue
In the handler of SMP_Pairing rsp, the encryption key
flag is cleared incorrectly.

It causes the LE LTK cannot be derived.

Do not modify the encryption key flag to fix the
issue.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-09-25 04:02:11 -04:00
Emil Gydesen
1406c547d6 Bluetooth: TBS: Add support for dynamic TBS
The TBS and GTBS instances can now be dynamically registered
and unregistered, which fits better for the use cases of TBS
where specific bearers can come and go depending on the
features of the device.

For example if a SIM card is inserted, then a device can
register a TBS for the provider and remove it again if the
SIM card is removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-24 09:21:54 -04:00
Emil Gydesen
bf897cf941 Bluetooth: Shell: Restructure shell files
Moves around the shell files so that they are placed nearer
to the features they expose access to.

A few changes as possible has been made.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-24 09:21:04 -04:00
Emil Gydesen
4e4971b25d Bluetooth: GATT: Fix issue with 0/NULL for bt_gatt_attr_read
The bt_gatt_attr_read function did not properly handle cases
where value is NULL and/or value_len is 0, or bad mixes of the
two.

The important part is here is that we do not perform the pointer
arithmetic on NULL and/or call memcpy with a NULL src with a
non-0 length.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-23 18:09:13 -04:00
Emil Gydesen
72829b3b77 Bluetooth: ISO: Added missing NULL checks for API functions
Add missing NULL check for public API function, so that the
function will return -EINVAL rather than crashing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-23 14:08:52 +01:00
Emil Gydesen
7ef2f81413 Bluetooth: Audio: Add helpers for assisted listening stream
Added helper functions to set and get assisted listening
stream values for codec capabilities and codec configs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-23 10:03:47 +02:00
Emil Gydesen
0fe97560a3 Bluetooth: BAP: Add validation of qos_pref
The QoS preference defined by ASCS has some specified
limits and values that we should enforce.

Given the current API we cannot return an error to the
unicast server if it supplies invalid values, so we have
to resort to a LOG_ERR.

For the unicast client we treat invalid QoS preferences
similar to other invalid data in the notifications.

This also adds additional documentation in the
bt_audio_codec_qos_pref struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-23 10:03:12 +02:00