Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
741};
742
744struct _bt_gatt_ccc {
747
749 uint16_t value;
750
756 void (*cfg_changed)(const struct bt_gatt_attr *attr, uint16_t value);
757
767 ssize_t (*cfg_write)(struct bt_conn *conn,
768 const struct bt_gatt_attr *attr, uint16_t value);
769
781 bool (*cfg_match)(struct bt_conn *conn,
782 const struct bt_gatt_attr *attr);
783};
784
801ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
802 const struct bt_gatt_attr *attr, void *buf,
803 uint16_t len, uint16_t offset);
804
821ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
822 const struct bt_gatt_attr *attr, const void *buf,
823 uint16_t len, uint16_t offset, uint8_t flags);
824
825
835#define BT_GATT_CCC_INITIALIZER(_changed, _write, _match) \
836 { \
837 .cfg = {}, \
838 .cfg_changed = _changed, \
839 .cfg_write = _write, \
840 .cfg_match = _match, \
841 }
842
852#define BT_GATT_CCC_MANAGED(_ccc, _perm) \
853 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CCC, _perm, \
854 bt_gatt_attr_read_ccc, bt_gatt_attr_write_ccc, \
855 _ccc)
856
866#define BT_GATT_CCC(_changed, _perm) \
867 BT_GATT_CCC_MANAGED(((struct _bt_gatt_ccc[]) \
868 {BT_GATT_CCC_INITIALIZER(_changed, NULL, NULL)}), _perm)
869
886ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
887 const struct bt_gatt_attr *attr, void *buf,
888 uint16_t len, uint16_t offset);
889
897#define BT_GATT_CEP(_value) \
898 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CEP, BT_GATT_PERM_READ, \
899 bt_gatt_attr_read_cep, NULL, (void *)_value)
900
918ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
919 const struct bt_gatt_attr *attr, void *buf,
920 uint16_t len, uint16_t offset);
921
931#define BT_GATT_CUD(_value, _perm) \
932 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CUD, _perm, bt_gatt_attr_read_cud, \
933 NULL, (void *)_value)
934
951ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
952 const struct bt_gatt_attr *attr, void *buf,
953 uint16_t len, uint16_t offset);
954
962#define BT_GATT_CPF(_value) \
963 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CPF, BT_GATT_PERM_READ, \
964 bt_gatt_attr_read_cpf, NULL, (void *)_value)
965
980#define BT_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _user_data) \
981 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
982
995#define BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data) \
996{ \
997 .uuid = _uuid, \
998 .read = _read, \
999 .write = _write, \
1000 .user_data = _user_data, \
1001 .handle = 0, \
1002 .perm = _perm, \
1003}
1004
1010typedef void (*bt_gatt_complete_func_t) (struct bt_conn *conn, void *user_data);
1011
1018 const struct bt_uuid *uuid;
1024 const struct bt_gatt_attr *attr;
1026 const void *data;
1033#if defined(CONFIG_BT_EATT)
1035#endif /* CONFIG_BT_EATT */
1036};
1037
1059int bt_gatt_notify_cb(struct bt_conn *conn,
1060 struct bt_gatt_notify_params *params);
1061
1113int bt_gatt_notify_multiple(struct bt_conn *conn,
1114 uint16_t num_params,
1115 struct bt_gatt_notify_params params[]);
1116
1136static inline int bt_gatt_notify(struct bt_conn *conn,
1137 const struct bt_gatt_attr *attr,
1138 const void *data, uint16_t len)
1139{
1140 struct bt_gatt_notify_params params;
1141
1142 memset(&params, 0, sizeof(params));
1143
1144 params.attr = attr;
1145 params.data = data;
1146 params.len = len;
1147#if defined(CONFIG_BT_EATT)
1149#endif /* CONFIG_BT_EATT */
1150
1151 return bt_gatt_notify_cb(conn, &params);
1152}
1153
1173static inline int bt_gatt_notify_uuid(struct bt_conn *conn,
1174 const struct bt_uuid *uuid,
1175 const struct bt_gatt_attr *attr,
1176 const void *data, uint16_t len)
1177{
1178 struct bt_gatt_notify_params params;
1179
1180 memset(&params, 0, sizeof(params));
1181
1182 params.uuid = uuid;
1183 params.attr = attr;
1184 params.data = data;
1185 params.len = len;
1186#if defined(CONFIG_BT_EATT)
1188#endif /* CONFIG_BT_EATT */
1189
1190 return bt_gatt_notify_cb(conn, &params);
1191}
1192
1193/* Forward declaration of the bt_gatt_indicate_params structure */
1195
1203typedef void (*bt_gatt_indicate_func_t)(struct bt_conn *conn,
1204 struct bt_gatt_indicate_params *params,
1205 uint8_t err);
1206
1208 struct bt_gatt_indicate_params *params);
1209
1217 const struct bt_uuid *uuid;
1223 const struct bt_gatt_attr *attr;
1229 const void *data;
1233 uint8_t _ref;
1234#if defined(CONFIG_BT_EATT)
1236#endif /* CONFIG_BT_EATT */
1237};
1238
1264int bt_gatt_indicate(struct bt_conn *conn,
1265 struct bt_gatt_indicate_params *params);
1266
1267
1286bool bt_gatt_is_subscribed(struct bt_conn *conn,
1287 const struct bt_gatt_attr *attr, uint16_t ccc_type);
1288
1298uint16_t bt_gatt_get_mtu(struct bt_conn *conn);
1299
1311 void (*func)(struct bt_conn *conn, uint8_t err,
1312 struct bt_gatt_exchange_params *params);
1313};
1314
1342int bt_gatt_exchange_mtu(struct bt_conn *conn,
1343 struct bt_gatt_exchange_params *params);
1344
1346
1391typedef uint8_t (*bt_gatt_discover_func_t)(struct bt_conn *conn,
1392 const struct bt_gatt_attr *attr,
1393 struct bt_gatt_discover_params *params);
1394
1396enum {
1437};
1438
1442 const struct bt_uuid *uuid;
1445 union {
1446 struct {
1453 } _included;
1455 uint16_t start_handle;
1456 };
1461#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC) || defined(__DOXYGEN__)
1464#endif /* defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC) || defined(__DOXYGEN__) */
1465#if defined(CONFIG_BT_EATT)
1467#endif /* CONFIG_BT_EATT */
1468};
1469
1506int bt_gatt_discover(struct bt_conn *conn,
1507 struct bt_gatt_discover_params *params);
1508
1509struct bt_gatt_read_params;
1510
1526typedef uint8_t (*bt_gatt_read_func_t)(struct bt_conn *conn, uint8_t err,
1527 struct bt_gatt_read_params *params,
1528 const void *data, uint16_t length);
1529
1539 union {
1540 struct {
1546 struct {
1563 struct {
1569 const struct bt_uuid *uuid;
1571 };
1572#if defined(CONFIG_BT_EATT)
1574#endif /* CONFIG_BT_EATT */
1575};
1576
1607int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params);
1608
1610
1618typedef void (*bt_gatt_write_func_t)(struct bt_conn *conn, uint8_t err,
1619 struct bt_gatt_write_params *params);
1620
1630 const void *data;
1633#if defined(CONFIG_BT_EATT)
1635#endif /* CONFIG_BT_EATT */
1636};
1637
1660int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
1661
1697int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
1698 const void *data, uint16_t length,
1699 bool sign, bt_gatt_complete_func_t func,
1700 void *user_data);
1701
1723static inline int bt_gatt_write_without_response(struct bt_conn *conn,
1724 uint16_t handle, const void *data,
1725 uint16_t length, bool sign)
1726{
1727 return bt_gatt_write_without_response_cb(conn, handle, data, length,
1728 sign, NULL, NULL);
1729}
1730
1732
1749typedef uint8_t (*bt_gatt_notify_func_t)(struct bt_conn *conn,
1750 struct bt_gatt_subscribe_params *params,
1751 const void *data, uint16_t length);
1752
1760typedef void (*bt_gatt_subscribe_func_t)(struct bt_conn *conn, uint8_t err,
1761 struct bt_gatt_subscribe_params *params);
1762
1764enum {
1775
1789
1798
1810
1813
1822
1829#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC) || defined(__DOXYGEN__)
1834#endif /* defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC) || defined(__DOXYGEN__) */
1837#if defined(CONFIG_BT_SMP)
1843#endif
1846
1848#if defined(CONFIG_BT_EATT)
1850#endif /* CONFIG_BT_EATT */
1851};
1852
1885int bt_gatt_subscribe(struct bt_conn *conn,
1886 struct bt_gatt_subscribe_params *params);
1887
1905 struct bt_gatt_subscribe_params *params);
1906
1931int bt_gatt_unsubscribe(struct bt_conn *conn,
1932 struct bt_gatt_subscribe_params *params);
1933
1951void bt_gatt_cancel(struct bt_conn *conn, void *params);
1952
1955#ifdef __cplusplus
1956}
1957#endif
1958
1963#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
Both Enhanced and Unenhanced channels can be used
Definition: att.h:148
bt_security_t
Security level.
Definition: conn.h:352
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:1391
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:1760
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:1526
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:1723
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:1749
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:1618
@ BT_GATT_DISCOVER_DESCRIPTOR
Discover Descriptors.
Definition: gatt.h:1416
@ BT_GATT_DISCOVER_SECONDARY
Discover Secondary Services.
Definition: gatt.h:1400
@ BT_GATT_DISCOVER_CHARACTERISTIC
Discover Characteristic Values.
Definition: gatt.h:1407
@ BT_GATT_DISCOVER_INCLUDE
Discover Included Services.
Definition: gatt.h:1402
@ BT_GATT_DISCOVER_STD_CHAR_DESC
Discover standard characteristic descriptor values.
Definition: gatt.h:1436
@ BT_GATT_DISCOVER_PRIMARY
Discover Primary Services.
Definition: gatt.h:1398
@ BT_GATT_DISCOVER_ATTRIBUTE
Discover Attributes.
Definition: gatt.h:1425
@ BT_GATT_SUBSCRIBE_FLAG_NO_RESUB
No resubscribe flag.
Definition: gatt.h:1788
@ BT_GATT_SUBSCRIBE_NUM_FLAGS
Definition: gatt.h:1811
@ BT_GATT_SUBSCRIBE_FLAG_SENT
Sent flag.
Definition: gatt.h:1809
@ BT_GATT_SUBSCRIBE_FLAG_VOLATILE
Persistence flag.
Definition: gatt.h:1774
@ BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING
Write pending flag.
Definition: gatt.h:1797
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:1203
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:1173
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:1207
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:1136
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:1010
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
GATT attribute permission bit field values.
Definition: gatt.h:37
@ 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
@ BT_GATT_PERM_READ_ENCRYPT
Attribute read permission with encryption.
Definition: gatt.h:51
@ BT_GATT_PERM_WRITE
Attribute write permission.
Definition: gatt.h:45
@ BT_GATT_PERM_WRITE_ENCRYPT
Attribute write permission with encryption.
Definition: gatt.h:57
@ BT_GATT_PERM_NONE
No operations supported, e.g.
Definition: gatt.h:39
@ BT_GATT_PERM_READ
Attribute read permission.
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
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
#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
#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)
Bluetooth LE Device Address.
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
Attribute write callback.
Definition: gatt.h:174
const struct bt_uuid * uuid
Attribute UUID.
Definition: gatt.h:171
void * user_data
Attribute user data.
Definition: gatt.h:176
uint16_t handle
Attribute 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
Configuration value.
Definition: gatt.h:740
bt_addr_le_t peer
Remote peer address.
Definition: gatt.h:738
uint8_t id
Local identity, BT_ID_DEFAULT in most cases.
Definition: gatt.h:736
Client Characteristic Configuration Attribute Value.
Definition: gatt.h:328
uint16_t flags
Client Characteristic Configuration flags.
Definition: gatt.h:330
Characteristic Extended Properties Attribute Value.
Definition: gatt.h:307
uint16_t properties
Characteristic Extended properties.
Definition: gatt.h:309
Characteristic Attribute Value.
Definition: gatt.h:293
uint16_t value_handle
Characteristic Value handle.
Definition: gatt.h:297
uint8_t properties
Characteristic properties.
Definition: gatt.h:299
const struct bt_uuid * uuid
Characteristic UUID.
Definition: gatt.h:295
GATT Characteristic Presentation Format Attribute Value.
Definition: gatt.h:350
uint8_t name_space
Name space of the description.
Definition: gatt.h:360
uint16_t unit
Unit of the characteristic.
Definition: gatt.h:358
int8_t exponent
Exponent field to determine how the value of this characteristic is further formatted.
Definition: gatt.h:356
uint16_t description
Description of the characteristic as defined in a higher layer profile.
Definition: gatt.h:362
uint8_t format
Format of the value of the characteristic.
Definition: gatt.h:352
GATT Discover Attributes parameters.
Definition: gatt.h:1440
uint16_t start_handle
Included service start handle.
Definition: gatt.h:1450
uint16_t end_handle
Included service end handle.
Definition: gatt.h:1452
bt_gatt_discover_func_t func
Discover attribute callback.
Definition: gatt.h:1444
uint16_t attr_handle
Include service attribute declaration handle.
Definition: gatt.h:1448
const struct bt_uuid * uuid
Discover UUID type.
Definition: gatt.h:1442
struct bt_gatt_subscribe_params * sub_params
Only for stack-internal use, used for automatic discovery.
Definition: gatt.h:1463
uint8_t type
Discover type.
Definition: gatt.h:1460
enum bt_att_chan_opt chan_opt
Definition: gatt.h:1466
GATT Exchange MTU parameters.
Definition: gatt.h:1309
void(* func)(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
Response callback.
Definition: gatt.h:1311
Include Attribute Value.
Definition: gatt.h:213
uint16_t end_handle
Service end handle.
Definition: gatt.h:219
uint16_t start_handle
Service start handle.
Definition: gatt.h:217
const struct bt_uuid * uuid
Service UUID.
Definition: gatt.h:215
GATT Indicate Value parameters.
Definition: gatt.h:1211
enum bt_att_chan_opt chan_opt
Definition: gatt.h:1235
uint16_t len
Indicate Value length.
Definition: gatt.h:1231
const struct bt_gatt_attr * attr
Indicate Attribute object.
Definition: gatt.h:1223
const void * data
Indicate Value data.
Definition: gatt.h:1229
bt_gatt_indicate_params_destroy_t destroy
Indicate operation complete callback.
Definition: gatt.h:1227
bt_gatt_indicate_func_t func
Indicate Value callback.
Definition: gatt.h:1225
const struct bt_uuid * uuid
Indicate Attribute UUID type.
Definition: gatt.h:1217
Definition: gatt.h:1012
const struct bt_uuid * uuid
Notification Attribute UUID type.
Definition: gatt.h:1018
uint16_t len
Notification Value length.
Definition: gatt.h:1028
const struct bt_gatt_attr * attr
Notification Attribute object.
Definition: gatt.h:1024
enum bt_att_chan_opt chan_opt
Definition: gatt.h:1034
bt_gatt_complete_func_t func
Notification Value callback.
Definition: gatt.h:1030
void * user_data
Notification Value callback user data.
Definition: gatt.h:1032
const void * data
Notification Value data.
Definition: gatt.h:1026
GATT Read parameters.
Definition: gatt.h:1531
size_t handle_count
If equals to 1 single.handle and single.offset are used.
Definition: gatt.h:1538
struct bt_gatt_read_params::@72::@75 multiple
enum bt_att_chan_opt chan_opt
Definition: gatt.h:1573
uint16_t * handles
Attribute handles to read with Read Multiple Characteristic Values.
Definition: gatt.h:1550
uint16_t offset
Attribute data offset.
Definition: gatt.h:1544
bt_gatt_read_func_t func
Read attribute callback.
Definition: gatt.h:1533
struct bt_gatt_read_params::@72::@76 by_uuid
bool variable
If true use Read Multiple Variable Length Characteristic Values procedure.
Definition: gatt.h:1561
uint16_t end_handle
Last requested handle number.
Definition: gatt.h:1567
struct bt_gatt_read_params::@72::@74 single
uint16_t start_handle
First requested handle number.
Definition: gatt.h:1565
const struct bt_uuid * uuid
2 or 16 octet UUID.
Definition: gatt.h:1569
uint16_t handle
Attribute handle.
Definition: gatt.h:1542
Server Characteristic Configuration Attribute Value.
Definition: gatt.h:344
uint16_t flags
Server Characteristic Configuration flags.
Definition: gatt.h:346
GATT Service structure.
Definition: gatt.h:187
const struct bt_gatt_attr * attrs
Service Attributes.
Definition: gatt.h:189
size_t attr_count
Service Attribute count.
Definition: gatt.h:191
Service Attribute Value.
Definition: gatt.h:205
const struct bt_uuid * uuid
Service UUID.
Definition: gatt.h:207
uint16_t end_handle
Service end handle.
Definition: gatt.h:209
GATT Service structure.
Definition: gatt.h:195
struct bt_gatt_attr * attrs
Service Attributes.
Definition: gatt.h:197
size_t attr_count
Service Attribute count.
Definition: gatt.h:199
sys_snode_t node
Definition: gatt.h:201
GATT Subscribe parameters.
Definition: gatt.h:1815
bt_gatt_write_func_t write
Definition: gatt.h:1824
uint16_t value
Subscribe value.
Definition: gatt.h:1836
bt_security_t min_security
Minimum required security for received notification.
Definition: gatt.h:1842
uint16_t ccc_handle
Subscribe CCC handle.
Definition: gatt.h:1828
bt_gatt_subscribe_func_t subscribe
Subscribe CCC write request response callback If given, called with the subscription parameters given...
Definition: gatt.h:1821
uint16_t value_handle
Subscribe value handle.
Definition: gatt.h:1826
sys_snode_t node
Definition: gatt.h:1847
bt_gatt_notify_func_t notify
Notification value callback.
Definition: gatt.h:1817
struct bt_gatt_discover_params * disc_params
Discover parameters used when ccc_handle = 0.
Definition: gatt.h:1833
enum bt_att_chan_opt chan_opt
Definition: gatt.h:1849
uint16_t end_handle
Subscribe End handle (for automatic discovery)
Definition: gatt.h:1831
GATT Write parameters.
Definition: gatt.h:1622
bt_gatt_write_func_t func
Response callback.
Definition: gatt.h:1624
uint16_t handle
Attribute handle.
Definition: gatt.h:1626
const void * data
Data to be written.
Definition: gatt.h:1630
enum bt_att_chan_opt chan_opt
Definition: gatt.h:1634
uint16_t offset
Attribute data offset.
Definition: gatt.h:1628
uint16_t length
Length of the data.
Definition: gatt.h:1632
This is a 'tentative' type and should be used as a pointer only.
Definition: uuid.h:49
Misc utilities.
Bluetooth UUID handling.