Zephyr Project API  3.4.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 <stdint.h>
21#include <stddef.h>
22
23#include <sys/types.h>
24
25#include <zephyr/sys/slist.h>
26#include <zephyr/sys/util.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
40
43
46
52
58
65
72
79
85
91};
92
100#define BT_GATT_ERR(_att_err) (-(_att_err))
101
103enum {
110
117
125};
126
127/* Forward declaration of GATT Attribute structure */
128struct bt_gatt_attr;
129
145typedef ssize_t (*bt_gatt_attr_read_func_t)(struct bt_conn *conn,
146 const struct bt_gatt_attr *attr,
147 void *buf, uint16_t len,
148 uint16_t offset);
149
163typedef ssize_t (*bt_gatt_attr_write_func_t)(struct bt_conn *conn,
164 const struct bt_gatt_attr *attr,
165 const void *buf, uint16_t len,
166 uint16_t offset, uint8_t flags);
167
171 const struct bt_uuid *uuid;
184};
185
189 const struct bt_gatt_attr *attrs;
192};
193
200
202};
203
207 const struct bt_uuid *uuid;
210};
211
215 const struct bt_uuid *uuid;
220};
221
233 void (*att_mtu_updated)(struct bt_conn *conn, uint16_t tx, uint16_t rx);
234
236};
237
246#define BT_GATT_CHRC_BROADCAST 0x01
252#define BT_GATT_CHRC_READ 0x02
258#define BT_GATT_CHRC_WRITE_WITHOUT_RESP 0x04
264#define BT_GATT_CHRC_WRITE 0x08
271#define BT_GATT_CHRC_NOTIFY 0x10
277#define BT_GATT_CHRC_INDICATE 0x20
283#define BT_GATT_CHRC_AUTH 0x40
290#define BT_GATT_CHRC_EXT_PROP 0x80
291
295 const struct bt_uuid *uuid;
300};
301
303#define BT_GATT_CEP_RELIABLE_WRITE 0x0001
304#define BT_GATT_CEP_WRITABLE_AUX 0x0002
305
310};
311
319#define BT_GATT_CCC_NOTIFY 0x0001
325#define BT_GATT_CCC_INDICATE 0x0002
326
331};
332
341#define BT_GATT_SCC_BROADCAST 0x0001
342
347};
348
363};
364
378
406
414
422
423enum {
426};
427
438typedef uint8_t (*bt_gatt_attr_func_t)(const struct bt_gatt_attr *attr,
440 void *user_data);
441
454void bt_gatt_foreach_attr_type(uint16_t start_handle, uint16_t end_handle,
455 const struct bt_uuid *uuid,
456 const void *attr_data, uint16_t num_matches,
458 void *user_data);
459
469static inline void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle,
471 void *user_data)
472{
473 bt_gatt_foreach_attr_type(start_handle, end_handle, NULL, NULL, 0, func,
474 user_data);
475}
476
485struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr);
486
502 uint16_t attr_count,
503 const struct bt_uuid *uuid);
504
513
525
541ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
542 void *buf, uint16_t buf_len, uint16_t offset,
543 const void *value, uint16_t value_len);
544
561 const struct bt_gatt_attr *attr,
562 void *buf, uint16_t len, uint16_t offset);
563
571#define BT_GATT_SERVICE_DEFINE(_name, ...) \
572 const struct bt_gatt_attr attr_##_name[] = { __VA_ARGS__ }; \
573 const STRUCT_SECTION_ITERABLE(bt_gatt_service_static, _name) = \
574 BT_GATT_SERVICE(attr_##_name)
575
576#define _BT_GATT_ATTRS_ARRAY_DEFINE(n, _instances, _attrs_def) \
577 static struct bt_gatt_attr attrs_##n[] = _attrs_def(_instances[n])
578
579#define _BT_GATT_SERVICE_ARRAY_ITEM(_n, _) BT_GATT_SERVICE(attrs_##_n)
580
596#define BT_GATT_SERVICE_INSTANCE_DEFINE( \
597 _name, _instances, _instance_num, _attrs_def) \
598 BUILD_ASSERT(ARRAY_SIZE(_instances) == _instance_num, \
599 "The number of array elements does not match its size"); \
600 LISTIFY(_instance_num, _BT_GATT_ATTRS_ARRAY_DEFINE, (;), \
601 _instances, _attrs_def); \
602 static struct bt_gatt_service _name[] = { \
603 LISTIFY(_instance_num, _BT_GATT_SERVICE_ARRAY_ITEM, (,)) \
604 }
605
613#define BT_GATT_SERVICE(_attrs) \
614{ \
615 .attrs = _attrs, \
616 .attr_count = ARRAY_SIZE(_attrs), \
617}
618
626#define BT_GATT_PRIMARY_SERVICE(_service) \
627 BT_GATT_ATTRIBUTE(BT_UUID_GATT_PRIMARY, BT_GATT_PERM_READ, \
628 bt_gatt_attr_read_service, NULL, _service)
629
640#define BT_GATT_SECONDARY_SERVICE(_service) \
641 BT_GATT_ATTRIBUTE(BT_UUID_GATT_SECONDARY, BT_GATT_PERM_READ, \
642 bt_gatt_attr_read_service, NULL, _service)
643
660 const struct bt_gatt_attr *attr,
661 void *buf, uint16_t len, uint16_t offset);
662
670#define BT_GATT_INCLUDE_SERVICE(_service_incl) \
671 BT_GATT_ATTRIBUTE(BT_UUID_GATT_INCLUDE, BT_GATT_PERM_READ, \
672 bt_gatt_attr_read_included, NULL, _service_incl)
673
689ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
690 const struct bt_gatt_attr *attr, void *buf,
691 uint16_t len, uint16_t offset);
692
693#define BT_GATT_CHRC_INIT(_uuid, _handle, _props) \
694{ \
695 .uuid = _uuid, \
696 .value_handle = _handle, \
697 .properties = _props, \
698}
699
717#define BT_GATT_CHARACTERISTIC(_uuid, _props, _perm, _read, _write, _user_data) \
718 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CHRC, BT_GATT_PERM_READ, \
719 bt_gatt_attr_read_chrc, NULL, \
720 ((struct bt_gatt_chrc[]) { \
721 BT_GATT_CHRC_INIT(_uuid, 0U, _props), \
722 })), \
723 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
724
725#if defined(CONFIG_BT_SETTINGS_CCC_LAZY_LOADING)
726 #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_CONN)
727#elif defined(CONFIG_BT_CONN)
728 #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
729#else
730 #define BT_GATT_CCC_MAX 0
731#endif
732
746};
747
749struct _bt_gatt_ccc {
752
755
761 void (*cfg_changed)(const struct bt_gatt_attr *attr, uint16_t value);
762
772 ssize_t (*cfg_write)(struct bt_conn *conn,
773 const struct bt_gatt_attr *attr, uint16_t value);
774
786 bool (*cfg_match)(struct bt_conn *conn,
787 const struct bt_gatt_attr *attr);
788};
789
806ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
807 const struct bt_gatt_attr *attr, void *buf,
808 uint16_t len, uint16_t offset);
809
826ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
827 const struct bt_gatt_attr *attr, const void *buf,
828 uint16_t len, uint16_t offset, uint8_t flags);
829
830
840#define BT_GATT_CCC_INITIALIZER(_changed, _write, _match) \
841 { \
842 .cfg = {}, \
843 .cfg_changed = _changed, \
844 .cfg_write = _write, \
845 .cfg_match = _match, \
846 }
847
857#define BT_GATT_CCC_MANAGED(_ccc, _perm) \
858 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CCC, _perm, \
859 bt_gatt_attr_read_ccc, bt_gatt_attr_write_ccc, \
860 _ccc)
861
871#define BT_GATT_CCC(_changed, _perm) \
872 BT_GATT_CCC_MANAGED(((struct _bt_gatt_ccc[]) \
873 {BT_GATT_CCC_INITIALIZER(_changed, NULL, NULL)}), _perm)
874
891ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
892 const struct bt_gatt_attr *attr, void *buf,
893 uint16_t len, uint16_t offset);
894
902#define BT_GATT_CEP(_value) \
903 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CEP, BT_GATT_PERM_READ, \
904 bt_gatt_attr_read_cep, NULL, (void *)_value)
905
923ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
924 const struct bt_gatt_attr *attr, void *buf,
925 uint16_t len, uint16_t offset);
926
936#define BT_GATT_CUD(_value, _perm) \
937 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CUD, _perm, bt_gatt_attr_read_cud, \
938 NULL, (void *)_value)
939
956ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
957 const struct bt_gatt_attr *attr, void *buf,
958 uint16_t len, uint16_t offset);
959
967#define BT_GATT_CPF(_value) \
968 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CPF, BT_GATT_PERM_READ, \
969 bt_gatt_attr_read_cpf, NULL, (void *)_value)
970
985#define BT_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _user_data) \
986 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
987
1000#define BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data) \
1001{ \
1002 .uuid = _uuid, \
1003 .read = _read, \
1004 .write = _write, \
1005 .user_data = _user_data, \
1006 .handle = 0, \
1007 .perm = _perm, \
1008}
1009
1015typedef void (*bt_gatt_complete_func_t) (struct bt_conn *conn, void *user_data);
1016
1023 const struct bt_uuid *uuid;
1029 const struct bt_gatt_attr *attr;
1031 const void *data;
1038#if defined(CONFIG_BT_EATT)
1039 enum bt_att_chan_opt chan_opt;
1040#endif /* CONFIG_BT_EATT */
1041};
1042
1064int bt_gatt_notify_cb(struct bt_conn *conn,
1065 struct bt_gatt_notify_params *params);
1066
1118int bt_gatt_notify_multiple(struct bt_conn *conn,
1119 uint16_t num_params,
1120 struct bt_gatt_notify_params params[]);
1121
1141static inline int bt_gatt_notify(struct bt_conn *conn,
1142 const struct bt_gatt_attr *attr,
1143 const void *data, uint16_t len)
1144{
1145 struct bt_gatt_notify_params params;
1146
1147 memset(&params, 0, sizeof(params));
1148
1149 params.attr = attr;
1150 params.data = data;
1151 params.len = len;
1152#if defined(CONFIG_BT_EATT)
1153 params.chan_opt = BT_ATT_CHAN_OPT_NONE;
1154#endif /* CONFIG_BT_EATT */
1155
1156 return bt_gatt_notify_cb(conn, &params);
1157}
1158
1178static inline int bt_gatt_notify_uuid(struct bt_conn *conn,
1179 const struct bt_uuid *uuid,
1180 const struct bt_gatt_attr *attr,
1181 const void *data, uint16_t len)
1182{
1183 struct bt_gatt_notify_params params;
1184
1185 memset(&params, 0, sizeof(params));
1186
1187 params.uuid = uuid;
1188 params.attr = attr;
1189 params.data = data;
1190 params.len = len;
1191#if defined(CONFIG_BT_EATT)
1192 params.chan_opt = BT_ATT_CHAN_OPT_NONE;
1193#endif /* CONFIG_BT_EATT */
1194
1195 return bt_gatt_notify_cb(conn, &params);
1196}
1197
1198/* Forward declaration of the bt_gatt_indicate_params structure */
1200
1208typedef void (*bt_gatt_indicate_func_t)(struct bt_conn *conn,
1209 struct bt_gatt_indicate_params *params,
1210 uint8_t err);
1211
1213 struct bt_gatt_indicate_params *params);
1214
1222 const struct bt_uuid *uuid;
1228 const struct bt_gatt_attr *attr;
1234 const void *data;
1238 uint8_t _ref;
1239#if defined(CONFIG_BT_EATT)
1240 enum bt_att_chan_opt chan_opt;
1241#endif /* CONFIG_BT_EATT */
1242};
1243
1269int bt_gatt_indicate(struct bt_conn *conn,
1270 struct bt_gatt_indicate_params *params);
1271
1272
1291bool bt_gatt_is_subscribed(struct bt_conn *conn,
1292 const struct bt_gatt_attr *attr, uint16_t ccc_type);
1293
1303uint16_t bt_gatt_get_mtu(struct bt_conn *conn);
1304
1316 void (*func)(struct bt_conn *conn, uint8_t err,
1317 struct bt_gatt_exchange_params *params);
1318};
1319
1347int bt_gatt_exchange_mtu(struct bt_conn *conn,
1348 struct bt_gatt_exchange_params *params);
1349
1351
1396typedef uint8_t (*bt_gatt_discover_func_t)(struct bt_conn *conn,
1397 const struct bt_gatt_attr *attr,
1398 struct bt_gatt_discover_params *params);
1399
1401enum {
1442};
1443
1447 const struct bt_uuid *uuid;
1450 union {
1451 struct {
1458 } _included;
1461 };
1466#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC)
1468 struct bt_gatt_subscribe_params *sub_params;
1469#endif /* defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC) */
1470#if defined(CONFIG_BT_EATT)
1471 enum bt_att_chan_opt chan_opt;
1472#endif /* CONFIG_BT_EATT */
1473};
1474
1511int bt_gatt_discover(struct bt_conn *conn,
1512 struct bt_gatt_discover_params *params);
1513
1514struct bt_gatt_read_params;
1515
1531typedef uint8_t (*bt_gatt_read_func_t)(struct bt_conn *conn, uint8_t err,
1532 struct bt_gatt_read_params *params,
1533 const void *data, uint16_t length);
1534
1544 union {
1545 struct {
1551 struct {
1568 struct {
1574 const struct bt_uuid *uuid;
1576 };
1577#if defined(CONFIG_BT_EATT)
1578 enum bt_att_chan_opt chan_opt;
1579#endif /* CONFIG_BT_EATT */
1580};
1581
1612int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params);
1613
1615
1623typedef void (*bt_gatt_write_func_t)(struct bt_conn *conn, uint8_t err,
1624 struct bt_gatt_write_params *params);
1625
1635 const void *data;
1638#if defined(CONFIG_BT_EATT)
1639 enum bt_att_chan_opt chan_opt;
1640#endif /* CONFIG_BT_EATT */
1641};
1642
1665int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
1666
1702int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
1703 const void *data, uint16_t length,
1704 bool sign, bt_gatt_complete_func_t func,
1705 void *user_data);
1706
1728static inline int bt_gatt_write_without_response(struct bt_conn *conn,
1729 uint16_t handle, const void *data,
1730 uint16_t length, bool sign)
1731{
1732 return bt_gatt_write_without_response_cb(conn, handle, data, length,
1733 sign, NULL, NULL);
1734}
1735
1737
1754typedef uint8_t (*bt_gatt_notify_func_t)(struct bt_conn *conn,
1755 struct bt_gatt_subscribe_params *params,
1756 const void *data, uint16_t length);
1757
1765typedef void (*bt_gatt_subscribe_func_t)(struct bt_conn *conn, uint8_t err,
1766 struct bt_gatt_subscribe_params *params);
1767
1769enum {
1780
1794
1803
1815
1818
1827
1834#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC)
1836 uint16_t end_handle;
1838 struct bt_gatt_discover_params *disc_params;
1839#endif /* CONFIG_BT_GATT_AUTO_DISCOVER_CCC */
1842#if defined(CONFIG_BT_SMP)
1848#endif
1851
1853#if defined(CONFIG_BT_EATT)
1854 enum bt_att_chan_opt chan_opt;
1855#endif /* CONFIG_BT_EATT */
1856};
1857
1890int bt_gatt_subscribe(struct bt_conn *conn,
1891 struct bt_gatt_subscribe_params *params);
1892
1910 struct bt_gatt_subscribe_params *params);
1911
1936int bt_gatt_unsubscribe(struct bt_conn *conn,
1937 struct bt_gatt_subscribe_params *params);
1938
1956void bt_gatt_cancel(struct bt_conn *conn, void *params);
1957
1960#ifdef __cplusplus
1961}
1962#endif
1963
1968#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:146
@ BT_ATT_CHAN_OPT_NONE
Definition: att.h:148
bt_security_t
Definition: conn.h:351
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:1396
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:1765
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:1531
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:1728
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:1754
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:1623
@ BT_GATT_DISCOVER_DESCRIPTOR
Discover Descriptors.
Definition: gatt.h:1421
@ BT_GATT_DISCOVER_SECONDARY
Definition: gatt.h:1405
@ BT_GATT_DISCOVER_CHARACTERISTIC
Discover Characteristic Values.
Definition: gatt.h:1412
@ BT_GATT_DISCOVER_INCLUDE
Definition: gatt.h:1407
@ BT_GATT_DISCOVER_STD_CHAR_DESC
Discover standard characteristic descriptor values.
Definition: gatt.h:1441
@ BT_GATT_DISCOVER_PRIMARY
Definition: gatt.h:1403
@ BT_GATT_DISCOVER_ATTRIBUTE
Discover Attributes.
Definition: gatt.h:1430
@ BT_GATT_SUBSCRIBE_FLAG_NO_RESUB
No resubscribe flag.
Definition: gatt.h:1793
@ BT_GATT_SUBSCRIBE_NUM_FLAGS
Definition: gatt.h:1816
@ BT_GATT_SUBSCRIBE_FLAG_SENT
Sent flag.
Definition: gatt.h:1814
@ BT_GATT_SUBSCRIBE_FLAG_VOLATILE
Persistence flag.
Definition: gatt.h:1779
@ BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING
Write pending flag.
Definition: gatt.h:1802
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:1208
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:1178
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:1212
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:1141
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:469
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:730
void(* bt_gatt_complete_func_t)(struct bt_conn *conn, void *user_data)
Notification complete result callback.
Definition: gatt.h:1015
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:438
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:424
@ BT_GATT_ITER_CONTINUE
Definition: gatt.h:425
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:145
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:163
bt_gatt_perm
Definition: gatt.h:37
@ BT_GATT_PERM_READ_ENCRYPT
Attribute read permission with encryption.
Definition: gatt.h:51
@ BT_GATT_PERM_WRITE
Definition: gatt.h:45
@ BT_GATT_PERM_WRITE_ENCRYPT
Attribute write permission with encryption.
Definition: gatt.h:57
@ BT_GATT_PERM_NONE
Definition: gatt.h:39
@ BT_GATT_PERM_READ
Definition: gatt.h:42
@ BT_GATT_PERM_PREPARE_WRITE
Attribute prepare write permission.
Definition: gatt.h:78
@ BT_GATT_PERM_WRITE_LESC
Attribute write permission with LE Secure Connection encryption.
Definition: gatt.h:90
@ BT_GATT_PERM_READ_AUTHEN
Attribute read permission with authentication.
Definition: gatt.h:64
@ BT_GATT_PERM_WRITE_AUTHEN
Attribute write permission with authentication.
Definition: gatt.h:71
@ BT_GATT_PERM_READ_LESC
Attribute read permission with LE Secure Connection encryption.
Definition: gatt.h:84
@ BT_GATT_WRITE_FLAG_PREPARE
Attribute prepare write flag.
Definition: gatt.h:109
@ BT_GATT_WRITE_FLAG_CMD
Attribute write command flag.
Definition: gatt.h:116
@ BT_GATT_WRITE_FLAG_EXECUTE
Attribute write execute flag.
Definition: gatt.h:124
#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:49
GATT Attribute structure.
Definition: gatt.h:169
bt_gatt_attr_read_func_t read
Definition: gatt.h:172
uint16_t perm
Attribute permissions.
Definition: gatt.h:183
bt_gatt_attr_write_func_t write
Definition: gatt.h:174
const struct bt_uuid * uuid
Definition: gatt.h:171
void * user_data
Definition: gatt.h:176
uint16_t handle
Definition: gatt.h:178
GATT callback structure.
Definition: gatt.h:223
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:233
sys_snode_t node
Definition: gatt.h:235
GATT CCC configuration entry.
Definition: gatt.h:734
uint16_t value
Definition: gatt.h:745
bt_addr_le_t peer
Definition: gatt.h:738
uint8_t id
Definition: gatt.h:736
bool link_encrypted
Definition: gatt.h:743
Definition: gatt.h:328
uint16_t flags
Definition: gatt.h:330
Characteristic Extended Properties Attribute Value.
Definition: gatt.h:307
uint16_t properties
Definition: gatt.h:309
Characteristic Attribute Value.
Definition: gatt.h:293
uint16_t value_handle
Definition: gatt.h:297
uint8_t properties
Definition: gatt.h:299
const struct bt_uuid * uuid
Definition: gatt.h:295
GATT Characteristic Presentation Format Attribute Value.
Definition: gatt.h:350
uint8_t name_space
Definition: gatt.h:360
uint16_t unit
Definition: gatt.h:358
int8_t exponent
Definition: gatt.h:356
uint16_t description
Definition: gatt.h:362
uint8_t format
Definition: gatt.h:352
GATT Discover Attributes parameters.
Definition: gatt.h:1445
uint16_t start_handle
Definition: gatt.h:1455
uint16_t end_handle
Definition: gatt.h:1457
bt_gatt_discover_func_t func
Definition: gatt.h:1449
uint16_t attr_handle
Definition: gatt.h:1453
const struct bt_uuid * uuid
Definition: gatt.h:1447
uint8_t type
Definition: gatt.h:1465
GATT Exchange MTU parameters.
Definition: gatt.h:1314
void(* func)(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
Definition: gatt.h:1316
Include Attribute Value.
Definition: gatt.h:213
uint16_t end_handle
Definition: gatt.h:219
uint16_t start_handle
Definition: gatt.h:217
const struct bt_uuid * uuid
Definition: gatt.h:215
GATT Indicate Value parameters.
Definition: gatt.h:1216
uint16_t len
Definition: gatt.h:1236
const struct bt_gatt_attr * attr
Indicate Attribute object.
Definition: gatt.h:1228
const void * data
Definition: gatt.h:1234
bt_gatt_indicate_params_destroy_t destroy
Definition: gatt.h:1232
bt_gatt_indicate_func_t func
Definition: gatt.h:1230
const struct bt_uuid * uuid
Indicate Attribute UUID type.
Definition: gatt.h:1222
Definition: gatt.h:1017
const struct bt_uuid * uuid
Notification Attribute UUID type.
Definition: gatt.h:1023
uint16_t len
Definition: gatt.h:1033
const struct bt_gatt_attr * attr
Notification Attribute object.
Definition: gatt.h:1029
bt_gatt_complete_func_t func
Definition: gatt.h:1035
void * user_data
Definition: gatt.h:1037
const void * data
Definition: gatt.h:1031
GATT Read parameters.
Definition: gatt.h:1536
struct bt_gatt_read_params::@75::@77 single
size_t handle_count
Definition: gatt.h:1543
uint16_t * handles
Definition: gatt.h:1555
uint16_t offset
Definition: gatt.h:1549
bt_gatt_read_func_t func
Definition: gatt.h:1538
bool variable
Definition: gatt.h:1566
uint16_t end_handle
Definition: gatt.h:1572
struct bt_gatt_read_params::@75::@78 multiple
struct bt_gatt_read_params::@75::@79 by_uuid
uint16_t start_handle
Definition: gatt.h:1570
const struct bt_uuid * uuid
Definition: gatt.h:1574
uint16_t handle
Definition: gatt.h:1547
Definition: gatt.h:344
uint16_t flags
Definition: gatt.h:346
GATT Service structure.
Definition: gatt.h:187
const struct bt_gatt_attr * attrs
Definition: gatt.h:189
size_t attr_count
Definition: gatt.h:191
Service Attribute Value.
Definition: gatt.h:205
const struct bt_uuid * uuid
Definition: gatt.h:207
uint16_t end_handle
Definition: gatt.h:209
GATT Service structure.
Definition: gatt.h:195
struct bt_gatt_attr * attrs
Definition: gatt.h:197
size_t attr_count
Definition: gatt.h:199
sys_snode_t node
Definition: gatt.h:201
GATT Subscribe parameters.
Definition: gatt.h:1820
bt_gatt_write_func_t write
Definition: gatt.h:1829
uint16_t value
Definition: gatt.h:1841
bt_security_t min_security
Definition: gatt.h:1847
uint16_t ccc_handle
Definition: gatt.h:1833
bt_gatt_subscribe_func_t subscribe
Definition: gatt.h:1826
uint16_t value_handle
Definition: gatt.h:1831
sys_snode_t node
Definition: gatt.h:1852
bt_gatt_notify_func_t notify
Definition: gatt.h:1822
GATT Write parameters.
Definition: gatt.h:1627
bt_gatt_write_func_t func
Definition: gatt.h:1629
uint16_t handle
Definition: gatt.h:1631
const void * data
Definition: gatt.h:1635
uint16_t offset
Definition: gatt.h:1633
uint16_t length
Definition: gatt.h:1637
This is a 'tentative' type and should be used as a pointer only.
Definition: uuid.h:49
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.