xref: /btstack/src/ble/gatt_client.h (revision 6da84376d1ec3610a3f17d90aa11771df90f5a4a)
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 
1243deb3ec6SMatthias Ringwald     P_W4_CMAC_READY,
1253deb3ec6SMatthias Ringwald     P_W4_CMAC_RESULT,
1263deb3ec6SMatthias Ringwald     P_W2_SEND_SIGNED_WRITE,
1273deb3ec6SMatthias Ringwald     P_W4_SEND_SINGED_WRITE_DONE,
1283deb3ec6SMatthias Ringwald } gatt_client_state_t;
1293deb3ec6SMatthias Ringwald 
1303deb3ec6SMatthias Ringwald 
1313deb3ec6SMatthias Ringwald typedef enum{
1323deb3ec6SMatthias Ringwald     SEND_MTU_EXCHANGE,
1333deb3ec6SMatthias Ringwald     SENT_MTU_EXCHANGE,
1345cf6c434SJakob Krantz     MTU_EXCHANGED,
1355cf6c434SJakob Krantz     MTU_AUTO_EXCHANGE_DISABLED
1363deb3ec6SMatthias Ringwald } gatt_client_mtu_t;
1373deb3ec6SMatthias Ringwald 
1383deb3ec6SMatthias Ringwald typedef struct gatt_client{
139665d90f2SMatthias Ringwald     btstack_linked_item_t    item;
1403deb3ec6SMatthias Ringwald     // TODO: rename gatt_client_state -> state
1413deb3ec6SMatthias Ringwald     gatt_client_state_t gatt_client_state;
1423deb3ec6SMatthias Ringwald 
1439c662c9bSMatthias Ringwald     // user callback
1449c662c9bSMatthias Ringwald     btstack_packet_handler_t callback;
1453deb3ec6SMatthias Ringwald 
14647181045SMatthias Ringwald     // can write without response callback
14747181045SMatthias Ringwald     btstack_packet_handler_t write_without_response_callback;
14847181045SMatthias Ringwald 
149fc64f94aSMatthias Ringwald     hci_con_handle_t con_handle;
1503deb3ec6SMatthias Ringwald 
1513deb3ec6SMatthias Ringwald     uint8_t   address_type;
1523deb3ec6SMatthias Ringwald     bd_addr_t address;
153f4b33574SMatthias Ringwald 
1543deb3ec6SMatthias Ringwald     uint16_t          mtu;
1553deb3ec6SMatthias Ringwald     gatt_client_mtu_t mtu_state;
1563deb3ec6SMatthias Ringwald 
1573deb3ec6SMatthias Ringwald     uint16_t uuid16;
1583deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
1593deb3ec6SMatthias Ringwald 
1603deb3ec6SMatthias Ringwald     uint16_t start_group_handle;
1613deb3ec6SMatthias Ringwald     uint16_t end_group_handle;
1623deb3ec6SMatthias Ringwald 
1633deb3ec6SMatthias Ringwald     uint16_t query_start_handle;
1643deb3ec6SMatthias Ringwald     uint16_t query_end_handle;
1653deb3ec6SMatthias Ringwald 
1663deb3ec6SMatthias Ringwald     uint8_t  characteristic_properties;
1673deb3ec6SMatthias Ringwald     uint16_t characteristic_start_handle;
1683deb3ec6SMatthias Ringwald 
1693deb3ec6SMatthias Ringwald     uint16_t attribute_handle;
1703deb3ec6SMatthias Ringwald     uint16_t attribute_offset;
1713deb3ec6SMatthias Ringwald     uint16_t attribute_length;
1723deb3ec6SMatthias Ringwald     uint8_t* attribute_value;
1733deb3ec6SMatthias Ringwald 
1743deb3ec6SMatthias Ringwald     // read multiple characteristic values
1753deb3ec6SMatthias Ringwald     uint16_t    read_multiple_handle_count;
1763deb3ec6SMatthias Ringwald     uint16_t  * read_multiple_handles;
1773deb3ec6SMatthias Ringwald 
1783deb3ec6SMatthias Ringwald     uint16_t client_characteristic_configuration_handle;
1793deb3ec6SMatthias Ringwald     uint8_t  client_characteristic_configuration_value[2];
1803deb3ec6SMatthias Ringwald 
1813deb3ec6SMatthias Ringwald     uint8_t  filter_with_uuid;
1823deb3ec6SMatthias Ringwald     uint8_t  send_confirmation;
1833deb3ec6SMatthias Ringwald 
1843deb3ec6SMatthias Ringwald     int      le_device_index;
1853deb3ec6SMatthias Ringwald     uint8_t  cmac[8];
1863deb3ec6SMatthias Ringwald 
187ec820d77SMatthias Ringwald     btstack_timer_source_t gc_timeout;
188f4b33574SMatthias Ringwald 
189f4b33574SMatthias Ringwald #ifdef ENABLE_GATT_CLIENT_PAIRING
190f4b33574SMatthias Ringwald     uint8_t  security_counter;
191f4b33574SMatthias Ringwald     uint8_t  wait_for_pairing_complete;
192f4b33574SMatthias Ringwald     uint8_t  pending_error_code;
193f4b33574SMatthias Ringwald #endif
194f4b33574SMatthias Ringwald 
1953deb3ec6SMatthias Ringwald } gatt_client_t;
1963deb3ec6SMatthias Ringwald 
1979c662c9bSMatthias Ringwald typedef struct gatt_client_notification {
198665d90f2SMatthias Ringwald     btstack_linked_item_t    item;
199b6e96f14SMatthias Ringwald     btstack_packet_handler_t callback;
200711e6c80SMatthias Ringwald     hci_con_handle_t con_handle;
2019c662c9bSMatthias Ringwald     uint16_t attribute_handle;
2029c662c9bSMatthias Ringwald } gatt_client_notification_t;
2033deb3ec6SMatthias Ringwald 
2043deb3ec6SMatthias Ringwald /* API_START */
2053deb3ec6SMatthias Ringwald 
206d25c33e5SMatthias Ringwald typedef struct {
2073deb3ec6SMatthias Ringwald     uint16_t start_group_handle;
2083deb3ec6SMatthias Ringwald     uint16_t end_group_handle;
2093deb3ec6SMatthias Ringwald     uint16_t uuid16;
2103deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
211d25c33e5SMatthias Ringwald } gatt_client_service_t;
2123deb3ec6SMatthias Ringwald 
213d25c33e5SMatthias Ringwald typedef struct {
2143deb3ec6SMatthias Ringwald     uint16_t start_handle;
2153deb3ec6SMatthias Ringwald     uint16_t value_handle;
2163deb3ec6SMatthias Ringwald     uint16_t end_handle;
2173deb3ec6SMatthias Ringwald     uint16_t properties;
2183deb3ec6SMatthias Ringwald     uint16_t uuid16;
2193deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
220d25c33e5SMatthias Ringwald } gatt_client_characteristic_t;
2213deb3ec6SMatthias Ringwald 
222d25c33e5SMatthias Ringwald typedef struct {
2233deb3ec6SMatthias Ringwald     uint16_t handle;
2243deb3ec6SMatthias Ringwald     uint16_t uuid16;
2253deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
226d25c33e5SMatthias Ringwald } gatt_client_characteristic_descriptor_t;
2273deb3ec6SMatthias Ringwald 
2283deb3ec6SMatthias Ringwald /**
2293deb3ec6SMatthias Ringwald  * @brief Set up GATT client.
2303deb3ec6SMatthias Ringwald  */
2313deb3ec6SMatthias Ringwald void gatt_client_init(void);
2323deb3ec6SMatthias Ringwald 
2333deb3ec6SMatthias Ringwald /**
234616edd56SMatthias Ringwald  * @brief MTU is available after the first query has completed. If status is equal to 0, it returns the real value, otherwise the default value of 23.
235*6da84376SMilanka Ringwald  * @param con_handle
236*6da84376SMilanka Ringwald  * @param mtu
2373deb3ec6SMatthias Ringwald  */
238*6da84376SMilanka Ringwald 
239fc64f94aSMatthias Ringwald uint8_t gatt_client_get_mtu(hci_con_handle_t con_handle, uint16_t * mtu);
2403deb3ec6SMatthias Ringwald 
2413deb3ec6SMatthias Ringwald /**
242*6da84376SMilanka Ringwald  * @brief Sets whether a MTU Exchange Request shall be automatically send before the first attribute read request is send. Default is enabled.
243*6da84376SMilanka Ringwald  * @param enabled
2445cf6c434SJakob Krantz  */
2455cf6c434SJakob Krantz void gatt_client_mtu_enable_auto_negotiation(uint8_t enabled);
2465cf6c434SJakob Krantz 
2475cf6c434SJakob Krantz /**
2485cf6c434SJakob Krantz * @brief Sends a MTU Exchange Request, this allows for the client to exchange MTU when gatt_client_mtu_enable_auto_negotiation is disabled.
249*6da84376SMilanka Ringwald  * @param callback
250*6da84376SMilanka Ringwald  * @param con_handle
2515cf6c434SJakob Krantz  */
2525cf6c434SJakob Krantz void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
2535cf6c434SJakob Krantz 
2545cf6c434SJakob Krantz /**
2553deb3ec6SMatthias Ringwald  * @brief Returns if the GATT client is ready to receive a query. It is used with daemon.
256*6da84376SMilanka Ringwald  * @param con_handle
2573deb3ec6SMatthias Ringwald  */
258fc64f94aSMatthias Ringwald int gatt_client_is_ready(hci_con_handle_t con_handle);
2593deb3ec6SMatthias Ringwald 
2603deb3ec6SMatthias Ringwald /**
2615611a760SMatthias 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.
262*6da84376SMilanka Ringwald  * @param callback
263*6da84376SMilanka Ringwald  * @param con_handle
2643deb3ec6SMatthias Ringwald  */
265711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
2663deb3ec6SMatthias Ringwald 
2673deb3ec6SMatthias Ringwald /**
2685611a760SMatthias 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.
269*6da84376SMilanka Ringwald  * @param callback
270*6da84376SMilanka Ringwald  * @param con_handle
271*6da84376SMilanka Ringwald  * @param uuid16
2723deb3ec6SMatthias Ringwald  */
273711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16);
274*6da84376SMilanka Ringwald 
275*6da84376SMilanka Ringwald /**
276*6da84376SMilanka 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.
277*6da84376SMilanka Ringwald  * @param callback
278*6da84376SMilanka Ringwald  * @param con_handle
279*6da84376SMilanka Ringwald  * @param uuid128
280*6da84376SMilanka Ringwald  */
281*6da84376SMilanka 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);
2823deb3ec6SMatthias Ringwald 
2833deb3ec6SMatthias Ringwald /**
2845611a760SMatthias 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.
285*6da84376SMilanka Ringwald  * @param callback
286*6da84376SMilanka Ringwald  * @param con_handle
287*6da84376SMilanka Ringwald  * @param service
2883deb3ec6SMatthias Ringwald  */
289711e6c80SMatthias 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);
2903deb3ec6SMatthias Ringwald 
2913deb3ec6SMatthias Ringwald /**
2925611a760SMatthias 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.
293*6da84376SMilanka Ringwald  * @param callback
294*6da84376SMilanka Ringwald  * @param con_handle
295*6da84376SMilanka Ringwald  * @param service
2963deb3ec6SMatthias Ringwald  */
297711e6c80SMatthias 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);
2983deb3ec6SMatthias Ringwald 
2993deb3ec6SMatthias Ringwald /**
3005611a760SMatthias 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.
301*6da84376SMilanka Ringwald  * @param callback
302*6da84376SMilanka Ringwald  * @param con_handle
303*6da84376SMilanka Ringwald  * @param start_handle
304*6da84376SMilanka Ringwald  * @param end_handle
305*6da84376SMilanka Ringwald  * @param uuid16
3063deb3ec6SMatthias Ringwald  */
307711e6c80SMatthias 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);
308*6da84376SMilanka Ringwald 
309*6da84376SMilanka Ringwald /**
310*6da84376SMilanka 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.
311*6da84376SMilanka Ringwald  * @param callback
312*6da84376SMilanka Ringwald  * @param con_handle
313*6da84376SMilanka Ringwald  * @param start_handle
314*6da84376SMilanka Ringwald  * @param end_handle
315*6da84376SMilanka Ringwald  * @param uuid128
316*6da84376SMilanka Ringwald  */
317*6da84376SMilanka 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);
318*6da84376SMilanka Ringwald 
319*6da84376SMilanka Ringwald /**
320*6da84376SMilanka 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.
321*6da84376SMilanka Ringwald  * @param callback
322*6da84376SMilanka Ringwald  * @param con_handle
323*6da84376SMilanka Ringwald  * @param service
324*6da84376SMilanka Ringwald  * @param uuid16
325*6da84376SMilanka Ringwald  */
326711e6c80SMatthias 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);
327*6da84376SMilanka Ringwald 
328*6da84376SMilanka Ringwald /**
329*6da84376SMilanka 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.
330*6da84376SMilanka Ringwald  * @param callback
331*6da84376SMilanka Ringwald  * @param con_handle
332*6da84376SMilanka Ringwald  * @param service
333*6da84376SMilanka Ringwald  * @param uuid128
334*6da84376SMilanka Ringwald  */
335711e6c80SMatthias 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);
3363deb3ec6SMatthias Ringwald 
3373deb3ec6SMatthias Ringwald /**
3385611a760SMatthias 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.
339*6da84376SMilanka Ringwald  * @param callback
340*6da84376SMilanka Ringwald  * @param con_handle
341*6da84376SMilanka Ringwald  * @param characteristic
3423deb3ec6SMatthias Ringwald  */
343711e6c80SMatthias Ringwald uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t  *characteristic);
3443deb3ec6SMatthias Ringwald 
3453deb3ec6SMatthias Ringwald /**
3465611a760SMatthias 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.
347*6da84376SMilanka Ringwald  * @param callback
348*6da84376SMilanka Ringwald  * @param con_handle
349*6da84376SMilanka Ringwald  * @param characteristic
3503deb3ec6SMatthias Ringwald  */
351711e6c80SMatthias 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);
352*6da84376SMilanka Ringwald 
353*6da84376SMilanka Ringwald /**
354*6da84376SMilanka 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.
355*6da84376SMilanka Ringwald  * @param callback
356*6da84376SMilanka Ringwald  * @param con_handle
357*6da84376SMilanka Ringwald  * @param characteristic_value_handle
358*6da84376SMilanka Ringwald  */
359711e6c80SMatthias 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);
3603deb3ec6SMatthias Ringwald 
3613deb3ec6SMatthias Ringwald /**
3625611a760SMatthias 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.
363*6da84376SMilanka Ringwald  * @param callback
364*6da84376SMilanka Ringwald  * @param con_handle
365*6da84376SMilanka Ringwald  * @param start_handle
366*6da84376SMilanka Ringwald  * @param end_handle
367*6da84376SMilanka Ringwald  * @param uuid16
3683deb3ec6SMatthias Ringwald  */
369711e6c80SMatthias 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);
370*6da84376SMilanka Ringwald 
371*6da84376SMilanka Ringwald /**
372*6da84376SMilanka 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.
373*6da84376SMilanka Ringwald  * @param callback
374*6da84376SMilanka Ringwald  * @param con_handle
375*6da84376SMilanka Ringwald  * @param start_handle
376*6da84376SMilanka Ringwald  * @param end_handle
377*6da84376SMilanka Ringwald  * @param uuid128
378*6da84376SMilanka Ringwald  */
379711e6c80SMatthias 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);
3803deb3ec6SMatthias Ringwald 
3813deb3ec6SMatthias Ringwald /**
3825611a760SMatthias 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.
383*6da84376SMilanka Ringwald  * @param callback
384*6da84376SMilanka Ringwald  * @param con_handle
385*6da84376SMilanka Ringwald  * @param characteristic
3863deb3ec6SMatthias Ringwald  */
387711e6c80SMatthias 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);
388*6da84376SMilanka Ringwald 
389*6da84376SMilanka Ringwald /**
390*6da84376SMilanka 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.
391*6da84376SMilanka Ringwald  * @param callback
392*6da84376SMilanka Ringwald  * @param con_handle
393*6da84376SMilanka Ringwald  * @param characteristic_value_handle
394*6da84376SMilanka Ringwald  */
395711e6c80SMatthias 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);
396*6da84376SMilanka Ringwald 
397*6da84376SMilanka Ringwald /**
398*6da84376SMilanka 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.
399*6da84376SMilanka Ringwald  * @param callback
400*6da84376SMilanka Ringwald  * @param con_handle
401*6da84376SMilanka Ringwald  * @param characteristic_value_handle
402*6da84376SMilanka Ringwald  * @param offset
403*6da84376SMilanka Ringwald  */
404711e6c80SMatthias 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);
4053deb3ec6SMatthias Ringwald 
4063deb3ec6SMatthias Ringwald /*
4073deb3ec6SMatthias Ringwald  * @brief Read multiple characteristic values
408*6da84376SMilanka Ringwald  * @param callback
409*6da84376SMilanka Ringwald  * @param con_handle
410*6da84376SMilanka Ringwald  * @param num_value_handles
411*6da84376SMilanka Ringwald  * @param value_handles list of handles
4123deb3ec6SMatthias Ringwald  */
413711e6c80SMatthias 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);
4143deb3ec6SMatthias Ringwald 
4153deb3ec6SMatthias Ringwald /**
4163deb3ec6SMatthias Ringwald  * @brief Writes the characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed.
417*6da84376SMilanka Ringwald  * @param con_handle
418*6da84376SMilanka Ringwald  * @param characteristic_value_handle
419*6da84376SMilanka Ringwald  * @param length of data
420*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done
4213deb3ec6SMatthias Ringwald  */
422830ec672SMatthias 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);
4233deb3ec6SMatthias Ringwald 
4243deb3ec6SMatthias Ringwald /**
4253deb3ec6SMatthias Ringwald  * @brief Writes the authenticated characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed.
426*6da84376SMilanka Ringwald  * @param callback
427*6da84376SMilanka Ringwald  * @param con_handle
428*6da84376SMilanka Ringwald  * @param value_handle
429*6da84376SMilanka Ringwald  * @param message_len
430*6da84376SMilanka Ringwald  * @param message is not copied, make sure memory is accessible until write is done
4313deb3ec6SMatthias Ringwald  */
432*6da84376SMilanka 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);
4333deb3ec6SMatthias Ringwald 
4343deb3ec6SMatthias Ringwald /**
4355611a760SMatthias 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 status field is set to 0.
436*6da84376SMilanka Ringwald  * @param callback
437*6da84376SMilanka Ringwald  * @param con_handle
438*6da84376SMilanka Ringwald  * @param characteristic_value_handle
439*6da84376SMilanka Ringwald  * @param length of data
440*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
4413deb3ec6SMatthias Ringwald  */
442711e6c80SMatthias 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);
443*6da84376SMilanka Ringwald 
444*6da84376SMilanka Ringwald /**
445*6da84376SMilanka 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 status field is set to 0.
446*6da84376SMilanka Ringwald  * @param callback
447*6da84376SMilanka Ringwald  * @param con_handle
448*6da84376SMilanka Ringwald  * @param characteristic_value_handle
449*6da84376SMilanka Ringwald  * @param length of data
450*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
451*6da84376SMilanka Ringwald  */
452711e6c80SMatthias 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);
453*6da84376SMilanka Ringwald 
454*6da84376SMilanka Ringwald /**
455*6da84376SMilanka 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 status field is set to 0.
456*6da84376SMilanka Ringwald  * @param callback
457*6da84376SMilanka Ringwald  * @param con_handle
458*6da84376SMilanka Ringwald  * @param characteristic_value_handle
459*6da84376SMilanka Ringwald  * @param offset of value
460*6da84376SMilanka Ringwald  * @param length of data
461*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
462*6da84376SMilanka Ringwald  */
463711e6c80SMatthias 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);
4643deb3ec6SMatthias Ringwald 
4653deb3ec6SMatthias Ringwald /**
4665611a760SMatthias 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 status field is set to 0.
467*6da84376SMilanka Ringwald  * @param callback
468*6da84376SMilanka Ringwald  * @param con_handle
469*6da84376SMilanka Ringwald  * @param characteristic_value_handle
470*6da84376SMilanka Ringwald  * @param length of data
471*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
4723deb3ec6SMatthias Ringwald  */
473711e6c80SMatthias 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);
4743deb3ec6SMatthias Ringwald 
4753deb3ec6SMatthias Ringwald /**
4765611a760SMatthias 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.
477*6da84376SMilanka Ringwald  * @param callback
478*6da84376SMilanka Ringwald  * @param con_handle
479*6da84376SMilanka Ringwald  * @param descriptor
4803deb3ec6SMatthias Ringwald  */
481711e6c80SMatthias 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);
482*6da84376SMilanka Ringwald 
483*6da84376SMilanka Ringwald /**
484*6da84376SMilanka 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.
485*6da84376SMilanka Ringwald  * @param callback
486*6da84376SMilanka Ringwald  * @param con_handle
487*6da84376SMilanka Ringwald  * @param descriptor
488*6da84376SMilanka Ringwald  */
489711e6c80SMatthias 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);
4903deb3ec6SMatthias Ringwald 
4913deb3ec6SMatthias Ringwald /**
4925611a760SMatthias 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.
493*6da84376SMilanka Ringwald  * @param callback
494*6da84376SMilanka Ringwald  * @param con_handle
495*6da84376SMilanka Ringwald  * @param descriptor_handle
4963deb3ec6SMatthias Ringwald  */
497711e6c80SMatthias 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);
498*6da84376SMilanka Ringwald 
499*6da84376SMilanka Ringwald /**
500*6da84376SMilanka 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.
501*6da84376SMilanka Ringwald  * @param callback
502*6da84376SMilanka Ringwald  * @param con_handle
503*6da84376SMilanka Ringwald  * @param descriptor_handle
504*6da84376SMilanka Ringwald  */
505711e6c80SMatthias 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);
506*6da84376SMilanka Ringwald 
507*6da84376SMilanka Ringwald /**
508*6da84376SMilanka 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.
509*6da84376SMilanka Ringwald  * @param callback
510*6da84376SMilanka Ringwald  * @param con_handle
511*6da84376SMilanka Ringwald  * @param descriptor_handle
512*6da84376SMilanka Ringwald  * @param offset
513*6da84376SMilanka Ringwald  */
514711e6c80SMatthias 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);
5153deb3ec6SMatthias Ringwald 
5163deb3ec6SMatthias Ringwald /**
5175611a760SMatthias 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 status field is set to 0.
518*6da84376SMilanka Ringwald  * @param callback
519*6da84376SMilanka Ringwald  * @param con_handle
520*6da84376SMilanka Ringwald  * @param descriptor
521*6da84376SMilanka Ringwald  * @param length of data
522*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
5233deb3ec6SMatthias Ringwald  */
524711e6c80SMatthias 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);
525*6da84376SMilanka Ringwald 
526*6da84376SMilanka Ringwald /**
527*6da84376SMilanka 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 status field is set to 0.
528*6da84376SMilanka Ringwald  * @param callback
529*6da84376SMilanka Ringwald  * @param con_handle
530*6da84376SMilanka Ringwald  * @param descriptor_handle
531*6da84376SMilanka Ringwald  * @param length of data
532*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
533*6da84376SMilanka Ringwald  */
534711e6c80SMatthias 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);
535*6da84376SMilanka Ringwald 
536*6da84376SMilanka Ringwald /**
537*6da84376SMilanka 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 status field is set to 0.
538*6da84376SMilanka Ringwald  * @param callback
539*6da84376SMilanka Ringwald  * @param con_handle
540*6da84376SMilanka Ringwald  * @param descriptor
541*6da84376SMilanka Ringwald  * @param length of data
542*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
543*6da84376SMilanka Ringwald  */
544711e6c80SMatthias 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);
545*6da84376SMilanka Ringwald 
546*6da84376SMilanka Ringwald /**
547*6da84376SMilanka 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 status field is set to 0.
548*6da84376SMilanka Ringwald  * @param callback
549*6da84376SMilanka Ringwald  * @param con_handle
550*6da84376SMilanka Ringwald  * @param descriptor_handle
551*6da84376SMilanka Ringwald  * @param length of data
552*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
553*6da84376SMilanka Ringwald  */
554711e6c80SMatthias 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);
555*6da84376SMilanka Ringwald 
556*6da84376SMilanka Ringwald /**
557*6da84376SMilanka 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 status field is set to 0.
558*6da84376SMilanka Ringwald  * @param callback
559*6da84376SMilanka Ringwald  * @param con_handle
560*6da84376SMilanka Ringwald  * @param descriptor_handle
561*6da84376SMilanka Ringwald  * @param offset of value
562*6da84376SMilanka Ringwald  * @param length of data
563*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
564*6da84376SMilanka Ringwald  */
565711e6c80SMatthias 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);
5663deb3ec6SMatthias Ringwald 
5673deb3ec6SMatthias Ringwald /**
5683deb3ec6SMatthias Ringwald  * @brief Writes the client characteristic configuration of the specified characteristic. It is used to subscribe for notifications or indications of the characteristic value. For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value.
569*6da84376SMilanka Ringwald  * @param callback
570*6da84376SMilanka Ringwald  * @param con_handle
571*6da84376SMilanka Ringwald  * @param characteristic
572*6da84376SMilanka Ringwald  * @param configuration
5733deb3ec6SMatthias Ringwald  */
574711e6c80SMatthias 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);
5759c662c9bSMatthias Ringwald 
5769c662c9bSMatthias Ringwald /**
5779c662c9bSMatthias Ringwald  * @brief Register for notifications and indications of a characteristic enabled by gatt_client_write_client_characteristic_configuration
5789c662c9bSMatthias Ringwald  * @param notification struct used to store registration
579*6da84376SMilanka Ringwald  * @param callback
5809c662c9bSMatthias Ringwald  * @param con_handle
5819c662c9bSMatthias Ringwald  * @param characteristic
5829c662c9bSMatthias Ringwald  */
583*6da84376SMilanka 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);
5843deb3ec6SMatthias Ringwald 
5853deb3ec6SMatthias Ringwald /**
5861f734b5fSMatthias Ringwald  * @brief Stop listening to characteristic value updates registered with gatt_client_listen_for_characteristic_value_updates
5871f734b5fSMatthias Ringwald  * @param notification struct used in gatt_client_listen_for_characteristic_value_updates
5881f734b5fSMatthias Ringwald  */
5891f734b5fSMatthias Ringwald void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification);
5901f734b5fSMatthias Ringwald 
5911f734b5fSMatthias Ringwald /**
59247181045SMatthias Ringwald  * @brief Requests GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE that guarantees a single successful gatt_client_write_value_of_characteristic_without_response
593*6da84376SMilanka Ringwald  * @param callback
59447181045SMatthias Ringwald  * @param con_handle
59547181045SMatthias Ringwald  * @returns status
59647181045SMatthias Ringwald  */
59747181045SMatthias Ringwald uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
59847181045SMatthias Ringwald 
59947181045SMatthias Ringwald /**
600*6da84376SMilanka 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.
601*6da84376SMilanka Ringwald  * @param callback
602*6da84376SMilanka Ringwald  * @param con_handle
603*6da84376SMilanka Ringwald  * @param attribute_handle
604*6da84376SMilanka Ringwald  * @param offset of value
605*6da84376SMilanka Ringwald  * @param length of data
606*6da84376SMilanka Ringwald  * @param data is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
6073deb3ec6SMatthias Ringwald  */
608711e6c80SMatthias 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);
6093deb3ec6SMatthias Ringwald 
6103deb3ec6SMatthias Ringwald /**
611*6da84376SMilanka Ringwald  * @brief Commit transactional write. GATT_EVENT_QUERY_COMPLETE is received.
612*6da84376SMilanka Ringwald  * @param callback
613*6da84376SMilanka Ringwald  * @param con_handle
6143deb3ec6SMatthias Ringwald  */
615711e6c80SMatthias Ringwald uint8_t gatt_client_execute_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
6163deb3ec6SMatthias Ringwald 
6173deb3ec6SMatthias Ringwald /**
618*6da84376SMilanka Ringwald  * @brief Abort transactional write. GATT_EVENT_QUERY_COMPLETE is received.
619*6da84376SMilanka Ringwald  * @param callback
620*6da84376SMilanka Ringwald  * @param con_handle
6213deb3ec6SMatthias Ringwald  */
622711e6c80SMatthias Ringwald uint8_t gatt_client_cancel_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle);
6233deb3ec6SMatthias Ringwald 
6243deb3ec6SMatthias Ringwald /* API_END */
6253deb3ec6SMatthias Ringwald 
6266ba2ad22SMatthias Ringwald // used by generated btstack_event.c
6276ba2ad22SMatthias Ringwald 
628313e337bSMatthias Ringwald void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t *service);
629313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic);
630313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor);
6316ba2ad22SMatthias Ringwald 
6323deb3ec6SMatthias Ringwald #if defined __cplusplus
6333deb3ec6SMatthias Ringwald }
6343deb3ec6SMatthias Ringwald #endif
6353deb3ec6SMatthias Ringwald 
6363deb3ec6SMatthias Ringwald #endif
637