テスト用

Fork of nRF51822 by Nordic Semiconductor

Committer:
bogdanm
Date:
Wed Mar 26 14:38:17 2014 +0000
Revision:
0:eff01767de02
Child:
37:c29c330d942c
Initial import of the nRF51822 code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:eff01767de02 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
bogdanm 0:eff01767de02 2 *
bogdanm 0:eff01767de02 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
bogdanm 0:eff01767de02 4 * copying, transfer or disclosure of such information is prohibited except by express written
bogdanm 0:eff01767de02 5 * agreement with Nordic Semiconductor.
bogdanm 0:eff01767de02 6 *
bogdanm 0:eff01767de02 7 */
bogdanm 0:eff01767de02 8 /**
bogdanm 0:eff01767de02 9 @addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server
bogdanm 0:eff01767de02 10 @{
bogdanm 0:eff01767de02 11 @brief Definitions and prototypes for the GATTS interface.
bogdanm 0:eff01767de02 12 */
bogdanm 0:eff01767de02 13
bogdanm 0:eff01767de02 14 #ifndef BLE_GATTS_H__
bogdanm 0:eff01767de02 15 #define BLE_GATTS_H__
bogdanm 0:eff01767de02 16
bogdanm 0:eff01767de02 17 #include "nordic_global.h"
bogdanm 0:eff01767de02 18 #include "ble_types.h"
bogdanm 0:eff01767de02 19 #include "ble_ranges.h"
bogdanm 0:eff01767de02 20 #include "ble_l2cap.h"
bogdanm 0:eff01767de02 21 #include "ble_gap.h"
bogdanm 0:eff01767de02 22 #include "ble_gatt.h"
bogdanm 0:eff01767de02 23 #include "nrf_svc.h"
bogdanm 0:eff01767de02 24
bogdanm 0:eff01767de02 25
bogdanm 0:eff01767de02 26 /**
bogdanm 0:eff01767de02 27 * @brief GATTS API SVC numbers.
bogdanm 0:eff01767de02 28 */
bogdanm 0:eff01767de02 29 enum BLE_GATTS_SVCS
bogdanm 0:eff01767de02 30 {
bogdanm 0:eff01767de02 31 SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */
bogdanm 0:eff01767de02 32 SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */
bogdanm 0:eff01767de02 33 SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */
bogdanm 0:eff01767de02 34 SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */
bogdanm 0:eff01767de02 35 SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */
bogdanm 0:eff01767de02 36 SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */
bogdanm 0:eff01767de02 37 SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */
bogdanm 0:eff01767de02 38 SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */
bogdanm 0:eff01767de02 39 SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */
bogdanm 0:eff01767de02 40 SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */
bogdanm 0:eff01767de02 41 SD_BLE_GATTS_SYS_ATTR_GET, /**< Get updated persistent system attributes after terminating a connection. */
bogdanm 0:eff01767de02 42 };
bogdanm 0:eff01767de02 43
bogdanm 0:eff01767de02 44
bogdanm 0:eff01767de02 45 /** @addtogroup BLE_GATTS_DEFINES Defines
bogdanm 0:eff01767de02 46 * @{ */
bogdanm 0:eff01767de02 47
bogdanm 0:eff01767de02 48 /** @brief Only the default MTU size of 23 is currently supported. */
bogdanm 0:eff01767de02 49 #define GATT_RX_MTU 23
bogdanm 0:eff01767de02 50
bogdanm 0:eff01767de02 51 /** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS
bogdanm 0:eff01767de02 52 * @{ */
bogdanm 0:eff01767de02 53 #define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */
bogdanm 0:eff01767de02 54 #define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */
bogdanm 0:eff01767de02 55 /** @} */
bogdanm 0:eff01767de02 56
bogdanm 0:eff01767de02 57 /** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths
bogdanm 0:eff01767de02 58 * @{ */
bogdanm 0:eff01767de02 59 #define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */
bogdanm 0:eff01767de02 60 #define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */
bogdanm 0:eff01767de02 61 /** @} */
bogdanm 0:eff01767de02 62
bogdanm 0:eff01767de02 63 /** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types
bogdanm 0:eff01767de02 64 * @{ */
bogdanm 0:eff01767de02 65 #define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */
bogdanm 0:eff01767de02 66 #define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */
bogdanm 0:eff01767de02 67 #define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */
bogdanm 0:eff01767de02 68 /** @} */
bogdanm 0:eff01767de02 69
bogdanm 0:eff01767de02 70
bogdanm 0:eff01767de02 71 /** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types
bogdanm 0:eff01767de02 72 * @{ */
bogdanm 0:eff01767de02 73 #define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */
bogdanm 0:eff01767de02 74 #define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */
bogdanm 0:eff01767de02 75 #define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */
bogdanm 0:eff01767de02 76 #define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */
bogdanm 0:eff01767de02 77 #define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */
bogdanm 0:eff01767de02 78 #define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */
bogdanm 0:eff01767de02 79 #define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */
bogdanm 0:eff01767de02 80 #define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */
bogdanm 0:eff01767de02 81 /** @} */
bogdanm 0:eff01767de02 82
bogdanm 0:eff01767de02 83
bogdanm 0:eff01767de02 84 /** @defgroup BLE_GATTS_OPS GATT Server Operations
bogdanm 0:eff01767de02 85 * @{ */
bogdanm 0:eff01767de02 86 #define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */
bogdanm 0:eff01767de02 87 #define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */
bogdanm 0:eff01767de02 88 #define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */
bogdanm 0:eff01767de02 89 #define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
bogdanm 0:eff01767de02 90 #define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
bogdanm 0:eff01767de02 91 #define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */
bogdanm 0:eff01767de02 92 #define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */
bogdanm 0:eff01767de02 93 /** @} */
bogdanm 0:eff01767de02 94
bogdanm 0:eff01767de02 95 /** @defgroup BLE_GATTS_VLOCS GATT Value Locations
bogdanm 0:eff01767de02 96 * @{ */
bogdanm 0:eff01767de02 97 #define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */
bogdanm 0:eff01767de02 98 #define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */
bogdanm 0:eff01767de02 99 #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
bogdanm 0:eff01767de02 100 will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */
bogdanm 0:eff01767de02 101 /** @} */
bogdanm 0:eff01767de02 102
bogdanm 0:eff01767de02 103 /** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types
bogdanm 0:eff01767de02 104 * @{ */
bogdanm 0:eff01767de02 105 #define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */
bogdanm 0:eff01767de02 106 #define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */
bogdanm 0:eff01767de02 107 #define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */
bogdanm 0:eff01767de02 108 /** @} */
bogdanm 0:eff01767de02 109
bogdanm 0:eff01767de02 110
bogdanm 0:eff01767de02 111 /** @} */
bogdanm 0:eff01767de02 112
bogdanm 0:eff01767de02 113 /**@brief Attribute metadata. */
bogdanm 0:eff01767de02 114 typedef struct
bogdanm 0:eff01767de02 115 {
bogdanm 0:eff01767de02 116 ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */
bogdanm 0:eff01767de02 117 ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
bogdanm 0:eff01767de02 118 uint8_t vlen :1; /**< Variable length attribute. */
bogdanm 0:eff01767de02 119 uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/
bogdanm 0:eff01767de02 120 uint8_t rd_auth :1; /**< Read Authorization and value will be requested from the application on every read operation. */
bogdanm 0:eff01767de02 121 uint8_t wr_auth :1; /**< Write Authorization will be requested from the application on every Write Request operation (but not Write Command). */
bogdanm 0:eff01767de02 122 } ble_gatts_attr_md_t;
bogdanm 0:eff01767de02 123
bogdanm 0:eff01767de02 124
bogdanm 0:eff01767de02 125 /**@brief GATT Attribute. */
bogdanm 0:eff01767de02 126 typedef struct
bogdanm 0:eff01767de02 127 {
bogdanm 0:eff01767de02 128 ble_uuid_t* p_uuid; /**< Pointer to the attribute UUID. */
bogdanm 0:eff01767de02 129 ble_gatts_attr_md_t* p_attr_md; /**< Pointer to the attribute metadata structure. */
bogdanm 0:eff01767de02 130 uint16_t init_len; /**< Initial attribute value length in bytes. */
bogdanm 0:eff01767de02 131 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. */
bogdanm 0:eff01767de02 132 uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */
bogdanm 0:eff01767de02 133 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
bogdanm 0:eff01767de02 134 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.
bogdanm 0:eff01767de02 135 The stack may access that memory directly without the application's knowledge. */
bogdanm 0:eff01767de02 136 } ble_gatts_attr_t;
bogdanm 0:eff01767de02 137
bogdanm 0:eff01767de02 138
bogdanm 0:eff01767de02 139 /**@brief GATT Attribute Context. */
bogdanm 0:eff01767de02 140 typedef struct
bogdanm 0:eff01767de02 141 {
bogdanm 0:eff01767de02 142 ble_uuid_t srvc_uuid; /**< Service UUID. */
bogdanm 0:eff01767de02 143 ble_uuid_t char_uuid; /**< Characteristic UUID if applicable (BLE_UUID_TYPE_UNKNOWN if N/A). */
bogdanm 0:eff01767de02 144 ble_uuid_t desc_uuid; /**< Descriptor UUID if applicable (BLE_UUID_TYPE_UNKNOWN if N/A). */
bogdanm 0:eff01767de02 145 uint16_t srvc_handle; /**< Service Handle. */
bogdanm 0:eff01767de02 146 uint16_t value_handle; /**< Characteristic Handle if applicable (BLE_GATT_HANDLE_INVALID if N/A). */
bogdanm 0:eff01767de02 147 uint8_t type; /**< Attribute Type, see @ref BLE_GATTS_ATTR_TYPES. */
bogdanm 0:eff01767de02 148 } ble_gatts_attr_context_t;
bogdanm 0:eff01767de02 149
bogdanm 0:eff01767de02 150
bogdanm 0:eff01767de02 151 /**@brief GATT Characteristic Presentation Format. */
bogdanm 0:eff01767de02 152 typedef struct
bogdanm 0:eff01767de02 153 {
bogdanm 0:eff01767de02 154 uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */
bogdanm 0:eff01767de02 155 int8_t exponent; /**< Exponent for integer data types. */
bogdanm 0:eff01767de02 156 uint16_t unit; /**< UUID from Bluetooth Assigned Numbers. */
bogdanm 0:eff01767de02 157 uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
bogdanm 0:eff01767de02 158 uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
bogdanm 0:eff01767de02 159 } ble_gatts_char_pf_t;
bogdanm 0:eff01767de02 160
bogdanm 0:eff01767de02 161
bogdanm 0:eff01767de02 162 /**@brief GATT Characteristic metadata. */
bogdanm 0:eff01767de02 163 typedef struct
bogdanm 0:eff01767de02 164 {
bogdanm 0:eff01767de02 165 ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
bogdanm 0:eff01767de02 166 ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */
bogdanm 0:eff01767de02 167 uint8_t* p_char_user_desc; /**< Pointer to a UTF-8, NULL if the descriptor is not required. */
bogdanm 0:eff01767de02 168 uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */
bogdanm 0:eff01767de02 169 uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */
bogdanm 0:eff01767de02 170 ble_gatts_char_pf_t* p_char_pf; /**< Pointer to a presentation format structure or NULL if the descriptor is not required. */
bogdanm 0:eff01767de02 171 ble_gatts_attr_md_t* p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */
bogdanm 0:eff01767de02 172 ble_gatts_attr_md_t* p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */
bogdanm 0:eff01767de02 173 ble_gatts_attr_md_t* p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */
bogdanm 0:eff01767de02 174 } ble_gatts_char_md_t;
bogdanm 0:eff01767de02 175
bogdanm 0:eff01767de02 176
bogdanm 0:eff01767de02 177 /**@brief GATT Characteristic Definition Handles. */
bogdanm 0:eff01767de02 178 typedef struct
bogdanm 0:eff01767de02 179 {
bogdanm 0:eff01767de02 180 uint16_t value_handle; /**< Handle to the characteristic value. */
bogdanm 0:eff01767de02 181 uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or BLE_GATT_HANDLE_INVALID if not present. */
bogdanm 0:eff01767de02 182 uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or BLE_GATT_HANDLE_INVALID if not present. */
bogdanm 0:eff01767de02 183 uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or BLE_GATT_HANDLE_INVALID if not present. */
bogdanm 0:eff01767de02 184 } ble_gatts_char_handles_t;
bogdanm 0:eff01767de02 185
bogdanm 0:eff01767de02 186
bogdanm 0:eff01767de02 187 /**@brief GATT HVx parameters. */
bogdanm 0:eff01767de02 188 typedef struct
bogdanm 0:eff01767de02 189 {
bogdanm 0:eff01767de02 190 uint16_t handle; /**< Characteristic Value Handle. */
bogdanm 0:eff01767de02 191 uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
bogdanm 0:eff01767de02 192 uint16_t offset; /**< Offset within the attribute value. */
bogdanm 0:eff01767de02 193 uint16_t* p_len; /**< Length in bytes to be written, length in bytes written after successful return. */
bogdanm 0:eff01767de02 194 uint8_t* p_data; /**< Actual data content, use NULL to use the current attribute value. */
bogdanm 0:eff01767de02 195 } ble_gatts_hvx_params_t;
bogdanm 0:eff01767de02 196
bogdanm 0:eff01767de02 197 /**@brief GATT Read Authorization parameters. */
bogdanm 0:eff01767de02 198 typedef struct
bogdanm 0:eff01767de02 199 {
bogdanm 0:eff01767de02 200 uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
bogdanm 0:eff01767de02 201 uint8_t update : 1; /**< If set, data supplied in p_data will be used in the ATT response. */
bogdanm 0:eff01767de02 202 uint16_t offset; /**< Offset of the attribute value being updated. */
bogdanm 0:eff01767de02 203 uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */
bogdanm 0:eff01767de02 204 uint8_t* p_data; /**< Pointer to new value used to update the attribute value. */
bogdanm 0:eff01767de02 205 } ble_gatts_read_authorize_params_t;
bogdanm 0:eff01767de02 206
bogdanm 0:eff01767de02 207 /**@brief GATT Write Authorisation parameters. */
bogdanm 0:eff01767de02 208 typedef struct
bogdanm 0:eff01767de02 209 {
bogdanm 0:eff01767de02 210 uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
bogdanm 0:eff01767de02 211 } ble_gatts_write_authorize_params_t;
bogdanm 0:eff01767de02 212
bogdanm 0:eff01767de02 213 /**@brief GATT Read or Write Authorize Reply parameters. */
bogdanm 0:eff01767de02 214 typedef struct
bogdanm 0:eff01767de02 215 {
bogdanm 0:eff01767de02 216 uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
bogdanm 0:eff01767de02 217 union {
bogdanm 0:eff01767de02 218 ble_gatts_read_authorize_params_t read; /**< Read authorization parameters. */
bogdanm 0:eff01767de02 219 ble_gatts_write_authorize_params_t write; /**< Write authorization parameters. */
bogdanm 0:eff01767de02 220 } params;
bogdanm 0:eff01767de02 221 } ble_gatts_rw_authorize_reply_params_t;
bogdanm 0:eff01767de02 222
bogdanm 0:eff01767de02 223
bogdanm 0:eff01767de02 224 /**
bogdanm 0:eff01767de02 225 * @brief GATT Server Event IDs.
bogdanm 0:eff01767de02 226 */
bogdanm 0:eff01767de02 227 enum BLE_GATTS_EVTS
bogdanm 0:eff01767de02 228 {
bogdanm 0:eff01767de02 229 BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. */
bogdanm 0:eff01767de02 230 BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. */
bogdanm 0:eff01767de02 231 BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending, awaiting a sd_ble_gatts_sys_attr_set(). */
bogdanm 0:eff01767de02 232 BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. */
bogdanm 0:eff01767de02 233 BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. */
bogdanm 0:eff01767de02 234 BLE_GATTS_EVT_TIMEOUT /**< Timeout. */
bogdanm 0:eff01767de02 235 };
bogdanm 0:eff01767de02 236
bogdanm 0:eff01767de02 237
bogdanm 0:eff01767de02 238 /**@brief Event structure for BLE_GATTS_EVT_WRITE. */
bogdanm 0:eff01767de02 239 typedef struct
bogdanm 0:eff01767de02 240 {
bogdanm 0:eff01767de02 241 uint16_t handle; /**< Attribute Handle. */
bogdanm 0:eff01767de02 242 uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */
bogdanm 0:eff01767de02 243 ble_gatts_attr_context_t context; /**< Attribute Context. */
bogdanm 0:eff01767de02 244 uint16_t offset; /**< Offset for the write operation. */
bogdanm 0:eff01767de02 245 uint16_t len; /**< Length of the incoming data. */
bogdanm 0:eff01767de02 246 uint8_t data[1]; /**< Incoming data, variable length. */
bogdanm 0:eff01767de02 247 } ble_gatts_evt_write_t;
bogdanm 0:eff01767de02 248
bogdanm 0:eff01767de02 249 /**@brief Event structure for authorize read request. */
bogdanm 0:eff01767de02 250 typedef struct
bogdanm 0:eff01767de02 251 {
bogdanm 0:eff01767de02 252 uint16_t handle; /**< Attribute Handle. */
bogdanm 0:eff01767de02 253 ble_gatts_attr_context_t context; /**< Attribute Context. */
bogdanm 0:eff01767de02 254 uint16_t offset; /**< Offset for the read operation. */
bogdanm 0:eff01767de02 255 } ble_gatts_evt_read_t;
bogdanm 0:eff01767de02 256
bogdanm 0:eff01767de02 257 /**@brief Event structure for BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */
bogdanm 0:eff01767de02 258 typedef struct
bogdanm 0:eff01767de02 259 {
bogdanm 0:eff01767de02 260 uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
bogdanm 0:eff01767de02 261 union {
bogdanm 0:eff01767de02 262 ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */
bogdanm 0:eff01767de02 263 ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */
bogdanm 0:eff01767de02 264 } request;
bogdanm 0:eff01767de02 265 } ble_gatts_evt_rw_authorize_request_t;
bogdanm 0:eff01767de02 266
bogdanm 0:eff01767de02 267 /**@brief Event structure for BLE_GATTS_EVT_SYS_ATTR_MISSING. */
bogdanm 0:eff01767de02 268 typedef struct
bogdanm 0:eff01767de02 269 {
bogdanm 0:eff01767de02 270 uint8_t hint;
bogdanm 0:eff01767de02 271 } ble_gatts_evt_sys_attr_missing_t;
bogdanm 0:eff01767de02 272
bogdanm 0:eff01767de02 273
bogdanm 0:eff01767de02 274 /**@brief Event structure for BLE_GATTS_EVT_HVC. */
bogdanm 0:eff01767de02 275 typedef struct
bogdanm 0:eff01767de02 276 {
bogdanm 0:eff01767de02 277 uint16_t handle; /**< Attribute Handle. */
bogdanm 0:eff01767de02 278 } ble_gatts_evt_hvc_t;
bogdanm 0:eff01767de02 279
bogdanm 0:eff01767de02 280 /**@brief Event structure for BLE_GATTS_EVT_TIMEOUT. */
bogdanm 0:eff01767de02 281 typedef struct
bogdanm 0:eff01767de02 282 {
bogdanm 0:eff01767de02 283 uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
bogdanm 0:eff01767de02 284 } ble_gatts_evt_timeout_t;
bogdanm 0:eff01767de02 285
bogdanm 0:eff01767de02 286
bogdanm 0:eff01767de02 287 /**@brief GATT Server event callback event structure. */
bogdanm 0:eff01767de02 288 typedef struct
bogdanm 0:eff01767de02 289 {
bogdanm 0:eff01767de02 290 uint16_t conn_handle; /**< Connection Handle on which event occurred. */
bogdanm 0:eff01767de02 291 union
bogdanm 0:eff01767de02 292 {
bogdanm 0:eff01767de02 293 ble_gatts_evt_write_t write; /**< Write Event Parameters. */
bogdanm 0:eff01767de02 294 ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */
bogdanm 0:eff01767de02 295 ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */
bogdanm 0:eff01767de02 296 ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */
bogdanm 0:eff01767de02 297 ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */
bogdanm 0:eff01767de02 298 } params;
bogdanm 0:eff01767de02 299 } ble_gatts_evt_t;
bogdanm 0:eff01767de02 300
bogdanm 0:eff01767de02 301
bogdanm 0:eff01767de02 302 /**@brief Add a service declaration to the local server ATT table.
bogdanm 0:eff01767de02 303 *
bogdanm 0:eff01767de02 304 * @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES.
bogdanm 0:eff01767de02 305 * @param[in] p_uuid Pointer to service UUID.
bogdanm 0:eff01767de02 306 * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
bogdanm 0:eff01767de02 307 *
bogdanm 0:eff01767de02 308 * @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to
bogdanm 0:eff01767de02 309 * add a secondary service declaration that is not referenced by another service later in the ATT table.
bogdanm 0:eff01767de02 310 *
bogdanm 0:eff01767de02 311 * @return @ref NRF_SUCCESS Successfully added a service declaration.
bogdanm 0:eff01767de02 312 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 0:eff01767de02 313 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table.
bogdanm 0:eff01767de02 314 * @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
bogdanm 0:eff01767de02 315 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
bogdanm 0:eff01767de02 316 */
bogdanm 0:eff01767de02 317 SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const*const p_uuid, uint16_t *const p_handle));
bogdanm 0:eff01767de02 318
bogdanm 0:eff01767de02 319
bogdanm 0:eff01767de02 320 /**@brief Add an include declaration to the local server ATT table.
bogdanm 0:eff01767de02 321 *
bogdanm 0:eff01767de02 322 * @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential addition is supported at this time).
bogdanm 0:eff01767de02 323 *
bogdanm 0:eff01767de02 324 * @note The included service must already be present in the ATT table prior to this call.
bogdanm 0:eff01767de02 325 *
bogdanm 0:eff01767de02 326 * @param[in] service_handle Handle of the service where the included service is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
bogdanm 0:eff01767de02 327 * @param[in] inc_srvc_handle Handle of the included service.
bogdanm 0:eff01767de02 328 * @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored.
bogdanm 0:eff01767de02 329 *
bogdanm 0:eff01767de02 330 * @return @ref NRF_SUCCESS Successfully added an include declaration.
bogdanm 0:eff01767de02 331 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 0:eff01767de02 332 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services.
bogdanm 0:eff01767de02 333 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
bogdanm 0:eff01767de02 334 * @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed.
bogdanm 0:eff01767de02 335 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
bogdanm 0:eff01767de02 336 * @return @ref NRF_ERROR_NOT_FOUND Attribute not found.
bogdanm 0:eff01767de02 337 */
bogdanm 0:eff01767de02 338 SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *const p_include_handle));
bogdanm 0:eff01767de02 339
bogdanm 0:eff01767de02 340
bogdanm 0:eff01767de02 341 /**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the local server ATT table.
bogdanm 0:eff01767de02 342 *
bogdanm 0:eff01767de02 343 * @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential addition is supported at this time).
bogdanm 0:eff01767de02 344 *
bogdanm 0:eff01767de02 345 * @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writeable auxiliaries bits,
bogdanm 0:eff01767de02 346 * readable (no security) and writeable (selectable) CCCDs and SCCDs and valid presentation format values.
bogdanm 0:eff01767de02 347 *
bogdanm 0:eff01767de02 348 * @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions.
bogdanm 0:eff01767de02 349 *
bogdanm 0:eff01767de02 350 * @param[in] service_handle Handle of the service where the characteristic is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
bogdanm 0:eff01767de02 351 * @param[in] p_char_md Characteristic metadata.
bogdanm 0:eff01767de02 352 * @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value.
bogdanm 0:eff01767de02 353 * @param[out] p_handles Pointer to the structure where the assigned handles will be stored.
bogdanm 0:eff01767de02 354 *
bogdanm 0:eff01767de02 355 * @return @ref NRF_SUCCESS Successfully added a characteristic.
bogdanm 0:eff01767de02 356 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 0:eff01767de02 357 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
bogdanm 0:eff01767de02 358 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required.
bogdanm 0:eff01767de02 359 * @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
bogdanm 0:eff01767de02 360 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
bogdanm 0:eff01767de02 361 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
bogdanm 0:eff01767de02 362 */
bogdanm 0:eff01767de02 363 SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const*const p_char_md, ble_gatts_attr_t const*const p_attr_char_value, ble_gatts_char_handles_t *const p_handles));
bogdanm 0:eff01767de02 364
bogdanm 0:eff01767de02 365
bogdanm 0:eff01767de02 366 /**@brief Add a descriptor to the local server ATT table.
bogdanm 0:eff01767de02 367 *
bogdanm 0:eff01767de02 368 * @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential addition is supported at this time).
bogdanm 0:eff01767de02 369 *
bogdanm 0:eff01767de02 370 * @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
bogdanm 0:eff01767de02 371 * @param[in] p_attr Pointer to the attribute structure.
bogdanm 0:eff01767de02 372 * @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
bogdanm 0:eff01767de02 373 *
bogdanm 0:eff01767de02 374 * @return @ref NRF_SUCCESS Successfully added a descriptor.
bogdanm 0:eff01767de02 375 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 0:eff01767de02 376 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
bogdanm 0:eff01767de02 377 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required.
bogdanm 0:eff01767de02 378 * @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
bogdanm 0:eff01767de02 379 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
bogdanm 0:eff01767de02 380 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
bogdanm 0:eff01767de02 381 */
bogdanm 0:eff01767de02 382 SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const * const p_attr, uint16_t* const p_handle));
bogdanm 0:eff01767de02 383
bogdanm 0:eff01767de02 384 /**@brief Set the value of a given attribute.
bogdanm 0:eff01767de02 385 *
bogdanm 0:eff01767de02 386 * @param[in] handle Attribute handle.
bogdanm 0:eff01767de02 387 * @param[in] offset Offset in bytes to write from.
bogdanm 0:eff01767de02 388 * @param[in,out] p_len Length in bytes to be written, length in bytes written after successful return.
bogdanm 0:eff01767de02 389 * @param[in] p_value Pointer to a buffer (at least len bytes long) containing the desired attribute value.
bogdanm 0:eff01767de02 390 *
bogdanm 0:eff01767de02 391 * @return @ref NRF_SUCCESS Successfully set the value of the attribute.
bogdanm 0:eff01767de02 392 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 0:eff01767de02 393 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
bogdanm 0:eff01767de02 394 * @return @ref NRF_ERROR_NOT_FOUND Attribute not found.
bogdanm 0:eff01767de02 395 * @return @ref NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application.
bogdanm 0:eff01767de02 396 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
bogdanm 0:eff01767de02 397 */
bogdanm 0:eff01767de02 398 SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t handle, uint16_t offset, uint16_t* const p_len, uint8_t const * const p_value));
bogdanm 0:eff01767de02 399
bogdanm 0:eff01767de02 400 /**@brief Get the value of a given attribute.
bogdanm 0:eff01767de02 401 *
bogdanm 0:eff01767de02 402 * @param[in] handle Attribute handle.
bogdanm 0:eff01767de02 403 * @param[in] offset Offset in bytes to read from.
bogdanm 0:eff01767de02 404 * @param[in,out] p_len Length in bytes to be read, total length of attribute value (in bytes, starting from offset) after successful return.
bogdanm 0:eff01767de02 405 * @param[in,out] p_data Pointer to a buffer (at least len bytes long) where to store the attribute value. Set to NULL to obtain the complete length of attribute value.
bogdanm 0:eff01767de02 406 *
bogdanm 0:eff01767de02 407 * @note If the attribute value is longer than the size of the supplied buffer,
bogdanm 0:eff01767de02 408 * p_len will return the total attribute value length (excluding offset),
bogdanm 0:eff01767de02 409 * and not the number of bytes actually returned in p_data.
bogdanm 0:eff01767de02 410 * The application may use this information to allocate a suitable buffer size.
bogdanm 0:eff01767de02 411 *
bogdanm 0:eff01767de02 412 * @return @ref NRF_SUCCESS Successfully retrieved the value of the attribute.
bogdanm 0:eff01767de02 413 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 0:eff01767de02 414 * @return @ref NRF_ERROR_NOT_FOUND Attribute not found.
bogdanm 0:eff01767de02 415 */
bogdanm 0:eff01767de02 416 SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t handle, uint16_t offset, uint16_t *const p_len, uint8_t* const p_data));
bogdanm 0:eff01767de02 417
bogdanm 0:eff01767de02 418 /**@brief Notify or Indicate an attribute value.
bogdanm 0:eff01767de02 419 *
bogdanm 0:eff01767de02 420 * @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation
bogdanm 0:eff01767de02 421 * (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that
bogdanm 0:eff01767de02 422 * the application can atomically perform a value update and a server initiated transaction with a single API call.
bogdanm 0:eff01767de02 423 * If the application chooses to indicate an attribute value, a @ref BLE_GATTS_EVT_HVC will be sent up as soon as the confirmation arrives from
bogdanm 0:eff01767de02 424 * the peer.
bogdanm 0:eff01767de02 425 *
bogdanm 0:eff01767de02 426 * @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.
bogdanm 0:eff01767de02 427 * When receiveing the error codes @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and
bogdanm 0:eff01767de02 428 * @ref BLE_ERROR_NO_TX_BUFFERS the ATT table has been updated.
bogdanm 0:eff01767de02 429 * The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len).
bogdanm 0:eff01767de02 430 *
bogdanm 0:eff01767de02 431 * @note It is important to note that a notification will <b>consume an application buffer</b>, and will therefore
bogdanm 0:eff01767de02 432 * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. An indication on the other hand will use the
bogdanm 0:eff01767de02 433 * standard server internal buffer and thus will only generate a @ref BLE_GATTS_EVT_HVC event as soon as the confirmation
bogdanm 0:eff01767de02 434 * has been received from the peer. Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details.
bogdanm 0:eff01767de02 435 *
bogdanm 0:eff01767de02 436 * @param[in] conn_handle Connection handle.
bogdanm 0:eff01767de02 437 * @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
bogdanm 0:eff01767de02 438 * the contents pointed by it before sending the notification or indication.
bogdanm 0:eff01767de02 439 *
bogdanm 0:eff01767de02 440 * @return @ref NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value.
bogdanm 0:eff01767de02 441 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
bogdanm 0:eff01767de02 442 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 0:eff01767de02 443 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
bogdanm 0:eff01767de02 444 * @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate.
bogdanm 0:eff01767de02 445 * @return @ref BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated.
bogdanm 0:eff01767de02 446 * @return @ref NRF_ERROR_NOT_FOUND Attribute not found.
bogdanm 0:eff01767de02 447 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
bogdanm 0:eff01767de02 448 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, notifications or indications must be enabled in the CCCD.
bogdanm 0:eff01767de02 449 * @return @ref NRF_ERROR_BUSY Procedure already in progress.
bogdanm 0:eff01767de02 450 * @return @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
bogdanm 0:eff01767de02 451 * @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers to send the data, applies only to notifications.
bogdanm 0:eff01767de02 452 */
bogdanm 0:eff01767de02 453 SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const*const p_hvx_params));
bogdanm 0:eff01767de02 454
bogdanm 0:eff01767de02 455 /**@brief Indicate the Service Changed attribute value.
bogdanm 0:eff01767de02 456 *
bogdanm 0:eff01767de02 457 * @details This call will send a Handle Value Indication to one or more peers connected to inform them that the attribute
bogdanm 0:eff01767de02 458 * table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will
bogdanm 0:eff01767de02 459 * be issued.
bogdanm 0:eff01767de02 460 *
bogdanm 0:eff01767de02 461 * @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here.
bogdanm 0:eff01767de02 462 *
bogdanm 0:eff01767de02 463 * @param[in] conn_handle Connection handle.
bogdanm 0:eff01767de02 464 * @param[in] start_handle Start of affected attribute handle range.
bogdanm 0:eff01767de02 465 * @param[in] end_handle End of affected attribute handle range.
bogdanm 0:eff01767de02 466 *
bogdanm 0:eff01767de02 467 * @return @ref NRF_SUCCESS Successfully queued the Service Changed indication for transmission.
bogdanm 0:eff01767de02 468 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
bogdanm 0:eff01767de02 469 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
bogdanm 0:eff01767de02 470 * @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application.
bogdanm 0:eff01767de02 471 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, notifications or indications must be enabled in the CCCD.
bogdanm 0:eff01767de02 472 * @return @ref NRF_ERROR_BUSY Procedure already in progress.
bogdanm 0:eff01767de02 473 * @return @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
bogdanm 0:eff01767de02 474 */
bogdanm 0:eff01767de02 475 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));
bogdanm 0:eff01767de02 476
bogdanm 0:eff01767de02 477 /**@brief Respond to a Read/Write authorization request.
bogdanm 0:eff01767de02 478 *
bogdanm 0:eff01767de02 479 * @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application.
bogdanm 0:eff01767de02 480 *
bogdanm 0:eff01767de02 481 * @param[in] conn_handle Connection handle.
bogdanm 0:eff01767de02 482 * @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application.
bogdanm 0:eff01767de02 483 *
bogdanm 0:eff01767de02 484 * @return @ref NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, ATT table updated.
bogdanm 0:eff01767de02 485 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
bogdanm 0:eff01767de02 486 * @return @ref NRF_ERROR_INVALID_STATE No authorization request pending.
bogdanm 0:eff01767de02 487 * @return @ref NRF_ERROR_INVALID_PARAM Authorization op invalid,
bogdanm 0:eff01767de02 488 * or for Read Authorization reply: requested handles not replied with,
bogdanm 0:eff01767de02 489 * or for Write Authorization reply: handle supplied does not match requested handle.
bogdanm 0:eff01767de02 490 */
bogdanm 0:eff01767de02 491 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*const p_rw_authorize_reply_params));
bogdanm 0:eff01767de02 492
bogdanm 0:eff01767de02 493
bogdanm 0:eff01767de02 494 /**@brief Update persistent system attribute information.
bogdanm 0:eff01767de02 495 *
bogdanm 0:eff01767de02 496 * @details Supply to the stack information about persistent system attributes.
bogdanm 0:eff01767de02 497 * This call is legal in the connected state only, and is usually
bogdanm 0:eff01767de02 498 * made immediately after a connection is established and the bond identified.
bogdanm 0:eff01767de02 499 * usually as a response to a BLE_GATTS_EVT_SYS_ATTR_MISSING.
bogdanm 0:eff01767de02 500 *
bogdanm 0:eff01767de02 501 * p_sysattrs may point directly to the application's stored copy of the struct.
bogdanm 0:eff01767de02 502 * If the pointer is NULL, the system attribute info is initialized, assuming that
bogdanm 0:eff01767de02 503 * the application does not have any previously saved data for this bond.
bogdanm 0:eff01767de02 504 *
bogdanm 0:eff01767de02 505 * @note The state of persistent system attributes is reset upon connection and then remembered for its duration.
bogdanm 0:eff01767de02 506 *
bogdanm 0:eff01767de02 507 * @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.
bogdanm 0:eff01767de02 508 * 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
bogdanm 0:eff01767de02 509 * reset the SoftDevice to return to a known state.
bogdanm 0:eff01767de02 510 *
bogdanm 0:eff01767de02 511 * @param[in] conn_handle Connection handle.
bogdanm 0:eff01767de02 512 * @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL.
bogdanm 0:eff01767de02 513 * @param[in] len Size of data pointed by p_sys_attr_data, in octets.
bogdanm 0:eff01767de02 514 *
bogdanm 0:eff01767de02 515 * @return @ref NRF_SUCCESS Successfully set the system attribute information.
bogdanm 0:eff01767de02 516 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
bogdanm 0:eff01767de02 517 * @return @ref NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get.
bogdanm 0:eff01767de02 518 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
bogdanm 0:eff01767de02 519 */
bogdanm 0:eff01767de02 520 SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const*const p_sys_attr_data, uint16_t len));
bogdanm 0:eff01767de02 521
bogdanm 0:eff01767de02 522
bogdanm 0:eff01767de02 523 /**@brief Retrieve persistent system attribute information from the stack.
bogdanm 0:eff01767de02 524 *
bogdanm 0:eff01767de02 525 * @details This call is used to retrieve information about values to be stored perisistently by the application
bogdanm 0:eff01767de02 526 * after a connection has been terminated. When a new connection is made to the same bond, the values
bogdanm 0:eff01767de02 527 * should be restored using @ref sd_ble_gatts_sys_attr_set.
bogdanm 0:eff01767de02 528 * The data should be read before any new advertising is started, or any new connection established. The connection handle for
bogdanm 0:eff01767de02 529 * the previous now defunct connection will remain valid until a new one is created to allow this API call to refer to it.
bogdanm 0:eff01767de02 530 *
bogdanm 0:eff01767de02 531 * @param[in] conn_handle Connection handle of the recently terminated connection.
bogdanm 0:eff01767de02 532 * @param[in] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. NULL can be provided to
bogdanm 0:eff01767de02 533 * obtain the length of the data
bogdanm 0:eff01767de02 534 * @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.
bogdanm 0:eff01767de02 535 *
bogdanm 0:eff01767de02 536 * @return @ref NRF_SUCCESS Successfully retrieved the system attribute information.
bogdanm 0:eff01767de02 537 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
bogdanm 0:eff01767de02 538 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
bogdanm 0:eff01767de02 539 * @return @ref NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer.
bogdanm 0:eff01767de02 540 */
bogdanm 0:eff01767de02 541 SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t * const p_sys_attr_data, uint16_t* const p_len));
bogdanm 0:eff01767de02 542
bogdanm 0:eff01767de02 543
bogdanm 0:eff01767de02 544 #endif // BLE_GATTS_H__
bogdanm 0:eff01767de02 545
bogdanm 0:eff01767de02 546 /**
bogdanm 0:eff01767de02 547 @}
bogdanm 0:eff01767de02 548 */