xref: /btstack/src/ble/gatt_client.h (revision 3503dc74a145a4cdff078364cdca8b8766178fc0)
13deb3ec6SMatthias Ringwald /*
23deb3ec6SMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
33deb3ec6SMatthias Ringwald  *
43deb3ec6SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
53deb3ec6SMatthias Ringwald  * modification, are permitted provided that the following conditions
63deb3ec6SMatthias Ringwald  * are met:
73deb3ec6SMatthias Ringwald  *
83deb3ec6SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
93deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
103deb3ec6SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
113deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
123deb3ec6SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
133deb3ec6SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
143deb3ec6SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
153deb3ec6SMatthias Ringwald  *    from this software without specific prior written permission.
163deb3ec6SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
173deb3ec6SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
183deb3ec6SMatthias Ringwald  *    monetary gain.
193deb3ec6SMatthias Ringwald  *
203deb3ec6SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
213deb3ec6SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
223deb3ec6SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
233deb3ec6SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
243deb3ec6SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
253deb3ec6SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
263deb3ec6SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
273deb3ec6SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
283deb3ec6SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
293deb3ec6SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
303deb3ec6SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
313deb3ec6SMatthias Ringwald  * SUCH DAMAGE.
323deb3ec6SMatthias Ringwald  *
333deb3ec6SMatthias Ringwald  * Please inquire about commercial licensing options at
343deb3ec6SMatthias Ringwald  * [email protected]
353deb3ec6SMatthias Ringwald  *
363deb3ec6SMatthias Ringwald  */
373deb3ec6SMatthias Ringwald 
383deb3ec6SMatthias Ringwald 
393deb3ec6SMatthias Ringwald #ifndef btstack_gatt_client_h
403deb3ec6SMatthias Ringwald #define btstack_gatt_client_h
413deb3ec6SMatthias Ringwald 
423deb3ec6SMatthias Ringwald #include "hci.h"
433deb3ec6SMatthias Ringwald 
443deb3ec6SMatthias Ringwald #if defined __cplusplus
453deb3ec6SMatthias Ringwald extern "C" {
463deb3ec6SMatthias Ringwald #endif
473deb3ec6SMatthias Ringwald 
483deb3ec6SMatthias Ringwald typedef enum {
493deb3ec6SMatthias Ringwald     P_READY,
503deb3ec6SMatthias Ringwald     P_W2_SEND_SERVICE_QUERY,
513deb3ec6SMatthias Ringwald     P_W4_SERVICE_QUERY_RESULT,
523deb3ec6SMatthias Ringwald     P_W2_SEND_SERVICE_WITH_UUID_QUERY,
533deb3ec6SMatthias Ringwald     P_W4_SERVICE_WITH_UUID_RESULT,
543deb3ec6SMatthias Ringwald 
553deb3ec6SMatthias Ringwald     P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY,
563deb3ec6SMatthias Ringwald     P_W4_ALL_CHARACTERISTICS_OF_SERVICE_QUERY_RESULT,
573deb3ec6SMatthias Ringwald     P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY,
583deb3ec6SMatthias Ringwald     P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT,
593deb3ec6SMatthias Ringwald 
603deb3ec6SMatthias Ringwald     P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY,
613deb3ec6SMatthias Ringwald     P_W4_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT,
623deb3ec6SMatthias Ringwald 
633deb3ec6SMatthias Ringwald     P_W2_SEND_INCLUDED_SERVICE_QUERY,
643deb3ec6SMatthias Ringwald     P_W4_INCLUDED_SERVICE_QUERY_RESULT,
653deb3ec6SMatthias Ringwald     P_W2_SEND_INCLUDED_SERVICE_WITH_UUID_QUERY,
663deb3ec6SMatthias Ringwald     P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT,
673deb3ec6SMatthias Ringwald 
683deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY,
693deb3ec6SMatthias Ringwald     P_W4_READ_CHARACTERISTIC_VALUE_RESULT,
703deb3ec6SMatthias Ringwald 
713deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BLOB_QUERY,
723deb3ec6SMatthias Ringwald     P_W4_READ_BLOB_RESULT,
733deb3ec6SMatthias Ringwald 
743deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BY_TYPE_REQUEST,
753deb3ec6SMatthias Ringwald     P_W4_READ_BY_TYPE_RESPONSE,
763deb3ec6SMatthias Ringwald 
773deb3ec6SMatthias Ringwald     P_W2_SEND_READ_MULTIPLE_REQUEST,
783deb3ec6SMatthias Ringwald     P_W4_READ_MULTIPLE_RESPONSE,
793deb3ec6SMatthias Ringwald 
803deb3ec6SMatthias Ringwald     P_W2_SEND_WRITE_CHARACTERISTIC_VALUE,
813deb3ec6SMatthias Ringwald     P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT,
823deb3ec6SMatthias Ringwald 
833deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE,
843deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_RESULT,
853deb3ec6SMatthias Ringwald     P_W2_PREPARE_RELIABLE_WRITE,
863deb3ec6SMatthias Ringwald     P_W4_PREPARE_RELIABLE_WRITE_RESULT,
873deb3ec6SMatthias Ringwald 
883deb3ec6SMatthias Ringwald     P_W2_EXECUTE_PREPARED_WRITE,
893deb3ec6SMatthias Ringwald     P_W4_EXECUTE_PREPARED_WRITE_RESULT,
903deb3ec6SMatthias Ringwald     P_W2_CANCEL_PREPARED_WRITE,
913deb3ec6SMatthias Ringwald     P_W4_CANCEL_PREPARED_WRITE_RESULT,
923deb3ec6SMatthias Ringwald     P_W2_CANCEL_PREPARED_WRITE_DATA_MISMATCH,
933deb3ec6SMatthias Ringwald     P_W4_CANCEL_PREPARED_WRITE_DATA_MISMATCH_RESULT,
943deb3ec6SMatthias Ringwald 
95abdc9fb5SMatthias Ringwald #ifdef ENABLE_GATT_FIND_INFORMATION_FOR_CCC_DISCOVERY
96abdc9fb5SMatthias Ringwald     P_W2_SEND_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY,
97abdc9fb5SMatthias Ringwald     P_W4_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT,
98abdc9fb5SMatthias Ringwald #else
993deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY,
1003deb3ec6SMatthias Ringwald     P_W4_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT,
101abdc9fb5SMatthias Ringwald #endif
1023deb3ec6SMatthias Ringwald     P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION,
1033deb3ec6SMatthias Ringwald     P_W4_CLIENT_CHARACTERISTIC_CONFIGURATION_RESULT,
1043deb3ec6SMatthias Ringwald 
1053deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CHARACTERISTIC_DESCRIPTOR_QUERY,
1063deb3ec6SMatthias Ringwald     P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT,
1073deb3ec6SMatthias Ringwald 
1083deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY,
1093deb3ec6SMatthias Ringwald     P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT,
1103deb3ec6SMatthias Ringwald 
1113deb3ec6SMatthias Ringwald     P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR,
1123deb3ec6SMatthias Ringwald     P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
1133deb3ec6SMatthias Ringwald 
1143deb3ec6SMatthias Ringwald     // all long writes use this
1153deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR,
1163deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
1173deb3ec6SMatthias Ringwald     P_W2_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR,
1183deb3ec6SMatthias Ringwald     P_W4_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
1193deb3ec6SMatthias Ringwald 
1203deb3ec6SMatthias Ringwald     // gatt reliable write API use this (manual version of the above)
1213deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE_SINGLE,
1223deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_SINGLE_RESULT,
1233deb3ec6SMatthias Ringwald 
124793cf6ceSMatthias Ringwald     P_W4_IDENTITY_RESOLVING,
1253deb3ec6SMatthias Ringwald     P_W4_CMAC_READY,
1263deb3ec6SMatthias Ringwald     P_W4_CMAC_RESULT,
1273deb3ec6SMatthias Ringwald     P_W2_SEND_SIGNED_WRITE,
1283deb3ec6SMatthias Ringwald     P_W4_SEND_SINGED_WRITE_DONE,
1293deb3ec6SMatthias Ringwald } gatt_client_state_t;
1303deb3ec6SMatthias Ringwald 
1313deb3ec6SMatthias Ringwald 
1323deb3ec6SMatthias Ringwald typedef enum{
1333deb3ec6SMatthias Ringwald     SEND_MTU_EXCHANGE,
1343deb3ec6SMatthias Ringwald     SENT_MTU_EXCHANGE,
1355cf6c434SJakob Krantz     MTU_EXCHANGED,
1365cf6c434SJakob Krantz     MTU_AUTO_EXCHANGE_DISABLED
1373deb3ec6SMatthias Ringwald } gatt_client_mtu_t;
1383deb3ec6SMatthias Ringwald 
1393deb3ec6SMatthias Ringwald typedef struct gatt_client{
140665d90f2SMatthias Ringwald     btstack_linked_item_t    item;
1413deb3ec6SMatthias Ringwald     // TODO: rename gatt_client_state -> state
1423deb3ec6SMatthias Ringwald     gatt_client_state_t gatt_client_state;
1433deb3ec6SMatthias Ringwald 
1449c662c9bSMatthias Ringwald     // user callback
1459c662c9bSMatthias Ringwald     btstack_packet_handler_t callback;
1463deb3ec6SMatthias Ringwald 
14747181045SMatthias Ringwald     // can write without response callback
14847181045SMatthias Ringwald     btstack_packet_handler_t write_without_response_callback;
14947181045SMatthias Ringwald 
150fc64f94aSMatthias Ringwald     hci_con_handle_t con_handle;
151f4b33574SMatthias Ringwald 
1523deb3ec6SMatthias Ringwald     uint16_t          mtu;
1533deb3ec6SMatthias Ringwald     gatt_client_mtu_t mtu_state;
1543deb3ec6SMatthias Ringwald 
1553deb3ec6SMatthias Ringwald     uint16_t uuid16;
1563deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
1573deb3ec6SMatthias Ringwald 
1583deb3ec6SMatthias Ringwald     uint16_t start_group_handle;
1593deb3ec6SMatthias Ringwald     uint16_t end_group_handle;
1603deb3ec6SMatthias Ringwald 
1613deb3ec6SMatthias Ringwald     uint16_t query_start_handle;
1623deb3ec6SMatthias Ringwald     uint16_t query_end_handle;
1633deb3ec6SMatthias Ringwald 
1643deb3ec6SMatthias Ringwald     uint8_t  characteristic_properties;
1653deb3ec6SMatthias Ringwald     uint16_t characteristic_start_handle;
1663deb3ec6SMatthias Ringwald 
1673deb3ec6SMatthias Ringwald     uint16_t attribute_handle;
1683deb3ec6SMatthias Ringwald     uint16_t attribute_offset;
1693deb3ec6SMatthias Ringwald     uint16_t attribute_length;
1703deb3ec6SMatthias Ringwald     uint8_t* attribute_value;
1713deb3ec6SMatthias Ringwald 
1723deb3ec6SMatthias Ringwald     // read multiple characteristic values
1733deb3ec6SMatthias Ringwald     uint16_t    read_multiple_handle_count;
1743deb3ec6SMatthias Ringwald     uint16_t  * read_multiple_handles;
1753deb3ec6SMatthias Ringwald 
1763deb3ec6SMatthias Ringwald     uint16_t client_characteristic_configuration_handle;
1773deb3ec6SMatthias Ringwald     uint8_t  client_characteristic_configuration_value[2];
1783deb3ec6SMatthias Ringwald 
1793deb3ec6SMatthias Ringwald     uint8_t  filter_with_uuid;
1803deb3ec6SMatthias Ringwald     uint8_t  send_confirmation;
1813deb3ec6SMatthias Ringwald 
1823deb3ec6SMatthias Ringwald     int      le_device_index;
1833deb3ec6SMatthias Ringwald     uint8_t  cmac[8];
1843deb3ec6SMatthias Ringwald 
185ec820d77SMatthias Ringwald     btstack_timer_source_t gc_timeout;
186f4b33574SMatthias Ringwald 
187f4b33574SMatthias Ringwald     uint8_t  security_counter;
188*3503dc74SMatthias Ringwald     uint8_t  wait_for_authentication_complete;
189f4b33574SMatthias Ringwald     uint8_t  pending_error_code;
190f4b33574SMatthias Ringwald 
1918918bbdaSMatthias Ringwald     bool     reencryption_active;
1928918bbdaSMatthias Ringwald     uint8_t  reencryption_result;
1938918bbdaSMatthias Ringwald 
1941dfae9c7SMatthias Ringwald     gap_security_level_t security_level;
1951dfae9c7SMatthias Ringwald 
1963deb3ec6SMatthias Ringwald } gatt_client_t;
1973deb3ec6SMatthias Ringwald 
1989c662c9bSMatthias Ringwald typedef struct gatt_client_notification {
199665d90f2SMatthias Ringwald     btstack_linked_item_t    item;
200b6e96f14SMatthias Ringwald     btstack_packet_handler_t callback;
201711e6c80SMatthias Ringwald     hci_con_handle_t con_handle;
2029c662c9bSMatthias Ringwald     uint16_t attribute_handle;
2039c662c9bSMatthias Ringwald } gatt_client_notification_t;
2043deb3ec6SMatthias Ringwald 
2053deb3ec6SMatthias Ringwald /* API_START */
2063deb3ec6SMatthias Ringwald 
207d25c33e5SMatthias Ringwald typedef struct {
2083deb3ec6SMatthias Ringwald     uint16_t start_group_handle;
2093deb3ec6SMatthias Ringwald     uint16_t end_group_handle;
2103deb3ec6SMatthias Ringwald     uint16_t uuid16;
2113deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
212d25c33e5SMatthias Ringwald } gatt_client_service_t;
2133deb3ec6SMatthias Ringwald 
214d25c33e5SMatthias Ringwald typedef struct {
2153deb3ec6SMatthias Ringwald     uint16_t start_handle;
2163deb3ec6SMatthias Ringwald     uint16_t value_handle;
2173deb3ec6SMatthias Ringwald     uint16_t end_handle;
2183deb3ec6SMatthias Ringwald     uint16_t properties;
2193deb3ec6SMatthias Ringwald     uint16_t uuid16;
2203deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
221d25c33e5SMatthias Ringwald } gatt_client_characteristic_t;
2223deb3ec6SMatthias Ringwald 
223d25c33e5SMatthias Ringwald typedef struct {
2243deb3ec6SMatthias Ringwald     uint16_t handle;
2253deb3ec6SMatthias Ringwald     uint16_t uuid16;
2263deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
227d25c33e5SMatthias Ringwald } gatt_client_characteristic_descriptor_t;
2283deb3ec6SMatthias Ringwald 
2293deb3ec6SMatthias Ringwald /**
2303deb3ec6SMatthias Ringwald  * @brief Set up GATT client.
2313deb3ec6SMatthias Ringwald  */
2323deb3ec6SMatthias Ringwald void gatt_client_init(void);
2333deb3ec6SMatthias Ringwald 
2343deb3ec6SMatthias Ringwald /**
23511279da7SMatthias Ringwald  * @brief Set minimum required security level for GATT Client
23611279da7SMatthias Ringwald  * @note  The Bluetooth specification makes the GATT Server responsible to check for security.
23711279da7SMatthias Ringwald  *        This allows an attacker to spoof existing devices with GATT Servers, but skip the authentication part
23811279da7SMatthias Ringwald  *        If your application is exchanging sensitive data from a remote device, you would need to manually check
23911279da7SMatthias Ringwald  *        the security level before sending/receive such data. This function allows to have the GATT Client post-pone
24011279da7SMatthias Ringwald  *        any exchange until the required security level is established.
24111279da7SMatthias Ringwald  *  @pram level, default LEVEL_0 (no encryption required)
24211279da7SMatthias Ringwald  */
24311279da7SMatthias Ringwald void gatt_client_set_required_security_level(gap_security_level_t level);
24411279da7SMatthias Ringwald 
24511279da7SMatthias Ringwald /**
246692bf1adSMilanka Ringwald  * @brief MTU is available after the first query has completed. If status is equal to ERROR_CODE_SUCCESS, it returns the real value, otherwise the default value ATT_DEFAULT_MTU (see bluetooth.h).
2476da84376SMilanka Ringwald  * @param  con_handle
2486da84376SMilanka Ringwald  * @param  mtu
249692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
250692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if MTU is not exchanged and MTU auto-exchange is disabled
251692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
2523deb3ec6SMatthias Ringwald  */
253fc64f94aSMatthias Ringwald uint8_t gatt_client_get_mtu(hci_con_handle_t con_handle, uint16_t * mtu);
2543deb3ec6SMatthias Ringwald 
2553deb3ec6SMatthias Ringwald /**
2566da84376SMilanka Ringwald  * @brief Sets whether a MTU Exchange Request shall be automatically send before the first attribute read request is send. Default is enabled.
2576da84376SMilanka Ringwald  * @param enabled
2585cf6c434SJakob Krantz  */
2595cf6c434SJakob Krantz void gatt_client_mtu_enable_auto_negotiation(uint8_t enabled);
2605cf6c434SJakob Krantz 
2615cf6c434SJakob Krantz /**
2625cf6c434SJakob Krantz * @brief Sends a MTU Exchange Request, this allows for the client to exchange MTU when gatt_client_mtu_enable_auto_negotiation is disabled.
2636da84376SMilanka Ringwald  * @param  callback
2646da84376SMilanka Ringwald  * @param  con_handle
2655cf6c434SJakob Krantz  */
2665cf6c434SJakob Krantz void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
2675cf6c434SJakob Krantz 
2685cf6c434SJakob Krantz /**
2693deb3ec6SMatthias Ringwald  * @brief Returns if the GATT client is ready to receive a query. It is used with daemon.
2706da84376SMilanka Ringwald  * @param  con_handle
271692bf1adSMilanka Ringwald  * @return is_ready_status     0 - if no GATT client for con_handle is found, or is not ready, otherwise 1
2723deb3ec6SMatthias Ringwald  */
273fc64f94aSMatthias Ringwald int gatt_client_is_ready(hci_con_handle_t con_handle);
2743deb3ec6SMatthias Ringwald 
2753deb3ec6SMatthias Ringwald /**
2765611a760SMatthias Ringwald  * @brief Discovers all primary services. For each found service, an le_service_event_t with type set to GATT_EVENT_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t, with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
2776da84376SMilanka Ringwald  * @param  callback
2786da84376SMilanka Ringwald  * @param  con_handle
279692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
280692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
281692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
2823deb3ec6SMatthias Ringwald  */
283711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
2843deb3ec6SMatthias Ringwald 
2853deb3ec6SMatthias Ringwald /**
2865611a760SMatthias Ringwald  * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. For each found service, an le_service_event_t with type set to GATT_EVENT_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t, with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
2876da84376SMilanka Ringwald  * @param callback
2886da84376SMilanka Ringwald  * @param con_handle
2896da84376SMilanka Ringwald  * @param uuid16
290692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
291692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
292692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
2933deb3ec6SMatthias Ringwald  */
294711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16);
2956da84376SMilanka Ringwald 
2966da84376SMilanka Ringwald /**
2976da84376SMilanka Ringwald  * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. For each found service, an le_service_event_t with type set to GATT_EVENT_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t, with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
2986da84376SMilanka Ringwald  * @param  callback
2996da84376SMilanka Ringwald  * @param  con_handle
3006da84376SMilanka Ringwald  * @param  uuid128
301692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
302692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
303692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3046da84376SMilanka Ringwald  */
3056da84376SMilanka Ringwald uint8_t gatt_client_discover_primary_services_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, const uint8_t  * uuid128);
3063deb3ec6SMatthias Ringwald 
3073deb3ec6SMatthias Ringwald /**
3085611a760SMatthias Ringwald  * @brief Finds included services within the specified service. For each found included service, an le_service_event_t with type set to GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery. Information about included service type (primary/secondary) can be retrieved either by sending an ATT find information request for the returned start group handle (returning the handle and the UUID for primary or secondary service) or by comparing the service to the list of all primary services.
3096da84376SMilanka Ringwald  * @param  callback
3106da84376SMilanka Ringwald  * @param  con_handle
3116da84376SMilanka Ringwald  * @param  service
312692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
313692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
314692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3153deb3ec6SMatthias Ringwald  */
316711e6c80SMatthias Ringwald 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);
3173deb3ec6SMatthias Ringwald 
3183deb3ec6SMatthias Ringwald /**
3195611a760SMatthias Ringwald  * @brief Discovers all characteristics within the specified service. For each found characteristic, an le_characteristics_event_t with type set to GATT_EVENT_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
3206da84376SMilanka Ringwald  * @param  callback
3216da84376SMilanka Ringwald  * @param  con_handle
3226da84376SMilanka Ringwald  * @param  service
323692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
324692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
325692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3263deb3ec6SMatthias Ringwald  */
327711e6c80SMatthias Ringwald uint8_t gatt_client_discover_characteristics_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t  *service);
3283deb3ec6SMatthias Ringwald 
3293deb3ec6SMatthias Ringwald /**
3305611a760SMatthias Ringwald  * @brief The following four functions are used to discover all characteristics within the specified service or handle range, and return those that match the given UUID. For each found characteristic, an le_characteristic_event_t with type set to GATT_EVENT_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
3316da84376SMilanka Ringwald  * @param  callback
3326da84376SMilanka Ringwald  * @param  con_handle
3336da84376SMilanka Ringwald  * @param  start_handle
3346da84376SMilanka Ringwald  * @param  end_handle
3356da84376SMilanka Ringwald  * @param  uuid16
336692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
337692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
338692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3393deb3ec6SMatthias Ringwald  */
340711e6c80SMatthias Ringwald 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);
3416da84376SMilanka Ringwald 
3426da84376SMilanka Ringwald /**
3436da84376SMilanka Ringwald  * @brief The following four functions are used to discover all characteristics within the specified service or handle range, and return those that match the given UUID. For each found characteristic, an le_characteristic_event_t with type set to GATT_EVENT_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
3446da84376SMilanka Ringwald  * @param  callback
3456da84376SMilanka Ringwald  * @param  con_handle
3466da84376SMilanka Ringwald  * @param  start_handle
3476da84376SMilanka Ringwald  * @param  end_handle
3486da84376SMilanka Ringwald  * @param  uuid128
349692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
350692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
351692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3526da84376SMilanka Ringwald  */
3536da84376SMilanka Ringwald 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, uint8_t  * uuid128);
3546da84376SMilanka Ringwald 
3556da84376SMilanka Ringwald /**
3566da84376SMilanka Ringwald  * @brief The following four functions are used to discover all characteristics within the specified service or handle range, and return those that match the given UUID. For each found characteristic, an le_characteristic_event_t with type set to GATT_EVENT_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
3576da84376SMilanka Ringwald  * @param  callback
3586da84376SMilanka Ringwald  * @param  con_handle
3596da84376SMilanka Ringwald  * @param  service
3606da84376SMilanka Ringwald  * @param  uuid16
361692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
362692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
363692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3646da84376SMilanka Ringwald  */
365711e6c80SMatthias Ringwald 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);
3666da84376SMilanka Ringwald 
3676da84376SMilanka Ringwald /**
3686da84376SMilanka Ringwald  * @brief The following four functions are used to discover all characteristics within the specified service or handle range, and return those that match the given UUID. For each found characteristic, an le_characteristic_event_t with type set to GATT_EVENT_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
3696da84376SMilanka Ringwald  * @param  callback
3706da84376SMilanka Ringwald  * @param  con_handle
3716da84376SMilanka Ringwald  * @param  service
3726da84376SMilanka Ringwald  * @param  uuid128
373692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
374692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
375692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3766da84376SMilanka Ringwald  */
377711e6c80SMatthias Ringwald 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, uint8_t  * uuid128);
3783deb3ec6SMatthias Ringwald 
3793deb3ec6SMatthias Ringwald /**
3805611a760SMatthias Ringwald  * @brief Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic. For each found descriptor, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of discovery.
3816da84376SMilanka Ringwald  * @param  callback
3826da84376SMilanka Ringwald  * @param  con_handle
3836da84376SMilanka Ringwald  * @param  characteristic
384692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
385692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
386692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3873deb3ec6SMatthias Ringwald  */
388711e6c80SMatthias Ringwald uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t  *characteristic);
3893deb3ec6SMatthias Ringwald 
3903deb3ec6SMatthias Ringwald /**
3915611a760SMatthias Ringwald  * @brief Reads the characteristic value using the characteristic's value handle. If the characteristic value is found, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
3926da84376SMilanka Ringwald  * @param  callback
3936da84376SMilanka Ringwald  * @param  con_handle
3946da84376SMilanka Ringwald  * @param  characteristic
395692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
396692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
397692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3983deb3ec6SMatthias Ringwald  */
399711e6c80SMatthias Ringwald uint8_t gatt_client_read_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t  *characteristic);
4006da84376SMilanka Ringwald 
4016da84376SMilanka Ringwald /**
4026da84376SMilanka Ringwald  * @brief Reads the characteristic value using the characteristic's value handle. If the characteristic value is found, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
4036da84376SMilanka Ringwald  * @param  callback
4046da84376SMilanka Ringwald  * @param  con_handle
4056da84376SMilanka Ringwald  * @param  characteristic_value_handle
406692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
407692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
408692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4096da84376SMilanka Ringwald  */
410711e6c80SMatthias Ringwald uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle);
4113deb3ec6SMatthias Ringwald 
4123deb3ec6SMatthias Ringwald /**
4135611a760SMatthias Ringwald  * @brief Reads the characteric value of all characteristics with the uuid. For each found, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
4146da84376SMilanka Ringwald  * @param  callback
4156da84376SMilanka Ringwald  * @param  con_handle
4166da84376SMilanka Ringwald  * @param  start_handle
4176da84376SMilanka Ringwald  * @param  end_handle
4186da84376SMilanka Ringwald  * @param  uuid16
419692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
420692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
421692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4223deb3ec6SMatthias Ringwald  */
423711e6c80SMatthias Ringwald 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);
4246da84376SMilanka Ringwald 
4256da84376SMilanka Ringwald /**
4266da84376SMilanka Ringwald  * @brief Reads the characteric value of all characteristics with the uuid. For each found, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
4276da84376SMilanka Ringwald  * @param  callback
4286da84376SMilanka Ringwald  * @param  con_handle
4296da84376SMilanka Ringwald  * @param  start_handle
4306da84376SMilanka Ringwald  * @param  end_handle
4316da84376SMilanka Ringwald  * @param  uuid128
432692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
433692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
434692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4356da84376SMilanka Ringwald  */
436711e6c80SMatthias Ringwald 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, uint8_t * uuid128);
4373deb3ec6SMatthias Ringwald 
4383deb3ec6SMatthias Ringwald /**
4395611a760SMatthias Ringwald  * @brief Reads the long characteristic value using the characteristic's value handle. The value will be returned in several blobs. For each blob, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT and updated value offset will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, mark the end of read.
4406da84376SMilanka Ringwald  * @param  callback
4416da84376SMilanka Ringwald  * @param  con_handle
4426da84376SMilanka Ringwald  * @param  characteristic
443692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
444692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
445692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4463deb3ec6SMatthias Ringwald  */
447711e6c80SMatthias Ringwald 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);
4486da84376SMilanka Ringwald 
4496da84376SMilanka Ringwald /**
4506da84376SMilanka Ringwald  * @brief Reads the long characteristic value using the characteristic's value handle. The value will be returned in several blobs. For each blob, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT and updated value offset will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, mark the end of read.
4516da84376SMilanka Ringwald  * @param  callback
4526da84376SMilanka Ringwald  * @param  con_handle
4536da84376SMilanka Ringwald  * @param  characteristic_value_handle
454692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
455692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
456692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4576da84376SMilanka Ringwald  */
458711e6c80SMatthias Ringwald 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 characteristic_value_handle);
4596da84376SMilanka Ringwald 
4606da84376SMilanka Ringwald /**
4616da84376SMilanka Ringwald  * @brief Reads the long characteristic value using the characteristic's value handle. The value will be returned in several blobs. For each blob, an le_characteristic_value_event_t with type set to GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT and updated value offset will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, mark the end of read.
4626da84376SMilanka Ringwald  * @param  callback
4636da84376SMilanka Ringwald  * @param  con_handle
4646da84376SMilanka Ringwald  * @param  characteristic_value_handle
4656da84376SMilanka Ringwald  * @param  offset
466692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
467692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
468692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4696da84376SMilanka Ringwald  */
470711e6c80SMatthias Ringwald 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 characteristic_value_handle, uint16_t offset);
4713deb3ec6SMatthias Ringwald 
4723deb3ec6SMatthias Ringwald /*
4733deb3ec6SMatthias Ringwald  * @brief Read multiple characteristic values
4746da84376SMilanka Ringwald  * @param  callback
4756da84376SMilanka Ringwald  * @param  con_handle
4766da84376SMilanka Ringwald  * @param  num_value_handles
4776da84376SMilanka Ringwald  * @param  value_handles list of handles
4783deb3ec6SMatthias Ringwald  */
479711e6c80SMatthias Ringwald 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);
4803deb3ec6SMatthias Ringwald 
4813deb3ec6SMatthias Ringwald /**
4823deb3ec6SMatthias Ringwald  * @brief Writes the characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed.
4836da84376SMilanka Ringwald  * @param  con_handle
4846da84376SMilanka Ringwald  * @param  characteristic_value_handle
4856da84376SMilanka Ringwald  * @param  length of data
4866da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done
487692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
488692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
489692bf1adSMilanka Ringwald  *                BTSTACK_ACL_BUFFERS_FULL   , if L2CAP cannot send, there are no free ACL slots
490692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4913deb3ec6SMatthias Ringwald  */
492830ec672SMatthias Ringwald uint8_t gatt_client_write_value_of_characteristic_without_response(hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t  * data);
4933deb3ec6SMatthias Ringwald 
4943deb3ec6SMatthias Ringwald /**
4953deb3ec6SMatthias Ringwald  * @brief Writes the authenticated characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed.
4967e656a40SMatthias Ringwald  * @note GATT_EVENT_QUERY_COMPLETE is emitted with 0 for success or ATT_ERROR_BONDING_INFORMATION_MISSING if there is no bonding information stored
4976da84376SMilanka Ringwald  * @param  callback
4986da84376SMilanka Ringwald  * @param  con_handle
4996da84376SMilanka Ringwald  * @param  value_handle
5006da84376SMilanka Ringwald  * @param  message_len
5016da84376SMilanka Ringwald  * @param  message is not copied, make sure memory is accessible until write is done
502692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
503692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
504692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5053deb3ec6SMatthias Ringwald  */
5066da84376SMilanka Ringwald 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);
5073deb3ec6SMatthias Ringwald 
5083deb3ec6SMatthias Ringwald /**
509b7e5512fSMilanka Ringwald  * @brief Writes the characteristic value using the characteristic's value handle. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. 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).
5106da84376SMilanka Ringwald  * @param  callback
5116da84376SMilanka Ringwald  * @param  con_handle
5126da84376SMilanka Ringwald  * @param  characteristic_value_handle
5136da84376SMilanka Ringwald  * @param  length of data
5146da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
515692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
516692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
517692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5183deb3ec6SMatthias Ringwald  */
519711e6c80SMatthias Ringwald uint8_t gatt_client_write_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t  * data);
5206da84376SMilanka Ringwald 
5216da84376SMilanka Ringwald /**
522b7e5512fSMilanka Ringwald  * @brief Writes the characteristic value using the characteristic's value handle. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. 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).
5236da84376SMilanka Ringwald  * @param  callback
5246da84376SMilanka Ringwald  * @param  con_handle
5256da84376SMilanka Ringwald  * @param  characteristic_value_handle
5266da84376SMilanka Ringwald  * @param  length of data
5276da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
528692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
529692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
530692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5316da84376SMilanka Ringwald  */
532711e6c80SMatthias Ringwald uint8_t gatt_client_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t  * data);
5336da84376SMilanka Ringwald 
5346da84376SMilanka Ringwald /**
535b7e5512fSMilanka Ringwald  * @brief Writes the characteristic value using the characteristic's value handle. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. 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).
5366da84376SMilanka Ringwald  * @param  callback
5376da84376SMilanka Ringwald  * @param  con_handle
5386da84376SMilanka Ringwald  * @param  characteristic_value_handle
5396da84376SMilanka Ringwald  * @param  offset of value
5406da84376SMilanka Ringwald  * @param  length of data
5416da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
542692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
543692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
544692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5456da84376SMilanka Ringwald  */
546711e6c80SMatthias Ringwald uint8_t gatt_client_write_long_value_of_characteristic_with_offset(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t offset, uint16_t length, uint8_t  * data);
5473deb3ec6SMatthias Ringwald 
5483deb3ec6SMatthias Ringwald /**
549b7e5512fSMilanka Ringwald  * @brief Writes of the long characteristic value using the characteristic's value handle. It uses server response to validate that the write was correctly received. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE marks the end of write. 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).
5506da84376SMilanka Ringwald  * @param  callback
5516da84376SMilanka Ringwald  * @param  con_handle
5526da84376SMilanka Ringwald  * @param  characteristic_value_handle
5536da84376SMilanka Ringwald  * @param  length of data
5546da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
555692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
556692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
557692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5583deb3ec6SMatthias Ringwald  */
559711e6c80SMatthias Ringwald uint8_t gatt_client_reliable_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t  * data);
5603deb3ec6SMatthias Ringwald 
5613deb3ec6SMatthias Ringwald /**
5625611a760SMatthias Ringwald  * @brief Reads the characteristic descriptor using its handle. If the characteristic descriptor is found, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
5636da84376SMilanka Ringwald  * @param  callback
5646da84376SMilanka Ringwald  * @param  con_handle
5656da84376SMilanka Ringwald  * @param  descriptor
566692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
567692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
568692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5693deb3ec6SMatthias Ringwald  */
570711e6c80SMatthias Ringwald uint8_t gatt_client_read_characteristic_descriptor(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t  * descriptor);
5716da84376SMilanka Ringwald 
5726da84376SMilanka Ringwald /**
5736da84376SMilanka Ringwald  * @brief Reads the characteristic descriptor using its handle. If the characteristic descriptor is found, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
5746da84376SMilanka Ringwald  * @param  callback
5756da84376SMilanka Ringwald  * @param  con_handle
5766da84376SMilanka Ringwald  * @param  descriptor
577692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
578692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
579692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5806da84376SMilanka Ringwald  */
581711e6c80SMatthias Ringwald 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);
5823deb3ec6SMatthias Ringwald 
5833deb3ec6SMatthias Ringwald /**
5845611a760SMatthias Ringwald  * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. For each blob, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
5856da84376SMilanka Ringwald  * @param  callback
5866da84376SMilanka Ringwald  * @param  con_handle
5876da84376SMilanka Ringwald  * @param  descriptor_handle
588692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
589692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
590692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5913deb3ec6SMatthias Ringwald  */
592711e6c80SMatthias Ringwald 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);
5936da84376SMilanka Ringwald 
5946da84376SMilanka Ringwald /**
5956da84376SMilanka Ringwald  * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. For each blob, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
5966da84376SMilanka Ringwald  * @param  callback
5976da84376SMilanka Ringwald  * @param  con_handle
5986da84376SMilanka Ringwald  * @param  descriptor_handle
599692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
600692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
601692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6026da84376SMilanka Ringwald  */
603711e6c80SMatthias Ringwald 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);
6046da84376SMilanka Ringwald 
6056da84376SMilanka Ringwald /**
6066da84376SMilanka Ringwald  * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. For each blob, an le_characteristic_descriptor_event_t with type set to GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of read.
6076da84376SMilanka Ringwald  * @param  callback
6086da84376SMilanka Ringwald  * @param  con_handle
6096da84376SMilanka Ringwald  * @param  descriptor_handle
6106da84376SMilanka Ringwald  * @param  offset
611692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
612692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
613692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6146da84376SMilanka Ringwald  */
615711e6c80SMatthias Ringwald 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);
6163deb3ec6SMatthias Ringwald 
6173deb3ec6SMatthias Ringwald /**
618b7e5512fSMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. 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).
6196da84376SMilanka Ringwald  * @param  callback
6206da84376SMilanka Ringwald  * @param  con_handle
6216da84376SMilanka Ringwald  * @param  descriptor
6226da84376SMilanka Ringwald  * @param  length of data
6236da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
624692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
625692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
626692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6273deb3ec6SMatthias Ringwald  */
628711e6c80SMatthias Ringwald 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 length, uint8_t  * data);
6296da84376SMilanka Ringwald 
6306da84376SMilanka Ringwald /**
631b7e5512fSMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. 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).
6326da84376SMilanka Ringwald  * @param  callback
6336da84376SMilanka Ringwald  * @param  con_handle
6346da84376SMilanka Ringwald  * @param  descriptor_handle
6356da84376SMilanka Ringwald  * @param  length of data
6366da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
637692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
638692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
639692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6406da84376SMilanka Ringwald  */
641711e6c80SMatthias Ringwald 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 length, uint8_t  * data);
6426da84376SMilanka Ringwald 
6436da84376SMilanka Ringwald /**
644b7e5512fSMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. 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).
6456da84376SMilanka Ringwald  * @param  callback
6466da84376SMilanka Ringwald  * @param  con_handle
6476da84376SMilanka Ringwald  * @param  descriptor
6486da84376SMilanka Ringwald  * @param  length of data
6496da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
650692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
651692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
652692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6536da84376SMilanka Ringwald  */
654711e6c80SMatthias Ringwald 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 length, uint8_t  * data);
6556da84376SMilanka Ringwald 
6566da84376SMilanka Ringwald /**
657b7e5512fSMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. 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).
6586da84376SMilanka Ringwald  * @param  callback
6596da84376SMilanka Ringwald  * @param  con_handle
6606da84376SMilanka Ringwald  * @param  descriptor_handle
6616da84376SMilanka Ringwald  * @param  length of data
6626da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
663692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
664692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
665692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6666da84376SMilanka Ringwald  */
667711e6c80SMatthias Ringwald 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 length, uint8_t  * data);
6686da84376SMilanka Ringwald 
6696da84376SMilanka Ringwald /**
670b7e5512fSMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle. The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. 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).
6716da84376SMilanka Ringwald  * @param  callback
6726da84376SMilanka Ringwald  * @param  con_handle
6736da84376SMilanka Ringwald  * @param  descriptor_handle
6746da84376SMilanka Ringwald  * @param  offset of value
6756da84376SMilanka Ringwald  * @param  length of data
6766da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
677692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
678692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
679692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6806da84376SMilanka Ringwald  */
681711e6c80SMatthias Ringwald 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 length, uint8_t  * data);
6823deb3ec6SMatthias Ringwald 
6833deb3ec6SMatthias Ringwald /**
684b7e5512fSMilanka Ringwald  * @brief Writes the client characteristic configuration of the specified characteristic. It is used to subscribe for notifications or indications of the characteristic value.
685b7e5512fSMilanka Ringwald  * For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value.
686b7e5512fSMilanka Ringwald  * The gatt_complete_event_t with type set to GATT_EVENT_QUERY_COMPLETE, marks the end of write. The write is successfully performed, if the event's att_status field is set to ATT_ERROR_SUCCESS
687b7e5512fSMilanka Ringwald  * (see bluetooth.h for ATT_ERROR codes).
6886da84376SMilanka Ringwald  * @param  callback
6896da84376SMilanka Ringwald  * @param  con_handle
6906da84376SMilanka Ringwald  * @param  characteristic
691b7e5512fSMilanka Ringwald  * @param  configuration                                                    GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION, GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION
692b7e5512fSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle is found
693692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
694b7e5512fSMilanka Ringwald  *                GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED     if configuring notification, but characteristic has no notification property set
695b7e5512fSMilanka Ringwald  *                GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED       if configuring indication, but characteristic has no indication property set
6966b04f675SMilanka Ringwald  *                ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE         if configuration is invalid
697b7e5512fSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6983deb3ec6SMatthias Ringwald  */
699711e6c80SMatthias Ringwald 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);
7009c662c9bSMatthias Ringwald 
7019c662c9bSMatthias Ringwald /**
7029c662c9bSMatthias Ringwald  * @brief Register for notifications and indications of a characteristic enabled by gatt_client_write_client_characteristic_configuration
7039c662c9bSMatthias Ringwald  * @param notification struct used to store registration
7046da84376SMilanka Ringwald  * @param callback
705b3f03c84SMatthias Ringwald  * @param con_handle or GATT_CLIENT_ANY_CONNECTION to receive updates from all connected devices
706b3f03c84SMatthias Ringwald  * @param characteristic or NULL to receive updates for all characteristics
7079c662c9bSMatthias Ringwald  */
7086da84376SMilanka Ringwald 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);
7093deb3ec6SMatthias Ringwald 
7103deb3ec6SMatthias Ringwald /**
7111f734b5fSMatthias Ringwald  * @brief Stop listening to characteristic value updates registered with gatt_client_listen_for_characteristic_value_updates
7121f734b5fSMatthias Ringwald  * @param notification struct used in gatt_client_listen_for_characteristic_value_updates
7131f734b5fSMatthias Ringwald  */
7141f734b5fSMatthias Ringwald void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification);
7151f734b5fSMatthias Ringwald 
7161f734b5fSMatthias Ringwald /**
71747181045SMatthias Ringwald  * @brief Requests GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE that guarantees a single successful gatt_client_write_value_of_characteristic_without_response
7186da84376SMilanka Ringwald  * @param  callback
71947181045SMatthias Ringwald  * @param  con_handle
72047181045SMatthias Ringwald  * @returns status
72147181045SMatthias Ringwald  */
72247181045SMatthias Ringwald uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
72347181045SMatthias Ringwald 
72447181045SMatthias Ringwald /**
7256da84376SMilanka Ringwald  * @brief Transactional write. It can be called as many times as it is needed to write the characteristics within the same transaction. Call gatt_client_execute_write to commit the transaction.
7266da84376SMilanka Ringwald  * @param  callback
7276da84376SMilanka Ringwald  * @param  con_handle
7286da84376SMilanka Ringwald  * @param  attribute_handle
7296da84376SMilanka Ringwald  * @param  offset of value
7306da84376SMilanka Ringwald  * @param  length of data
7316da84376SMilanka Ringwald  * @param  data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
7323deb3ec6SMatthias Ringwald  */
733711e6c80SMatthias Ringwald 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 length, uint8_t * data);
7343deb3ec6SMatthias Ringwald 
7353deb3ec6SMatthias Ringwald /**
7366da84376SMilanka Ringwald  * @brief Commit transactional write. GATT_EVENT_QUERY_COMPLETE is received.
7376da84376SMilanka Ringwald  * @param  callback
7386da84376SMilanka Ringwald  * @param  con_handle
7393deb3ec6SMatthias Ringwald  */
740711e6c80SMatthias Ringwald uint8_t gatt_client_execute_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
7413deb3ec6SMatthias Ringwald 
7423deb3ec6SMatthias Ringwald /**
7436da84376SMilanka Ringwald  * @brief Abort transactional write. GATT_EVENT_QUERY_COMPLETE is received.
7446da84376SMilanka Ringwald  * @param  callback
7456da84376SMilanka Ringwald  * @param  con_handle
7463deb3ec6SMatthias Ringwald  */
747711e6c80SMatthias Ringwald uint8_t gatt_client_cancel_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
7483deb3ec6SMatthias Ringwald 
7493deb3ec6SMatthias Ringwald /* API_END */
7503deb3ec6SMatthias Ringwald 
7516ba2ad22SMatthias Ringwald // used by generated btstack_event.c
7526ba2ad22SMatthias Ringwald 
753313e337bSMatthias Ringwald void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t *service);
754313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic);
755313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor);
7566ba2ad22SMatthias Ringwald 
757a6121b51SMilanka Ringwald #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
758a6121b51SMilanka Ringwald void gatt_client_att_packet_handler_fuzz(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size);
759a6121b51SMilanka Ringwald #endif
760a6121b51SMilanka Ringwald 
7613deb3ec6SMatthias Ringwald #if defined __cplusplus
7623deb3ec6SMatthias Ringwald }
7633deb3ec6SMatthias Ringwald #endif
7643deb3ec6SMatthias Ringwald 
7653deb3ec6SMatthias Ringwald #endif
766