Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
|
Generic Attribute Profile (GATT) . More...
Topics | |
GATT Client APIs | |
GATT Server APIs | |
Data Structures | |
struct | bt_gatt_attr |
GATT Attribute. More... | |
struct | bt_gatt_service_static |
GATT Service structure. More... | |
struct | bt_gatt_service |
GATT Service structure. More... | |
struct | bt_gatt_service_val |
Service Attribute Value. More... | |
struct | bt_gatt_include |
Include Attribute Value. More... | |
struct | bt_gatt_cb |
GATT callback structure. More... | |
struct | bt_gatt_authorization_cb |
GATT authorization callback structure. More... | |
struct | bt_gatt_chrc |
Characteristic Attribute Value. More... | |
struct | bt_gatt_cep |
Characteristic Extended Properties Attribute Value. More... | |
struct | bt_gatt_ccc |
Client Characteristic Configuration Attribute Value. More... | |
struct | bt_gatt_scc |
Server Characteristic Configuration Attribute Value. More... | |
struct | bt_gatt_cpf |
GATT Characteristic Presentation Format Attribute Value. More... | |
Macros | |
#define | BT_GATT_ERR(_att_err) |
Construct error return value for attribute read and write callbacks. | |
#define | BT_GATT_CHRC_BROADCAST 0x01 |
Characteristic Properties Bit field values. | |
#define | BT_GATT_CHRC_READ 0x02 |
Characteristic read property. | |
#define | BT_GATT_CHRC_WRITE_WITHOUT_RESP 0x04 |
Characteristic write without response property. | |
#define | BT_GATT_CHRC_WRITE 0x08 |
Characteristic write with response property. | |
#define | BT_GATT_CHRC_NOTIFY 0x10 |
Characteristic notify property. | |
#define | BT_GATT_CHRC_INDICATE 0x20 |
Characteristic indicate property. | |
#define | BT_GATT_CHRC_AUTH 0x40 |
Characteristic Authenticated Signed Writes property. | |
#define | BT_GATT_CHRC_EXT_PROP 0x80 |
Characteristic Extended Properties property. | |
#define | BT_GATT_CEP_RELIABLE_WRITE 0x0001 |
Characteristic Extended Properties Bit field values. | |
#define | BT_GATT_CEP_WRITABLE_AUX 0x0002 |
#define | BT_GATT_CCC_NOTIFY 0x0001 |
Client Characteristic Configuration Values. | |
#define | BT_GATT_CCC_INDICATE 0x0002 |
Client Characteristic Configuration Indication. | |
#define | BT_GATT_SCC_BROADCAST 0x0001 |
Server Characteristic Configuration Values. | |
Typedefs | |
typedef ssize_t(* | bt_gatt_attr_read_func_t) (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
Attribute read callback. | |
typedef ssize_t(* | bt_gatt_attr_write_func_t) (struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags) |
Attribute Value write implementation. | |
Enumerations | |
enum | bt_gatt_perm { BT_GATT_PERM_NONE = 0 , BT_GATT_PERM_READ = BIT(0) , BT_GATT_PERM_WRITE = BIT(1) , BT_GATT_PERM_READ_ENCRYPT = BIT(2) , BT_GATT_PERM_WRITE_ENCRYPT = BIT(3) , BT_GATT_PERM_READ_AUTHEN = BIT(4) , BT_GATT_PERM_WRITE_AUTHEN = BIT(5) , BT_GATT_PERM_PREPARE_WRITE = BIT(6) , BT_GATT_PERM_READ_LESC = BIT(7) , BT_GATT_PERM_WRITE_LESC = BIT(8) } |
GATT attribute permission bit field values. More... | |
enum | { BT_GATT_WRITE_FLAG_PREPARE = BIT(0) , BT_GATT_WRITE_FLAG_CMD = BIT(1) , BT_GATT_WRITE_FLAG_EXECUTE = BIT(2) } |
GATT attribute write flags. More... | |
Generic Attribute Profile (GATT) .
#define BT_GATT_CCC_INDICATE 0x0002 |
#include <zephyr/bluetooth/gatt.h>
Client Characteristic Configuration Indication.
If set, changes to Characteristic Value shall be indicated.
#define BT_GATT_CCC_NOTIFY 0x0001 |
#include <zephyr/bluetooth/gatt.h>
Client Characteristic Configuration Values.
Client Characteristic Configuration Notification.
If set, changes to Characteristic Value shall be notified.
#define BT_GATT_CEP_RELIABLE_WRITE 0x0001 |
#include <zephyr/bluetooth/gatt.h>
Characteristic Extended Properties Bit field values.
#define BT_GATT_CEP_WRITABLE_AUX 0x0002 |
#include <zephyr/bluetooth/gatt.h>
#define BT_GATT_CHRC_AUTH 0x40 |
#include <zephyr/bluetooth/gatt.h>
Characteristic Authenticated Signed Writes property.
If set, permits signed writes to the Characteristic Value.
#define BT_GATT_CHRC_BROADCAST 0x01 |
#include <zephyr/bluetooth/gatt.h>
Characteristic Properties Bit field values.
Characteristic broadcast property.
If set, permits broadcasts of the Characteristic Value using Server Characteristic Configuration Descriptor.
#define BT_GATT_CHRC_EXT_PROP 0x80 |
#include <zephyr/bluetooth/gatt.h>
Characteristic Extended Properties property.
If set, additional characteristic properties are defined in the Characteristic Extended Properties Descriptor.
#define BT_GATT_CHRC_INDICATE 0x20 |
#include <zephyr/bluetooth/gatt.h>
Characteristic indicate property.
If set, permits indications of a Characteristic Value with acknowledgment.
#define BT_GATT_CHRC_NOTIFY 0x10 |
#include <zephyr/bluetooth/gatt.h>
Characteristic notify property.
If set, permits notifications of a Characteristic Value without acknowledgment.
#define BT_GATT_CHRC_READ 0x02 |
#include <zephyr/bluetooth/gatt.h>
Characteristic read property.
If set, permits reads of the Characteristic Value.
#define BT_GATT_CHRC_WRITE 0x08 |
#include <zephyr/bluetooth/gatt.h>
Characteristic write with response property.
If set, permits write of the Characteristic Value with response.
#define BT_GATT_CHRC_WRITE_WITHOUT_RESP 0x04 |
#include <zephyr/bluetooth/gatt.h>
Characteristic write without response property.
If set, permits write of the Characteristic Value without response.
#define BT_GATT_ERR | ( | _att_err | ) |
#include <zephyr/bluetooth/gatt.h>
Construct error return value for attribute read and write callbacks.
_att_err | ATT error code |
#define BT_GATT_SCC_BROADCAST 0x0001 |
#include <zephyr/bluetooth/gatt.h>
Server Characteristic Configuration Values.
Server Characteristic Configuration Broadcast
If set, the characteristic value shall be broadcast in the advertising data when the server is advertising.
typedef ssize_t(* bt_gatt_attr_read_func_t) (struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset) |
#include <zephyr/bluetooth/gatt.h>
Attribute read callback.
This is the type of the bt_gatt_attr.read() method.
This function may safely assume the Attribute Permissions are satisfied for this read. Callers are responsible for this.
Callers may set conn
to emulate a GATT client read, or leave it NULL for local reads.
conn | The connection that is requesting to read. NULL if local. |
attr | The attribute that's being read |
buf | Buffer to place the read result in |
len | Length of data to read |
offset | Offset to start reading from |
BT_GATT_ERR()
with a specific BT_ATT_ERR_*
error code. typedef ssize_t(* bt_gatt_attr_write_func_t) (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>
Attribute Value write implementation.
This is the type of the bt_gatt_attr.write() method.
This function may safely assume the Attribute Permissions are satisfied for this write. Callers are responsible for this.
Callers may set conn
to emulate a GATT client write, or leave it NULL for local writes.
If flags
contains BT_GATT_WRITE_FLAG_PREPARE, then the method shall not perform a write, but instead only check if the write is authorized and return an error code if not.
Attribute Value write implementations can and often do have side effects besides potentially storing the value. E.g. togging an LED.
conn | The connection that is requesting to write |
attr | The attribute that's being written |
buf | Buffer with the data to write |
len | Number of bytes in the buffer |
offset | Offset to start writing from |
flags | Flags (BT_GATT_WRITE_FLAG_* ) |
BT_GATT_ERR()
with a specific BT_ATT_ERR_*
error code. anonymous enum |
#include <zephyr/bluetooth/gatt.h>
GATT attribute write flags.
Enumerator | |
---|---|
BT_GATT_WRITE_FLAG_PREPARE | Attribute prepare write flag. If set, write callback should only check if the device is authorized but no data shall be written. |
BT_GATT_WRITE_FLAG_CMD | Attribute write command flag. If set, indicates that write operation is a command (Write without response) which doesn't generate any response. |
BT_GATT_WRITE_FLAG_EXECUTE | Attribute write execute flag. If set, indicates that write operation is a execute, which indicates the end of a long write, and will come after 1 or more BT_GATT_WRITE_FLAG_PREPARE. |
enum bt_gatt_perm |
#include <zephyr/bluetooth/gatt.h>
GATT attribute permission bit field values.