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