The latest development version of this page may be more current than this released 1.14.0 version.

Generic Attribute Profile (GATT)

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

Services can be registered using bt_gatt_service_register() API which takes the bt_gatt_service struct that provides the list of attributes the service contains. The helper macro BT_GATT_SERVICE() can be used to declare a service.

Attributes can be declared using the bt_gatt_attr struct or using one of the helper macros:

BT_GATT_PRIMARY_SERVICE()
Declares a Primary Service.
BT_GATT_SECONDARY_SERVICE()
Declares a Secondary Service.
BT_GATT_INCLUDE_SERVICE()
Declares a Include Service.
BT_GATT_CHARACTERISTIC()
Declares a Characteristic.
BT_GATT_DESCRIPTOR()
Declares a Descriptor.
BT_GATT_ATTRIBUTE()
Declares an Attribute.
BT_GATT_CCC()
Declares a Client Characteristic Configuration.
BT_GATT_CEP()
Declares a Characteristic Extended Properties.
BT_GATT_CUD()
Declares a Characteristic User Format.

Each attribute contain a uuid, which describes their type, a read callback, a write callback and a set of permission. Both read and write callbacks can be set to NULL if the attribute permission don’t allow their respective operations.

Note

Attribute read and write callbacks are called directly from RX Thread thus it is not recommended to block for long periods of time in them.

Attribute value changes can be notified using bt_gatt_notify() API, alternatively there is bt_gatt_notify_cb() where is is possible to 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 bt_gatt_indicate() API.

Client procedures can be enabled with the configuration option: CONFIG_BT_GATT_CLIENT

Discover procedures can be initiated with the use of bt_gatt_discover() API which takes the bt_gatt_dicover_params struct which describes the type of discovery. The parameters also serves as a filter when setting the uuid field only attributes which matches will be discovered, in contrast setting it to NULL allows all attributes to be discovered.

Note

Caching discovered attributes is not supported.

Read procedures are supported by bt_gatt_read() API which takes the bt_gatt_read_params struct as parameters. In the parameters one or more attributes can be set, though setting multiple handles requires the option: CONFIG_BT_GATT_READ_MULTIPLE

Write procedures are supported by bt_gatt_write() API and takes bt_gatt_write_params struct as parameters. In case the write operation don’t require a response bt_gatt_write_without_response() or bt_gatt_write_without_response_cb() APIs can be used, with the later working similarly to bt_gatt_notify_cb.

Subscriptions to notification and indication can be initiated with use of :cpp:func`bt_gatt_subscribe` API which takes bt_gatt_subscribe_params as parameters. Multiple subscriptions to the same attribute are supported so there could be multiple notify callback being triggered for the same attribute. Subscriptions can be removed with use of bt_gatt_unsubscribe() API.

Note

When subscriptions are removed notify callback is called with the data set to NULL.

API Reference

group bt_gatt

Generic Attribute Profile (GATT)

Defines

BT_GATT_ERR(_att_err)

Construct error return value for attribute read and write callbacks.

Return
Appropriate error code for the attribute callbacks.
Parameters
  • _att_err: ATT error code

BT_GATT_CHRC_BROADCAST

Characteristic broadcast property.

If set, permits broadcasts of the Characteristic Value using Server Characteristic Configuration Descriptor.

BT_GATT_CHRC_READ

Characteristic read property.

If set, permits reads of the Characteristic Value.

BT_GATT_CHRC_WRITE_WITHOUT_RESP

Characteristic write without response property.

If set, permits write of the Characteristic Value without response.

BT_GATT_CHRC_WRITE

Characteristic write with response property.

If set, permits write of the Characteristic Value with response.

BT_GATT_CHRC_NOTIFY

Characteristic notify property.

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

BT_GATT_CHRC_INDICATE

Characteristic indicate property.

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

BT_GATT_CHRC_AUTH

Characteristic Authenticated Signed Writes property.

If set, permits signed writes to the Characteristic Value.

BT_GATT_CHRC_EXT_PROP

Characteristic Extended Properties property.

If set, additional characteristic properties are defined in the Characteristic Extended Properties Descriptor.

BT_GATT_CEP_RELIABLE_WRITE
BT_GATT_CEP_WRITABLE_AUX
BT_GATT_CCC_NOTIFY

Client Characteristic Configuration Notification.

If set, changes to Characteristic Value shall be notified.

BT_GATT_CCC_INDICATE

Client Characteristic Configuration Indication.

If set, changes to Characteristic Value shall be indicated.

Enums

enum [anonymous]

Values:

BT_GATT_PERM_NONE = 0

No operations supported, e.g. for notify-only

BT_GATT_PERM_READ = BIT(0)

Attribute read permission.

BT_GATT_PERM_WRITE = BIT(1)

Attribute write permission.

BT_GATT_PERM_READ_ENCRYPT = BIT(2)

Attribute read permission with encryption.

    If set, requires encryption for read access.

BT_GATT_PERM_WRITE_ENCRYPT = BIT(3)

Attribute write permission with encryption.

    If set, requires encryption for write access.

BT_GATT_PERM_READ_AUTHEN = BIT(4)

Attribute read permission with authentication.

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

BT_GATT_PERM_WRITE_AUTHEN = BIT(5)

Attribute write permission with authentication.

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

BT_GATT_PERM_PREPARE_WRITE = BIT(6)

Attribute prepare write permission.

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

enum [anonymous]

Values:

BT_GATT_WRITE_FLAG_PREPARE = BIT(0)

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 = BIT(1)

Attribute write command flag

   If set, indicates that write operation is a command (Write without
   response) which doesn't generate any response.

struct bt_gatt_attr
#include <gatt.h>

GATT Attribute structure.

struct bt_gatt_service
#include <gatt.h>

GATT Service structure.

struct bt_gatt_service_val
#include <gatt.h>

Service Attribute Value.

struct bt_gatt_include
#include <gatt.h>

Include Attribute Value.

struct bt_gatt_chrc
#include <gatt.h>

Characteristic Attribute Value.

struct bt_gatt_cep
#include <gatt.h>

Characteristic Extended Properties Attribute Value.

struct bt_gatt_cpf
#include <gatt.h>

GATT Characteristic Presentation Format Attribute Value.

GATT Server

group bt_gatt_server

Defines

BT_GATT_SERVICE(_attrs)

Service Structure Declaration Macro.

Helper macro to declare a service structure.

Parameters
  • _attrs: Service attributes.

BT_GATT_PRIMARY_SERVICE(_service)

Primary Service Declaration Macro.

Helper macro to declare a primary service attribute.

Parameters
  • _service: Service attribute value.

BT_GATT_SECONDARY_SERVICE(_service)

Secondary Service Declaration Macro.

Helper macro to declare a secondary service attribute.

Parameters
  • _service: Service attribute value.

BT_GATT_INCLUDE_SERVICE(_service_incl)

Include Service Declaration Macro.

Helper macro to declare database internal include service attribute.

Parameters
  • _service_incl: the first service attribute of service to include

BT_GATT_CHARACTERISTIC(_uuid, _props, _perm, _read, _write, _value)

Characteristic and Value Declaration Macro.

Helper macro to declare a characteristic attribute along with its attribute value.

Parameters
  • _uuid: Characteristic attribute uuid.
  • _props: Characteristic attribute properties.
  • _perm: Characteristic Attribute access permissions.
  • _read: Characteristic Attribute read callback.
  • _write: Characteristic Attribute write callback.
  • _value: Characteristic Attribute value.

BT_GATT_CCC_MAX
BT_GATT_CCC_MANAGED(_cfg, _changed, _write, _match)

Managed Client Characteristic Configuration Declaration Macro.

Helper macro to declare a Managed CCC attribute.

Parameters
  • _cfg: Initial configuration.
  • _changed: Configuration changed callback.
  • _write: Configuration write callback.
  • _match: Configuration match callback.

BT_GATT_CCC(_cfg, _cfg_changed)

Client Characteristic Configuration Declaration Macro.

Helper macro to declare a CCC attribute.

Parameters
  • _cfg: Initial configuration.
  • _cfg_changed: Configuration changed callback.

BT_GATT_CEP(_value)

Characteristic Extended Properties Declaration Macro.

Helper macro to declare a CEP attribute.

Parameters
  • _value: Descriptor attribute value.

BT_GATT_CUD(_value, _perm)

Characteristic User Format Descriptor Declaration Macro.

Helper macro to declare a CUD attribute.

Parameters
  • _value: User description NULL-terminated C string.
  • _perm: Descriptor attribute access permissions.

BT_GATT_CPF(_value)

Characteristic Presentation Format Descriptor Declaration Macro.

Helper macro to declare a CPF attribute.

Parameters
  • _value: Descriptor attribute value.

BT_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _value)

Descriptor Declaration Macro.

Helper macro to declare a descriptor attribute.

Parameters
  • _uuid: Descriptor attribute uuid.
  • _perm: Descriptor attribute access permissions.
  • _read: Descriptor attribute read callback.
  • _write: Descriptor attribute write callback.
  • _value: Descriptor attribute value.

BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _value)

Attribute Declaration Macro.

Helper macro to declare an attribute.

Parameters
  • _uuid: Attribute uuid.
  • _perm: Attribute access permissions.
  • _read: Attribute read callback.
  • _write: Attribute write callback.
  • _value: Attribute value.

Typedefs

typedef bt_gatt_attr_func_t

Attribute iterator callback.

Return
BT_GATT_ITER_CONTINUE if should continue to the next attribute or BT_GATT_ITER_STOP to stop.
Parameters
  • attr: Attribute found.
  • user_data: Data given.

typedef void (*bt_gatt_complete_func_t)(struct bt_conn *conn)

Notification complete result callback.

Parameters
  • conn: Connection object.

typedef bt_gatt_indicate_func_t

Indication complete result callback.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • attr: Attribute object.
  • err: ATT error code

Enums

enum [anonymous]

Values:

BT_GATT_ITER_STOP = 0
BT_GATT_ITER_CONTINUE

Functions

int bt_gatt_service_register(struct bt_gatt_service *svc)

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.

Return
0 in case of success or negative value in case of error.
Parameters
  • svc: Service containing the available attributes

int bt_gatt_service_unregister(struct bt_gatt_service *svc)

Unregister GATT service. *.

Return
0 in case of success or negative value in case of error.
Parameters
  • svc: Service to be unregistered.

void bt_gatt_foreach_attr(u16_t start_handle, u16_t end_handle, bt_gatt_attr_func_t func, void *user_data)

Attribute iterator.

Iterate attributes in the given range.

Parameters
  • start_handle: Start handle.
  • end_handle: End handle.
  • func: Callback function.
  • user_data: Data to pass to the callback.

struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr)

Iterate to the next attribute.

Iterate to the next attribute following a given attribute.

Return
The next attribute or NULL if it cannot be found.
Parameters
  • attr: Current Attribute.

ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t buf_len, u16_t offset, const void *value, u16_t value_len)

Generic Read Attribute value helper.

Read attribute value from local database storing the result into buffer.

Return
int number of bytes read in case of success or negative values in case of error.
Parameters
  • 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_service(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset)

Read Service Attribute helper.

Read service attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_uuid.

Return
int number of bytes read in case of success or negative values in case of error.
Parameters
  • 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, u16_t len, u16_t offset)

Read Include Attribute helper.

Read include service attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_gatt_include.

Return
int number of bytes read in case of success or negative values in case of error.
Parameters
  • 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, u16_t len, u16_t offset)

Read Characteristic Attribute helper.

Read characteristic attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_gatt_chrc.

Return
number of bytes read in case of success or negative values in case of error.
Parameters
  • 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_ccc(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset)

Read Client Characteristic Configuration Attribute helper.

Read CCC attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a _bt_gatt_ccc.

Return
number of bytes read in case of success or negative values in case of error.
Parameters
  • 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_write_ccc(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, u16_t len, u16_t offset, u8_t flags)

Write Client Characteristic Configuration Attribute helper.

Write value in the buffer into CCC attribute. NOTE: Only use this with attributes which user_data is a _bt_gatt_ccc.

Return
number of bytes written in case of success or negative values in case of error.
Parameters
  • conn: Connection object.
  • attr: Attribute to read.
  • buf: Buffer to store the value read.
  • len: Buffer length.
  • offset: Start offset.
  • flags: Write flags.

ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset)

Read Characteristic Extended Properties Attribute helper.

Read CEP attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_gatt_cep.

Return
number of bytes read in case of success or negative values in case of error.
Parameters
  • 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, u16_t len, u16_t offset)

Read Characteristic User Description Descriptor Attribute helper.

Read CUD attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a NULL-terminated C string.

Return
number of bytes read in case of success or negative values in case of error.
Parameters
  • 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, u16_t len, u16_t offset)

Read Characteristic Presentation format Descriptor Attribute helper.

Read CPF attribute value from local database storing the result into buffer after encoding it. NOTE: Only use this with attributes which user_data is a bt_gatt_pf.

Return
number of bytes read in case of success or negative values in case of error.
Parameters
  • conn: Connection object
  • attr: Attribute to read
  • buf: Buffer to store the value read
  • len: Buffer length
  • offset: Start offset

int bt_gatt_notify_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *data, u16_t len, bt_gatt_complete_func_t func)

Notify attribute value change with callback.

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.

Parameters
  • conn: Connection object.
  • attr: Characteristic or Characteristic Value attribute.
  • data: Pointer to Attribute data.
  • len: Attribute value length.
  • func: Notification value callback.

static int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *data, u16_t len)

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

Parameters
  • conn: Connection object.
  • attr: Characteristic or Characteristic Value attribute.
  • data: Pointer to Attribute data.
  • len: Attribute value length.

int bt_gatt_indicate(struct bt_conn *conn, struct bt_gatt_indicate_params *params)

Indicate attribute value change.

Send an indication of attribute value change. Note: This function should only be called if CCC is declared with BT_GATT_CCC otherwise it cannot find a valid peer configuration.

Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • params: Indicate parameters.

u16_t bt_gatt_get_mtu(struct bt_conn *conn)

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.

Return
MTU in bytes
Parameters
  • conn: Connection object.

struct bt_gatt_ccc_cfg
#include <gatt.h>

GATT CCC configuration entry.

Parameters
  • id: Local identity, BT_ID_DEFAULT in most cases.
  • peer: Remote peer address
  • value: Configuration value.
  • data: Configuration pointer data.

struct bt_gatt_indicate_params
#include <gatt.h>

GATT Indicate Value parameters.

GATT Client

group bt_gatt_client

Typedefs

typedef bt_gatt_discover_func_t

Discover attribute callback function.

If discovery procedure has completed this callback will be called with attr set to NULL. This will not happen if procedure was stopped by returning BT_GATT_ITER_STOP. The attribute is read-only and cannot be cached without copying its contents.

Parameters
  • conn: Connection object.
  • attr: Attribute found.
  • params: Discovery parameters given.

Return
BT_GATT_ITER_CONTINUE if should continue attribute discovery or BT_GATT_ITER_STOP to stop discovery procedure.

typedef bt_gatt_read_func_t

Read callback function.

Parameters
  • conn: Connection object.
  • err: ATT error code.
  • params: Read parameters used.
  • data: Attribute value data. NULL means read has completed.
  • length: Attribute value length.

typedef bt_gatt_write_func_t

Write callback function.

Parameters
  • conn: Connection object.
  • err: ATT error code.
  • params: Write parameters used.

typedef bt_gatt_notify_func_t

Notification callback function.

Parameters
  • conn: Connection object.
  • params: Subscription parameters.
  • data: Attribute value data. If NULL then subscription was removed.
  • length: Attribute value length.

Enums

enum [anonymous]

Values:

BT_GATT_DISCOVER_PRIMARY

Discover Primary Services.

BT_GATT_DISCOVER_SECONDARY

Discover Secondary Services.

BT_GATT_DISCOVER_INCLUDE

Discover Included Services.

BT_GATT_DISCOVER_CHARACTERISTIC

Discover Characteristic Values.

    Discover Characteristic Value and its properties.

BT_GATT_DISCOVER_DESCRIPTOR

Discover Descriptors.

    Discover Attributes which are not services or characteristics.

    Note: The use of this type of discover is not recommended for
    discovering in ranges across multiple services/characteristics
    as it may incur in extra round trips.

BT_GATT_DISCOVER_ATTRIBUTE

Discover Attributes.

    Discover Attributes of any type.

    Note: The use of this type of discover is not recommended for
    discovering in ranges across multiple services/characteristics as
    it may incur in more round trips.

enum [anonymous]

Values:

BT_GATT_SUBSCRIBE_FLAG_VOLATILE = BIT(0)

Persistence flag

   If set, indicates that the subscription is not saved
   on the GATT server side. Therefore, upon disconnection,
   the subscription will be automatically removed
   from the client's subscriptions list and
   when the client reconnects, it will have to
   issue a new subscription.

Functions

int bt_gatt_exchange_mtu(struct bt_conn *conn, struct bt_gatt_exchange_params *params)

Exchange MTU.

This client procedure can be used to set the MTU to the maximum possible size the buffers can hold.

NOTE: Shall only be used once per connection.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • params: Exchange MTU parameters.

int bt_gatt_discover(struct bt_conn *conn, struct bt_gatt_discover_params *params)

GATT Discover function.

This procedure is used by a client to discover attributes on a server.

Primary Service Discovery: Procedure allows to discover specific Primary Service based on UUID. Include Service Discovery: Procedure allows to discover all Include Services within specified range. Characteristic Discovery: Procedure allows to discover all characteristics within specified handle range as well as discover characteristics with specified UUID. Descriptors Discovery: Procedure allows to discover all characteristic descriptors within specified range.

For each attribute found the callback is called which can then decide whether to continue discovering or stop.

Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • params: Discover parameters.

int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params)

Read Attribute Value by handle.

This procedure read the attribute value and return it to the callback.

Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • params: Read parameters.

int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params)

Write Attribute Value by handle.

This procedure write the attribute value and return the result in the callback.

Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • params: Write parameters.

int bt_gatt_write_without_response_cb(struct bt_conn *conn, u16_t handle, const void *data, u16_t length, bool sign, bt_gatt_complete_func_t func)

Write Attribute Value by handle without response with callback.

This function works in the same way as bt_gatt_write_without_response. With the addition that after sending the write the callback function will be called.

Note: By using a callback it also disable the internal flow control which would prevent sending multiple commands without waiting for their transmissions to complete, so if that is required the caller shall not submit more data until the callback is called.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • handle: Attribute handle.
  • data: Data to be written.
  • length: Data length.
  • sign: Whether to sign data
  • func: Transmission complete callback.

static int bt_gatt_write_without_response(struct bt_conn *conn, u16_t handle, const void *data, u16_t length, bool sign)

Write Attribute Value by handle without response.

This procedure write the attribute value without requiring an acknowledgment that the write was successfully performed

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • handle: Attribute handle.
  • data: Data to be written.
  • length: Data length.
  • sign: Whether to sign data

int bt_gatt_subscribe(struct bt_conn *conn, struct bt_gatt_subscribe_params *params)

Subscribe Attribute Value Notification.

This procedure subscribe to value notification using the Client Characteristic Configuration handle. If notification received subscribe value callback is called to return notified value. One may then decide whether to unsubscribe directly from this callback. Notification callback with NULL data will not be called if subscription was removed by this method.

Note: This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • params: Subscribe parameters.

int bt_gatt_unsubscribe(struct bt_conn *conn, struct bt_gatt_subscribe_params *params)

Unsubscribe Attribute Value Notification.

This procedure unsubscribe to value notification using the Client Characteristic Configuration handle. Notification callback with NULL data will be called if subscription was removed by this call, until then the parameters cannot be reused.

Return
0 in case of success or negative value in case of error.
Parameters
  • conn: Connection object.
  • params: Subscribe parameters.

void bt_gatt_cancel(struct bt_conn *conn, void *params)

Cancel GATT pending request.

Parameters
  • conn: Connection object.
  • params: Requested params address.

struct bt_gatt_exchange_params
#include <gatt.h>

GATT Exchange MTU parameters.

struct bt_gatt_discover_params
#include <gatt.h>

GATT Discover Attributes parameters.

struct bt_gatt_read_params
#include <gatt.h>

GATT Read parameters.

Parameters
  • func: Read attribute callback
  • handle_count: If equals to 1 single.handle and single.offset are used. If >1 Read Multiple Characteristic Values is performed and handles are used.
  • handle: Attribute handle
  • offset: Attribute data offset
  • handles: Handles to read in Read Multiple Characteristic Values

struct bt_gatt_write_params
#include <gatt.h>

GATT Write parameters.

struct bt_gatt_subscribe_params
#include <gatt.h>

GATT Subscribe parameters.