xref: /btstack/src/ble/gatt_client.h (revision 40faeb84f8b4da73ab0a98e48bed751325c25bfc)
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
232fca4dadSMilanka Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald  * GMBH 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 
38fe5a6c4eSMilanka Ringwald /**
39fe5a6c4eSMilanka Ringwald  * @title GATT Client
40fe5a6c4eSMilanka Ringwald  *
41fe5a6c4eSMilanka Ringwald  */
423deb3ec6SMatthias Ringwald 
433deb3ec6SMatthias Ringwald #ifndef btstack_gatt_client_h
443deb3ec6SMatthias Ringwald #define btstack_gatt_client_h
453deb3ec6SMatthias Ringwald 
463deb3ec6SMatthias Ringwald #include "hci.h"
473deb3ec6SMatthias Ringwald 
483deb3ec6SMatthias Ringwald #if defined __cplusplus
493deb3ec6SMatthias Ringwald extern "C" {
503deb3ec6SMatthias Ringwald #endif
513deb3ec6SMatthias Ringwald 
523deb3ec6SMatthias Ringwald typedef enum {
533deb3ec6SMatthias Ringwald     P_READY,
543deb3ec6SMatthias Ringwald     P_W2_SEND_SERVICE_QUERY,
553deb3ec6SMatthias Ringwald     P_W4_SERVICE_QUERY_RESULT,
563deb3ec6SMatthias Ringwald     P_W2_SEND_SERVICE_WITH_UUID_QUERY,
573deb3ec6SMatthias Ringwald     P_W4_SERVICE_WITH_UUID_RESULT,
583deb3ec6SMatthias Ringwald 
593deb3ec6SMatthias Ringwald     P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY,
603deb3ec6SMatthias Ringwald     P_W4_ALL_CHARACTERISTICS_OF_SERVICE_QUERY_RESULT,
613deb3ec6SMatthias Ringwald     P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY,
623deb3ec6SMatthias Ringwald     P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT,
633deb3ec6SMatthias Ringwald 
643deb3ec6SMatthias Ringwald     P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY,
653deb3ec6SMatthias Ringwald     P_W4_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT,
663deb3ec6SMatthias Ringwald 
673deb3ec6SMatthias Ringwald     P_W2_SEND_INCLUDED_SERVICE_QUERY,
683deb3ec6SMatthias Ringwald     P_W4_INCLUDED_SERVICE_QUERY_RESULT,
693deb3ec6SMatthias Ringwald     P_W2_SEND_INCLUDED_SERVICE_WITH_UUID_QUERY,
703deb3ec6SMatthias Ringwald     P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT,
713deb3ec6SMatthias Ringwald 
723deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY,
733deb3ec6SMatthias Ringwald     P_W4_READ_CHARACTERISTIC_VALUE_RESULT,
743deb3ec6SMatthias Ringwald 
753deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BLOB_QUERY,
763deb3ec6SMatthias Ringwald     P_W4_READ_BLOB_RESULT,
773deb3ec6SMatthias Ringwald 
783deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BY_TYPE_REQUEST,
793deb3ec6SMatthias Ringwald     P_W4_READ_BY_TYPE_RESPONSE,
803deb3ec6SMatthias Ringwald 
813deb3ec6SMatthias Ringwald     P_W2_SEND_READ_MULTIPLE_REQUEST,
823deb3ec6SMatthias Ringwald     P_W4_READ_MULTIPLE_RESPONSE,
833deb3ec6SMatthias Ringwald 
843deb3ec6SMatthias Ringwald     P_W2_SEND_WRITE_CHARACTERISTIC_VALUE,
853deb3ec6SMatthias Ringwald     P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT,
863deb3ec6SMatthias Ringwald 
873deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE,
883deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_RESULT,
893deb3ec6SMatthias Ringwald     P_W2_PREPARE_RELIABLE_WRITE,
903deb3ec6SMatthias Ringwald     P_W4_PREPARE_RELIABLE_WRITE_RESULT,
913deb3ec6SMatthias Ringwald 
923deb3ec6SMatthias Ringwald     P_W2_EXECUTE_PREPARED_WRITE,
933deb3ec6SMatthias Ringwald     P_W4_EXECUTE_PREPARED_WRITE_RESULT,
943deb3ec6SMatthias Ringwald     P_W2_CANCEL_PREPARED_WRITE,
953deb3ec6SMatthias Ringwald     P_W4_CANCEL_PREPARED_WRITE_RESULT,
963deb3ec6SMatthias Ringwald     P_W2_CANCEL_PREPARED_WRITE_DATA_MISMATCH,
973deb3ec6SMatthias Ringwald     P_W4_CANCEL_PREPARED_WRITE_DATA_MISMATCH_RESULT,
983deb3ec6SMatthias Ringwald 
99abdc9fb5SMatthias Ringwald #ifdef ENABLE_GATT_FIND_INFORMATION_FOR_CCC_DISCOVERY
100abdc9fb5SMatthias Ringwald     P_W2_SEND_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY,
101abdc9fb5SMatthias Ringwald     P_W4_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT,
102abdc9fb5SMatthias Ringwald #else
1033deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY,
1043deb3ec6SMatthias Ringwald     P_W4_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT,
105abdc9fb5SMatthias Ringwald #endif
1063deb3ec6SMatthias Ringwald     P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION,
1073deb3ec6SMatthias Ringwald     P_W4_CLIENT_CHARACTERISTIC_CONFIGURATION_RESULT,
1083deb3ec6SMatthias Ringwald 
1093deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CHARACTERISTIC_DESCRIPTOR_QUERY,
1103deb3ec6SMatthias Ringwald     P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT,
1113deb3ec6SMatthias Ringwald 
1123deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY,
1133deb3ec6SMatthias Ringwald     P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT,
1143deb3ec6SMatthias Ringwald 
1153deb3ec6SMatthias Ringwald     P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR,
1163deb3ec6SMatthias Ringwald     P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
1173deb3ec6SMatthias Ringwald 
1183deb3ec6SMatthias Ringwald     // all long writes use this
1193deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR,
1203deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
1213deb3ec6SMatthias Ringwald     P_W2_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR,
1223deb3ec6SMatthias Ringwald     P_W4_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
1233deb3ec6SMatthias Ringwald 
1243deb3ec6SMatthias Ringwald     // gatt reliable write API use this (manual version of the above)
1253deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE_SINGLE,
1263deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_SINGLE_RESULT,
1273deb3ec6SMatthias Ringwald 
128793cf6ceSMatthias Ringwald     P_W4_IDENTITY_RESOLVING,
1293deb3ec6SMatthias Ringwald     P_W4_CMAC_READY,
1303deb3ec6SMatthias Ringwald     P_W4_CMAC_RESULT,
1313deb3ec6SMatthias Ringwald     P_W2_SEND_SIGNED_WRITE,
1323deb3ec6SMatthias Ringwald     P_W4_SEND_SINGED_WRITE_DONE,
1333deb3ec6SMatthias Ringwald } gatt_client_state_t;
1343deb3ec6SMatthias Ringwald 
1353deb3ec6SMatthias Ringwald 
1363deb3ec6SMatthias Ringwald typedef enum{
1373deb3ec6SMatthias Ringwald     SEND_MTU_EXCHANGE,
1383deb3ec6SMatthias Ringwald     SENT_MTU_EXCHANGE,
1395cf6c434SJakob Krantz     MTU_EXCHANGED,
1405cf6c434SJakob Krantz     MTU_AUTO_EXCHANGE_DISABLED
1413deb3ec6SMatthias Ringwald } gatt_client_mtu_t;
1423deb3ec6SMatthias Ringwald 
1433deb3ec6SMatthias Ringwald typedef struct gatt_client{
144665d90f2SMatthias Ringwald     btstack_linked_item_t    item;
1453deb3ec6SMatthias Ringwald     // TODO: rename gatt_client_state -> state
1463deb3ec6SMatthias Ringwald     gatt_client_state_t gatt_client_state;
1473deb3ec6SMatthias Ringwald 
1489c662c9bSMatthias Ringwald     // user callback
1499c662c9bSMatthias Ringwald     btstack_packet_handler_t callback;
1503deb3ec6SMatthias Ringwald 
15147181045SMatthias Ringwald     // can write without response callback
15247181045SMatthias Ringwald     btstack_packet_handler_t write_without_response_callback;
15347181045SMatthias Ringwald 
154fc64f94aSMatthias Ringwald     hci_con_handle_t con_handle;
155f4b33574SMatthias Ringwald 
1563deb3ec6SMatthias Ringwald     uint16_t          mtu;
1573deb3ec6SMatthias Ringwald     gatt_client_mtu_t mtu_state;
1583deb3ec6SMatthias Ringwald 
1593deb3ec6SMatthias Ringwald     uint16_t uuid16;
1603deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
1613deb3ec6SMatthias Ringwald 
1623deb3ec6SMatthias Ringwald     uint16_t start_group_handle;
1633deb3ec6SMatthias Ringwald     uint16_t end_group_handle;
1643deb3ec6SMatthias Ringwald 
1653deb3ec6SMatthias Ringwald     uint16_t query_start_handle;
1663deb3ec6SMatthias Ringwald     uint16_t query_end_handle;
1673deb3ec6SMatthias Ringwald 
1683deb3ec6SMatthias Ringwald     uint8_t  characteristic_properties;
1693deb3ec6SMatthias Ringwald     uint16_t characteristic_start_handle;
1703deb3ec6SMatthias Ringwald 
1713deb3ec6SMatthias Ringwald     uint16_t attribute_handle;
1723deb3ec6SMatthias Ringwald     uint16_t attribute_offset;
1733deb3ec6SMatthias Ringwald     uint16_t attribute_length;
1743deb3ec6SMatthias Ringwald     uint8_t* attribute_value;
1753deb3ec6SMatthias Ringwald 
1763deb3ec6SMatthias Ringwald     // read multiple characteristic values
1773deb3ec6SMatthias Ringwald     uint16_t    read_multiple_handle_count;
1783deb3ec6SMatthias Ringwald     uint16_t  * read_multiple_handles;
1793deb3ec6SMatthias Ringwald 
1803deb3ec6SMatthias Ringwald     uint16_t client_characteristic_configuration_handle;
1813deb3ec6SMatthias Ringwald     uint8_t  client_characteristic_configuration_value[2];
1823deb3ec6SMatthias Ringwald 
1833deb3ec6SMatthias Ringwald     uint8_t  filter_with_uuid;
1843deb3ec6SMatthias Ringwald     uint8_t  send_confirmation;
1853deb3ec6SMatthias Ringwald 
1863deb3ec6SMatthias Ringwald     int      le_device_index;
1873deb3ec6SMatthias Ringwald     uint8_t  cmac[8];
1883deb3ec6SMatthias Ringwald 
189ec820d77SMatthias Ringwald     btstack_timer_source_t gc_timeout;
190f4b33574SMatthias Ringwald 
191f4b33574SMatthias Ringwald     uint8_t  security_counter;
1923503dc74SMatthias Ringwald     uint8_t  wait_for_authentication_complete;
193f4b33574SMatthias Ringwald     uint8_t  pending_error_code;
194f4b33574SMatthias Ringwald 
1958918bbdaSMatthias Ringwald     bool     reencryption_active;
1968918bbdaSMatthias Ringwald     uint8_t  reencryption_result;
1978918bbdaSMatthias Ringwald 
1981dfae9c7SMatthias Ringwald     gap_security_level_t security_level;
1991dfae9c7SMatthias Ringwald 
2003deb3ec6SMatthias Ringwald } gatt_client_t;
2013deb3ec6SMatthias Ringwald 
2029c662c9bSMatthias Ringwald typedef struct gatt_client_notification {
203665d90f2SMatthias Ringwald     btstack_linked_item_t    item;
204b6e96f14SMatthias Ringwald     btstack_packet_handler_t callback;
205711e6c80SMatthias Ringwald     hci_con_handle_t con_handle;
2069c662c9bSMatthias Ringwald     uint16_t attribute_handle;
2079c662c9bSMatthias Ringwald } gatt_client_notification_t;
2083deb3ec6SMatthias Ringwald 
2093deb3ec6SMatthias Ringwald /* API_START */
2103deb3ec6SMatthias Ringwald 
211d25c33e5SMatthias Ringwald typedef struct {
2123deb3ec6SMatthias Ringwald     uint16_t start_group_handle;
2133deb3ec6SMatthias Ringwald     uint16_t end_group_handle;
2143deb3ec6SMatthias Ringwald     uint16_t uuid16;
2153deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
216d25c33e5SMatthias Ringwald } gatt_client_service_t;
2173deb3ec6SMatthias Ringwald 
218d25c33e5SMatthias Ringwald typedef struct {
2193deb3ec6SMatthias Ringwald     uint16_t start_handle;
2203deb3ec6SMatthias Ringwald     uint16_t value_handle;
2213deb3ec6SMatthias Ringwald     uint16_t end_handle;
2223deb3ec6SMatthias Ringwald     uint16_t properties;
2233deb3ec6SMatthias Ringwald     uint16_t uuid16;
2243deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
225d25c33e5SMatthias Ringwald } gatt_client_characteristic_t;
2263deb3ec6SMatthias Ringwald 
227d25c33e5SMatthias Ringwald typedef struct {
2283deb3ec6SMatthias Ringwald     uint16_t handle;
2293deb3ec6SMatthias Ringwald     uint16_t uuid16;
2303deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
231d25c33e5SMatthias Ringwald } gatt_client_characteristic_descriptor_t;
2323deb3ec6SMatthias Ringwald 
2333deb3ec6SMatthias Ringwald /**
2343deb3ec6SMatthias Ringwald  * @brief Set up GATT client.
2353deb3ec6SMatthias Ringwald  */
2363deb3ec6SMatthias Ringwald void gatt_client_init(void);
2373deb3ec6SMatthias Ringwald 
2383deb3ec6SMatthias Ringwald /**
23911279da7SMatthias Ringwald  * @brief Set minimum required security level for GATT Client
24011279da7SMatthias Ringwald  * @note  The Bluetooth specification makes the GATT Server responsible to check for security.
241b11289a8SMatthias Ringwald  *        This allows an attacker to spoof an existing device with a GATT Servers, but skip the authentication part.
242b11289a8SMatthias Ringwald  *        If your application is exchanging sensitive data with a remote device, you would need to manually check
243b11289a8SMatthias Ringwald  *        the security level before sending/receive such data.
244b11289a8SMatthias Ringwald  *        With level > 0, the GATT Client triggers authentication for all GATT Requests and defers any exchange
245b11289a8SMatthias Ringwald  *        until the required security level is established.
246b11289a8SMatthias Ringwald  *        gatt_client_request_can_write_without_response_event does not trigger authentication
24711279da7SMatthias Ringwald  *  @pram level, default LEVEL_0 (no encryption required)
24811279da7SMatthias Ringwald  */
24911279da7SMatthias Ringwald void gatt_client_set_required_security_level(gap_security_level_t level);
25011279da7SMatthias Ringwald 
25111279da7SMatthias Ringwald /**
25279188ed7SMilanka Ringwald  * @brief MTU is available after the first query has completed. If status is equal to ERROR_CODE_SUCCESS, it returns the real value,
25379188ed7SMilanka Ringwald  * otherwise the default value ATT_DEFAULT_MTU (see bluetooth.h).
2546da84376SMilanka Ringwald  * @param  con_handle
2556da84376SMilanka Ringwald  * @param  mtu
256*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
257*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
258692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if MTU is not exchanged and MTU auto-exchange is disabled
259692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
2603deb3ec6SMatthias Ringwald  */
261fc64f94aSMatthias Ringwald uint8_t gatt_client_get_mtu(hci_con_handle_t con_handle, uint16_t * mtu);
2623deb3ec6SMatthias Ringwald 
2633deb3ec6SMatthias Ringwald /**
26479188ed7SMilanka Ringwald  * @brief Sets whether a MTU Exchange Request shall be automatically send before the
26579188ed7SMilanka Ringwald  * first attribute read request is send. Default is enabled.
2666da84376SMilanka Ringwald  * @param enabled
2675cf6c434SJakob Krantz  */
2685cf6c434SJakob Krantz void gatt_client_mtu_enable_auto_negotiation(uint8_t enabled);
2695cf6c434SJakob Krantz 
2705cf6c434SJakob Krantz /**
27179188ed7SMilanka Ringwald  * @brief Sends a MTU Exchange Request, this allows for the client to exchange MTU
27279188ed7SMilanka Ringwald  * when gatt_client_mtu_enable_auto_negotiation is disabled.
2736da84376SMilanka Ringwald  * @param  callback
2746da84376SMilanka Ringwald  * @param  con_handle
2755cf6c434SJakob Krantz  */
2765cf6c434SJakob Krantz void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
2775cf6c434SJakob Krantz 
2785cf6c434SJakob Krantz /**
279aacf1b1aSMilanka Ringwald  * @brief Returns 1 if the GATT client is ready to receive a query. It is used with daemon.
2806da84376SMilanka Ringwald  * @param  con_handle
281692bf1adSMilanka Ringwald  * @return is_ready_status     0 - if no GATT client for con_handle is found, or is not ready, otherwise 1
2823deb3ec6SMatthias Ringwald  */
283fc64f94aSMatthias Ringwald int gatt_client_is_ready(hci_con_handle_t con_handle);
2843deb3ec6SMatthias Ringwald 
2853deb3ec6SMatthias Ringwald /**
28679188ed7SMilanka Ringwald  * @brief Discovers all primary services.
28779188ed7SMilanka Ringwald  * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted.
28879188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
2896da84376SMilanka Ringwald  * @param  callback
2906da84376SMilanka Ringwald  * @param  con_handle
291692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
292692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
293692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
2943deb3ec6SMatthias Ringwald  */
295711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
2963deb3ec6SMatthias Ringwald 
2973deb3ec6SMatthias Ringwald /**
29879188ed7SMilanka Ringwald  * @brief Discovers all secondary services.
29979188ed7SMilanka Ringwald  * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted.
30079188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
3018d1f34d3SMatheus Eduardo Garbelini  * @param  callback
3028d1f34d3SMatheus Eduardo Garbelini  * @param  con_handle
3038d1f34d3SMatheus Eduardo Garbelini  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
3048d1f34d3SMatheus Eduardo Garbelini  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
3058d1f34d3SMatheus Eduardo Garbelini  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3068d1f34d3SMatheus Eduardo Garbelini  */
3078d1f34d3SMatheus Eduardo Garbelini uint8_t gatt_client_discover_secondary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
3088d1f34d3SMatheus Eduardo Garbelini 
3098d1f34d3SMatheus Eduardo Garbelini /**
31079188ed7SMilanka Ringwald  * @brief Discovers a specific primary service given its UUID. This service may exist multiple times.
31179188ed7SMilanka Ringwald  * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted.
31279188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
3136da84376SMilanka Ringwald  * @param callback
3146da84376SMilanka Ringwald  * @param con_handle
3156da84376SMilanka Ringwald  * @param uuid16
316692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
317692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
318692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3193deb3ec6SMatthias Ringwald  */
320711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16);
3216da84376SMilanka Ringwald 
3226da84376SMilanka Ringwald /**
32379188ed7SMilanka Ringwald  * @brief Discovers a specific primary service given its UUID. This service may exist multiple times.
32479188ed7SMilanka Ringwald  * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted.
32579188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
3266da84376SMilanka Ringwald  * @param  callback
3276da84376SMilanka Ringwald  * @param  con_handle
3286da84376SMilanka Ringwald  * @param  uuid128
329692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
330692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
331692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3326da84376SMilanka Ringwald  */
3336da84376SMilanka 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);
3343deb3ec6SMatthias Ringwald 
3353deb3ec6SMatthias Ringwald /**
33679188ed7SMilanka Ringwald  * @brief Finds included services within the specified service.
33779188ed7SMilanka Ringwald  * For each found included service a GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT event will be emitted.
33879188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
33979188ed7SMilanka Ringwald  * Information about included service type (primary/secondary) can be retrieved either by sending
34079188ed7SMilanka Ringwald  * an ATT find information request for the returned start group handle
34179188ed7SMilanka Ringwald  * (returning the handle and the UUID for primary or secondary service) or by comparing the service
34279188ed7SMilanka Ringwald  * to the list of all primary services.
3436da84376SMilanka Ringwald  * @param  callback
3446da84376SMilanka Ringwald  * @param  con_handle
3456da84376SMilanka Ringwald  * @param  service
346692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
347692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
348692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3493deb3ec6SMatthias Ringwald  */
350711e6c80SMatthias 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);
3513deb3ec6SMatthias Ringwald 
3523deb3ec6SMatthias Ringwald /**
35379188ed7SMilanka Ringwald  * @brief Discovers all characteristics within the specified service.
35479188ed7SMilanka Ringwald  * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will be emited.
35579188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
3566da84376SMilanka Ringwald  * @param  callback
3576da84376SMilanka Ringwald  * @param  con_handle
3586da84376SMilanka Ringwald  * @param  service
359692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
360692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
361692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3623deb3ec6SMatthias Ringwald  */
363711e6c80SMatthias 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);
3643deb3ec6SMatthias Ringwald 
3653deb3ec6SMatthias Ringwald /**
36679188ed7SMilanka Ringwald  * @brief The following four functions are used to discover all characteristics within
36779188ed7SMilanka Ringwald  * the specified service or handle range, and return those that match the given UUID.
36879188ed7SMilanka Ringwald  *
36979188ed7SMilanka Ringwald  * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted.
37079188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
3716da84376SMilanka Ringwald  * @param  callback
3726da84376SMilanka Ringwald  * @param  con_handle
3736da84376SMilanka Ringwald  * @param  start_handle
3746da84376SMilanka Ringwald  * @param  end_handle
3756da84376SMilanka Ringwald  * @param  uuid16
376692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
377692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
378692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3793deb3ec6SMatthias Ringwald  */
380711e6c80SMatthias 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);
3816da84376SMilanka Ringwald 
3826da84376SMilanka Ringwald /**
38379188ed7SMilanka Ringwald  * @brief The following four functions are used to discover all characteristics within the
38479188ed7SMilanka Ringwald  * specified service or handle range, and return those that match the given UUID.
38579188ed7SMilanka Ringwald  * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted.
38679188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
3876da84376SMilanka Ringwald  * @param  callback
3886da84376SMilanka Ringwald  * @param  con_handle
3896da84376SMilanka Ringwald  * @param  start_handle
3906da84376SMilanka Ringwald  * @param  end_handle
3916da84376SMilanka Ringwald  * @param  uuid128
392692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
393692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
394692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
3956da84376SMilanka Ringwald  */
396045d700dSDavid Lechner 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);
3976da84376SMilanka Ringwald 
3986da84376SMilanka Ringwald /**
39979188ed7SMilanka Ringwald  * @brief The following four functions are used to discover all characteristics within the
40079188ed7SMilanka Ringwald  * specified service or handle range, and return those that match the given UUID.
40179188ed7SMilanka Ringwald  * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted.
40279188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
4036da84376SMilanka Ringwald  * @param  callback
4046da84376SMilanka Ringwald  * @param  con_handle
4056da84376SMilanka Ringwald  * @param  service
4066da84376SMilanka Ringwald  * @param  uuid16
407692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
408692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
409692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4106da84376SMilanka Ringwald  */
411711e6c80SMatthias 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);
4126da84376SMilanka Ringwald 
4136da84376SMilanka Ringwald /**
41479188ed7SMilanka Ringwald  * @brief The following four functions are used to discover all characteristics within the
41579188ed7SMilanka Ringwald  * specified service or handle range, and return those that match the given UUID.
41679188ed7SMilanka Ringwald  * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted.
41779188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
4186da84376SMilanka Ringwald  * @param  callback
4196da84376SMilanka Ringwald  * @param  con_handle
4206da84376SMilanka Ringwald  * @param  service
4216da84376SMilanka Ringwald  * @param  uuid128
422692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
423692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
424692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4256da84376SMilanka Ringwald  */
426045d700dSDavid Lechner 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);
4273deb3ec6SMatthias Ringwald 
4283deb3ec6SMatthias Ringwald /**
42979188ed7SMilanka Ringwald  * @brief Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic.
43079188ed7SMilanka Ringwald  * For each found descriptor a GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT event will be emitted.
43179188ed7SMilanka Ringwald  *
43279188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
4336da84376SMilanka Ringwald  * @param  callback
4346da84376SMilanka Ringwald  * @param  con_handle
4356da84376SMilanka Ringwald  * @param  characteristic
436692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
437692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
438692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4393deb3ec6SMatthias Ringwald  */
440711e6c80SMatthias Ringwald uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic);
4413deb3ec6SMatthias Ringwald 
4423deb3ec6SMatthias Ringwald /**
44379188ed7SMilanka Ringwald  * @brief Reads the characteristic value using the characteristic's value handle.
44479188ed7SMilanka Ringwald  * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted.
44579188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
4466da84376SMilanka Ringwald  * @param  callback
4476da84376SMilanka Ringwald  * @param  con_handle
4486da84376SMilanka Ringwald  * @param  characteristic
449692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
450692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
451692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4523deb3ec6SMatthias Ringwald  */
453711e6c80SMatthias 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);
4546da84376SMilanka Ringwald 
4556da84376SMilanka Ringwald /**
45679188ed7SMilanka Ringwald  * @brief Reads the characteristic value using the characteristic's value handle.
45779188ed7SMilanka Ringwald  * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted.
45879188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
4596da84376SMilanka Ringwald  * @param  callback
4606da84376SMilanka Ringwald  * @param  con_handle
461b45b7749SMilanka Ringwald  * @param  value_handle
462692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
463692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
464692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4656da84376SMilanka Ringwald  */
466b45b7749SMilanka 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 value_handle);
4673deb3ec6SMatthias Ringwald 
4683deb3ec6SMatthias Ringwald /**
46979188ed7SMilanka Ringwald  * @brief Reads the characteric value of all characteristics with the uuid.
47079188ed7SMilanka Ringwald  * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted.
47179188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
4726da84376SMilanka Ringwald  * @param  callback
4736da84376SMilanka Ringwald  * @param  con_handle
4746da84376SMilanka Ringwald  * @param  start_handle
4756da84376SMilanka Ringwald  * @param  end_handle
4766da84376SMilanka Ringwald  * @param  uuid16
477692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
478692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
479692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4803deb3ec6SMatthias Ringwald  */
481711e6c80SMatthias 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);
4826da84376SMilanka Ringwald 
4836da84376SMilanka Ringwald /**
48479188ed7SMilanka Ringwald  * @brief Reads the characteric value of all characteristics with the uuid.
48579188ed7SMilanka Ringwald  * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted.
48679188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
4876da84376SMilanka Ringwald  * @param  callback
4886da84376SMilanka Ringwald  * @param  con_handle
4896da84376SMilanka Ringwald  * @param  start_handle
4906da84376SMilanka Ringwald  * @param  end_handle
4916da84376SMilanka Ringwald  * @param  uuid128
492692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
493692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
494692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
4956da84376SMilanka Ringwald  */
496045d700dSDavid Lechner 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);
4973deb3ec6SMatthias Ringwald 
4983deb3ec6SMatthias Ringwald /**
49979188ed7SMilanka Ringwald  * @brief Reads the long characteristic value using the characteristic's value handle.
50079188ed7SMilanka Ringwald  * The value will be returned in several blobs.
50179188ed7SMilanka Ringwald  * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted.
50279188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
5036da84376SMilanka Ringwald  * @param  callback
5046da84376SMilanka Ringwald  * @param  con_handle
5056da84376SMilanka Ringwald  * @param  characteristic
506692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
507692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
508692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
5093deb3ec6SMatthias Ringwald  */
510711e6c80SMatthias 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);
5116da84376SMilanka Ringwald 
5126da84376SMilanka Ringwald /**
51379188ed7SMilanka Ringwald  * @brief Reads the long characteristic value using the characteristic's value handle.
51479188ed7SMilanka Ringwald  * The value will be returned in several blobs.
51579188ed7SMilanka Ringwald  * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted.
51679188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
5176da84376SMilanka Ringwald  * @param  callback
5186da84376SMilanka Ringwald  * @param  con_handle
519b45b7749SMilanka Ringwald  * @param  value_handle
520692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
521692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
522692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
5236da84376SMilanka Ringwald  */
524b45b7749SMilanka 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 value_handle);
5256da84376SMilanka Ringwald 
5266da84376SMilanka Ringwald /**
52779188ed7SMilanka Ringwald  * @brief Reads the long characteristic value using the characteristic's value handle.
52879188ed7SMilanka Ringwald  * The value will be returned in several blobs.
52979188ed7SMilanka Ringwald  * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted.
53079188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
5316da84376SMilanka Ringwald  * @param  callback
5326da84376SMilanka Ringwald  * @param  con_handle
533b45b7749SMilanka Ringwald  * @param  value_handle
5346da84376SMilanka Ringwald  * @param  offset
535692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
536692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
537692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
5386da84376SMilanka Ringwald  */
539b45b7749SMilanka 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 value_handle, uint16_t offset);
5403deb3ec6SMatthias Ringwald 
5413deb3ec6SMatthias Ringwald /*
54279188ed7SMilanka Ringwald  * @brief Read multiple characteristic values.
54379188ed7SMilanka Ringwald  * The all results are emitted via single GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event,
54479188ed7SMilanka Ringwald  * followed by the GATT_EVENT_QUERY_COMPLETE event, which marks the end of read.
5456da84376SMilanka Ringwald  * @param  callback
5466da84376SMilanka Ringwald  * @param  con_handle
5476da84376SMilanka Ringwald  * @param  num_value_handles
5486da84376SMilanka Ringwald  * @param  value_handles list of handles
54979188ed7SMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
55079188ed7SMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
55179188ed7SMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
5523deb3ec6SMatthias Ringwald  */
553711e6c80SMatthias 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);
5543deb3ec6SMatthias Ringwald 
5553deb3ec6SMatthias Ringwald /**
55679188ed7SMilanka Ringwald  * @brief Writes the characteristic value using the characteristic's value handle without
55779188ed7SMilanka Ringwald  * an acknowledgment that the write was successfully performed.
5586da84376SMilanka Ringwald  * @param  con_handle
559b45b7749SMilanka Ringwald  * @param  value_handle
560b45b7749SMilanka Ringwald  * @param  value_length
5617e6f0853SDavid Lechner  * @param  value is copied on success and does not need to be retained
562692bf1adSMilanka Ringwald  * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
563692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
564692bf1adSMilanka Ringwald  *                BTSTACK_ACL_BUFFERS_FULL   , if L2CAP cannot send, there are no free ACL slots
565692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS         , if query is successfully registered
5663deb3ec6SMatthias Ringwald  */
567b45b7749SMilanka Ringwald 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);
5683deb3ec6SMatthias Ringwald 
5693deb3ec6SMatthias Ringwald /**
57079188ed7SMilanka Ringwald  * @brief Writes the authenticated characteristic value using the characteristic's value handle
57179188ed7SMilanka Ringwald  * without an acknowledgment that the write was successfully performed.
57279188ed7SMilanka Ringwald  * @note GATT_EVENT_QUERY_COMPLETE is emitted with ATT_ERROR_SUCCESS for success,
57379188ed7SMilanka Ringwald  * or ATT_ERROR_BONDING_INFORMATION_MISSING if there is no bonding information stored.
5746da84376SMilanka Ringwald  * @param  callback
5756da84376SMilanka Ringwald  * @param  con_handle
5766da84376SMilanka Ringwald  * @param  value_handle
5776da84376SMilanka Ringwald  * @param  message_len
5786da84376SMilanka Ringwald  * @param  message is not copied, make sure memory is accessible until write is done
579*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
580*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
581692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
582692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
5833deb3ec6SMatthias Ringwald  */
5846da84376SMilanka 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);
5853deb3ec6SMatthias Ringwald 
5863deb3ec6SMatthias Ringwald /**
587b2468039SMilanka Ringwald  * @brief Writes the characteristic value using the characteristic's value handle.
588b2468039SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
589b2468039SMilanka Ringwald  * The write is successfully performed, if the event's att_status field is set to
590b2468039SMilanka Ringwald  * ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes).
5916da84376SMilanka Ringwald  * @param  callback
5926da84376SMilanka Ringwald  * @param  con_handle
593b45b7749SMilanka Ringwald  * @param  value_handle
594b45b7749SMilanka Ringwald  * @param  value_length
595b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
596*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
597*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
598692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
599692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6003deb3ec6SMatthias Ringwald  */
601b45b7749SMilanka Ringwald 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);
6026da84376SMilanka Ringwald 
6036da84376SMilanka Ringwald /**
60479188ed7SMilanka Ringwald  * @brief Writes the characteristic value using the characteristic's value handle.
60579188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
60679188ed7SMilanka Ringwald  * 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).
6076da84376SMilanka Ringwald  * @param  callback
6086da84376SMilanka Ringwald  * @param  con_handle
609b45b7749SMilanka Ringwald  * @param  value_handle
610b45b7749SMilanka Ringwald  * @param  value_length
611b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
612*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
613*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
614692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
615692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6166da84376SMilanka Ringwald  */
617b45b7749SMilanka Ringwald 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);
6186da84376SMilanka Ringwald 
6196da84376SMilanka Ringwald /**
62079188ed7SMilanka Ringwald  * @brief Writes the characteristic value using the characteristic's value handle.
62179188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
62279188ed7SMilanka Ringwald  * 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).
6236da84376SMilanka Ringwald  * @param  callback
6246da84376SMilanka Ringwald  * @param  con_handle
625b45b7749SMilanka Ringwald  * @param  value_handle
6266da84376SMilanka Ringwald  * @param  offset of value
627b45b7749SMilanka Ringwald  * @param  value_length
628b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
629*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
630*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
631692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
632692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6336da84376SMilanka Ringwald  */
634b45b7749SMilanka 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 value_handle, uint16_t offset, uint16_t value_length, uint8_t * value);
6353deb3ec6SMatthias Ringwald 
6363deb3ec6SMatthias Ringwald /**
63779188ed7SMilanka Ringwald  * @brief Writes of the long characteristic value using the characteristic's value handle.
63879188ed7SMilanka Ringwald  * It uses server response to validate that the write was correctly received.
63979188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE EVENT marks the end of write.
64079188ed7SMilanka Ringwald  * 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).
6416da84376SMilanka Ringwald  * @param  callback
6426da84376SMilanka Ringwald  * @param  con_handle
643b45b7749SMilanka Ringwald  * @param  value_handle
644b45b7749SMilanka Ringwald  * @param  value_length
645b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
646*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
647*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
648692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
649692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6503deb3ec6SMatthias Ringwald  */
651b45b7749SMilanka Ringwald 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);
6523deb3ec6SMatthias Ringwald 
6533deb3ec6SMatthias Ringwald /**
65479188ed7SMilanka Ringwald  * @brief Reads the characteristic descriptor using its handle.
65579188ed7SMilanka Ringwald  * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted.
65679188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
6576da84376SMilanka Ringwald  * @param  callback
6586da84376SMilanka Ringwald  * @param  con_handle
6596da84376SMilanka Ringwald  * @param  descriptor
660*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
661*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
662692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
663692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6643deb3ec6SMatthias Ringwald  */
665711e6c80SMatthias 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);
6666da84376SMilanka Ringwald 
6676da84376SMilanka Ringwald /**
66879188ed7SMilanka Ringwald  * @brief Reads the characteristic descriptor using its handle.
66979188ed7SMilanka Ringwald  * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted.
67079188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
6716da84376SMilanka Ringwald  * @param  callback
6726da84376SMilanka Ringwald  * @param  con_handle
6736da84376SMilanka Ringwald  * @param  descriptor
674*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
675*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
676692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
677692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6786da84376SMilanka Ringwald  */
679711e6c80SMatthias 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);
6803deb3ec6SMatthias Ringwald 
6813deb3ec6SMatthias Ringwald /**
68279188ed7SMilanka Ringwald  * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs.
68379188ed7SMilanka Ringwald  * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted.
68479188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
6856da84376SMilanka Ringwald  * @param  callback
6866da84376SMilanka Ringwald  * @param  con_handle
687b45b7749SMilanka Ringwald  * @param  descriptor
688*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
689*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
690692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
691692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
6923deb3ec6SMatthias Ringwald  */
693711e6c80SMatthias 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);
6946da84376SMilanka Ringwald 
6956da84376SMilanka Ringwald /**
69679188ed7SMilanka Ringwald  * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs.
69779188ed7SMilanka Ringwald  * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted.
69879188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
6996da84376SMilanka Ringwald  * @param  callback
7006da84376SMilanka Ringwald  * @param  con_handle
7016da84376SMilanka Ringwald  * @param  descriptor_handle
702*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
703*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
704692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
705692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
7066da84376SMilanka Ringwald  */
707711e6c80SMatthias 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);
7086da84376SMilanka Ringwald 
7096da84376SMilanka Ringwald /**
71079188ed7SMilanka Ringwald  * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs.
71179188ed7SMilanka Ringwald  * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted.
71279188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
7136da84376SMilanka Ringwald  * @param  callback
7146da84376SMilanka Ringwald  * @param  con_handle
7156da84376SMilanka Ringwald  * @param  descriptor_handle
7166da84376SMilanka Ringwald  * @param  offset
717*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
718*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
719692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
720692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
7216da84376SMilanka Ringwald  */
722711e6c80SMatthias 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);
7233deb3ec6SMatthias Ringwald 
7243deb3ec6SMatthias Ringwald /**
72579188ed7SMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle.
72679188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
72779188ed7SMilanka Ringwald  * 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).
7286da84376SMilanka Ringwald  * @param  callback
7296da84376SMilanka Ringwald  * @param  con_handle
7306da84376SMilanka Ringwald  * @param  descriptor
731b45b7749SMilanka Ringwald  * @param  value_length
732b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
733*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
734*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
735692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
736692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
7373deb3ec6SMatthias Ringwald  */
738b45b7749SMilanka 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 value_length, uint8_t * value);
7396da84376SMilanka Ringwald 
7406da84376SMilanka Ringwald /**
74179188ed7SMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle.
74279188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
74379188ed7SMilanka Ringwald  * 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).
7446da84376SMilanka Ringwald  * @param  callback
7456da84376SMilanka Ringwald  * @param  con_handle
7466da84376SMilanka Ringwald  * @param  descriptor_handle
747b45b7749SMilanka Ringwald  * @param  value_length
748b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
749*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
750*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
751692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
752692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
7536da84376SMilanka Ringwald  */
754b45b7749SMilanka 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 value_length, uint8_t * value);
7556da84376SMilanka Ringwald 
7566da84376SMilanka Ringwald /**
75779188ed7SMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle.
75879188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
75979188ed7SMilanka Ringwald  * 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).
7606da84376SMilanka Ringwald  * @param  callback
7616da84376SMilanka Ringwald  * @param  con_handle
7626da84376SMilanka Ringwald  * @param  descriptor
763b45b7749SMilanka Ringwald  * @param  value_length
764b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
765*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
766*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
767692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
768692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
7696da84376SMilanka Ringwald  */
770b45b7749SMilanka 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 value_length, uint8_t * value);
7716da84376SMilanka Ringwald 
7726da84376SMilanka Ringwald /**
77379188ed7SMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle.
77479188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
77579188ed7SMilanka Ringwald  * 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).
7766da84376SMilanka Ringwald  * @param  callback
7776da84376SMilanka Ringwald  * @param  con_handle
7786da84376SMilanka Ringwald  * @param  descriptor_handle
779b45b7749SMilanka Ringwald  * @param  value_length
780b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
781*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
782*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
783692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
784692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
7856da84376SMilanka Ringwald  */
786b45b7749SMilanka 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 value_length, uint8_t * value);
7876da84376SMilanka Ringwald 
7886da84376SMilanka Ringwald /**
78979188ed7SMilanka Ringwald  * @brief Writes the characteristic descriptor using its handle.
79079188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
79179188ed7SMilanka Ringwald  * 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).
7926da84376SMilanka Ringwald  * @param  callback
7936da84376SMilanka Ringwald  * @param  con_handle
7946da84376SMilanka Ringwald  * @param  descriptor_handle
7956da84376SMilanka Ringwald  * @param  offset of value
796b45b7749SMilanka Ringwald  * @param  value_length
797b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
798*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
799*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
800692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
801692bf1adSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
8026da84376SMilanka Ringwald  */
803b45b7749SMilanka 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 value_length, uint8_t * value);
8043deb3ec6SMatthias Ringwald 
8053deb3ec6SMatthias Ringwald /**
80679188ed7SMilanka Ringwald  * @brief Writes the client characteristic configuration of the specified characteristic.
80779188ed7SMilanka Ringwald  * It is used to subscribe for notifications or indications of the characteristic value.
80879188ed7SMilanka Ringwald  * For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION
80979188ed7SMilanka Ringwald  * resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value.
81079188ed7SMilanka Ringwald  * The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
81179188ed7SMilanka Ringwald  * 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).
8126da84376SMilanka Ringwald  * @param  callback
8136da84376SMilanka Ringwald  * @param  con_handle
8146da84376SMilanka Ringwald  * @param  characteristic
815b7e5512fSMilanka Ringwald  * @param  configuration                                                    GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION, GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION
816*40faeb84SMilanka Ringwald  * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER                  if no HCI connection for con_handle is found
817*40faeb84SMilanka Ringwald  *                BTSTACK_MEMORY_ALLOC_FAILED                               if no GATT client for con_handle could be allocated
818692bf1adSMilanka Ringwald  *                GATT_CLIENT_IN_WRONG_STATE                                if GATT client is not ready
819b7e5512fSMilanka Ringwald  *                GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED     if configuring notification, but characteristic has no notification property set
820b7e5512fSMilanka Ringwald  *                GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED       if configuring indication, but characteristic has no indication property set
8216b04f675SMilanka Ringwald  *                ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE         if configuration is invalid
822b7e5512fSMilanka Ringwald  *                ERROR_CODE_SUCCESS                                        if query is successfully registered
8233deb3ec6SMatthias Ringwald  */
824711e6c80SMatthias 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);
8259c662c9bSMatthias Ringwald 
8269c662c9bSMatthias Ringwald /**
82779188ed7SMilanka Ringwald  * @brief Register for notifications and indications of a characteristic enabled by
82879188ed7SMilanka Ringwald  * the gatt_client_write_client_characteristic_configuration function.
8299c662c9bSMatthias Ringwald  * @param notification struct used to store registration
8306da84376SMilanka Ringwald  * @param callback
831b3f03c84SMatthias Ringwald  * @param con_handle or GATT_CLIENT_ANY_CONNECTION to receive updates from all connected devices
832b3f03c84SMatthias Ringwald  * @param characteristic or NULL to receive updates for all characteristics
8339c662c9bSMatthias Ringwald  */
8346da84376SMilanka 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);
8353deb3ec6SMatthias Ringwald 
8363deb3ec6SMatthias Ringwald /**
83779188ed7SMilanka Ringwald  * @brief Stop listening to characteristic value updates registered with
83879188ed7SMilanka Ringwald  * the gatt_client_listen_for_characteristic_value_updates function.
8391f734b5fSMatthias Ringwald  * @param notification struct used in gatt_client_listen_for_characteristic_value_updates
8401f734b5fSMatthias Ringwald  */
8411f734b5fSMatthias Ringwald void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification);
8421f734b5fSMatthias Ringwald 
8431f734b5fSMatthias Ringwald /**
84479188ed7SMilanka Ringwald  * @brief Requests GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE that guarantees
84579188ed7SMilanka Ringwald  * a single successful gatt_client_write_value_of_characteristic_without_response call.
8466da84376SMilanka Ringwald  * @param  callback
84747181045SMatthias Ringwald  * @param  con_handle
8486b65794dSMilanka Ringwald  * @return status
84947181045SMatthias Ringwald  */
85047181045SMatthias Ringwald uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
85147181045SMatthias Ringwald 
85247181045SMatthias Ringwald /**
85379188ed7SMilanka Ringwald  * @brief Transactional write. It can be called as many times as it is needed to write the characteristics within the same transaction.
85479188ed7SMilanka Ringwald  * Call the gatt_client_execute_write function to commit the transaction.
8556da84376SMilanka Ringwald  * @param  callback
8566da84376SMilanka Ringwald  * @param  con_handle
8576da84376SMilanka Ringwald  * @param  attribute_handle
8586da84376SMilanka Ringwald  * @param  offset of value
859b45b7749SMilanka Ringwald  * @param  value_length
860b45b7749SMilanka Ringwald  * @param  value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
8613deb3ec6SMatthias Ringwald  */
862b45b7749SMilanka 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 value_length, uint8_t * value);
8633deb3ec6SMatthias Ringwald 
8643deb3ec6SMatthias Ringwald /**
8656da84376SMilanka Ringwald  * @brief Commit transactional write. GATT_EVENT_QUERY_COMPLETE is received.
8666da84376SMilanka Ringwald  * @param  callback
8676da84376SMilanka Ringwald  * @param  con_handle
868*40faeb84SMilanka Ringwald  * @return status
8693deb3ec6SMatthias Ringwald  */
870711e6c80SMatthias Ringwald uint8_t gatt_client_execute_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
8713deb3ec6SMatthias Ringwald 
8723deb3ec6SMatthias Ringwald /**
8736da84376SMilanka Ringwald  * @brief Abort transactional write. GATT_EVENT_QUERY_COMPLETE is received.
8746da84376SMilanka Ringwald  * @param  callback
8756da84376SMilanka Ringwald  * @param  con_handle
876*40faeb84SMilanka Ringwald  * @return status
8773deb3ec6SMatthias Ringwald  */
878711e6c80SMatthias Ringwald uint8_t gatt_client_cancel_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
8793deb3ec6SMatthias Ringwald 
8803deb3ec6SMatthias Ringwald /* API_END */
8813deb3ec6SMatthias Ringwald 
8826ba2ad22SMatthias Ringwald // used by generated btstack_event.c
8836ba2ad22SMatthias Ringwald 
884313e337bSMatthias Ringwald void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t * service);
885313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic);
886313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor);
8876ba2ad22SMatthias Ringwald 
888a6121b51SMilanka Ringwald #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
889a6121b51SMilanka Ringwald void gatt_client_att_packet_handler_fuzz(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size);
890*40faeb84SMilanka Ringwald uint8_t gatt_client_get_client(hci_con_handle_t con_handle, gatt_client_t ** gatt_client);
891a6121b51SMilanka Ringwald #endif
892a6121b51SMilanka Ringwald 
8933deb3ec6SMatthias Ringwald #if defined __cplusplus
8943deb3ec6SMatthias Ringwald }
8953deb3ec6SMatthias Ringwald #endif
8963deb3ec6SMatthias Ringwald 
8973deb3ec6SMatthias Ringwald #endif
898