Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.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 <stddef.h>
21#include <sys/slist.h>
22#include <sys/types.h>
23#include <sys/util.h>
24#include <bluetooth/conn.h>
25#include <bluetooth/uuid.h>
26#include <bluetooth/att.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 UTIL_EVAL(UTIL_REPEAT( \
566 _instance_num, _BT_GATT_ATTRS_ARRAY_DEFINE, _instances, \
567 _attrs_def)) \
568 static struct bt_gatt_service _name[] = { \
569 UTIL_LISTIFY(_instance_num, _BT_GATT_SERVICE_ARRAY_ITEM) \
570 }
571
579#define BT_GATT_SERVICE(_attrs) \
580{ \
581 .attrs = _attrs, \
582 .attr_count = ARRAY_SIZE(_attrs), \
583}
584
592#define BT_GATT_PRIMARY_SERVICE(_service) \
593 BT_GATT_ATTRIBUTE(BT_UUID_GATT_PRIMARY, BT_GATT_PERM_READ, \
594 bt_gatt_attr_read_service, NULL, _service)
595
603#define BT_GATT_SECONDARY_SERVICE(_service) \
604 BT_GATT_ATTRIBUTE(BT_UUID_GATT_SECONDARY, BT_GATT_PERM_READ, \
605 bt_gatt_attr_read_service, NULL, _service)
606
623 const struct bt_gatt_attr *attr,
624 void *buf, uint16_t len, uint16_t offset);
625
633#define BT_GATT_INCLUDE_SERVICE(_service_incl) \
634 BT_GATT_ATTRIBUTE(BT_UUID_GATT_INCLUDE, BT_GATT_PERM_READ, \
635 bt_gatt_attr_read_included, NULL, _service_incl)
636
652ssize_t bt_gatt_attr_read_chrc(struct bt_conn *conn,
653 const struct bt_gatt_attr *attr, void *buf,
654 uint16_t len, uint16_t offset);
655
656#define BT_GATT_CHRC_INIT(_uuid, _handle, _props) \
657{ \
658 .uuid = _uuid, \
659 .value_handle = _handle, \
660 .properties = _props, \
661}
662
676#define BT_GATT_CHARACTERISTIC(_uuid, _props, _perm, _read, _write, _user_data) \
677 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CHRC, BT_GATT_PERM_READ, \
678 bt_gatt_attr_read_chrc, NULL, \
679 ((struct bt_gatt_chrc[]) { \
680 BT_GATT_CHRC_INIT(_uuid, 0U, _props), \
681 })), \
682 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
683
684#if defined(CONFIG_BT_SETTINGS_CCC_LAZY_LOADING)
685 #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_CONN)
686#elif defined(CONFIG_BT_CONN)
687 #define BT_GATT_CCC_MAX (CONFIG_BT_MAX_PAIRED + CONFIG_BT_MAX_CONN)
688#else
689 #define BT_GATT_CCC_MAX 0
690#endif
691
700};
701
703struct _bt_gatt_ccc {
706
709
715 void (*cfg_changed)(const struct bt_gatt_attr *attr, uint16_t value);
716
726 ssize_t (*cfg_write)(struct bt_conn *conn,
727 const struct bt_gatt_attr *attr, uint16_t value);
728
740 bool (*cfg_match)(struct bt_conn *conn,
741 const struct bt_gatt_attr *attr);
742};
743
760ssize_t bt_gatt_attr_read_ccc(struct bt_conn *conn,
761 const struct bt_gatt_attr *attr, void *buf,
762 uint16_t len, uint16_t offset);
763
780ssize_t bt_gatt_attr_write_ccc(struct bt_conn *conn,
781 const struct bt_gatt_attr *attr, const void *buf,
782 uint16_t len, uint16_t offset, uint8_t flags);
783
784
794#define BT_GATT_CCC_INITIALIZER(_changed, _write, _match) \
795 { \
796 .cfg = {}, \
797 .cfg_changed = _changed, \
798 .cfg_write = _write, \
799 .cfg_match = _match, \
800 }
801
810#define BT_GATT_CCC_MANAGED(_ccc, _perm) \
811 BT_GATT_ATTRIBUTE(BT_UUID_GATT_CCC, _perm, \
812 bt_gatt_attr_read_ccc, bt_gatt_attr_write_ccc, \
813 _ccc)
814
823#define BT_GATT_CCC(_changed, _perm) \
824 BT_GATT_CCC_MANAGED(((struct _bt_gatt_ccc[]) \
825 {BT_GATT_CCC_INITIALIZER(_changed, NULL, NULL)}), _perm)
826
843ssize_t bt_gatt_attr_read_cep(struct bt_conn *conn,
844 const struct bt_gatt_attr *attr, void *buf,
845 uint16_t len, uint16_t offset);
846
854#define BT_GATT_CEP(_value) \
855 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CEP, BT_GATT_PERM_READ, \
856 bt_gatt_attr_read_cep, NULL, (void *)_value)
857
875ssize_t bt_gatt_attr_read_cud(struct bt_conn *conn,
876 const struct bt_gatt_attr *attr, void *buf,
877 uint16_t len, uint16_t offset);
878
887#define BT_GATT_CUD(_value, _perm) \
888 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CUD, _perm, bt_gatt_attr_read_cud, \
889 NULL, (void *)_value)
890
907ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
908 const struct bt_gatt_attr *attr, void *buf,
909 uint16_t len, uint16_t offset);
910
918#define BT_GATT_CPF(_value) \
919 BT_GATT_DESCRIPTOR(BT_UUID_GATT_CPF, BT_GATT_PERM_READ, \
920 bt_gatt_attr_read_cpf, NULL, (void *)_value)
921
933#define BT_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _user_data) \
934 BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data)
935
947#define BT_GATT_ATTRIBUTE(_uuid, _perm, _read, _write, _user_data) \
948{ \
949 .uuid = _uuid, \
950 .read = _read, \
951 .write = _write, \
952 .user_data = _user_data, \
953 .handle = 0, \
954 .perm = _perm, \
955}
956
962typedef void (*bt_gatt_complete_func_t) (struct bt_conn *conn, void *user_data);
963
970 const struct bt_uuid *uuid;
976 const struct bt_gatt_attr *attr;
978 const void *data;
985};
986
1008int bt_gatt_notify_cb(struct bt_conn *conn,
1009 struct bt_gatt_notify_params *params);
1010
1021int bt_gatt_notify_multiple(struct bt_conn *conn, uint16_t num_params,
1022 struct bt_gatt_notify_params *params);
1023
1043static inline int bt_gatt_notify(struct bt_conn *conn,
1044 const struct bt_gatt_attr *attr,
1045 const void *data, uint16_t len)
1046{
1047 struct bt_gatt_notify_params params;
1048
1049 memset(&params, 0, sizeof(params));
1050
1051 params.attr = attr;
1052 params.data = data;
1053 params.len = len;
1054
1055 return bt_gatt_notify_cb(conn, &params);
1056}
1057
1077static inline int bt_gatt_notify_uuid(struct bt_conn *conn,
1078 const struct bt_uuid *uuid,
1079 const struct bt_gatt_attr *attr,
1080 const void *data, uint16_t len)
1081{
1082 struct bt_gatt_notify_params params;
1083
1084 memset(&params, 0, sizeof(params));
1085
1086 params.uuid = uuid;
1087 params.attr = attr;
1088 params.data = data;
1089 params.len = len;
1090
1091 return bt_gatt_notify_cb(conn, &params);
1092}
1093
1094/* Forward declaration of the bt_gatt_indicate_params structure */
1096
1104typedef void (*bt_gatt_indicate_func_t)(struct bt_conn *conn,
1105 struct bt_gatt_indicate_params *params,
1106 uint8_t err);
1107
1109 struct bt_gatt_indicate_params *params);
1110
1118 const struct bt_uuid *uuid;
1124 const struct bt_gatt_attr *attr;
1130 const void *data;
1134 uint8_t _ref;
1135};
1136
1162int bt_gatt_indicate(struct bt_conn *conn,
1163 struct bt_gatt_indicate_params *params);
1164
1165
1183bool bt_gatt_is_subscribed(struct bt_conn *conn,
1184 const struct bt_gatt_attr *attr, uint16_t ccc_value);
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
1236int bt_gatt_exchange_mtu(struct bt_conn *conn,
1237 struct bt_gatt_exchange_params *params);
1238
1240
1270typedef uint8_t (*bt_gatt_discover_func_t)(struct bt_conn *conn,
1271 const struct bt_gatt_attr *attr,
1272 struct bt_gatt_discover_params *params);
1273
1275enum {
1316};
1317
1321 const struct bt_uuid *uuid;
1324 union {
1325 struct {
1332 } _included;
1335 };
1340#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC)
1342 struct bt_gatt_subscribe_params *sub_params;
1343#endif /* defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC) */
1344};
1345
1381int bt_gatt_discover(struct bt_conn *conn,
1382 struct bt_gatt_discover_params *params);
1383
1384struct bt_gatt_read_params;
1385
1398typedef uint8_t (*bt_gatt_read_func_t)(struct bt_conn *conn, uint8_t err,
1399 struct bt_gatt_read_params *params,
1400 const void *data, uint16_t length);
1401
1411 union {
1412 struct {
1418 struct {
1435 struct {
1441 const struct bt_uuid *uuid;
1443 };
1444};
1445
1475int bt_gatt_read(struct bt_conn *conn, struct bt_gatt_read_params *params);
1476
1478
1486typedef void (*bt_gatt_write_func_t)(struct bt_conn *conn, uint8_t err,
1487 struct bt_gatt_write_params *params);
1488
1498 const void *data;
1501};
1502
1524int bt_gatt_write(struct bt_conn *conn, struct bt_gatt_write_params *params);
1525
1561int bt_gatt_write_without_response_cb(struct bt_conn *conn, uint16_t handle,
1562 const void *data, uint16_t length,
1563 bool sign, bt_gatt_complete_func_t func,
1564 void *user_data);
1565
1587static inline int bt_gatt_write_without_response(struct bt_conn *conn,
1588 uint16_t handle, const void *data,
1589 uint16_t length, bool sign)
1590{
1591 return bt_gatt_write_without_response_cb(conn, handle, data, length,
1592 sign, NULL, NULL);
1593}
1594
1596
1613typedef uint8_t (*bt_gatt_notify_func_t)(struct bt_conn *conn,
1614 struct bt_gatt_subscribe_params *params,
1615 const void *data, uint16_t length);
1616
1618enum {
1629
1643
1650
1653
1664#if defined(CONFIG_BT_GATT_AUTO_DISCOVER_CCC)
1666 uint16_t end_handle;
1668 struct bt_gatt_discover_params *disc_params;
1669#endif /* CONFIG_BT_GATT_AUTO_DISCOVER_CCC */
1674
1676};
1677
1709int bt_gatt_subscribe(struct bt_conn *conn,
1710 struct bt_gatt_subscribe_params *params);
1711
1729 struct bt_gatt_subscribe_params *params);
1730
1755int bt_gatt_unsubscribe(struct bt_conn *conn,
1756 struct bt_gatt_subscribe_params *params);
1757
1775void bt_gatt_cancel(struct bt_conn *conn, void *params);
1776
1779#ifdef __cplusplus
1780}
1781#endif
1782
1787#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
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:1270
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:1398
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:1587
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:1613
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:1486
@ BT_GATT_DISCOVER_DESCRIPTOR
Discover Descriptors.
Definition: gatt.h:1295
@ BT_GATT_DISCOVER_SECONDARY
Definition: gatt.h:1279
@ BT_GATT_DISCOVER_CHARACTERISTIC
Discover Characteristic Values.
Definition: gatt.h:1286
@ BT_GATT_DISCOVER_INCLUDE
Definition: gatt.h:1281
@ BT_GATT_DISCOVER_STD_CHAR_DESC
Discover standard characteristic descriptor values.
Definition: gatt.h:1315
@ BT_GATT_DISCOVER_PRIMARY
Definition: gatt.h:1277
@ BT_GATT_DISCOVER_ATTRIBUTE
Discover Attributes.
Definition: gatt.h:1304
@ BT_GATT_SUBSCRIBE_FLAG_NO_RESUB
No resubscribe flag.
Definition: gatt.h:1642
@ BT_GATT_SUBSCRIBE_NUM_FLAGS
Definition: gatt.h:1651
@ BT_GATT_SUBSCRIBE_FLAG_VOLATILE
Persistence flag.
Definition: gatt.h:1628
@ BT_GATT_SUBSCRIBE_FLAG_WRITE_PENDING
Write pending flag.
Definition: gatt.h:1649
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:1104
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:1077
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:1108
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:1043
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.
#define BT_GATT_CCC_MAX
Definition: gatt.h:689
void(* bt_gatt_complete_func_t)(struct bt_conn *conn, void *user_data)
Notification complete result callback.
Definition: gatt.h:962
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.
bool bt_gatt_is_subscribed(struct bt_conn *conn, const struct bt_gatt_attr *attr, uint16_t ccc_value)
Check if connection have subscribed to attribute.
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:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
__INT8_TYPE__ int8_t
Definition: stdint.h:42
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:693
uint16_t value
Definition: gatt.h:699
bt_addr_le_t peer
Definition: gatt.h:697
uint8_t id
Definition: gatt.h:695
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:1319
uint16_t start_handle
Definition: gatt.h:1329
uint16_t end_handle
Definition: gatt.h:1331
bt_gatt_discover_func_t func
Definition: gatt.h:1323
uint16_t attr_handle
Definition: gatt.h:1327
const struct bt_uuid * uuid
Definition: gatt.h:1321
uint8_t type
Definition: gatt.h:1339
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:1112
uint16_t len
Definition: gatt.h:1132
const struct bt_gatt_attr * attr
Indicate Attribute object.
Definition: gatt.h:1124
const void * data
Definition: gatt.h:1130
bt_gatt_indicate_params_destroy_t destroy
Definition: gatt.h:1128
bt_gatt_indicate_func_t func
Definition: gatt.h:1126
const struct bt_uuid * uuid
Indicate Attribute UUID type.
Definition: gatt.h:1118
Definition: gatt.h:964
const struct bt_uuid * uuid
Notification Attribute UUID type.
Definition: gatt.h:970
uint16_t len
Definition: gatt.h:980
const struct bt_gatt_attr * attr
Notification Attribute object.
Definition: gatt.h:976
bt_gatt_complete_func_t func
Definition: gatt.h:982
void * user_data
Definition: gatt.h:984
const void * data
Definition: gatt.h:978
GATT Read parameters.
Definition: gatt.h:1403
size_t handle_count
Definition: gatt.h:1410
struct bt_gatt_read_params::@72::@75 multiple
uint16_t * handles
Definition: gatt.h:1422
uint16_t offset
Definition: gatt.h:1416
bt_gatt_read_func_t func
Definition: gatt.h:1405
struct bt_gatt_read_params::@72::@76 by_uuid
bool variable
Definition: gatt.h:1433
uint16_t end_handle
Definition: gatt.h:1439
struct bt_gatt_read_params::@72::@74 single
uint16_t start_handle
Definition: gatt.h:1437
const struct bt_uuid * uuid
Definition: gatt.h:1441
uint16_t handle
Definition: gatt.h:1414
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:1655
bt_gatt_write_func_t write
Definition: gatt.h:1659
uint16_t value
Definition: gatt.h:1671
uint16_t ccc_handle
Definition: gatt.h:1663
uint16_t value_handle
Definition: gatt.h:1661
sys_snode_t node
Definition: gatt.h:1675
bt_gatt_notify_func_t notify
Definition: gatt.h:1657
GATT Write parameters.
Definition: gatt.h:1490
bt_gatt_write_func_t func
Definition: gatt.h:1492
uint16_t handle
Definition: gatt.h:1494
const void * data
Definition: gatt.h:1498
uint16_t offset
Definition: gatt.h:1496
uint16_t length
Definition: gatt.h:1500
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.