Zephyr Project API  3.3.0
A Scalable Open Source RTOS
gatt.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2015-2016 Intel Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10#ifndef ZEPHYR_INCLUDE_BLUETOOTH_GATT_H_
11#define ZEPHYR_INCLUDE_BLUETOOTH_GATT_H_
12
20#include <stddef.h>
21#include <zephyr/sys/slist.h>
22#include <sys/types.h>
23#include <zephyr/sys/util.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
36
39
42
48
54
61
68
75
81
87};
88
96#define BT_GATT_ERR(_att_err) (-(_att_err))
97
99enum {
106
113
121};
122
123/* Forward declaration of GATT Attribute structure */
124struct bt_gatt_attr;
125
141typedef ssize_t (*bt_gatt_attr_read_func_t)(struct bt_conn *conn,
142 const struct bt_gatt_attr *attr,
143 void *buf, uint16_t len,
144 uint16_t offset);
145
159typedef ssize_t (*bt_gatt_attr_write_func_t)(struct bt_conn *conn,
160 const struct bt_gatt_attr *attr,
161 const void *buf, uint16_t len,
162 uint16_t offset, uint8_t flags);
163
167 const struct bt_uuid *uuid;
180};
181
185 const struct bt_gatt_attr *attrs;
188};
189
196
198};
199
203 const struct bt_uuid *uuid;
206};
207
211 const struct bt_uuid *uuid;
216};
217
229 void (*att_mtu_updated)(struct bt_conn *conn, uint16_t tx, uint16_t rx);
230
232};
233
242#define BT_GATT_CHRC_BROADCAST 0x01
248#define BT_GATT_CHRC_READ 0x02
254#define BT_GATT_CHRC_WRITE_WITHOUT_RESP 0x04
260#define BT_GATT_CHRC_WRITE 0x08
267#define BT_GATT_CHRC_NOTIFY 0x10
273#define BT_GATT_CHRC_INDICATE 0x20
279#define BT_GATT_CHRC_AUTH 0x40
286#define BT_GATT_CHRC_EXT_PROP 0x80
287
291 const struct bt_uuid *uuid;
296};
297
299#define BT_GATT_CEP_RELIABLE_WRITE 0x0001
300#define BT_GATT_CEP_WRITABLE_AUX 0x0002
301
306};
307
315#define BT_GATT_CCC_NOTIFY 0x0001
321#define BT_GATT_CCC_INDICATE 0x0002
322
327};
328
337#define BT_GATT_SCC_BROADCAST 0x0001
338
343};
344
359};
360
374
396
404
412
413enum {
416};
417
428typedef uint8_t (*bt_gatt_attr_func_t)(const struct bt_gatt_attr *attr,
430 void *user_data);
431
444void bt_gatt_foreach_attr_type(uint16_t start_handle, uint16_t end_handle,
445 const struct bt_uuid *uuid,
446 const void *attr_data, uint16_t num_matches,
448 void *user_data);
449
459static inline void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle,
461 void *user_data)
462{
463 bt_gatt_foreach_attr_type(start_handle, end_handle, NULL, NULL, 0, func,
464 user_data);
465}
466
475struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr);
476
492 uint16_t attr_count,
493 const struct bt_uuid *uuid);
494
503
515
531ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
532 void *buf, uint16_t buf_len, uint16_t offset,
533 const void *value, uint16_t value_len);
534
551 const struct bt_gatt_attr *attr,
552 void *buf, uint16_t len, uint16_t offset);
553
561#define BT_GATT_SERVICE_DEFINE(_name, ...) \
562 const struct bt_gatt_attr attr_##_name[] = { __VA_ARGS__ }; \
563 const STRUCT_SECTION_ITERABLE(bt_gatt_service_static, _name) = \
564 BT_GATT_SERVICE(attr_##_name)
565
566#define _BT_GATT_ATTRS_ARRAY_DEFINE(n, _instances, _attrs_def) \
567 static struct bt_gatt_attr attrs_##n[] = _attrs_def(_instances[n])
568
569#define _BT_GATT_SERVICE_ARRAY_ITEM(_n, _) BT_GATT_SERVICE(attrs_##_n)
570
586#define BT_GATT_SERVICE_INSTANCE_DEFINE( \
587 _name, _instances, _instance_num, _attrs_def) \
588 BUILD_ASSERT(ARRAY_SIZE(_instances) == _instance_num, \
589 "The number of array elements does not match its size"); \
590 LISTIFY(_instance_num, _BT_GATT_ATTRS_ARRAY_DEFINE, (;), \
591 _instances, _attrs_def); \
592 static struct bt_gatt_service _name[] = { \
593 LISTIFY(_instance_num, _BT_GATT_SERVICE_ARRAY_ITEM, (,)) \
594 }
595
603#define BT_GATT_SERVICE(_attrs) \
604{ \
605 .attrs = _attrs, \
606 .attr_count = ARRAY_SIZE(_attrs), \
607}
608
616#define BT_GATT_PRIMARY_SERVICE(_service) \
617 BT_GATT_ATTRIBUTE(BT_UUID_GATT_PRIMARY, BT_GATT_PERM_READ, \
618 bt_gatt_attr_read_service, NULL, _service)
619
630#define BT_GATT_SECONDARY_SERVICE(_service) \
631 BT_GATT_ATTRIBUTE(BT_UUID_GATT_SECONDARY, BT_GATT_PERM_READ, \
632 bt_gatt_attr_read_service, NULL, _service)
633
650 const struct bt_gatt_attr *attr,
651 void *buf, uint16_t len, uint16_t offset);
652
660#define BT_GATT_INCLUDE_SERVICE(_service_incl) \
661 BT_GATT_ATTRIBUTE(BT_UUID_GATT_INCLUDE, BT_GATT_PERM_READ, \
662 bt_gatt_attr_read_included, NULL, _service_incl)
663
679ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
680 const struct bt_gatt_attr *attr, void *buf,
681 uint16_t len, uint16_t offset);
682
683#define BT_GATT_CHRC_INIT(_uuid, _handle, _props) \
684{ \
685 .uuid = _uuid, \
686 .value_handle = _handle, \
687 .properties = _props, \
688}
689
707#define BT_GATT_CHARACTERISTIC(_uuid, _props, _perm, _read, _write, _user_data) \
708 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CHRC, BT_GATT_PERM_READ, \
709 bt_gatt_attr_read_chrc, NULL, \
710 ((struct bt_gatt_chrc[]) { \
711 BT_GATT_CHRC_INIT(_uuid, 0U, _props), \
712 })), \
713 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
714
715#if defined(CONFIG_BT_SETTINGS_CCC_LAZY_LOADING)
716 #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_CONN)
717#elif defined(CONFIG_BT_CONN)
718 #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
719#else
720 #define BT_GATT_CCC_MAX 0
721#endif
722
731};
732
734struct _bt_gatt_ccc {
737
740
746 void (*cfg_changed)(const struct bt_gatt_attr *attr, uint16_t value);
747
757 ssize_t (*cfg_write)(struct bt_conn *conn,
758 const struct bt_gatt_attr *attr, uint16_t value);
759
771 bool (*cfg_match)(struct bt_conn *conn,
772 const struct bt_gatt_attr *attr);
773};
774
791ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
792 const struct bt_gatt_attr *attr, void *buf,
793 uint16_t len, uint16_t offset);
794
811ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
812 const struct bt_gatt_attr *attr, const void *buf,
813 uint16_t len, uint16_t offset, uint8_t flags);
814
815
825#define BT_GATT_CCC_INITIALIZER(_changed, _write, _match) \
826 { \
827 .cfg = {}, \
828 .cfg_changed = _changed, \
829 .cfg_write = _write, \
830 .cfg_match = _match, \
831 }
832
842#define BT_GATT_CCC_MANAGED(_ccc, _perm) \
843 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CCC, _perm, \
844 bt_gatt_attr_read_ccc, bt_gatt_attr_write_ccc, \
845 _ccc)
846
856#define BT_GATT_CCC(_changed, _perm) \
857 BT_GATT_CCC_MANAGED(((struct _bt_gatt_ccc[]) \
858 {BT_GATT_CCC_INITIALIZER(_changed, NULL, NULL)}), _perm)
859
876ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
877 const struct bt_gatt_attr *attr, void *buf,
878 uint16_t len, uint16_t offset);
879
887#define BT_GATT_CEP(_value) \
888 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CEP, BT_GATT_PERM_READ, \
889 bt_gatt_attr_read_cep, NULL, (void *)_value)
890
908ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
909 const struct bt_gatt_attr *attr, void *buf,
910 uint16_t len, uint16_t offset);
911
921#define BT_GATT_CUD(_value, _perm) \
922 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CUD, _perm, bt_gatt_attr_read_cud, \
923 NULL, (void *)_value)
924
941ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
942 const struct bt_gatt_attr *attr, void *buf,
943 uint16_t len, uint16_t offset);
944
952#define BT_GATT_CPF(_value) \
953 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CPF, BT_GATT_PERM_READ, \
954 bt_gatt_attr_read_cpf, NULL, (void *)_value)
955
970#define BT_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _user_data) \
971 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
972
985#define BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data) \
986{ \
987 .uuid = _uuid, \
988 .read = _read, \
989 .write = _write, \
990 .user_data = _user_data, \
991 .handle = 0, \
992 .perm = _perm, \
993}
994
1000typedef void (*bt_gatt_complete_func_t) (struct bt_conn *conn, void *user_data);
1001
1008 const struct bt_uuid *uuid;
1014 const struct bt_gatt_attr *attr;
1016 const void *data;
1023#if defined(CONFIG_BT_EATT)
1024 enum bt_att_chan_opt chan_opt;
1025#endif /* CONFIG_BT_EATT */
1026};
1027
1049int bt_gatt_notify_cb(struct bt_conn *conn,
1050 struct bt_gatt_notify_params *params);
1051
1103int bt_gatt_notify_multiple(struct bt_conn *conn,
1104 uint16_t num_params,
1105 struct bt_gatt_notify_params params[]);
1106
1126static inline int bt_gatt_notify(struct bt_conn *conn,
1127 const struct bt_gatt_attr *attr,
1128 const void *data, uint16_t len)
1129{
1130 struct bt_gatt_notify_params params;
1131
1132 memset(&params, 0, sizeof(params));
1133
1134 params.attr = attr;
1135 params.data = data;
1136 params.len = len;
1137#if defined(CONFIG_BT_EATT)
1138 params.chan_opt = BT_ATT_CHAN_OPT_NONE;
1139#endif /* CONFIG_BT_EATT */
1140
1141 return bt_gatt_notify_cb(conn, &params);
1142}
1143
1163static inline int bt_gatt_notify_uuid(struct bt_conn *conn,
1164 const struct bt_uuid *uuid,
1165 const struct bt_gatt_attr *attr,
1166 const void *data, uint16_t len)
1167{
1168 struct bt_gatt_notify_params params;
1169
1170 memset(&params, 0, sizeof(params));
1171
1172 params.uuid = uuid;
1173 params.attr = attr;
1174 params.data = data;
1175 params.len = len;
1176#if defined(CONFIG_BT_EATT)
1177 params.chan_opt = BT_ATT_CHAN_OPT_NONE;
1178#endif /* CONFIG_BT_EATT */
1179
1180 return bt_gatt_notify_cb(conn, &params);
1181}
1182
1183/* Forward declaration of the bt_gatt_indicate_params structure */
1185
1193typedef void (*bt_gatt_indicate_func_t)(struct bt_conn *conn,
1194 struct bt_gatt_indicate_params *params,
1195 uint8_t err);
1196
1198 struct bt_gatt_indicate_params *params);
1199
1207 const struct bt_uuid *uuid;
1213 const struct bt_gatt_attr *attr;
1219 const void *data;
1223 uint8_t _ref;
1224#if defined(CONFIG_BT_EATT)
1225 enum bt_att_chan_opt chan_opt;
1226#endif /* CONFIG_BT_EATT */
1227};
1228
1254int bt_gatt_indicate(struct bt_conn *conn,
1255 struct bt_gatt_indicate_params *params);
1256
1257
1276bool bt_gatt_is_subscribed(struct bt_conn *conn,
1277 const struct bt_gatt_attr *attr, uint16_t ccc_type);
1278
1288uint16_t bt_gatt_get_mtu(struct bt_conn *conn);
1289
1301 void (*func)(struct bt_conn *conn, uint8_t err,
1302 struct bt_gatt_exchange_params *params);
1303};
1304
1332int bt_gatt_exchange_mtu(struct bt_conn *conn,
1333 struct bt_gatt_exchange_params *params);
1334
1336
1381typedef uint8_t (*bt_gatt_discover_func_t)(struct bt_conn *conn,
1382 const struct bt_gatt_attr *attr,
1383 struct bt_gatt_discover_params *params);
1384
1386enum {
1427};
1428
1432 const struct bt_uuid *uuid;
1435 union {
1436 struct {
1443 } _included;
1446 };
1451#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC)
1453 struct bt_gatt_subscribe_params *sub_params;
1454#endif /* defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC) */
1455#if defined(CONFIG_BT_EATT)
1456 enum bt_att_chan_opt chan_opt;
1457#endif /* CONFIG_BT_EATT */
1458};
1459
1496int bt_gatt_discover(struct bt_conn *conn,
1497 struct bt_gatt_discover_params *params);
1498
1499struct bt_gatt_read_params;
1500
1513typedef uint8_t (*bt_gatt_read_func_t)(struct bt_conn *conn, uint8_t err,
1514 struct bt_gatt_read_params *params,
1515 const void *data, uint16_t length);
1516
1526 union {
1527 struct {
1533 struct {
1550 struct {
1556 const struct bt_uuid *uuid;
1558 };
1559#if defined(CONFIG_BT_EATT)
1560 enum bt_att_chan_opt chan_opt;
1561#endif /* CONFIG_BT_EATT */
1562};
1563
1594int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params);
1595
1597
1605typedef void (*bt_gatt_write_func_t)(struct bt_conn *conn, uint8_t err,
1606 struct bt_gatt_write_params *params);
1607
1617 const void *data;
1620#if defined(CONFIG_BT_EATT)
1621 enum bt_att_chan_opt chan_opt;
1622#endif /* CONFIG_BT_EATT */
1623};
1624
1647int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
1648
1684int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
1685 const void *data, uint16_t length,
1686 bool sign, bt_gatt_complete_func_t func,
1687 void *user_data);
1688
1710static inline int bt_gatt_write_without_response(struct bt_conn *conn,
1711 uint16_t handle, const void *data,
1712 uint16_t length, bool sign)
1713{
1714 return bt_gatt_write_without_response_cb(conn, handle, data, length,
1715 sign, NULL, NULL);
1716}
1717
1719
1736typedef uint8_t (*bt_gatt_notify_func_t)(struct bt_conn *conn,
1737 struct bt_gatt_subscribe_params *params,
1738 const void *data, uint16_t length);
1739
1747typedef void (*bt_gatt_subscribe_func_t)(struct bt_conn *conn, uint8_t err,
1748 struct bt_gatt_subscribe_params *params);
1749
1751enum {
1762
1776
1785
1797
1800
1809
1816#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC)
1818 uint16_t end_handle;
1820 struct bt_gatt_discover_params *disc_params;
1821#endif /* CONFIG_BT_GATT_AUTO_DISCOVER_CCC */
1824#if defined(CONFIG_BT_SMP)
1830#endif
1833
1835#if defined(CONFIG_BT_EATT)
1836 enum bt_att_chan_opt chan_opt;
1837#endif /* CONFIG_BT_EATT */
1838};
1839
1872int bt_gatt_subscribe(struct bt_conn *conn,
1873 struct bt_gatt_subscribe_params *params);
1874
1892 struct bt_gatt_subscribe_params *params);
1893
1918int bt_gatt_unsubscribe(struct bt_conn *conn,
1919 struct bt_gatt_subscribe_params *params);
1920
1938void bt_gatt_cancel(struct bt_conn *conn, void *params);
1939
1942#ifdef __cplusplus
1943}
1944#endif
1945
1950#endif /* ZEPHYR_INCLUDE_BLUETOOTH_GATT_H_ */
Attribute Protocol handling.
Bluetooth connection handling.
#define ATOMIC_DEFINE(name, num_bits)
Define an array of atomic variables.
Definition: atomic.h:114
bt_att_chan_opt
ATT channel option bit field values.
Definition: att.h:107
@ BT_ATT_CHAN_OPT_NONE
Definition: att.h:109
bt_security_t
Definition: conn.h:339
int bt_gatt_exchange_mtu(struct bt_conn *conn, struct bt_gatt_exchange_params *params)
Exchange MTU.
int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params)
Read Attribute Value by handle.
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.
Definition: gatt.h:1381
void(* bt_gatt_subscribe_func_t)(struct bt_conn *conn, uint8_t err, struct bt_gatt_subscribe_params *params)
Subscription callback function.
Definition: gatt.h:1747
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.
void bt_gatt_cancel(struct bt_conn *conn, void *params)
Try to cancel the first pending request identified by params.
int bt_gatt_unsubscribe(struct bt_conn *conn, struct bt_gatt_subscribe_params *params)
Unsubscribe Attribute Value Notification.
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.
Definition: gatt.h:1513
int bt_gatt_resubscribe(uint8_t id, const bt_addr_le_t *peer, struct bt_gatt_subscribe_params *params)
Resubscribe Attribute Value Notification subscription.
int bt_gatt_subscribe(struct bt_conn *conn, struct bt_gatt_subscribe_params *params)
Subscribe Attribute Value Notification.
int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params)
Write Attribute Value by handle.
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.
Definition: gatt.h:1710
int bt_gatt_discover(struct bt_conn *conn, struct bt_gatt_discover_params *params)
GATT Discover function.
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.
Definition: gatt.h:1736
void(* bt_gatt_write_func_t)(struct bt_conn *conn, uint8_t err, struct bt_gatt_write_params *params)
Write callback function.
Definition: gatt.h:1605
@ BT_GATT_DISCOVER_DESCRIPTOR
Discover Descriptors.
Definition: gatt.h:1406
@ BT_GATT_DISCOVER_SECONDARY
Definition: gatt.h:1390
@ BT_GATT_DISCOVER_CHARACTERISTIC
Discover Characteristic Values.
Definition: gatt.h:1397
@ BT_GATT_DISCOVER_INCLUDE
Definition: gatt.h:1392
@ BT_GATT_DISCOVER_STD_CHAR_DESC
Discover standard characteristic descriptor values.
Definition: gatt.h:1426
@ BT_GATT_DISCOVER_PRIMARY
Definition: gatt.h:1388
@ BT_GATT_DISCOVER_ATTRIBUTE
Discover Attributes.
Definition: gatt.h:1415
@ BT_GATT_SUBSCRIBE_FLAG_NO_RESUB
No resubscribe flag.
Definition: gatt.h:1775
@ BT_GATT_SUBSCRIBE_NUM_FLAGS
Definition: gatt.h:1798
@ BT_GATT_SUBSCRIBE_FLAG_SENT
Sent flag.
Definition: gatt.h:1796
@ BT_GATT_SUBSCRIBE_FLAG_VOLATILE
Persistence flag.
Definition: gatt.h:1761
@ BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING
Write pending flag.
Definition: gatt.h:1784
void(* bt_gatt_indicate_func_t)(struct bt_conn *conn, struct bt_gatt_indicate_params *params, uint8_t err)
Indication complete result callback.
Definition: gatt.h:1193
static int bt_gatt_notify_uuid(struct bt_conn *conn, const struct bt_uuid *uuid, const struct bt_gatt_attr *attr, const void *data, uint16_t len)
Notify attribute value change by UUID.
Definition: gatt.h:1163
void bt_gatt_cb_register(struct bt_gatt_cb *cb)
Register GATT callbacks.
ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
Read Characteristic User Description Descriptor Attribute helper.
uint16_t bt_gatt_attr_get_handle(const struct bt_gatt_attr *attr)
Get Attribute handle.
ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
Read Client Characteristic Configuration Attribute helper.
uint16_t bt_gatt_get_mtu(struct bt_conn *conn)
Get ATT MTU for a connection.
struct bt_gatt_attr * bt_gatt_attr_next(const struct bt_gatt_attr *attr)
Iterate to the next attribute.
ssize_t bt_gatt_attr_read_included(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
Read Include Attribute helper.
int bt_gatt_indicate(struct bt_conn *conn, struct bt_gatt_indicate_params *params)
Indicate attribute value change.
int bt_gatt_notify_cb(struct bt_conn *conn, struct bt_gatt_notify_params *params)
Notify attribute value change.
ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
Read Characteristic Extended Properties Attribute helper.
ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
Read Characteristic Presentation format Descriptor Attribute helper.
void(* bt_gatt_indicate_params_destroy_t)(struct bt_gatt_indicate_params *params)
Definition: gatt.h:1197
static int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *data, uint16_t len)
Notify attribute value change.
Definition: gatt.h:1126
int bt_gatt_notify_multiple(struct bt_conn *conn, uint16_t num_params, struct bt_gatt_notify_params params[])
Send multiple notifications in a single PDU.
uint16_t bt_gatt_attr_value_handle(const struct bt_gatt_attr *attr)
Get the handle of the characteristic value descriptor.
static void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle, bt_gatt_attr_func_t func, void *user_data)
Attribute iterator.
Definition: gatt.h:459
int bt_gatt_service_register(struct bt_gatt_service *svc)
Register GATT service.
ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, uint16_t len, uint16_t offset, uint8_t flags)
Write Client Characteristic Configuration Attribute helper.
bool bt_gatt_is_subscribed(struct bt_conn *conn, const struct bt_gatt_attr *attr, uint16_t ccc_type)
Check if connection have subscribed to attribute.
#define BT_GATT_CCC_MAX
Definition: gatt.h:720
void(* bt_gatt_complete_func_t)(struct bt_conn *conn, void *user_data)
Notification complete result callback.
Definition: gatt.h:1000
ssize_t bt_gatt_attr_read_service(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
Read Service Attribute helper.
struct bt_gatt_attr * bt_gatt_find_by_uuid(const struct bt_gatt_attr *attr, uint16_t attr_count, const struct bt_uuid *uuid)
Find Attribute by UUID.
ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
Read Characteristic Attribute helper.
void bt_gatt_foreach_attr_type(uint16_t start_handle, uint16_t end_handle, const struct bt_uuid *uuid, const void *attr_data, uint16_t num_matches, bt_gatt_attr_func_t func, void *user_data)
Attribute iterator by type.
bool bt_gatt_service_is_registered(const struct bt_gatt_service *svc)
Check if GATT service is registered.
uint8_t(* bt_gatt_attr_func_t)(const struct bt_gatt_attr *attr, uint16_t handle, void *user_data)
Attribute iterator callback.
Definition: gatt.h:428
int bt_gatt_service_unregister(struct bt_gatt_service *svc)
Unregister GATT service.
ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t buf_len, uint16_t offset, const void *value, uint16_t value_len)
Generic Read Attribute value helper.
@ BT_GATT_ITER_STOP
Definition: gatt.h:414
@ BT_GATT_ITER_CONTINUE
Definition: gatt.h:415
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.
Definition: gatt.h:141
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.
Definition: gatt.h:159
bt_gatt_perm
Definition: gatt.h:33
@ BT_GATT_PERM_READ_ENCRYPT
Attribute read permission with encryption.
Definition: gatt.h:47
@ BT_GATT_PERM_WRITE
Definition: gatt.h:41
@ BT_GATT_PERM_WRITE_ENCRYPT
Attribute write permission with encryption.
Definition: gatt.h:53
@ BT_GATT_PERM_NONE
Definition: gatt.h:35
@ BT_GATT_PERM_READ
Definition: gatt.h:38
@ BT_GATT_PERM_PREPARE_WRITE
Attribute prepare write permission.
Definition: gatt.h:74
@ BT_GATT_PERM_WRITE_LESC
Attribute write permission with LE Secure Connection encryption.
Definition: gatt.h:86
@ BT_GATT_PERM_READ_AUTHEN
Attribute read permission with authentication.
Definition: gatt.h:60
@ BT_GATT_PERM_WRITE_AUTHEN
Attribute write permission with authentication.
Definition: gatt.h:67
@ BT_GATT_PERM_READ_LESC
Attribute read permission with LE Secure Connection encryption.
Definition: gatt.h:80
@ BT_GATT_WRITE_FLAG_PREPARE
Attribute prepare write flag.
Definition: gatt.h:105
@ BT_GATT_WRITE_FLAG_CMD
Attribute write command flag.
Definition: gatt.h:112
@ BT_GATT_WRITE_FLAG_EXECUTE
Attribute write execute flag.
Definition: gatt.h:120
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
__SIZE_TYPE__ ssize_t
Definition: types.h:28
flags
Definition: parser.h:96
Single-linked list implementation.
struct _snode sys_snode_t
Definition: slist.h:33
#define bool
Definition: stdbool.h:13
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
__INT8_TYPE__ int8_t
Definition: stdint.h:72
void * memset(void *buf, int c, size_t n)
Definition: addr.h:48
GATT Attribute structure.
Definition: gatt.h:165
bt_gatt_attr_read_func_t read
Definition: gatt.h:168
uint16_t perm
Attribute permissions.
Definition: gatt.h:179
bt_gatt_attr_write_func_t write
Definition: gatt.h:170
const struct bt_uuid * uuid
Definition: gatt.h:167
void * user_data
Definition: gatt.h:172
uint16_t handle
Definition: gatt.h:174
GATT callback structure.
Definition: gatt.h:219
void(* att_mtu_updated)(struct bt_conn *conn, uint16_t tx, uint16_t rx)
The maximum ATT MTU on a connection has changed.
Definition: gatt.h:229
sys_snode_t node
Definition: gatt.h:231
GATT CCC configuration entry.
Definition: gatt.h:724
uint16_t value
Definition: gatt.h:730
bt_addr_le_t peer
Definition: gatt.h:728
uint8_t id
Definition: gatt.h:726
Definition: gatt.h:324
uint16_t flags
Definition: gatt.h:326
Characteristic Extended Properties Attribute Value.
Definition: gatt.h:303
uint16_t properties
Definition: gatt.h:305
Characteristic Attribute Value.
Definition: gatt.h:289
uint16_t value_handle
Definition: gatt.h:293
uint8_t properties
Definition: gatt.h:295
const struct bt_uuid * uuid
Definition: gatt.h:291
GATT Characteristic Presentation Format Attribute Value.
Definition: gatt.h:346
uint8_t name_space
Definition: gatt.h:356
uint16_t unit
Definition: gatt.h:354
int8_t exponent
Definition: gatt.h:352
uint16_t description
Definition: gatt.h:358
uint8_t format
Definition: gatt.h:348
GATT Discover Attributes parameters.
Definition: gatt.h:1430
uint16_t start_handle
Definition: gatt.h:1440
uint16_t end_handle
Definition: gatt.h:1442
bt_gatt_discover_func_t func
Definition: gatt.h:1434
uint16_t attr_handle
Definition: gatt.h:1438
const struct bt_uuid * uuid
Definition: gatt.h:1432
uint8_t type
Definition: gatt.h:1450
GATT Exchange MTU parameters.
Definition: gatt.h:1299
void(* func)(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
Definition: gatt.h:1301
Include Attribute Value.
Definition: gatt.h:209
uint16_t end_handle
Definition: gatt.h:215
uint16_t start_handle
Definition: gatt.h:213
const struct bt_uuid * uuid
Definition: gatt.h:211
GATT Indicate Value parameters.
Definition: gatt.h:1201
uint16_t len
Definition: gatt.h:1221
const struct bt_gatt_attr * attr
Indicate Attribute object.
Definition: gatt.h:1213
const void * data
Definition: gatt.h:1219
bt_gatt_indicate_params_destroy_t destroy
Definition: gatt.h:1217
bt_gatt_indicate_func_t func
Definition: gatt.h:1215
const struct bt_uuid * uuid
Indicate Attribute UUID type.
Definition: gatt.h:1207
Definition: gatt.h:1002
const struct bt_uuid * uuid
Notification Attribute UUID type.
Definition: gatt.h:1008
uint16_t len
Definition: gatt.h:1018
const struct bt_gatt_attr * attr
Notification Attribute object.
Definition: gatt.h:1014
bt_gatt_complete_func_t func
Definition: gatt.h:1020
void * user_data
Definition: gatt.h:1022
const void * data
Definition: gatt.h:1016
GATT Read parameters.
Definition: gatt.h:1518
struct bt_gatt_read_params::@75::@77 single
size_t handle_count
Definition: gatt.h:1525
uint16_t * handles
Definition: gatt.h:1537
uint16_t offset
Definition: gatt.h:1531
bt_gatt_read_func_t func
Definition: gatt.h:1520
bool variable
Definition: gatt.h:1548
uint16_t end_handle
Definition: gatt.h:1554
struct bt_gatt_read_params::@75::@78 multiple
struct bt_gatt_read_params::@75::@79 by_uuid
uint16_t start_handle
Definition: gatt.h:1552
const struct bt_uuid * uuid
Definition: gatt.h:1556
uint16_t handle
Definition: gatt.h:1529
Definition: gatt.h:340
uint16_t flags
Definition: gatt.h:342
GATT Service structure.
Definition: gatt.h:183
const struct bt_gatt_attr * attrs
Definition: gatt.h:185
size_t attr_count
Definition: gatt.h:187
Service Attribute Value.
Definition: gatt.h:201
const struct bt_uuid * uuid
Definition: gatt.h:203
uint16_t end_handle
Definition: gatt.h:205
GATT Service structure.
Definition: gatt.h:191
struct bt_gatt_attr * attrs
Definition: gatt.h:193
size_t attr_count
Definition: gatt.h:195
sys_snode_t node
Definition: gatt.h:197
GATT Subscribe parameters.
Definition: gatt.h:1802
bt_gatt_write_func_t write
Definition: gatt.h:1811
uint16_t value
Definition: gatt.h:1823
bt_security_t min_security
Definition: gatt.h:1829
uint16_t ccc_handle
Definition: gatt.h:1815
bt_gatt_subscribe_func_t subscribe
Definition: gatt.h:1808
uint16_t value_handle
Definition: gatt.h:1813
sys_snode_t node
Definition: gatt.h:1834
bt_gatt_notify_func_t notify
Definition: gatt.h:1804
GATT Write parameters.
Definition: gatt.h:1609
bt_gatt_write_func_t func
Definition: gatt.h:1611
uint16_t handle
Definition: gatt.h:1613
const void * data
Definition: gatt.h:1617
uint16_t offset
Definition: gatt.h:1615
uint16_t length
Definition: gatt.h:1619
This is a 'tentative' type and should be used as a pointer only.
Definition: uuid.h:46
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
static const intptr_t user_data[5]
Definition: main.c:588
Misc utilities.
Bluetooth UUID handling.