Tas Lab / Mbed 2 deprecated BLE_LightingSwitch

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:24:20 2014 +0000
Revision:
1:48f6e08a3ac2
2014.08.20?????BLE?????????????; ???mbed?????????????????; mbed HRM1017; Nordic nRF51822

Who changed what in which revision?

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