13deb3ec6SMatthias Ringwald /* 23deb3ec6SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 33deb3ec6SMatthias Ringwald * 43deb3ec6SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 53deb3ec6SMatthias Ringwald * modification, are permitted provided that the following conditions 63deb3ec6SMatthias Ringwald * are met: 73deb3ec6SMatthias Ringwald * 83deb3ec6SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 93deb3ec6SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 103deb3ec6SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 113deb3ec6SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 123deb3ec6SMatthias Ringwald * documentation and/or other materials provided with the distribution. 133deb3ec6SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 143deb3ec6SMatthias Ringwald * contributors may be used to endorse or promote products derived 153deb3ec6SMatthias Ringwald * from this software without specific prior written permission. 163deb3ec6SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 173deb3ec6SMatthias Ringwald * personal benefit and not for any commercial purpose or for 183deb3ec6SMatthias Ringwald * monetary gain. 193deb3ec6SMatthias Ringwald * 203deb3ec6SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 213deb3ec6SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 223deb3ec6SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 242fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 253deb3ec6SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 263deb3ec6SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 273deb3ec6SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 283deb3ec6SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 293deb3ec6SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 303deb3ec6SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 313deb3ec6SMatthias Ringwald * SUCH DAMAGE. 323deb3ec6SMatthias Ringwald * 333deb3ec6SMatthias Ringwald * Please inquire about commercial licensing options at 343deb3ec6SMatthias Ringwald * [email protected] 353deb3ec6SMatthias Ringwald * 363deb3ec6SMatthias Ringwald */ 373deb3ec6SMatthias Ringwald 38fe5a6c4eSMilanka Ringwald /** 39fe5a6c4eSMilanka Ringwald * @title GATT Client 40fe5a6c4eSMilanka Ringwald * 41fe5a6c4eSMilanka Ringwald */ 423deb3ec6SMatthias Ringwald 433deb3ec6SMatthias Ringwald #ifndef btstack_gatt_client_h 443deb3ec6SMatthias Ringwald #define btstack_gatt_client_h 453deb3ec6SMatthias Ringwald 463deb3ec6SMatthias Ringwald #include "hci.h" 473deb3ec6SMatthias Ringwald 483deb3ec6SMatthias Ringwald #if defined __cplusplus 493deb3ec6SMatthias Ringwald extern "C" { 503deb3ec6SMatthias Ringwald #endif 513deb3ec6SMatthias Ringwald 523deb3ec6SMatthias Ringwald typedef enum { 533deb3ec6SMatthias Ringwald P_READY, 543deb3ec6SMatthias Ringwald P_W2_SEND_SERVICE_QUERY, 553deb3ec6SMatthias Ringwald P_W4_SERVICE_QUERY_RESULT, 563deb3ec6SMatthias Ringwald P_W2_SEND_SERVICE_WITH_UUID_QUERY, 573deb3ec6SMatthias Ringwald P_W4_SERVICE_WITH_UUID_RESULT, 583deb3ec6SMatthias Ringwald 593deb3ec6SMatthias Ringwald P_W2_SEND_ALL_CHARACTERISTICS_OF_SERVICE_QUERY, 603deb3ec6SMatthias Ringwald P_W4_ALL_CHARACTERISTICS_OF_SERVICE_QUERY_RESULT, 613deb3ec6SMatthias Ringwald P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY, 623deb3ec6SMatthias Ringwald P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT, 633deb3ec6SMatthias Ringwald 643deb3ec6SMatthias Ringwald P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY, 653deb3ec6SMatthias Ringwald P_W4_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT, 663deb3ec6SMatthias Ringwald 673deb3ec6SMatthias Ringwald P_W2_SEND_INCLUDED_SERVICE_QUERY, 683deb3ec6SMatthias Ringwald P_W4_INCLUDED_SERVICE_QUERY_RESULT, 693deb3ec6SMatthias Ringwald P_W2_SEND_INCLUDED_SERVICE_WITH_UUID_QUERY, 703deb3ec6SMatthias Ringwald P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT, 713deb3ec6SMatthias Ringwald 723deb3ec6SMatthias Ringwald P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY, 733deb3ec6SMatthias Ringwald P_W4_READ_CHARACTERISTIC_VALUE_RESULT, 743deb3ec6SMatthias Ringwald 753deb3ec6SMatthias Ringwald P_W2_SEND_READ_BLOB_QUERY, 763deb3ec6SMatthias Ringwald P_W4_READ_BLOB_RESULT, 773deb3ec6SMatthias Ringwald 783deb3ec6SMatthias Ringwald P_W2_SEND_READ_BY_TYPE_REQUEST, 793deb3ec6SMatthias Ringwald P_W4_READ_BY_TYPE_RESPONSE, 803deb3ec6SMatthias Ringwald 813deb3ec6SMatthias Ringwald P_W2_SEND_READ_MULTIPLE_REQUEST, 823deb3ec6SMatthias Ringwald P_W4_READ_MULTIPLE_RESPONSE, 833deb3ec6SMatthias Ringwald 843deb3ec6SMatthias Ringwald P_W2_SEND_WRITE_CHARACTERISTIC_VALUE, 853deb3ec6SMatthias Ringwald P_W4_WRITE_CHARACTERISTIC_VALUE_RESULT, 863deb3ec6SMatthias Ringwald 873deb3ec6SMatthias Ringwald P_W2_PREPARE_WRITE, 883deb3ec6SMatthias Ringwald P_W4_PREPARE_WRITE_RESULT, 893deb3ec6SMatthias Ringwald P_W2_PREPARE_RELIABLE_WRITE, 903deb3ec6SMatthias Ringwald P_W4_PREPARE_RELIABLE_WRITE_RESULT, 913deb3ec6SMatthias Ringwald 923deb3ec6SMatthias Ringwald P_W2_EXECUTE_PREPARED_WRITE, 933deb3ec6SMatthias Ringwald P_W4_EXECUTE_PREPARED_WRITE_RESULT, 943deb3ec6SMatthias Ringwald P_W2_CANCEL_PREPARED_WRITE, 953deb3ec6SMatthias Ringwald P_W4_CANCEL_PREPARED_WRITE_RESULT, 963deb3ec6SMatthias Ringwald P_W2_CANCEL_PREPARED_WRITE_DATA_MISMATCH, 973deb3ec6SMatthias Ringwald P_W4_CANCEL_PREPARED_WRITE_DATA_MISMATCH_RESULT, 983deb3ec6SMatthias Ringwald 99abdc9fb5SMatthias Ringwald #ifdef ENABLE_GATT_FIND_INFORMATION_FOR_CCC_DISCOVERY 100abdc9fb5SMatthias Ringwald P_W2_SEND_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY, 101abdc9fb5SMatthias Ringwald P_W4_FIND_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT, 102abdc9fb5SMatthias Ringwald #else 1033deb3ec6SMatthias Ringwald P_W2_SEND_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY, 1043deb3ec6SMatthias Ringwald P_W4_READ_CLIENT_CHARACTERISTIC_CONFIGURATION_QUERY_RESULT, 105abdc9fb5SMatthias Ringwald #endif 1063deb3ec6SMatthias Ringwald P_W2_WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION, 1073deb3ec6SMatthias Ringwald P_W4_CLIENT_CHARACTERISTIC_CONFIGURATION_RESULT, 1083deb3ec6SMatthias Ringwald 1093deb3ec6SMatthias Ringwald P_W2_SEND_READ_CHARACTERISTIC_DESCRIPTOR_QUERY, 1103deb3ec6SMatthias Ringwald P_W4_READ_CHARACTERISTIC_DESCRIPTOR_RESULT, 1113deb3ec6SMatthias Ringwald 1123deb3ec6SMatthias Ringwald P_W2_SEND_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_QUERY, 1133deb3ec6SMatthias Ringwald P_W4_READ_BLOB_CHARACTERISTIC_DESCRIPTOR_RESULT, 1143deb3ec6SMatthias Ringwald 1153deb3ec6SMatthias Ringwald P_W2_SEND_WRITE_CHARACTERISTIC_DESCRIPTOR, 1163deb3ec6SMatthias Ringwald P_W4_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT, 1173deb3ec6SMatthias Ringwald 1183deb3ec6SMatthias Ringwald // all long writes use this 1193deb3ec6SMatthias Ringwald P_W2_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR, 1203deb3ec6SMatthias Ringwald P_W4_PREPARE_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT, 1213deb3ec6SMatthias Ringwald P_W2_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR, 1223deb3ec6SMatthias Ringwald P_W4_EXECUTE_PREPARED_WRITE_CHARACTERISTIC_DESCRIPTOR_RESULT, 1233deb3ec6SMatthias Ringwald 1243deb3ec6SMatthias Ringwald // gatt reliable write API use this (manual version of the above) 1253deb3ec6SMatthias Ringwald P_W2_PREPARE_WRITE_SINGLE, 1263deb3ec6SMatthias Ringwald P_W4_PREPARE_WRITE_SINGLE_RESULT, 1273deb3ec6SMatthias Ringwald 128793cf6ceSMatthias Ringwald P_W4_IDENTITY_RESOLVING, 1293deb3ec6SMatthias Ringwald P_W4_CMAC_READY, 1303deb3ec6SMatthias Ringwald P_W4_CMAC_RESULT, 1313deb3ec6SMatthias Ringwald P_W2_SEND_SIGNED_WRITE, 1323deb3ec6SMatthias Ringwald P_W4_SEND_SINGED_WRITE_DONE, 1333deb3ec6SMatthias Ringwald } gatt_client_state_t; 1343deb3ec6SMatthias Ringwald 1353deb3ec6SMatthias Ringwald 1363deb3ec6SMatthias Ringwald typedef enum{ 1373deb3ec6SMatthias Ringwald SEND_MTU_EXCHANGE, 1383deb3ec6SMatthias Ringwald SENT_MTU_EXCHANGE, 1395cf6c434SJakob Krantz MTU_EXCHANGED, 1405cf6c434SJakob Krantz MTU_AUTO_EXCHANGE_DISABLED 1413deb3ec6SMatthias Ringwald } gatt_client_mtu_t; 1423deb3ec6SMatthias Ringwald 1433deb3ec6SMatthias Ringwald typedef struct gatt_client{ 144665d90f2SMatthias Ringwald btstack_linked_item_t item; 1453deb3ec6SMatthias Ringwald // TODO: rename gatt_client_state -> state 1463deb3ec6SMatthias Ringwald gatt_client_state_t gatt_client_state; 1473deb3ec6SMatthias Ringwald 1489c662c9bSMatthias Ringwald // user callback 1499c662c9bSMatthias Ringwald btstack_packet_handler_t callback; 1503deb3ec6SMatthias Ringwald 15147181045SMatthias Ringwald // can write without response callback 15247181045SMatthias Ringwald btstack_packet_handler_t write_without_response_callback; 15347181045SMatthias Ringwald 154fc64f94aSMatthias Ringwald hci_con_handle_t con_handle; 155f4b33574SMatthias Ringwald 1563deb3ec6SMatthias Ringwald uint16_t mtu; 1573deb3ec6SMatthias Ringwald gatt_client_mtu_t mtu_state; 1583deb3ec6SMatthias Ringwald 1593deb3ec6SMatthias Ringwald uint16_t uuid16; 1603deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 1613deb3ec6SMatthias Ringwald 1623deb3ec6SMatthias Ringwald uint16_t start_group_handle; 1633deb3ec6SMatthias Ringwald uint16_t end_group_handle; 1643deb3ec6SMatthias Ringwald 1653deb3ec6SMatthias Ringwald uint16_t query_start_handle; 1663deb3ec6SMatthias Ringwald uint16_t query_end_handle; 1673deb3ec6SMatthias Ringwald 1683deb3ec6SMatthias Ringwald uint8_t characteristic_properties; 1693deb3ec6SMatthias Ringwald uint16_t characteristic_start_handle; 1703deb3ec6SMatthias Ringwald 1713deb3ec6SMatthias Ringwald uint16_t attribute_handle; 1723deb3ec6SMatthias Ringwald uint16_t attribute_offset; 1733deb3ec6SMatthias Ringwald uint16_t attribute_length; 1743deb3ec6SMatthias Ringwald uint8_t* attribute_value; 1753deb3ec6SMatthias Ringwald 1763deb3ec6SMatthias Ringwald // read multiple characteristic values 1773deb3ec6SMatthias Ringwald uint16_t read_multiple_handle_count; 1783deb3ec6SMatthias Ringwald uint16_t * read_multiple_handles; 1793deb3ec6SMatthias Ringwald 1803deb3ec6SMatthias Ringwald uint16_t client_characteristic_configuration_handle; 1813deb3ec6SMatthias Ringwald uint8_t client_characteristic_configuration_value[2]; 1823deb3ec6SMatthias Ringwald 1833deb3ec6SMatthias Ringwald uint8_t filter_with_uuid; 1843deb3ec6SMatthias Ringwald uint8_t send_confirmation; 1853deb3ec6SMatthias Ringwald 1863deb3ec6SMatthias Ringwald int le_device_index; 1873deb3ec6SMatthias Ringwald uint8_t cmac[8]; 1883deb3ec6SMatthias Ringwald 189ec820d77SMatthias Ringwald btstack_timer_source_t gc_timeout; 190f4b33574SMatthias Ringwald 191f4b33574SMatthias Ringwald uint8_t security_counter; 1923503dc74SMatthias Ringwald uint8_t wait_for_authentication_complete; 193f4b33574SMatthias Ringwald uint8_t pending_error_code; 194f4b33574SMatthias Ringwald 1958918bbdaSMatthias Ringwald bool reencryption_active; 1968918bbdaSMatthias Ringwald uint8_t reencryption_result; 1978918bbdaSMatthias Ringwald 1981dfae9c7SMatthias Ringwald gap_security_level_t security_level; 1991dfae9c7SMatthias Ringwald 2003deb3ec6SMatthias Ringwald } gatt_client_t; 2013deb3ec6SMatthias Ringwald 2029c662c9bSMatthias Ringwald typedef struct gatt_client_notification { 203665d90f2SMatthias Ringwald btstack_linked_item_t item; 204b6e96f14SMatthias Ringwald btstack_packet_handler_t callback; 205711e6c80SMatthias Ringwald hci_con_handle_t con_handle; 2069c662c9bSMatthias Ringwald uint16_t attribute_handle; 2079c662c9bSMatthias Ringwald } gatt_client_notification_t; 2083deb3ec6SMatthias Ringwald 2093deb3ec6SMatthias Ringwald /* API_START */ 2103deb3ec6SMatthias Ringwald 211d25c33e5SMatthias Ringwald typedef struct { 2123deb3ec6SMatthias Ringwald uint16_t start_group_handle; 2133deb3ec6SMatthias Ringwald uint16_t end_group_handle; 2143deb3ec6SMatthias Ringwald uint16_t uuid16; 2153deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 216d25c33e5SMatthias Ringwald } gatt_client_service_t; 2173deb3ec6SMatthias Ringwald 218d25c33e5SMatthias Ringwald typedef struct { 2193deb3ec6SMatthias Ringwald uint16_t start_handle; 2203deb3ec6SMatthias Ringwald uint16_t value_handle; 2213deb3ec6SMatthias Ringwald uint16_t end_handle; 2223deb3ec6SMatthias Ringwald uint16_t properties; 2233deb3ec6SMatthias Ringwald uint16_t uuid16; 2243deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 225d25c33e5SMatthias Ringwald } gatt_client_characteristic_t; 2263deb3ec6SMatthias Ringwald 227d25c33e5SMatthias Ringwald typedef struct { 2283deb3ec6SMatthias Ringwald uint16_t handle; 2293deb3ec6SMatthias Ringwald uint16_t uuid16; 2303deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 231d25c33e5SMatthias Ringwald } gatt_client_characteristic_descriptor_t; 2323deb3ec6SMatthias Ringwald 2333deb3ec6SMatthias Ringwald /** 2343deb3ec6SMatthias Ringwald * @brief Set up GATT client. 2353deb3ec6SMatthias Ringwald */ 2363deb3ec6SMatthias Ringwald void gatt_client_init(void); 2373deb3ec6SMatthias Ringwald 2383deb3ec6SMatthias Ringwald /** 23911279da7SMatthias Ringwald * @brief Set minimum required security level for GATT Client 24011279da7SMatthias Ringwald * @note The Bluetooth specification makes the GATT Server responsible to check for security. 241b11289a8SMatthias Ringwald * This allows an attacker to spoof an existing device with a GATT Servers, but skip the authentication part. 242b11289a8SMatthias Ringwald * If your application is exchanging sensitive data with a remote device, you would need to manually check 243b11289a8SMatthias Ringwald * the security level before sending/receive such data. 244b11289a8SMatthias Ringwald * With level > 0, the GATT Client triggers authentication for all GATT Requests and defers any exchange 245b11289a8SMatthias Ringwald * until the required security level is established. 246b11289a8SMatthias Ringwald * gatt_client_request_can_write_without_response_event does not trigger authentication 24711279da7SMatthias Ringwald * @pram level, default LEVEL_0 (no encryption required) 24811279da7SMatthias Ringwald */ 24911279da7SMatthias Ringwald void gatt_client_set_required_security_level(gap_security_level_t level); 25011279da7SMatthias Ringwald 25111279da7SMatthias Ringwald /** 252*79188ed7SMilanka Ringwald * @brief MTU is available after the first query has completed. If status is equal to ERROR_CODE_SUCCESS, it returns the real value, 253*79188ed7SMilanka Ringwald * otherwise the default value ATT_DEFAULT_MTU (see bluetooth.h). 2546da84376SMilanka Ringwald * @param con_handle 2556da84376SMilanka Ringwald * @param mtu 256692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 257692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if MTU is not exchanged and MTU auto-exchange is disabled 258692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 2593deb3ec6SMatthias Ringwald */ 260fc64f94aSMatthias Ringwald uint8_t gatt_client_get_mtu(hci_con_handle_t con_handle, uint16_t * mtu); 2613deb3ec6SMatthias Ringwald 2623deb3ec6SMatthias Ringwald /** 263*79188ed7SMilanka Ringwald * @brief Sets whether a MTU Exchange Request shall be automatically send before the 264*79188ed7SMilanka Ringwald * first attribute read request is send. Default is enabled. 2656da84376SMilanka Ringwald * @param enabled 2665cf6c434SJakob Krantz */ 2675cf6c434SJakob Krantz void gatt_client_mtu_enable_auto_negotiation(uint8_t enabled); 2685cf6c434SJakob Krantz 2695cf6c434SJakob Krantz /** 270*79188ed7SMilanka Ringwald * @brief Sends a MTU Exchange Request, this allows for the client to exchange MTU 271*79188ed7SMilanka Ringwald * when gatt_client_mtu_enable_auto_negotiation is disabled. 2726da84376SMilanka Ringwald * @param callback 2736da84376SMilanka Ringwald * @param con_handle 2745cf6c434SJakob Krantz */ 2755cf6c434SJakob Krantz void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 2765cf6c434SJakob Krantz 2775cf6c434SJakob Krantz /** 278aacf1b1aSMilanka Ringwald * @brief Returns 1 if the GATT client is ready to receive a query. It is used with daemon. 2796da84376SMilanka Ringwald * @param con_handle 280692bf1adSMilanka Ringwald * @return is_ready_status 0 - if no GATT client for con_handle is found, or is not ready, otherwise 1 2813deb3ec6SMatthias Ringwald */ 282fc64f94aSMatthias Ringwald int gatt_client_is_ready(hci_con_handle_t con_handle); 2833deb3ec6SMatthias Ringwald 2843deb3ec6SMatthias Ringwald /** 285*79188ed7SMilanka Ringwald * @brief Discovers all primary services. 286*79188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 287*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 2886da84376SMilanka Ringwald * @param callback 2896da84376SMilanka Ringwald * @param con_handle 290692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 291692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 292692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 2933deb3ec6SMatthias Ringwald */ 294711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 2953deb3ec6SMatthias Ringwald 2963deb3ec6SMatthias Ringwald /** 297*79188ed7SMilanka Ringwald * @brief Discovers all secondary services. 298*79188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 299*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3008d1f34d3SMatheus Eduardo Garbelini * @param callback 3018d1f34d3SMatheus Eduardo Garbelini * @param con_handle 3028d1f34d3SMatheus Eduardo Garbelini * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 3038d1f34d3SMatheus Eduardo Garbelini * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 3048d1f34d3SMatheus Eduardo Garbelini * ERROR_CODE_SUCCESS , if query is successfully registered 3058d1f34d3SMatheus Eduardo Garbelini */ 3068d1f34d3SMatheus Eduardo Garbelini uint8_t gatt_client_discover_secondary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 3078d1f34d3SMatheus Eduardo Garbelini 3088d1f34d3SMatheus Eduardo Garbelini /** 309*79188ed7SMilanka Ringwald * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. 310*79188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 311*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3126da84376SMilanka Ringwald * @param callback 3136da84376SMilanka Ringwald * @param con_handle 3146da84376SMilanka Ringwald * @param uuid16 315692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 316692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 317692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3183deb3ec6SMatthias Ringwald */ 319711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16); 3206da84376SMilanka Ringwald 3216da84376SMilanka Ringwald /** 322*79188ed7SMilanka Ringwald * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. 323*79188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 324*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3256da84376SMilanka Ringwald * @param callback 3266da84376SMilanka Ringwald * @param con_handle 3276da84376SMilanka Ringwald * @param uuid128 328692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 329692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 330692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3316da84376SMilanka Ringwald */ 3326da84376SMilanka 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); 3333deb3ec6SMatthias Ringwald 3343deb3ec6SMatthias Ringwald /** 335*79188ed7SMilanka Ringwald * @brief Finds included services within the specified service. 336*79188ed7SMilanka Ringwald * For each found included service a GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT event will be emitted. 337*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 338*79188ed7SMilanka Ringwald * Information about included service type (primary/secondary) can be retrieved either by sending 339*79188ed7SMilanka Ringwald * an ATT find information request for the returned start group handle 340*79188ed7SMilanka Ringwald * (returning the handle and the UUID for primary or secondary service) or by comparing the service 341*79188ed7SMilanka Ringwald * to the list of all primary services. 3426da84376SMilanka Ringwald * @param callback 3436da84376SMilanka Ringwald * @param con_handle 3446da84376SMilanka Ringwald * @param service 345692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 346692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 347692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3483deb3ec6SMatthias Ringwald */ 349711e6c80SMatthias 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); 3503deb3ec6SMatthias Ringwald 3513deb3ec6SMatthias Ringwald /** 352*79188ed7SMilanka Ringwald * @brief Discovers all characteristics within the specified service. 353*79188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will be emited. 354*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3556da84376SMilanka Ringwald * @param callback 3566da84376SMilanka Ringwald * @param con_handle 3576da84376SMilanka Ringwald * @param service 358692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 359692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 360692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3613deb3ec6SMatthias Ringwald */ 362711e6c80SMatthias 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); 3633deb3ec6SMatthias Ringwald 3643deb3ec6SMatthias Ringwald /** 365*79188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within 366*79188ed7SMilanka Ringwald * the specified service or handle range, and return those that match the given UUID. 367*79188ed7SMilanka Ringwald * 368*79188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 369*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3706da84376SMilanka Ringwald * @param callback 3716da84376SMilanka Ringwald * @param con_handle 3726da84376SMilanka Ringwald * @param start_handle 3736da84376SMilanka Ringwald * @param end_handle 3746da84376SMilanka Ringwald * @param uuid16 375692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 376692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 377692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3783deb3ec6SMatthias Ringwald */ 379711e6c80SMatthias 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); 3806da84376SMilanka Ringwald 3816da84376SMilanka Ringwald /** 382*79188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 383*79188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 384*79188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 385*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3866da84376SMilanka Ringwald * @param callback 3876da84376SMilanka Ringwald * @param con_handle 3886da84376SMilanka Ringwald * @param start_handle 3896da84376SMilanka Ringwald * @param end_handle 3906da84376SMilanka Ringwald * @param uuid128 391692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 392692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 393692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3946da84376SMilanka Ringwald */ 395045d700dSDavid Lechner uint8_t gatt_client_discover_characteristics_for_handle_range_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128); 3966da84376SMilanka Ringwald 3976da84376SMilanka Ringwald /** 398*79188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 399*79188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 400*79188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 401*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4026da84376SMilanka Ringwald * @param callback 4036da84376SMilanka Ringwald * @param con_handle 4046da84376SMilanka Ringwald * @param service 4056da84376SMilanka Ringwald * @param uuid16 406692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 407692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 408692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4096da84376SMilanka Ringwald */ 410711e6c80SMatthias Ringwald uint8_t gatt_client_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); 4116da84376SMilanka Ringwald 4126da84376SMilanka Ringwald /** 413*79188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 414*79188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 415*79188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 416*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4176da84376SMilanka Ringwald * @param callback 4186da84376SMilanka Ringwald * @param con_handle 4196da84376SMilanka Ringwald * @param service 4206da84376SMilanka Ringwald * @param uuid128 421692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 422692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 423692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4246da84376SMilanka Ringwald */ 425045d700dSDavid Lechner uint8_t gatt_client_discover_characteristics_for_service_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service, const uint8_t * uuid128); 4263deb3ec6SMatthias Ringwald 4273deb3ec6SMatthias Ringwald /** 428*79188ed7SMilanka Ringwald * @brief Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic. 429*79188ed7SMilanka Ringwald * For each found descriptor a GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT event will be emitted. 430*79188ed7SMilanka Ringwald * 431*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4326da84376SMilanka Ringwald * @param callback 4336da84376SMilanka Ringwald * @param con_handle 4346da84376SMilanka Ringwald * @param characteristic 435692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 436692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 437692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4383deb3ec6SMatthias Ringwald */ 439711e6c80SMatthias Ringwald uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic); 4403deb3ec6SMatthias Ringwald 4413deb3ec6SMatthias Ringwald /** 442*79188ed7SMilanka Ringwald * @brief Reads the characteristic value using the characteristic's value handle. 443*79188ed7SMilanka Ringwald * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 444*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4456da84376SMilanka Ringwald * @param callback 4466da84376SMilanka Ringwald * @param con_handle 4476da84376SMilanka Ringwald * @param characteristic 448692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 449692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 450692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4513deb3ec6SMatthias Ringwald */ 452711e6c80SMatthias 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); 4536da84376SMilanka Ringwald 4546da84376SMilanka Ringwald /** 455*79188ed7SMilanka Ringwald * @brief Reads the characteristic value using the characteristic's value handle. 456*79188ed7SMilanka Ringwald * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 457*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4586da84376SMilanka Ringwald * @param callback 4596da84376SMilanka Ringwald * @param con_handle 460b45b7749SMilanka Ringwald * @param value_handle 461692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 462692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 463692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4646da84376SMilanka Ringwald */ 465b45b7749SMilanka Ringwald uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle); 4663deb3ec6SMatthias Ringwald 4673deb3ec6SMatthias Ringwald /** 468*79188ed7SMilanka Ringwald * @brief Reads the characteric value of all characteristics with the uuid. 469*79188ed7SMilanka Ringwald * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 470*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4716da84376SMilanka Ringwald * @param callback 4726da84376SMilanka Ringwald * @param con_handle 4736da84376SMilanka Ringwald * @param start_handle 4746da84376SMilanka Ringwald * @param end_handle 4756da84376SMilanka Ringwald * @param uuid16 476692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 477692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 478692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4793deb3ec6SMatthias Ringwald */ 480711e6c80SMatthias 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); 4816da84376SMilanka Ringwald 4826da84376SMilanka Ringwald /** 483*79188ed7SMilanka Ringwald * @brief Reads the characteric value of all characteristics with the uuid. 484*79188ed7SMilanka Ringwald * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 485*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4866da84376SMilanka Ringwald * @param callback 4876da84376SMilanka Ringwald * @param con_handle 4886da84376SMilanka Ringwald * @param start_handle 4896da84376SMilanka Ringwald * @param end_handle 4906da84376SMilanka Ringwald * @param uuid128 491692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 492692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 493692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4946da84376SMilanka Ringwald */ 495045d700dSDavid Lechner uint8_t gatt_client_read_value_of_characteristics_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128); 4963deb3ec6SMatthias Ringwald 4973deb3ec6SMatthias Ringwald /** 498*79188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 499*79188ed7SMilanka Ringwald * The value will be returned in several blobs. 500*79188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 501*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5026da84376SMilanka Ringwald * @param callback 5036da84376SMilanka Ringwald * @param con_handle 5046da84376SMilanka Ringwald * @param characteristic 505692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 506692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 507692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5083deb3ec6SMatthias Ringwald */ 509711e6c80SMatthias 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); 5106da84376SMilanka Ringwald 5116da84376SMilanka Ringwald /** 512*79188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 513*79188ed7SMilanka Ringwald * The value will be returned in several blobs. 514*79188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 515*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5166da84376SMilanka Ringwald * @param callback 5176da84376SMilanka Ringwald * @param con_handle 518b45b7749SMilanka Ringwald * @param value_handle 519692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 520692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 521692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5226da84376SMilanka Ringwald */ 523b45b7749SMilanka Ringwald uint8_t gatt_client_read_long_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle); 5246da84376SMilanka Ringwald 5256da84376SMilanka Ringwald /** 526*79188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 527*79188ed7SMilanka Ringwald * The value will be returned in several blobs. 528*79188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 529*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5306da84376SMilanka Ringwald * @param callback 5316da84376SMilanka Ringwald * @param con_handle 532b45b7749SMilanka Ringwald * @param value_handle 5336da84376SMilanka Ringwald * @param offset 534692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 535692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 536692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5376da84376SMilanka Ringwald */ 538b45b7749SMilanka Ringwald uint8_t gatt_client_read_long_value_of_characteristic_using_value_handle_with_offset(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t offset); 5393deb3ec6SMatthias Ringwald 5403deb3ec6SMatthias Ringwald /* 541*79188ed7SMilanka Ringwald * @brief Read multiple characteristic values. 542*79188ed7SMilanka Ringwald * The all results are emitted via single GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event, 543*79188ed7SMilanka Ringwald * followed by the GATT_EVENT_QUERY_COMPLETE event, which marks the end of read. 5446da84376SMilanka Ringwald * @param callback 5456da84376SMilanka Ringwald * @param con_handle 5466da84376SMilanka Ringwald * @param num_value_handles 5476da84376SMilanka Ringwald * @param value_handles list of handles 548*79188ed7SMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 549*79188ed7SMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 550*79188ed7SMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5513deb3ec6SMatthias Ringwald */ 552711e6c80SMatthias 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); 5533deb3ec6SMatthias Ringwald 5543deb3ec6SMatthias Ringwald /** 555*79188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle without 556*79188ed7SMilanka Ringwald * an acknowledgment that the write was successfully performed. 5576da84376SMilanka Ringwald * @param con_handle 558b45b7749SMilanka Ringwald * @param value_handle 559b45b7749SMilanka Ringwald * @param value_length 5607e6f0853SDavid Lechner * @param value is copied on success and does not need to be retained 561692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 562692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 563692bf1adSMilanka Ringwald * BTSTACK_ACL_BUFFERS_FULL , if L2CAP cannot send, there are no free ACL slots 564692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5653deb3ec6SMatthias Ringwald */ 566b45b7749SMilanka Ringwald uint8_t gatt_client_write_value_of_characteristic_without_response(hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value); 5673deb3ec6SMatthias Ringwald 5683deb3ec6SMatthias Ringwald /** 569*79188ed7SMilanka Ringwald * @brief Writes the authenticated characteristic value using the characteristic's value handle 570*79188ed7SMilanka Ringwald * without an acknowledgment that the write was successfully performed. 571*79188ed7SMilanka Ringwald * @note GATT_EVENT_QUERY_COMPLETE is emitted with ATT_ERROR_SUCCESS for success, 572*79188ed7SMilanka Ringwald * or ATT_ERROR_BONDING_INFORMATION_MISSING if there is no bonding information stored. 5736da84376SMilanka Ringwald * @param callback 5746da84376SMilanka Ringwald * @param con_handle 5756da84376SMilanka Ringwald * @param value_handle 5766da84376SMilanka Ringwald * @param message_len 5776da84376SMilanka Ringwald * @param message is not copied, make sure memory is accessible until write is done 578692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 579692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 580692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 5813deb3ec6SMatthias Ringwald */ 5826da84376SMilanka 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); 5833deb3ec6SMatthias Ringwald 5843deb3ec6SMatthias Ringwald /** 585b2468039SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 586b2468039SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 587b2468039SMilanka Ringwald * The write is successfully performed, if the event's att_status field is set to 588b2468039SMilanka Ringwald * ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 5896da84376SMilanka Ringwald * @param callback 5906da84376SMilanka Ringwald * @param con_handle 591b45b7749SMilanka Ringwald * @param value_handle 592b45b7749SMilanka Ringwald * @param value_length 593b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 594692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 595692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 596692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 5973deb3ec6SMatthias Ringwald */ 598b45b7749SMilanka Ringwald uint8_t gatt_client_write_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value); 5996da84376SMilanka Ringwald 6006da84376SMilanka Ringwald /** 601*79188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 602*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 603*79188ed7SMilanka Ringwald * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 6046da84376SMilanka Ringwald * @param callback 6056da84376SMilanka Ringwald * @param con_handle 606b45b7749SMilanka Ringwald * @param value_handle 607b45b7749SMilanka Ringwald * @param value_length 608b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 609692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 610692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 611692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6126da84376SMilanka Ringwald */ 613b45b7749SMilanka Ringwald uint8_t gatt_client_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value); 6146da84376SMilanka Ringwald 6156da84376SMilanka Ringwald /** 616*79188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 617*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 618*79188ed7SMilanka Ringwald * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 6196da84376SMilanka Ringwald * @param callback 6206da84376SMilanka Ringwald * @param con_handle 621b45b7749SMilanka Ringwald * @param value_handle 6226da84376SMilanka Ringwald * @param offset of value 623b45b7749SMilanka Ringwald * @param value_length 624b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 625692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 626692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 627692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6286da84376SMilanka Ringwald */ 629b45b7749SMilanka Ringwald uint8_t gatt_client_write_long_value_of_characteristic_with_offset(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t offset, uint16_t value_length, uint8_t * value); 6303deb3ec6SMatthias Ringwald 6313deb3ec6SMatthias Ringwald /** 632*79188ed7SMilanka Ringwald * @brief Writes of the long characteristic value using the characteristic's value handle. 633*79188ed7SMilanka Ringwald * It uses server response to validate that the write was correctly received. 634*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE EVENT marks the end of write. 635*79188ed7SMilanka Ringwald * The write is successfully performed, if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 6366da84376SMilanka Ringwald * @param callback 6376da84376SMilanka Ringwald * @param con_handle 638b45b7749SMilanka Ringwald * @param value_handle 639b45b7749SMilanka Ringwald * @param value_length 640b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 641692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 642692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 643692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6443deb3ec6SMatthias Ringwald */ 645b45b7749SMilanka Ringwald uint8_t gatt_client_reliable_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value); 6463deb3ec6SMatthias Ringwald 6473deb3ec6SMatthias Ringwald /** 648*79188ed7SMilanka Ringwald * @brief Reads the characteristic descriptor using its handle. 649*79188ed7SMilanka Ringwald * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 650*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 6516da84376SMilanka Ringwald * @param callback 6526da84376SMilanka Ringwald * @param con_handle 6536da84376SMilanka Ringwald * @param descriptor 654692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 655692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 656692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6573deb3ec6SMatthias Ringwald */ 658711e6c80SMatthias 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); 6596da84376SMilanka Ringwald 6606da84376SMilanka Ringwald /** 661*79188ed7SMilanka Ringwald * @brief Reads the characteristic descriptor using its handle. 662*79188ed7SMilanka Ringwald * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 663*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 6646da84376SMilanka Ringwald * @param callback 6656da84376SMilanka Ringwald * @param con_handle 6666da84376SMilanka Ringwald * @param descriptor 667692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 668692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 669692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6706da84376SMilanka Ringwald */ 671711e6c80SMatthias 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); 6723deb3ec6SMatthias Ringwald 6733deb3ec6SMatthias Ringwald /** 674*79188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 675*79188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 676*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 6776da84376SMilanka Ringwald * @param callback 6786da84376SMilanka Ringwald * @param con_handle 679b45b7749SMilanka Ringwald * @param descriptor 680692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 681692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 682692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6833deb3ec6SMatthias Ringwald */ 684711e6c80SMatthias 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); 6856da84376SMilanka Ringwald 6866da84376SMilanka Ringwald /** 687*79188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 688*79188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 689*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 6906da84376SMilanka Ringwald * @param callback 6916da84376SMilanka Ringwald * @param con_handle 6926da84376SMilanka Ringwald * @param descriptor_handle 693692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 694692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 695692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6966da84376SMilanka Ringwald */ 697711e6c80SMatthias 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); 6986da84376SMilanka Ringwald 6996da84376SMilanka Ringwald /** 700*79188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 701*79188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 702*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 7036da84376SMilanka Ringwald * @param callback 7046da84376SMilanka Ringwald * @param con_handle 7056da84376SMilanka Ringwald * @param descriptor_handle 7066da84376SMilanka Ringwald * @param offset 707692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 708692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 709692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7106da84376SMilanka Ringwald */ 711711e6c80SMatthias 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); 7123deb3ec6SMatthias Ringwald 7133deb3ec6SMatthias Ringwald /** 714*79188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 715*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 716*79188ed7SMilanka Ringwald * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 7176da84376SMilanka Ringwald * @param callback 7186da84376SMilanka Ringwald * @param con_handle 7196da84376SMilanka Ringwald * @param descriptor 720b45b7749SMilanka Ringwald * @param value_length 721b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 722692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 723692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 724692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7253deb3ec6SMatthias Ringwald */ 726b45b7749SMilanka Ringwald uint8_t gatt_client_write_characteristic_descriptor(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t * descriptor, uint16_t value_length, uint8_t * value); 7276da84376SMilanka Ringwald 7286da84376SMilanka Ringwald /** 729*79188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 730*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 731*79188ed7SMilanka Ringwald * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 7326da84376SMilanka Ringwald * @param callback 7336da84376SMilanka Ringwald * @param con_handle 7346da84376SMilanka Ringwald * @param descriptor_handle 735b45b7749SMilanka Ringwald * @param value_length 736b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 737692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 738692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 739692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7406da84376SMilanka Ringwald */ 741b45b7749SMilanka Ringwald uint8_t gatt_client_write_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t value_length, uint8_t * value); 7426da84376SMilanka Ringwald 7436da84376SMilanka Ringwald /** 744*79188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 745*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 746*79188ed7SMilanka Ringwald * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 7476da84376SMilanka Ringwald * @param callback 7486da84376SMilanka Ringwald * @param con_handle 7496da84376SMilanka Ringwald * @param descriptor 750b45b7749SMilanka Ringwald * @param value_length 751b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 752692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 753692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 754692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7556da84376SMilanka Ringwald */ 756b45b7749SMilanka Ringwald uint8_t gatt_client_write_long_characteristic_descriptor(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_descriptor_t * descriptor, uint16_t value_length, uint8_t * value); 7576da84376SMilanka Ringwald 7586da84376SMilanka Ringwald /** 759*79188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 760*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 761*79188ed7SMilanka Ringwald * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 7626da84376SMilanka Ringwald * @param callback 7636da84376SMilanka Ringwald * @param con_handle 7646da84376SMilanka Ringwald * @param descriptor_handle 765b45b7749SMilanka Ringwald * @param value_length 766b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 767692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 768692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 769692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7706da84376SMilanka Ringwald */ 771b45b7749SMilanka Ringwald uint8_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t value_length, uint8_t * value); 7726da84376SMilanka Ringwald 7736da84376SMilanka Ringwald /** 774*79188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 775*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 776*79188ed7SMilanka Ringwald * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 7776da84376SMilanka Ringwald * @param callback 7786da84376SMilanka Ringwald * @param con_handle 7796da84376SMilanka Ringwald * @param descriptor_handle 7806da84376SMilanka Ringwald * @param offset of value 781b45b7749SMilanka Ringwald * @param value_length 782b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 783692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 784692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 785692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7866da84376SMilanka Ringwald */ 787b45b7749SMilanka Ringwald uint8_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle_with_offset(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle, uint16_t offset, uint16_t value_length, uint8_t * value); 7883deb3ec6SMatthias Ringwald 7893deb3ec6SMatthias Ringwald /** 790*79188ed7SMilanka Ringwald * @brief Writes the client characteristic configuration of the specified characteristic. 791*79188ed7SMilanka Ringwald * It is used to subscribe for notifications or indications of the characteristic value. 792*79188ed7SMilanka Ringwald * For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION 793*79188ed7SMilanka Ringwald * resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value. 794*79188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 795*79188ed7SMilanka Ringwald * The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 7966da84376SMilanka Ringwald * @param callback 7976da84376SMilanka Ringwald * @param con_handle 7986da84376SMilanka Ringwald * @param characteristic 799b7e5512fSMilanka Ringwald * @param configuration GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION, GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION 800b7e5512fSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle is found 801692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 802b7e5512fSMilanka Ringwald * GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED if configuring notification, but characteristic has no notification property set 803b7e5512fSMilanka Ringwald * GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED if configuring indication, but characteristic has no indication property set 8046b04f675SMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if configuration is invalid 805b7e5512fSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 8063deb3ec6SMatthias Ringwald */ 807711e6c80SMatthias 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); 8089c662c9bSMatthias Ringwald 8099c662c9bSMatthias Ringwald /** 810*79188ed7SMilanka Ringwald * @brief Register for notifications and indications of a characteristic enabled by 811*79188ed7SMilanka Ringwald * the gatt_client_write_client_characteristic_configuration function. 8129c662c9bSMatthias Ringwald * @param notification struct used to store registration 8136da84376SMilanka Ringwald * @param callback 814b3f03c84SMatthias Ringwald * @param con_handle or GATT_CLIENT_ANY_CONNECTION to receive updates from all connected devices 815b3f03c84SMatthias Ringwald * @param characteristic or NULL to receive updates for all characteristics 8169c662c9bSMatthias Ringwald */ 8176da84376SMilanka 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); 8183deb3ec6SMatthias Ringwald 8193deb3ec6SMatthias Ringwald /** 820*79188ed7SMilanka Ringwald * @brief Stop listening to characteristic value updates registered with 821*79188ed7SMilanka Ringwald * the gatt_client_listen_for_characteristic_value_updates function. 8221f734b5fSMatthias Ringwald * @param notification struct used in gatt_client_listen_for_characteristic_value_updates 8231f734b5fSMatthias Ringwald */ 8241f734b5fSMatthias Ringwald void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification); 8251f734b5fSMatthias Ringwald 8261f734b5fSMatthias Ringwald /** 827*79188ed7SMilanka Ringwald * @brief Requests GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE that guarantees 828*79188ed7SMilanka Ringwald * a single successful gatt_client_write_value_of_characteristic_without_response call. 8296da84376SMilanka Ringwald * @param callback 83047181045SMatthias Ringwald * @param con_handle 8316b65794dSMilanka Ringwald * @return status 83247181045SMatthias Ringwald */ 83347181045SMatthias Ringwald uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 83447181045SMatthias Ringwald 83547181045SMatthias Ringwald /** 836*79188ed7SMilanka Ringwald * @brief Transactional write. It can be called as many times as it is needed to write the characteristics within the same transaction. 837*79188ed7SMilanka Ringwald * Call the gatt_client_execute_write function to commit the transaction. 8386da84376SMilanka Ringwald * @param callback 8396da84376SMilanka Ringwald * @param con_handle 8406da84376SMilanka Ringwald * @param attribute_handle 8416da84376SMilanka Ringwald * @param offset of value 842b45b7749SMilanka Ringwald * @param value_length 843b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 8443deb3ec6SMatthias Ringwald */ 845b45b7749SMilanka Ringwald uint8_t gatt_client_prepare_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint16_t value_length, uint8_t * value); 8463deb3ec6SMatthias Ringwald 8473deb3ec6SMatthias Ringwald /** 8486da84376SMilanka Ringwald * @brief Commit transactional write. GATT_EVENT_QUERY_COMPLETE is received. 8496da84376SMilanka Ringwald * @param callback 8506da84376SMilanka Ringwald * @param con_handle 8513deb3ec6SMatthias Ringwald */ 852711e6c80SMatthias Ringwald uint8_t gatt_client_execute_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 8533deb3ec6SMatthias Ringwald 8543deb3ec6SMatthias Ringwald /** 8556da84376SMilanka Ringwald * @brief Abort transactional write. GATT_EVENT_QUERY_COMPLETE is received. 8566da84376SMilanka Ringwald * @param callback 8576da84376SMilanka Ringwald * @param con_handle 8583deb3ec6SMatthias Ringwald */ 859711e6c80SMatthias Ringwald uint8_t gatt_client_cancel_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 8603deb3ec6SMatthias Ringwald 8613deb3ec6SMatthias Ringwald /* API_END */ 8623deb3ec6SMatthias Ringwald 8636ba2ad22SMatthias Ringwald // used by generated btstack_event.c 8646ba2ad22SMatthias Ringwald 865313e337bSMatthias Ringwald void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t * service); 866313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic); 867313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor); 8686ba2ad22SMatthias Ringwald 869a6121b51SMilanka Ringwald #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 870a6121b51SMilanka Ringwald void gatt_client_att_packet_handler_fuzz(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size); 871a6121b51SMilanka Ringwald #endif 872a6121b51SMilanka Ringwald 8733deb3ec6SMatthias Ringwald #if defined __cplusplus 8743deb3ec6SMatthias Ringwald } 8753deb3ec6SMatthias Ringwald #endif 8763deb3ec6SMatthias Ringwald 8773deb3ec6SMatthias Ringwald #endif 878