1 /* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24 * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 /** 39 * @title GATT Client 40 * 41 */ 42 43 #ifndef btstack_gatt_client_h 44 #define btstack_gatt_client_h 45 46 #include "hci.h" 47 48 #if defined __cplusplus 49 extern "C" { 50 #endif 51 52 typedef enum { 53 P_READY, 54 P_W2_SEND_SERVICE_QUERY, 55 P_W4_SERVICE_QUERY_RESULT, 56 P_W2_SEND_SERVICE_WITH_UUID_QUERY, 57 P_W4_SERVICE_WITH_UUID_RESULT, 58 59 P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY, 60 P_W4_ALL_CHARACTERISTICS_OF_SERVICE_QUERY_RESULT, 61 P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY, 62 P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT, 63 64 P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY, 65 P_W4_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT, 66 67 P_W2_SEND_INCLUDED_SERVICE_QUERY, 68 P_W4_INCLUDED_SERVICE_QUERY_RESULT, 69 P_W2_SEND_INCLUDED_SERVICE_WITH_UUID_QUERY, 70 P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT, 71 72 P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY, 73 P_W4_READ_CHARACTERISTIC_VALUE_RESULT, 74 75 P_W2_SEND_READ_BLOB_QUERY, 76 P_W4_READ_BLOB_RESULT, 77 78 P_W2_SEND_READ_BY_TYPE_REQUEST, 79 P_W4_READ_BY_TYPE_RESPONSE, 80 81 P_W2_SEND_READ_MULTIPLE_REQUEST, 82 P_W4_READ_MULTIPLE_RESPONSE, 83 84 P_W2_SEND_WRITE_CHARACTERISTIC_VALUE, 85 P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT, 86 87 P_W2_PREPARE_WRITE, 88 P_W4_PREPARE_WRITE_RESULT, 89 P_W2_PREPARE_RELIABLE_WRITE, 90 P_W4_PREPARE_RELIABLE_WRITE_RESULT, 91 92 P_W2_EXECUTE_PREPARED_WRITE, 93 P_W4_EXECUTE_PREPARED_WRITE_RESULT, 94 P_W2_CANCEL_PREPARED_WRITE, 95 P_W4_CANCEL_PREPARED_WRITE_RESULT, 96 P_W2_CANCEL_PREPARED_WRITE_DATA_MISMATCH, 97 P_W4_CANCEL_PREPARED_WRITE_DATA_MISMATCH_RESULT, 98 99 #ifdef ENABLE_GATT_FIND_INFORMATION_FOR_CCC_DISCOVERY 100 P_W2_SEND_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY, 101 P_W4_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT, 102 #else 103 P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY, 104 P_W4_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT, 105 #endif 106 P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION, 107 P_W4_CLIENT_CHARACTERISTIC_CONFIGURATION_RESULT, 108 109 P_W2_SEND_READ_CHARACTERISTIC_DESCRIPTOR_QUERY, 110 P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT, 111 112 P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY, 113 P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT, 114 115 P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR, 116 P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT, 117 118 // all long writes use this 119 P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR, 120 P_W4_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT, 121 P_W2_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR, 122 P_W4_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT, 123 124 // gatt reliable write API use this (manual version of the above) 125 P_W2_PREPARE_WRITE_SINGLE, 126 P_W4_PREPARE_WRITE_SINGLE_RESULT, 127 128 P_W4_IDENTITY_RESOLVING, 129 P_W4_CMAC_READY, 130 P_W4_CMAC_RESULT, 131 P_W2_SEND_SIGNED_WRITE, 132 P_W4_SEND_SINGED_WRITE_DONE, 133 } gatt_client_state_t; 134 135 136 typedef enum{ 137 SEND_MTU_EXCHANGE, 138 SENT_MTU_EXCHANGE, 139 MTU_EXCHANGED, 140 MTU_AUTO_EXCHANGE_DISABLED 141 } gatt_client_mtu_t; 142 143 typedef struct gatt_client{ 144 btstack_linked_item_t item; 145 // TODO: rename gatt_client_state -> state 146 gatt_client_state_t gatt_client_state; 147 148 // user callback 149 btstack_packet_handler_t callback; 150 151 // can write without response callback 152 btstack_packet_handler_t write_without_response_callback; 153 154 hci_con_handle_t con_handle; 155 156 uint16_t mtu; 157 gatt_client_mtu_t mtu_state; 158 159 uint16_t uuid16; 160 uint8_t uuid128[16]; 161 162 uint16_t start_group_handle; 163 uint16_t end_group_handle; 164 165 uint16_t query_start_handle; 166 uint16_t query_end_handle; 167 168 uint8_t characteristic_properties; 169 uint16_t characteristic_start_handle; 170 171 uint16_t attribute_handle; 172 uint16_t attribute_offset; 173 uint16_t attribute_length; 174 uint8_t* attribute_value; 175 176 // read multiple characteristic values 177 uint16_t read_multiple_handle_count; 178 uint16_t * read_multiple_handles; 179 180 uint16_t client_characteristic_configuration_handle; 181 uint8_t client_characteristic_configuration_value[2]; 182 183 uint8_t filter_with_uuid; 184 uint8_t send_confirmation; 185 186 int le_device_index; 187 uint8_t cmac[8]; 188 189 btstack_timer_source_t gc_timeout; 190 191 uint8_t security_counter; 192 uint8_t wait_for_authentication_complete; 193 uint8_t pending_error_code; 194 195 bool reencryption_active; 196 uint8_t reencryption_result; 197 198 gap_security_level_t security_level; 199 200 } gatt_client_t; 201 202 typedef struct gatt_client_notification { 203 btstack_linked_item_t item; 204 btstack_packet_handler_t callback; 205 hci_con_handle_t con_handle; 206 uint16_t attribute_handle; 207 } gatt_client_notification_t; 208 209 /* API_START */ 210 211 typedef struct { 212 uint16_t start_group_handle; 213 uint16_t end_group_handle; 214 uint16_t uuid16; 215 uint8_t uuid128[16]; 216 } gatt_client_service_t; 217 218 typedef struct { 219 uint16_t start_handle; 220 uint16_t value_handle; 221 uint16_t end_handle; 222 uint16_t properties; 223 uint16_t uuid16; 224 uint8_t uuid128[16]; 225 } gatt_client_characteristic_t; 226 227 typedef struct { 228 uint16_t handle; 229 uint16_t uuid16; 230 uint8_t uuid128[16]; 231 } gatt_client_characteristic_descriptor_t; 232 233 /** 234 * @brief Set up GATT client. 235 */ 236 void gatt_client_init(void); 237 238 /** 239 * @brief Set minimum required security level for GATT Client 240 * @note The Bluetooth specification makes the GATT Server responsible to check for security. 241 * This allows an attacker to spoof an existing device with a GATT Servers, but skip the authentication part. 242 * If your application is exchanging sensitive data with a remote device, you would need to manually check 243 * the security level before sending/receive such data. 244 * With level > 0, the GATT Client triggers authentication for all GATT Requests and defers any exchange 245 * until the required security level is established. 246 * gatt_client_request_can_write_without_response_event does not trigger authentication 247 * @pram level, default LEVEL_0 (no encryption required) 248 */ 249 void gatt_client_set_required_security_level(gap_security_level_t level); 250 251 /** 252 * @brief MTU is available after the first query has completed. If status is equal to ERROR_CODE_SUCCESS, it returns the real value, 253 * otherwise the default value ATT_DEFAULT_MTU (see bluetooth.h). 254 * @param con_handle 255 * @param mtu 256 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 257 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 258 * GATT_CLIENT_IN_WRONG_STATE if MTU is not exchanged and MTU auto-exchange is disabled 259 * ERROR_CODE_SUCCESS if query is successfully registered 260 */ 261 uint8_t gatt_client_get_mtu(hci_con_handle_t con_handle, uint16_t * mtu); 262 263 /** 264 * @brief Sets whether a MTU Exchange Request shall be automatically send before the 265 * first attribute read request is send. Default is enabled. 266 * @param enabled 267 */ 268 void gatt_client_mtu_enable_auto_negotiation(uint8_t enabled); 269 270 /** 271 * @brief Sends a MTU Exchange Request, this allows for the client to exchange MTU 272 * when gatt_client_mtu_enable_auto_negotiation is disabled. 273 * @param callback 274 * @param con_handle 275 */ 276 void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 277 278 /** 279 * @brief Returns 1 if the GATT client is ready to receive a query. It is used with daemon. 280 * @param con_handle 281 * @return is_ready_status 0 - if no GATT client for con_handle is found, or is not ready, otherwise 1 282 */ 283 int gatt_client_is_ready(hci_con_handle_t con_handle); 284 285 /** 286 * @brief Discovers all primary services. 287 * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 288 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 289 * @param callback 290 * @param con_handle 291 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 292 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 293 * ERROR_CODE_SUCCESS , if query is successfully registered 294 */ 295 uint8_t gatt_client_discover_primary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 296 297 /** 298 * @brief Discovers all secondary services. 299 * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 300 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 301 * @param callback 302 * @param con_handle 303 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 304 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 305 * ERROR_CODE_SUCCESS , if query is successfully registered 306 */ 307 uint8_t gatt_client_discover_secondary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 308 309 /** 310 * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. 311 * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 312 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 313 * @param callback 314 * @param con_handle 315 * @param uuid16 316 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 317 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 318 * ERROR_CODE_SUCCESS , if query is successfully registered 319 */ 320 uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16); 321 322 /** 323 * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. 324 * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 325 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 326 * @param callback 327 * @param con_handle 328 * @param uuid128 329 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 330 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 331 * ERROR_CODE_SUCCESS , if query is successfully registered 332 */ 333 uint8_t gatt_client_discover_primary_services_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, const uint8_t * uuid128); 334 335 /** 336 * @brief Finds included services within the specified service. 337 * For each found included service a GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT event will be emitted. 338 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 339 * Information about included service type (primary/secondary) can be retrieved either by sending 340 * an ATT find information request for the returned start group handle 341 * (returning the handle and the UUID for primary or secondary service) or by comparing the service 342 * to the list of all primary services. 343 * @param callback 344 * @param con_handle 345 * @param service 346 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 347 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 348 * ERROR_CODE_SUCCESS , if query is successfully registered 349 */ 350 uint8_t gatt_client_find_included_services_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service); 351 352 /** 353 * @brief Discovers all characteristics within the specified service. 354 * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will be emited. 355 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 356 * @param callback 357 * @param con_handle 358 * @param service 359 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 360 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 361 * ERROR_CODE_SUCCESS , if query is successfully registered 362 */ 363 uint8_t gatt_client_discover_characteristics_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service); 364 365 /** 366 * @brief The following four functions are used to discover all characteristics within 367 * the specified service or handle range, and return those that match the given UUID. 368 * 369 * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 370 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 371 * @param callback 372 * @param con_handle 373 * @param start_handle 374 * @param end_handle 375 * @param uuid16 376 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 377 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 378 * ERROR_CODE_SUCCESS , if query is successfully registered 379 */ 380 uint8_t gatt_client_discover_characteristics_for_handle_range_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid16); 381 382 /** 383 * @brief The following four functions are used to discover all characteristics within the 384 * specified service or handle range, and return those that match the given UUID. 385 * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 386 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 387 * @param callback 388 * @param con_handle 389 * @param start_handle 390 * @param end_handle 391 * @param uuid128 392 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 393 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 394 * ERROR_CODE_SUCCESS , if query is successfully registered 395 */ 396 uint8_t gatt_client_discover_characteristics_for_handle_range_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128); 397 398 /** 399 * @brief The following four functions are used to discover all characteristics within the 400 * specified service or handle range, and return those that match the given UUID. 401 * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 402 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 403 * @param callback 404 * @param con_handle 405 * @param service 406 * @param uuid16 407 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 408 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 409 * ERROR_CODE_SUCCESS , if query is successfully registered 410 */ 411 uint8_t gatt_client_discover_characteristics_for_service_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service, uint16_t uuid16); 412 413 /** 414 * @brief The following four functions are used to discover all characteristics within the 415 * specified service or handle range, and return those that match the given UUID. 416 * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 417 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 418 * @param callback 419 * @param con_handle 420 * @param service 421 * @param uuid128 422 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 423 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 424 * ERROR_CODE_SUCCESS , if query is successfully registered 425 */ 426 uint8_t gatt_client_discover_characteristics_for_service_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service, const uint8_t * uuid128); 427 428 /** 429 * @brief Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic. 430 * For each found descriptor a GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT event will be emitted. 431 * 432 * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 433 * @param callback 434 * @param con_handle 435 * @param characteristic 436 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 437 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 438 * ERROR_CODE_SUCCESS , if query is successfully registered 439 */ 440 uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic); 441 442 /** 443 * @brief Reads the characteristic value using the characteristic's value handle. 444 * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 445 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 446 * @param callback 447 * @param con_handle 448 * @param characteristic 449 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 450 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 451 * ERROR_CODE_SUCCESS , if query is successfully registered 452 */ 453 uint8_t gatt_client_read_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic); 454 455 /** 456 * @brief Reads the characteristic value using the characteristic's value handle. 457 * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 458 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 459 * @param callback 460 * @param con_handle 461 * @param value_handle 462 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 463 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 464 * ERROR_CODE_SUCCESS , if query is successfully registered 465 */ 466 uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle); 467 468 /** 469 * @brief Reads the characteric value of all characteristics with the uuid. 470 * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 471 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 472 * @param callback 473 * @param con_handle 474 * @param start_handle 475 * @param end_handle 476 * @param uuid16 477 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 478 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 479 * ERROR_CODE_SUCCESS , if query is successfully registered 480 */ 481 uint8_t gatt_client_read_value_of_characteristics_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid16); 482 483 /** 484 * @brief Reads the characteric value of all characteristics with the uuid. 485 * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 486 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 487 * @param callback 488 * @param con_handle 489 * @param start_handle 490 * @param end_handle 491 * @param uuid128 492 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 493 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 494 * ERROR_CODE_SUCCESS , if query is successfully registered 495 */ 496 uint8_t gatt_client_read_value_of_characteristics_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128); 497 498 /** 499 * @brief Reads the long characteristic value using the characteristic's value handle. 500 * The value will be returned in several blobs. 501 * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 502 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 503 * @param callback 504 * @param con_handle 505 * @param characteristic 506 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 507 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 508 * ERROR_CODE_SUCCESS , if query is successfully registered 509 */ 510 uint8_t gatt_client_read_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic); 511 512 /** 513 * @brief Reads the long characteristic value using the characteristic's value handle. 514 * The value will be returned in several blobs. 515 * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 516 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 517 * @param callback 518 * @param con_handle 519 * @param value_handle 520 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 521 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 522 * ERROR_CODE_SUCCESS , if query is successfully registered 523 */ 524 uint8_t gatt_client_read_long_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle); 525 526 /** 527 * @brief Reads the long characteristic value using the characteristic's value handle. 528 * The value will be returned in several blobs. 529 * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 530 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 531 * @param callback 532 * @param con_handle 533 * @param value_handle 534 * @param offset 535 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 536 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 537 * ERROR_CODE_SUCCESS , if query is successfully registered 538 */ 539 uint8_t gatt_client_read_long_value_of_characteristic_using_value_handle_with_offset(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t offset); 540 541 /* 542 * @brief Read multiple characteristic values. 543 * The all results are emitted via single GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event, 544 * followed by the GATT_EVENT_QUERY_COMPLETE event, which marks the end of read. 545 * @param callback 546 * @param con_handle 547 * @param num_value_handles 548 * @param value_handles list of handles 549 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 550 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 551 * ERROR_CODE_SUCCESS , if query is successfully registered 552 */ 553 uint8_t gatt_client_read_multiple_characteristic_values(btstack_packet_handler_t callback, hci_con_handle_t con_handle, int num_value_handles, uint16_t * value_handles); 554 555 /** 556 * @brief Writes the characteristic value using the characteristic's value handle without 557 * an acknowledgment that the write was successfully performed. 558 * @param con_handle 559 * @param value_handle 560 * @param value_length 561 * @param value is copied on success and does not need to be retained 562 * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 563 * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 564 * BTSTACK_ACL_BUFFERS_FULL , if L2CAP cannot send, there are no free ACL slots 565 * ERROR_CODE_SUCCESS , if query is successfully registered 566 */ 567 uint8_t gatt_client_write_value_of_characteristic_without_response(hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value); 568 569 /** 570 * @brief Writes the authenticated characteristic value using the characteristic's value handle 571 * without an acknowledgment that the write was successfully performed. 572 * @note GATT_EVENT_QUERY_COMPLETE is emitted with ATT_ERROR_SUCCESS for success, 573 * or ATT_ERROR_BONDING_INFORMATION_MISSING if there is no bonding information stored. 574 * @param callback 575 * @param con_handle 576 * @param value_handle 577 * @param message_len 578 * @param message is not copied, make sure memory is accessible until write is done 579 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 580 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 581 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 582 * ERROR_CODE_SUCCESS if query is successfully registered 583 */ 584 uint8_t gatt_client_signed_write_without_response(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t message_len, uint8_t * message); 585 586 /** 587 * @brief Writes the characteristic value using the characteristic's value handle. 588 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 589 * The write is successfully performed, if the event's att_status field is set to 590 * ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 591 * @param callback 592 * @param con_handle 593 * @param value_handle 594 * @param value_length 595 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 596 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 597 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 598 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 599 * ERROR_CODE_SUCCESS if query is successfully registered 600 */ 601 uint8_t gatt_client_write_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value); 602 603 /** 604 * @brief Writes the characteristic value using the characteristic's value handle. 605 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 606 * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 607 * @param callback 608 * @param con_handle 609 * @param value_handle 610 * @param value_length 611 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 612 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 613 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 614 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 615 * ERROR_CODE_SUCCESS if query is successfully registered 616 */ 617 uint8_t gatt_client_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value); 618 619 /** 620 * @brief Writes the characteristic value using the characteristic's value handle. 621 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 622 * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 623 * @param callback 624 * @param con_handle 625 * @param value_handle 626 * @param offset of value 627 * @param value_length 628 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 629 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 630 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 631 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 632 * ERROR_CODE_SUCCESS if query is successfully registered 633 */ 634 uint8_t gatt_client_write_long_value_of_characteristic_with_offset(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t offset, uint16_t value_length, uint8_t * value); 635 636 /** 637 * @brief Writes of the long characteristic value using the characteristic's value handle. 638 * It uses server response to validate that the write was correctly received. 639 * The GATT_EVENT_QUERY_COMPLETE EVENT marks the end of write. 640 * The write is successfully performed, if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 641 * @param callback 642 * @param con_handle 643 * @param value_handle 644 * @param value_length 645 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 646 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 647 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 648 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 649 * ERROR_CODE_SUCCESS if query is successfully registered 650 */ 651 uint8_t gatt_client_reliable_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value); 652 653 /** 654 * @brief Reads the characteristic descriptor using its handle. 655 * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 656 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 657 * @param callback 658 * @param con_handle 659 * @param descriptor 660 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 661 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 662 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 663 * ERROR_CODE_SUCCESS if query is successfully registered 664 */ 665 uint8_t gatt_client_read_characteristic_descriptor(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t * descriptor); 666 667 /** 668 * @brief Reads the characteristic descriptor using its handle. 669 * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 670 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 671 * @param callback 672 * @param con_handle 673 * @param descriptor 674 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 675 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 676 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 677 * ERROR_CODE_SUCCESS if query is successfully registered 678 */ 679 uint8_t gatt_client_read_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle); 680 681 /** 682 * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 683 * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 684 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 685 * @param callback 686 * @param con_handle 687 * @param descriptor 688 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 689 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 690 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 691 * ERROR_CODE_SUCCESS if query is successfully registered 692 */ 693 uint8_t gatt_client_read_long_characteristic_descriptor(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t * descriptor); 694 695 /** 696 * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 697 * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 698 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 699 * @param callback 700 * @param con_handle 701 * @param descriptor_handle 702 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 703 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 704 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 705 * ERROR_CODE_SUCCESS if query is successfully registered 706 */ 707 uint8_t gatt_client_read_long_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle); 708 709 /** 710 * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 711 * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 712 * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 713 * @param callback 714 * @param con_handle 715 * @param descriptor_handle 716 * @param offset 717 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 718 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 719 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 720 * ERROR_CODE_SUCCESS if query is successfully registered 721 */ 722 uint8_t gatt_client_read_long_characteristic_descriptor_using_descriptor_handle_with_offset(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t offset); 723 724 /** 725 * @brief Writes the characteristic descriptor using its handle. 726 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 727 * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 728 * @param callback 729 * @param con_handle 730 * @param descriptor 731 * @param value_length 732 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 733 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 734 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 735 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 736 * ERROR_CODE_SUCCESS if query is successfully registered 737 */ 738 uint8_t gatt_client_write_characteristic_descriptor(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t * descriptor, uint16_t value_length, uint8_t * value); 739 740 /** 741 * @brief Writes the characteristic descriptor using its handle. 742 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 743 * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 744 * @param callback 745 * @param con_handle 746 * @param descriptor_handle 747 * @param value_length 748 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 749 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 750 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 751 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 752 * ERROR_CODE_SUCCESS if query is successfully registered 753 */ 754 uint8_t gatt_client_write_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t value_length, uint8_t * value); 755 756 /** 757 * @brief Writes the characteristic descriptor using its handle. 758 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 759 * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 760 * @param callback 761 * @param con_handle 762 * @param descriptor 763 * @param value_length 764 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 765 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 766 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 767 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 768 * ERROR_CODE_SUCCESS if query is successfully registered 769 */ 770 uint8_t gatt_client_write_long_characteristic_descriptor(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t * descriptor, uint16_t value_length, uint8_t * value); 771 772 /** 773 * @brief Writes the characteristic descriptor using its handle. 774 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 775 * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 776 * @param callback 777 * @param con_handle 778 * @param descriptor_handle 779 * @param value_length 780 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 781 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 782 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 783 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 784 * ERROR_CODE_SUCCESS if query is successfully registered 785 */ 786 uint8_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t value_length, uint8_t * value); 787 788 /** 789 * @brief Writes the characteristic descriptor using its handle. 790 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 791 * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 792 * @param callback 793 * @param con_handle 794 * @param descriptor_handle 795 * @param offset of value 796 * @param value_length 797 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 798 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 799 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 800 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 801 * ERROR_CODE_SUCCESS if query is successfully registered 802 */ 803 uint8_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t offset, uint16_t value_length, uint8_t * value); 804 805 /** 806 * @brief Writes the client characteristic configuration of the specified characteristic. 807 * It is used to subscribe for notifications or indications of the characteristic value. 808 * For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION 809 * resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value. 810 * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 811 * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 812 * @param callback 813 * @param con_handle 814 * @param characteristic 815 * @param configuration GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION, GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION 816 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 817 * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 818 * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 819 * GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED if configuring notification, but characteristic has no notification property set 820 * GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED if configuring indication, but characteristic has no indication property set 821 * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if configuration is invalid 822 * ERROR_CODE_SUCCESS if query is successfully registered 823 */ 824 uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic, uint16_t configuration); 825 826 /** 827 * @brief Register for notifications and indications of a characteristic enabled by 828 * the gatt_client_write_client_characteristic_configuration function. 829 * @param notification struct used to store registration 830 * @param callback 831 * @param con_handle or GATT_CLIENT_ANY_CONNECTION to receive updates from all connected devices 832 * @param characteristic or NULL to receive updates for all characteristics 833 */ 834 void gatt_client_listen_for_characteristic_value_updates(gatt_client_notification_t * notification, btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic); 835 836 /** 837 * @brief Stop listening to characteristic value updates registered with 838 * the gatt_client_listen_for_characteristic_value_updates function. 839 * @param notification struct used in gatt_client_listen_for_characteristic_value_updates 840 */ 841 void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification); 842 843 /** 844 * @brief Requests GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE that guarantees 845 * a single successful gatt_client_write_value_of_characteristic_without_response call. 846 * @param callback 847 * @param con_handle 848 * @return status 849 */ 850 uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 851 852 /** 853 * @brief Transactional write. It can be called as many times as it is needed to write the characteristics within the same transaction. 854 * Call the gatt_client_execute_write function to commit the transaction. 855 * @param callback 856 * @param con_handle 857 * @param attribute_handle 858 * @param offset of value 859 * @param value_length 860 * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 861 */ 862 uint8_t gatt_client_prepare_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint16_t value_length, uint8_t * value); 863 864 /** 865 * @brief Commit transactional write. GATT_EVENT_QUERY_COMPLETE is received. 866 * @param callback 867 * @param con_handle 868 * @return status 869 */ 870 uint8_t gatt_client_execute_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 871 872 /** 873 * @brief Abort transactional write. GATT_EVENT_QUERY_COMPLETE is received. 874 * @param callback 875 * @param con_handle 876 * @return status 877 */ 878 uint8_t gatt_client_cancel_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 879 880 /* API_END */ 881 882 // used by generated btstack_event.c 883 884 void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t * service); 885 void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic); 886 void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor); 887 888 #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 889 void gatt_client_att_packet_handler_fuzz(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size); 890 uint8_t gatt_client_get_client(hci_con_handle_t con_handle, gatt_client_t ** gatt_client); 891 #endif 892 893 #if defined __cplusplus 894 } 895 #endif 896 897 #endif 898