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