nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
gatt_pool.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef BT_GATT_POOL_
8#define BT_GATT_POOL_
9
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <zephyr/bluetooth/gatt.h>
22#include <zephyr/bluetooth/uuid.h>
23
24
31#define BT_GATT_POOL_INIT(_attr_array_size) \
32 { \
33 .svc = \
34 { \
35 .attrs = (struct bt_gatt_attr[_attr_array_size]) \
36 { {0} } \
37 }, \
38 .attr_array_size = _attr_array_size \
39 }
40
48#define BT_GATT_POOL_DEF(_name, _attr_array_size) \
49 const static struct bt_gatt_pool _name = \
50 BT_GATT_POOL_INIT(_attr_array_size)
51
57#define BT_GATT_POOL_SVC(_gp, _svc_uuid_init) \
58 do { \
59 int _ret; \
60 const struct bt_uuid *_svc_uuid = _svc_uuid_init; \
61 _ret = bt_gatt_pool_svc_alloc(_gp, _svc_uuid); \
62 __ASSERT_NO_MSG(!_ret); \
63 (void)_ret; \
64 } while (0)
65
76#define BT_GATT_POOL_CHRC(_gp, _uuid, _props, _perm, _read, _write, _value) \
77 do { \
78 int _ret; \
79 const struct bt_gatt_attr _attr = BT_GATT_ATTRIBUTE( \
80 _uuid, _perm, _read, _write, _value); \
81 _ret = bt_gatt_pool_chrc_alloc(_gp, _props, &_attr); \
82 __ASSERT_NO_MSG(!_ret); \
83 (void)_ret; \
84 } while (0)
85
95#define BT_GATT_POOL_DESC(_gp, _uuid, _perm, _read, _write, _value) \
96 do { \
97 int _ret; \
98 const struct bt_gatt_attr _descriptor = BT_GATT_DESCRIPTOR( \
99 _uuid, _perm, _read, _write, _value); \
100 _ret = bt_gatt_pool_desc_alloc(_gp, &_descriptor); \
101 __ASSERT_NO_MSG(!_ret); \
102 (void)_ret; \
103 } while (0)
104
112#define BT_GATT_POOL_CCC(_gp, _ccc, _ccc_changed, _perm) \
113 do { \
114 int _ret; \
115 _ccc = (struct _bt_gatt_ccc)BT_GATT_CCC_INITIALIZER(\
116 _ccc_changed, NULL, NULL); \
117 _ret = bt_gatt_pool_ccc_alloc(_gp, &_ccc, _perm); \
118 __ASSERT_NO_MSG(!_ret); \
119 (void)_ret; \
120 } while (0)
121
122
130 struct bt_gatt_service svc;
133};
134
146 struct bt_uuid const *svc_uuid);
147
156int bt_gatt_pool_chrc_alloc(struct bt_gatt_pool *gp, uint8_t props,
157 struct bt_gatt_attr const *attr);
158
167 struct bt_gatt_attr const *descriptor);
168
179 struct _bt_gatt_ccc *ccc,
180 uint8_t perm);
181
187
188#if CONFIG_BT_GATT_POOL_STATS != 0
191void bt_gatt_pool_stats_print(void);
192#endif
193
194#ifdef __cplusplus
195}
196#endif
197
202#endif /* BT_GATT_POOL_ */
int bt_gatt_pool_chrc_alloc(struct bt_gatt_pool *gp, uint8_t props, struct bt_gatt_attr const *attr)
Take a characteristic descriptor from the pool.
int bt_gatt_pool_svc_alloc(struct bt_gatt_pool *gp, struct bt_uuid const *svc_uuid)
Take a primary service descriptor from the pool.
void bt_gatt_pool_free(struct bt_gatt_pool *gp)
Free the whole dynamically created GATT service.
int bt_gatt_pool_ccc_alloc(struct bt_gatt_pool *gp, struct _bt_gatt_ccc *ccc, uint8_t perm)
Take a CCC descriptor from the pool.
int bt_gatt_pool_desc_alloc(struct bt_gatt_pool *gp, struct bt_gatt_attr const *descriptor)
Take an attribute descriptor from the pool.
size_t attr_array_size
Definition: gatt_pool.h:132
struct bt_gatt_service svc
Definition: gatt_pool.h:130
The GATT service object that uses dynamic attribute allocation.
Definition: gatt_pool.h:128