Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Data Structures | |
struct | bt_gatt_exchange_params |
GATT Exchange MTU parameters. More... | |
struct | bt_gatt_discover_params |
GATT Discover Attributes parameters. More... | |
struct | bt_gatt_read_params |
GATT Read parameters. More... | |
struct | bt_gatt_write_params |
GATT Write parameters. More... | |
struct | bt_gatt_subscribe_params |
GATT Subscribe parameters. More... | |
Typedefs | |
typedef uint8_t(* | bt_gatt_discover_func_t) (struct bt_conn *conn, const struct bt_gatt_attr *attr, struct bt_gatt_discover_params *params) |
Discover attribute callback function. More... | |
typedef uint8_t(* | bt_gatt_read_func_t) (struct bt_conn *conn, uint8_t err, struct bt_gatt_read_params *params, const void *data, uint16_t length) |
Read callback function. More... | |
typedef void(* | bt_gatt_write_func_t) (struct bt_conn *conn, uint8_t err, struct bt_gatt_write_params *params) |
Write callback function. More... | |
typedef uint8_t(* | bt_gatt_notify_func_t) (struct bt_conn *conn, struct bt_gatt_subscribe_params *params, const void *data, uint16_t length) |
Notification callback function. More... | |
Functions | |
int | bt_gatt_exchange_mtu (struct bt_conn *conn, struct bt_gatt_exchange_params *params) |
Exchange MTU. More... | |
int | bt_gatt_discover (struct bt_conn *conn, struct bt_gatt_discover_params *params) |
GATT Discover function. More... | |
int | bt_gatt_read (struct bt_conn *conn, struct bt_gatt_read_params *params) |
Read Attribute Value by handle. More... | |
int | bt_gatt_write (struct bt_conn *conn, struct bt_gatt_write_params *params) |
Write Attribute Value by handle. More... | |
int | bt_gatt_write_without_response_cb (struct bt_conn *conn, uint16_t handle, const void *data, uint16_t length, bool sign, bt_gatt_complete_func_t func, void *user_data) |
Write Attribute Value by handle without response with callback. More... | |
static int | bt_gatt_write_without_response (struct bt_conn *conn, uint16_t handle, const void *data, uint16_t length, bool sign) |
Write Attribute Value by handle without response. More... | |
int | bt_gatt_subscribe (struct bt_conn *conn, struct bt_gatt_subscribe_params *params) |
Subscribe Attribute Value Notification. More... | |
int | bt_gatt_resubscribe (uint8_t id, const bt_addr_le_t *peer, struct bt_gatt_subscribe_params *params) |
Resubscribe Attribute Value Notification subscription. More... | |
int | bt_gatt_unsubscribe (struct bt_conn *conn, struct bt_gatt_subscribe_params *params) |
Unsubscribe Attribute Value Notification. More... | |
void | bt_gatt_cancel (struct bt_conn *conn, void *params) |
Cancel GATT pending request. More... | |
bt_gatt_discover_func_t |
#include <include/bluetooth/gatt.h>
Discover attribute callback function.
conn | Connection object. |
attr | Attribute found, or NULL if not found. |
params | Discovery parameters given. |
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 object as well as its UUID and value objects are temporary and must be copied to in order to cache its information. Only the following fields of the attribute contains valid information:
To be able to read the value of the discovered attribute the user_data must be cast to an appropriate type.
bt_gatt_notify_func_t |
#include <include/bluetooth/gatt.h>
Notification callback function.
In the case of an empty notification, the data
pointer will be non-NULL while the length
will be 0, which is due to the special case where a data
NULL pointer means unsubscribed.
conn | Connection object. May be NULL, indicating that the peer is being unpaired |
params | Subscription parameters. |
data | Attribute value data. If NULL then subscription was removed. |
length | Attribute value length. |
bt_gatt_read_func_t |
#include <include/bluetooth/gatt.h>
Read callback function.
conn | Connection object. |
err | ATT error code. |
params | Read parameters used. |
data | Attribute value data. NULL means read has completed. |
length | Attribute value length. |
bt_gatt_write_func_t |
#include <include/bluetooth/gatt.h>
Write callback function.
conn | Connection object. |
err | ATT error code. |
params | Write parameters used. |
anonymous enum |
#include <include/bluetooth/gatt.h>
GATT Discover types
anonymous enum |
#include <include/bluetooth/gatt.h>
Subscription flags
#include <include/bluetooth/gatt.h>
Cancel GATT pending request.
conn | Connection object. |
params | Requested params address. |
int bt_gatt_discover | ( | struct bt_conn * | conn, |
struct bt_gatt_discover_params * | params | ||
) |
#include <include/bluetooth/gatt.h>
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.
conn | Connection object. |
params | Discover parameters. |
int bt_gatt_exchange_mtu | ( | struct bt_conn * | conn, |
struct bt_gatt_exchange_params * | params | ||
) |
#include <include/bluetooth/gatt.h>
Exchange MTU.
This client procedure can be used to set the MTU to the maximum possible size the buffers can hold.
conn | Connection object. |
params | Exchange MTU parameters. |
int bt_gatt_read | ( | struct bt_conn * | conn, |
struct bt_gatt_read_params * | params | ||
) |
#include <include/bluetooth/gatt.h>
Read Attribute Value by handle.
This procedure read the attribute value and return it to the callback.
When reading attributes by UUID the callback can be called multiple times depending on how many instances of given the UUID exists with the start_handle being updated for each instance.
If an instance does contain a long value which cannot be read entirely the caller will need to read the remaining data separately using the handle and offset.
conn | Connection object. |
params | Read parameters. |
int bt_gatt_resubscribe | ( | uint8_t | id, |
const bt_addr_le_t * | peer, | ||
struct bt_gatt_subscribe_params * | params | ||
) |
#include <include/bluetooth/gatt.h>
Resubscribe Attribute Value Notification subscription.
Resubscribe to Attribute Value Notification when already subscribed from a previous connection. The GATT server will remember subscription from previous connections when bonded, so resubscribing can be done without performing a new subscribe procedure after a power cycle.
id | Local identity (in most cases BT_ID_DEFAULT). |
peer | Remote address. |
params | Subscribe parameters. |
int bt_gatt_subscribe | ( | struct bt_conn * | conn, |
struct bt_gatt_subscribe_params * | params | ||
) |
#include <include/bluetooth/gatt.h>
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.
conn | Connection object. |
params | Subscribe parameters. |
int bt_gatt_unsubscribe | ( | struct bt_conn * | conn, |
struct bt_gatt_subscribe_params * | params | ||
) |
#include <include/bluetooth/gatt.h>
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.
conn | Connection object. |
params | Subscribe parameters. |
int bt_gatt_write | ( | struct bt_conn * | conn, |
struct bt_gatt_write_params * | params | ||
) |
#include <include/bluetooth/gatt.h>
Write Attribute Value by handle.
This procedure write the attribute value and return the result in the callback.
conn | Connection object. |
params | Write parameters. |
|
inlinestatic |
#include <include/bluetooth/gatt.h>
Write Attribute Value by handle without response.
This procedure write the attribute value without requiring an acknowledgment that the write was successfully performed
conn | Connection object. |
handle | Attribute handle. |
data | Data to be written. |
length | Data length. |
sign | Whether to sign data |
int bt_gatt_write_without_response_cb | ( | struct bt_conn * | conn, |
uint16_t | handle, | ||
const void * | data, | ||
uint16_t | length, | ||
bool | sign, | ||
bt_gatt_complete_func_t | func, | ||
void * | user_data | ||
) |
#include <include/bluetooth/gatt.h>
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.
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
embed:rst:inline :kconfig:`CONFIG_BT_CONN_TX_MAX`
option.
conn | Connection object. |
handle | Attribute handle. |
data | Data to be written. |
length | Data length. |
sign | Whether to sign data |
func | Transmission complete callback. |
user_data | User data to be passed back to callback. |