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