Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Generic Attribute Profile (GATT)

Generic Attribute Profile (GATT) More...

Modules

 GATT Client APIs
 
 GATT Server APIs
 

Data Structures

struct  bt_gatt_attr
 GATT Attribute structure. 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)   (-(_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 write callback.
 

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...
 

Detailed Description

Generic Attribute Profile (GATT)

Macro Definition Documentation

◆ BT_GATT_CCC_INDICATE

#define BT_GATT_CCC_INDICATE   0x0002

#include <zephyr/bluetooth/gatt.h>

Client Characteristic Configuration Indication.

If set, changes to Characteristic Value shall be indicated.

◆ BT_GATT_CCC_NOTIFY

#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.

◆ BT_GATT_CEP_RELIABLE_WRITE

#define BT_GATT_CEP_RELIABLE_WRITE   0x0001

#include <zephyr/bluetooth/gatt.h>

Characteristic Extended Properties Bit field values.

◆ BT_GATT_CEP_WRITABLE_AUX

#define BT_GATT_CEP_WRITABLE_AUX   0x0002

◆ BT_GATT_CHRC_AUTH

#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.

◆ BT_GATT_CHRC_BROADCAST

#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.

◆ BT_GATT_CHRC_EXT_PROP

#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.

◆ BT_GATT_CHRC_INDICATE

#define BT_GATT_CHRC_INDICATE   0x20

#include <zephyr/bluetooth/gatt.h>

Characteristic indicate property.

If set, permits indications of a Characteristic Value with acknowledgment.

◆ BT_GATT_CHRC_NOTIFY

#define BT_GATT_CHRC_NOTIFY   0x10

#include <zephyr/bluetooth/gatt.h>

Characteristic notify property.

If set, permits notifications of a Characteristic Value without acknowledgment.

◆ BT_GATT_CHRC_READ

#define BT_GATT_CHRC_READ   0x02

#include <zephyr/bluetooth/gatt.h>

Characteristic read property.

If set, permits reads of the Characteristic Value.

◆ BT_GATT_CHRC_WRITE

#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.

◆ BT_GATT_CHRC_WRITE_WITHOUT_RESP

#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.

◆ BT_GATT_ERR

#define BT_GATT_ERR (   _att_err)    (-(_att_err))

#include <zephyr/bluetooth/gatt.h>

Construct error return value for attribute read and write callbacks.

Parameters
_att_errATT error code
Returns
Appropriate error code for the attribute callbacks.

◆ BT_GATT_SCC_BROADCAST

#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 Documentation

◆ bt_gatt_attr_read_func_t

bt_gatt_attr_read_func_t

#include <zephyr/bluetooth/gatt.h>

Attribute read callback.

The callback can also be used locally to read the contents of the attribute in which case no connection will be set.

Parameters
connThe connection that is requesting to read
attrThe attribute that's being read
bufBuffer to place the read result in
lenLength of data to read
offsetOffset to start reading from
Returns
Number of bytes read, or in case of an error BT_GATT_ERR() with a specific BT_ATT_ERR_* error code.

◆ bt_gatt_attr_write_func_t

bt_gatt_attr_write_func_t

#include <zephyr/bluetooth/gatt.h>

Attribute write callback.

Parameters
connThe connection that is requesting to write
attrThe attribute that's being written
bufBuffer with the data to write
lenNumber of bytes in the buffer
offsetOffset to start writing from
flagsFlags (BT_GATT_WRITE_FLAG_*)
Returns
Number of bytes written, or in case of an error BT_GATT_ERR() with a specific BT_ATT_ERR_* error code.

Enumeration Type Documentation

◆ anonymous enum

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
   @ref BT_GATT_WRITE_FLAG_PREPARE.

◆ bt_gatt_perm

#include <zephyr/bluetooth/gatt.h>

GATT attribute permission bit field values.

Enumerator
BT_GATT_PERM_NONE 

No operations supported, e.g.

for notify-only

BT_GATT_PERM_READ 

Attribute read permission.

BT_GATT_PERM_WRITE 

Attribute write permission.

BT_GATT_PERM_READ_ENCRYPT 

Attribute read permission with encryption.

    If set, requires encryption for read access.
BT_GATT_PERM_WRITE_ENCRYPT 

Attribute write permission with encryption.

    If set, requires encryption for write access.
BT_GATT_PERM_READ_AUTHEN 

Attribute read permission with authentication.

    If set, requires encryption using authenticated link-key for read
    access.
BT_GATT_PERM_WRITE_AUTHEN 

Attribute write permission with authentication.

    If set, requires encryption using authenticated link-key for write
    access.
BT_GATT_PERM_PREPARE_WRITE 

Attribute prepare write permission.

    If set, allows prepare writes with use of ``BT_GATT_WRITE_FLAG_PREPARE``
    passed to write callback.
BT_GATT_PERM_READ_LESC 

Attribute read permission with LE Secure Connection encryption.

    If set, requires that LE Secure Connections is used for read access.
BT_GATT_PERM_WRITE_LESC 

Attribute write permission with LE Secure Connection encryption.

    If set, requires that LE Secure Connections is used for write access.