S145 SoftDevice for nRF54LV10 API documentation 10.0.0
Loading...
Searching...
No Matches
ble_gatts.h
1/*
2 * Copyright (c) Nordic Semiconductor ASA
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form, except as embedded into a Nordic
12 * Semiconductor ASA integrated circuit in a product or a software update for
13 * such product, must reproduce the above copyright notice, this list of
14 * conditions and the following disclaimer in the documentation and/or other
15 * materials provided with the distribution.
16 *
17 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * 4. This software, with or without modification, must only be used with a
22 * Nordic Semiconductor ASA integrated circuit.
23 *
24 * 5. Any software provided in binary form under this license must not be reverse
25 * engineered, decompiled, modified and/or disassembled.
26 *
27 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
45#ifndef BLE_GATTS_H__
46#define BLE_GATTS_H__
47
48#include <stdint.h>
49#include "nrf_svc.h"
50#include "nrf_error.h"
51#include "ble_hci.h"
52#include "ble_ranges.h"
53#include "ble_types.h"
54#include "ble_err.h"
55#include "ble_gatt.h"
56#include "ble_gap.h"
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
85
100
111
119#define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000)
120#define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001)
125#define BLE_GATTS_FIX_ATTR_LEN_MAX (510)
126#define BLE_GATTS_VAR_ATTR_LEN_MAX (512)
131#define BLE_GATTS_SRVC_TYPE_INVALID 0x00
132#define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01
133#define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02
139#define BLE_GATTS_ATTR_TYPE_INVALID 0x00
140#define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01
141#define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02
142#define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03
143#define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04
144#define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05
145#define BLE_GATTS_ATTR_TYPE_DESC 0x06
146#define BLE_GATTS_ATTR_TYPE_OTHER 0x07
152#define BLE_GATTS_OP_INVALID 0x00
153#define BLE_GATTS_OP_WRITE_REQ 0x01
154#define BLE_GATTS_OP_WRITE_CMD 0x02
155#define BLE_GATTS_OP_PREP_WRITE_REQ 0x04
156#define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05
157#define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06
162#define BLE_GATTS_VLOC_INVALID 0x00
163#define BLE_GATTS_VLOC_STACK 0x01
164#define BLE_GATTS_VLOC_USER 0x02
170#define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00
171#define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01
172#define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02
177#define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0)
178#define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1)
184#define BLE_GATTS_SERVICE_CHANGED_DEFAULT (1)
190#define BLE_GATTS_ATTR_TAB_SIZE_MIN (248)
191#define BLE_GATTS_ATTR_TAB_SIZE_DEFAULT (1408)
197#define BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT 1
208typedef struct
209{
213
224
225
227typedef struct
228{
231 uint16_t init_len;
232 uint16_t init_offs;
233 uint16_t max_len;
234 uint8_t *p_value;
238
240typedef struct
241{
242 uint16_t len;
243 uint16_t offset;
244 uint8_t *p_value;
248
249
251typedef struct
252{
253 uint8_t format;
254 int8_t exponent;
255 uint16_t unit;
256 uint8_t name_space;
257 uint16_t desc;
259
260
274
275
277typedef struct
278{
279 uint16_t value_handle;
281 uint16_t cccd_handle;
282 uint16_t sccd_handle;
284
285
287typedef struct
288{
289 uint16_t handle;
290 uint8_t type;
291 uint16_t offset;
292 uint16_t *p_len;
293 uint8_t const *p_data;
295
297typedef struct
298{
299 uint16_t gatt_status;
300 uint8_t update : 1;
303 uint16_t offset;
304 uint16_t len;
305 uint8_t const *p_data;
307
317
319typedef struct
320{
321 uint8_t service_changed : 1;
323
338
346typedef struct
347{
348 uint32_t attr_tab_size;
350
358
359
361typedef struct
362{
363 uint16_t handle;
365 uint8_t op;
367 uint16_t offset;
368 uint16_t len;
369 uint8_t data[1];
372
374typedef struct
375{
376 uint16_t handle;
378 uint16_t offset;
380
390
392typedef struct
393{
394 uint8_t hint;
396
397
399typedef struct
400{
401 uint16_t handle;
403
405typedef struct
406{
407 uint16_t client_rx_mtu;
409
411typedef struct
412{
413 uint8_t src;
415
417typedef struct
418{
419 uint8_t count;
421
437
462SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle));
463
464
488SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle));
489
490
517SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles));
518
519
540SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle));
541
563SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
564
587SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value));
588
652SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params));
653
688SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle));
689
721SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params));
722
723
765SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags));
766
767
798SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags));
799
800
809
821SVCALL(SD_BLE_GATTS_ATTR_GET, uint32_t, sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t * p_uuid, ble_gatts_attr_md_t * p_md));
822
851SVCALL(SD_BLE_GATTS_EXCHANGE_MTU_REPLY, uint32_t, sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu));
854#ifdef __cplusplus
855}
856#endif
857#endif // BLE_GATTS_H__
858
BLE_GATTS_CFGS
GATTS Configuration IDs.
Definition ble_gatts.h:106
@ BLE_GATTS_CFG_ATTR_TAB_SIZE
Definition ble_gatts.h:109
@ BLE_GATTS_CFG_SERVICE_CHANGED_CCCD_PERM
Definition ble_gatts.h:108
@ BLE_GATTS_CFG_SERVICE_CHANGED
Definition ble_gatts.h:107
BLE_GATTS_SVCS
GATTS API SVC numbers.
Definition ble_gatts.h:69
@ SD_BLE_GATTS_INITIAL_USER_HANDLE_GET
Definition ble_gatts.h:81
@ SD_BLE_GATTS_ATTR_GET
Definition ble_gatts.h:82
@ SD_BLE_GATTS_VALUE_GET
Definition ble_gatts.h:75
@ SD_BLE_GATTS_CHARACTERISTIC_ADD
Definition ble_gatts.h:72
@ SD_BLE_GATTS_SERVICE_CHANGED
Definition ble_gatts.h:77
@ SD_BLE_GATTS_RW_AUTHORIZE_REPLY
Definition ble_gatts.h:78
@ SD_BLE_GATTS_INCLUDE_ADD
Definition ble_gatts.h:71
@ SD_BLE_GATTS_HVX
Definition ble_gatts.h:76
@ SD_BLE_GATTS_VALUE_SET
Definition ble_gatts.h:74
@ SD_BLE_GATTS_SERVICE_ADD
Definition ble_gatts.h:70
@ SD_BLE_GATTS_SYS_ATTR_SET
Definition ble_gatts.h:79
@ SD_BLE_GATTS_SYS_ATTR_GET
Definition ble_gatts.h:80
@ SD_BLE_GATTS_EXCHANGE_MTU_REPLY
Definition ble_gatts.h:83
@ SD_BLE_GATTS_DESCRIPTOR_ADD
Definition ble_gatts.h:73
BLE_GATTS_EVTS
GATT Server Event IDs.
Definition ble_gatts.h:90
@ BLE_GATTS_EVT_SC_CONFIRM
Definition ble_gatts.h:95
@ BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST
Definition ble_gatts.h:92
@ BLE_GATTS_EVT_TIMEOUT
Definition ble_gatts.h:97
@ BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST
Definition ble_gatts.h:96
@ BLE_GATTS_EVT_WRITE
Definition ble_gatts.h:91
@ BLE_GATTS_EVT_SYS_ATTR_MISSING
Definition ble_gatts.h:93
@ BLE_GATTS_EVT_HVC
Definition ble_gatts.h:94
@ BLE_GATTS_EVT_HVN_TX_COMPLETE
Definition ble_gatts.h:98
uint32_t sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const *p_attr, uint16_t *p_handle)
Add a descriptor to the Attribute Table.
uint32_t sd_ble_gatts_value_set(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)
Set the value of a given attribute.
uint32_t sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)
Indicate the Service Changed attribute value.
uint32_t sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params)
Notify or Indicate an attribute value.
uint32_t sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid, uint16_t *p_handle)
Add a service declaration to the Attribute Table.
uint32_t sd_ble_gatts_attr_get(uint16_t handle, ble_uuid_t *p_uuid, ble_gatts_attr_md_t *p_md)
Retrieve the attribute UUID and/or metadata.
uint32_t sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t *p_sys_attr_data, uint16_t *p_len, uint32_t flags)
Retrieve persistent system attribute information from the stack.
uint32_t sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const *p_sys_attr_data, uint16_t len, uint32_t flags)
Update persistent system attribute information.
uint32_t sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *p_include_handle)
Add an include declaration to the Attribute Table.
uint32_t sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const *p_rw_authorize_reply_params)
Respond to a Read/Write authorization request.
uint32_t sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const *p_char_md, ble_gatts_attr_t const *p_attr_char_value, ble_gatts_char_handles_t *p_handles)
Add a characteristic declaration, a characteristic value declaration and optional characteristic desc...
uint32_t sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle)
Retrieve the first valid user attribute handle.
uint32_t sd_ble_gatts_exchange_mtu_reply(uint16_t conn_handle, uint16_t server_rx_mtu)
Reply to an ATT_MTU exchange request by sending an Exchange MTU Response to the client.
uint32_t sd_ble_gatts_value_get(uint16_t conn_handle, uint16_t handle, ble_gatts_value_t *p_value)
Get the value of a given attribute.
#define BLE_GATTS_EVT_BASE
Definition ble_ranges.h:91
#define BLE_GATTS_SVC_BASE
Definition ble_ranges.h:75
#define BLE_GATTS_CFG_BASE
Definition ble_ranges.h:132
GAP connection security modes.
Definition ble_gap.h:780
GATT Characteristic Extended Properties.
Definition ble_gatt.h:215
GATT Characteristic Properties.
Definition ble_gatt.h:202
uint8_t rd_auth
Definition ble_gatts.h:221
ble_gap_conn_sec_mode_t read_perm
Definition ble_gatts.h:217
uint8_t vlen
Definition ble_gatts.h:219
uint8_t vloc
Definition ble_gatts.h:220
ble_gap_conn_sec_mode_t write_perm
Definition ble_gatts.h:218
uint8_t wr_auth
Definition ble_gatts.h:222
Attribute metadata.
Definition ble_gatts.h:216
ble_uuid_t const * p_uuid
Definition ble_gatts.h:229
ble_gatts_attr_md_t const * p_attr_md
Definition ble_gatts.h:230
uint16_t max_len
Definition ble_gatts.h:233
uint16_t init_len
Definition ble_gatts.h:231
uint16_t init_offs
Definition ble_gatts.h:232
uint8_t * p_value
Definition ble_gatts.h:234
GATT Attribute.
Definition ble_gatts.h:228
uint16_t gatt_status
Definition ble_gatts.h:299
uint8_t update
Definition ble_gatts.h:300
uint8_t const * p_data
Definition ble_gatts.h:305
uint16_t offset
Definition ble_gatts.h:303
uint16_t len
Definition ble_gatts.h:304
GATT Authorization parameters.
Definition ble_gatts.h:298
uint32_t attr_tab_size
Definition ble_gatts.h:348
Attribute table size configuration parameters, set with sd_ble_cfg_set.
Definition ble_gatts.h:347
ble_gatts_attr_md_t perm
Definition ble_gatts.h:336
Service Changed CCCD permission configuration parameters, set with sd_ble_cfg_set.
Definition ble_gatts.h:335
uint8_t service_changed
Definition ble_gatts.h:321
Service Changed Inclusion configuration parameters, set with sd_ble_cfg_set.
Definition ble_gatts.h:320
uint16_t sccd_handle
Definition ble_gatts.h:282
uint16_t user_desc_handle
Definition ble_gatts.h:280
uint16_t value_handle
Definition ble_gatts.h:279
uint16_t cccd_handle
Definition ble_gatts.h:281
GATT Characteristic Definition Handles.
Definition ble_gatts.h:278
ble_gatts_attr_md_t const * p_user_desc_md
Definition ble_gatts.h:270
uint16_t char_user_desc_size
Definition ble_gatts.h:268
ble_gatt_char_props_t char_props
Definition ble_gatts.h:264
ble_gatts_attr_md_t const * p_cccd_md
Definition ble_gatts.h:271
uint16_t char_user_desc_max_size
Definition ble_gatts.h:267
ble_gatts_char_pf_t const * p_char_pf
Definition ble_gatts.h:269
uint8_t const * p_char_user_desc
Definition ble_gatts.h:266
ble_gatt_char_ext_props_t char_ext_props
Definition ble_gatts.h:265
ble_gatts_attr_md_t const * p_sccd_md
Definition ble_gatts.h:272
GATT Characteristic metadata.
Definition ble_gatts.h:263
uint8_t name_space
Definition ble_gatts.h:256
uint16_t desc
Definition ble_gatts.h:257
int8_t exponent
Definition ble_gatts.h:254
uint8_t format
Definition ble_gatts.h:253
uint16_t unit
Definition ble_gatts.h:255
GATT Characteristic Presentation Format.
Definition ble_gatts.h:252
uint8_t hvn_tx_queue_size
Definition ble_gatts.h:210
BLE GATTS connection configuration parameters, set with sd_ble_cfg_set.
Definition ble_gatts.h:209
uint16_t client_rx_mtu
Definition ble_gatts.h:407
Event structure for BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST.
Definition ble_gatts.h:406
uint16_t handle
Definition ble_gatts.h:401
Event structure for BLE_GATTS_EVT_HVC.
Definition ble_gatts.h:400
uint8_t count
Definition ble_gatts.h:419
Event structure for BLE_GATTS_EVT_HVN_TX_COMPLETE.
Definition ble_gatts.h:418
ble_uuid_t uuid
Definition ble_gatts.h:377
uint16_t handle
Definition ble_gatts.h:376
uint16_t offset
Definition ble_gatts.h:378
Event substructure for authorized read requests, see ble_gatts_evt_rw_authorize_request_t.
Definition ble_gatts.h:375
uint8_t type
Definition ble_gatts.h:384
ble_gatts_evt_read_t read
Definition ble_gatts.h:386
ble_gatts_evt_write_t write
Definition ble_gatts.h:387
Event structure for BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST.
Definition ble_gatts.h:383
uint8_t hint
Definition ble_gatts.h:394
Event structure for BLE_GATTS_EVT_SYS_ATTR_MISSING.
Definition ble_gatts.h:393
ble_gatts_evt_rw_authorize_request_t authorize_request
Definition ble_gatts.h:429
ble_gatts_evt_exchange_mtu_request_t exchange_mtu_request
Definition ble_gatts.h:432
ble_gatts_evt_hvn_tx_complete_t hvn_tx_complete
Definition ble_gatts.h:434
ble_gatts_evt_timeout_t timeout
Definition ble_gatts.h:433
ble_gatts_evt_hvc_t hvc
Definition ble_gatts.h:431
ble_gatts_evt_write_t write
Definition ble_gatts.h:428
ble_gatts_evt_sys_attr_missing_t sys_attr_missing
Definition ble_gatts.h:430
uint16_t conn_handle
Definition ble_gatts.h:425
GATTS event structure.
Definition ble_gatts.h:424
uint8_t src
Definition ble_gatts.h:413
Event structure for BLE_GATTS_EVT_TIMEOUT.
Definition ble_gatts.h:412
uint8_t op
Definition ble_gatts.h:365
uint16_t len
Definition ble_gatts.h:368
ble_uuid_t uuid
Definition ble_gatts.h:364
uint8_t auth_required
Definition ble_gatts.h:366
uint16_t handle
Definition ble_gatts.h:363
uint16_t offset
Definition ble_gatts.h:367
Event structure for BLE_GATTS_EVT_WRITE.
Definition ble_gatts.h:362
uint16_t offset
Definition ble_gatts.h:291
uint16_t handle
Definition ble_gatts.h:289
uint8_t type
Definition ble_gatts.h:290
uint16_t * p_len
Definition ble_gatts.h:292
uint8_t const * p_data
Definition ble_gatts.h:293
GATT HVx parameters.
Definition ble_gatts.h:288
ble_gatts_authorize_params_t read
Definition ble_gatts.h:313
uint8_t type
Definition ble_gatts.h:311
ble_gatts_authorize_params_t write
Definition ble_gatts.h:314
GATT Read or Write Authorize Reply parameters.
Definition ble_gatts.h:310
uint8_t * p_value
Definition ble_gatts.h:244
uint16_t offset
Definition ble_gatts.h:243
uint16_t len
Definition ble_gatts.h:242
GATT Attribute Value.
Definition ble_gatts.h:241
Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.
Definition ble_types.h:193
ble_gatts_cfg_service_changed_cccd_perm_t service_changed_cccd_perm
Definition ble_gatts.h:355
ble_gatts_cfg_attr_tab_size_t attr_tab_size
Definition ble_gatts.h:356
ble_gatts_cfg_service_changed_t service_changed
Definition ble_gatts.h:354
Config structure for GATTS configurations.
Definition ble_gatts.h:353