警告

This document is not updated for ESP32C6 yet, so some of the content may not be correct.

This warning was automatically inserted due to the source file being in the add_warnings_pages list.

GATT DEFINES

API Reference

Header File

Unions

union esp_gatt_rsp_t
#include <esp_gatt_defs.h>

GATT remote read request response type.

Public Members

esp_gatt_value_t attr_value

Gatt attribute structure

uint16_t handle

Gatt attribute handle

Structures

struct esp_gatt_id_t

Gatt id, include uuid and instance id.

Public Members

esp_bt_uuid_t uuid

UUID

uint8_t inst_id

Instance id

struct esp_gatt_srvc_id_t

Gatt service id, include id (uuid and instance id) and primary flag.

Public Members

esp_gatt_id_t id

Gatt id, include uuid and instance

bool is_primary

This service is primary or not

struct esp_attr_desc_t

Attribute description (used to create database)

Public Members

uint16_t uuid_length

UUID length

uint8_t *uuid_p

UUID value

uint16_t perm

Attribute permission

uint16_t max_length

Maximum length of the element

uint16_t length

Current length of the element

uint8_t *value

Element value array

struct esp_attr_control_t

attribute auto response flag

Public Members

uint8_t auto_rsp

if auto_rsp set to ESP_GATT_RSP_BY_APP, means the response of Write/Read operation will by replied by application. if auto_rsp set to ESP_GATT_AUTO_RSP, means the response of Write/Read operation will be replied by GATT stack automatically.

struct esp_gatts_attr_db_t

attribute type added to the gatt server database

Public Members

esp_attr_control_t attr_control

The attribute control type

esp_attr_desc_t att_desc

The attribute type

struct esp_attr_value_t

set the attribute value type

Public Members

uint16_t attr_max_len

attribute max value length

uint16_t attr_len

attribute current value length

uint8_t *attr_value

the pointer to attribute value

struct esp_gatts_incl_svc_desc_t

Gatt include service entry element.

Public Members

uint16_t start_hdl

Gatt start handle value of included service

uint16_t end_hdl

Gatt end handle value of included service

uint16_t uuid

Gatt attribute value UUID of included service

struct esp_gatts_incl128_svc_desc_t

Gatt include 128 bit service entry element.

Public Members

uint16_t start_hdl

Gatt start handle value of included 128 bit service

uint16_t end_hdl

Gatt end handle value of included 128 bit service

struct esp_gatt_value_t

Gatt attribute value.

Public Members

uint8_t value[ESP_GATT_MAX_ATTR_LEN]

Gatt attribute value

uint16_t handle

Gatt attribute handle

uint16_t offset

Gatt attribute value offset

uint16_t len

Gatt attribute value length

uint8_t auth_req

Gatt authentication request

struct esp_gatt_conn_params_t

Connection parameters information.

Public Members

uint16_t interval

connection interval

uint16_t latency

Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3

uint16_t timeout

Supervision timeout for the LE Link. Range: 0x000A to 0x0C80. Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec Time Range: 100 msec to 32 seconds

struct esp_gattc_multi_t

read multiple attribute

Public Members

uint8_t num_attr

The number of the attribute

uint16_t handles[ESP_GATT_MAX_READ_MULTI_HANDLES]

The handles list

struct esp_gattc_db_elem_t

data base attribute element

Public Members

esp_gatt_db_attr_type_t type

The attribute type

uint16_t attribute_handle

The attribute handle, it’s valid for all of the type

uint16_t start_handle

The service start handle, it’s valid only when the type = ESP_GATT_DB_PRIMARY_SERVICE or ESP_GATT_DB_SECONDARY_SERVICE

uint16_t end_handle

The service end handle, it’s valid only when the type = ESP_GATT_DB_PRIMARY_SERVICE or ESP_GATT_DB_SECONDARY_SERVICE

esp_gatt_char_prop_t properties

The characteristic properties, it’s valid only when the type = ESP_GATT_DB_CHARACTERISTIC

esp_bt_uuid_t uuid

The attribute uuid, it’s valid for all of the type

struct esp_gattc_service_elem_t

service element

Public Members

bool is_primary

The service flag, true if the service is primary service, else is secondary service

uint16_t start_handle

The start handle of the service

uint16_t end_handle

The end handle of the service

esp_bt_uuid_t uuid

The uuid of the service

struct esp_gattc_char_elem_t

characteristic element

Public Members

uint16_t char_handle

The characteristic handle

esp_gatt_char_prop_t properties

The characteristic properties

esp_bt_uuid_t uuid

The characteristic uuid

struct esp_gattc_descr_elem_t

descriptor element

Public Members

uint16_t handle

The characteristic descriptor handle

esp_bt_uuid_t uuid

The characteristic descriptor uuid

struct esp_gattc_incl_svc_elem_t

include service element

Public Members

uint16_t handle

The include service current attribute handle

uint16_t incl_srvc_s_handle

The start handle of the service which has been included

uint16_t incl_srvc_e_handle

The end handle of the service which has been included

esp_bt_uuid_t uuid

The include service uuid

Macros

ESP_GATT_UUID_IMMEDIATE_ALERT_SVC

All “ESP_GATT_UUID_xxx” is attribute types

ESP_GATT_UUID_TX_POWER_SVC
ESP_GATT_UUID_CURRENT_TIME_SVC
ESP_GATT_UUID_REF_TIME_UPDATE_SVC
ESP_GATT_UUID_NEXT_DST_CHANGE_SVC
ESP_GATT_UUID_GLUCOSE_SVC
ESP_GATT_UUID_HEALTH_THERMOM_SVC
ESP_GATT_UUID_DEVICE_INFO_SVC
ESP_GATT_UUID_HEART_RATE_SVC
ESP_GATT_UUID_PHONE_ALERT_STATUS_SVC
ESP_GATT_UUID_BATTERY_SERVICE_SVC
ESP_GATT_UUID_BLOOD_PRESSURE_SVC
ESP_GATT_UUID_ALERT_NTF_SVC
ESP_GATT_UUID_HID_SVC
ESP_GATT_UUID_SCAN_PARAMETERS_SVC
ESP_GATT_UUID_RUNNING_SPEED_CADENCE_SVC
ESP_GATT_UUID_Automation_IO_SVC
ESP_GATT_UUID_CYCLING_SPEED_CADENCE_SVC
ESP_GATT_UUID_CYCLING_POWER_SVC
ESP_GATT_UUID_LOCATION_AND_NAVIGATION_SVC
ESP_GATT_UUID_ENVIRONMENTAL_SENSING_SVC
ESP_GATT_UUID_BODY_COMPOSITION
ESP_GATT_UUID_USER_DATA_SVC
ESP_GATT_UUID_WEIGHT_SCALE_SVC
ESP_GATT_UUID_BOND_MANAGEMENT_SVC
ESP_GATT_UUID_CONT_GLUCOSE_MONITOR_SVC
ESP_GATT_UUID_PRI_SERVICE
ESP_GATT_UUID_SEC_SERVICE
ESP_GATT_UUID_INCLUDE_SERVICE
ESP_GATT_UUID_CHAR_DECLARE
ESP_GATT_UUID_CHAR_EXT_PROP
ESP_GATT_UUID_CHAR_DESCRIPTION
ESP_GATT_UUID_CHAR_CLIENT_CONFIG
ESP_GATT_UUID_CHAR_SRVR_CONFIG
ESP_GATT_UUID_CHAR_PRESENT_FORMAT
ESP_GATT_UUID_CHAR_AGG_FORMAT
ESP_GATT_UUID_CHAR_VALID_RANGE
ESP_GATT_UUID_EXT_RPT_REF_DESCR
ESP_GATT_UUID_RPT_REF_DESCR
ESP_GATT_UUID_NUM_DIGITALS_DESCR
ESP_GATT_UUID_VALUE_TRIGGER_DESCR
ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR
ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR
ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR
ESP_GATT_UUID_TIME_TRIGGER_DESCR
ESP_GATT_UUID_GAP_DEVICE_NAME
ESP_GATT_UUID_GAP_ICON
ESP_GATT_UUID_GAP_PREF_CONN_PARAM
ESP_GATT_UUID_GAP_CENTRAL_ADDR_RESOL
ESP_GATT_UUID_GATT_SRV_CHGD
ESP_GATT_UUID_ALERT_LEVEL
ESP_GATT_UUID_TX_POWER_LEVEL
ESP_GATT_UUID_CURRENT_TIME
ESP_GATT_UUID_LOCAL_TIME_INFO
ESP_GATT_UUID_REF_TIME_INFO
ESP_GATT_UUID_NW_STATUS
ESP_GATT_UUID_NW_TRIGGER
ESP_GATT_UUID_ALERT_STATUS
ESP_GATT_UUID_RINGER_CP
ESP_GATT_UUID_RINGER_SETTING
ESP_GATT_UUID_GM_MEASUREMENT
ESP_GATT_UUID_GM_CONTEXT
ESP_GATT_UUID_GM_CONTROL_POINT
ESP_GATT_UUID_GM_FEATURE
ESP_GATT_UUID_SYSTEM_ID
ESP_GATT_UUID_MODEL_NUMBER_STR
ESP_GATT_UUID_SERIAL_NUMBER_STR
ESP_GATT_UUID_FW_VERSION_STR
ESP_GATT_UUID_HW_VERSION_STR
ESP_GATT_UUID_SW_VERSION_STR
ESP_GATT_UUID_MANU_NAME
ESP_GATT_UUID_IEEE_DATA
ESP_GATT_UUID_PNP_ID
ESP_GATT_UUID_HID_INFORMATION
ESP_GATT_UUID_HID_REPORT_MAP
ESP_GATT_UUID_HID_CONTROL_POINT
ESP_GATT_UUID_HID_REPORT
ESP_GATT_UUID_HID_PROTO_MODE
ESP_GATT_UUID_HID_BT_KB_INPUT
ESP_GATT_UUID_HID_BT_KB_OUTPUT
ESP_GATT_UUID_HID_BT_MOUSE_INPUT
ESP_GATT_HEART_RATE_MEAS

Heart Rate Measurement.

ESP_GATT_BODY_SENSOR_LOCATION

Body Sensor Location.

ESP_GATT_HEART_RATE_CNTL_POINT

Heart Rate Control Point.

ESP_GATT_UUID_BATTERY_LEVEL
ESP_GATT_UUID_SC_CONTROL_POINT
ESP_GATT_UUID_SENSOR_LOCATION
ESP_GATT_UUID_RSC_MEASUREMENT
ESP_GATT_UUID_RSC_FEATURE
ESP_GATT_UUID_CSC_MEASUREMENT
ESP_GATT_UUID_CSC_FEATURE
ESP_GATT_UUID_SCAN_INT_WINDOW
ESP_GATT_UUID_SCAN_REFRESH
ESP_GATT_ILLEGAL_UUID

GATT INVALID UUID.

ESP_GATT_ILLEGAL_HANDLE

GATT INVALID HANDLE.

ESP_GATT_ATTR_HANDLE_MAX

GATT attribute max handle.

ESP_GATT_MAX_READ_MULTI_HANDLES
ESP_GATT_PERM_READ

Attribute permissions.

ESP_GATT_PERM_READ_ENCRYPTED
ESP_GATT_PERM_READ_ENC_MITM
ESP_GATT_PERM_WRITE
ESP_GATT_PERM_WRITE_ENCRYPTED
ESP_GATT_PERM_WRITE_ENC_MITM
ESP_GATT_PERM_WRITE_SIGNED
ESP_GATT_PERM_WRITE_SIGNED_MITM
ESP_GATT_PERM_READ_AUTHORIZATION
ESP_GATT_PERM_WRITE_AUTHORIZATION
ESP_GATT_PERM_ENCRYPT_KEY_SIZE(keysize)
ESP_GATT_CHAR_PROP_BIT_BROADCAST
ESP_GATT_CHAR_PROP_BIT_READ
ESP_GATT_CHAR_PROP_BIT_WRITE_NR
ESP_GATT_CHAR_PROP_BIT_WRITE
ESP_GATT_CHAR_PROP_BIT_NOTIFY
ESP_GATT_CHAR_PROP_BIT_INDICATE
ESP_GATT_CHAR_PROP_BIT_AUTH
ESP_GATT_CHAR_PROP_BIT_EXT_PROP
ESP_GATT_MAX_ATTR_LEN

GATT maximum attribute length.

ESP_GATT_RSP_BY_APP
ESP_GATT_AUTO_RSP
ESP_GATT_IF_NONE

If callback report gattc_if/gatts_if as this macro, means this event is not correspond to any app

Type Definitions

typedef uint16_t esp_gatt_perm_t
typedef uint8_t esp_gatt_char_prop_t
typedef uint8_t esp_gatt_if_t

Gatt interface type, different application on GATT client use different gatt_if

Enumerations

enum esp_gatt_prep_write_type

Attribute write data type from the client.

Values:

enumerator ESP_GATT_PREP_WRITE_CANCEL

Prepare write cancel

enumerator ESP_GATT_PREP_WRITE_EXEC

Prepare write execute

enum esp_gatt_status_t

GATT success code and error codes.

Values:

enumerator ESP_GATT_OK
enumerator ESP_GATT_INVALID_HANDLE
enumerator ESP_GATT_READ_NOT_PERMIT
enumerator ESP_GATT_WRITE_NOT_PERMIT
enumerator ESP_GATT_INVALID_PDU
enumerator ESP_GATT_INSUF_AUTHENTICATION
enumerator ESP_GATT_REQ_NOT_SUPPORTED
enumerator ESP_GATT_INVALID_OFFSET
enumerator ESP_GATT_INSUF_AUTHORIZATION
enumerator ESP_GATT_PREPARE_Q_FULL
enumerator ESP_GATT_NOT_FOUND
enumerator ESP_GATT_NOT_LONG
enumerator ESP_GATT_INSUF_KEY_SIZE
enumerator ESP_GATT_INVALID_ATTR_LEN
enumerator ESP_GATT_ERR_UNLIKELY
enumerator ESP_GATT_INSUF_ENCRYPTION
enumerator ESP_GATT_UNSUPPORT_GRP_TYPE
enumerator ESP_GATT_INSUF_RESOURCE
enumerator ESP_GATT_NO_RESOURCES
enumerator ESP_GATT_INTERNAL_ERROR
enumerator ESP_GATT_WRONG_STATE
enumerator ESP_GATT_DB_FULL
enumerator ESP_GATT_BUSY
enumerator ESP_GATT_ERROR
enumerator ESP_GATT_CMD_STARTED
enumerator ESP_GATT_ILLEGAL_PARAMETER
enumerator ESP_GATT_PENDING
enumerator ESP_GATT_AUTH_FAIL
enumerator ESP_GATT_MORE
enumerator ESP_GATT_INVALID_CFG
enumerator ESP_GATT_SERVICE_STARTED
enumerator ESP_GATT_ENCRYPTED_MITM
enumerator ESP_GATT_ENCRYPTED_NO_MITM
enumerator ESP_GATT_NOT_ENCRYPTED
enumerator ESP_GATT_CONGESTED
enumerator ESP_GATT_DUP_REG
enumerator ESP_GATT_ALREADY_OPEN
enumerator ESP_GATT_CANCEL
enumerator ESP_GATT_STACK_RSP
enumerator ESP_GATT_APP_RSP
enumerator ESP_GATT_UNKNOWN_ERROR
enumerator ESP_GATT_CCC_CFG_ERR
enumerator ESP_GATT_PRC_IN_PROGRESS
enumerator ESP_GATT_OUT_OF_RANGE
enum esp_gatt_conn_reason_t

Gatt Connection reason enum.

Values:

enumerator ESP_GATT_CONN_UNKNOWN

Gatt connection unknown

enumerator ESP_GATT_CONN_L2C_FAILURE

General L2cap failure

enumerator ESP_GATT_CONN_TIMEOUT

Connection timeout

enumerator ESP_GATT_CONN_TERMINATE_PEER_USER

Connection terminate by peer user

enumerator ESP_GATT_CONN_TERMINATE_LOCAL_HOST

Connection terminated by local host

enumerator ESP_GATT_CONN_FAIL_ESTABLISH

Connection fail to establish

enumerator ESP_GATT_CONN_LMP_TIMEOUT

Connection fail for LMP response tout

enumerator ESP_GATT_CONN_CONN_CANCEL

L2CAP connection cancelled

enumerator ESP_GATT_CONN_NONE

No connection to cancel

enum esp_gatt_auth_req_t

Gatt authentication request type.

Values:

enumerator ESP_GATT_AUTH_REQ_NONE
enumerator ESP_GATT_AUTH_REQ_NO_MITM
enumerator ESP_GATT_AUTH_REQ_MITM
enumerator ESP_GATT_AUTH_REQ_SIGNED_NO_MITM
enumerator ESP_GATT_AUTH_REQ_SIGNED_MITM
enum esp_service_source_t

Values:

enumerator ESP_GATT_SERVICE_FROM_REMOTE_DEVICE
enumerator ESP_GATT_SERVICE_FROM_NVS_FLASH
enumerator ESP_GATT_SERVICE_FROM_UNKNOWN
enum esp_gatt_write_type_t

Gatt write type.

Values:

enumerator ESP_GATT_WRITE_TYPE_NO_RSP

Gatt write attribute need no response

enumerator ESP_GATT_WRITE_TYPE_RSP

Gatt write attribute need remote response

enum esp_gatt_db_attr_type_t

the type of attribute element

Values:

enumerator ESP_GATT_DB_PRIMARY_SERVICE

Gattc primary service attribute type in the cache

enumerator ESP_GATT_DB_SECONDARY_SERVICE

Gattc secondary service attribute type in the cache

enumerator ESP_GATT_DB_CHARACTERISTIC

Gattc characteristic attribute type in the cache

enumerator ESP_GATT_DB_DESCRIPTOR

Gattc characteristic descriptor attribute type in the cache

enumerator ESP_GATT_DB_INCLUDED_SERVICE

Gattc include service attribute type in the cache

enumerator ESP_GATT_DB_ALL

Gattc all the attribute (primary service & secondary service & include service & char & descriptor) type in the cache