Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
|
Data Structures | |
struct | bt_gatt_ccc_cfg |
GATT CCC configuration entry. More... | |
struct | bt_gatt_notify_params |
struct | bt_gatt_indicate_params |
GATT Indicate Value parameters. More... | |
Macros | |
#define | BT_GATT_SERVICE_DEFINE(_name, ...) |
Statically define and register a service. | |
#define | BT_GATT_SERVICE_INSTANCE_DEFINE( _name, _instances, _instance_num, _attrs_def) |
Statically define service structure array. | |
#define | BT_GATT_SERVICE(_attrs) |
Service Structure Declaration Macro. | |
#define | BT_GATT_PRIMARY_SERVICE(_service) |
Primary Service Declaration Macro. | |
#define | BT_GATT_SECONDARY_SERVICE(_service) |
Secondary Service Declaration Macro. | |
#define | BT_GATT_INCLUDE_SERVICE(_service_incl) |
Include Service Declaration Macro. | |
#define | BT_GATT_CHRC_INIT(_uuid, _handle, _props) |
#define | BT_GATT_CHARACTERISTIC(_uuid, _props, _perm, _read, _write, _user_data) |
Characteristic and Value Declaration Macro. | |
#define | BT_GATT_CCC_MAX 0 |
#define | BT_GATT_CCC_INITIALIZER(_changed, _write, _match) |
Initialize Client Characteristic Configuration Declaration Macro. | |
#define | BT_GATT_CCC_MANAGED(_ccc, _perm) |
Managed Client Characteristic Configuration Declaration Macro. | |
#define | BT_GATT_CCC(_changed, _perm) |
Client Characteristic Configuration Declaration Macro. | |
#define | BT_GATT_CEP(_value) |
Characteristic Extended Properties Declaration Macro. | |
#define | BT_GATT_CUD(_value, _perm) |
Characteristic User Format Descriptor Declaration Macro. | |
#define | BT_GATT_CPF(_value) |
Characteristic Presentation Format Descriptor Declaration Macro. | |
#define | BT_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _user_data) |
Descriptor Declaration Macro. | |
#define | BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data) |
Attribute Declaration Macro. | |
Typedefs | |
typedef uint8_t(* | bt_gatt_attr_func_t) (const struct bt_gatt_attr *attr, uint16_t handle, void *user_data) |
Attribute iterator callback. | |
typedef void(* | bt_gatt_complete_func_t) (struct bt_conn *conn, void *user_data) |
Notification complete result callback. | |
typedef void(* | bt_gatt_indicate_func_t) (struct bt_conn *conn, struct bt_gatt_indicate_params *params, uint8_t err) |
Indication complete result callback. | |
typedef void(* | bt_gatt_indicate_params_destroy_t) (struct bt_gatt_indicate_params *params) |
Enumerations | |
enum | { BT_GATT_ITER_STOP = 0 , BT_GATT_ITER_CONTINUE } |
Functions | |
static const char * | bt_gatt_err_to_str (int gatt_err) |
Converts a GATT error to string. | |
void | bt_gatt_cb_register (struct bt_gatt_cb *cb) |
Register GATT callbacks. | |
int | bt_gatt_authorization_cb_register (const struct bt_gatt_authorization_cb *cb) |
Register GATT authorization callbacks. | |
int | bt_gatt_service_register (struct bt_gatt_service *svc) |
Register GATT service. | |
int | bt_gatt_service_unregister (struct bt_gatt_service *svc) |
Unregister GATT service. | |
bool | bt_gatt_service_is_registered (const struct bt_gatt_service *svc) |
Check if GATT service is registered. | |
void | bt_gatt_foreach_attr_type (uint16_t start_handle, uint16_t end_handle, const struct bt_uuid *uuid, const void *attr_data, uint16_t num_matches, bt_gatt_attr_func_t func, void *user_data) |
Attribute iterator by type. | |
static void | bt_gatt_foreach_attr (uint16_t start_handle, uint16_t end_handle, bt_gatt_attr_func_t func, void *user_data) |
Attribute iterator. | |
struct bt_gatt_attr * | bt_gatt_attr_next (const struct bt_gatt_attr *attr) |
Iterate to the next attribute. | |
struct bt_gatt_attr * | bt_gatt_find_by_uuid (const struct bt_gatt_attr *attr, uint16_t attr_count, const struct bt_uuid *uuid) |
Find Attribute by UUID. | |
uint16_t | bt_gatt_attr_get_handle (const struct bt_gatt_attr *attr) |
Get Attribute handle. | |
uint16_t | bt_gatt_attr_value_handle (const struct bt_gatt_attr *attr) |
Get the handle of the characteristic value descriptor. | |
ssize_t | bt_gatt_attr_read (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t buf_len, uint16_t offset, const void *value, uint16_t value_len) |
Generic Read Attribute value helper. | |
ssize_t | bt_gatt_attr_read_service (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
Read Service Attribute helper. | |
ssize_t | bt_gatt_attr_read_included (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
Read Include Attribute helper. | |
ssize_t | bt_gatt_attr_read_chrc (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
Read Characteristic Attribute helper. | |
ssize_t | bt_gatt_attr_read_ccc (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
Read Client Characteristic Configuration Attribute helper. | |
ssize_t | bt_gatt_attr_write_ccc (struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) |
Write Client Characteristic Configuration Attribute helper. | |
ssize_t | bt_gatt_attr_read_cep (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
Read Characteristic Extended Properties Attribute helper. | |
ssize_t | bt_gatt_attr_read_cud (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
Read Characteristic User Description Descriptor Attribute helper. | |
ssize_t | bt_gatt_attr_read_cpf (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
Read Characteristic Presentation format Descriptor Attribute helper. | |
int | bt_gatt_notify_cb (struct bt_conn *conn, struct bt_gatt_notify_params *params) |
Notify attribute value change. | |
int | bt_gatt_notify_multiple (struct bt_conn *conn, uint16_t num_params, struct bt_gatt_notify_params params[]) |
Send multiple notifications in a single PDU. | |
static int | bt_gatt_notify (struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *data, uint16_t len) |
Notify attribute value change. | |
static int | bt_gatt_notify_uuid (struct bt_conn *conn, const struct bt_uuid *uuid, const struct bt_gatt_attr *attr, const void *data, uint16_t len) |
Notify attribute value change by UUID. | |
int | bt_gatt_indicate (struct bt_conn *conn, struct bt_gatt_indicate_params *params) |
Indicate attribute value change. | |
bool | bt_gatt_is_subscribed (struct bt_conn *conn, const struct bt_gatt_attr *attr, uint16_t ccc_type) |
Check if connection have subscribed to attribute. | |
uint16_t | bt_gatt_get_mtu (struct bt_conn *conn) |
Get ATT MTU for a connection. | |
uint16_t | bt_gatt_get_uatt_mtu (struct bt_conn *conn) |
Get Unenhanced ATT (UATT) MTU for a connection. | |
#define BT_GATT_ATTRIBUTE | ( | _uuid, | |
_perm, | |||
_read, | |||
_write, | |||
_user_data ) |
#include <zephyr/bluetooth/gatt.h>
Attribute Declaration Macro.
Helper macro to declare an attribute.
_uuid | Attribute uuid. |
_perm | Attribute access permissions, a bitmap of bt_gatt_perm values. |
_read | Attribute read callback (bt_gatt_attr_read_func_t). |
_write | Attribute write callback (bt_gatt_attr_write_func_t). |
_user_data | Attribute user data. |
#define BT_GATT_CCC | ( | _changed, | |
_perm ) |
#include <zephyr/bluetooth/gatt.h>
Client Characteristic Configuration Declaration Macro.
Helper macro to declare a CCC attribute.
_changed | Configuration changed callback. |
_perm | CCC access permissions, a bitmap of bt_gatt_perm values. |
#define BT_GATT_CCC_INITIALIZER | ( | _changed, | |
_write, | |||
_match ) |
#include <zephyr/bluetooth/gatt.h>
Initialize Client Characteristic Configuration Declaration Macro.
Helper macro to initialize a Managed CCC attribute value.
_changed | Configuration changed callback. |
_write | Configuration write callback. |
_match | Configuration match callback. |
#define BT_GATT_CCC_MANAGED | ( | _ccc, | |
_perm ) |
#include <zephyr/bluetooth/gatt.h>
Managed Client Characteristic Configuration Declaration Macro.
Helper macro to declare a Managed CCC attribute.
_ccc | CCC attribute user data, shall point to a _bt_gatt_ccc. |
_perm | CCC access permissions, a bitmap of bt_gatt_perm values. |
#define BT_GATT_CCC_MAX 0 |
#include <zephyr/bluetooth/gatt.h>
#define BT_GATT_CEP | ( | _value | ) |
#include <zephyr/bluetooth/gatt.h>
Characteristic Extended Properties Declaration Macro.
Helper macro to declare a CEP attribute.
_value | Pointer to a struct bt_gatt_cep. |
#define BT_GATT_CHARACTERISTIC | ( | _uuid, | |
_props, | |||
_perm, | |||
_read, | |||
_write, | |||
_user_data ) |
#include <zephyr/bluetooth/gatt.h>
Characteristic and Value Declaration Macro.
Helper macro to declare a characteristic attribute along with its attribute value.
_uuid | Characteristic attribute uuid. |
_props | Characteristic attribute properties, a bitmap of BT_GATT_CHRC_* macros. |
_perm | Characteristic Attribute access permissions, a bitmap of bt_gatt_perm values. |
_read | Characteristic Attribute read callback (bt_gatt_attr_read_func_t). |
_write | Characteristic Attribute write callback (bt_gatt_attr_write_func_t). |
_user_data | Characteristic Attribute user data. |
#define BT_GATT_CHRC_INIT | ( | _uuid, | |
_handle, | |||
_props ) |
#include <zephyr/bluetooth/gatt.h>
#define BT_GATT_CPF | ( | _value | ) |
#include <zephyr/bluetooth/gatt.h>
Characteristic Presentation Format Descriptor Declaration Macro.
Helper macro to declare a CPF attribute.
_value | Pointer to a struct bt_gatt_cpf. |
#define BT_GATT_CUD | ( | _value, | |
_perm ) |
#include <zephyr/bluetooth/gatt.h>
Characteristic User Format Descriptor Declaration Macro.
Helper macro to declare a CUD attribute.
_value | User description NULL-terminated C string. |
_perm | Descriptor attribute access permissions, a bitmap of bt_gatt_perm values. |
#define BT_GATT_DESCRIPTOR | ( | _uuid, | |
_perm, | |||
_read, | |||
_write, | |||
_user_data ) |
#include <zephyr/bluetooth/gatt.h>
Descriptor Declaration Macro.
Helper macro to declare a descriptor attribute.
_uuid | Descriptor attribute uuid. |
_perm | Descriptor attribute access permissions, a bitmap of bt_gatt_perm values. |
_read | Descriptor attribute read callback (bt_gatt_attr_read_func_t). |
_write | Descriptor attribute write callback (bt_gatt_attr_write_func_t). |
_user_data | Descriptor attribute user data. |
#define BT_GATT_INCLUDE_SERVICE | ( | _service_incl | ) |
#include <zephyr/bluetooth/gatt.h>
Include Service Declaration Macro.
Helper macro to declare database internal include service attribute.
_service_incl | the first service attribute of service to include |
#define BT_GATT_PRIMARY_SERVICE | ( | _service | ) |
#include <zephyr/bluetooth/gatt.h>
Primary Service Declaration Macro.
Helper macro to declare a primary service attribute.
_service | Service attribute value. |
#define BT_GATT_SECONDARY_SERVICE | ( | _service | ) |
#include <zephyr/bluetooth/gatt.h>
Secondary Service Declaration Macro.
Helper macro to declare a secondary service attribute.
_service | Service attribute value. |
#define BT_GATT_SERVICE | ( | _attrs | ) |
#include <zephyr/bluetooth/gatt.h>
Service Structure Declaration Macro.
Helper macro to declare a service structure.
_attrs | Service attributes. |
#define BT_GATT_SERVICE_DEFINE | ( | _name, | |
... ) |
#include <zephyr/bluetooth/gatt.h>
Statically define and register a service.
Helper macro to statically define and register a service.
_name | Service name. |
#define BT_GATT_SERVICE_INSTANCE_DEFINE | ( | _name, | |
_instances, | |||
_instance_num, | |||
_attrs_def ) |
#include <zephyr/bluetooth/gatt.h>
Statically define service structure array.
Helper macro to statically define service structure array. Each element of the array is linked to the service attribute array which is also defined in this scope using _attrs_def
macro.
_name | Name of service structure array. |
_instances | Array of instances to pass as user context to the attribute callbacks. |
_instance_num | Number of elements in instance array. |
_attrs_def | Macro provided by the user that defines attribute array for the service. This macro should accept single parameter which is the instance context. |
typedef uint8_t(* bt_gatt_attr_func_t) (const struct bt_gatt_attr *attr, uint16_t handle, void *user_data) |
#include <zephyr/bluetooth/gatt.h>
Attribute iterator callback.
attr | Attribute found. |
handle | Attribute handle found. |
user_data | Data given. |
BT_GATT_ITER_CONTINUE
if should continue to the next attribute. BT_GATT_ITER_STOP
to stop. typedef void(* bt_gatt_complete_func_t) (struct bt_conn *conn, void *user_data) |
#include <zephyr/bluetooth/gatt.h>
Notification complete result callback.
conn | Connection object. |
user_data | Data passed in by the user. |
typedef void(* bt_gatt_indicate_func_t) (struct bt_conn *conn, struct bt_gatt_indicate_params *params, uint8_t err) |
#include <zephyr/bluetooth/gatt.h>
Indication complete result callback.
conn | Connection object. |
params | Indication params object. |
err | ATT error code |
typedef void(* bt_gatt_indicate_params_destroy_t) (struct bt_gatt_indicate_params *params) |
#include <zephyr/bluetooth/gatt.h>
anonymous enum |
#include <zephyr/bluetooth/gatt.h>
Enumerator | |
---|---|
BT_GATT_ITER_STOP | |
BT_GATT_ITER_CONTINUE |
uint16_t bt_gatt_attr_get_handle | ( | const struct bt_gatt_attr * | attr | ) |
#include <zephyr/bluetooth/gatt.h>
Get Attribute handle.
attr | An attribute object currently registered in the local ATT server. |
struct bt_gatt_attr * bt_gatt_attr_next | ( | const struct bt_gatt_attr * | attr | ) |
#include <zephyr/bluetooth/gatt.h>
Iterate to the next attribute.
Iterate to the next attribute following a given attribute.
attr | Current Attribute. |
ssize_t bt_gatt_attr_read | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
void * | buf, | ||
uint16_t | buf_len, | ||
uint16_t | offset, | ||
const void * | value, | ||
uint16_t | value_len ) |
#include <zephyr/bluetooth/gatt.h>
Generic Read Attribute value helper.
Read attribute value from local database storing the result into buffer.
conn | Connection object. |
attr | Attribute to read. |
buf | Buffer to store the value. |
buf_len | Buffer length. |
offset | Start offset. |
value | Attribute value. |
value_len | Length of the attribute value. |
ssize_t bt_gatt_attr_read_ccc | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
void * | buf, | ||
uint16_t | len, | ||
uint16_t | offset ) |
#include <zephyr/bluetooth/gatt.h>
Read Client Characteristic Configuration Attribute helper.
Read CCC attribute value from local database storing the result into buffer after encoding it.
conn | Connection object. |
attr | Attribute to read. |
buf | Buffer to store the value read. |
len | Buffer length. |
offset | Start offset. |
ssize_t bt_gatt_attr_read_cep | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
void * | buf, | ||
uint16_t | len, | ||
uint16_t | offset ) |
#include <zephyr/bluetooth/gatt.h>
Read Characteristic Extended Properties Attribute helper.
Read CEP attribute value from local database storing the result into buffer after encoding it.
conn | Connection object |
attr | Attribute to read |
buf | Buffer to store the value read |
len | Buffer length |
offset | Start offset |
ssize_t bt_gatt_attr_read_chrc | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
void * | buf, | ||
uint16_t | len, | ||
uint16_t | offset ) |
#include <zephyr/bluetooth/gatt.h>
Read Characteristic Attribute helper.
Read characteristic attribute value from local database storing the result into buffer after encoding it.
user_data
is a bt_gatt_chrc
.conn | Connection object. |
attr | Attribute to read. |
buf | Buffer to store the value read. |
len | Buffer length. |
offset | Start offset. |
ssize_t bt_gatt_attr_read_cpf | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
void * | buf, | ||
uint16_t | len, | ||
uint16_t | offset ) |
#include <zephyr/bluetooth/gatt.h>
Read Characteristic Presentation format Descriptor Attribute helper.
Read CPF attribute value from local database storing the result into buffer after encoding it.
conn | Connection object |
attr | Attribute to read |
buf | Buffer to store the value read |
len | Buffer length |
offset | Start offset |
ssize_t bt_gatt_attr_read_cud | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
void * | buf, | ||
uint16_t | len, | ||
uint16_t | offset ) |
#include <zephyr/bluetooth/gatt.h>
Read Characteristic User Description Descriptor Attribute helper.
Read CUD attribute value from local database storing the result into buffer after encoding it.
conn | Connection object |
attr | Attribute to read |
buf | Buffer to store the value read |
len | Buffer length |
offset | Start offset |
ssize_t bt_gatt_attr_read_included | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
void * | buf, | ||
uint16_t | len, | ||
uint16_t | offset ) |
#include <zephyr/bluetooth/gatt.h>
Read Include Attribute helper.
Read include service attribute value from local database storing the result into buffer after encoding it.
bt_gatt_include
.conn | Connection object. |
attr | Attribute to read. |
buf | Buffer to store the value read. |
len | Buffer length. |
offset | Start offset. |
ssize_t bt_gatt_attr_read_service | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
void * | buf, | ||
uint16_t | len, | ||
uint16_t | offset ) |
#include <zephyr/bluetooth/gatt.h>
Read Service Attribute helper.
Read service attribute value from local database storing the result into buffer after encoding it.
user_data
is a bt_uuid
.conn | Connection object. |
attr | Attribute to read. |
buf | Buffer to store the value read. |
len | Buffer length. |
offset | Start offset. |
uint16_t bt_gatt_attr_value_handle | ( | const struct bt_gatt_attr * | attr | ) |
#include <zephyr/bluetooth/gatt.h>
Get the handle of the characteristic value descriptor.
attr | A Characteristic Attribute. |
user_data
of the attribute must of type bt_gatt_chrc.attr
was not a characteristic attribute. ssize_t bt_gatt_attr_write_ccc | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
const void * | buf, | ||
uint16_t | len, | ||
uint16_t | offset, | ||
uint8_t | flags ) |
#include <zephyr/bluetooth/gatt.h>
Write Client Characteristic Configuration Attribute helper.
Write value in the buffer into CCC attribute.
conn | Connection object. |
attr | Attribute to read. |
buf | Buffer to store the value read. |
len | Buffer length. |
offset | Start offset. |
flags | Write flags. |
int bt_gatt_authorization_cb_register | ( | const struct bt_gatt_authorization_cb * | cb | ) |
#include <zephyr/bluetooth/gatt.h>
Register GATT authorization callbacks.
Register callbacks to perform application-specific authorization of GATT operations on all registered GATT attributes. The callback structure must remain valid throughout the entire duration of the Bluetooth subsys activity.
The
CONFIG_BT_GATT_AUTHORIZATION_CUSTOM
Kconfig must be enabled to make this API functional.
This API allows the user to register only one callback structure concurrently. Passing NULL unregisters the previous set of callbacks and makes it possible to register a new one.
cb | Callback struct. |
void bt_gatt_cb_register | ( | struct bt_gatt_cb * | cb | ) |
#include <zephyr/bluetooth/gatt.h>
Register GATT callbacks.
Register callbacks to monitor the state of GATT. The callback struct must remain valid for the remainder of the program.
cb | Callback struct. |
|
inlinestatic |
#include <zephyr/bluetooth/gatt.h>
Converts a GATT error to string.
The GATT errors are created with BT_GATT_ERR.
The error codes are described in the Bluetooth Core specification, Vol 3, Part F, Section 3.4.1.1.
The ATT and GATT documentation found in Vol 4, Part F and Part G describe when the different error codes are used.
See also the defined BT_ATT_ERR_* macros.
CONFIG_BT_ATT_ERR_TO_STRis not enabled, this just returns the empty string.
struct bt_gatt_attr * bt_gatt_find_by_uuid | ( | const struct bt_gatt_attr * | attr, |
uint16_t | attr_count, | ||
const struct bt_uuid * | uuid ) |
#include <zephyr/bluetooth/gatt.h>
Find Attribute by UUID.
Find the attribute with the matching UUID. To limit the search to a service set the attr to the service attributes and the attr_count
to the service attribute count .
attr | Pointer to an attribute that serves as the starting point for the search of a match for the UUID. Passing NULL will search the entire range. |
attr_count | The number of attributes from the starting point to search for a match for the UUID. Set to 0 to search until the end. |
uuid | UUID to match. |
|
inlinestatic |
#include <zephyr/bluetooth/gatt.h>
Attribute iterator.
Iterate attributes in the given range.
start_handle | Start handle. |
end_handle | End handle. |
func | Callback function. |
user_data | Data to pass to the callback. |
void bt_gatt_foreach_attr_type | ( | uint16_t | start_handle, |
uint16_t | end_handle, | ||
const struct bt_uuid * | uuid, | ||
const void * | attr_data, | ||
uint16_t | num_matches, | ||
bt_gatt_attr_func_t | func, | ||
void * | user_data ) |
#include <zephyr/bluetooth/gatt.h>
Attribute iterator by type.
Iterate attributes in the given range matching given UUID and/or data.
start_handle | Start handle. |
end_handle | End handle. |
uuid | UUID to match, passing NULL skips UUID matching. |
attr_data | Attribute data to match, passing NULL skips data matching. |
num_matches | Number matches, passing 0 makes it unlimited. |
func | Callback function. |
user_data | Data to pass to the callback. |
uint16_t bt_gatt_get_mtu | ( | struct bt_conn * | conn | ) |
#include <zephyr/bluetooth/gatt.h>
Get ATT MTU for a connection.
Get negotiated ATT connection MTU, note that this does not equal the largest amount of attribute data that can be transferred within a single packet.
conn | Connection object. |
uint16_t bt_gatt_get_uatt_mtu | ( | struct bt_conn * | conn | ) |
#include <zephyr/bluetooth/gatt.h>
Get Unenhanced ATT (UATT) MTU for a connection.
Get UATT connection MTU.
The ATT_MTU defines the largest size of an ATT PDU, encompassing the ATT opcode, additional fields, and any attribute value payload. Consequently, the maximum size of a value payload is less and varies based on the type of ATT PDU. For example, in an ATT_HANDLE_VALUE_NTF PDU, the Attribute Value field can contain up to ATT_MTU - 3 octets (size of opcode and handle).
conn | Connection object. |
conn
does not have an UATT ATT_MTU (e.g: disconnected). int bt_gatt_indicate | ( | struct bt_conn * | conn, |
struct bt_gatt_indicate_params * | params ) |
#include <zephyr/bluetooth/gatt.h>
Indicate attribute value change.
Send an indication of attribute value change. if connection is NULL indicate all peer that have notification enabled via CCC otherwise do a direct indication only the given connection.
The attribute object on the parameters can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC.
Alternatively it is possible to indicate by UUID by setting it on the parameters, when using this method the attribute if provided is used as the start range when looking up for possible matches.
conn | Connection object. |
params | Indicate parameters. |
bool bt_gatt_is_subscribed | ( | struct bt_conn * | conn, |
const struct bt_gatt_attr * | attr, | ||
uint16_t | ccc_type ) |
#include <zephyr/bluetooth/gatt.h>
Check if connection have subscribed to attribute.
Check if connection has subscribed to attribute value change.
The attribute object can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC, or the Client Characteristic Configuration Descriptor (CCCD) which is created by BT_GATT_CCC.
conn | Connection object. |
attr | Attribute object. |
ccc_type | The subscription type, BT_GATT_CCC_NOTIFY and/or BT_GATT_CCC_INDICATE. |
|
inlinestatic |
#include <zephyr/bluetooth/gatt.h>
Notify attribute value change.
Send notification of attribute value change, if connection is NULL notify all peer that have notification enabled via CCC otherwise do a direct notification only the given connection.
The attribute object on the parameters can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC.
conn | Connection object. |
attr | Characteristic or Characteristic Value attribute. |
data | Pointer to Attribute data. |
len | Attribute value length. |
int bt_gatt_notify_cb | ( | struct bt_conn * | conn, |
struct bt_gatt_notify_params * | params ) |
#include <zephyr/bluetooth/gatt.h>
Notify attribute value change.
This function works in the same way as bt_gatt_notify. With the addition that after sending the notification the callback function will be called.
The callback is run from System Workqueue context. When called from the System Workqueue context this API will not wait for resources for the callback but instead return an error. The number of pending callbacks can be increased with the
CONFIG_BT_CONN_TX_MAX
option.
Alternatively it is possible to notify by UUID by setting it on the parameters, when using this method the attribute if provided is used as the start range when looking up for possible matches.
conn | Connection object. |
params | Notification parameters. |
int bt_gatt_notify_multiple | ( | struct bt_conn * | conn, |
uint16_t | num_params, | ||
struct bt_gatt_notify_params | params[] ) |
#include <zephyr/bluetooth/gatt.h>
Send multiple notifications in a single PDU.
The GATT Server will send a single ATT_MULTIPLE_HANDLE_VALUE_NTF PDU containing all the notifications passed to this API.
All params
must have the same func
and user_data
(due to implementation limitation). But func(user_data)
will be invoked for each parameter.
As this API may block to wait for Bluetooth Host resources, it is not recommended to call it from a cooperative thread or a Bluetooth callback.
The peer's GATT Client must write to this device's Client Supported Features attribute and set the bit for Multiple Handle Value Notifications before this API can be used.
Only use this API to force the use of the ATT_MULTIPLE_HANDLE_VALUE_NTF PDU. For standard applications, bt_gatt_notify_cb
is preferred, as it will use this PDU if supported and automatically fallback to ATT_HANDLE_VALUE_NTF when not supported by the peer.
This API has an additional limitation: it only accepts valid attribute references and not UUIDs like bt_gatt_notify
and bt_gatt_notify_cb
.
conn | Target client. Notifying all connected clients by passing NULL is not yet supported, please use bt_gatt_notify instead. |
num_params | Element count of params array. Has to be greater than 1. |
params | Array of notification parameters. It is okay to free this after calling this function. |
0 | Success. The PDU is queued for sending. |
-EINVAL |
|
-ERANGE |
|
-EPERM | The connection has a lower security level than required by one of the attributes. |
-EOPNOTSUPP | The peer hasn't yet communicated that it supports this PDU type. |
|
inlinestatic |
#include <zephyr/bluetooth/gatt.h>
Notify attribute value change by UUID.
Send notification of attribute value change, if connection is NULL notify all peer that have notification enabled via CCC otherwise do a direct notification only on the given connection.
The attribute object is the starting point for the search of the UUID.
conn | Connection object. |
uuid | The UUID. If the server contains multiple services with the same UUID, then the first occurrence, starting from the attr given, is used. |
attr | Pointer to an attribute that serves as the starting point for the search of a match for the UUID. |
data | Pointer to Attribute data. |
len | Attribute value length. |
bool bt_gatt_service_is_registered | ( | const struct bt_gatt_service * | svc | ) |
#include <zephyr/bluetooth/gatt.h>
Check if GATT service is registered.
svc | Service to be checked. |
int bt_gatt_service_register | ( | struct bt_gatt_service * | svc | ) |
#include <zephyr/bluetooth/gatt.h>
Register GATT service.
Register GATT service. Applications can make use of macros such as BT_GATT_PRIMARY_SERVICE
, BT_GATT_CHARACTERISTIC
, BT_GATT_DESCRIPTOR
, etc.
When using
CONFIG_BT_SETTINGS
then all services that should have bond configuration loaded, i.e. CCC values, must be registered before calling settings_load.
When using
CONFIG_BT_GATT_CACHING
and
CONFIG_BT_SETTINGS
then all services that should be included in the GATT Database Hash calculation should be added before calling settings_load. All services registered after settings_load will trigger a new database hash calculation and a new hash stored.
There are two situations where this function can be called: either before bt_init()
has been called, or after settings_load()
has been called. Registering a service in the middle is not supported and will return an error.
svc | Service containing the available attributes |
bt_init()
has been called but settings_load()
hasn't yet. int bt_gatt_service_unregister | ( | struct bt_gatt_service * | svc | ) |
#include <zephyr/bluetooth/gatt.h>
Unregister GATT service.
svc | Service to be unregistered. |