Microbug / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Committer:
finneyj
Date:
Fri May 15 12:12:21 2015 +0000
Revision:
177:7a1917171a20
Parent:
103:138bdc859cc9
Child:
112:737b08b3b995
bug fix - redefined symbol

Who changed what in which revision?

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