The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_VBLUNO51/TOOLCHAIN_IAR/nrf_ble_gatts.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_TY51822R3/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51/TARGET_MCU_NRF51822_UNIFIED/sdk/softdevice/s130/headers/nrf_ble_gatts.h@169:a7c7b631e539
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 148:fd96258d940d | 1 | /* |
Kojto | 148:fd96258d940d | 2 | * Copyright (c) 2000 Nordic Semiconductor ASA |
Kojto | 148:fd96258d940d | 3 | * All rights reserved. |
Kojto | 148:fd96258d940d | 4 | * |
Kojto | 148:fd96258d940d | 5 | * Redistribution and use in source and binary forms, with or without modification, |
Kojto | 148:fd96258d940d | 6 | * are permitted provided that the following conditions are met: |
Kojto | 148:fd96258d940d | 7 | * |
Kojto | 148:fd96258d940d | 8 | * 1. Redistributions of source code must retain the above copyright notice, this list |
Kojto | 148:fd96258d940d | 9 | * of conditions and the following disclaimer. |
Kojto | 148:fd96258d940d | 10 | * |
Kojto | 148:fd96258d940d | 11 | * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA |
Kojto | 148:fd96258d940d | 12 | * integrated circuit in a product or a software update for such product, must reproduce |
Kojto | 148:fd96258d940d | 13 | * the above copyright notice, this list of conditions and the following disclaimer in |
Kojto | 148:fd96258d940d | 14 | * the documentation and/or other materials provided with the distribution. |
Kojto | 148:fd96258d940d | 15 | * |
Kojto | 148:fd96258d940d | 16 | * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be |
Kojto | 148:fd96258d940d | 17 | * used to endorse or promote products derived from this software without specific prior |
Kojto | 148:fd96258d940d | 18 | * written permission. |
Kojto | 148:fd96258d940d | 19 | * |
Kojto | 148:fd96258d940d | 20 | * 4. This software, with or without modification, must only be used with a |
Kojto | 148:fd96258d940d | 21 | * Nordic Semiconductor ASA integrated circuit. |
Kojto | 148:fd96258d940d | 22 | * |
Kojto | 148:fd96258d940d | 23 | * 5. Any software provided in binary or object form under this license must not be reverse |
Kojto | 148:fd96258d940d | 24 | * engineered, decompiled, modified and/or disassembled. |
Kojto | 148:fd96258d940d | 25 | * |
Kojto | 148:fd96258d940d | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
Kojto | 148:fd96258d940d | 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
Kojto | 148:fd96258d940d | 28 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Kojto | 148:fd96258d940d | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
Kojto | 148:fd96258d940d | 30 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
Kojto | 148:fd96258d940d | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
Kojto | 148:fd96258d940d | 32 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
Kojto | 148:fd96258d940d | 33 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
Kojto | 148:fd96258d940d | 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
Kojto | 148:fd96258d940d | 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Kojto | 148:fd96258d940d | 36 | * |
Kojto | 148:fd96258d940d | 37 | */ |
Kojto | 148:fd96258d940d | 38 | |
Kojto | 148:fd96258d940d | 39 | |
Kojto | 148:fd96258d940d | 40 | /** |
Kojto | 148:fd96258d940d | 41 | @addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server |
Kojto | 148:fd96258d940d | 42 | @{ |
Kojto | 148:fd96258d940d | 43 | @brief Definitions and prototypes for the GATTS interface. |
Kojto | 148:fd96258d940d | 44 | */ |
Kojto | 148:fd96258d940d | 45 | |
Kojto | 148:fd96258d940d | 46 | #ifndef NRF_BLE_GATTS_H__ |
Kojto | 148:fd96258d940d | 47 | #define NRF_BLE_GATTS_H__ |
Kojto | 148:fd96258d940d | 48 | |
Kojto | 148:fd96258d940d | 49 | #include "nrf_ble_types.h" |
Kojto | 148:fd96258d940d | 50 | #include "nrf_ble_ranges.h" |
Kojto | 148:fd96258d940d | 51 | #include "nrf_ble_l2cap.h" |
Kojto | 148:fd96258d940d | 52 | #include "nrf_ble_gap.h" |
Kojto | 148:fd96258d940d | 53 | #include "nrf_ble_gatt.h" |
Kojto | 148:fd96258d940d | 54 | #include "nrf_svc.h" |
Kojto | 148:fd96258d940d | 55 | |
Kojto | 148:fd96258d940d | 56 | #ifdef __cplusplus |
Kojto | 148:fd96258d940d | 57 | extern "C" { |
Kojto | 148:fd96258d940d | 58 | #endif |
Kojto | 148:fd96258d940d | 59 | |
Kojto | 148:fd96258d940d | 60 | /** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations |
Kojto | 148:fd96258d940d | 61 | * @{ */ |
Kojto | 148:fd96258d940d | 62 | |
Kojto | 148:fd96258d940d | 63 | /** |
Kojto | 148:fd96258d940d | 64 | * @brief GATTS API SVC numbers. |
Kojto | 148:fd96258d940d | 65 | */ |
Kojto | 148:fd96258d940d | 66 | enum BLE_GATTS_SVCS |
Kojto | 148:fd96258d940d | 67 | { |
Kojto | 148:fd96258d940d | 68 | SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */ |
Kojto | 148:fd96258d940d | 69 | SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */ |
Kojto | 148:fd96258d940d | 70 | SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */ |
Kojto | 148:fd96258d940d | 71 | SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */ |
Kojto | 148:fd96258d940d | 72 | SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */ |
Kojto | 148:fd96258d940d | 73 | SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */ |
Kojto | 148:fd96258d940d | 74 | SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */ |
Kojto | 148:fd96258d940d | 75 | SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */ |
Kojto | 148:fd96258d940d | 76 | SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */ |
Kojto | 148:fd96258d940d | 77 | SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */ |
Kojto | 148:fd96258d940d | 78 | SD_BLE_GATTS_SYS_ATTR_GET, /**< Retrieve the persistent system attributes. */ |
Kojto | 148:fd96258d940d | 79 | SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, /**< Retrieve the first valid user handle. */ |
Kojto | 148:fd96258d940d | 80 | SD_BLE_GATTS_ATTR_GET /**< Retrieve the UUID and/or metadata of an attribute. */ |
Kojto | 148:fd96258d940d | 81 | }; |
Kojto | 148:fd96258d940d | 82 | |
Kojto | 148:fd96258d940d | 83 | /** |
Kojto | 148:fd96258d940d | 84 | * @brief GATT Server Event IDs. |
Kojto | 148:fd96258d940d | 85 | */ |
Kojto | 148:fd96258d940d | 86 | enum BLE_GATTS_EVTS |
Kojto | 148:fd96258d940d | 87 | { |
Kojto | 148:fd96258d940d | 88 | BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. \n See @ref ble_gatts_evt_write_t. */ |
Kojto | 148:fd96258d940d | 89 | BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. \n Reply with @ref sd_ble_gatts_rw_authorize_reply. \n See @ref ble_gatts_evt_rw_authorize_request_t. */ |
Kojto | 148:fd96258d940d | 90 | BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending. \n Respond with @ref sd_ble_gatts_sys_attr_set. \n See @ref ble_gatts_evt_sys_attr_missing_t. */ |
Kojto | 148:fd96258d940d | 91 | BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. \n See @ref ble_gatts_evt_hvc_t. */ |
Kojto | 148:fd96258d940d | 92 | BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. No additional event structure applies. */ |
Kojto | 148:fd96258d940d | 93 | BLE_GATTS_EVT_TIMEOUT /**< Peer failed to resonpond to an ATT request in time. \n See @ref ble_gatts_evt_timeout_t. */ |
Kojto | 148:fd96258d940d | 94 | }; |
Kojto | 148:fd96258d940d | 95 | /** @} */ |
Kojto | 148:fd96258d940d | 96 | |
Kojto | 148:fd96258d940d | 97 | /** @addtogroup BLE_GATTS_DEFINES Defines |
Kojto | 148:fd96258d940d | 98 | * @{ */ |
Kojto | 148:fd96258d940d | 99 | |
Kojto | 148:fd96258d940d | 100 | /** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS |
Kojto | 148:fd96258d940d | 101 | * @{ */ |
Kojto | 148:fd96258d940d | 102 | #define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */ |
Kojto | 148:fd96258d940d | 103 | #define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */ |
Kojto | 148:fd96258d940d | 104 | /** @} */ |
Kojto | 148:fd96258d940d | 105 | |
Kojto | 148:fd96258d940d | 106 | /** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths |
Kojto | 148:fd96258d940d | 107 | * @{ */ |
Kojto | 148:fd96258d940d | 108 | #define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */ |
Kojto | 148:fd96258d940d | 109 | #define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */ |
Kojto | 148:fd96258d940d | 110 | /** @} */ |
Kojto | 148:fd96258d940d | 111 | |
Kojto | 148:fd96258d940d | 112 | /** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types |
Kojto | 148:fd96258d940d | 113 | * @{ */ |
Kojto | 148:fd96258d940d | 114 | #define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */ |
Kojto | 148:fd96258d940d | 115 | #define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */ |
Kojto | 148:fd96258d940d | 116 | #define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */ |
Kojto | 148:fd96258d940d | 117 | /** @} */ |
Kojto | 148:fd96258d940d | 118 | |
Kojto | 148:fd96258d940d | 119 | |
Kojto | 148:fd96258d940d | 120 | /** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types |
Kojto | 148:fd96258d940d | 121 | * @{ */ |
Kojto | 148:fd96258d940d | 122 | #define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */ |
Kojto | 148:fd96258d940d | 123 | #define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */ |
Kojto | 148:fd96258d940d | 124 | #define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */ |
Kojto | 148:fd96258d940d | 125 | #define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */ |
Kojto | 148:fd96258d940d | 126 | #define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */ |
Kojto | 148:fd96258d940d | 127 | #define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */ |
Kojto | 148:fd96258d940d | 128 | #define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */ |
Kojto | 148:fd96258d940d | 129 | #define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */ |
Kojto | 148:fd96258d940d | 130 | /** @} */ |
Kojto | 148:fd96258d940d | 131 | |
Kojto | 148:fd96258d940d | 132 | |
Kojto | 148:fd96258d940d | 133 | /** @defgroup BLE_GATTS_OPS GATT Server Operations |
Kojto | 148:fd96258d940d | 134 | * @{ */ |
Kojto | 148:fd96258d940d | 135 | #define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */ |
Kojto | 148:fd96258d940d | 136 | #define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */ |
Kojto | 148:fd96258d940d | 137 | #define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */ |
Kojto | 148:fd96258d940d | 138 | #define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */ |
Kojto | 148:fd96258d940d | 139 | #define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */ |
Kojto | 148:fd96258d940d | 140 | #define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */ |
Kojto | 148:fd96258d940d | 141 | #define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */ |
Kojto | 148:fd96258d940d | 142 | /** @} */ |
Kojto | 148:fd96258d940d | 143 | |
Kojto | 148:fd96258d940d | 144 | /** @defgroup BLE_GATTS_VLOCS GATT Value Locations |
Kojto | 148:fd96258d940d | 145 | * @{ */ |
Kojto | 148:fd96258d940d | 146 | #define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */ |
Kojto | 148:fd96258d940d | 147 | #define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */ |
Kojto | 148:fd96258d940d | 148 | #define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack |
Kojto | 148:fd96258d940d | 149 | will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */ |
Kojto | 148:fd96258d940d | 150 | /** @} */ |
Kojto | 148:fd96258d940d | 151 | |
Kojto | 148:fd96258d940d | 152 | /** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types |
Kojto | 148:fd96258d940d | 153 | * @{ */ |
Kojto | 148:fd96258d940d | 154 | #define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */ |
Kojto | 148:fd96258d940d | 155 | #define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */ |
Kojto | 148:fd96258d940d | 156 | #define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */ |
Kojto | 148:fd96258d940d | 157 | /** @} */ |
Kojto | 148:fd96258d940d | 158 | |
Kojto | 148:fd96258d940d | 159 | /** @defgroup BLE_GATTS_SYS_ATTR_FLAGS System Attribute Flags |
Kojto | 148:fd96258d940d | 160 | * @{ */ |
Kojto | 148:fd96258d940d | 161 | #define BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS (1 << 0) /**< Restrict system attributes to system services only. */ |
Kojto | 148:fd96258d940d | 162 | #define BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS (1 << 1) /**< Restrict system attributes to user services only. */ |
Kojto | 148:fd96258d940d | 163 | /** @} */ |
Kojto | 148:fd96258d940d | 164 | |
Kojto | 148:fd96258d940d | 165 | /** @defgroup BLE_GATTS_ATTR_TAB_SIZE Attribute Table size |
Kojto | 148:fd96258d940d | 166 | * @{ |
Kojto | 148:fd96258d940d | 167 | */ |
Kojto | 148:fd96258d940d | 168 | #define BLE_GATTS_ATTR_TAB_SIZE_MIN 216 /**< Minimum Attribute Table size */ |
Kojto | 148:fd96258d940d | 169 | #define BLE_GATTS_ATTR_TAB_SIZE_DEFAULT 0x0000 /**< Default Attribute Table size (0x580 bytes for this version of the SoftDevice). */ |
Kojto | 148:fd96258d940d | 170 | /** @} */ |
Kojto | 148:fd96258d940d | 171 | |
Kojto | 148:fd96258d940d | 172 | /** @} */ |
Kojto | 148:fd96258d940d | 173 | |
Kojto | 148:fd96258d940d | 174 | /** @addtogroup BLE_GATTS_STRUCTURES Structures |
Kojto | 148:fd96258d940d | 175 | * @{ */ |
Kojto | 148:fd96258d940d | 176 | |
Kojto | 148:fd96258d940d | 177 | /** |
Kojto | 148:fd96258d940d | 178 | * @brief BLE GATTS initialization parameters. |
Kojto | 148:fd96258d940d | 179 | */ |
Kojto | 148:fd96258d940d | 180 | typedef struct |
Kojto | 148:fd96258d940d | 181 | { |
Kojto | 148:fd96258d940d | 182 | uint8_t service_changed:1; /**< Include the Service Changed characteristic in the Attribute Table. */ |
Kojto | 148:fd96258d940d | 183 | uint32_t attr_tab_size; /**< Attribute Table size in bytes. The size must be a multiple of 4. @ref BLE_GATTS_ATTR_TAB_SIZE_DEFAULT is used to set the default size. */ |
Kojto | 148:fd96258d940d | 184 | } ble_gatts_enable_params_t; |
Kojto | 148:fd96258d940d | 185 | |
Kojto | 148:fd96258d940d | 186 | /**@brief Attribute metadata. */ |
Kojto | 148:fd96258d940d | 187 | typedef struct |
Kojto | 148:fd96258d940d | 188 | { |
Kojto | 148:fd96258d940d | 189 | ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */ |
Kojto | 148:fd96258d940d | 190 | ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */ |
Kojto | 148:fd96258d940d | 191 | uint8_t vlen :1; /**< Variable length attribute. */ |
Kojto | 148:fd96258d940d | 192 | uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/ |
Kojto | 148:fd96258d940d | 193 | uint8_t rd_auth :1; /**< Read authorization and value will be requested from the application on every read operation. */ |
Kojto | 148:fd96258d940d | 194 | uint8_t wr_auth :1; /**< Write authorization will be requested from the application on every Write Request operation (but not Write Command). */ |
Kojto | 148:fd96258d940d | 195 | } ble_gatts_attr_md_t; |
Kojto | 148:fd96258d940d | 196 | |
Kojto | 148:fd96258d940d | 197 | |
Kojto | 148:fd96258d940d | 198 | /**@brief GATT Attribute. */ |
Kojto | 148:fd96258d940d | 199 | typedef struct |
Kojto | 148:fd96258d940d | 200 | { |
Kojto | 148:fd96258d940d | 201 | ble_uuid_t *p_uuid; /**< Pointer to the attribute UUID. */ |
Kojto | 148:fd96258d940d | 202 | ble_gatts_attr_md_t *p_attr_md; /**< Pointer to the attribute metadata structure. */ |
Kojto | 148:fd96258d940d | 203 | uint16_t init_len; /**< Initial attribute value length in bytes. */ |
Kojto | 148:fd96258d940d | 204 | uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */ |
Kojto | 148:fd96258d940d | 205 | uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */ |
Kojto | 148:fd96258d940d | 206 | uint8_t* p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer |
Kojto | 148:fd96258d940d | 207 | that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location. |
Kojto | 148:fd96258d940d | 208 | The stack may access that memory directly without the application's knowledge. For writable characteristics, this value must not be a location in flash memory.*/ |
Kojto | 148:fd96258d940d | 209 | } ble_gatts_attr_t; |
Kojto | 148:fd96258d940d | 210 | |
Kojto | 148:fd96258d940d | 211 | /**@brief GATT Attribute Value. */ |
Kojto | 148:fd96258d940d | 212 | typedef struct |
Kojto | 148:fd96258d940d | 213 | { |
Kojto | 148:fd96258d940d | 214 | uint16_t len; /**< Length in bytes to be written or read. Length in bytes written or read after successful return.*/ |
Kojto | 148:fd96258d940d | 215 | uint16_t offset; /**< Attribute value offset. */ |
Kojto | 148:fd96258d940d | 216 | uint8_t *p_value; /**< Pointer to where value is stored or will be stored. |
Kojto | 148:fd96258d940d | 217 | If value is stored in user memory, only the attribute length is updated when p_value == NULL. |
Kojto | 148:fd96258d940d | 218 | Set to NULL when reading to obtain the complete length of the attribute value */ |
Kojto | 148:fd96258d940d | 219 | } ble_gatts_value_t; |
Kojto | 148:fd96258d940d | 220 | |
Kojto | 148:fd96258d940d | 221 | |
Kojto | 148:fd96258d940d | 222 | /**@brief GATT Characteristic Presentation Format. */ |
Kojto | 148:fd96258d940d | 223 | typedef struct |
Kojto | 148:fd96258d940d | 224 | { |
Kojto | 148:fd96258d940d | 225 | uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */ |
Kojto | 148:fd96258d940d | 226 | int8_t exponent; /**< Exponent for integer data types. */ |
Kojto | 148:fd96258d940d | 227 | uint16_t unit; /**< Unit from Bluetooth Assigned Numbers. */ |
Kojto | 148:fd96258d940d | 228 | uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ |
Kojto | 148:fd96258d940d | 229 | uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */ |
Kojto | 148:fd96258d940d | 230 | } ble_gatts_char_pf_t; |
Kojto | 148:fd96258d940d | 231 | |
Kojto | 148:fd96258d940d | 232 | |
Kojto | 148:fd96258d940d | 233 | /**@brief GATT Characteristic metadata. */ |
Kojto | 148:fd96258d940d | 234 | typedef struct |
Kojto | 148:fd96258d940d | 235 | { |
Kojto | 148:fd96258d940d | 236 | ble_gatt_char_props_t char_props; /**< Characteristic Properties. */ |
Kojto | 148:fd96258d940d | 237 | ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */ |
Kojto | 148:fd96258d940d | 238 | uint8_t *p_char_user_desc; /**< Pointer to a UTF-8 encoded string (non-NULL terminated), NULL if the descriptor is not required. */ |
Kojto | 148:fd96258d940d | 239 | uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */ |
Kojto | 148:fd96258d940d | 240 | uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */ |
Kojto | 148:fd96258d940d | 241 | ble_gatts_char_pf_t* p_char_pf; /**< Pointer to a presentation format structure or NULL if the CPF descriptor is not required. */ |
Kojto | 148:fd96258d940d | 242 | ble_gatts_attr_md_t* p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */ |
Kojto | 148:fd96258d940d | 243 | ble_gatts_attr_md_t* p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */ |
Kojto | 148:fd96258d940d | 244 | ble_gatts_attr_md_t* p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */ |
Kojto | 148:fd96258d940d | 245 | } ble_gatts_char_md_t; |
Kojto | 148:fd96258d940d | 246 | |
Kojto | 148:fd96258d940d | 247 | |
Kojto | 148:fd96258d940d | 248 | /**@brief GATT Characteristic Definition Handles. */ |
Kojto | 148:fd96258d940d | 249 | typedef struct |
Kojto | 148:fd96258d940d | 250 | { |
Kojto | 148:fd96258d940d | 251 | uint16_t value_handle; /**< Handle to the characteristic value. */ |
Kojto | 148:fd96258d940d | 252 | uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ |
Kojto | 148:fd96258d940d | 253 | uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ |
Kojto | 148:fd96258d940d | 254 | uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or @ref BLE_GATT_HANDLE_INVALID if not present. */ |
Kojto | 148:fd96258d940d | 255 | } ble_gatts_char_handles_t; |
Kojto | 148:fd96258d940d | 256 | |
Kojto | 148:fd96258d940d | 257 | |
Kojto | 148:fd96258d940d | 258 | /**@brief GATT HVx parameters. */ |
Kojto | 148:fd96258d940d | 259 | typedef struct |
Kojto | 148:fd96258d940d | 260 | { |
Kojto | 148:fd96258d940d | 261 | uint16_t handle; /**< Characteristic Value Handle. */ |
Kojto | 148:fd96258d940d | 262 | uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */ |
Kojto | 148:fd96258d940d | 263 | uint16_t offset; /**< Offset within the attribute value. */ |
Kojto | 148:fd96258d940d | 264 | uint16_t *p_len; /**< Length in bytes to be written, length in bytes written after successful return. */ |
Kojto | 148:fd96258d940d | 265 | uint8_t *p_data; /**< Actual data content, use NULL to use the current attribute value. */ |
Kojto | 148:fd96258d940d | 266 | } ble_gatts_hvx_params_t; |
Kojto | 148:fd96258d940d | 267 | |
Kojto | 148:fd96258d940d | 268 | /**@brief GATT Authorization parameters. */ |
Kojto | 148:fd96258d940d | 269 | typedef struct |
Kojto | 148:fd96258d940d | 270 | { |
Kojto | 148:fd96258d940d | 271 | uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */ |
Kojto | 148:fd96258d940d | 272 | uint8_t update : 1; /**< If set, data supplied in p_data will be used to update the attribute value. |
Kojto | 148:fd96258d940d | 273 | Please note that for @ref BLE_GATTS_OP_WRITE_REQ operations this bit must always be set, |
Kojto | 148:fd96258d940d | 274 | as the data to be written needs to be stored and later provided by the application. */ |
Kojto | 148:fd96258d940d | 275 | uint16_t offset; /**< Offset of the attribute value being updated. */ |
Kojto | 148:fd96258d940d | 276 | uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */ |
Kojto | 148:fd96258d940d | 277 | const uint8_t *p_data; /**< Pointer to new value used to update the attribute value. */ |
Kojto | 148:fd96258d940d | 278 | } ble_gatts_authorize_params_t; |
Kojto | 148:fd96258d940d | 279 | |
Kojto | 148:fd96258d940d | 280 | /**@brief GATT Read or Write Authorize Reply parameters. */ |
Kojto | 148:fd96258d940d | 281 | typedef struct |
Kojto | 148:fd96258d940d | 282 | { |
Kojto | 148:fd96258d940d | 283 | uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ |
Kojto | 148:fd96258d940d | 284 | union { |
Kojto | 148:fd96258d940d | 285 | ble_gatts_authorize_params_t read; /**< Read authorization parameters. */ |
Kojto | 148:fd96258d940d | 286 | ble_gatts_authorize_params_t write; /**< Write authorization parameters. */ |
Kojto | 148:fd96258d940d | 287 | } params; /**< Reply Parameters. */ |
Kojto | 148:fd96258d940d | 288 | } ble_gatts_rw_authorize_reply_params_t; |
Kojto | 148:fd96258d940d | 289 | |
Kojto | 148:fd96258d940d | 290 | |
Kojto | 148:fd96258d940d | 291 | |
Kojto | 148:fd96258d940d | 292 | /**@brief Event structure for @ref BLE_GATTS_EVT_WRITE. */ |
Kojto | 148:fd96258d940d | 293 | typedef struct |
Kojto | 148:fd96258d940d | 294 | { |
Kojto | 148:fd96258d940d | 295 | uint16_t handle; /**< Attribute Handle. */ |
Kojto | 148:fd96258d940d | 296 | ble_uuid_t uuid; /**< Attribute UUID. */ |
Kojto | 148:fd96258d940d | 297 | uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */ |
Kojto | 148:fd96258d940d | 298 | uint8_t auth_required; /**< Writing operation deferred due to authorization requirement. Application may use @ref sd_ble_gatts_value_set to finalise the writing operation. */ |
Kojto | 148:fd96258d940d | 299 | uint16_t offset; /**< Offset for the write operation. */ |
Kojto | 148:fd96258d940d | 300 | uint16_t len; /**< Length of the received data. */ |
Kojto | 148:fd96258d940d | 301 | uint8_t data[1]; /**< Received data. @note This is a variable length array. The size of 1 indicated is only a placeholder for compilation. |
Kojto | 148:fd96258d940d | 302 | See @ref sd_ble_evt_get for more information on how to use event structures with variable length array members. */ |
Kojto | 148:fd96258d940d | 303 | } ble_gatts_evt_write_t; |
Kojto | 148:fd96258d940d | 304 | |
Kojto | 148:fd96258d940d | 305 | /**@brief Event substructure for authorized read requests, see @ref ble_gatts_evt_rw_authorize_request_t. */ |
Kojto | 148:fd96258d940d | 306 | typedef struct |
Kojto | 148:fd96258d940d | 307 | { |
Kojto | 148:fd96258d940d | 308 | uint16_t handle; /**< Attribute Handle. */ |
Kojto | 148:fd96258d940d | 309 | ble_uuid_t uuid; /**< Attribute UUID. */ |
Kojto | 148:fd96258d940d | 310 | uint16_t offset; /**< Offset for the read operation. */ |
Kojto | 148:fd96258d940d | 311 | } ble_gatts_evt_read_t; |
Kojto | 148:fd96258d940d | 312 | |
Kojto | 148:fd96258d940d | 313 | /**@brief Event structure for @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */ |
Kojto | 148:fd96258d940d | 314 | typedef struct |
Kojto | 148:fd96258d940d | 315 | { |
Kojto | 148:fd96258d940d | 316 | uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */ |
Kojto | 148:fd96258d940d | 317 | union { |
Kojto | 148:fd96258d940d | 318 | ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */ |
Kojto | 148:fd96258d940d | 319 | ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */ |
Kojto | 148:fd96258d940d | 320 | } request; /**< Request Parameters. */ |
Kojto | 148:fd96258d940d | 321 | } ble_gatts_evt_rw_authorize_request_t; |
Kojto | 148:fd96258d940d | 322 | |
Kojto | 148:fd96258d940d | 323 | /**@brief Event structure for @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. */ |
Kojto | 148:fd96258d940d | 324 | typedef struct |
Kojto | 148:fd96258d940d | 325 | { |
Kojto | 148:fd96258d940d | 326 | uint8_t hint; /**< Hint (currently unused). */ |
Kojto | 148:fd96258d940d | 327 | } ble_gatts_evt_sys_attr_missing_t; |
Kojto | 148:fd96258d940d | 328 | |
Kojto | 148:fd96258d940d | 329 | |
Kojto | 148:fd96258d940d | 330 | /**@brief Event structure for @ref BLE_GATTS_EVT_HVC. */ |
Kojto | 148:fd96258d940d | 331 | typedef struct |
Kojto | 148:fd96258d940d | 332 | { |
Kojto | 148:fd96258d940d | 333 | uint16_t handle; /**< Attribute Handle. */ |
Kojto | 148:fd96258d940d | 334 | } ble_gatts_evt_hvc_t; |
Kojto | 148:fd96258d940d | 335 | |
Kojto | 148:fd96258d940d | 336 | /**@brief Event structure for @ref BLE_GATTS_EVT_TIMEOUT. */ |
Kojto | 148:fd96258d940d | 337 | typedef struct |
Kojto | 148:fd96258d940d | 338 | { |
Kojto | 148:fd96258d940d | 339 | uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */ |
Kojto | 148:fd96258d940d | 340 | } ble_gatts_evt_timeout_t; |
Kojto | 148:fd96258d940d | 341 | |
Kojto | 148:fd96258d940d | 342 | |
Kojto | 148:fd96258d940d | 343 | /**@brief GATT Server event callback event structure. */ |
Kojto | 148:fd96258d940d | 344 | typedef struct |
Kojto | 148:fd96258d940d | 345 | { |
Kojto | 148:fd96258d940d | 346 | uint16_t conn_handle; /**< Connection Handle on which the event occurred. */ |
Kojto | 148:fd96258d940d | 347 | union |
Kojto | 148:fd96258d940d | 348 | { |
Kojto | 148:fd96258d940d | 349 | ble_gatts_evt_write_t write; /**< Write Event Parameters. */ |
Kojto | 148:fd96258d940d | 350 | ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */ |
Kojto | 148:fd96258d940d | 351 | ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */ |
Kojto | 148:fd96258d940d | 352 | ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */ |
Kojto | 148:fd96258d940d | 353 | ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */ |
Kojto | 148:fd96258d940d | 354 | } params; /**< Event Parameters. */ |
Kojto | 148:fd96258d940d | 355 | } ble_gatts_evt_t; |
Kojto | 148:fd96258d940d | 356 | |
Kojto | 148:fd96258d940d | 357 | /** @} */ |
Kojto | 148:fd96258d940d | 358 | |
Kojto | 148:fd96258d940d | 359 | /** @addtogroup BLE_GATTS_FUNCTIONS Functions |
Kojto | 148:fd96258d940d | 360 | * @{ */ |
Kojto | 148:fd96258d940d | 361 | |
Kojto | 148:fd96258d940d | 362 | /**@brief Add a service declaration to the Attribute Table. |
Kojto | 148:fd96258d940d | 363 | * |
Kojto | 148:fd96258d940d | 364 | * @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to |
Kojto | 148:fd96258d940d | 365 | * add a secondary service declaration that is not referenced by another service later in the Attribute Table. |
Kojto | 148:fd96258d940d | 366 | * |
Kojto | 148:fd96258d940d | 367 | * @mscs |
Kojto | 148:fd96258d940d | 368 | * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} |
Kojto | 148:fd96258d940d | 369 | * @endmscs |
Kojto | 148:fd96258d940d | 370 | * |
Kojto | 148:fd96258d940d | 371 | * @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES. |
Kojto | 148:fd96258d940d | 372 | * @param[in] p_uuid Pointer to service UUID. |
Kojto | 148:fd96258d940d | 373 | * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. |
Kojto | 148:fd96258d940d | 374 | * |
Kojto | 148:fd96258d940d | 375 | * @retval ::NRF_SUCCESS Successfully added a service declaration. |
Kojto | 148:fd96258d940d | 376 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 377 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table. |
Kojto | 148:fd96258d940d | 378 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. |
Kojto | 148:fd96258d940d | 379 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
Kojto | 148:fd96258d940d | 380 | */ |
Kojto | 148:fd96258d940d | 381 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 382 | |
Kojto | 148:fd96258d940d | 383 | |
Kojto | 148:fd96258d940d | 384 | /**@brief Add an include declaration to the Attribute Table. |
Kojto | 148:fd96258d940d | 385 | * |
Kojto | 148:fd96258d940d | 386 | * @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential population is supported at this time). |
Kojto | 148:fd96258d940d | 387 | * |
Kojto | 148:fd96258d940d | 388 | * @note The included service must already be present in the Attribute Table prior to this call. |
Kojto | 148:fd96258d940d | 389 | * |
Kojto | 148:fd96258d940d | 390 | * @mscs |
Kojto | 148:fd96258d940d | 391 | * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} |
Kojto | 148:fd96258d940d | 392 | * @endmscs |
Kojto | 148:fd96258d940d | 393 | * |
Kojto | 148:fd96258d940d | 394 | * @param[in] service_handle Handle of the service where the included service is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. |
Kojto | 148:fd96258d940d | 395 | * @param[in] inc_srvc_handle Handle of the included service. |
Kojto | 148:fd96258d940d | 396 | * @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored. |
Kojto | 148:fd96258d940d | 397 | * |
Kojto | 148:fd96258d940d | 398 | * @retval ::NRF_SUCCESS Successfully added an include declaration. |
Kojto | 148:fd96258d940d | 399 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 400 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services. |
Kojto | 148:fd96258d940d | 401 | * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. |
Kojto | 148:fd96258d940d | 402 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed. |
Kojto | 148:fd96258d940d | 403 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
Kojto | 148:fd96258d940d | 404 | * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. |
Kojto | 148:fd96258d940d | 405 | */ |
Kojto | 148:fd96258d940d | 406 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 407 | |
Kojto | 148:fd96258d940d | 408 | |
Kojto | 148:fd96258d940d | 409 | /**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the Attribute Table. |
Kojto | 148:fd96258d940d | 410 | * |
Kojto | 148:fd96258d940d | 411 | * @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential population is supported at this time). |
Kojto | 148:fd96258d940d | 412 | * |
Kojto | 148:fd96258d940d | 413 | * @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writeable auxiliaries bits, |
Kojto | 148:fd96258d940d | 414 | * readable (no security) and writeable (selectable) CCCDs and SCCDs and valid presentation format values. |
Kojto | 148:fd96258d940d | 415 | * |
Kojto | 148:fd96258d940d | 416 | * @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions. |
Kojto | 148:fd96258d940d | 417 | * |
Kojto | 148:fd96258d940d | 418 | * @mscs |
Kojto | 148:fd96258d940d | 419 | * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} |
Kojto | 148:fd96258d940d | 420 | * @endmscs |
Kojto | 148:fd96258d940d | 421 | * |
Kojto | 148:fd96258d940d | 422 | * @param[in] service_handle Handle of the service where the characteristic is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. |
Kojto | 148:fd96258d940d | 423 | * @param[in] p_char_md Characteristic metadata. |
Kojto | 148:fd96258d940d | 424 | * @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value. |
Kojto | 148:fd96258d940d | 425 | * @param[out] p_handles Pointer to the structure where the assigned handles will be stored. |
Kojto | 148:fd96258d940d | 426 | * |
Kojto | 148:fd96258d940d | 427 | * @retval ::NRF_SUCCESS Successfully added a characteristic. |
Kojto | 148:fd96258d940d | 428 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 429 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. |
Kojto | 148:fd96258d940d | 430 | * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required. |
Kojto | 148:fd96258d940d | 431 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. |
Kojto | 148:fd96258d940d | 432 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
Kojto | 148:fd96258d940d | 433 | * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. |
Kojto | 148:fd96258d940d | 434 | */ |
Kojto | 148:fd96258d940d | 435 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 436 | |
Kojto | 148:fd96258d940d | 437 | |
Kojto | 148:fd96258d940d | 438 | /**@brief Add a descriptor to the Attribute Table. |
Kojto | 148:fd96258d940d | 439 | * |
Kojto | 148:fd96258d940d | 440 | * @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential population is supported at this time). |
Kojto | 148:fd96258d940d | 441 | * |
Kojto | 148:fd96258d940d | 442 | * @mscs |
Kojto | 148:fd96258d940d | 443 | * @mmsc{@ref BLE_GATTS_ATT_TABLE_POP_MSC} |
Kojto | 148:fd96258d940d | 444 | * @endmscs |
Kojto | 148:fd96258d940d | 445 | * |
Kojto | 148:fd96258d940d | 446 | * @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if @ref BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially. |
Kojto | 148:fd96258d940d | 447 | * @param[in] p_attr Pointer to the attribute structure. |
Kojto | 148:fd96258d940d | 448 | * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored. |
Kojto | 148:fd96258d940d | 449 | * |
Kojto | 148:fd96258d940d | 450 | * @retval ::NRF_SUCCESS Successfully added a descriptor. |
Kojto | 148:fd96258d940d | 451 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 452 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints. |
Kojto | 148:fd96258d940d | 453 | * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required. |
Kojto | 148:fd96258d940d | 454 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack. |
Kojto | 148:fd96258d940d | 455 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
Kojto | 148:fd96258d940d | 456 | * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. |
Kojto | 148:fd96258d940d | 457 | */ |
Kojto | 148:fd96258d940d | 458 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 459 | |
Kojto | 148:fd96258d940d | 460 | /**@brief Set the value of a given attribute. |
Kojto | 148:fd96258d940d | 461 | * |
Kojto | 148:fd96258d940d | 462 | * @note Values other than system attributes can be set at any time, regardless of wheter any active connections exist. |
Kojto | 148:fd96258d940d | 463 | * |
Kojto | 148:fd96258d940d | 464 | * @mscs |
Kojto | 148:fd96258d940d | 465 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} |
Kojto | 148:fd96258d940d | 466 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} |
Kojto | 148:fd96258d940d | 467 | * @endmscs |
Kojto | 148:fd96258d940d | 468 | * |
Kojto | 148:fd96258d940d | 469 | * @param[in] conn_handle Connection handle. If the value does not belong to a system attribute then @ref BLE_CONN_HANDLE_INVALID can be used. |
Kojto | 148:fd96258d940d | 470 | * @param[in] handle Attribute handle. |
Kojto | 148:fd96258d940d | 471 | * @param[in,out] p_value Attribute value information. |
Kojto | 148:fd96258d940d | 472 | * |
Kojto | 148:fd96258d940d | 473 | * @retval ::NRF_SUCCESS Successfully set the value of the attribute. |
Kojto | 148:fd96258d940d | 474 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 475 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
Kojto | 148:fd96258d940d | 476 | * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. |
Kojto | 148:fd96258d940d | 477 | * @retval ::NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application. |
Kojto | 148:fd96258d940d | 478 | * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX. |
Kojto | 148:fd96258d940d | 479 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. |
Kojto | 148:fd96258d940d | 480 | * @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE @ref BLE_CONN_HANDLE_INVALID supplied on a system attribute. |
Kojto | 148:fd96258d940d | 481 | */ |
Kojto | 148:fd96258d940d | 482 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 483 | |
Kojto | 148:fd96258d940d | 484 | /**@brief Get the value of a given attribute. |
Kojto | 148:fd96258d940d | 485 | * |
Kojto | 148:fd96258d940d | 486 | * @note If the attribute value is longer than the size of the supplied buffer, |
Kojto | 148:fd96258d940d | 487 | * p_len will return the total attribute value length (excluding offset), |
Kojto | 148:fd96258d940d | 488 | * and not the number of bytes actually returned in p_data. |
Kojto | 148:fd96258d940d | 489 | * The application may use this information to allocate a suitable buffer size. |
Kojto | 148:fd96258d940d | 490 | * |
Kojto | 148:fd96258d940d | 491 | * @note When retrieving system attribute values with this function, the connection handle |
Kojto | 148:fd96258d940d | 492 | * may refer to an already disconnected connection. Refer to the documentation of |
Kojto | 148:fd96258d940d | 493 | * @ref sd_ble_gatts_sys_attr_get for further information. |
Kojto | 148:fd96258d940d | 494 | * |
Kojto | 148:fd96258d940d | 495 | * @param[in] conn_handle Connection handle. If the value does not belong to a system attribute then @ref BLE_CONN_HANDLE_INVALID can be used. |
Kojto | 148:fd96258d940d | 496 | * @param[in] handle Attribute handle. |
Kojto | 148:fd96258d940d | 497 | * @param[in,out] p_value Attribute value information. |
Kojto | 148:fd96258d940d | 498 | * |
Kojto | 148:fd96258d940d | 499 | * @retval ::NRF_SUCCESS Successfully retrieved the value of the attribute. |
Kojto | 148:fd96258d940d | 500 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 501 | * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. |
Kojto | 148:fd96258d940d | 502 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid attribute offset supplied. |
Kojto | 148:fd96258d940d | 503 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. |
Kojto | 148:fd96258d940d | 504 | * @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE @ref BLE_CONN_HANDLE_INVALID supplied on a system attribute. |
Kojto | 148:fd96258d940d | 505 | */ |
Kojto | 148:fd96258d940d | 506 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 507 | |
Kojto | 148:fd96258d940d | 508 | /**@brief Notify or Indicate an attribute value. |
Kojto | 148:fd96258d940d | 509 | * |
Kojto | 148:fd96258d940d | 510 | * @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation |
Kojto | 148:fd96258d940d | 511 | * (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that |
Kojto | 148:fd96258d940d | 512 | * the application can atomically perform a value update and a server initiated transaction with a single API call. |
Kojto | 148:fd96258d940d | 513 | * If the application chooses to indicate an attribute value, a @ref BLE_GATTS_EVT_HVC event will be issued as soon as the confirmation arrives from |
Kojto | 148:fd96258d940d | 514 | * the peer. |
Kojto | 148:fd96258d940d | 515 | * |
Kojto | 148:fd96258d940d | 516 | * @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution. |
Kojto | 148:fd96258d940d | 517 | * When receiveing the error codes @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and |
Kojto | 148:fd96258d940d | 518 | * @ref BLE_ERROR_NO_TX_PACKETS the Attribute Table has been updated. |
Kojto | 148:fd96258d940d | 519 | * The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len). |
Kojto | 148:fd96258d940d | 520 | * |
Kojto | 148:fd96258d940d | 521 | * @note It is important to note that a notification will <b>consume an application buffer</b>, and will therefore |
Kojto | 148:fd96258d940d | 522 | * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. An indication on the other hand will use the |
Kojto | 148:fd96258d940d | 523 | * standard server internal buffer and thus will only generate a @ref BLE_GATTS_EVT_HVC event as soon as the confirmation |
Kojto | 148:fd96258d940d | 524 | * has been received from the peer. Please see the documentation of @ref sd_ble_tx_packet_count_get for more details. |
Kojto | 148:fd96258d940d | 525 | * |
Kojto | 148:fd96258d940d | 526 | * @events |
Kojto | 148:fd96258d940d | 527 | * @event{@ref BLE_EVT_TX_COMPLETE, Transmission complete.} |
Kojto | 148:fd96258d940d | 528 | * @event{@ref BLE_GATTS_EVT_HVC, Confirmation received from peer.} |
Kojto | 148:fd96258d940d | 529 | * @endevents |
Kojto | 148:fd96258d940d | 530 | * |
Kojto | 148:fd96258d940d | 531 | * @mscs |
Kojto | 148:fd96258d940d | 532 | * @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC} |
Kojto | 148:fd96258d940d | 533 | * @mmsc{@ref BLE_GATTS_HVN_MSC} |
Kojto | 148:fd96258d940d | 534 | * @mmsc{@ref BLE_GATTS_HVI_MSC} |
Kojto | 148:fd96258d940d | 535 | * @mmsc{@ref BLE_GATTS_HVX_DISABLED_MSC} |
Kojto | 148:fd96258d940d | 536 | * @mmsc{@ref BLE_COMMON_APP_BUFF_MSC} |
Kojto | 148:fd96258d940d | 537 | * @endmscs |
Kojto | 148:fd96258d940d | 538 | * |
Kojto | 148:fd96258d940d | 539 | * @param[in] conn_handle Connection handle. |
Kojto | 148:fd96258d940d | 540 | * @param[in] p_hvx_params Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with |
Kojto | 148:fd96258d940d | 541 | * the contents pointed by it before sending the notification or indication. |
Kojto | 148:fd96258d940d | 542 | * |
Kojto | 148:fd96258d940d | 543 | * @retval ::NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value. |
Kojto | 148:fd96258d940d | 544 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
Kojto | 148:fd96258d940d | 545 | * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or notifications and/or indications not enabled in the CCCD. |
Kojto | 148:fd96258d940d | 546 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 547 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
Kojto | 148:fd96258d940d | 548 | * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate. |
Kojto | 148:fd96258d940d | 549 | * @retval ::BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated. |
Kojto | 148:fd96258d940d | 550 | * @retval ::NRF_ERROR_NOT_FOUND Attribute not found. |
Kojto | 148:fd96258d940d | 551 | * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. |
Kojto | 148:fd96258d940d | 552 | * @retval ::NRF_ERROR_BUSY Procedure already in progress. |
Kojto | 148:fd96258d940d | 553 | * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. |
Kojto | 148:fd96258d940d | 554 | * @retval ::BLE_ERROR_NO_TX_PACKETS No available application packets for this connection, applies only to notifications. |
Kojto | 148:fd96258d940d | 555 | */ |
Kojto | 148:fd96258d940d | 556 | SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const *p_hvx_params)); |
Kojto | 148:fd96258d940d | 557 | |
Kojto | 148:fd96258d940d | 558 | /**@brief Indicate the Service Changed attribute value. |
Kojto | 148:fd96258d940d | 559 | * |
Kojto | 148:fd96258d940d | 560 | * @details This call will send a Handle Value Indication to one or more peers connected to inform them that the Attribute |
Kojto | 148:fd96258d940d | 561 | * Table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will |
Kojto | 148:fd96258d940d | 562 | * be issued. |
Kojto | 148:fd96258d940d | 563 | * |
Kojto | 148:fd96258d940d | 564 | * @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here. |
Kojto | 148:fd96258d940d | 565 | * |
Kojto | 148:fd96258d940d | 566 | * @events |
Kojto | 148:fd96258d940d | 567 | * @event{@ref BLE_GATTS_EVT_SC_CONFIRM, Confirmation of attribute table change received from peer.} |
Kojto | 148:fd96258d940d | 568 | * @endevents |
Kojto | 148:fd96258d940d | 569 | * |
Kojto | 148:fd96258d940d | 570 | * @mscs |
Kojto | 148:fd96258d940d | 571 | * @mmsc{@ref BLE_GATTS_SC_MSC} |
Kojto | 148:fd96258d940d | 572 | * @endmscs |
Kojto | 148:fd96258d940d | 573 | * |
Kojto | 148:fd96258d940d | 574 | * @param[in] conn_handle Connection handle. |
Kojto | 148:fd96258d940d | 575 | * @param[in] start_handle Start of affected attribute handle range. |
Kojto | 148:fd96258d940d | 576 | * @param[in] end_handle End of affected attribute handle range. |
Kojto | 148:fd96258d940d | 577 | * |
Kojto | 148:fd96258d940d | 578 | * @retval ::NRF_SUCCESS Successfully queued the Service Changed indication for transmission. |
Kojto | 148:fd96258d940d | 579 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
Kojto | 148:fd96258d940d | 580 | * @retval ::NRF_ERROR_NOT_SUPPORTED Service Changed not enabled at initialization. See @ref sd_ble_enable and @ref ble_gatts_enable_params_t. |
Kojto | 148:fd96258d940d | 581 | * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or notifications and/or indications not enabled in the CCCD. |
Kojto | 148:fd96258d940d | 582 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. |
Kojto | 148:fd96258d940d | 583 | * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application. |
Kojto | 148:fd96258d940d | 584 | * @retval ::NRF_ERROR_BUSY Procedure already in progress. |
Kojto | 148:fd96258d940d | 585 | * @retval ::BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value. |
Kojto | 148:fd96258d940d | 586 | */ |
Kojto | 148:fd96258d940d | 587 | SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle)); |
Kojto | 148:fd96258d940d | 588 | |
Kojto | 148:fd96258d940d | 589 | /**@brief Respond to a Read/Write authorization request. |
Kojto | 148:fd96258d940d | 590 | * |
Kojto | 148:fd96258d940d | 591 | * @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application. |
Kojto | 148:fd96258d940d | 592 | * |
Kojto | 148:fd96258d940d | 593 | * @mscs |
Kojto | 148:fd96258d940d | 594 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_AUTH_MSC} |
Kojto | 148:fd96258d940d | 595 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_BUF_AUTH_MSC} |
Kojto | 148:fd96258d940d | 596 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_NOAUTH_MSC} |
Kojto | 148:fd96258d940d | 597 | * @mmsc{@ref BLE_GATTS_READ_REQ_AUTH_MSC} |
Kojto | 148:fd96258d940d | 598 | * @mmsc{@ref BLE_GATTS_WRITE_REQ_AUTH_MSC} |
Kojto | 148:fd96258d940d | 599 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_QUEUE_FULL_MSC} |
Kojto | 148:fd96258d940d | 600 | * @mmsc{@ref BLE_GATTS_QUEUED_WRITE_NOBUF_PEER_CANCEL_MSC} |
Kojto | 148:fd96258d940d | 601 | * @endmscs |
Kojto | 148:fd96258d940d | 602 | * |
Kojto | 148:fd96258d940d | 603 | * @param[in] conn_handle Connection handle. |
Kojto | 148:fd96258d940d | 604 | * @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application. |
Kojto | 148:fd96258d940d | 605 | * |
Kojto | 148:fd96258d940d | 606 | * @retval ::NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, Attribute Table updated. |
Kojto | 148:fd96258d940d | 607 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
Kojto | 148:fd96258d940d | 608 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 609 | * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no authorization request pending. |
Kojto | 148:fd96258d940d | 610 | * @retval ::NRF_ERROR_INVALID_PARAM Authorization op invalid, |
Kojto | 148:fd96258d940d | 611 | * handle supplied does not match requested handle, |
Kojto | 148:fd96258d940d | 612 | * or invalid data to be written provided by the application. |
Kojto | 148:fd96258d940d | 613 | * @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time. |
Kojto | 148:fd96258d940d | 614 | */ |
Kojto | 148:fd96258d940d | 615 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 616 | |
Kojto | 148:fd96258d940d | 617 | |
Kojto | 148:fd96258d940d | 618 | /**@brief Update persistent system attribute information. |
Kojto | 148:fd96258d940d | 619 | * |
Kojto | 148:fd96258d940d | 620 | * @details Supply information about persistent system attributes to the stack, |
Kojto | 148:fd96258d940d | 621 | * previously obtained using @ref sd_ble_gatts_sys_attr_get. |
Kojto | 148:fd96258d940d | 622 | * This call is only allowed for active connections, and is usually |
Kojto | 148:fd96258d940d | 623 | * made immediately after a connection is established with an known bonded device, |
Kojto | 148:fd96258d940d | 624 | * often as a response to a @ref BLE_GATTS_EVT_SYS_ATTR_MISSING. |
Kojto | 148:fd96258d940d | 625 | * |
Kojto | 148:fd96258d940d | 626 | * p_sysattrs may point directly to the application's stored copy of the system attributes |
Kojto | 148:fd96258d940d | 627 | * obtained using @ref sd_ble_gatts_sys_attr_get. |
Kojto | 148:fd96258d940d | 628 | * If the pointer is NULL, the system attribute info is initialized, assuming that |
Kojto | 148:fd96258d940d | 629 | * the application does not have any previously saved system attribute data for this device. |
Kojto | 148:fd96258d940d | 630 | * |
Kojto | 148:fd96258d940d | 631 | * @note The state of persistent system attributes is reset upon connection establishment and then remembered for its duration. |
Kojto | 148:fd96258d940d | 632 | * |
Kojto | 148:fd96258d940d | 633 | * @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially. |
Kojto | 148:fd96258d940d | 634 | * This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or |
Kojto | 148:fd96258d940d | 635 | * reset the SoftDevice to return to a known state. |
Kojto | 148:fd96258d940d | 636 | * |
Kojto | 148:fd96258d940d | 637 | * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be modified. |
Kojto | 148:fd96258d940d | 638 | * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be modified. |
Kojto | 148:fd96258d940d | 639 | * |
Kojto | 148:fd96258d940d | 640 | * @mscs |
Kojto | 148:fd96258d940d | 641 | * @mmsc{@ref BLE_GATTS_HVX_SYS_ATTRS_MISSING_MSC} |
Kojto | 148:fd96258d940d | 642 | * @mmsc{@ref BLE_GATTS_SYS_ATTRS_UNK_PEER_MSC} |
Kojto | 148:fd96258d940d | 643 | * @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC} |
Kojto | 148:fd96258d940d | 644 | * @endmscs |
Kojto | 148:fd96258d940d | 645 | * |
Kojto | 148:fd96258d940d | 646 | * @param[in] conn_handle Connection handle. |
Kojto | 148:fd96258d940d | 647 | * @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL. |
Kojto | 148:fd96258d940d | 648 | * @param[in] len Size of data pointed by p_sys_attr_data, in octets. |
Kojto | 148:fd96258d940d | 649 | * @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS |
Kojto | 148:fd96258d940d | 650 | * |
Kojto | 148:fd96258d940d | 651 | * @retval ::NRF_SUCCESS Successfully set the system attribute information. |
Kojto | 148:fd96258d940d | 652 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
Kojto | 148:fd96258d940d | 653 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 654 | * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State. |
Kojto | 148:fd96258d940d | 655 | * @retval ::NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get. |
Kojto | 148:fd96258d940d | 656 | * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation. |
Kojto | 148:fd96258d940d | 657 | * @retval ::NRF_ERROR_BUSY The stack is busy. Retry at later time. |
Kojto | 148:fd96258d940d | 658 | */ |
Kojto | 148:fd96258d940d | 659 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 660 | |
Kojto | 148:fd96258d940d | 661 | |
Kojto | 148:fd96258d940d | 662 | /**@brief Retrieve persistent system attribute information from the stack. |
Kojto | 148:fd96258d940d | 663 | * |
Kojto | 148:fd96258d940d | 664 | * @details This call is used to retrieve information about values to be stored perisistently by the application |
Kojto | 148:fd96258d940d | 665 | * during the lifetime of a connection or after it has been terminated. When a new connection is established with the same bonded device, |
Kojto | 148:fd96258d940d | 666 | * the system attribute information retrieved with this function should be restored using using @ref sd_ble_gatts_sys_attr_set. |
Kojto | 148:fd96258d940d | 667 | * If retrieved after disconnection, the data should be read before a new connection established. The connection handle for |
Kojto | 148:fd96258d940d | 668 | * the previous, now disconnected, connection will remain valid until a new one is created to allow this API call to refer to it. |
Kojto | 148:fd96258d940d | 669 | * Connection handles belonging to active connections can be used as well, but care should be taken since the system attributes |
Kojto | 148:fd96258d940d | 670 | * may be written to at any time by the peer during a connection's lifetime. |
Kojto | 148:fd96258d940d | 671 | * |
Kojto | 148:fd96258d940d | 672 | * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS is used with this function, only the system attributes included in system services will be returned. |
Kojto | 148:fd96258d940d | 673 | * @note When the @ref BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS is used with this function, only the system attributes included in user services will be returned. |
Kojto | 148:fd96258d940d | 674 | * |
Kojto | 148:fd96258d940d | 675 | * @mscs |
Kojto | 148:fd96258d940d | 676 | * @mmsc{@ref BLE_GATTS_SYS_ATTRS_BONDED_PEER_MSC} |
Kojto | 148:fd96258d940d | 677 | * @endmscs |
Kojto | 148:fd96258d940d | 678 | * |
Kojto | 148:fd96258d940d | 679 | * @param[in] conn_handle Connection handle of the recently terminated connection. |
Kojto | 148:fd96258d940d | 680 | * @param[out] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. The format of the data is described |
Kojto | 148:fd96258d940d | 681 | * in @ref BLE_GATTS_SYS_ATTRS_FORMAT. NULL can be provided to obtain the length of the data. |
Kojto | 148:fd96258d940d | 682 | * @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditially updated to actual length of system attribute data. |
Kojto | 148:fd96258d940d | 683 | * @param[in] flags Optional additional flags, see @ref BLE_GATTS_SYS_ATTR_FLAGS |
Kojto | 148:fd96258d940d | 684 | * |
Kojto | 148:fd96258d940d | 685 | * @retval ::NRF_SUCCESS Successfully retrieved the system attribute information. |
Kojto | 148:fd96258d940d | 686 | * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. |
Kojto | 148:fd96258d940d | 687 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 688 | * @retval ::NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer. |
Kojto | 148:fd96258d940d | 689 | * @retval ::NRF_ERROR_NOT_FOUND No system attributes found. |
Kojto | 148:fd96258d940d | 690 | */ |
Kojto | 148:fd96258d940d | 691 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 692 | |
Kojto | 148:fd96258d940d | 693 | |
Kojto | 148:fd96258d940d | 694 | /**@brief Retrieve the first valid user attribute handle. |
Kojto | 148:fd96258d940d | 695 | * |
Kojto | 148:fd96258d940d | 696 | * @param[out] p_handle Pointer to an integer where the handle will be stored. |
Kojto | 148:fd96258d940d | 697 | * |
Kojto | 148:fd96258d940d | 698 | * @retval ::NRF_SUCCESS Successfully retrieved the handle. |
Kojto | 148:fd96258d940d | 699 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 700 | */ |
Kojto | 148:fd96258d940d | 701 | SVCALL(SD_BLE_GATTS_INITIAL_USER_HANDLE_GET, uint32_t, sd_ble_gatts_initial_user_handle_get(uint16_t *p_handle)); |
Kojto | 148:fd96258d940d | 702 | |
Kojto | 148:fd96258d940d | 703 | /**@brief Retrieve the attribute UUID and/or metadata. |
Kojto | 148:fd96258d940d | 704 | * |
Kojto | 148:fd96258d940d | 705 | * @param[in] handle Attribute handle |
Kojto | 148:fd96258d940d | 706 | * @param[out] p_uuid UUID of the attribute. Use NULL to omit this field. |
Kojto | 148:fd96258d940d | 707 | * @param[out] p_md Metadata of the attribute. Use NULL to omit this field. |
Kojto | 148:fd96258d940d | 708 | * |
Kojto | 148:fd96258d940d | 709 | * @retval ::NRF_SUCCESS Successfully retrieved the attribute metadata, |
Kojto | 148:fd96258d940d | 710 | * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. |
Kojto | 148:fd96258d940d | 711 | * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied. Returned when both @c p_uuid and @c p_md are NULL. |
Kojto | 148:fd96258d940d | 712 | * @retval ::NRF_ERROR_NOT_FOUND Attribute was not found. |
Kojto | 148:fd96258d940d | 713 | */ |
Kojto | 148:fd96258d940d | 714 | SVCALL(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)); |
Kojto | 148:fd96258d940d | 715 | |
Kojto | 148:fd96258d940d | 716 | /** @} */ |
Kojto | 148:fd96258d940d | 717 | |
Kojto | 148:fd96258d940d | 718 | #ifdef __cplusplus |
Kojto | 148:fd96258d940d | 719 | } |
Kojto | 148:fd96258d940d | 720 | #endif |
Kojto | 148:fd96258d940d | 721 | #endif // NRF_BLE_GATTS_H__ |
Kojto | 148:fd96258d940d | 722 | |
Kojto | 148:fd96258d940d | 723 | /** |
Kojto | 148:fd96258d940d | 724 | @} |
Kojto | 148:fd96258d940d | 725 | */ |