xref: /btstack/src/ble/gatt_client.h (revision 3deb3ec68039c68a16974dffc53343233662f909)
1*3deb3ec6SMatthias Ringwald /*
2*3deb3ec6SMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
3*3deb3ec6SMatthias Ringwald  *
4*3deb3ec6SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5*3deb3ec6SMatthias Ringwald  * modification, are permitted provided that the following conditions
6*3deb3ec6SMatthias Ringwald  * are met:
7*3deb3ec6SMatthias Ringwald  *
8*3deb3ec6SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9*3deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10*3deb3ec6SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11*3deb3ec6SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12*3deb3ec6SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13*3deb3ec6SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14*3deb3ec6SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15*3deb3ec6SMatthias Ringwald  *    from this software without specific prior written permission.
16*3deb3ec6SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17*3deb3ec6SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18*3deb3ec6SMatthias Ringwald  *    monetary gain.
19*3deb3ec6SMatthias Ringwald  *
20*3deb3ec6SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21*3deb3ec6SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*3deb3ec6SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*3deb3ec6SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24*3deb3ec6SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25*3deb3ec6SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26*3deb3ec6SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27*3deb3ec6SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28*3deb3ec6SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29*3deb3ec6SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30*3deb3ec6SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*3deb3ec6SMatthias Ringwald  * SUCH DAMAGE.
32*3deb3ec6SMatthias Ringwald  *
33*3deb3ec6SMatthias Ringwald  * Please inquire about commercial licensing options at
34*3deb3ec6SMatthias Ringwald  * [email protected]
35*3deb3ec6SMatthias Ringwald  *
36*3deb3ec6SMatthias Ringwald  */
37*3deb3ec6SMatthias Ringwald 
38*3deb3ec6SMatthias Ringwald 
39*3deb3ec6SMatthias Ringwald #ifndef btstack_gatt_client_h
40*3deb3ec6SMatthias Ringwald #define btstack_gatt_client_h
41*3deb3ec6SMatthias Ringwald 
42*3deb3ec6SMatthias Ringwald #include "hci.h"
43*3deb3ec6SMatthias Ringwald 
44*3deb3ec6SMatthias Ringwald #if defined __cplusplus
45*3deb3ec6SMatthias Ringwald extern "C" {
46*3deb3ec6SMatthias Ringwald #endif
47*3deb3ec6SMatthias Ringwald 
48*3deb3ec6SMatthias Ringwald typedef struct le_event {
49*3deb3ec6SMatthias Ringwald     uint8_t   type;
50*3deb3ec6SMatthias Ringwald     uint16_t handle;
51*3deb3ec6SMatthias Ringwald } le_event_t;
52*3deb3ec6SMatthias Ringwald 
53*3deb3ec6SMatthias Ringwald typedef void (*gatt_client_callback_t)(uint8_t packet_type, uint8_t *packet, uint16_t size);
54*3deb3ec6SMatthias Ringwald 
55*3deb3ec6SMatthias Ringwald typedef enum {
56*3deb3ec6SMatthias Ringwald     P_READY,
57*3deb3ec6SMatthias Ringwald     P_W2_SEND_SERVICE_QUERY,
58*3deb3ec6SMatthias Ringwald     P_W4_SERVICE_QUERY_RESULT,
59*3deb3ec6SMatthias Ringwald     P_W2_SEND_SERVICE_WITH_UUID_QUERY,
60*3deb3ec6SMatthias Ringwald     P_W4_SERVICE_WITH_UUID_RESULT,
61*3deb3ec6SMatthias Ringwald 
62*3deb3ec6SMatthias Ringwald     P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY,
63*3deb3ec6SMatthias Ringwald     P_W4_ALL_CHARACTERISTICS_OF_SERVICE_QUERY_RESULT,
64*3deb3ec6SMatthias Ringwald     P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY,
65*3deb3ec6SMatthias Ringwald     P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT,
66*3deb3ec6SMatthias Ringwald 
67*3deb3ec6SMatthias Ringwald     P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY,
68*3deb3ec6SMatthias Ringwald     P_W4_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT,
69*3deb3ec6SMatthias Ringwald 
70*3deb3ec6SMatthias Ringwald     P_W2_SEND_INCLUDED_SERVICE_QUERY,
71*3deb3ec6SMatthias Ringwald     P_W4_INCLUDED_SERVICE_QUERY_RESULT,
72*3deb3ec6SMatthias Ringwald     P_W2_SEND_INCLUDED_SERVICE_WITH_UUID_QUERY,
73*3deb3ec6SMatthias Ringwald     P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT,
74*3deb3ec6SMatthias Ringwald 
75*3deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY,
76*3deb3ec6SMatthias Ringwald     P_W4_READ_CHARACTERISTIC_VALUE_RESULT,
77*3deb3ec6SMatthias Ringwald 
78*3deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BLOB_QUERY,
79*3deb3ec6SMatthias Ringwald     P_W4_READ_BLOB_RESULT,
80*3deb3ec6SMatthias Ringwald 
81*3deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BY_TYPE_REQUEST,
82*3deb3ec6SMatthias Ringwald     P_W4_READ_BY_TYPE_RESPONSE,
83*3deb3ec6SMatthias Ringwald 
84*3deb3ec6SMatthias Ringwald     P_W2_SEND_READ_MULTIPLE_REQUEST,
85*3deb3ec6SMatthias Ringwald     P_W4_READ_MULTIPLE_RESPONSE,
86*3deb3ec6SMatthias Ringwald 
87*3deb3ec6SMatthias Ringwald     P_W2_SEND_WRITE_CHARACTERISTIC_VALUE,
88*3deb3ec6SMatthias Ringwald     P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT,
89*3deb3ec6SMatthias Ringwald 
90*3deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE,
91*3deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_RESULT,
92*3deb3ec6SMatthias Ringwald     P_W2_PREPARE_RELIABLE_WRITE,
93*3deb3ec6SMatthias Ringwald     P_W4_PREPARE_RELIABLE_WRITE_RESULT,
94*3deb3ec6SMatthias Ringwald 
95*3deb3ec6SMatthias Ringwald     P_W2_EXECUTE_PREPARED_WRITE,
96*3deb3ec6SMatthias Ringwald     P_W4_EXECUTE_PREPARED_WRITE_RESULT,
97*3deb3ec6SMatthias Ringwald     P_W2_CANCEL_PREPARED_WRITE,
98*3deb3ec6SMatthias Ringwald     P_W4_CANCEL_PREPARED_WRITE_RESULT,
99*3deb3ec6SMatthias Ringwald     P_W2_CANCEL_PREPARED_WRITE_DATA_MISMATCH,
100*3deb3ec6SMatthias Ringwald     P_W4_CANCEL_PREPARED_WRITE_DATA_MISMATCH_RESULT,
101*3deb3ec6SMatthias Ringwald 
102*3deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY,
103*3deb3ec6SMatthias Ringwald     P_W4_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT,
104*3deb3ec6SMatthias Ringwald     P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION,
105*3deb3ec6SMatthias Ringwald     P_W4_CLIENT_CHARACTERISTIC_CONFIGURATION_RESULT,
106*3deb3ec6SMatthias Ringwald 
107*3deb3ec6SMatthias Ringwald     P_W2_SEND_READ_CHARACTERISTIC_DESCRIPTOR_QUERY,
108*3deb3ec6SMatthias Ringwald     P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT,
109*3deb3ec6SMatthias Ringwald 
110*3deb3ec6SMatthias Ringwald     P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY,
111*3deb3ec6SMatthias Ringwald     P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT,
112*3deb3ec6SMatthias Ringwald 
113*3deb3ec6SMatthias Ringwald     P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR,
114*3deb3ec6SMatthias Ringwald     P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
115*3deb3ec6SMatthias Ringwald 
116*3deb3ec6SMatthias Ringwald     // all long writes use this
117*3deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR,
118*3deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
119*3deb3ec6SMatthias Ringwald     P_W2_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR,
120*3deb3ec6SMatthias Ringwald     P_W4_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT,
121*3deb3ec6SMatthias Ringwald 
122*3deb3ec6SMatthias Ringwald     // gatt reliable write API use this (manual version of the above)
123*3deb3ec6SMatthias Ringwald     P_W2_PREPARE_WRITE_SINGLE,
124*3deb3ec6SMatthias Ringwald     P_W4_PREPARE_WRITE_SINGLE_RESULT,
125*3deb3ec6SMatthias Ringwald 
126*3deb3ec6SMatthias Ringwald     P_W4_CMAC_READY,
127*3deb3ec6SMatthias Ringwald     P_W4_CMAC_RESULT,
128*3deb3ec6SMatthias Ringwald     P_W2_SEND_SIGNED_WRITE,
129*3deb3ec6SMatthias Ringwald     P_W4_SEND_SINGED_WRITE_DONE,
130*3deb3ec6SMatthias Ringwald } gatt_client_state_t;
131*3deb3ec6SMatthias Ringwald 
132*3deb3ec6SMatthias Ringwald 
133*3deb3ec6SMatthias Ringwald typedef enum{
134*3deb3ec6SMatthias Ringwald     SEND_MTU_EXCHANGE,
135*3deb3ec6SMatthias Ringwald     SENT_MTU_EXCHANGE,
136*3deb3ec6SMatthias Ringwald     MTU_EXCHANGED
137*3deb3ec6SMatthias Ringwald } gatt_client_mtu_t;
138*3deb3ec6SMatthias Ringwald 
139*3deb3ec6SMatthias Ringwald typedef struct gatt_client{
140*3deb3ec6SMatthias Ringwald     linked_item_t    item;
141*3deb3ec6SMatthias Ringwald     // TODO: rename gatt_client_state -> state
142*3deb3ec6SMatthias Ringwald     gatt_client_state_t gatt_client_state;
143*3deb3ec6SMatthias Ringwald 
144*3deb3ec6SMatthias Ringwald     // subclient
145*3deb3ec6SMatthias Ringwald     uint16_t subclient_id;
146*3deb3ec6SMatthias Ringwald 
147*3deb3ec6SMatthias Ringwald     uint16_t handle;
148*3deb3ec6SMatthias Ringwald 
149*3deb3ec6SMatthias Ringwald     uint8_t   address_type;
150*3deb3ec6SMatthias Ringwald     bd_addr_t address;
151*3deb3ec6SMatthias Ringwald     uint16_t mtu;
152*3deb3ec6SMatthias Ringwald     gatt_client_mtu_t mtu_state;
153*3deb3ec6SMatthias Ringwald 
154*3deb3ec6SMatthias Ringwald     uint16_t uuid16;
155*3deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
156*3deb3ec6SMatthias Ringwald 
157*3deb3ec6SMatthias Ringwald     uint16_t start_group_handle;
158*3deb3ec6SMatthias Ringwald     uint16_t end_group_handle;
159*3deb3ec6SMatthias Ringwald 
160*3deb3ec6SMatthias Ringwald     uint16_t query_start_handle;
161*3deb3ec6SMatthias Ringwald     uint16_t query_end_handle;
162*3deb3ec6SMatthias Ringwald 
163*3deb3ec6SMatthias Ringwald     uint8_t  characteristic_properties;
164*3deb3ec6SMatthias Ringwald     uint16_t characteristic_start_handle;
165*3deb3ec6SMatthias Ringwald 
166*3deb3ec6SMatthias Ringwald     uint16_t attribute_handle;
167*3deb3ec6SMatthias Ringwald     uint16_t attribute_offset;
168*3deb3ec6SMatthias Ringwald     uint16_t attribute_length;
169*3deb3ec6SMatthias Ringwald     uint8_t* attribute_value;
170*3deb3ec6SMatthias Ringwald 
171*3deb3ec6SMatthias Ringwald     // read multiple characteristic values
172*3deb3ec6SMatthias Ringwald     uint16_t    read_multiple_handle_count;
173*3deb3ec6SMatthias Ringwald     uint16_t  * read_multiple_handles;
174*3deb3ec6SMatthias Ringwald 
175*3deb3ec6SMatthias Ringwald     uint16_t client_characteristic_configuration_handle;
176*3deb3ec6SMatthias Ringwald     uint8_t  client_characteristic_configuration_value[2];
177*3deb3ec6SMatthias Ringwald 
178*3deb3ec6SMatthias Ringwald     uint8_t  filter_with_uuid;
179*3deb3ec6SMatthias Ringwald     uint8_t  send_confirmation;
180*3deb3ec6SMatthias Ringwald 
181*3deb3ec6SMatthias Ringwald     int      le_device_index;
182*3deb3ec6SMatthias Ringwald     uint8_t  cmac[8];
183*3deb3ec6SMatthias Ringwald 
184*3deb3ec6SMatthias Ringwald     timer_source_t gc_timeout;
185*3deb3ec6SMatthias Ringwald } gatt_client_t;
186*3deb3ec6SMatthias Ringwald 
187*3deb3ec6SMatthias Ringwald typedef struct gatt_subclient {
188*3deb3ec6SMatthias Ringwald     linked_item_t   item;
189*3deb3ec6SMatthias Ringwald     uint16_t        id;
190*3deb3ec6SMatthias Ringwald     gatt_client_callback_t callback;
191*3deb3ec6SMatthias Ringwald } gatt_subclient_t;
192*3deb3ec6SMatthias Ringwald 
193*3deb3ec6SMatthias Ringwald /* API_START */
194*3deb3ec6SMatthias Ringwald 
195*3deb3ec6SMatthias Ringwald typedef struct le_service{
196*3deb3ec6SMatthias Ringwald     uint16_t start_group_handle;
197*3deb3ec6SMatthias Ringwald     uint16_t end_group_handle;
198*3deb3ec6SMatthias Ringwald     uint16_t uuid16;
199*3deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
200*3deb3ec6SMatthias Ringwald } le_service_t;
201*3deb3ec6SMatthias Ringwald 
202*3deb3ec6SMatthias Ringwald typedef struct le_characteristic{
203*3deb3ec6SMatthias Ringwald     uint16_t start_handle;
204*3deb3ec6SMatthias Ringwald     uint16_t value_handle;
205*3deb3ec6SMatthias Ringwald     uint16_t end_handle;
206*3deb3ec6SMatthias Ringwald     uint16_t properties;
207*3deb3ec6SMatthias Ringwald     uint16_t uuid16;
208*3deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
209*3deb3ec6SMatthias Ringwald } le_characteristic_t;
210*3deb3ec6SMatthias Ringwald 
211*3deb3ec6SMatthias Ringwald typedef struct le_characteristic_descriptor{
212*3deb3ec6SMatthias Ringwald     uint16_t handle;
213*3deb3ec6SMatthias Ringwald     uint16_t uuid16;
214*3deb3ec6SMatthias Ringwald     uint8_t  uuid128[16];
215*3deb3ec6SMatthias Ringwald } le_characteristic_descriptor_t;
216*3deb3ec6SMatthias Ringwald 
217*3deb3ec6SMatthias Ringwald /**
218*3deb3ec6SMatthias Ringwald  * @brief Set up GATT client.
219*3deb3ec6SMatthias Ringwald  */
220*3deb3ec6SMatthias Ringwald void gatt_client_init(void);
221*3deb3ec6SMatthias Ringwald 
222*3deb3ec6SMatthias Ringwald /**
223*3deb3ec6SMatthias Ringwald  * @brief Register callback (packet handler) for GATT client. Returns GATT client ID.
224*3deb3ec6SMatthias Ringwald  */
225*3deb3ec6SMatthias Ringwald uint16_t gatt_client_register_packet_handler (gatt_client_callback_t callback);
226*3deb3ec6SMatthias Ringwald 
227*3deb3ec6SMatthias Ringwald /**
228*3deb3ec6SMatthias Ringwald  * @brief Unregister callback (packet handler) for GATT client.
229*3deb3ec6SMatthias Ringwald  */
230*3deb3ec6SMatthias Ringwald void gatt_client_unregister_packet_handler(uint16_t gatt_client_id);
231*3deb3ec6SMatthias Ringwald 
232*3deb3ec6SMatthias Ringwald /**
233*3deb3ec6SMatthias Ringwald  * @brief MTU is available after the first query has completed. If status is equal to BLE_PERIPHERAL_OK, it returns the real value, otherwise the default value of 23.
234*3deb3ec6SMatthias Ringwald  */
235*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_get_mtu(uint16_t handle, uint16_t * mtu);
236*3deb3ec6SMatthias Ringwald 
237*3deb3ec6SMatthias Ringwald /**
238*3deb3ec6SMatthias Ringwald  * @brief Returns if the GATT client is ready to receive a query. It is used with daemon.
239*3deb3ec6SMatthias Ringwald  */
240*3deb3ec6SMatthias Ringwald int gatt_client_is_ready(uint16_t handle);
241*3deb3ec6SMatthias Ringwald 
242*3deb3ec6SMatthias Ringwald /**
243*3deb3ec6SMatthias Ringwald  * @brief Discovers all primary services. For each found service, an le_service_event_t with type set to GATT_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t, with type set to GATT_QUERY_COMPLETE, marks the end of discovery.
244*3deb3ec6SMatthias Ringwald  */
245*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_primary_services(uint16_t gatt_client_id, uint16_t con_handle);
246*3deb3ec6SMatthias Ringwald 
247*3deb3ec6SMatthias Ringwald /**
248*3deb3ec6SMatthias 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_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t, with type set to GATT_QUERY_COMPLETE, marks the end of discovery.
249*3deb3ec6SMatthias Ringwald  */
250*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_primary_services_by_uuid16(uint16_t gatt_client_id, uint16_t con_handle, uint16_t uuid16);
251*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_primary_services_by_uuid128(uint16_t gatt_client_id, uint16_t con_handle, const uint8_t  * uuid);
252*3deb3ec6SMatthias Ringwald 
253*3deb3ec6SMatthias Ringwald /**
254*3deb3ec6SMatthias Ringwald  * @brief Finds included services within the specified service. For each found included service, an le_service_event_t with type set to GATT_INCLUDED_SERVICE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_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.
255*3deb3ec6SMatthias Ringwald  */
256*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_find_included_services_for_service(uint16_t gatt_client_id, uint16_t con_handle, le_service_t  *service);
257*3deb3ec6SMatthias Ringwald 
258*3deb3ec6SMatthias Ringwald /**
259*3deb3ec6SMatthias Ringwald  * @brief Discovers all characteristics within the specified service. For each found characteristic, an le_characteristics_event_t with type set to GATT_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of discovery.
260*3deb3ec6SMatthias Ringwald  */
261*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_characteristics_for_service(uint16_t gatt_client_id, uint16_t con_handle, le_service_t  *service);
262*3deb3ec6SMatthias Ringwald 
263*3deb3ec6SMatthias Ringwald /**
264*3deb3ec6SMatthias 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_CHARACTERISTIC_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of discovery.
265*3deb3ec6SMatthias Ringwald  */
266*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_characteristics_for_handle_range_by_uuid16(uint16_t gatt_client_id, uint16_t con_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid16);
267*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_characteristics_for_handle_range_by_uuid128(uint16_t gatt_client_id, uint16_t con_handle, uint16_t start_handle, uint16_t end_handle, uint8_t  * uuid);
268*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_characteristics_for_service_by_uuid16 (uint16_t gatt_client_id, uint16_t con_handle, le_service_t  *service, uint16_t  uuid16);
269*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_characteristics_for_service_by_uuid128(uint16_t gatt_client_id, uint16_t con_handle, le_service_t  *service, uint8_t  * uuid128);
270*3deb3ec6SMatthias Ringwald 
271*3deb3ec6SMatthias Ringwald /**
272*3deb3ec6SMatthias 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_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of discovery.
273*3deb3ec6SMatthias Ringwald  */
274*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_discover_characteristic_descriptors(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_t  *characteristic);
275*3deb3ec6SMatthias Ringwald 
276*3deb3ec6SMatthias Ringwald /**
277*3deb3ec6SMatthias 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_CHARACTERISTIC_VALUE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of read.
278*3deb3ec6SMatthias Ringwald  */
279*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_t  *characteristic);
280*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_value_of_characteristic_using_value_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle);
281*3deb3ec6SMatthias Ringwald 
282*3deb3ec6SMatthias Ringwald /**
283*3deb3ec6SMatthias 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_CHARACTERISTIC_VALUE_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of read.
284*3deb3ec6SMatthias Ringwald  */
285*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_value_of_characteristics_by_uuid16(uint16_t gatt_client_id, uint16_t con_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid16);
286*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_value_of_characteristics_by_uuid128(uint16_t gatt_client_id, uint16_t con_handle, uint16_t start_handle, uint16_t end_handle, uint8_t * uuid128);
287*3deb3ec6SMatthias Ringwald 
288*3deb3ec6SMatthias Ringwald /**
289*3deb3ec6SMatthias 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_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_QUERY_COMPLETE, mark the end of read.
290*3deb3ec6SMatthias Ringwald  */
291*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_long_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_t  *characteristic);
292*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_long_value_of_characteristic_using_value_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle);
293*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_long_value_of_characteristic_using_value_handle_with_offset(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t offset);
294*3deb3ec6SMatthias Ringwald 
295*3deb3ec6SMatthias Ringwald /*
296*3deb3ec6SMatthias Ringwald  * @brief Read multiple characteristic values
297*3deb3ec6SMatthias Ringwald  * @param number handles
298*3deb3ec6SMatthias Ringwald  * @param list_of_handles list of handles
299*3deb3ec6SMatthias Ringwald  */
300*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_multiple_characteristic_values(uint16_t gatt_client_id, uint16_t con_handle, int num_value_handles, uint16_t * value_handles);
301*3deb3ec6SMatthias Ringwald 
302*3deb3ec6SMatthias Ringwald /**
303*3deb3ec6SMatthias Ringwald  * @brief Writes the characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed.
304*3deb3ec6SMatthias Ringwald  */
305*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_value_of_characteristic_without_response(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t  * data);
306*3deb3ec6SMatthias Ringwald 
307*3deb3ec6SMatthias Ringwald /**
308*3deb3ec6SMatthias Ringwald  * @brief Writes the authenticated characteristic value using the characteristic's value handle without an acknowledgment that the write was successfully performed.
309*3deb3ec6SMatthias Ringwald  */
310*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_signed_write_without_response(uint16_t gatt_client_id, uint16_t con_handle, uint16_t handle, uint16_t message_len, uint8_t  * message);
311*3deb3ec6SMatthias Ringwald 
312*3deb3ec6SMatthias Ringwald /**
313*3deb3ec6SMatthias Ringwald  * @brief Writes the characteristic value using the characteristic's value handle. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of write. The write is successfully performed, if the event's status field is set to 0.
314*3deb3ec6SMatthias Ringwald  */
315*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t  * data);
316*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_long_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t  * data);
317*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_long_value_of_characteristic_with_offset(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t offset, uint16_t length, uint8_t  * data);
318*3deb3ec6SMatthias Ringwald 
319*3deb3ec6SMatthias Ringwald /**
320*3deb3ec6SMatthias 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_QUERY_COMPLETE marks the end of write. The write is successfully performed, if the event's status field is set to 0.
321*3deb3ec6SMatthias Ringwald  */
322*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_reliable_write_long_value_of_characteristic(uint16_t gatt_client_id, uint16_t con_handle, uint16_t characteristic_value_handle, uint16_t length, uint8_t  * data);
323*3deb3ec6SMatthias Ringwald 
324*3deb3ec6SMatthias Ringwald /**
325*3deb3ec6SMatthias 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_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of read.
326*3deb3ec6SMatthias Ringwald  */
327*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_characteristic_descriptor(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_descriptor_t  * descriptor);
328*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_characteristic_descriptor_using_descriptor_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle);
329*3deb3ec6SMatthias Ringwald 
330*3deb3ec6SMatthias Ringwald /**
331*3deb3ec6SMatthias 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_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT will be generated and passed to the registered callback. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of read.
332*3deb3ec6SMatthias Ringwald  */
333*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_long_characteristic_descriptor(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_descriptor_t  * descriptor);
334*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_long_characteristic_descriptor_using_descriptor_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle);
335*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_read_long_characteristic_descriptor_using_descriptor_handle_with_offset(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t offset);
336*3deb3ec6SMatthias Ringwald 
337*3deb3ec6SMatthias Ringwald /**
338*3deb3ec6SMatthias Ringwald  * @brief Writes the characteristic descriptor using its handle. The gatt_complete_event_t with type set to GATT_QUERY_COMPLETE, marks the end of write. The write is successfully performed, if the event's status field is set to 0.
339*3deb3ec6SMatthias Ringwald  */
340*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_characteristic_descriptor(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_descriptor_t  * descriptor, uint16_t length, uint8_t  * data);
341*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_characteristic_descriptor_using_descriptor_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t length, uint8_t  * data);
342*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_long_characteristic_descriptor(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_descriptor_t  * descriptor, uint16_t length, uint8_t  * data);
343*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t length, uint8_t  * data);
344*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset(uint16_t gatt_client_id, uint16_t con_handle, uint16_t descriptor_handle, uint16_t offset, uint16_t length, uint8_t  * data);
345*3deb3ec6SMatthias Ringwald 
346*3deb3ec6SMatthias Ringwald /**
347*3deb3ec6SMatthias 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.
348*3deb3ec6SMatthias Ringwald  */
349*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_write_client_characteristic_configuration(uint16_t gatt_client_id, uint16_t con_handle, le_characteristic_t * characteristic, uint16_t configuration);
350*3deb3ec6SMatthias Ringwald 
351*3deb3ec6SMatthias Ringwald /**
352*3deb3ec6SMatthias Ringwald  * @brief -> gatt complete event
353*3deb3ec6SMatthias Ringwald  */
354*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_prepare_write(uint16_t gatt_client_id, uint16_t con_handle, uint16_t attribute_handle, uint16_t offset, uint16_t length, uint8_t * data);
355*3deb3ec6SMatthias Ringwald 
356*3deb3ec6SMatthias Ringwald /**
357*3deb3ec6SMatthias Ringwald  * @brief -> gatt complete event
358*3deb3ec6SMatthias Ringwald  */
359*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_execute_write(uint16_t gatt_client_id, uint16_t con_handle);
360*3deb3ec6SMatthias Ringwald 
361*3deb3ec6SMatthias Ringwald /**
362*3deb3ec6SMatthias Ringwald  * @brief -> gatt complete event
363*3deb3ec6SMatthias Ringwald  */
364*3deb3ec6SMatthias Ringwald le_command_status_t gatt_client_cancel_write(uint16_t gatt_client_id, uint16_t con_handle);
365*3deb3ec6SMatthias Ringwald 
366*3deb3ec6SMatthias Ringwald 
367*3deb3ec6SMatthias Ringwald /* API_END */
368*3deb3ec6SMatthias Ringwald 
369*3deb3ec6SMatthias Ringwald // only used for testing
370*3deb3ec6SMatthias Ringwald void gatt_client_pts_suppress_mtu_exchange(void);
371*3deb3ec6SMatthias Ringwald 
372*3deb3ec6SMatthias Ringwald #if defined __cplusplus
373*3deb3ec6SMatthias Ringwald }
374*3deb3ec6SMatthias Ringwald #endif
375*3deb3ec6SMatthias Ringwald 
376*3deb3ec6SMatthias Ringwald #endif
377