Nordic stack and drivers for the mbed BLE API

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate writable_gatt ... more

Committer:
Vincent Coubard
Date:
Wed Sep 14 14:39:43 2016 +0100
Revision:
638:c90ae1400bf2
Sync with bdab10dc0f90748b6989c8b577771bb403ca6bd8 from ARMmbed/mbed-os.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Vincent Coubard 638:c90ae1400bf2 1 /*
Vincent Coubard 638:c90ae1400bf2 2 * Copyright (c) Nordic Semiconductor ASA
Vincent Coubard 638:c90ae1400bf2 3 * All rights reserved.
Vincent Coubard 638:c90ae1400bf2 4 *
Vincent Coubard 638:c90ae1400bf2 5 * Redistribution and use in source and binary forms, with or without modification,
Vincent Coubard 638:c90ae1400bf2 6 * are permitted provided that the following conditions are met:
Vincent Coubard 638:c90ae1400bf2 7 *
Vincent Coubard 638:c90ae1400bf2 8 * 1. Redistributions of source code must retain the above copyright notice, this
Vincent Coubard 638:c90ae1400bf2 9 * list of conditions and the following disclaimer.
Vincent Coubard 638:c90ae1400bf2 10 *
Vincent Coubard 638:c90ae1400bf2 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this
Vincent Coubard 638:c90ae1400bf2 12 * list of conditions and the following disclaimer in the documentation and/or
Vincent Coubard 638:c90ae1400bf2 13 * other materials provided with the distribution.
Vincent Coubard 638:c90ae1400bf2 14 *
Vincent Coubard 638:c90ae1400bf2 15 * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
Vincent Coubard 638:c90ae1400bf2 16 * contributors to this software may be used to endorse or promote products
Vincent Coubard 638:c90ae1400bf2 17 * derived from this software without specific prior written permission.
Vincent Coubard 638:c90ae1400bf2 18 *
Vincent Coubard 638:c90ae1400bf2 19 *
Vincent Coubard 638:c90ae1400bf2 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Vincent Coubard 638:c90ae1400bf2 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Vincent Coubard 638:c90ae1400bf2 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Vincent Coubard 638:c90ae1400bf2 23 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Vincent Coubard 638:c90ae1400bf2 24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Vincent Coubard 638:c90ae1400bf2 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Vincent Coubard 638:c90ae1400bf2 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Vincent Coubard 638:c90ae1400bf2 27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Vincent Coubard 638:c90ae1400bf2 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Vincent Coubard 638:c90ae1400bf2 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Vincent Coubard 638:c90ae1400bf2 30 *
Vincent Coubard 638:c90ae1400bf2 31 */
Vincent Coubard 638:c90ae1400bf2 32
Vincent Coubard 638:c90ae1400bf2 33 /**
Vincent Coubard 638:c90ae1400bf2 34 @addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client
Vincent Coubard 638:c90ae1400bf2 35 @{
Vincent Coubard 638:c90ae1400bf2 36 @brief Definitions and prototypes for the GATT Client interface.
Vincent Coubard 638:c90ae1400bf2 37 */
Vincent Coubard 638:c90ae1400bf2 38
Vincent Coubard 638:c90ae1400bf2 39 #ifndef BLE_GATTC_H__
Vincent Coubard 638:c90ae1400bf2 40 #define BLE_GATTC_H__
Vincent Coubard 638:c90ae1400bf2 41
Vincent Coubard 638:c90ae1400bf2 42 #include "ble_gatt.h"
Vincent Coubard 638:c90ae1400bf2 43 #include "ble_types.h"
Vincent Coubard 638:c90ae1400bf2 44 #include "ble_ranges.h"
Vincent Coubard 638:c90ae1400bf2 45 #include "nrf_svc.h"
Vincent Coubard 638:c90ae1400bf2 46
Vincent Coubard 638:c90ae1400bf2 47 /** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations
Vincent Coubard 638:c90ae1400bf2 48 * @{ */
Vincent Coubard 638:c90ae1400bf2 49
Vincent Coubard 638:c90ae1400bf2 50 /**@brief GATTC API SVC numbers. */
Vincent Coubard 638:c90ae1400bf2 51 enum BLE_GATTC_SVCS
Vincent Coubard 638:c90ae1400bf2 52 {
Vincent Coubard 638:c90ae1400bf2 53 SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */
Vincent Coubard 638:c90ae1400bf2 54 SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */
Vincent Coubard 638:c90ae1400bf2 55 SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */
Vincent Coubard 638:c90ae1400bf2 56 SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */
Vincent Coubard 638:c90ae1400bf2 57 SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */
Vincent Coubard 638:c90ae1400bf2 58 SD_BLE_GATTC_READ, /**< Generic read. */
Vincent Coubard 638:c90ae1400bf2 59 SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */
Vincent Coubard 638:c90ae1400bf2 60 SD_BLE_GATTC_WRITE, /**< Generic write. */
Vincent Coubard 638:c90ae1400bf2 61 SD_BLE_GATTC_HV_CONFIRM /**< Handle Value Confirmation. */
Vincent Coubard 638:c90ae1400bf2 62 };
Vincent Coubard 638:c90ae1400bf2 63
Vincent Coubard 638:c90ae1400bf2 64 /**
Vincent Coubard 638:c90ae1400bf2 65 * @brief GATT Client Event IDs.
Vincent Coubard 638:c90ae1400bf2 66 */
Vincent Coubard 638:c90ae1400bf2 67 enum BLE_GATTC_EVTS
Vincent Coubard 638:c90ae1400bf2 68 {
Vincent Coubard 638:c90ae1400bf2 69 BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. @ref ble_gattc_evt_prim_srvc_disc_rsp_t */
Vincent Coubard 638:c90ae1400bf2 70 BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. @ref ble_gattc_evt_rel_disc_rsp_t */
Vincent Coubard 638:c90ae1400bf2 71 BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. @ref ble_gattc_evt_char_disc_rsp_t */
Vincent Coubard 638:c90ae1400bf2 72 BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. @ref ble_gattc_evt_desc_disc_rsp_t */
Vincent Coubard 638:c90ae1400bf2 73 BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t */
Vincent Coubard 638:c90ae1400bf2 74 BLE_GATTC_EVT_READ_RSP, /**< Read Response event. @ref ble_gattc_evt_read_rsp_t */
Vincent Coubard 638:c90ae1400bf2 75 BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. @ref ble_gattc_evt_char_vals_read_rsp_t */
Vincent Coubard 638:c90ae1400bf2 76 BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. @ref ble_gattc_evt_write_rsp_t */
Vincent Coubard 638:c90ae1400bf2 77 BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. @ref ble_gattc_evt_hvx_t */
Vincent Coubard 638:c90ae1400bf2 78 BLE_GATTC_EVT_TIMEOUT /**< Timeout event. @ref ble_gattc_evt_timeout_t */
Vincent Coubard 638:c90ae1400bf2 79 };
Vincent Coubard 638:c90ae1400bf2 80
Vincent Coubard 638:c90ae1400bf2 81 /** @} */
Vincent Coubard 638:c90ae1400bf2 82
Vincent Coubard 638:c90ae1400bf2 83 /** @addtogroup BLE_GATTC_DEFINES Defines
Vincent Coubard 638:c90ae1400bf2 84 * @{ */
Vincent Coubard 638:c90ae1400bf2 85
Vincent Coubard 638:c90ae1400bf2 86 /** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC
Vincent Coubard 638:c90ae1400bf2 87 * @{ */
Vincent Coubard 638:c90ae1400bf2 88 #define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000) /**< Procedure not Permitted. */
Vincent Coubard 638:c90ae1400bf2 89 /** @} */
Vincent Coubard 638:c90ae1400bf2 90
Vincent Coubard 638:c90ae1400bf2 91 /**@brief Last Attribute Handle. */
Vincent Coubard 638:c90ae1400bf2 92 #define BLE_GATTC_HANDLE_END 0xFFFF
Vincent Coubard 638:c90ae1400bf2 93
Vincent Coubard 638:c90ae1400bf2 94 /** @} */
Vincent Coubard 638:c90ae1400bf2 95
Vincent Coubard 638:c90ae1400bf2 96 /** @addtogroup BLE_GATTC_STRUCTURES Structures
Vincent Coubard 638:c90ae1400bf2 97 * @{ */
Vincent Coubard 638:c90ae1400bf2 98
Vincent Coubard 638:c90ae1400bf2 99 /**@brief Operation Handle Range. */
Vincent Coubard 638:c90ae1400bf2 100 typedef struct
Vincent Coubard 638:c90ae1400bf2 101 {
Vincent Coubard 638:c90ae1400bf2 102 uint16_t start_handle; /**< Start Handle. */
Vincent Coubard 638:c90ae1400bf2 103 uint16_t end_handle; /**< End Handle. */
Vincent Coubard 638:c90ae1400bf2 104 } ble_gattc_handle_range_t;
Vincent Coubard 638:c90ae1400bf2 105
Vincent Coubard 638:c90ae1400bf2 106
Vincent Coubard 638:c90ae1400bf2 107 /**@brief GATT service. */
Vincent Coubard 638:c90ae1400bf2 108 typedef struct
Vincent Coubard 638:c90ae1400bf2 109 {
Vincent Coubard 638:c90ae1400bf2 110 ble_uuid_t uuid; /**< Service UUID. */
Vincent Coubard 638:c90ae1400bf2 111 ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */
Vincent Coubard 638:c90ae1400bf2 112 } ble_gattc_service_t;
Vincent Coubard 638:c90ae1400bf2 113
Vincent Coubard 638:c90ae1400bf2 114
Vincent Coubard 638:c90ae1400bf2 115 /**@brief GATT include. */
Vincent Coubard 638:c90ae1400bf2 116 typedef struct
Vincent Coubard 638:c90ae1400bf2 117 {
Vincent Coubard 638:c90ae1400bf2 118 uint16_t handle; /**< Include Handle. */
Vincent Coubard 638:c90ae1400bf2 119 ble_gattc_service_t included_srvc; /**< Handle of the included service. */
Vincent Coubard 638:c90ae1400bf2 120 } ble_gattc_include_t;
Vincent Coubard 638:c90ae1400bf2 121
Vincent Coubard 638:c90ae1400bf2 122
Vincent Coubard 638:c90ae1400bf2 123 /**@brief GATT characteristic. */
Vincent Coubard 638:c90ae1400bf2 124 typedef struct
Vincent Coubard 638:c90ae1400bf2 125 {
Vincent Coubard 638:c90ae1400bf2 126 ble_uuid_t uuid; /**< Characteristic UUID. */
Vincent Coubard 638:c90ae1400bf2 127 ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
Vincent Coubard 638:c90ae1400bf2 128 uint8_t char_ext_props : 1; /**< Extended properties present. */
Vincent Coubard 638:c90ae1400bf2 129 uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */
Vincent Coubard 638:c90ae1400bf2 130 uint16_t handle_value; /**< Handle of the Characteristic Value. */
Vincent Coubard 638:c90ae1400bf2 131 } ble_gattc_char_t;
Vincent Coubard 638:c90ae1400bf2 132
Vincent Coubard 638:c90ae1400bf2 133
Vincent Coubard 638:c90ae1400bf2 134 /**@brief GATT descriptor. */
Vincent Coubard 638:c90ae1400bf2 135 typedef struct
Vincent Coubard 638:c90ae1400bf2 136 {
Vincent Coubard 638:c90ae1400bf2 137 uint16_t handle; /**< Descriptor Handle. */
Vincent Coubard 638:c90ae1400bf2 138 ble_uuid_t uuid; /**< Descriptor UUID. */
Vincent Coubard 638:c90ae1400bf2 139 } ble_gattc_desc_t;
Vincent Coubard 638:c90ae1400bf2 140
Vincent Coubard 638:c90ae1400bf2 141
Vincent Coubard 638:c90ae1400bf2 142 /**@brief Write Parameters. */
Vincent Coubard 638:c90ae1400bf2 143 typedef struct
Vincent Coubard 638:c90ae1400bf2 144 {
Vincent Coubard 638:c90ae1400bf2 145 uint8_t write_op; /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */
Vincent Coubard 638:c90ae1400bf2 146 uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */
Vincent Coubard 638:c90ae1400bf2 147 uint16_t handle; /**< Handle to the attribute to be written. */
Vincent Coubard 638:c90ae1400bf2 148 uint16_t offset; /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */
Vincent Coubard 638:c90ae1400bf2 149 uint16_t len; /**< Length of data in bytes. */
Vincent Coubard 638:c90ae1400bf2 150 uint8_t *p_value; /**< Pointer to the value data. */
Vincent Coubard 638:c90ae1400bf2 151 } ble_gattc_write_params_t;
Vincent Coubard 638:c90ae1400bf2 152
Vincent Coubard 638:c90ae1400bf2 153 /**@brief Event structure for @ref BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */
Vincent Coubard 638:c90ae1400bf2 154 typedef struct
Vincent Coubard 638:c90ae1400bf2 155 {
Vincent Coubard 638:c90ae1400bf2 156 uint16_t count; /**< Service count. */
Vincent Coubard 638:c90ae1400bf2 157 ble_gattc_service_t services[1]; /**< Service data, variable length. */
Vincent Coubard 638:c90ae1400bf2 158 } ble_gattc_evt_prim_srvc_disc_rsp_t;
Vincent Coubard 638:c90ae1400bf2 159
Vincent Coubard 638:c90ae1400bf2 160 /**@brief Event structure for @ref BLE_GATTC_EVT_REL_DISC_RSP. */
Vincent Coubard 638:c90ae1400bf2 161 typedef struct
Vincent Coubard 638:c90ae1400bf2 162 {
Vincent Coubard 638:c90ae1400bf2 163 uint16_t count; /**< Include count. */
Vincent Coubard 638:c90ae1400bf2 164 ble_gattc_include_t includes[1]; /**< Include data, variable length. */
Vincent Coubard 638:c90ae1400bf2 165 } ble_gattc_evt_rel_disc_rsp_t;
Vincent Coubard 638:c90ae1400bf2 166
Vincent Coubard 638:c90ae1400bf2 167 /**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_DISC_RSP. */
Vincent Coubard 638:c90ae1400bf2 168 typedef struct
Vincent Coubard 638:c90ae1400bf2 169 {
Vincent Coubard 638:c90ae1400bf2 170 uint16_t count; /**< Characteristic count. */
Vincent Coubard 638:c90ae1400bf2 171 ble_gattc_char_t chars[1]; /**< Characteristic data, variable length. */
Vincent Coubard 638:c90ae1400bf2 172 } ble_gattc_evt_char_disc_rsp_t;
Vincent Coubard 638:c90ae1400bf2 173
Vincent Coubard 638:c90ae1400bf2 174 /**@brief Event structure for @ref BLE_GATTC_EVT_DESC_DISC_RSP. */
Vincent Coubard 638:c90ae1400bf2 175 typedef struct
Vincent Coubard 638:c90ae1400bf2 176 {
Vincent Coubard 638:c90ae1400bf2 177 uint16_t count; /**< Descriptor count. */
Vincent Coubard 638:c90ae1400bf2 178 ble_gattc_desc_t descs[1]; /**< Descriptor data, variable length. */
Vincent Coubard 638:c90ae1400bf2 179 } ble_gattc_evt_desc_disc_rsp_t;
Vincent Coubard 638:c90ae1400bf2 180
Vincent Coubard 638:c90ae1400bf2 181 /**@brief GATT read by UUID handle value pair. */
Vincent Coubard 638:c90ae1400bf2 182 typedef struct
Vincent Coubard 638:c90ae1400bf2 183 {
Vincent Coubard 638:c90ae1400bf2 184 uint16_t handle; /**< Attribute Handle. */
Vincent Coubard 638:c90ae1400bf2 185 uint8_t *p_value; /**< Pointer to value, variable length (length available as value_len in @ref ble_gattc_evt_char_val_by_uuid_read_rsp_t).
Vincent Coubard 638:c90ae1400bf2 186 Please note that this pointer is absolute to the memory provided by the user when retrieving the event,
Vincent Coubard 638:c90ae1400bf2 187 so it will effectively point to a location inside the handle_value array. */
Vincent Coubard 638:c90ae1400bf2 188 } ble_gattc_handle_value_t;
Vincent Coubard 638:c90ae1400bf2 189
Vincent Coubard 638:c90ae1400bf2 190 /**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */
Vincent Coubard 638:c90ae1400bf2 191 typedef struct
Vincent Coubard 638:c90ae1400bf2 192 {
Vincent Coubard 638:c90ae1400bf2 193 uint16_t count; /**< Handle-Value Pair Count. */
Vincent Coubard 638:c90ae1400bf2 194 uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */
Vincent Coubard 638:c90ae1400bf2 195 ble_gattc_handle_value_t handle_value[1]; /**< Handle-Value(s) list, variable length. */
Vincent Coubard 638:c90ae1400bf2 196 } ble_gattc_evt_char_val_by_uuid_read_rsp_t;
Vincent Coubard 638:c90ae1400bf2 197
Vincent Coubard 638:c90ae1400bf2 198 /**@brief Event structure for @ref BLE_GATTC_EVT_READ_RSP. */
Vincent Coubard 638:c90ae1400bf2 199 typedef struct
Vincent Coubard 638:c90ae1400bf2 200 {
Vincent Coubard 638:c90ae1400bf2 201 uint16_t handle; /**< Attribute Handle. */
Vincent Coubard 638:c90ae1400bf2 202 uint16_t offset; /**< Offset of the attribute data. */
Vincent Coubard 638:c90ae1400bf2 203 uint16_t len; /**< Attribute data length. */
Vincent Coubard 638:c90ae1400bf2 204 uint8_t data[1]; /**< Attribute data, variable length. */
Vincent Coubard 638:c90ae1400bf2 205 } ble_gattc_evt_read_rsp_t;
Vincent Coubard 638:c90ae1400bf2 206
Vincent Coubard 638:c90ae1400bf2 207 /**@brief Event structure for @ref BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */
Vincent Coubard 638:c90ae1400bf2 208 typedef struct
Vincent Coubard 638:c90ae1400bf2 209 {
Vincent Coubard 638:c90ae1400bf2 210 uint16_t len; /**< Concatenated Attribute values length. */
Vincent Coubard 638:c90ae1400bf2 211 uint8_t values[1]; /**< Attribute values, variable length. */
Vincent Coubard 638:c90ae1400bf2 212 } ble_gattc_evt_char_vals_read_rsp_t;
Vincent Coubard 638:c90ae1400bf2 213
Vincent Coubard 638:c90ae1400bf2 214 /**@brief Event structure for @ref BLE_GATTC_EVT_WRITE_RSP. */
Vincent Coubard 638:c90ae1400bf2 215 typedef struct
Vincent Coubard 638:c90ae1400bf2 216 {
Vincent Coubard 638:c90ae1400bf2 217 uint16_t handle; /**< Attribute Handle. */
Vincent Coubard 638:c90ae1400bf2 218 uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */
Vincent Coubard 638:c90ae1400bf2 219 uint16_t offset; /**< Data offset. */
Vincent Coubard 638:c90ae1400bf2 220 uint16_t len; /**< Data length. */
Vincent Coubard 638:c90ae1400bf2 221 uint8_t data[1]; /**< Data, variable length. */
Vincent Coubard 638:c90ae1400bf2 222 } ble_gattc_evt_write_rsp_t;
Vincent Coubard 638:c90ae1400bf2 223
Vincent Coubard 638:c90ae1400bf2 224 /**@brief Event structure for @ref BLE_GATTC_EVT_HVX. */
Vincent Coubard 638:c90ae1400bf2 225 typedef struct
Vincent Coubard 638:c90ae1400bf2 226 {
Vincent Coubard 638:c90ae1400bf2 227 uint16_t handle; /**< Handle to which the HVx operation applies. */
Vincent Coubard 638:c90ae1400bf2 228 uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
Vincent Coubard 638:c90ae1400bf2 229 uint16_t len; /**< Attribute data length. */
Vincent Coubard 638:c90ae1400bf2 230 uint8_t data[1]; /**< Attribute data, variable length. */
Vincent Coubard 638:c90ae1400bf2 231 } ble_gattc_evt_hvx_t;
Vincent Coubard 638:c90ae1400bf2 232
Vincent Coubard 638:c90ae1400bf2 233 /**@brief Event structure for @ref BLE_GATTC_EVT_TIMEOUT. */
Vincent Coubard 638:c90ae1400bf2 234 typedef struct
Vincent Coubard 638:c90ae1400bf2 235 {
Vincent Coubard 638:c90ae1400bf2 236 uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
Vincent Coubard 638:c90ae1400bf2 237 } ble_gattc_evt_timeout_t;
Vincent Coubard 638:c90ae1400bf2 238
Vincent Coubard 638:c90ae1400bf2 239 /**@brief GATTC event structure. */
Vincent Coubard 638:c90ae1400bf2 240 typedef struct
Vincent Coubard 638:c90ae1400bf2 241 {
Vincent Coubard 638:c90ae1400bf2 242 uint16_t conn_handle; /**< Connection Handle on which event occured. */
Vincent Coubard 638:c90ae1400bf2 243 uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
Vincent Coubard 638:c90ae1400bf2 244 uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases @ref BLE_GATT_HANDLE_INVALID. */
Vincent Coubard 638:c90ae1400bf2 245 union
Vincent Coubard 638:c90ae1400bf2 246 {
Vincent Coubard 638:c90ae1400bf2 247 ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 248 ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 249 ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 250 ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 251 ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 252 ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 253 ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 254 ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 255 ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 256 ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */
Vincent Coubard 638:c90ae1400bf2 257 } params; /**< Event Parameters. @note Only valid if @ref gatt_status == @ref BLE_GATT_STATUS_SUCCESS. */
Vincent Coubard 638:c90ae1400bf2 258 } ble_gattc_evt_t;
Vincent Coubard 638:c90ae1400bf2 259 /** @} */
Vincent Coubard 638:c90ae1400bf2 260
Vincent Coubard 638:c90ae1400bf2 261 /** @addtogroup BLE_GATTC_FUNCTIONS Functions
Vincent Coubard 638:c90ae1400bf2 262 * @{ */
Vincent Coubard 638:c90ae1400bf2 263
Vincent Coubard 638:c90ae1400bf2 264 /**@brief Initiate or continue a GATT Primary Service Discovery procedure.
Vincent Coubard 638:c90ae1400bf2 265 *
Vincent Coubard 638:c90ae1400bf2 266 * @details This function initiates or resumes a Primary Service discovery procedure, starting from the supplied handle.
Vincent Coubard 638:c90ae1400bf2 267 * If the last service has not been reached, this function must be called again with an updated start handle value to continue the search.
Vincent Coubard 638:c90ae1400bf2 268 *
Vincent Coubard 638:c90ae1400bf2 269 * @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
Vincent Coubard 638:c90ae1400bf2 270 * type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
Vincent Coubard 638:c90ae1400bf2 271 *
Vincent Coubard 638:c90ae1400bf2 272 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 273 * @param[in] start_handle Handle to start searching from.
Vincent Coubard 638:c90ae1400bf2 274 * @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned.
Vincent Coubard 638:c90ae1400bf2 275 *
Vincent Coubard 638:c90ae1400bf2 276 * @retval ::NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure.
Vincent Coubard 638:c90ae1400bf2 277 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 278 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
Vincent Coubard 638:c90ae1400bf2 279 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
Vincent Coubard 638:c90ae1400bf2 280 * @retval ::NRF_ERROR_BUSY Client procedure already in progress.
Vincent Coubard 638:c90ae1400bf2 281 */
Vincent Coubard 638:c90ae1400bf2 282 SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const *p_srvc_uuid));
Vincent Coubard 638:c90ae1400bf2 283
Vincent Coubard 638:c90ae1400bf2 284
Vincent Coubard 638:c90ae1400bf2 285 /**@brief Initiate or continue a GATT Relationship Discovery procedure.
Vincent Coubard 638:c90ae1400bf2 286 *
Vincent Coubard 638:c90ae1400bf2 287 * @details This function initiates or resumes the Find Included Services sub-procedure. If the last included service has not been reached,
Vincent Coubard 638:c90ae1400bf2 288 * this must be called again with an updated handle range to continue the search.
Vincent Coubard 638:c90ae1400bf2 289 *
Vincent Coubard 638:c90ae1400bf2 290 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 291 * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 292 *
Vincent Coubard 638:c90ae1400bf2 293 * @retval ::NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure.
Vincent Coubard 638:c90ae1400bf2 294 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 295 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
Vincent Coubard 638:c90ae1400bf2 296 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
Vincent Coubard 638:c90ae1400bf2 297 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
Vincent Coubard 638:c90ae1400bf2 298 * @retval ::NRF_ERROR_BUSY Client procedure already in progress.
Vincent Coubard 638:c90ae1400bf2 299 */
Vincent Coubard 638:c90ae1400bf2 300 SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
Vincent Coubard 638:c90ae1400bf2 301
Vincent Coubard 638:c90ae1400bf2 302
Vincent Coubard 638:c90ae1400bf2 303 /**@brief Initiate or continue a GATT Characteristic Discovery procedure.
Vincent Coubard 638:c90ae1400bf2 304 *
Vincent Coubard 638:c90ae1400bf2 305 * @details This function initiates or resumes a Characteristic discovery procedure. If the last Characteristic has not been reached,
Vincent Coubard 638:c90ae1400bf2 306 * this must be called again with an updated handle range to continue the discovery.
Vincent Coubard 638:c90ae1400bf2 307 *
Vincent Coubard 638:c90ae1400bf2 308 * @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
Vincent Coubard 638:c90ae1400bf2 309 * type @ref BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
Vincent Coubard 638:c90ae1400bf2 310 *
Vincent Coubard 638:c90ae1400bf2 311 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 312 * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 313 *
Vincent Coubard 638:c90ae1400bf2 314 * @retval ::NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure.
Vincent Coubard 638:c90ae1400bf2 315 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 316 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
Vincent Coubard 638:c90ae1400bf2 317 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
Vincent Coubard 638:c90ae1400bf2 318 * @retval ::NRF_ERROR_BUSY Client procedure already in progress.
Vincent Coubard 638:c90ae1400bf2 319 */
Vincent Coubard 638:c90ae1400bf2 320 SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
Vincent Coubard 638:c90ae1400bf2 321
Vincent Coubard 638:c90ae1400bf2 322
Vincent Coubard 638:c90ae1400bf2 323 /**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure.
Vincent Coubard 638:c90ae1400bf2 324 *
Vincent Coubard 638:c90ae1400bf2 325 * @details This function initiates or resumes a Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached,
Vincent Coubard 638:c90ae1400bf2 326 * this must be called again with an updated handle range to continue the discovery.
Vincent Coubard 638:c90ae1400bf2 327 *
Vincent Coubard 638:c90ae1400bf2 328 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 329 * @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 330 *
Vincent Coubard 638:c90ae1400bf2 331 * @retval ::NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure.
Vincent Coubard 638:c90ae1400bf2 332 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 333 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
Vincent Coubard 638:c90ae1400bf2 334 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
Vincent Coubard 638:c90ae1400bf2 335 * @retval ::NRF_ERROR_BUSY Client procedure already in progress.
Vincent Coubard 638:c90ae1400bf2 336 */
Vincent Coubard 638:c90ae1400bf2 337 SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const *p_handle_range));
Vincent Coubard 638:c90ae1400bf2 338
Vincent Coubard 638:c90ae1400bf2 339
Vincent Coubard 638:c90ae1400bf2 340 /**@brief Initiate or continue a GATT Read using Characteristic UUID procedure.
Vincent Coubard 638:c90ae1400bf2 341 *
Vincent Coubard 638:c90ae1400bf2 342 * @details This function initiates or resumes a Read using Characteristic UUID procedure. If the last Characteristic has not been reached,
Vincent Coubard 638:c90ae1400bf2 343 * this must be called again with an updated handle range to continue the discovery.
Vincent Coubard 638:c90ae1400bf2 344 *
Vincent Coubard 638:c90ae1400bf2 345 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 346 * @param[in] p_uuid Pointer to a Characteristic value UUID to read.
Vincent Coubard 638:c90ae1400bf2 347 * @param[in] p_handle_range A pointer to the range of handles to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 348 *
Vincent Coubard 638:c90ae1400bf2 349 * @retval ::NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure.
Vincent Coubard 638:c90ae1400bf2 350 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 351 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
Vincent Coubard 638:c90ae1400bf2 352 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
Vincent Coubard 638:c90ae1400bf2 353 * @retval ::NRF_ERROR_BUSY Client procedure already in progress.
Vincent Coubard 638:c90ae1400bf2 354 */
Vincent Coubard 638:c90ae1400bf2 355 SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const *p_uuid, ble_gattc_handle_range_t const *p_handle_range));
Vincent Coubard 638:c90ae1400bf2 356
Vincent Coubard 638:c90ae1400bf2 357
Vincent Coubard 638:c90ae1400bf2 358 /**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure.
Vincent Coubard 638:c90ae1400bf2 359 *
Vincent Coubard 638:c90ae1400bf2 360 * @details This function initiates or resumes a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor
Vincent Coubard 638:c90ae1400bf2 361 * to be read is longer than ATT_MTU - 1, this function must be called multiple times with appropriate offset to read the
Vincent Coubard 638:c90ae1400bf2 362 * complete value.
Vincent Coubard 638:c90ae1400bf2 363 *
Vincent Coubard 638:c90ae1400bf2 364 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 365 * @param[in] handle The handle of the attribute to be read.
Vincent Coubard 638:c90ae1400bf2 366 * @param[in] offset Offset into the attribute value to be read.
Vincent Coubard 638:c90ae1400bf2 367 *
Vincent Coubard 638:c90ae1400bf2 368 * @retval ::NRF_SUCCESS Successfully started or resumed the Read (Long) procedure.
Vincent Coubard 638:c90ae1400bf2 369 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 370 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
Vincent Coubard 638:c90ae1400bf2 371 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
Vincent Coubard 638:c90ae1400bf2 372 * @retval ::NRF_ERROR_BUSY Client procedure already in progress.
Vincent Coubard 638:c90ae1400bf2 373 */
Vincent Coubard 638:c90ae1400bf2 374 SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset));
Vincent Coubard 638:c90ae1400bf2 375
Vincent Coubard 638:c90ae1400bf2 376
Vincent Coubard 638:c90ae1400bf2 377 /**@brief Initiate a GATT Read Multiple Characteristic Values procedure.
Vincent Coubard 638:c90ae1400bf2 378 *
Vincent Coubard 638:c90ae1400bf2 379 * @details This function initiates a GATT Read Multiple Characteristic Values procedure.
Vincent Coubard 638:c90ae1400bf2 380 *
Vincent Coubard 638:c90ae1400bf2 381 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 382 * @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read.
Vincent Coubard 638:c90ae1400bf2 383 * @param[in] handle_count The number of handles in p_handles.
Vincent Coubard 638:c90ae1400bf2 384 *
Vincent Coubard 638:c90ae1400bf2 385 * @retval ::NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure.
Vincent Coubard 638:c90ae1400bf2 386 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 387 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
Vincent Coubard 638:c90ae1400bf2 388 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
Vincent Coubard 638:c90ae1400bf2 389 * @retval ::NRF_ERROR_BUSY Client procedure already in progress.
Vincent Coubard 638:c90ae1400bf2 390 */
Vincent Coubard 638:c90ae1400bf2 391 SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const *p_handles, uint16_t handle_count));
Vincent Coubard 638:c90ae1400bf2 392
Vincent Coubard 638:c90ae1400bf2 393
Vincent Coubard 638:c90ae1400bf2 394 /**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure.
Vincent Coubard 638:c90ae1400bf2 395 *
Vincent Coubard 638:c90ae1400bf2 396 * @details This function can perform all write procedures described in GATT.
Vincent Coubard 638:c90ae1400bf2 397 *
Vincent Coubard 638:c90ae1400bf2 398 * @note It is important to note that a write without response will <b>consume an application buffer</b>, and will therefore
Vincent Coubard 638:c90ae1400bf2 399 * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. A write (with response) on the other hand will use the
Vincent Coubard 638:c90ae1400bf2 400 * standard client internal buffer and thus will only generate a @ref BLE_GATTC_EVT_WRITE_RSP event as soon as the write response
Vincent Coubard 638:c90ae1400bf2 401 * has been received from the peer. Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details.
Vincent Coubard 638:c90ae1400bf2 402 *
Vincent Coubard 638:c90ae1400bf2 403 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 404 * @param[in] p_write_params A pointer to a write parameters structure.
Vincent Coubard 638:c90ae1400bf2 405 *
Vincent Coubard 638:c90ae1400bf2 406 * @retval ::NRF_SUCCESS Successfully started the Write procedure.
Vincent Coubard 638:c90ae1400bf2 407 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 408 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State.
Vincent Coubard 638:c90ae1400bf2 409 * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
Vincent Coubard 638:c90ae1400bf2 410 * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
Vincent Coubard 638:c90ae1400bf2 411 * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
Vincent Coubard 638:c90ae1400bf2 412 * @retval ::NRF_ERROR_BUSY Procedure already in progress.
Vincent Coubard 638:c90ae1400bf2 413 * @retval ::BLE_ERROR_NO_TX_BUFFERS There are no available buffers left.
Vincent Coubard 638:c90ae1400bf2 414 */
Vincent Coubard 638:c90ae1400bf2 415 SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const *p_write_params));
Vincent Coubard 638:c90ae1400bf2 416
Vincent Coubard 638:c90ae1400bf2 417
Vincent Coubard 638:c90ae1400bf2 418 /**@brief Send a Handle Value Confirmation to the GATT Server.
Vincent Coubard 638:c90ae1400bf2 419 *
Vincent Coubard 638:c90ae1400bf2 420 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
Vincent Coubard 638:c90ae1400bf2 421 * @param[in] handle The handle of the attribute in the indication.
Vincent Coubard 638:c90ae1400bf2 422 *
Vincent Coubard 638:c90ae1400bf2 423 * @retval ::NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission.
Vincent Coubard 638:c90ae1400bf2 424 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
Vincent Coubard 638:c90ae1400bf2 425 * @retval ::NRF_ERROR_INVALID_STATE Invalid Connection State or no Indication pending to be confirmed.
Vincent Coubard 638:c90ae1400bf2 426 * @retval ::BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle.
Vincent Coubard 638:c90ae1400bf2 427 */
Vincent Coubard 638:c90ae1400bf2 428 SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle));
Vincent Coubard 638:c90ae1400bf2 429
Vincent Coubard 638:c90ae1400bf2 430 /** @} */
Vincent Coubard 638:c90ae1400bf2 431
Vincent Coubard 638:c90ae1400bf2 432 #endif /* BLE_GATTC_H__ */
Vincent Coubard 638:c90ae1400bf2 433
Vincent Coubard 638:c90ae1400bf2 434 /**
Vincent Coubard 638:c90ae1400bf2 435 @}
Vincent Coubard 638:c90ae1400bf2 436 @}
Vincent Coubard 638:c90ae1400bf2 437 */