Yoshihiro TSUBOI / BLE_API_Native_IRC

Dependents:   BLE_Health_Thermometer_IRC BLE_RCBController_micono_test BLE_konashi_PIO_test BLE_ADT7410_TMP102_Sample ... more

Fork of BLE_API_Native_blog by Donal Morrissey

Committer:
ktownsend
Date:
Thu Feb 06 11:51:06 2014 +0000
Revision:
0:4c3097c65247
Child:
4:2f1f20c755ed
Native mode drivers

Who changed what in which revision?

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