Birkbeck College Mobile and Ubiquitous Computing IoT Lab Exercise 2

Dependencies:   BLE_API_Native_blog

Committer:
gkroussos
Date:
Sat Mar 07 16:34:53 2015 +0000
Revision:
0:e8fdba0ed044
MUC IoT Workshop v1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gkroussos 0:e8fdba0ed044 1 /* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
gkroussos 0:e8fdba0ed044 2 *
gkroussos 0:e8fdba0ed044 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
gkroussos 0:e8fdba0ed044 4 * copying, transfer or disclosure of such information is prohibited except by express written
gkroussos 0:e8fdba0ed044 5 * agreement with Nordic Semiconductor.
gkroussos 0:e8fdba0ed044 6 *
gkroussos 0:e8fdba0ed044 7 */
gkroussos 0:e8fdba0ed044 8 /**
gkroussos 0:e8fdba0ed044 9 @addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client
gkroussos 0:e8fdba0ed044 10 @{
gkroussos 0:e8fdba0ed044 11 @brief Definitions and prototypes for the GATT Client interface.
gkroussos 0:e8fdba0ed044 12 */
gkroussos 0:e8fdba0ed044 13
gkroussos 0:e8fdba0ed044 14 #ifndef BLE_GATTC_H__
gkroussos 0:e8fdba0ed044 15 #define BLE_GATTC_H__
gkroussos 0:e8fdba0ed044 16
gkroussos 0:e8fdba0ed044 17 #include "ble_gatt.h"
gkroussos 0:e8fdba0ed044 18 #include "ble_types.h"
gkroussos 0:e8fdba0ed044 19 #include "ble_ranges.h"
gkroussos 0:e8fdba0ed044 20 #include "nrf_svc.h"
gkroussos 0:e8fdba0ed044 21
gkroussos 0:e8fdba0ed044 22
gkroussos 0:e8fdba0ed044 23 /**@brief GATTC API SVC numbers. */
gkroussos 0:e8fdba0ed044 24 enum BLE_GATTC_SVCS
gkroussos 0:e8fdba0ed044 25 {
gkroussos 0:e8fdba0ed044 26 SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */
gkroussos 0:e8fdba0ed044 27 SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */
gkroussos 0:e8fdba0ed044 28 SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */
gkroussos 0:e8fdba0ed044 29 SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */
gkroussos 0:e8fdba0ed044 30 SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */
gkroussos 0:e8fdba0ed044 31 SD_BLE_GATTC_READ, /**< Generic read. */
gkroussos 0:e8fdba0ed044 32 SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */
gkroussos 0:e8fdba0ed044 33 SD_BLE_GATTC_WRITE, /**< Generic write. */
gkroussos 0:e8fdba0ed044 34 SD_BLE_GATTC_HV_CONFIRM /**< Handle Value Confirmation. */
gkroussos 0:e8fdba0ed044 35 };
gkroussos 0:e8fdba0ed044 36
gkroussos 0:e8fdba0ed044 37 /** @addtogroup BLE_GATTC_DEFINES Defines
gkroussos 0:e8fdba0ed044 38 * @{ */
gkroussos 0:e8fdba0ed044 39
gkroussos 0:e8fdba0ed044 40 /** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC
gkroussos 0:e8fdba0ed044 41 * @{ */
gkroussos 0:e8fdba0ed044 42 #define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000)
gkroussos 0:e8fdba0ed044 43 /** @} */
gkroussos 0:e8fdba0ed044 44
gkroussos 0:e8fdba0ed044 45 /**@brief Last Attribute Handle. */
gkroussos 0:e8fdba0ed044 46 #define BLE_GATTC_HANDLE_END 0xFFFF
gkroussos 0:e8fdba0ed044 47
gkroussos 0:e8fdba0ed044 48 /** @} */
gkroussos 0:e8fdba0ed044 49
gkroussos 0:e8fdba0ed044 50 /**@brief Operation Handle Range. */
gkroussos 0:e8fdba0ed044 51 typedef struct
gkroussos 0:e8fdba0ed044 52 {
gkroussos 0:e8fdba0ed044 53 uint16_t start_handle; /**< Start Handle. */
gkroussos 0:e8fdba0ed044 54 uint16_t end_handle; /**< End Handle. */
gkroussos 0:e8fdba0ed044 55 } ble_gattc_handle_range_t;
gkroussos 0:e8fdba0ed044 56
gkroussos 0:e8fdba0ed044 57
gkroussos 0:e8fdba0ed044 58 /**@brief GATT service. */
gkroussos 0:e8fdba0ed044 59 typedef struct
gkroussos 0:e8fdba0ed044 60 {
gkroussos 0:e8fdba0ed044 61 ble_uuid_t uuid; /**< Service UUID. */
gkroussos 0:e8fdba0ed044 62 ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */
gkroussos 0:e8fdba0ed044 63 } ble_gattc_service_t;
gkroussos 0:e8fdba0ed044 64
gkroussos 0:e8fdba0ed044 65
gkroussos 0:e8fdba0ed044 66 /**@brief GATT include. */
gkroussos 0:e8fdba0ed044 67 typedef struct
gkroussos 0:e8fdba0ed044 68 {
gkroussos 0:e8fdba0ed044 69 uint16_t handle; /**< Include Handle. */
gkroussos 0:e8fdba0ed044 70 ble_gattc_service_t included_srvc; /**< Handle of the included service. */
gkroussos 0:e8fdba0ed044 71 } ble_gattc_include_t;
gkroussos 0:e8fdba0ed044 72
gkroussos 0:e8fdba0ed044 73
gkroussos 0:e8fdba0ed044 74 /**@brief GATT characteristic. */
gkroussos 0:e8fdba0ed044 75 typedef struct
gkroussos 0:e8fdba0ed044 76 {
gkroussos 0:e8fdba0ed044 77 ble_uuid_t uuid; /**< Characteristic UUID. */
gkroussos 0:e8fdba0ed044 78 ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
gkroussos 0:e8fdba0ed044 79 uint8_t char_ext_props : 1; /**< Extended properties present. */
gkroussos 0:e8fdba0ed044 80 uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */
gkroussos 0:e8fdba0ed044 81 uint16_t handle_value; /**< Handle of the Characteristic Value. */
gkroussos 0:e8fdba0ed044 82 } ble_gattc_char_t;
gkroussos 0:e8fdba0ed044 83
gkroussos 0:e8fdba0ed044 84
gkroussos 0:e8fdba0ed044 85 /**@brief GATT descriptor. */
gkroussos 0:e8fdba0ed044 86 typedef struct
gkroussos 0:e8fdba0ed044 87 {
gkroussos 0:e8fdba0ed044 88 uint16_t handle; /**< Descriptor Handle. */
gkroussos 0:e8fdba0ed044 89 ble_uuid_t uuid; /**< Descriptor UUID. */
gkroussos 0:e8fdba0ed044 90 } ble_gattc_desc_t;
gkroussos 0:e8fdba0ed044 91
gkroussos 0:e8fdba0ed044 92
gkroussos 0:e8fdba0ed044 93 /**@brief Write Parameters. */
gkroussos 0:e8fdba0ed044 94 typedef struct
gkroussos 0:e8fdba0ed044 95 {
gkroussos 0:e8fdba0ed044 96 uint8_t write_op; /**< Write Operation to be performed, see BLE_GATT_WRITE_OPS. */
gkroussos 0:e8fdba0ed044 97 uint16_t handle; /**< Handle to the attribute to be written. */
gkroussos 0:e8fdba0ed044 98 uint16_t offset; /**< Offset in bytes. */
gkroussos 0:e8fdba0ed044 99 uint16_t len; /**< Length of data in bytes. */
gkroussos 0:e8fdba0ed044 100 uint8_t* p_value; /**< Pointer to the value data. */
gkroussos 0:e8fdba0ed044 101 uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */
gkroussos 0:e8fdba0ed044 102 } ble_gattc_write_params_t;
gkroussos 0:e8fdba0ed044 103
gkroussos 0:e8fdba0ed044 104
gkroussos 0:e8fdba0ed044 105 /**
gkroussos 0:e8fdba0ed044 106 * @brief GATT Client Event IDs.
gkroussos 0:e8fdba0ed044 107 */
gkroussos 0:e8fdba0ed044 108 enum BLE_GATTC_EVTS
gkroussos 0:e8fdba0ed044 109 {
gkroussos 0:e8fdba0ed044 110 BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. */
gkroussos 0:e8fdba0ed044 111 BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. */
gkroussos 0:e8fdba0ed044 112 BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. */
gkroussos 0:e8fdba0ed044 113 BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. */
gkroussos 0:e8fdba0ed044 114 BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. */
gkroussos 0:e8fdba0ed044 115 BLE_GATTC_EVT_READ_RSP, /**< Read Response event. */
gkroussos 0:e8fdba0ed044 116 BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. */
gkroussos 0:e8fdba0ed044 117 BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. */
gkroussos 0:e8fdba0ed044 118 BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. */
gkroussos 0:e8fdba0ed044 119 BLE_GATTC_EVT_TIMEOUT /**< Timeout event. */
gkroussos 0:e8fdba0ed044 120 };
gkroussos 0:e8fdba0ed044 121
gkroussos 0:e8fdba0ed044 122 /**@brief Event structure for BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */
gkroussos 0:e8fdba0ed044 123 typedef struct
gkroussos 0:e8fdba0ed044 124 {
gkroussos 0:e8fdba0ed044 125 uint16_t count; /**< Service count. */
gkroussos 0:e8fdba0ed044 126 ble_gattc_service_t services[1]; /**< Service data, variable length. */
gkroussos 0:e8fdba0ed044 127 } ble_gattc_evt_prim_srvc_disc_rsp_t;
gkroussos 0:e8fdba0ed044 128
gkroussos 0:e8fdba0ed044 129 /**@brief Event structure for BLE_GATTC_EVT_REL_DISC_RSP. */
gkroussos 0:e8fdba0ed044 130 typedef struct
gkroussos 0:e8fdba0ed044 131 {
gkroussos 0:e8fdba0ed044 132 uint16_t count; /**< Include count. */
gkroussos 0:e8fdba0ed044 133 ble_gattc_include_t includes[1]; /**< Include data, variable length. */
gkroussos 0:e8fdba0ed044 134 } ble_gattc_evt_rel_disc_rsp_t;
gkroussos 0:e8fdba0ed044 135
gkroussos 0:e8fdba0ed044 136 /**@brief Event structure for BLE_GATTC_EVT_CHAR_DISC_RSP. */
gkroussos 0:e8fdba0ed044 137 typedef struct
gkroussos 0:e8fdba0ed044 138 {
gkroussos 0:e8fdba0ed044 139 uint16_t count; /**< Characteristic count. */
gkroussos 0:e8fdba0ed044 140 ble_gattc_char_t chars[1]; /**< Characteristic data, variable length. */
gkroussos 0:e8fdba0ed044 141 } ble_gattc_evt_char_disc_rsp_t;
gkroussos 0:e8fdba0ed044 142
gkroussos 0:e8fdba0ed044 143 /**@brief Event structure for BLE_GATTC_EVT_DESC_DISC_RSP. */
gkroussos 0:e8fdba0ed044 144 typedef struct
gkroussos 0:e8fdba0ed044 145 {
gkroussos 0:e8fdba0ed044 146 uint16_t count; /**< Descriptor count. */
gkroussos 0:e8fdba0ed044 147 ble_gattc_desc_t descs[1]; /**< Descriptor data, variable length. */
gkroussos 0:e8fdba0ed044 148 } ble_gattc_evt_desc_disc_rsp_t;
gkroussos 0:e8fdba0ed044 149
gkroussos 0:e8fdba0ed044 150 /**@brief GATT read by UUID handle value pair. */
gkroussos 0:e8fdba0ed044 151 typedef struct
gkroussos 0:e8fdba0ed044 152 {
gkroussos 0:e8fdba0ed044 153 uint16_t handle; /**< Attribute Handle. */
gkroussos 0:e8fdba0ed044 154 uint8_t *p_value; /**< Pointer to value, variable length (length available as value_len in ble_gattc_evt_read_by_uuid_rsp_t).
gkroussos 0:e8fdba0ed044 155 Please note that this pointer is absolute to the memory provided by the user when retrieving the event,
gkroussos 0:e8fdba0ed044 156 so it will effectively point to a location inside the handle_value array. */
gkroussos 0:e8fdba0ed044 157 } ble_gattc_handle_value_t;
gkroussos 0:e8fdba0ed044 158
gkroussos 0:e8fdba0ed044 159 /**@brief Event structure for BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */
gkroussos 0:e8fdba0ed044 160 typedef struct
gkroussos 0:e8fdba0ed044 161 {
gkroussos 0:e8fdba0ed044 162 uint16_t count; /**< Handle-Value Pair Count. */
gkroussos 0:e8fdba0ed044 163 uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */
gkroussos 0:e8fdba0ed044 164 ble_gattc_handle_value_t handle_value[1]; /**< Handle-Value(s) list, variable length. */
gkroussos 0:e8fdba0ed044 165 } ble_gattc_evt_char_val_by_uuid_read_rsp_t;
gkroussos 0:e8fdba0ed044 166
gkroussos 0:e8fdba0ed044 167 /**@brief Event structure for BLE_GATTC_EVT_READ_RSP. */
gkroussos 0:e8fdba0ed044 168 typedef struct
gkroussos 0:e8fdba0ed044 169 {
gkroussos 0:e8fdba0ed044 170 uint16_t handle; /**< Attribute Handle. */
gkroussos 0:e8fdba0ed044 171 uint16_t offset; /**< Offset of the attribute data. */
gkroussos 0:e8fdba0ed044 172 uint16_t len; /**< Attribute data length. */
gkroussos 0:e8fdba0ed044 173 uint8_t data[1]; /**< Attribute data, variable length. */
gkroussos 0:e8fdba0ed044 174 } ble_gattc_evt_read_rsp_t;
gkroussos 0:e8fdba0ed044 175
gkroussos 0:e8fdba0ed044 176 /**@brief Event structure for BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */
gkroussos 0:e8fdba0ed044 177 typedef struct
gkroussos 0:e8fdba0ed044 178 {
gkroussos 0:e8fdba0ed044 179 uint16_t len; /**< Concatenated Attribute values length. */
gkroussos 0:e8fdba0ed044 180 uint8_t values[1]; /**< Attribute values, variable length. */
gkroussos 0:e8fdba0ed044 181 } ble_gattc_evt_char_vals_read_rsp_t;
gkroussos 0:e8fdba0ed044 182
gkroussos 0:e8fdba0ed044 183 /**@brief Event structure for BLE_GATTC_EVT_WRITE_RSP. */
gkroussos 0:e8fdba0ed044 184 typedef struct
gkroussos 0:e8fdba0ed044 185 {
gkroussos 0:e8fdba0ed044 186 uint16_t handle; /**< Attribute Handle. */
gkroussos 0:e8fdba0ed044 187 uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */
gkroussos 0:e8fdba0ed044 188 uint16_t offset; /**< Data Offset. */
gkroussos 0:e8fdba0ed044 189 uint16_t len; /**< Data length. */
gkroussos 0:e8fdba0ed044 190 uint8_t data[1]; /**< Data, variable length. */
gkroussos 0:e8fdba0ed044 191 } ble_gattc_evt_write_rsp_t;
gkroussos 0:e8fdba0ed044 192
gkroussos 0:e8fdba0ed044 193 /**@brief Event structure for BLE_GATTC_EVT_HVX. */
gkroussos 0:e8fdba0ed044 194 typedef struct
gkroussos 0:e8fdba0ed044 195 {
gkroussos 0:e8fdba0ed044 196 uint16_t handle; /**< Handle to which the HVx operation applies. */
gkroussos 0:e8fdba0ed044 197 uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
gkroussos 0:e8fdba0ed044 198 uint16_t len; /**< Attribute data length. */
gkroussos 0:e8fdba0ed044 199 uint8_t data[1]; /**< Attribute data, variable length. */
gkroussos 0:e8fdba0ed044 200 } ble_gattc_evt_hvx_t;
gkroussos 0:e8fdba0ed044 201
gkroussos 0:e8fdba0ed044 202 /**@brief Event structure for BLE_GATTC_EVT_TIMEOUT. */
gkroussos 0:e8fdba0ed044 203 typedef struct
gkroussos 0:e8fdba0ed044 204 {
gkroussos 0:e8fdba0ed044 205 uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
gkroussos 0:e8fdba0ed044 206 } ble_gattc_evt_timeout_t;
gkroussos 0:e8fdba0ed044 207
gkroussos 0:e8fdba0ed044 208 /**@brief GATTC event type. */
gkroussos 0:e8fdba0ed044 209 typedef struct
gkroussos 0:e8fdba0ed044 210 {
gkroussos 0:e8fdba0ed044 211 uint16_t conn_handle; /**< Connection Handle on which event occured. */
gkroussos 0:e8fdba0ed044 212 uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
gkroussos 0:e8fdba0ed044 213 uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases BLE_GATT_HANDLE_INVALID. */
gkroussos 0:e8fdba0ed044 214 union
gkroussos 0:e8fdba0ed044 215 {
gkroussos 0:e8fdba0ed044 216 ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */
gkroussos 0:e8fdba0ed044 217 ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */
gkroussos 0:e8fdba0ed044 218 ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */
gkroussos 0:e8fdba0ed044 219 ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */
gkroussos 0:e8fdba0ed044 220 ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */
gkroussos 0:e8fdba0ed044 221 ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */
gkroussos 0:e8fdba0ed044 222 ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */
gkroussos 0:e8fdba0ed044 223 ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */
gkroussos 0:e8fdba0ed044 224 ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */
gkroussos 0:e8fdba0ed044 225 ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */
gkroussos 0:e8fdba0ed044 226 } params; /**< Event Parameters. @note Only valid if @ref gatt_status == BLE_GATT_STATUS_SUCCESS. */
gkroussos 0:e8fdba0ed044 227 } ble_gattc_evt_t;
gkroussos 0:e8fdba0ed044 228
gkroussos 0:e8fdba0ed044 229
gkroussos 0:e8fdba0ed044 230 /**@brief Initiate or continue a GATT Primary Service Discovery procedure.
gkroussos 0:e8fdba0ed044 231 *
gkroussos 0:e8fdba0ed044 232 * @details This function initiates a Primary Service discovery, starting from the supplied handle.
gkroussos 0:e8fdba0ed044 233 * If the last service has not been reached, this must be called again with an updated start handle value to continue the search.
gkroussos 0:e8fdba0ed044 234 *
gkroussos 0:e8fdba0ed044 235 * @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
gkroussos 0:e8fdba0ed044 236 * type BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
gkroussos 0:e8fdba0ed044 237 *
gkroussos 0:e8fdba0ed044 238 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 239 * @param[in] start_handle Handle to start searching from.
gkroussos 0:e8fdba0ed044 240 * @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned.
gkroussos 0:e8fdba0ed044 241 *
gkroussos 0:e8fdba0ed044 242 * @return @ref NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure.
gkroussos 0:e8fdba0ed044 243 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 244 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
gkroussos 0:e8fdba0ed044 245 * @return @ref NRF_ERROR_BUSY Client procedure already in progress.
gkroussos 0:e8fdba0ed044 246 */
gkroussos 0:e8fdba0ed044 247 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 * const p_srvc_uuid));
gkroussos 0:e8fdba0ed044 248
gkroussos 0:e8fdba0ed044 249
gkroussos 0:e8fdba0ed044 250 /**@brief Initiate or continue a GATT Relationship Discovery procedure.
gkroussos 0:e8fdba0ed044 251 *
gkroussos 0:e8fdba0ed044 252 * @details This function initiates the Find Included Services sub-procedure. If the last included service has not been reached,
gkroussos 0:e8fdba0ed044 253 * this must be called again with an updated handle range to continue the search.
gkroussos 0:e8fdba0ed044 254 *
gkroussos 0:e8fdba0ed044 255 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 256 * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
gkroussos 0:e8fdba0ed044 257 *
gkroussos 0:e8fdba0ed044 258 * @return @ref NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure.
gkroussos 0:e8fdba0ed044 259 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 260 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
gkroussos 0:e8fdba0ed044 261 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
gkroussos 0:e8fdba0ed044 262 * @return @ref NRF_ERROR_BUSY Client procedure already in progress.
gkroussos 0:e8fdba0ed044 263 */
gkroussos 0:e8fdba0ed044 264 SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range));
gkroussos 0:e8fdba0ed044 265
gkroussos 0:e8fdba0ed044 266
gkroussos 0:e8fdba0ed044 267 /**@brief Initiate or continue a GATT Characteristic Discovery procedure.
gkroussos 0:e8fdba0ed044 268 *
gkroussos 0:e8fdba0ed044 269 * @details This function initiates a Characteristic discovery procedure. If the last Characteristic has not been reached,
gkroussos 0:e8fdba0ed044 270 * this must be called again with an updated handle range to continue the discovery.
gkroussos 0:e8fdba0ed044 271 *
gkroussos 0:e8fdba0ed044 272 * @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
gkroussos 0:e8fdba0ed044 273 * type BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
gkroussos 0:e8fdba0ed044 274 *
gkroussos 0:e8fdba0ed044 275 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 276 * @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
gkroussos 0:e8fdba0ed044 277 *
gkroussos 0:e8fdba0ed044 278 * @return @ref NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure.
gkroussos 0:e8fdba0ed044 279 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 280 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
gkroussos 0:e8fdba0ed044 281 * @return @ref NRF_ERROR_BUSY Client procedure already in progress.
gkroussos 0:e8fdba0ed044 282 */
gkroussos 0:e8fdba0ed044 283 SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range));
gkroussos 0:e8fdba0ed044 284
gkroussos 0:e8fdba0ed044 285
gkroussos 0:e8fdba0ed044 286 /**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure.
gkroussos 0:e8fdba0ed044 287 *
gkroussos 0:e8fdba0ed044 288 * @details This function initiates the Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached,
gkroussos 0:e8fdba0ed044 289 * this must be called again with an updated handle range to continue the discovery.
gkroussos 0:e8fdba0ed044 290 *
gkroussos 0:e8fdba0ed044 291 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 292 * @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on.
gkroussos 0:e8fdba0ed044 293 *
gkroussos 0:e8fdba0ed044 294 * @return @ref NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure.
gkroussos 0:e8fdba0ed044 295 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 296 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
gkroussos 0:e8fdba0ed044 297 * @return @ref NRF_ERROR_BUSY Client procedure already in progress.
gkroussos 0:e8fdba0ed044 298 */
gkroussos 0:e8fdba0ed044 299 SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range));
gkroussos 0:e8fdba0ed044 300
gkroussos 0:e8fdba0ed044 301
gkroussos 0:e8fdba0ed044 302 /**@brief Initiate or continue a GATT Read using Characteristic UUID procedure.
gkroussos 0:e8fdba0ed044 303 *
gkroussos 0:e8fdba0ed044 304 * @details This function initiates the Read using Characteristic UUID procedure. If the last Characteristic has not been reached,
gkroussos 0:e8fdba0ed044 305 * this must be called again with an updated handle range to continue the discovery.
gkroussos 0:e8fdba0ed044 306 *
gkroussos 0:e8fdba0ed044 307 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 308 * @param[in] p_uuid Pointer to a Characteristic value UUID to read.
gkroussos 0:e8fdba0ed044 309 * @param[in] p_handle_range A pointer to the range of handles to perform this procedure on.
gkroussos 0:e8fdba0ed044 310 *
gkroussos 0:e8fdba0ed044 311 * @return @ref NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure.
gkroussos 0:e8fdba0ed044 312 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 313 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
gkroussos 0:e8fdba0ed044 314 * @return @ref NRF_ERROR_BUSY Client procedure already in progress.
gkroussos 0:e8fdba0ed044 315 */
gkroussos 0:e8fdba0ed044 316 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 * const p_uuid, ble_gattc_handle_range_t const * const p_handle_range));
gkroussos 0:e8fdba0ed044 317
gkroussos 0:e8fdba0ed044 318
gkroussos 0:e8fdba0ed044 319 /**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure.
gkroussos 0:e8fdba0ed044 320 *
gkroussos 0:e8fdba0ed044 321 * @details This function initiates a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor
gkroussos 0:e8fdba0ed044 322 * to be read is longer than GATT_MTU - 1, this function must be called multiple times with appropriate offset to read the
gkroussos 0:e8fdba0ed044 323 * complete value.
gkroussos 0:e8fdba0ed044 324 *
gkroussos 0:e8fdba0ed044 325 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 326 * @param[in] handle The handle of the attribute to be read.
gkroussos 0:e8fdba0ed044 327 * @param[in] offset Offset into the attribute value to be read.
gkroussos 0:e8fdba0ed044 328 *
gkroussos 0:e8fdba0ed044 329 * @return @ref NRF_SUCCESS Successfully started or resumed the Read (Long) procedure.
gkroussos 0:e8fdba0ed044 330 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 331 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
gkroussos 0:e8fdba0ed044 332 * @return @ref NRF_ERROR_BUSY Client procedure already in progress.
gkroussos 0:e8fdba0ed044 333 */
gkroussos 0:e8fdba0ed044 334 SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset));
gkroussos 0:e8fdba0ed044 335
gkroussos 0:e8fdba0ed044 336
gkroussos 0:e8fdba0ed044 337 /**@brief Initiate a GATT Read Multiple Characteristic Values procedure.
gkroussos 0:e8fdba0ed044 338 *
gkroussos 0:e8fdba0ed044 339 * @details This function initiates a GATT Read Multiple Characteristic Values procedure.
gkroussos 0:e8fdba0ed044 340 *
gkroussos 0:e8fdba0ed044 341 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 342 * @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read.
gkroussos 0:e8fdba0ed044 343 * @param[in] handle_count The number of handles in p_handles.
gkroussos 0:e8fdba0ed044 344 *
gkroussos 0:e8fdba0ed044 345 * @return @ref NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure.
gkroussos 0:e8fdba0ed044 346 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 347 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
gkroussos 0:e8fdba0ed044 348 * @return @ref NRF_ERROR_BUSY Client procedure already in progress.
gkroussos 0:e8fdba0ed044 349 */
gkroussos 0:e8fdba0ed044 350 SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const * const p_handles, uint16_t handle_count));
gkroussos 0:e8fdba0ed044 351
gkroussos 0:e8fdba0ed044 352
gkroussos 0:e8fdba0ed044 353 /**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure.
gkroussos 0:e8fdba0ed044 354 *
gkroussos 0:e8fdba0ed044 355 * @details This function can perform all write procedures described in GATT.
gkroussos 0:e8fdba0ed044 356 *
gkroussos 0:e8fdba0ed044 357 * @note It is important to note that a write without response will <b>consume an application buffer</b>, and will therefore
gkroussos 0:e8fdba0ed044 358 * generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. A write on the other hand will use the
gkroussos 0:e8fdba0ed044 359 * standard client internal buffer and thus will only generate a @ref BLE_GATTC_EVT_WRITE_RSP event as soon as the write response
gkroussos 0:e8fdba0ed044 360 * has been received from the peer. Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details.
gkroussos 0:e8fdba0ed044 361 *
gkroussos 0:e8fdba0ed044 362 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 363 * @param[in] p_write_params A pointer to a write parameters structure.
gkroussos 0:e8fdba0ed044 364 *
gkroussos 0:e8fdba0ed044 365 * @return @ref NRF_SUCCESS Successfully started the Write procedure.
gkroussos 0:e8fdba0ed044 366 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 367 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
gkroussos 0:e8fdba0ed044 368 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
gkroussos 0:e8fdba0ed044 369 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
gkroussos 0:e8fdba0ed044 370 * @return @ref NRF_ERROR_BUSY Procedure already in progress.
gkroussos 0:e8fdba0ed044 371 * @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers left.
gkroussos 0:e8fdba0ed044 372 */
gkroussos 0:e8fdba0ed044 373 SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const * const p_write_params));
gkroussos 0:e8fdba0ed044 374
gkroussos 0:e8fdba0ed044 375
gkroussos 0:e8fdba0ed044 376 /**@brief Send a Handle Value Confirmation to the GATT Server.
gkroussos 0:e8fdba0ed044 377 *
gkroussos 0:e8fdba0ed044 378 * @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
gkroussos 0:e8fdba0ed044 379 * @param[in] handle The handle of the attribute in the indication.
gkroussos 0:e8fdba0ed044 380 *
gkroussos 0:e8fdba0ed044 381 * @return @ref NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission.
gkroussos 0:e8fdba0ed044 382 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
gkroussos 0:e8fdba0ed044 383 * @return @ref NRF_ERROR_INVALID_STATE No Indication pending to be confirmed.
gkroussos 0:e8fdba0ed044 384 * @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle.
gkroussos 0:e8fdba0ed044 385 * @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers left.
gkroussos 0:e8fdba0ed044 386 */
gkroussos 0:e8fdba0ed044 387 SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle));
gkroussos 0:e8fdba0ed044 388
gkroussos 0:e8fdba0ed044 389
gkroussos 0:e8fdba0ed044 390 #endif /* BLE_GATTC_H__ */
gkroussos 0:e8fdba0ed044 391
gkroussos 0:e8fdba0ed044 392 /**
gkroussos 0:e8fdba0ed044 393 @}
gkroussos 0:e8fdba0ed044 394 @}
gkroussos 0:e8fdba0ed044 395 */