ble_gatts.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file ble_gatts.h
5  *
6  * @brief BLE GATTS API
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  *****************************************************************************************
36  */
37 
38 /**
39  * @addtogroup BLE
40  * @{
41  */
42 
43 /**
44  * @addtogroup BLE_GATT Generic Attribute Profile (GATT)
45  * @{
46  * @brief Definitions and prototypes for the GATT interface.
47  */
48 
49 /**
50  @addtogroup BLE_SDK_GATTS Generic Attribute Profile (GATT) Server
51  @{
52  @brief Definitions and prototypes for the GATT server interface.
53  */
54 
55 
56 #ifndef __BLE_GATTS_H__
57 #define __BLE_GATTS_H__
58 
59 #include "ble_error.h"
60 #include "ble_att.h"
61 #include "ble_gatt.h"
62 #include "ble_gapc.h"
63 
64 #include <stdint.h>
65 
66 /** @addtogroup BLE_GATTS_DEFINES Defines
67  * @{ */
68 
69 /** @defgroup BLE_GATTS_MAX_INC_SRVC_NUM Max Number of Included Services
70  * @{ */
71 #define BLE_GATTS_MAX_INC_SRVC_NUM (5) /**< The max number of Included Services a Primary/Secondary service can have. Used by @ref ble_gatts_create_db_t. */
72 /** @} */
73 
74 /** @defgroup BLE_GATTS_ATTR_PERM_BIT Attribute Permission Bit
75  * @{ */
76 #define BLE_GATTS_BROADCAST (0x01) /**< In one byte, bit0 means: Broadcast bit. Used by @ref BLE_GATTS_BROADCAST_ENABLE. */
77 #define BLE_GATTS_READ (0x02) /**< In one byte, bit1 means: Read bit. Used by @ref BLE_GATTS_READ_PERM_UNSEC, @ref BLE_GATTS_READ_PERM */
78 #define BLE_GATTS_WRITE_CMD (0x04) /**< In one byte, bit2 means: Write_cmd bit. Used by @ref BLE_GATTS_WRITE_CMD_PERM_UNSEC, @ref BLE_GATTS_WRITE_CMD_PERM. */
79 #define BLE_GATTS_WRITE_REQ (0x08) /**< In one byte, bit3 means: Write_req bit. Used by @ref BLE_GATTS_WRITE_REQ_PERM_UNSEC, @ref BLE_GATTS_WRITE_REQ_PERM. */
80 #define BLE_GATTS_NOTIFY (0x10) /**< In one byte, bit4 means: Notify bit. Used by @ref BLE_GATTS_NOTIFY_PERM_UNSEC, @ref BLE_GATTS_NOTIFY_PERM. */
81 #define BLE_GATTS_INDICATE (0x20) /**< In one byte, bit5 means: Indicate bit. Used by @ref BLE_GATTS_INDICATE_PERM_UNSEC, @ref BLE_GATTS_INDICATE_PERM */
82 #define BLE_GATTS_WRITE_SIGNED (0x40) /**< In one byte, bit6 means: Write_signed bit. Used by @ref BLE_GATTS_WRITE_SIGNED_PERM_UNSEC, @ref BLE_GATTS_WRITE_SIGNED_PERM. */
83 #define BLE_GATTS_EXT_PROP (0x80) /**< In one byte, bit7 means: Ext_property bit. Used by @ref BLE_GATTS_EXT_PROP_ENABLE. */
84 /** @} */
85 
86 /** @defgroup BLE_GATTS_ATTR_PERM_POS Attribute Permission Value Position
87  * @{ */
88 #define BLE_GATTS_READ_POS (0x00) /**< Bit position of read permission. Used by @ref BLE_GATTS_READ_PERM. */
89 #define BLE_GATTS_WRITE_POS (0x02) /**< Bit position of write permission. Used by @ref BLE_GATTS_WRITE_CMD_PERM, @ref BLE_GATTS_WRITE_REQ_PERM, @ref BLE_GATTS_WRITE_SIGNED_PERM. */
90 #define BLE_GATTS_INDICATE_POS (0x04) /**< Bit position of indicate bit. Used by @ref BLE_GATTS_INDICATE_PERM. */
91 #define BLE_GATTS_NOTIFY_POS (0x06) /**< Bit position of notify bit. Used by @ref BLE_GATTS_NOTIFY_PERM. */
92 /** @} */
93 
94 /** @defgroup BLE_GATTS_SEC_LEVEL Attribute and Service Access Rights
95  * @{ */
96 
97 #define BLE_GATTS_NOAUTH (0x00) /**< LE security mode 1, level 1. Link does not need to be encrypted or authenticated.
98  Parameter of @ref BLE_GATTS_SRVC_PERM, @ref BLE_GATTS_READ_PERM, @ref BLE_GATTS_WRITE_REQ_PERM, @ref BLE_GATTS_WRITE_CMD_PERM, @ref BLE_GATTS_WRITE_SIGNED_PERM, @ref BLE_GATTS_INDICATE_PERM, @ref BLE_GATTS_NOTIFY_PERM. */
99 #define BLE_GATTS_UNAUTH (0x01) /**< LE security mode 1, level 2. Link needs to be encrypted, but not to be authenticated.
100  Parameter of @ref BLE_GATTS_SRVC_PERM, @ref BLE_GATTS_READ_PERM, @ref BLE_GATTS_WRITE_REQ_PERM, @ref BLE_GATTS_WRITE_CMD_PERM, @ref BLE_GATTS_WRITE_SIGNED_PERM, @ref BLE_GATTS_INDICATE_PERM, @ref BLE_GATTS_NOTIFY_PERM. */
101 #define BLE_GATTS_AUTH (0x02) /**< LE security mode 1, level 3. Link needs to be encrypted and authenticated (MITM).
102  Parameter of @ref BLE_GATTS_SRVC_PERM, @ref BLE_GATTS_READ_PERM, @ref BLE_GATTS_WRITE_REQ_PERM, @ref BLE_GATTS_WRITE_CMD_PERM, @ref BLE_GATTS_WRITE_SIGNED_PERM, @ref BLE_GATTS_INDICATE_PERM, @ref BLE_GATTS_NOTIFY_PERM. */
103 #define BLE_GATTS_SEC_CON (0x03) /**< LE security mode 1, level 4. Link needs to be encrypted and authenticateBLE_GATTS_d (secure connections).
104  Parameter of @ref BLE_GATTS_SRVC_PERM, @ref BLE_GATTS_READ_PERM, @ref BLE_GATTS_WRITE_REQ_PERM, @ref BLE_GATTS_WRITE_CMD_PERM, @ref BLE_GATTS_WRITE_SIGNED_PERM, @ref BLE_GATTS_INDICATE_PERM, @ref BLE_GATTS_NOTIFY_PERM. */
105 /** @} */
106 
107 /** @defgroup BLE_GATTS_SEC_LEVEL_MASK Attribute and Service Security Level Mask
108  * @{ */
109 #define BLE_GATTS_SEC_LEVEL_MASK (0x03) /**< Security level mask.
110  Used by @ref BLE_GATTS_SRVC_PERM, @ref BLE_GATTS_READ_PERM, @ref BLE_GATTS_WRITE_REQ_PERM, @ref BLE_GATTS_WRITE_CMD_PERM, @ref BLE_GATTS_WRITE_SIGNED_PERM, @ref BLE_GATTS_INDICATE_PERM, @ref BLE_GATTS_NOTIFY_PERM. */
111 /** @} */
112 
113 /** @defgroup BLE_GATTS_UUID_TYPE Attribute and Service UUID Type
114  * @{ */
115 #define BLE_GATTS_UUID_TYPE_16 (0x00) /**< 16-bit UUID length. */
116 #define BLE_GATTS_UUID_TYPE_128 (0x02) /**< 128-bit UUID length. */
117 /** @} */
118 
119 /**
120  * Service permissions
121  *
122  * | 7 | 6--5 | 4 | 3--2 | 1 | 0 |
123  * |----|--------|----|--------|----|----|
124  * |SEC |UUID_LEN|DIS | AUTH |EKS | MI |
125  *
126  * Bit [0] : Service is multi-instantiated (0 = not support; 1 = support) \n
127  * Bit [1] : Encryption key size must be 16 bytes (0 = not need; 1 = need) \n
128  * Bit [2-3]: Service permission (0 = NOAUTH; 1 = UNAUTH; 2 = AUTH; 3 = SEC_CON) \n
129  * Bit [4] : Disable the service (0 = no; 1 = yes) \n
130  * Bit [5-6]: UUID Length Type (0 = 16 bits; 2 = 128 bits) \n
131  * Bit [7] : Secondary Service (0 = Primary Service; 1 = Secondary Service) \n
132  */
133 
134 /** @defgroup BLE_GATTS_SRVC_PERM Service Permission
135  * @{ */
136 #define BLE_GATTS_SRVC_SECONDARY_SET (0x80) /**< Secondary service set. */
137 #define BLE_GATTS_SRVC_UUID_TYPE_SET(uuid_len) ((uuid_len) << 5) /**< Service UUID length set. See @ref BLE_GATTS_UUID_TYPE. */
138 #define BLE_GATTS_SRVC_DISABLE (0x10) /**< Service disable. */
139 #define BLE_GATTS_SRVC_PERM(sec_level) (((sec_level) & SEC_LEVEL_MASK) << 2) /**< Service permission authentication. See @ref BLE_GATTS_SEC_LEVEL. */
140 #define BLE_GATTS_SRVC_ENCRP_KEY_SIZE_16 (0x02) /**< 16 bytes service encryption key size . */
141 #define BLE_GATTS_SRVC_MULTI_ENABLE (0x01) /**< Service is multi-instantiated. */
142 /** @} */
143 
144 /**
145  * Attribute permission
146  *
147  * | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7--6 | 5--4 | 3--2 | 1--0 |
148  * |----|----|----|----|----|----|----|----|--------|--------|--------|--------|
149  * |EXT | WS | I | N | WR | WC | RD | B | NP | IP | WP | RP |
150  *
151  * Bit [0-1]: Read permission (0 = NOAUTH; 1 = UNAUTH; 2 = AUTH; 3 = SEC_CON) \n
152  * Bit [2-3]: Write permission (0 = NOAUTH; 1 = UNAUTH; 2 = AUTH; 3 = SEC_CON) \n
153  * Bit [4-5]: Indicate permission (0 = NOAUTH; 1 = UNAUTH; 2 = AUTH; 3 = SEC_CON) \n
154  * Bit [6-7]: Notify permission (0 = NOAUTH; 1 = UNAUTH; 2 = AUTH; 3 = SEC_CON) \n
155  *
156  * Bit [8] : Broadcast permission \n
157  * Bit [9] : Read accepted \n
158  * Bit [10] : Write Command accepted \n
159  * Bit [11] : Write Request accepted \n
160  * Bit [12] : Notify accepted \n
161  * Bit [13] : Indicate accepted \n
162  * Bit [14] : Write Signed accepted \n
163  * Bit [15] : Extended Properties present \n
164  */
165 
166 /** @defgroup BLE_GATTS_ATTR_PERM Attribute Permission
167  * @{ */
168 #define BLE_GATTS_READ_PERM_UNSEC (BLE_GATTS_READ << 8) /**< Default Read permission. */
169 #define BLE_GATTS_READ_PERM(sec_level) (BLE_GATTS_READ << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_READ_POS)) /**< Read permission set. See @ref BLE_GATTS_SEC_LEVEL. */
170 #define BLE_GATTS_WRITE_REQ_PERM_UNSEC (BLE_GATTS_WRITE_REQ << 8) /**< Default Write Permission. */
171 #define BLE_GATTS_WRITE_REQ_PERM(sec_level) (BLE_GATTS_WRITE_REQ << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_WRITE_POS)) /**< Write permission set. See @ref BLE_GATTS_SEC_LEVEL. */
172 #define BLE_GATTS_WRITE_CMD_PERM_UNSEC (BLE_GATTS_WRITE_CMD << 8) /**< Default Write without Response Permission. */
173 #define BLE_GATTS_WRITE_CMD_PERM(sec_level) (BLE_GATTS_WRITE_CMD << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_WRITE_POS)) /**< Write without Response permission set. See @ref BLE_GATTS_SEC_LEVEL. */
174 #define BLE_GATTS_WRITE_SIGNED_PERM_UNSEC (BLE_GATTS_WRITE_SIGNED << 8) /**< Default Authenticated Signed Write Permission. */
175 #define BLE_GATTS_WRITE_SIGNED_PERM(sec_level) (BLE_GATTS_WRITE_SIGNED << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_WRITE_POS)) /**< Authenticated Signed Write permission set. See @ref BLE_GATTS_SEC_LEVEL. */
176 #define BLE_GATTS_INDICATE_PERM_UNSEC (BLE_GATTS_INDICATE << 8) /**< Default Indicate Permission. */
177 #define BLE_GATTS_INDICATE_PERM(sec_level) (BLE_GATTS_INDICATE << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_INDICATE_POS)) /**< Indicate permission set. See @ref BLE_GATTS_SEC_LEVEL. */
178 #define BLE_GATTS_NOTIFY_PERM_UNSEC (BLE_GATTS_NOTIFY << 8) /**< Default Notify Permission. */
179 #define BLE_GATTS_NOTIFY_PERM(sec_level) (BLE_GATTS_NOTIFY << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_NOTIFY_POS)) /**< Notify permission set. See @ref BLE_GATTS_SEC_LEVEL. */
180 #define BLE_GATTS_BROADCAST_ENABLE (BLE_GATTS_BROADCAST << 8) /**< Broadcast enable. */
181 #define BLE_GATTS_EXT_PROP_ENABLE (BLE_GATTS_EXT_PROP << 8) /**< Extended Properties enable. */
182 /** @} */
183 
184 /**
185  * Attribute extend permission
186  *
187  * | 15 | 14--13 | 12 | 11--0 |
188  * |----|---------|----|-----------------------------------------------------------|
189  * | VL |UUID_LEN |EKS | RESERVED |
190  *
191  * Bit [0-11] : Reserved \n
192  * Bit [12] : Encryption key size must be 16 bytes (0 = not need; 1 = need) \n
193  * Bit [14-13]: UUID length type (0 = 16 bits; 2 = 128 bits) \n
194  * Bit [15] : Value location (0 = value saved in BLE Stack; 1 = value saved in user space) \n
195  */
196 
197 /** @defgroup BLE_GATTS_ATTR_EXT_PERM Attribute Extend Permission
198  * @{ */
199 #define BLE_GATTS_ATT_VAL_LOC_USER (1 << 15) /**< Value location which means value saved in user space, the profile's read/write callback will be called. */
200 #define BLE_GATTS_ATT_VAL_LOC_STACK (0 << 15) /**< Value location which means value saved in BLE Stack. */
201 #define BLE_GATTS_ATT_UUID_TYPE_SET(uuid_len) ((uuid_len) << 13) /**< Attribute UUID length set. See @ref BLE_GATTS_UUID_TYPE */
202 #define BLE_GATTS_ATT_ENC_KEY_SIZE_16 (0x1000) /**< 16 bytes attribute encryption key size . */
203 /** @} */
204 /** @} */
205 
206 
207 
208 /** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations
209  * @{ */
210 /**
211  * @brief Service table type.
212  */
213 typedef enum
214 {
215  BLE_GATTS_SERVICE_TABLE_TYPE_16 = 0x00, /**< 16-bit service table type. */
216  BLE_GATTS_SERVICE_TABLE_TYPE_128, /**< 128-bit service table type. */
218 /** @} */
219 
220 
221 /** @addtogroup BLE_GATTS_STRUCTURES Structures
222  * @{ */
223 /**
224  * @brief Service(16-bit UUID) description.
225  */
226 typedef struct
227 {
228  uint16_t uuid; /**< 16-bit LSB-first UUID */
229  uint16_t perm; /**< Attribute permissions, see @ref BLE_GATTS_ATTR_PERM. \n
230  - For Primary/Secondary/Included Services, must be @ref BLE_GATTS_READ_PERM_UNSEC. \n
231  - For Characteristic Declaration, must be @ref BLE_GATTS_READ_PERM_UNSEC. \n
232  - For Characteristic Extended Properties, must be @ref BLE_GATTS_READ_PERM_UNSEC. \n
233  - For Characteristic Presentation Format, must be @ref BLE_GATTS_READ_PERM_UNSEC. \n
234  - For Characteristic Aggregate Format, must be @ref BLE_GATTS_READ_PERM_UNSEC. */
235 
236  uint16_t ext_perm; /**< Attribute extended permissions, see @ref BLE_GATTS_ATTR_EXT_PERM. \n
237  - For Primary/Secondary/Included Services, this field is not used and should be set to 0. \n
238  - For Characteristic Declaration, this field is not used and should be set to 0. \n
239  - For Characteristic Extended Properties, this field is not used and should be set to 0. \n
240  - For Client Characteristic Configuration and Server Characteristic Configuration, value must be saved in user space,
241  user needn't to set this value location bit. The UUID length type must be set to 0.*/
242 
243  uint16_t max_size; /**< Attribute max size. \n
244  - For Primary/Secondary/Included Services, this field is not used, set to 0. \n
245  - For Characteristic Declaration, this field is not used, set to 0. \n
246  - For Characteristic Extended Properties, this field contains 2-byte value. \n
247  - For Client Characteristic Configuration and Server Characteristic Configuration, this field is not used, set to 0. \n
248  - For others, this field is attribute max size. */
250 
251 /**
252  * @brief Service(128 bits UUID) description.
253  */
254 typedef struct
255 {
256  uint8_t uuid[16]; /**< 128 bits UUID LSB First. */
257  uint16_t perm; /**< Attribute permissions, see @ref BLE_GATTS_ATTR_PERM. \n
258  - For Primary/Secondary/Included Services, must be @ref BLE_GATTS_READ_PERM_UNSEC. \n
259  - For Characteristic Declaration, must be @ref BLE_GATTS_READ_PERM_UNSEC. \n
260  - For Characteristic Extended Properties, must be @ref BLE_GATTS_READ_PERM_UNSEC. \n
261  - For Characteristic Presentation Format, must be @ref BLE_GATTS_READ_PERM_UNSEC. \n
262  - For Characteristic Aggregate Format, must be @ref BLE_GATTS_READ_PERM_UNSEC. */
263 
264  uint16_t ext_perm; /**< Attribute extended permissions, see @ref BLE_GATTS_ATTR_EXT_PERM. \n
265  - For Primary/Secondary/Included Services, this field is not used, set to 0. \n
266  - For Characteristic Declaration, this field is not used, set to 0. \n
267  - For Characteristic Extended Properties, this field is not used, set to 0. \n
268  - For Client Characteristic Configuration and Server Characteristic Configuration, value must be saved in user space,
269  user needn't to set this value location bit. The UUID length type must be set to 0.*/
270 
271  uint16_t max_size; /**< Attribute max size. \n
272  - For Primary/Secondary/Included Services, this field is not used, set to 0. \n
273  - For Characteristic Declaration, this field is not used, set to 0. \n
274  - For Characteristic Extended Properties, this field contains 2-byte value. \n
275  - For Client Characteristic Configuration and Server Characteristic Configuration, this field is not used, set to 0. \n
276  - For others, this field is attribute max size. */
278 
279 /**
280  * @brief Parameter of Added service description.
281  */
282 typedef struct
283 {
284 
285  uint16_t *shdl; /**< Service start handle pointer. If *shdl = 0, it returns a handle using the first available handle (*shdl is modified); otherwise it verifies if the given start handle can be used to allocate handle range. */
286  const uint8_t *uuid; /**< Service UUID pointer. The pointer points to the Service UUID LSB. */
287  uint8_t *attr_tab_cfg; /**< Attribute table selector pointer. It can be set to NULL to select all items of attribute table. Each bit matches with an attribute of attribute table. \n EXAMPLE:if attr_tab_cfg points to array {0x3F, 0x03}, it means that the 0.1.2.3.4.5.8.9 items of attribute table will be added to database. */
288  uint8_t max_nb_attr; /**< Number of attributes in attribute table. */
289  union attribute_table /**< Attribute table. */
290  {
291  const ble_gatts_attm_desc_t *attr_tab_16; /**< 16 bits service description. The pointer point to attribute table of 16 bits service. See @ref ble_gatts_attm_desc_t. */
292  const ble_gatts_attm_desc_128_t *attr_tab_128; /**< 128 bits service description. The pointer point to attribute table of 128 bits service. See @ref ble_gatts_attm_desc_128_t. */
293  } attr_tab; /**< Attribute table. */
294  uint16_t *inc_srvc_handle[BLE_GATTS_MAX_INC_SRVC_NUM]; /**< Pointer array of Included Service start handle's address. */
295  uint16_t inc_srvc_num; /**< Included Service number for this service. */
296  uint8_t srvc_perm; /**< Service permission. See @ref BLE_GATTS_SRVC_PERM. */
297  ble_gatts_service_type_t attr_tab_type; /**< Service table type. See @ref ble_gatts_service_type_t. */
299 
300 /**
301  * @brief GATT read attribute result description.
302  */
303 typedef struct
304 {
305  uint16_t handle; /**< Handle of the read attribute. */
306  uint16_t length; /**< Length of read data. */
307  uint8_t status; /**< Status of read operation by upper layers. See @ref BLE_STACK_ERROR_CODES.*/
308  uint8_t *value; /**< Attribute value pointer. */
310 
311 /**
312  * @brief GATT write attribute result description.
313  */
314 typedef struct
315 {
316  uint16_t handle; /**< Handle of the attribute written. */
317  uint8_t status; /**< Status of write operation by upper layers. See @ref BLE_STACK_ERROR_CODES.*/
319 
320 /**
321  * @brief GATT prepare write result description.
322  */
323 typedef struct
324 {
325  uint16_t handle; /**< Handle of the attribute in prepare write operation. */
326  uint16_t length; /**< Current length of the attribute. */
327  uint8_t status; /**< Status of prepare write operation by upper layers. See @ref BLE_STACK_ERROR_CODES.*/
329 
330 
331 /**
332  * @brief GATT sending Notification or Indication event param description.
333  */
334 typedef struct
335 {
336  ble_gatt_evt_type_t type; /**< Request type (Notification/Indication). see @ref ble_gatt_evt_type_t. */
337  uint16_t handle; /**< Characteristic Value handle to be notified or indicated. */
338  uint16_t length; /**< Length of Characteristic Value to be sent. */
339  uint8_t *value; /**< Characteristic Value pointer. */
341 
342 /**
343  * @brief GATTS sending Multiple Notification event param description.
344  */
345 typedef struct
346 {
347  uint16_t handle; /**< Characteristic Value handle to be notified. */
348  uint16_t length; /**< Length of Characteristic Value to be sent. */
349  uint8_t *value; /**< Characteristic Value pointer. */
351 
352 /**@brief GATTCS Multiple Notification. */
353 typedef struct
354 {
355  uint16_t handle_count; /**< Handle count of the multiple attributes to be notified. */
356  noti_multiple_t *p_noti_multiple; /**< Pointer to the multiple attributes to be notified. */
358 
359 /**
360  * @brief GATT read request event for @ref BLE_GATTS_EVT_READ_REQUEST.
361  */
362 typedef struct
363 {
364  uint16_t handle; /**< Handle of the attribute to be read. */
366 
367 /**
368  * @brief GATT write request event for @ref BLE_GATTS_EVT_WRITE_REQUEST.
369  */
370 typedef struct
371 {
372  uint16_t handle; /**< Handle of the attribute to be written. */
373  uint16_t offset; /**< Offset at which the data has to be written. */
374  uint16_t length; /**< Data length to be written. */
375  uint8_t *value; /**< Data to be written to characteristic value. */
377 
378 /**
379  * @brief GATT prepare write request event for @ref BLE_GATTS_EVT_PREP_WRITE_REQUEST.
380  */
381 typedef struct
382 {
383  uint16_t handle; /**< Handle of the attribute for whose value is requested. */
385 
386 /**@brief Gatt Notification or indication event for @ref BLE_GATTS_EVT_NTF_IND. */
387 typedef struct
388 {
389  ble_gatt_evt_type_t type; /**< Notification or indication event type. */
390  uint16_t handle; /**< Handle of the write operation, or notification/indication operation. */
392 
393 /**@brief Gatt cccd recovery event for @ref BLE_GATTS_EVT_CCCD_RECOVERY. */
394 typedef struct
395 {
396  ble_gap_bdaddr_t peer_addr; /**< Pointer to peer address. */
397  uint16_t handle; /**< Handle of attribute. */
398  uint16_t cccd_val; /**< CCCD value. */
400 
401 /**
402  * @brief GATTS Multiple Variable Length Notification Operation Complete event structure.
403  */
404 typedef struct
405 {
406  uint16_t handle_count; /**< The count of handle to be notificated. */
408 
409 /**
410  * @brief GATT read request event for @ref BLE_GATTS_EVT_READ_REQUEST.
411  */
412 typedef struct
413 {
414  uint16_t cid; /**< Channel id. */
415  ble_gatts_evt_read_t param; /**< ble gatts evt read param. */
417 
418 /**
419  * @brief GATT write request struct.
420  */
421 typedef struct
422 {
423  uint16_t cid; /**< Channel id. */
424  ble_gatts_evt_write_t param; /**< ble gatts evt write param. */
426 
427 /**
428  * @brief GATT prepare write request struct.
429  */
430 typedef struct
431 {
432  uint16_t cid; /**< Channel id. */
433  ble_gatts_evt_prep_write_t param; /**< ble gatts evt prep write param. */
435 
436 /**
437  * @brief GATTS Operation Complete event structure.
438  */
439 typedef struct
440 {
441  uint16_t cid; /**< Channel id. */
442  ble_gatts_evt_ntf_ind_t param; /**< ble gatts evt ntf param. */
444 
445 /**@brief Gatt cccd recovery event for @ref BLE_GATTS_EVT_CCCD_RECOVERY. */
446 typedef struct
447 {
448  ble_gatts_evt_cccd_rec_t param; /**< ble gatts evt cccd rec param. */
450 
451 /**
452  * @brief GATTS Multiple Variable Length Notification Operation Complete event structure.
453  */
454 typedef struct
455 {
456  uint16_t cid; /**< Channel id. */
457  ble_gatts_evt_multi_ntf_t param ; /**< Ble gatts evt multi ntf param. */
459 /**
460  * @brief GATTS Multiple Variable Length Notification Operation Complete event structure.
461  */
462 typedef struct
463 {
464  uint16_t start_hdl;
465  uint16_t end_hdl;
467 
468 
469 /**@brief BLE GATTS event structure. */
470 typedef struct
471 {
472  uint8_t index; /**< Index of connection. */
473  union
474  {
475  ble_gatts_evt_read_t read_req; /**< Read request event. */
476  ble_gatts_evt_write_t write_req; /**< Write request event. */
477  ble_gatts_evt_prep_write_t prep_wr_req; /**< Prepare write request event. */
478  ble_gatts_evt_ntf_ind_t ntf_ind_sended; /**< Notification or indication sened event. */
479  ble_gatts_evt_cccd_rec_t cccd_recovery; /**< Gatt cccd recovery event . */
481  ble_gatts_evt_enh_read_t enh_read_req; /**< Enhance Read request event. */
482  ble_gatts_evt_enh_write_t enh_write_req; /**< Enhance Write request event. */
483  ble_gatts_evt_enh_prep_write_t enh_prep_wr_req; /**< Enhance Prepare write request event. */
484  ble_gatts_evt_enh_ntf_ind_t enh_ntf_ind_sended; /**< Enhance Notification or indication sened event. */
485  ble_gatts_evt_enh_cccd_rec_t enh_cccd_recovery; /**< Enhance Gatt cccd recovery event . */
488  } params; /**< Event Parameters. */
490 /** @} */
491 
492 
493 /** @addtogroup BLE_GATTS_FUNCTIONS Functions
494 * @{ */
495 /**
496  ****************************************************************************************
497  * @brief Register a service's attribute list.
498  *
499  * @param[in] p_param: Pointer to the parameter used in creating databases. see @ref ble_gatts_create_db_t.
500  *
501  * @retval ::SDK_SUCCESS: Database has been registered successfully.
502  * @retval ::SDK_ERR_POINTER_NULL: Param is NULL or param's members are NULL.
503  * @retval ::SDK_ERR_INVALID_PARAM: The member of param is invalid.
504  * @retval ::SDK_ERR_INVALID_HANDLE: The service handles can not be allocated.
505  * @retval ::SDK_ERR_NO_RESOURCES: There is not enough memory to allocate service buffer.
506  * @retval ::SDK_ERR_INVALID_PERM: Permissions of Client Characteristic Configuration or Server Characteristic Configuration are not set correctly.
507  ****************************************************************************************
508  */
510 
511 /**
512  ****************************************************************************************
513  * @brief Update attribute value only if the attribute value is saved in the BLE Stack space.
514  *
515  * @param[in] handle: Attribute handle.
516  * @param[in] length: Size of the value to set.
517  * @param[in] offset: Data offset of the value in attribute value.
518  * @param[in] p_value: The value to set. If offset = 0, the value is the new attribute value; otherwise, the value is part of the new attribute value.
519  *
520  * @retval ::SDK_SUCCESS: Successfully update the attribute value.
521  * @retval ::SDK_ERR_POINTER_NULL: Value is NULL.
522  * @retval ::SDK_ERR_INVALID_HANDLE: Handle not exist in database.
523  * @retval ::SDK_ERR_REQ_NOT_SUPPORTED: Attribute data is not present in database or cannot be modified.
524  * @retval ::SDK_ERR_INVALID_ATT_VAL_LEN: New value length exceeds maximum attribute value length.
525  * @retval ::SDK_ERR_INVALID_OFFSET: Offset exceeds current attribute value length.
526  ****************************************************************************************
527  */
528 uint16_t ble_gatts_value_set(uint16_t handle, uint16_t length, uint16_t offset, const uint8_t* p_value);
529 
530 /**
531  ****************************************************************************************
532  * @brief Retrieve attribute value only if the attribute value is saved in the BLE Stack space.
533  *
534  * @param[in] handle: Attribute handle.
535  * @param[in,out] p_length: Input as buffer size and output as attribute value length.
536  * @param[out] p_value: Buffer to store attribute value when buffer size is enough.
537  *
538  * @retval ::SDK_SUCCESS: Attribute value retrieved successfully.
539  * @retval ::SDK_ERR_POINTER_NULL: The pointer to input buffer size or input buffer is NULL.
540  * @retval ::SDK_ERR_INVALID_HANDLE: Handle not exist in the database.
541  * @retval ::SDK_ERR_REQ_NOT_SUPPORTED: Attribute data is not present in database.
542  * @retval ::SDK_ERR_INVALID_ATT_VAL_LEN: Attribute data value size is bigger than buffer size.
543  * @retval ::SDK_ERR_APP_ERROR: Database is not correctly initialized by application.
544  ****************************************************************************************
545  */
546 uint16_t ble_gatts_value_get(uint16_t handle, uint16_t* p_length, uint8_t* p_value);
547 
548 /**
549  ****************************************************************************************
550  * @brief Update attribute permission.
551  * @note The modifications of attribute permission to service/character/include/character_extended_properties_descriptor declaration: not supported. \n
552  * The modifications of attribute permission to others: perm can be updated and EKS of ext_perm can be updated.See @ref BLE_GATTS_ATTR_PERM.
553  *
554  * @param[in] handle: Attribute handle.
555  * @param[in] perm: New attribute permission.
556  * @param[in] ext_perm: New attribute extended permission.
557  *
558  * @retval ::SDK_SUCCESS: Update attribute permission successfully.
559  * @retval ::SDK_ERR_INVALID_HANDLE: Handle not exist in the database.
560  * @retval ::SDK_ERR_REQ_NOT_SUPPORTED: Attribute permission can't be modified.
561  ****************************************************************************************
562  */
563 uint16_t ble_gatts_attr_permission_set(uint16_t handle, uint16_t perm, uint16_t ext_perm);
564 
565 /**
566  ****************************************************************************************
567  * @brief Retrieve attribute permission.
568  *
569  * @param[in] handle: Attribute handle.
570  * @param[out] p_perm: Attribute permission value to be returned.
571  * @param[out] p_ext_perm: Attribute extended permission value to be returned.
572  *
573  * @retval ::SDK_SUCCESS: Retrieve attribute permission successfully.
574  * @retval ::SDK_ERR_POINTER_NULL: Perm or ext_perm is NULL.
575  * @retval ::SDK_ERR_INVALID_HANDLE: Handle not exist in the database.
576  ****************************************************************************************
577  */
578 uint16_t ble_gatts_attr_permission_get(uint16_t handle, uint16_t *p_perm, uint16_t *p_ext_perm);
579 
580 /**
581  ****************************************************************************************
582  * @brief Respond to an attribute read request..
583  *
584  * @note The status member gatts_read_cfm_t::status should be set to @ref BLE_ATT_ERR_INSUFF_AUTHOR
585  * to control the authorization of particular read operations of a client.
586  *
587  * @param[in] conn_idx: Current connection index.
588  * @param[in] p_param: Pointer to the parameters filled by profile. See @ref ble_gatts_read_cfm_t.
589  *
590  * @retval ::SDK_SUCCESS: Send read confirm value to stack successfully.
591  * @retval ::SDK_ERR_POINTER_NULL: Param is NULL.
592  * @retval ::SDK_ERR_INVALID_CONN_IDX: Conidx is invalid.
593  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
594  ****************************************************************************************
595  */
596 uint16_t ble_gatts_read_cfm(uint8_t conn_idx, const ble_gatts_read_cfm_t *p_param);
597 
598 /**
599  ****************************************************************************************
600  * @brief Respond to an attribute write request.
601  *
602  * @note The status member gatts_write_cfm_t::status should be set to @ref BLE_ATT_ERR_INSUFF_AUTHOR
603  * to control the authorization of particular client's write operation.
604  *
605  * @param[in] conn_idx: Current connection index.
606  * @param[in] p_param: Pointer to the parameters filled by profile. see @ref ble_gatts_write_cfm_t.
607  *
608  * @retval ::SDK_SUCCESS: Send write confirm status to stack successfully.
609  * @retval ::SDK_ERR_POINTER_NULL: Param is NULL.
610  * @retval ::SDK_ERR_INVALID_CONN_IDX: Conidx is invalid.
611  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
612  ****************************************************************************************
613  */
614 uint16_t ble_gatts_write_cfm(uint8_t conn_idx, const ble_gatts_write_cfm_t *p_param);
615 
616 /**
617  ****************************************************************************************
618  * @brief Respond to an attribute prepare write request.
619  *
620  * @note The status member gatts_prep_write_cfm_t::status should be set to @ref BLE_ATT_ERR_INSUFF_AUTHOR
621  * to control the authorization of particular client's write operation.
622  *
623  * @param[in] conn_idx: Current connection index.
624  * @param[in] p_param: Pointer to the parameters filled by profile. see @ref ble_gatts_prep_write_cfm_t.
625  *
626  * @retval ::SDK_SUCCESS: Send prepare write confirm status to stack successfully.
627  * @retval ::SDK_ERR_POINTER_NULL: Param is NULL.
628  * @retval ::SDK_ERR_INVALID_CONN_IDX: Conidx is invalid.
629  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
630  ****************************************************************************************
631  */
632 uint16_t ble_gatts_prepare_write_cfm(uint8_t conn_idx, const ble_gatts_prep_write_cfm_t *p_param);
633 
634 /**
635  ****************************************************************************************
636  * @brief Send out a notification or an indication.
637  *
638  * @note Check whether the relevant Client Characteristic Configuration Descriptor is enabled before using this API.
639  *
640  * @param[in] conn_idx: Current connection index.
641  * @param[in] p_param: Pointer to the parameters filled by profile. see @ref ble_gatts_noti_ind_t.
642  *
643  * @retval ::SDK_SUCCESS: Send Notification or Indication event to stack successfully.
644  * @retval ::SDK_ERR_POINTER_NULL: Param is NULL.
645  * @retval ::SDK_ERR_INVALID_CONN_IDX: Conidx is invalid.
646  * @retval ::SDK_ERR_INVALID_PARAM: Type is invalid.
647  * @retval ::SDK_ERR_INVALID_HANDLE: Handle not exist in the database.
648  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
649  ****************************************************************************************
650  */
651 uint16_t ble_gatts_noti_ind(uint8_t conn_idx, const ble_gatts_noti_ind_t *p_param);
652 
653 /**
654  ****************************************************************************************
655  * @brief When service on local device finishes upgrade, call this API to send service upgrade to stack.
656  * If the bonded device connects again, the stack will send service change to the bonded device until the bonded
657  * device has sent back indication confirmation.
658  ****************************************************************************************
659  */
661 
662 /**
663  ****************************************************************************************
664  * @brief Send out Multiple Variable Length Notifications. The execution status of sending notification or
665  * indication will be retrieved in the gatts event handler @ref BLE_GATTS_EVT_MULT_NTF.
666  *
667  * @note Check whether the relevant Client Characteristic Configuration Descriptor is enabled before using this API.
668  *
669  * @param[in] conn_idx: Current connection index.
670  * @param[in] p_param: Pointer to the parameters filled by profile. see @ref ble_gatts_noti_multiple_t.
671  *
672  * @retval ::SDK_SUCCESS: Send Notification or Indication event to stack successfully.
673  * @retval ::SDK_ERR_POINTER_NULL: Param is NULL.
674  * @retval ::SDK_ERR_INVALID_CONN_IDX: Conidx is invalid.
675  * @retval ::SDK_ERR_INVALID_PARAM: Type is invalid.
676  * @retval ::SDK_ERR_INVALID_HANDLE: Handle not exist in the database.
677  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
678  ****************************************************************************************
679  */
680 uint16_t ble_gatts_mult_noti(uint8_t conn_idx, const ble_gatts_noti_multiple_t *p_param);
681 
682 /** @} */
683 
684 #endif // BLE_SDK_GATTS_H_
685 /** @} */
686 
687 /** @} */
688 /** @} */
689 
ble_gatts_create_db_t::attribute_table::attr_tab_128
const ble_gatts_attm_desc_128_t * attr_tab_128
Definition: ble_gatts.h:292
ble_gatts_evt_t::enh_cccd_recovery
ble_gatts_evt_enh_cccd_rec_t enh_cccd_recovery
Definition: ble_gatts.h:485
ble_gatts_attm_desc_t::max_size
uint16_t max_size
Definition: ble_gatts.h:243
noti_multiple_t::length
uint16_t length
Definition: ble_gatts.h:348
ble_gatts_evt_enh_multi_ntf_t::param
ble_gatts_evt_multi_ntf_t param
Definition: ble_gatts.h:457
ble_gatts_create_db_t::srvc_perm
uint8_t srvc_perm
Definition: ble_gatts.h:296
ble_gatts_evt_enh_ntf_ind_t
GATTS Operation Complete event structure.
Definition: ble_gatts.h:440
ble_gatts_evt_inited_ind_t::start_hdl
uint16_t start_hdl
Definition: ble_gatts.h:464
ble_gatts_evt_enh_write_t::param
ble_gatts_evt_write_t param
Definition: ble_gatts.h:424
ble_gatts_attm_desc_128_t::max_size
uint16_t max_size
Definition: ble_gatts.h:271
ble_gatts_evt_read_t
GATT read request event for BLE_GATTS_EVT_READ_REQUEST.
Definition: ble_gatts.h:363
ble_gatts_evt_multi_ntf_t::handle_count
uint16_t handle_count
Definition: ble_gatts.h:406
ble_gatts_evt_t::enh_ntf_ind_sended
ble_gatts_evt_enh_ntf_ind_t enh_ntf_ind_sended
Definition: ble_gatts.h:484
ble_gatts_evt_t::enh_write_req
ble_gatts_evt_enh_write_t enh_write_req
Definition: ble_gatts.h:482
ble_gap_bdaddr_t
The struct of broadcast address with broadcast type.
Definition: ble_gapc.h:277
ble_gatts_write_cfm_t::status
uint8_t status
Definition: ble_gatts.h:317
ble_gatts_noti_multiple_t::p_noti_multiple
noti_multiple_t * p_noti_multiple
Definition: ble_gatts.h:356
ble_gatts_read_cfm_t::handle
uint16_t handle
Definition: ble_gatts.h:305
ble_gatts_evt_write_t::value
uint8_t * value
Definition: ble_gatts.h:375
ble_gatts_write_cfm_t
GATT write attribute result description.
Definition: ble_gatts.h:315
ble_gatts_evt_write_t::offset
uint16_t offset
Definition: ble_gatts.h:373
ble_gatts_create_db_t
Parameter of Added service description.
Definition: ble_gatts.h:283
noti_multiple_t
GATTS sending Multiple Notification event param description.
Definition: ble_gatts.h:346
ble_gatts_evt_enh_cccd_rec_t
Gatt cccd recovery event for BLE_GATTS_EVT_CCCD_RECOVERY.
Definition: ble_gatts.h:447
BLE_GATTS_SERVICE_TABLE_TYPE_16
@ BLE_GATTS_SERVICE_TABLE_TYPE_16
Definition: ble_gatts.h:215
ble_gatts_attm_desc_t
Service(16-bit UUID) description.
Definition: ble_gatts.h:227
noti_multiple_t::handle
uint16_t handle
Definition: ble_gatts.h:347
ble_gatts_evt_cccd_rec_t::cccd_val
uint16_t cccd_val
Definition: ble_gatts.h:398
ble_gatts_noti_ind_t
GATT sending Notification or Indication event param description.
Definition: ble_gatts.h:335
ble_gatt.h
BLE GATT.
ble_gatts_evt_ntf_ind_t::type
ble_gatt_evt_type_t type
Definition: ble_gatts.h:389
ble_gatts_evt_t::enh_multi_ntf
ble_gatts_evt_enh_multi_ntf_t enh_multi_ntf
Definition: ble_gatts.h:486
ble_gatts_evt_cccd_rec_t::peer_addr
ble_gap_bdaddr_t peer_addr
Definition: ble_gatts.h:396
ble_gatts_evt_t::enh_read_req
ble_gatts_evt_enh_read_t enh_read_req
Definition: ble_gatts.h:481
ble_gatts_evt_prep_write_t
GATT prepare write request event for BLE_GATTS_EVT_PREP_WRITE_REQUEST.
Definition: ble_gatts.h:382
BLE_GATTS_SERVICE_TABLE_TYPE_128
@ BLE_GATTS_SERVICE_TABLE_TYPE_128
Definition: ble_gatts.h:216
ble_gatts_evt_enh_multi_ntf_t
GATTS Multiple Variable Length Notification Operation Complete event structure.
Definition: ble_gatts.h:455
ble_gatts_attr_permission_set
uint16_t ble_gatts_attr_permission_set(uint16_t handle, uint16_t perm, uint16_t ext_perm)
Update attribute permission.
ble_gatts_evt_enh_read_t::param
ble_gatts_evt_read_t param
Definition: ble_gatts.h:415
ble_gatts_noti_ind_t::value
uint8_t * value
Definition: ble_gatts.h:339
ble_gatts_evt_t::index
uint8_t index
Definition: ble_gatts.h:472
ble_gatts_attm_desc_t::uuid
uint16_t uuid
Definition: ble_gatts.h:228
ble_gatts_noti_ind_t::type
ble_gatt_evt_type_t type
Definition: ble_gatts.h:336
ble_gatts_evt_t::inited_ind
ble_gatts_evt_inited_ind_t inited_ind
Definition: ble_gatts.h:487
ble_gatts_create_db_t::uuid
const uint8_t * uuid
Definition: ble_gatts.h:286
ble_gatts_service_type_t
ble_gatts_service_type_t
Service table type.
Definition: ble_gatts.h:214
ble_gatts_evt_write_t::handle
uint16_t handle
Definition: ble_gatts.h:372
ble_gatts_value_set
uint16_t ble_gatts_value_set(uint16_t handle, uint16_t length, uint16_t offset, const uint8_t *p_value)
Update attribute value only if the attribute value is saved in the BLE Stack space.
ble_gatts_evt_enh_prep_write_t
GATT prepare write request struct.
Definition: ble_gatts.h:431
ble_gatts_evt_enh_read_t
GATT read request event for BLE_GATTS_EVT_READ_REQUEST.
Definition: ble_gatts.h:413
ble_gatts_evt_inited_ind_t::end_hdl
uint16_t end_hdl
Definition: ble_gatts.h:465
ble_error.h
File that contains error codes.
ble_gatts_evt_t::read_req
ble_gatts_evt_read_t read_req
Definition: ble_gatts.h:475
ble_gapc.h
BLE GAPC API.
ble_gatts_evt_t::multi_ntf
ble_gatts_evt_multi_ntf_t multi_ntf
Definition: ble_gatts.h:480
ble_gatts_evt_t::enh_prep_wr_req
ble_gatts_evt_enh_prep_write_t enh_prep_wr_req
Definition: ble_gatts.h:483
ble_gatts_evt_t::write_req
ble_gatts_evt_write_t write_req
Definition: ble_gatts.h:476
ble_gatts_create_db_t::attribute_table::attr_tab_16
const ble_gatts_attm_desc_t * attr_tab_16
Definition: ble_gatts.h:291
ble_gatts_create_db_t::attr_tab_type
ble_gatts_service_type_t attr_tab_type
Definition: ble_gatts.h:297
ble_gatts_create_db_t::max_nb_attr
uint8_t max_nb_attr
Definition: ble_gatts.h:288
ble_gatts_noti_ind_t::handle
uint16_t handle
Definition: ble_gatts.h:337
ble_gatts_attm_desc_128_t::perm
uint16_t perm
Definition: ble_gatts.h:257
ble_gatts_evt_enh_read_t::cid
uint16_t cid
Definition: ble_gatts.h:414
ble_gatts_evt_cccd_rec_t::handle
uint16_t handle
Definition: ble_gatts.h:397
ble_gatts_write_cfm
uint16_t ble_gatts_write_cfm(uint8_t conn_idx, const ble_gatts_write_cfm_t *p_param)
Respond to an attribute write request.
ble_gatts_prep_write_cfm_t::handle
uint16_t handle
Definition: ble_gatts.h:325
ble_gatts_create_db_t::shdl
uint16_t * shdl
Definition: ble_gatts.h:285
ble_gatts_evt_t::cccd_recovery
ble_gatts_evt_cccd_rec_t cccd_recovery
Definition: ble_gatts.h:479
ble_gatts_read_cfm_t::length
uint16_t length
Definition: ble_gatts.h:306
ble_gatts_write_cfm_t::handle
uint16_t handle
Definition: ble_gatts.h:316
ble_gatts_evt_ntf_ind_t::handle
uint16_t handle
Definition: ble_gatts.h:390
ble_gatt_evt_type_t
ble_gatt_evt_type_t
GATT common events.
Definition: ble_gatt.h:67
ble_gatts_srvc_db_create
uint16_t ble_gatts_srvc_db_create(ble_gatts_create_db_t *p_param)
Register a service's attribute list.
ble_gatts_prep_write_cfm_t::status
uint8_t status
Definition: ble_gatts.h:327
ble_gatts_prepare_write_cfm
uint16_t ble_gatts_prepare_write_cfm(uint8_t conn_idx, const ble_gatts_prep_write_cfm_t *p_param)
Respond to an attribute prepare write request.
ble_gatts_attr_permission_get
uint16_t ble_gatts_attr_permission_get(uint16_t handle, uint16_t *p_perm, uint16_t *p_ext_perm)
Retrieve attribute permission.
ble_gatts_read_cfm_t::status
uint8_t status
Definition: ble_gatts.h:307
ble_gatts_evt_t
BLE GATTS event structure.
Definition: ble_gatts.h:471
ble_gatts_evt_write_t
GATT write request event for BLE_GATTS_EVT_WRITE_REQUEST.
Definition: ble_gatts.h:371
ble_gatts_create_db_t::inc_srvc_num
uint16_t inc_srvc_num
Definition: ble_gatts.h:295
ble_gatts_evt_prep_write_t::handle
uint16_t handle
Definition: ble_gatts.h:383
ble_gatts_prep_write_cfm_t::length
uint16_t length
Definition: ble_gatts.h:326
BLE_GATTS_MAX_INC_SRVC_NUM
#define BLE_GATTS_MAX_INC_SRVC_NUM
Definition: ble_gatts.h:71
ble_gatts_create_db_t::attr_tab_cfg
uint8_t * attr_tab_cfg
Definition: ble_gatts.h:287
noti_multiple_t::value
uint8_t * value
Definition: ble_gatts.h:349
ble_gatts_evt_enh_write_t::cid
uint16_t cid
Definition: ble_gatts.h:423
ble_gatts_evt_enh_ntf_ind_t::cid
uint16_t cid
Definition: ble_gatts.h:441
ble_gatts_evt_multi_ntf_t
GATTS Multiple Variable Length Notification Operation Complete event structure.
Definition: ble_gatts.h:405
ble_gatts_evt_t::ntf_ind_sended
ble_gatts_evt_ntf_ind_t ntf_ind_sended
Definition: ble_gatts.h:478
ble_att.h
Attribute Protocol.
ble_gatts_evt_enh_ntf_ind_t::param
ble_gatts_evt_ntf_ind_t param
Definition: ble_gatts.h:442
ble_gatts_value_get
uint16_t ble_gatts_value_get(uint16_t handle, uint16_t *p_length, uint8_t *p_value)
Retrieve attribute value only if the attribute value is saved in the BLE Stack space.
ble_gatts_evt_enh_prep_write_t::param
ble_gatts_evt_prep_write_t param
Definition: ble_gatts.h:433
ble_gatts_evt_read_t::handle
uint16_t handle
Definition: ble_gatts.h:364
ble_gatts_prep_write_cfm_t
GATT prepare write result description.
Definition: ble_gatts.h:324
ble_gatts_attm_desc_t::perm
uint16_t perm
Definition: ble_gatts.h:229
ble_gatts_noti_multiple_t
GATTCS Multiple Notification.
Definition: ble_gatts.h:354
ble_gatts_noti_ind_t::length
uint16_t length
Definition: ble_gatts.h:338
ble_gatts_noti_multiple_t::handle_count
uint16_t handle_count
Definition: ble_gatts.h:355
ble_gatts_service_changed
void ble_gatts_service_changed(void)
When service on local device finishes upgrade, call this API to send service upgrade to stack....
ble_gatts_evt_enh_write_t
GATT write request struct.
Definition: ble_gatts.h:422
ble_gatts_evt_enh_cccd_rec_t::param
ble_gatts_evt_cccd_rec_t param
Definition: ble_gatts.h:448
ble_gatts_evt_t::prep_wr_req
ble_gatts_evt_prep_write_t prep_wr_req
Definition: ble_gatts.h:477
ble_gatts_read_cfm_t::value
uint8_t * value
Definition: ble_gatts.h:308
ble_gatts_evt_enh_prep_write_t::cid
uint16_t cid
Definition: ble_gatts.h:432
ble_gatts_create_db_t::attribute_table
Definition: ble_gatts.h:290
ble_gatts_evt_inited_ind_t
GATTS Multiple Variable Length Notification Operation Complete event structure.
Definition: ble_gatts.h:463
ble_gatts_evt_enh_multi_ntf_t::cid
uint16_t cid
Definition: ble_gatts.h:456
ble_gatts_evt_write_t::length
uint16_t length
Definition: ble_gatts.h:374
ble_gatts_attm_desc_128_t::ext_perm
uint16_t ext_perm
Definition: ble_gatts.h:264
ble_gatts_read_cfm_t
GATT read attribute result description.
Definition: ble_gatts.h:304
ble_gatts_attm_desc_t::ext_perm
uint16_t ext_perm
Definition: ble_gatts.h:236
ble_gatts_mult_noti
uint16_t ble_gatts_mult_noti(uint8_t conn_idx, const ble_gatts_noti_multiple_t *p_param)
Send out Multiple Variable Length Notifications. The execution status of sending notification or indi...
ble_gatts_noti_ind
uint16_t ble_gatts_noti_ind(uint8_t conn_idx, const ble_gatts_noti_ind_t *p_param)
Send out a notification or an indication.
ble_gatts_attm_desc_128_t
Service(128 bits UUID) description.
Definition: ble_gatts.h:255
ble_gatts_evt_ntf_ind_t
Gatt Notification or indication event for BLE_GATTS_EVT_NTF_IND.
Definition: ble_gatts.h:388
ble_gatts_read_cfm
uint16_t ble_gatts_read_cfm(uint8_t conn_idx, const ble_gatts_read_cfm_t *p_param)
Respond to an attribute read request..
ble_gatts_evt_cccd_rec_t
Gatt cccd recovery event for BLE_GATTS_EVT_CCCD_RECOVERY.
Definition: ble_gatts.h:395