Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c5f522f
[nrf fromtree] bluetooth: host: smp: fix deadlock when public key gen…
PavelVPV Feb 11, 2025
93101a6
[nrf fromtree] Bluetooth: Host: drop deprecated BT_LE_SCAN_OPT_FILTER…
kartben Feb 17, 2025
d561d91
[nrf fromtree] Bluetooth: host: Fix bug in scan start
jthm-ot Feb 18, 2025
0e5d43b
[nrf fromtree] Bluetooth: Host: Remove nested allocation of HCI comma…
cvinayak Jan 13, 2025
3e79c8a
[nrf fromtree] Bluetooth: Host: improve GATT documentation
KyraLengfeld Feb 26, 2025
a75e2f1
[nrf fromtree] Bluetooth: Host: Fix deadlock when failing to alloc on…
KyraLengfeld Feb 27, 2025
be4811d
[nrf fromtree] Bluetooth: GATT: Change get_handle function of find_by…
Thalley Jan 14, 2025
55f05d8
[nrf fromtree] Bluetooth: Host: Improve more GATT documentation
HaavardRei Feb 28, 2025
7037f59
[nrf fromtree] Bluetooth: Host: improve more² GATT documentation
KyraLengfeld Mar 3, 2025
82843cb
[nrf fromtree] Bluetooth: Host: Add API for reading LE controller fea…
Thalley Feb 20, 2025
bfbe4b3
[nrf fromtree] drivers: bluetooth: hci_nxp: fix nomem handling
axelnxp Feb 24, 2025
c7f5381
[nrf fromtree] drivers: bluetooth: hci_nxp: fix unexpected command co…
axelnxp Feb 21, 2025
8c875cd
[nrf fromtree] drivers: Bluetooth: nxp: not power off BLE controller …
zhaynxp Feb 28, 2025
2b21bd4
[nrf fromtree] bluetooth: host: perform hci-reset in bt_disable()
nirav-agrawal Mar 5, 2025
bd116b6
[nrf fromtree] Bluetooth: Host: improve GATT documentation
KyraLengfeld Mar 10, 2025
ec0fbf0
[nrf fromtree] Bluetooth: Host: Improve bluetooth documentation
KyraLengfeld Mar 12, 2025
a8d72a1
[nrf fromtree] bluetooth: host: ecc: Change log level debug
PavelVPV Mar 4, 2025
6eca7ac
[nrf fromtree] Bluetooth: Host: Remove experimental label from PAwR
hermabe Mar 12, 2025
b25fe3a
[nrf fromtree] bluetooth: host: Remove experimental flag from LE Conn…
weeTike Mar 13, 2025
f0f398b
[nrf fromtree] Bluetooth: Host: ATT: Fix build warning with clang
aescolar Mar 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions doc/connectivity/bluetooth/api/gatt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
Generic Attribute Profile (GATT)
################################

GATT layer manages the service database providing APIs for service registration
and attribute declaration.
The GATT layer manages the service database providing APIs for service
registration and attribute declaration.

Services can be registered using :c:func:`bt_gatt_service_register` API
The GATT Client initiates commands and requests towards the GATT Server, and can
receive responses, indications and notifications sent by the server. It is
enabled through the configuration option:
:kconfig:option:`CONFIG_BT_GATT_CLIENT`

The GATT Server accepts incoming commands and requests from the GATT Client, and
sends responses, indications and notifications to the client.

Services can be registered using the :c:func:`bt_gatt_service_register` API
which takes the :c:struct:`bt_gatt_service` struct that provides the list of
attributes the service contains. The helper macro :c:macro:`BT_GATT_SERVICE()`
can be used to declare a service.
Expand Down Expand Up @@ -61,9 +69,6 @@ pass a callback to be called when it is necessary to know the exact instant when
the data has been transmitted over the air. Indications are supported by
:c:func:`bt_gatt_indicate` API.

Client procedures can be enabled with the configuration option:
:kconfig:option:`CONFIG_BT_GATT_CLIENT`

Discover procedures can be initiated with the use of
:c:func:`bt_gatt_discover` API which takes the
:c:struct:`bt_gatt_discover_params` struct which describes the type of
Expand Down
8 changes: 8 additions & 0 deletions doc/releases/release-notes-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ New APIs and options
like you need to add more details, add them in the API documentation code
instead.

* Bluetooth

* Host

* :c:func:`bt_le_get_local_features`

* LE Connection Subrating is no longer experimental.

New Boards
**********

Expand Down
48 changes: 19 additions & 29 deletions drivers/bluetooth/hci/hci_nxp.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 NXP
* Copyright 2023-2025 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -79,7 +79,8 @@ LOG_MODULE_REGISTER(bt_driver);
/* Private functions */
/* -------------------------------------------------------------------------- */

#if defined(CONFIG_HCI_NXP_ENABLE_AUTO_SLEEP) || defined(CONFIG_HCI_NXP_SET_CAL_DATA)
#if defined(CONFIG_HCI_NXP_ENABLE_AUTO_SLEEP) || defined(CONFIG_HCI_NXP_SET_CAL_DATA) ||\
defined(CONFIG_BT_HCI_SET_PUBLIC_ADDR)
static int nxp_bt_send_vs_command(uint16_t opcode, const uint8_t *params, uint8_t params_len)
{
if (IS_ENABLED(CONFIG_BT_HCI_HOST)) {
Expand All @@ -101,7 +102,7 @@ static int nxp_bt_send_vs_command(uint16_t opcode, const uint8_t *params, uint8_
return 0;
}
}
#endif /* CONFIG_HCI_NXP_ENABLE_AUTO_SLEEP || CONFIG_HCI_NXP_SET_CAL_DATA */
#endif

#if defined(CONFIG_HCI_NXP_ENABLE_AUTO_SLEEP)
static int nxp_bt_enable_controller_autosleep(void)
Expand Down Expand Up @@ -170,7 +171,10 @@ static int bt_nxp_set_mac_address(const bt_addr_t *public_addr)
uint8_t addrOUI[BD_ADDR_OUI_PART_SIZE] = {BD_ADDR_OUI};
uint8_t uid[16] = {0};
uint8_t uuidLen;
uint8_t hciBuffer[12];
uint8_t params[HCI_CMD_BT_HOST_SET_MAC_ADDR_PARAM_LENGTH] = {
BT_USER_BD,
0x06U
};

/* If no public address is provided by the user, use a unique address made
* from the device's UID (unique ID)
Expand All @@ -190,18 +194,12 @@ static int bt_nxp_set_mac_address(const bt_addr_t *public_addr)
bt_addr_copy((bt_addr_t *)bleDeviceAddress, public_addr);
}

hciBuffer[0] = BT_HCI_H4_CMD;
memcpy((void *)&hciBuffer[1], (const void *)&opcode, 2U);
/* Set HCI parameter length */
hciBuffer[3] = HCI_CMD_BT_HOST_SET_MAC_ADDR_PARAM_LENGTH;
/* Set command parameter ID */
hciBuffer[4] = BT_USER_BD;
/* Set command parameter length */
hciBuffer[5] = (uint8_t)6U;
memcpy(hciBuffer + 6U, (const void *)bleDeviceAddress,
BD_ADDR_UUID_PART_SIZE + BD_ADDR_OUI_PART_SIZE);
memcpy(&params[2], (const void *)bleDeviceAddress,
BD_ADDR_UUID_PART_SIZE + BD_ADDR_OUI_PART_SIZE);

/* Send the command */
return PLATFORM_SendHciMessage(hciBuffer, 12U);
return nxp_bt_send_vs_command(opcode, params,
HCI_CMD_BT_HOST_SET_MAC_ADDR_PARAM_LENGTH);
}
#endif /* CONFIG_BT_HCI_SET_PUBLIC_ADDR */

Expand Down Expand Up @@ -368,19 +366,23 @@ K_THREAD_DEFINE(nxp_hci_rx_thread, CONFIG_BT_DRV_RX_STACK_SIZE, bt_rx_thread, NU
static void hci_rx_cb(uint8_t packetType, uint8_t *data, uint16_t len)
{
struct hci_data hci_rx_frame;
int ret;

hci_rx_frame.packetType = packetType;
hci_rx_frame.data = k_malloc(len);

if (!hci_rx_frame.data) {
LOG_ERR("Failed to allocate RX buffer");
return;
}

memcpy(hci_rx_frame.data, data, len);
hci_rx_frame.len = len;

if (k_msgq_put(&rx_msgq, &hci_rx_frame, K_NO_WAIT) < 0) {
LOG_ERR("Failed to push RX data to message queue");
ret = k_msgq_put(&rx_msgq, &hci_rx_frame, K_NO_WAIT);
if (ret < 0) {
LOG_ERR("Failed to push RX data to message queue: %d", ret);
k_free(hci_rx_frame.data);
}
}

Expand Down Expand Up @@ -505,19 +507,7 @@ static int bt_nxp_close(const struct device *dev)
{
struct bt_nxp_data *hci = dev->data;
int ret = 0;
/* Reset the Controller */
if (IS_ENABLED(CONFIG_BT_HCI_HOST)) {
ret = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, NULL);
if (ret) {
LOG_ERR("Failed to reset BLE controller");
}
k_sleep(K_SECONDS(1));

ret = PLATFORM_TerminateBle();
if (ret < 0) {
LOG_ERR("Failed to shutdown BLE controller");
}
}
hci->recv = NULL;

return ret;
Expand Down
9 changes: 1 addition & 8 deletions drivers/bluetooth/hci/ipc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2019 Nordic Semiconductor ASA
* Copyright 2025 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -372,14 +373,6 @@ static int bt_ipc_close(const struct device *dev)
struct ipc_data *ipc = dev->data;
int err;

if (IS_ENABLED(CONFIG_BT_HCI_HOST)) {
err = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, NULL);
if (err) {
LOG_ERR("Sending reset command failed with: %d", err);
return err;
}
}

err = ipc_service_deregister_endpoint(&ipc->hci_ept);
if (err) {
LOG_ERR("Deregistering HCI endpoint failed with: %d", err);
Expand Down
95 changes: 93 additions & 2 deletions include/zephyr/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@

/**
* @brief Bluetooth APIs
* @details The Bluetooth Subsystem Core APIs provide essential functionalities
* to use and manage Bluetooth based communication. These APIs include
* APIs for Bluetooth stack initialization, device discovery,
* connection management, data transmission, profiles and services.
* These APIs support both classic Bluetooth and Bluetooth Low Energy
* (LE) operations.
* @defgroup bluetooth Bluetooth APIs
* @ingroup connectivity
* @{
*/

#include <stdbool.h>
#include <stdint.h>
#include <string.h>

#include <zephyr/sys/util.h>
Expand All @@ -34,6 +41,13 @@ extern "C" {

/**
* @brief Generic Access Profile (GAP)
* @details The Generic Access Profile (GAP) defines fundamental Bluetooth
* operations, including device discovery, pairing, and connection
* management. Zephyr's GAP implementation supports both classic
* Bluetooth and Bluetooth Low Energy (LE) functionalities, enabling
* roles such as Broadcaster, Observer, Peripheral, and Central. These
* roles define the device's behavior in advertising, scanning, and
* establishing connections within Bluetooth networks.
* @defgroup bt_gap Generic Access Profile (GAP)
* @since 1.0
* @version 1.0.0
Expand All @@ -48,6 +62,13 @@ extern "C" {
*/
#define BT_ID_DEFAULT 0

/**
* @brief Number of octets for local supported
*
* The value of 8 correspond to page 0 in the LE Controller supported features
*/
#define BT_LE_LOCAL_SUPPORTED_FEATURES_SIZE 8

/** Opaque type representing an advertiser. */
struct bt_le_ext_adv;

Expand Down Expand Up @@ -517,6 +538,78 @@ size_t bt_data_get_len(const struct bt_data data[], size_t data_count);
*/
size_t bt_data_serialize(const struct bt_data *input, uint8_t *output);

struct bt_le_local_features {
/**
* @brief Local LE controller supported features.
*
* Refer to BT_LE_FEAT_BIT_* for values.
* Refer to the BT_FEAT_LE_* macros for value comparionson.
* See Bluetooth Core Specification, Vol 6, Part B, Section 4.6.
*/
uint8_t features[BT_LE_LOCAL_SUPPORTED_FEATURES_SIZE];

/**
* @brief Local LE controller supported states
*
* Refer to BT_LE_STATES_* for values.
* See Bluetooth Core Specification 6.0, Vol 4, Part E, Section 7.8.27
*/
uint64_t states;

/**
* @brief ACL data packet length
*
* This represents the maximum ACL HCI Data packet which can be sent from the Host to the
* Controller.
* The Host may support L2CAP and ATT MTUs larger than this value.
* See Bluetooth Core Specification, Vol 6, Part E, Section 7.8.2.
*/
uint16_t acl_mtu;
/** Total number of ACL data packets */
uint8_t acl_pkts;

/**
* @brief ISO data packet length
*
* This represents the maximum ISO HCI Data packet which can be sent from the Host to the
* Controller.
* ISO SDUs above this size can be fragmented assuming that the number of
* @ref bt_le_local_features.iso_pkts support the maximum size.
*/
uint16_t iso_mtu;
/** Total number of ISO data packets */
uint8_t iso_pkts;

/**
* @brief Maximum size of the controller resolving list.
*
* See Bluetooth Core Specification, Vol 6, Part E, Section 7.8.41.
*/
uint8_t rl_size;

/**
* @brief Maximum advertising data length
*
* @note The maximum advertising data length also depends on advertising type.
*
* See Bluetooth Core Specification, Vol 6, Part E, Section 7.8.57.
*/
uint16_t max_adv_data_len;
};

/**
* @brief Get local Bluetooth LE controller features
*
* Can only be called after bt_enable()
*
* @param local_features Local features struct to be populated with information.
*
* @retval 0 Success
* @retval -EAGAIN The information is not yet available.
* @retval -EINVAL @p local_features is NULL.
*/
int bt_le_get_local_features(struct bt_le_local_features *local_features);

/** Advertising options */
enum {
/** Convenience value when no options are specified. */
Expand Down Expand Up @@ -2169,8 +2262,6 @@ enum {
BT_LE_SCAN_OPT_NO_1M = BIT(3),
};

#define BT_LE_SCAN_OPT_FILTER_WHITELIST __DEPRECATED_MACRO BT_LE_SCAN_OPT_FILTER_ACCEPT_LIST

enum {
/** Scan without requesting additional information from advertisers. */
BT_LE_SCAN_TYPE_PASSIVE = 0x00,
Expand Down
Loading