Commit graph

576 commits

Author SHA1 Message Date
Rubin Gerritsen 3ce106c620 Bluetooth: Host: Fix not clearing IDs and keys upon bt_disable()
Expectation: After calling `bt_disable()` it is possible to
use the Bluetooth APIs as if `bt_enable()` was never called.

This was not the case for `bt_id_create()`, it was not possible
to set the default identity. This prevented an application
developer to restart the stack as a different identity.

Keys also need to be cleared to avoid the following pattern:
1. Pair two devices
2. Central calls `bt_disable()` and `bt_enable()`.
   The central will now generate a new identity address.
3. Connect the two devices.
4. Re-establish encryption. Now the central will try to use
   the previously used keys. The procedure will fail
   because the peripheral does not have any keys associated
   with the new central address.

The API documentation is updated accordingly.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-05-28 09:11:52 -07:00
Mark Wang bdca41d0bf Bluetooth: A2DP: Implement the a2dp and avdtp
implement a2dp.c and avdtp.c
add a2dp related Kconfig:
BT_AVDTP_RTP_VERSION, BT_A2DP_SOURCE and BT_A2DP_SINK
a2dp_codec_sbc.c/h are used to provide some APIs to get
A2DP SBC codec information. (like: channel num).

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-05-28 12:56:42 +02:00
Babak Arisian b0dceffacc Bluetooth: Audio: add bt_audio_get_chan_count
Implement a function bt_audio_get_chan_count that takes an enum
bt_audio_location and returns the number of channels in that value.

This PR fixes #69617
(https://github.com/zephyrproject-rtos/zephyr/issues/69617)

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-05-24 09:55:37 -05:00
Ping Wang 1339ce4bf0 Bluetooth: Audio: Get function for bt_audio_codec_qos_pref.
Get the preferred QoS settings via bt_bap_ep_get_info()
Therefore no need to use the internal header file to get it.

This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/72359

Signed-off-by: Ping Wang <pinw@demant.com>
2024-05-24 08:04:45 -04:00
Aleksander Wasaznik a530010fe2 Bluetooth: Remove useless field init_credits
Remove `bt_l2cap_le_endpoint.init_credits` that has zero uses and is
just taking up RAM for no reason.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-21 16:45:50 -04:00
Aleksander Wasaznik 442f208cb3 Bluetooth: Add BT_LE_ADV_CONN_ONE_TIME
The adv auto resume feature is planned for deprecation. This new define
is the new default applications should use.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-20 15:16:03 +01:00
Emil Gydesen 7c96743fae Bluetooth: ISO: Upgrade from experimental to unstable
The ISO API and implementation have existed in Zephyr
for several years, and while not fully qualified, stable
or tested yet, it's not experimental anymore (and have
not been for a long time).

This commit removes any references to it being experimental
and instead defines it as unstable by setting the version to
> 0.1.0. 0.8.0 is being used as the initial version, as that
is what other unstable modules was defined to have as their
initial version if they were not stable (>= 1.0.0).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:54:31 +03:00
Emil Gydesen fcf089574d Bluetooth: ISO: Guard sec_level for iso_chan with unicast
The required_sec_level is only valid for unicast iso channels.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:54:19 +03:00
Emil Gydesen f58ac3476f Bluetooth: CAP: Add reference to the set member for CAP discover
Since the CSIP API expects a set member struct for nearly all
functionality, the reference to the full set member (along with
the CAS specific CSIS) should be given to the application.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:51:26 +03:00
Emil Gydesen c547079cc2 Bluetooth: Audio: Upgrade from experimental to unstable
This commit upgrades the LE audio API and implementation
from experimental to unstable.

LE Audio have existing for quite a few years in Zephyr
and is not going anywhere, but at the same time it still
has significant effort remaining before it can be
considered stable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-17 14:33:39 +02:00
Lyle Zhu 615fe2466b Bluetooth: RFCOMM: Kconfig: Add configure BT_RFCOMM_DLC_STACK_SIZE
The default stack size of RFCOMM DLC is 256.
The default value is sufficient for basic operation.

If more stack space is used (such as call function printk)
in context of callback disconnected of RFCOMM DLC, the
default stack size is not sufficient.

Add a configuration BT_RFCOMM_DLC_STACK_SIZE to configure
the RFCOMM DLC stack size.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 514c78546c include: Bluetooth: Add BT COD macros to hci_types.h
Add macros to get Major Service Classes, Major Device
Class and Minor Device Class.

Define Major Device Class code.
Define Minor Device Class field for Computer Major
Class.
Define Minor Device Class field for Phone Major Class.
Define Minor Device Class field for Audio/Video Major
Class.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 84144c6833 Bluetooth: HFP_AG: Initialize HFP AG
Implement basic functions for HFP AG.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Emil Gydesen a6a14360a9 Bluetooth: BAP: Remove err from recv_state_removed callback
The callback is only ever called when we received a
notification from the BASS server that the receive state is
removed, which cannot contain an error code.
Thus it does not make sense for the callback to have an
error code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-15 14:57:20 +02:00
Vinayak Kariappa Chettimada 3997479b49 Bluetooth: HCI: Rename to bt_hci_iso_sdu_hdr and bt_hci_iso_sdu_ts_hdr
Rename struct bt_hci_iso_data_hdr to bt_hci_iso_sdu_hdr, and
struct bt_hci_iso_ts_data_hdr to bt_hci_iso_sdu_ts_hdr.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-10 15:02:10 +02:00
Andries Kruithof 6a0cdb4eaa Bluetooth: CAP: Commander Reception start procedure
Add the CAP commander reception start procedure which starts reception
on one or more CAP acceptors

With the implementation of broadcast reception start procedure we also need
some mockups for unit testing

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-05-07 09:34:01 +02:00
Pieter De Gendt f147a5fec2 spelling: Replace occurrences of "iff" with "if and only if"
Spell checking tools do not recognize "iff", replace with "if and only if".
See https://en.wikipedia.org/wiki/If_and_only_if

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-05-06 14:58:08 +01:00
Emil Gydesen 49d6b6bc0e Bluetooth: Fix spelling in some public header files
Fixes a few spelling mistakes

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-04 15:21:52 +01:00
Omkar Kulkarni 11eed84775 Bluetooth: Mesh: Update models metadata API
This commit updates models metadata API to simplify the usage and
removes the metadata pointer in health server model context.

Signed-off-by: Omkar Kulkarni <omkar.kulkarni@nordicsemi.no>
2024-05-01 10:54:50 -04:00
Pisit Sawangvonganan 3d39926f94 bluetooth: hci: refactored bluetooth hci packet type indicators
Introduced a unified definition for HCI packet type indicators in
'bluetooth/hci_types.h. This change streamlines the code in
'drivers/bluetooth/hci/', reducing redundancy.
Enhances maintainability and consistency across all HCI drivers.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-05-01 10:33:12 +02:00
Johan Hedberg d590bcb5e0 Bluetooth: Remove BT_HCI_RESERVE and BT_HCI_RAW_RESERVE
In most cases these were defined as 1. Saving one byte for the rest
doesn't really justify the added complexity that comes with these
options. Removing them also simplifies the interface between HCI
transports/drivers and the host stack, which in turn helps pave the way
for having HCI as a proper Zephyr driver API.

Fixes #71907

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-04-29 11:01:27 +02:00
Théo Battrel 909ad8170c Bluetooth: Host: Deprecate auto name in AD
Deprecate the advertiser options `BT_LE_ADV_OPT_USE_NAME` and
`BT_LE_ADV_OPT_FORCE_NAME_IN_AD`.

Reasons:

- It is out of place in the advertiser options, as it acts on
  advertising data and not configuration
- The behavior is not clear. All of these are trick questions:
  - where does the data for the name go?
  - do I have to allocate memory for this?
  - does it work the same in legacy vs extended advertising?
- The trade-off between UX improvement and extra complexity in the host
  is debatable. Hundreds of lines in the stack to avoid making the user
  type out less than ten.

Also deprecate the following macros that uses those options:

- `BT_LE_ADV_CONN_NAME`
- `BT_LE_ADV_CONN_NAME_AD`
- `BT_LE_ADV_NCONN_NAME`
- `BT_LE_EXT_ADV_CONN_NAME`
- `BT_LE_EXT_ADV_SCAN_NAME`
- `BT_LE_EXT_ADV_NCONN_NAME`
- `BT_LE_EXT_ADV_CODED_NCONN_NAME`

Update the migration guide and the release note for Zephyr 3.7 to
describe those changes.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-04-23 12:42:24 +02:00
Théo Battrel 93fde589af Bluetooth: Host: Add new advertiser params macro
With the deprecation of the advertiser options to automatically add the
device name in the scan response and advertising data, some macro used
to set the advertiser parameter also became deprecated. That's the case
for `BT_LE_EXT_ADV_CONN_NAME` and `BT_LE_EXT_ADV_SCAN_NAME`. The issue
is that those two macro didn't had their equivalent without including
the name. So this commit add `BT_LE_EXT_ADV_CONN` and
`BT_LE_EXT_ADV_SCAN` to be used instead.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-04-23 12:42:24 +02:00
Rubin Gerritsen 1d33322ce1 bluetooth: Document periodic advertising interval unit
It was not possible to see what unit was used for periodic
advertising interval in the scan recv callback without digging
deep into the code.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-04-17 14:34:23 +02:00
Jonathan Rico 43de309b3e Bluetooth: l2cap: Remove (net/buf) frag support
It's needless complexity, and the terminology clashes with
Bluetooth (HCI frags).

It has one user, IPSP, that is going away soon.

Removing frag support will allow a future optimization, removing the
need for HCI and L2CAP fragment buffer pools, saving memory.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-04-11 14:40:32 +02:00
Rubin Gerritsen 75973852bf Bluetooth: Audio: Add iso_chan to bt_bap_ep_info
By exposing the underlying iso channel, the application can retrieve
properties of the iso channel.

This can be useful in case the application wants to use the connection
handle for vendor specific HCI commands or to retrieve the particular
parameters used for the given channel.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-04-11 10:33:42 +02:00
Emil Gydesen 5ab37692c0 Bluetooth: CAP: Commander change microphone mute procedure
Adds the CAP Commander Change Microphone Mute procedure.
This procedure changes the microphone mute state on one or more
CAP Acceptors.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-04-05 12:21:38 +02:00
Aleksander Wasaznik 3d3b5b5a48 Bluetooth: hci_driver.h: Remove bt_recv_prio
Remove `bt_recv_prio` from the HCI driver interface. It's primary
purpose was to be used in conjunction with `CONFIG_BT_RECV_BLOCKING`,
which has been removed.

`hci_raw.c` provided a adapter implementation to make drivers
implementing the `CONFIG_BT_RECV_BLOCKING` interface useable with
`CONFIG_BT_HCI_RAW`. But since `bt_recv_prio` is being removed from the
HCI driver interface, drivers needing the adapter should copy the
adapter implementation as private internals.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-03-26 11:17:29 -05:00
Sungwoo Kim 2ca179c96e Bluetooth: Host: Add a validation for hci_le_read_max_data_len()
Check max_tx_octects and max_tx_time are in the valid range, according
to the BT Core spec 5.4 [Vol 4, Part E, 7.8.46]
Fix #70472

Signed-off-by: Sungwoo Kim <iam@sung-woo.kim>
2024-03-26 09:30:11 +00:00
Luis Ubieda f6b1b24a50 bluetooth: services: nus: Add Nordic UART Service
NUS is implemented as a Bluetooth LE service, exchanging data treating
the NUS characteristics as Serial endpoints: RX characteristic to
receive, TX characteristic to send binary packets.

This implementation also enables the ability to define multiple
instances of the NUS Service, analogous to mutliple serial endpoints,
to use each one for different purposes. Unless disabled through Kconfig,
NUS instantiates a default instance, similar to what other services do,
which allows users not interested in using multiple instances, to not
worry about the inherent complexities.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-03-22 10:25:37 +01:00
Ederson de Souza 28d08ada28 include/zephyr: Add 'version' and 'since' tag to groups
Based on information from doc/develop/api/overview.rst, add current
version for some groups representing APIs, following the following
table:

  - Experimental:   0.1.0
  - Unstable:       0.8.0
  - Stable:         1.0.0

Also based on doc/develop/api/overview.rst, add 'since' tag to the
groups.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-03-19 13:13:45 +01:00
Lyle Zhu faeb9bf681 Bluetooth: Host: Add SCO Connect notify for HFP
Call bt_sco_server_register to register SCO
server. Manage the SCO connection request.
Get SCO connect/disconnect status via SCO
channel ops.

Notify the uppper layer of the SCO connection
status changes through bt_hfp_hf_cb::
sco_connected and bt_hfp_hf_cb::
sco_disconnected.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-03-19 10:08:27 +01:00
Lyle Zhu ce154b94d0 Bluetooth: Host: Add SCO connection management
Currently, SCO connections and disconnections
are agnostic to upper-layer.

Add two functions, bt_sco_connected and
bt_sco_disconnected, to notify the SCO
connect changes.

For Central side, pass "struct bt_sco_chan"
object when calling bt_conn_create_sco. it
uses to manage the SCO channel for upper-
layer.

For Peripheral side, two functions
bt_sco_server_register and
bt_sco_server_unregister are added to monitor
SCO connection request for upper-layer. The
upper-layer could accept or reject SCO connect
When the connection request received. If the
connect is accepted, the "struct bt_sco_chan"
object could be passed by "sco_server->accept".

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-03-19 10:08:27 +01:00
Emil Gydesen 62ac753a61 Bluetooth: CAP: Fix issue with codec_cfg in CAP uni start
The codecs used for the bap bt_bap_stream_config was only
valid for the lifetime of the procedure, which meant
that by the end of the procedure the stream->codec_cfg
became invalid.

This is fixed by using the pointer provided to the
CAP API, and documentating the lifetime of the codec_cfg.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-03-19 09:47:13 +01:00
Rubin Gerritsen 7c2f26bd2a Bluetooth: Host: Add macros for contiuous scanner
It is often desired to maximize the chances of receiving advertising
when scanning. To achieve this, the scanner should be enabled all the time.

Some controller implementations (like Nordic's SoftDevice Controller)
handle scheduling differently when scan_window = scan_interval.
Having a macro that defines this scanning configuration simplifies
writing applications.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-03-14 17:03:44 -05:00
Emil Gydesen fa6a7c1b77 Bluetooth: CAP: Commander change microphone gain procedure
Adds the CAP Commander Change Microphone Gain procedure.
This procedure changes the microphone gain on one or more
CAP Acceptors.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-03-12 17:56:09 +00:00
Lyle Zhu cb3d1c9ee9 Bluetooth: RFCOMM: Add data sent cb for RFCOMM
Currently, the upper layer cannot know
whether the data is successfully sent
through DLC.

Add a field "sent" for RFCOMM DLC ops.
Notify upper-layer of the sending
result through the field "sent".

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-03-12 09:45:27 +00:00
Nithin Ramesh Myliattil 6ce38c1aa7 bluetooth: id: fix adv sets with same id use different RPA
The fix is to check if any of the adv set's rpa expired
callback returns false, then all adv sets continues with
the old RPA.

Note: Fix is applicable only to adv sets which shares the
same id.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
2024-03-11 14:24:41 +01:00
Aleksandr Khromykh aa87ed5d8a Bluetooth: Mesh: make models metadata const
Commit adds const qualifier to models metadata.
Specification claims: Composition Metadata Page 0
shall not change during a term of a node on the network.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-03-11 09:26:12 +01:00
Emil Gydesen 913ca370c7 Bluetooth: BAP: Add input validation for bt_bap_ep_get_info
The function did not have a NULL check for the parameters,
and thus did not fail correctly on invalid input.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-03-09 16:13:24 +01:00
Chang An 3605d57ae1 LE Audio: bt_bap_broadcast_sink_cb.syncable should provide the BIGInfo
Modify bt_bap_broadcast_sink_cb.syncable to provide the BIGInfo
instead of just the encryption field.

Signed-off-by: Chang An <chang.an_1@nxp.com>
2024-03-07 11:09:12 +00:00
Aleksandr Khromykh b764cf0b07 Bluetooth: Mesh: fixed health srv metadata id
Assigned Numbers document
4.3.6 Mesh Metadata Identifiers
0x0000 - Health Tests Information

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2024-03-07 10:58:53 +00:00
Emil Gydesen a472133587 Bluetooth: BAP: Apply missing guards for Kconfig values
Some pieces of code were missing proper guards for Kconfig
values, which could cause compile issues

The massive amount of #if in bap.c clearly indicates that the
file should be split, as it contains many things that are specific
for various roles.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-03-07 10:58:32 +00:00
Andries Kruithof 7540535284 Bluetooth: audio: BAP: allow for multiple callbacks
The existing implementation allows for only one callback per procedure.
This creates problems when for example adding CAP functionality.
The callbacks are here implemented as an SLIST

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-03-07 10:58:10 +00:00
Lyle Zhu 40cf23daff Bluetooth: Rename BT_BREDR to BT_CLASSIC
Rename BT_BREDR to BT_CLASSIC
Rename CONFIG_BT_BREDR to CONFIG_BT_CLASSIC

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-03-07 11:26:45 +02:00
Lyle Zhu 83bfa4c91b Bluetooth: Host: Move BR headers to subfolder classic
Move BR/EDR header files from "include/zephyr/
bluetooth" to subfolder "include/zephyr/bluetooth/
classic".

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-03-07 11:26:45 +02:00
Anders Storrø 6af7ad5a52 Bluetooth: Mesh: Prevent duplicate cdb appkeys
Fixes issue where it is possible to store the same appkey
multiple times in CDB implementation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-03-06 10:21:27 +00:00
Emil Gydesen 6976ad82ea Bluetooth: BAP: Add can_recv to bt_bap_ep_info
Similar to the can_send, the can_recv field indicates whether
or not this endpoint can receive data.

This commit also slightly refactors and optimized how the
can_send field is set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-03-04 14:05:07 +01:00
Emil Gydesen 689e3216fc Bluetooth: BAP: Add bt_bap_base_subgroup_get_bis_indexes
Add bt_bap_base_subgroup_get_bis_indexes that gets the BIS indexes
of a subgroup. This work very similar to
bt_bap_base_get_bis_indexes, except that it works for subgroups
rather than BASEs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-02-27 14:46:33 +01:00
Herman Berget 9135de7a66 Bluetooth: hci: Add hw variant definitions for nrf54H/L
Assign new numbers for new soc series and update string
conversion function.

Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
2024-02-27 14:43:07 +01:00