mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Mon Apr 07 18:28:36 2014 +0100
Revision:
82:6473597d706e
Release 82 of the mbed library

Main changes:

- support for K64F
- Revisited Nordic code structure
- Test infrastructure improvements
- various bug fixes

Who changed what in which revision?

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