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