ble_gattc.h 29 KB

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