Zephyr Project API  3.1.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
33enum {
36
39
42
48
54
61
68
75};
76
84#define BT_GATT_ERR(_att_err) (-(_att_err))
85
87enum {
94
101
109};
110
114 const struct bt_uuid *uuid;
115
130 ssize_t (*read)(struct bt_conn *conn, const struct bt_gatt_attr *attr,
131 void *buf, uint16_t len, uint16_t offset);
132
145 ssize_t (*write)(struct bt_conn *conn, const struct bt_gatt_attr *attr,
146 const void *buf, uint16_t len, uint16_t offset,
147 uint8_t flags);
148
155};
156
160 const struct bt_gatt_attr *attrs;
163};
164
171
173};
174
178 const struct bt_uuid *uuid;
181};
182
186 const struct bt_uuid *uuid;
191};
192
204 void (*att_mtu_updated)(struct bt_conn *conn, uint16_t tx, uint16_t rx);
205
207};
208
217#define BT_GATT_CHRC_BROADCAST 0x01
223#define BT_GATT_CHRC_READ 0x02
229#define BT_GATT_CHRC_WRITE_WITHOUT_RESP 0x04
235#define BT_GATT_CHRC_WRITE 0x08
242#define BT_GATT_CHRC_NOTIFY 0x10
248#define BT_GATT_CHRC_INDICATE 0x20
254#define BT_GATT_CHRC_AUTH 0x40
261#define BT_GATT_CHRC_EXT_PROP 0x80
262
266 const struct bt_uuid *uuid;
271};
272
274#define BT_GATT_CEP_RELIABLE_WRITE 0x0001
275#define BT_GATT_CEP_WRITABLE_AUX 0x0002
276
281};
282
290#define BT_GATT_CCC_NOTIFY 0x0001
296#define BT_GATT_CCC_INDICATE 0x0002
297
302};
303
312#define BT_GATT_SCC_BROADCAST 0x0001
313
318};
319
334};
335
349
371
379
387
388enum {
391};
392
403typedef uint8_t (*bt_gatt_attr_func_t)(const struct bt_gatt_attr *attr,
405 void *user_data);
406
419void bt_gatt_foreach_attr_type(uint16_t start_handle, uint16_t end_handle,
420 const struct bt_uuid *uuid,
421 const void *attr_data, uint16_t num_matches,
423 void *user_data);
424
434static inline void bt_gatt_foreach_attr(uint16_t start_handle, uint16_t end_handle,
436 void *user_data)
437{
438 bt_gatt_foreach_attr_type(start_handle, end_handle, NULL, NULL, 0, func,
439 user_data);
440}
441
450struct bt_gatt_attr *bt_gatt_attr_next(const struct bt_gatt_attr *attr);
451
467 uint16_t attr_count,
468 const struct bt_uuid *uuid);
469
478
490
506ssize_t bt_gatt_attr_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,
507 void *buf, uint16_t buf_len, uint16_t offset,
508 const void *value, uint16_t value_len);
509
526 const struct bt_gatt_attr *attr,
527 void *buf, uint16_t len, uint16_t offset);
528
536#define BT_GATT_SERVICE_DEFINE(_name, ...) \
537 const struct bt_gatt_attr attr_##_name[] = { __VA_ARGS__ }; \
538 const STRUCT_SECTION_ITERABLE(bt_gatt_service_static, _name) = \
539 BT_GATT_SERVICE(attr_##_name)
540
541#define _BT_GATT_ATTRS_ARRAY_DEFINE(n, _instances, _attrs_def) \
542 static struct bt_gatt_attr attrs_##n[] = _attrs_def(_instances[n])
543
544#define _BT_GATT_SERVICE_ARRAY_ITEM(_n, _) BT_GATT_SERVICE(attrs_##_n)
545
561#define BT_GATT_SERVICE_INSTANCE_DEFINE( \
562 _name, _instances, _instance_num, _attrs_def) \
563 BUILD_ASSERT(ARRAY_SIZE(_instances) == _instance_num, \
564 "The number of array elements does not match its size"); \
565 LISTIFY(_instance_num, _BT_GATT_ATTRS_ARRAY_DEFINE, (;), \
566 _instances, _attrs_def); \
567 static struct bt_gatt_service _name[] = { \
568 LISTIFY(_instance_num, _BT_GATT_SERVICE_ARRAY_ITEM, (,)) \
569 }
570
578#define BT_GATT_SERVICE(_attrs) \
579{ \
580 .attrs = _attrs, \
581 .attr_count = ARRAY_SIZE(_attrs), \
582}
583
591#define BT_GATT_PRIMARY_SERVICE(_service) \
592 BT_GATT_ATTRIBUTE(BT_UUID_GATT_PRIMARY, BT_GATT_PERM_READ, \
593 bt_gatt_attr_read_service, NULL, _service)
594
602#define BT_GATT_SECONDARY_SERVICE(_service) \
603 BT_GATT_ATTRIBUTE(BT_UUID_GATT_SECONDARY, BT_GATT_PERM_READ, \
604 bt_gatt_attr_read_service, NULL, _service)
605
622 const struct bt_gatt_attr *attr,
623 void *buf, uint16_t len, uint16_t offset);
624
632#define BT_GATT_INCLUDE_SERVICE(_service_incl) \
633 BT_GATT_ATTRIBUTE(BT_UUID_GATT_INCLUDE, BT_GATT_PERM_READ, \
634 bt_gatt_attr_read_included, NULL, _service_incl)
635
651ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
652 const struct bt_gatt_attr *attr, void *buf,
653 uint16_t len, uint16_t offset);
654
655#define BT_GATT_CHRC_INIT(_uuid, _handle, _props) \
656{ \
657 .uuid = _uuid, \
658 .value_handle = _handle, \
659 .properties = _props, \
660}
661
675#define BT_GATT_CHARACTERISTIC(_uuid, _props, _perm, _read, _write, _user_data) \
676 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CHRC, BT_GATT_PERM_READ, \
677 bt_gatt_attr_read_chrc, NULL, \
678 ((struct bt_gatt_chrc[]) { \
679 BT_GATT_CHRC_INIT(_uuid, 0U, _props), \
680 })), \
681 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
682
683#if defined(CONFIG_BT_SETTINGS_CCC_LAZY_LOADING)
684 #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_CONN)
685#elif defined(CONFIG_BT_CONN)
686 #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
687#else
688 #define BT_GATT_CCC_MAX 0
689#endif
690
699};
700
702struct _bt_gatt_ccc {
705
708
714 void (*cfg_changed)(const struct bt_gatt_attr *attr, uint16_t value);
715
725 ssize_t (*cfg_write)(struct bt_conn *conn,
726 const struct bt_gatt_attr *attr, uint16_t value);
727
739 bool (*cfg_match)(struct bt_conn *conn,
740 const struct bt_gatt_attr *attr);
741};
742
759ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
760 const struct bt_gatt_attr *attr, void *buf,
761 uint16_t len, uint16_t offset);
762
779ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
780 const struct bt_gatt_attr *attr, const void *buf,
781 uint16_t len, uint16_t offset, uint8_t flags);
782
783
793#define BT_GATT_CCC_INITIALIZER(_changed, _write, _match) \
794 { \
795 .cfg = {}, \
796 .cfg_changed = _changed, \
797 .cfg_write = _write, \
798 .cfg_match = _match, \
799 }
800
809#define BT_GATT_CCC_MANAGED(_ccc, _perm) \
810 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CCC, _perm, \
811 bt_gatt_attr_read_ccc, bt_gatt_attr_write_ccc, \
812 _ccc)
813
822#define BT_GATT_CCC(_changed, _perm) \
823 BT_GATT_CCC_MANAGED(((struct _bt_gatt_ccc[]) \
824 {BT_GATT_CCC_INITIALIZER(_changed, NULL, NULL)}), _perm)
825
842ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
843 const struct bt_gatt_attr *attr, void *buf,
844 uint16_t len, uint16_t offset);
845
853#define BT_GATT_CEP(_value) \
854 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CEP, BT_GATT_PERM_READ, \
855 bt_gatt_attr_read_cep, NULL, (void *)_value)
856
874ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
875 const struct bt_gatt_attr *attr, void *buf,
876 uint16_t len, uint16_t offset);
877
886#define BT_GATT_CUD(_value, _perm) \
887 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CUD, _perm, bt_gatt_attr_read_cud, \
888 NULL, (void *)_value)
889
906ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
907 const struct bt_gatt_attr *attr, void *buf,
908 uint16_t len, uint16_t offset);
909
917#define BT_GATT_CPF(_value) \
918 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CPF, BT_GATT_PERM_READ, \
919 bt_gatt_attr_read_cpf, NULL, (void *)_value)
920
932#define BT_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _user_data) \
933 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
934
946#define BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data) \
947{ \
948 .uuid = _uuid, \
949 .read = _read, \
950 .write = _write, \
951 .user_data = _user_data, \
952 .handle = 0, \
953 .perm = _perm, \
954}
955
961typedef void (*bt_gatt_complete_func_t) (struct bt_conn *conn, void *user_data);
962
969 const struct bt_uuid *uuid;
975 const struct bt_gatt_attr *attr;
977 const void *data;
984};
985
1007int bt_gatt_notify_cb(struct bt_conn *conn,
1008 struct bt_gatt_notify_params *params);
1009
1020int bt_gatt_notify_multiple(struct bt_conn *conn, uint16_t num_params,
1021 struct bt_gatt_notify_params *params);
1022
1042static inline int bt_gatt_notify(struct bt_conn *conn,
1043 const struct bt_gatt_attr *attr,
1044 const void *data, uint16_t len)
1045{
1046 struct bt_gatt_notify_params params;
1047
1048 memset(&params, 0, sizeof(params));
1049
1050 params.attr = attr;
1051 params.data = data;
1052 params.len = len;
1053
1054 return bt_gatt_notify_cb(conn, &params);
1055}
1056
1076static inline int bt_gatt_notify_uuid(struct bt_conn *conn,
1077 const struct bt_uuid *uuid,
1078 const struct bt_gatt_attr *attr,
1079 const void *data, uint16_t len)
1080{
1081 struct bt_gatt_notify_params params;
1082
1083 memset(&params, 0, sizeof(params));
1084
1085 params.uuid = uuid;
1086 params.attr = attr;
1087 params.data = data;
1088 params.len = len;
1089
1090 return bt_gatt_notify_cb(conn, &params);
1091}
1092
1093/* Forward declaration of the bt_gatt_indicate_params structure */
1095
1103typedef void (*bt_gatt_indicate_func_t)(struct bt_conn *conn,
1104 struct bt_gatt_indicate_params *params,
1105 uint8_t err);
1106
1108 struct bt_gatt_indicate_params *params);
1109
1117 const struct bt_uuid *uuid;
1123 const struct bt_gatt_attr *attr;
1129 const void *data;
1133 uint8_t _ref;
1134};
1135
1161int bt_gatt_indicate(struct bt_conn *conn,
1162 struct bt_gatt_indicate_params *params);
1163
1164
1183bool bt_gatt_is_subscribed(struct bt_conn *conn,
1184 const struct bt_gatt_attr *attr, uint16_t ccc_type);
1185
1195uint16_t bt_gatt_get_mtu(struct bt_conn *conn);
1196
1208 void (*func)(struct bt_conn *conn, uint8_t err,
1209 struct bt_gatt_exchange_params *params);
1210};
1211
1239int bt_gatt_exchange_mtu(struct bt_conn *conn,
1240 struct bt_gatt_exchange_params *params);
1241
1243
1288typedef uint8_t (*bt_gatt_discover_func_t)(struct bt_conn *conn,
1289 const struct bt_gatt_attr *attr,
1290 struct bt_gatt_discover_params *params);
1291
1293enum {
1334};
1335
1339 const struct bt_uuid *uuid;
1342 union {
1343 struct {
1350 } _included;
1353 };
1358#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC)
1360 struct bt_gatt_subscribe_params *sub_params;
1361#endif /* defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC) */
1362};
1363
1399int bt_gatt_discover(struct bt_conn *conn,
1400 struct bt_gatt_discover_params *params);
1401
1402struct bt_gatt_read_params;
1403
1416typedef uint8_t (*bt_gatt_read_func_t)(struct bt_conn *conn, uint8_t err,
1417 struct bt_gatt_read_params *params,
1418 const void *data, uint16_t length);
1419
1429 union {
1430 struct {
1436 struct {
1453 struct {
1459 const struct bt_uuid *uuid;
1461 };
1462};
1463
1494int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params);
1495
1497
1505typedef void (*bt_gatt_write_func_t)(struct bt_conn *conn, uint8_t err,
1506 struct bt_gatt_write_params *params);
1507
1517 const void *data;
1520};
1521
1544int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
1545
1581int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
1582 const void *data, uint16_t length,
1583 bool sign, bt_gatt_complete_func_t func,
1584 void *user_data);
1585
1607static inline int bt_gatt_write_without_response(struct bt_conn *conn,
1608 uint16_t handle, const void *data,
1609 uint16_t length, bool sign)
1610{
1611 return bt_gatt_write_without_response_cb(conn, handle, data, length,
1612 sign, NULL, NULL);
1613}
1614
1616
1633typedef uint8_t (*bt_gatt_notify_func_t)(struct bt_conn *conn,
1634 struct bt_gatt_subscribe_params *params,
1635 const void *data, uint16_t length);
1636
1644typedef void (*bt_gatt_subscribe_func_t)(struct bt_conn *conn, uint8_t err,
1645 struct bt_gatt_subscribe_params *params);
1646
1648enum {
1659
1673
1680
1683
1692
1699#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC)
1701 uint16_t end_handle;
1703 struct bt_gatt_discover_params *disc_params;
1704#endif /* CONFIG_BT_GATT_AUTO_DISCOVER_CCC */
1707#if defined(CONFIG_BT_SMP)
1713#endif
1716
1718};
1719
1752int bt_gatt_subscribe(struct bt_conn *conn,
1753 struct bt_gatt_subscribe_params *params);
1754
1772 struct bt_gatt_subscribe_params *params);
1773
1798int bt_gatt_unsubscribe(struct bt_conn *conn,
1799 struct bt_gatt_subscribe_params *params);
1800
1818void bt_gatt_cancel(struct bt_conn *conn, void *params);
1819
1822#ifdef __cplusplus
1823}
1824#endif
1825
1830#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_security_t
Definition: conn.h:680
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:1288
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:1644
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:1416
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:1607
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:1633
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:1505
@ BT_GATT_DISCOVER_DESCRIPTOR
Discover Descriptors.
Definition: gatt.h:1313
@ BT_GATT_DISCOVER_SECONDARY
Definition: gatt.h:1297
@ BT_GATT_DISCOVER_CHARACTERISTIC
Discover Characteristic Values.
Definition: gatt.h:1304
@ BT_GATT_DISCOVER_INCLUDE
Definition: gatt.h:1299
@ BT_GATT_DISCOVER_STD_CHAR_DESC
Discover standard characteristic descriptor values.
Definition: gatt.h:1333
@ BT_GATT_DISCOVER_PRIMARY
Definition: gatt.h:1295
@ BT_GATT_DISCOVER_ATTRIBUTE
Discover Attributes.
Definition: gatt.h:1322
@ BT_GATT_SUBSCRIBE_FLAG_NO_RESUB
No resubscribe flag.
Definition: gatt.h:1672
@ BT_GATT_SUBSCRIBE_NUM_FLAGS
Definition: gatt.h:1681
@ BT_GATT_SUBSCRIBE_FLAG_VOLATILE
Persistence flag.
Definition: gatt.h:1658
@ BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING
Write pending flag.
Definition: gatt.h:1679
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:1103
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:1076
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:1107
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:1042
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:434
int bt_gatt_notify_multiple(struct bt_conn *conn, uint16_t num_params, struct bt_gatt_notify_params *params)
Notify multiple attribute value change.
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:688
void(* bt_gatt_complete_func_t)(struct bt_conn *conn, void *user_data)
Notification complete result callback.
Definition: gatt.h:961
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:403
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:389
@ BT_GATT_ITER_CONTINUE
Definition: gatt.h:390
@ BT_GATT_WRITE_FLAG_PREPARE
Attribute prepare write flag.
Definition: gatt.h:93
@ BT_GATT_WRITE_FLAG_CMD
Attribute write command flag.
Definition: gatt.h:100
@ BT_GATT_WRITE_FLAG_EXECUTE
Attribute write execute flag.
Definition: gatt.h:108
@ 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_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
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
flags
Definition: http_parser.h:131
__SIZE_TYPE__ ssize_t
Definition: types.h:28
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:112
uint8_t perm
Definition: gatt.h:154
ssize_t(* read)(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
Attribute read callback.
Definition: gatt.h:130
const struct bt_uuid * uuid
Definition: gatt.h:114
ssize_t(* write)(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:145
void * user_data
Definition: gatt.h:150
uint16_t handle
Definition: gatt.h:152
GATT callback structure.
Definition: gatt.h:194
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:204
sys_snode_t node
Definition: gatt.h:206
GATT CCC configuration entry.
Definition: gatt.h:692
uint16_t value
Definition: gatt.h:698
bt_addr_le_t peer
Definition: gatt.h:696
uint8_t id
Definition: gatt.h:694
Definition: gatt.h:299
uint16_t flags
Definition: gatt.h:301
Characteristic Extended Properties Attribute Value.
Definition: gatt.h:278
uint16_t properties
Definition: gatt.h:280
Characteristic Attribute Value.
Definition: gatt.h:264
uint16_t value_handle
Definition: gatt.h:268
uint8_t properties
Definition: gatt.h:270
const struct bt_uuid * uuid
Definition: gatt.h:266
GATT Characteristic Presentation Format Attribute Value.
Definition: gatt.h:321
uint8_t name_space
Definition: gatt.h:331
uint16_t unit
Definition: gatt.h:329
int8_t exponent
Definition: gatt.h:327
uint16_t description
Definition: gatt.h:333
uint8_t format
Definition: gatt.h:323
GATT Discover Attributes parameters.
Definition: gatt.h:1337
uint16_t start_handle
Definition: gatt.h:1347
uint16_t end_handle
Definition: gatt.h:1349
bt_gatt_discover_func_t func
Definition: gatt.h:1341
uint16_t attr_handle
Definition: gatt.h:1345
const struct bt_uuid * uuid
Definition: gatt.h:1339
uint8_t type
Definition: gatt.h:1357
GATT Exchange MTU parameters.
Definition: gatt.h:1206
void(* func)(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
Definition: gatt.h:1208
Include Attribute Value.
Definition: gatt.h:184
uint16_t end_handle
Definition: gatt.h:190
uint16_t start_handle
Definition: gatt.h:188
const struct bt_uuid * uuid
Definition: gatt.h:186
GATT Indicate Value parameters.
Definition: gatt.h:1111
uint16_t len
Definition: gatt.h:1131
const struct bt_gatt_attr * attr
Indicate Attribute object.
Definition: gatt.h:1123
const void * data
Definition: gatt.h:1129
bt_gatt_indicate_params_destroy_t destroy
Definition: gatt.h:1127
bt_gatt_indicate_func_t func
Definition: gatt.h:1125
const struct bt_uuid * uuid
Indicate Attribute UUID type.
Definition: gatt.h:1117
Definition: gatt.h:963
const struct bt_uuid * uuid
Notification Attribute UUID type.
Definition: gatt.h:969
uint16_t len
Definition: gatt.h:979
const struct bt_gatt_attr * attr
Notification Attribute object.
Definition: gatt.h:975
bt_gatt_complete_func_t func
Definition: gatt.h:981
void * user_data
Definition: gatt.h:983
const void * data
Definition: gatt.h:977
GATT Read parameters.
Definition: gatt.h:1421
size_t handle_count
Definition: gatt.h:1428
struct bt_gatt_read_params::@72::@75 multiple
uint16_t * handles
Definition: gatt.h:1440
uint16_t offset
Definition: gatt.h:1434
bt_gatt_read_func_t func
Definition: gatt.h:1423
struct bt_gatt_read_params::@72::@76 by_uuid
bool variable
Definition: gatt.h:1451
uint16_t end_handle
Definition: gatt.h:1457
struct bt_gatt_read_params::@72::@74 single
uint16_t start_handle
Definition: gatt.h:1455
const struct bt_uuid * uuid
Definition: gatt.h:1459
uint16_t handle
Definition: gatt.h:1432
Definition: gatt.h:315
uint16_t flags
Definition: gatt.h:317
GATT Service structure.
Definition: gatt.h:158
const struct bt_gatt_attr * attrs
Definition: gatt.h:160
size_t attr_count
Definition: gatt.h:162
Service Attribute Value.
Definition: gatt.h:176
const struct bt_uuid * uuid
Definition: gatt.h:178
uint16_t end_handle
Definition: gatt.h:180
GATT Service structure.
Definition: gatt.h:166
struct bt_gatt_attr * attrs
Definition: gatt.h:168
size_t attr_count
Definition: gatt.h:170
sys_snode_t node
Definition: gatt.h:172
GATT Subscribe parameters.
Definition: gatt.h:1685
bt_gatt_write_func_t write
Definition: gatt.h:1694
uint16_t value
Definition: gatt.h:1706
bt_security_t min_security
Definition: gatt.h:1712
uint16_t ccc_handle
Definition: gatt.h:1698
bt_gatt_subscribe_func_t subscribe
Definition: gatt.h:1691
uint16_t value_handle
Definition: gatt.h:1696
sys_snode_t node
Definition: gatt.h:1717
bt_gatt_notify_func_t notify
Definition: gatt.h:1687
GATT Write parameters.
Definition: gatt.h:1509
bt_gatt_write_func_t func
Definition: gatt.h:1511
uint16_t handle
Definition: gatt.h:1513
const void * data
Definition: gatt.h:1517
uint16_t offset
Definition: gatt.h:1515
uint16_t length
Definition: gatt.h:1519
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:590
Misc utilities.
Bluetooth UUID handling.