The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
emilmont
Date:
Fri Feb 21 12:21:39 2014 +0000
Revision:
80:8e73be2a2ac1
First alpha release for the NRF51822 target (to be tested in the online IDE)

Who changed what in which revision?

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