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 15459d34cd2SMatthias Ringwald // can write without response requests 15559d34cd2SMatthias Ringwald btstack_linked_list_t write_without_response_requests; 15659d34cd2SMatthias Ringwald 157*53e9c18fSMatthias Ringwald // regular gatt query requests 158*53e9c18fSMatthias Ringwald btstack_linked_list_t query_requests; 159*53e9c18fSMatthias Ringwald 160fc64f94aSMatthias Ringwald hci_con_handle_t con_handle; 161f4b33574SMatthias Ringwald 1623deb3ec6SMatthias Ringwald uint16_t mtu; 1633deb3ec6SMatthias Ringwald gatt_client_mtu_t mtu_state; 1643deb3ec6SMatthias Ringwald 1653deb3ec6SMatthias Ringwald uint16_t uuid16; 1663deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 1673deb3ec6SMatthias Ringwald 1683deb3ec6SMatthias Ringwald uint16_t start_group_handle; 1693deb3ec6SMatthias Ringwald uint16_t end_group_handle; 1703deb3ec6SMatthias Ringwald 1713deb3ec6SMatthias Ringwald uint16_t query_start_handle; 1723deb3ec6SMatthias Ringwald uint16_t query_end_handle; 1733deb3ec6SMatthias Ringwald 1743deb3ec6SMatthias Ringwald uint8_t characteristic_properties; 1753deb3ec6SMatthias Ringwald uint16_t characteristic_start_handle; 1763deb3ec6SMatthias Ringwald 1773deb3ec6SMatthias Ringwald uint16_t attribute_handle; 1783deb3ec6SMatthias Ringwald uint16_t attribute_offset; 1793deb3ec6SMatthias Ringwald uint16_t attribute_length; 1803deb3ec6SMatthias Ringwald uint8_t* attribute_value; 1813deb3ec6SMatthias Ringwald 1823deb3ec6SMatthias Ringwald // read multiple characteristic values 1833deb3ec6SMatthias Ringwald uint16_t read_multiple_handle_count; 1843deb3ec6SMatthias Ringwald uint16_t * read_multiple_handles; 1853deb3ec6SMatthias Ringwald 1863deb3ec6SMatthias Ringwald uint16_t client_characteristic_configuration_handle; 1873deb3ec6SMatthias Ringwald uint8_t client_characteristic_configuration_value[2]; 1883deb3ec6SMatthias Ringwald 1893deb3ec6SMatthias Ringwald uint8_t filter_with_uuid; 1903deb3ec6SMatthias Ringwald uint8_t send_confirmation; 1913deb3ec6SMatthias Ringwald 1923deb3ec6SMatthias Ringwald int le_device_index; 1933deb3ec6SMatthias Ringwald uint8_t cmac[8]; 1943deb3ec6SMatthias Ringwald 195ec820d77SMatthias Ringwald btstack_timer_source_t gc_timeout; 196f4b33574SMatthias Ringwald 197f4b33574SMatthias Ringwald uint8_t security_counter; 1983503dc74SMatthias Ringwald uint8_t wait_for_authentication_complete; 199f4b33574SMatthias Ringwald uint8_t pending_error_code; 200f4b33574SMatthias Ringwald 2018918bbdaSMatthias Ringwald bool reencryption_active; 2028918bbdaSMatthias Ringwald uint8_t reencryption_result; 2038918bbdaSMatthias Ringwald 2041dfae9c7SMatthias Ringwald gap_security_level_t security_level; 2051dfae9c7SMatthias Ringwald 2063deb3ec6SMatthias Ringwald } gatt_client_t; 2073deb3ec6SMatthias Ringwald 2089c662c9bSMatthias Ringwald typedef struct gatt_client_notification { 209665d90f2SMatthias Ringwald btstack_linked_item_t item; 210b6e96f14SMatthias Ringwald btstack_packet_handler_t callback; 211711e6c80SMatthias Ringwald hci_con_handle_t con_handle; 2129c662c9bSMatthias Ringwald uint16_t attribute_handle; 2139c662c9bSMatthias Ringwald } gatt_client_notification_t; 2143deb3ec6SMatthias Ringwald 2153deb3ec6SMatthias Ringwald /* API_START */ 2163deb3ec6SMatthias Ringwald 217d25c33e5SMatthias Ringwald typedef struct { 2183deb3ec6SMatthias Ringwald uint16_t start_group_handle; 2193deb3ec6SMatthias Ringwald uint16_t end_group_handle; 2203deb3ec6SMatthias Ringwald uint16_t uuid16; 2213deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 222d25c33e5SMatthias Ringwald } gatt_client_service_t; 2233deb3ec6SMatthias Ringwald 224d25c33e5SMatthias Ringwald typedef struct { 2253deb3ec6SMatthias Ringwald uint16_t start_handle; 2263deb3ec6SMatthias Ringwald uint16_t value_handle; 2273deb3ec6SMatthias Ringwald uint16_t end_handle; 2283deb3ec6SMatthias Ringwald uint16_t properties; 2293deb3ec6SMatthias Ringwald uint16_t uuid16; 2303deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 231d25c33e5SMatthias Ringwald } gatt_client_characteristic_t; 2323deb3ec6SMatthias Ringwald 233d25c33e5SMatthias Ringwald typedef struct { 2343deb3ec6SMatthias Ringwald uint16_t handle; 2353deb3ec6SMatthias Ringwald uint16_t uuid16; 2363deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 237d25c33e5SMatthias Ringwald } gatt_client_characteristic_descriptor_t; 2383deb3ec6SMatthias Ringwald 2393deb3ec6SMatthias Ringwald /** 2403deb3ec6SMatthias Ringwald * @brief Set up GATT client. 2413deb3ec6SMatthias Ringwald */ 2423deb3ec6SMatthias Ringwald void gatt_client_init(void); 2433deb3ec6SMatthias Ringwald 2443deb3ec6SMatthias Ringwald /** 24511279da7SMatthias Ringwald * @brief Set minimum required security level for GATT Client 24611279da7SMatthias Ringwald * @note The Bluetooth specification makes the GATT Server responsible to check for security. 247b11289a8SMatthias Ringwald * This allows an attacker to spoof an existing device with a GATT Servers, but skip the authentication part. 248b11289a8SMatthias Ringwald * If your application is exchanging sensitive data with a remote device, you would need to manually check 249b11289a8SMatthias Ringwald * the security level before sending/receive such data. 250b11289a8SMatthias Ringwald * With level > 0, the GATT Client triggers authentication for all GATT Requests and defers any exchange 251b11289a8SMatthias Ringwald * until the required security level is established. 252b11289a8SMatthias Ringwald * gatt_client_request_can_write_without_response_event does not trigger authentication 25359d34cd2SMatthias Ringwald * gatt_client_request_to_write_without_response does not trigger authentication 25411279da7SMatthias Ringwald * @pram level, default LEVEL_0 (no encryption required) 25511279da7SMatthias Ringwald */ 25611279da7SMatthias Ringwald void gatt_client_set_required_security_level(gap_security_level_t level); 25711279da7SMatthias Ringwald 25811279da7SMatthias Ringwald /** 25979188ed7SMilanka Ringwald * @brief MTU is available after the first query has completed. If status is equal to ERROR_CODE_SUCCESS, it returns the real value, 26079188ed7SMilanka Ringwald * otherwise the default value ATT_DEFAULT_MTU (see bluetooth.h). 2616da84376SMilanka Ringwald * @param con_handle 2626da84376SMilanka Ringwald * @param mtu 26340faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 26440faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 265692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if MTU is not exchanged and MTU auto-exchange is disabled 266692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 2673deb3ec6SMatthias Ringwald */ 268fc64f94aSMatthias Ringwald uint8_t gatt_client_get_mtu(hci_con_handle_t con_handle, uint16_t * mtu); 2693deb3ec6SMatthias Ringwald 2703deb3ec6SMatthias Ringwald /** 27179188ed7SMilanka Ringwald * @brief Sets whether a MTU Exchange Request shall be automatically send before the 27279188ed7SMilanka Ringwald * first attribute read request is send. Default is enabled. 2736da84376SMilanka Ringwald * @param enabled 2745cf6c434SJakob Krantz */ 2755cf6c434SJakob Krantz void gatt_client_mtu_enable_auto_negotiation(uint8_t enabled); 2765cf6c434SJakob Krantz 2775cf6c434SJakob Krantz /** 27879188ed7SMilanka Ringwald * @brief Sends a MTU Exchange Request, this allows for the client to exchange MTU 27979188ed7SMilanka Ringwald * when gatt_client_mtu_enable_auto_negotiation is disabled. 2806da84376SMilanka Ringwald * @param callback 2816da84376SMilanka Ringwald * @param con_handle 2825cf6c434SJakob Krantz */ 2835cf6c434SJakob Krantz void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 2845cf6c434SJakob Krantz 2855cf6c434SJakob Krantz /** 286aacf1b1aSMilanka Ringwald * @brief Returns 1 if the GATT client is ready to receive a query. It is used with daemon. 2876da84376SMilanka Ringwald * @param con_handle 288692bf1adSMilanka Ringwald * @return is_ready_status 0 - if no GATT client for con_handle is found, or is not ready, otherwise 1 2893deb3ec6SMatthias Ringwald */ 290fc64f94aSMatthias Ringwald int gatt_client_is_ready(hci_con_handle_t con_handle); 2913deb3ec6SMatthias Ringwald 2923deb3ec6SMatthias Ringwald /** 29379188ed7SMilanka Ringwald * @brief Discovers all primary services. 29479188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 29579188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 2966da84376SMilanka Ringwald * @param callback 2976da84376SMilanka Ringwald * @param con_handle 298692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 299692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 300692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3013deb3ec6SMatthias Ringwald */ 302711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 3033deb3ec6SMatthias Ringwald 3043deb3ec6SMatthias Ringwald /** 30579188ed7SMilanka Ringwald * @brief Discovers all secondary services. 30679188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 30779188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3088d1f34d3SMatheus Eduardo Garbelini * @param callback 3098d1f34d3SMatheus Eduardo Garbelini * @param con_handle 3108d1f34d3SMatheus Eduardo Garbelini * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 3118d1f34d3SMatheus Eduardo Garbelini * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 3128d1f34d3SMatheus Eduardo Garbelini * ERROR_CODE_SUCCESS , if query is successfully registered 3138d1f34d3SMatheus Eduardo Garbelini */ 3148d1f34d3SMatheus Eduardo Garbelini uint8_t gatt_client_discover_secondary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 3158d1f34d3SMatheus Eduardo Garbelini 3168d1f34d3SMatheus Eduardo Garbelini /** 31779188ed7SMilanka Ringwald * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. 31879188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 31979188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3206da84376SMilanka Ringwald * @param callback 3216da84376SMilanka Ringwald * @param con_handle 3226da84376SMilanka Ringwald * @param uuid16 323692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 324692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 325692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3263deb3ec6SMatthias Ringwald */ 327711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16); 3286da84376SMilanka Ringwald 3296da84376SMilanka Ringwald /** 33079188ed7SMilanka Ringwald * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. 33179188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 33279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3336da84376SMilanka Ringwald * @param callback 3346da84376SMilanka Ringwald * @param con_handle 3356da84376SMilanka Ringwald * @param uuid128 336692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 337692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 338692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3396da84376SMilanka Ringwald */ 3406da84376SMilanka 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); 3413deb3ec6SMatthias Ringwald 3423deb3ec6SMatthias Ringwald /** 34379188ed7SMilanka Ringwald * @brief Finds included services within the specified service. 34479188ed7SMilanka Ringwald * For each found included service a GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT event will be emitted. 34579188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 34679188ed7SMilanka Ringwald * Information about included service type (primary/secondary) can be retrieved either by sending 34779188ed7SMilanka Ringwald * an ATT find information request for the returned start group handle 34879188ed7SMilanka Ringwald * (returning the handle and the UUID for primary or secondary service) or by comparing the service 34979188ed7SMilanka Ringwald * to the list of all primary services. 3506da84376SMilanka Ringwald * @param callback 3516da84376SMilanka Ringwald * @param con_handle 3526da84376SMilanka Ringwald * @param service 353692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 354692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 355692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3563deb3ec6SMatthias Ringwald */ 357711e6c80SMatthias 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); 3583deb3ec6SMatthias Ringwald 3593deb3ec6SMatthias Ringwald /** 36079188ed7SMilanka Ringwald * @brief Discovers all characteristics within the specified service. 36179188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will be emited. 36279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3636da84376SMilanka Ringwald * @param callback 3646da84376SMilanka Ringwald * @param con_handle 3656da84376SMilanka Ringwald * @param service 366692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 367692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 368692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3693deb3ec6SMatthias Ringwald */ 370711e6c80SMatthias 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); 3713deb3ec6SMatthias Ringwald 3723deb3ec6SMatthias Ringwald /** 37379188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within 37479188ed7SMilanka Ringwald * the specified service or handle range, and return those that match the given UUID. 37579188ed7SMilanka Ringwald * 37679188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 37779188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3786da84376SMilanka Ringwald * @param callback 3796da84376SMilanka Ringwald * @param con_handle 3806da84376SMilanka Ringwald * @param start_handle 3816da84376SMilanka Ringwald * @param end_handle 3826da84376SMilanka Ringwald * @param uuid16 383692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 384692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 385692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3863deb3ec6SMatthias Ringwald */ 387711e6c80SMatthias 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); 3886da84376SMilanka Ringwald 3896da84376SMilanka Ringwald /** 39079188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 39179188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 39279188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 39379188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3946da84376SMilanka Ringwald * @param callback 3956da84376SMilanka Ringwald * @param con_handle 3966da84376SMilanka Ringwald * @param start_handle 3976da84376SMilanka Ringwald * @param end_handle 3986da84376SMilanka Ringwald * @param uuid128 399692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 400692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 401692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4026da84376SMilanka Ringwald */ 403045d700dSDavid 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); 4046da84376SMilanka Ringwald 4056da84376SMilanka Ringwald /** 40679188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 40779188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 40879188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 40979188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4106da84376SMilanka Ringwald * @param callback 4116da84376SMilanka Ringwald * @param con_handle 4126da84376SMilanka Ringwald * @param service 4136da84376SMilanka Ringwald * @param uuid16 414692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 415692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 416692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4176da84376SMilanka Ringwald */ 418711e6c80SMatthias 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); 4196da84376SMilanka Ringwald 4206da84376SMilanka Ringwald /** 42179188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 42279188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 42379188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 42479188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4256da84376SMilanka Ringwald * @param callback 4266da84376SMilanka Ringwald * @param con_handle 4276da84376SMilanka Ringwald * @param service 4286da84376SMilanka Ringwald * @param uuid128 429692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 430692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 431692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4326da84376SMilanka Ringwald */ 433045d700dSDavid 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); 4343deb3ec6SMatthias Ringwald 4353deb3ec6SMatthias Ringwald /** 43679188ed7SMilanka Ringwald * @brief Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic. 43779188ed7SMilanka Ringwald * For each found descriptor a GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT event will be emitted. 43879188ed7SMilanka Ringwald * 43979188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4406da84376SMilanka Ringwald * @param callback 4416da84376SMilanka Ringwald * @param con_handle 4426da84376SMilanka Ringwald * @param characteristic 443692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 444692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 445692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4463deb3ec6SMatthias Ringwald */ 447711e6c80SMatthias Ringwald uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic); 4483deb3ec6SMatthias Ringwald 4493deb3ec6SMatthias Ringwald /** 45079188ed7SMilanka Ringwald * @brief Reads the characteristic value using the characteristic's value handle. 45179188ed7SMilanka Ringwald * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 45279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4536da84376SMilanka Ringwald * @param callback 4546da84376SMilanka Ringwald * @param con_handle 4556da84376SMilanka Ringwald * @param characteristic 456692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 457692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 458692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4593deb3ec6SMatthias Ringwald */ 460711e6c80SMatthias 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); 4616da84376SMilanka Ringwald 4626da84376SMilanka Ringwald /** 46379188ed7SMilanka Ringwald * @brief Reads the characteristic value using the characteristic's value handle. 46479188ed7SMilanka Ringwald * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 46579188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4666da84376SMilanka Ringwald * @param callback 4676da84376SMilanka Ringwald * @param con_handle 468b45b7749SMilanka Ringwald * @param value_handle 469692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 470692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 471692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4726da84376SMilanka Ringwald */ 473b45b7749SMilanka 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); 4743deb3ec6SMatthias Ringwald 4753deb3ec6SMatthias Ringwald /** 47679188ed7SMilanka Ringwald * @brief Reads the characteric value of all characteristics with the uuid. 47779188ed7SMilanka Ringwald * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 47879188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4796da84376SMilanka Ringwald * @param callback 4806da84376SMilanka Ringwald * @param con_handle 4816da84376SMilanka Ringwald * @param start_handle 4826da84376SMilanka Ringwald * @param end_handle 4836da84376SMilanka Ringwald * @param uuid16 484692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 485692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 486692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4873deb3ec6SMatthias Ringwald */ 488711e6c80SMatthias 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); 4896da84376SMilanka Ringwald 4906da84376SMilanka Ringwald /** 49179188ed7SMilanka Ringwald * @brief Reads the characteric value of all characteristics with the uuid. 49279188ed7SMilanka Ringwald * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 49379188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4946da84376SMilanka Ringwald * @param callback 4956da84376SMilanka Ringwald * @param con_handle 4966da84376SMilanka Ringwald * @param start_handle 4976da84376SMilanka Ringwald * @param end_handle 4986da84376SMilanka Ringwald * @param uuid128 499692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 500692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 501692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5026da84376SMilanka Ringwald */ 503045d700dSDavid 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); 5043deb3ec6SMatthias Ringwald 5053deb3ec6SMatthias Ringwald /** 50679188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 50779188ed7SMilanka Ringwald * The value will be returned in several blobs. 50879188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 50979188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5106da84376SMilanka Ringwald * @param callback 5116da84376SMilanka Ringwald * @param con_handle 5126da84376SMilanka Ringwald * @param characteristic 513692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 514692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 515692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5163deb3ec6SMatthias Ringwald */ 517711e6c80SMatthias 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); 5186da84376SMilanka Ringwald 5196da84376SMilanka Ringwald /** 52079188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 52179188ed7SMilanka Ringwald * The value will be returned in several blobs. 52279188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 52379188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5246da84376SMilanka Ringwald * @param callback 5256da84376SMilanka Ringwald * @param con_handle 526b45b7749SMilanka Ringwald * @param value_handle 527692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 528692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 529692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5306da84376SMilanka Ringwald */ 531b45b7749SMilanka 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); 5326da84376SMilanka Ringwald 5336da84376SMilanka Ringwald /** 53479188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 53579188ed7SMilanka Ringwald * The value will be returned in several blobs. 53679188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 53779188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5386da84376SMilanka Ringwald * @param callback 5396da84376SMilanka Ringwald * @param con_handle 540b45b7749SMilanka Ringwald * @param value_handle 5416da84376SMilanka Ringwald * @param offset 542692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 543692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 544692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5456da84376SMilanka Ringwald */ 546b45b7749SMilanka 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); 5473deb3ec6SMatthias Ringwald 5483deb3ec6SMatthias Ringwald /* 54979188ed7SMilanka Ringwald * @brief Read multiple characteristic values. 55079188ed7SMilanka Ringwald * The all results are emitted via single GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event, 55179188ed7SMilanka Ringwald * followed by the GATT_EVENT_QUERY_COMPLETE event, which marks the end of read. 5526da84376SMilanka Ringwald * @param callback 5536da84376SMilanka Ringwald * @param con_handle 5546da84376SMilanka Ringwald * @param num_value_handles 5556da84376SMilanka Ringwald * @param value_handles list of handles 55679188ed7SMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 55779188ed7SMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 55879188ed7SMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5593deb3ec6SMatthias Ringwald */ 560711e6c80SMatthias 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); 5613deb3ec6SMatthias Ringwald 5623deb3ec6SMatthias Ringwald /** 56379188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle without 56479188ed7SMilanka Ringwald * an acknowledgment that the write was successfully performed. 5656da84376SMilanka Ringwald * @param con_handle 566b45b7749SMilanka Ringwald * @param value_handle 567b45b7749SMilanka Ringwald * @param value_length 5687e6f0853SDavid Lechner * @param value is copied on success and does not need to be retained 569692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 570692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 571692bf1adSMilanka Ringwald * BTSTACK_ACL_BUFFERS_FULL , if L2CAP cannot send, there are no free ACL slots 572692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5733deb3ec6SMatthias Ringwald */ 574b45b7749SMilanka 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); 5753deb3ec6SMatthias Ringwald 5763deb3ec6SMatthias Ringwald /** 57779188ed7SMilanka Ringwald * @brief Writes the authenticated characteristic value using the characteristic's value handle 57879188ed7SMilanka Ringwald * without an acknowledgment that the write was successfully performed. 57979188ed7SMilanka Ringwald * @note GATT_EVENT_QUERY_COMPLETE is emitted with ATT_ERROR_SUCCESS for success, 58079188ed7SMilanka Ringwald * or ATT_ERROR_BONDING_INFORMATION_MISSING if there is no bonding information stored. 5816da84376SMilanka Ringwald * @param callback 5826da84376SMilanka Ringwald * @param con_handle 5836da84376SMilanka Ringwald * @param value_handle 5846da84376SMilanka Ringwald * @param message_len 5856da84376SMilanka Ringwald * @param message is not copied, make sure memory is accessible until write is done 58640faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 58740faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 588692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 589692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 5903deb3ec6SMatthias Ringwald */ 5916da84376SMilanka 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); 5923deb3ec6SMatthias Ringwald 5933deb3ec6SMatthias Ringwald /** 594b2468039SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 595b2468039SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 596b2468039SMilanka Ringwald * The write is successfully performed, if the event's att_status field is set to 597b2468039SMilanka Ringwald * ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 5986da84376SMilanka Ringwald * @param callback 5996da84376SMilanka Ringwald * @param con_handle 600b45b7749SMilanka Ringwald * @param value_handle 601b45b7749SMilanka Ringwald * @param value_length 602b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 60340faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 60440faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 605692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 606692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6073deb3ec6SMatthias Ringwald */ 608b45b7749SMilanka 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); 6096da84376SMilanka Ringwald 6106da84376SMilanka Ringwald /** 61179188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 61279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 61379188ed7SMilanka 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). 6146da84376SMilanka Ringwald * @param callback 6156da84376SMilanka Ringwald * @param con_handle 616b45b7749SMilanka Ringwald * @param value_handle 617b45b7749SMilanka Ringwald * @param value_length 618b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 61940faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 62040faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 621692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 622692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6236da84376SMilanka Ringwald */ 624b45b7749SMilanka 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); 6256da84376SMilanka Ringwald 6266da84376SMilanka Ringwald /** 62779188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 62879188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 62979188ed7SMilanka 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). 6306da84376SMilanka Ringwald * @param callback 6316da84376SMilanka Ringwald * @param con_handle 632b45b7749SMilanka Ringwald * @param value_handle 6336da84376SMilanka Ringwald * @param offset of value 634b45b7749SMilanka Ringwald * @param value_length 635b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 63640faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 63740faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 638692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 639692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6406da84376SMilanka Ringwald */ 641b45b7749SMilanka 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); 6423deb3ec6SMatthias Ringwald 6433deb3ec6SMatthias Ringwald /** 64479188ed7SMilanka Ringwald * @brief Writes of the long characteristic value using the characteristic's value handle. 64579188ed7SMilanka Ringwald * It uses server response to validate that the write was correctly received. 64679188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE EVENT marks the end of write. 64779188ed7SMilanka 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). 6486da84376SMilanka Ringwald * @param callback 6496da84376SMilanka Ringwald * @param con_handle 650b45b7749SMilanka Ringwald * @param value_handle 651b45b7749SMilanka Ringwald * @param value_length 652b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 65340faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 65440faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 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 */ 658b45b7749SMilanka 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); 6593deb3ec6SMatthias Ringwald 6603deb3ec6SMatthias Ringwald /** 66179188ed7SMilanka Ringwald * @brief Reads the characteristic descriptor using its handle. 66279188ed7SMilanka Ringwald * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 66379188ed7SMilanka 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 66740faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 66840faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 669692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 670692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6713deb3ec6SMatthias Ringwald */ 672711e6c80SMatthias 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); 6736da84376SMilanka Ringwald 6746da84376SMilanka Ringwald /** 67579188ed7SMilanka Ringwald * @brief Reads the characteristic descriptor using its handle. 67679188ed7SMilanka Ringwald * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 67779188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 6786da84376SMilanka Ringwald * @param callback 6796da84376SMilanka Ringwald * @param con_handle 6806da84376SMilanka Ringwald * @param descriptor 68140faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 68240faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 683692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 684692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6856da84376SMilanka Ringwald */ 686711e6c80SMatthias 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); 6873deb3ec6SMatthias Ringwald 6883deb3ec6SMatthias Ringwald /** 68979188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 69079188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 69179188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 6926da84376SMilanka Ringwald * @param callback 6936da84376SMilanka Ringwald * @param con_handle 694b45b7749SMilanka Ringwald * @param descriptor 69540faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 69640faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 697692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 698692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6993deb3ec6SMatthias Ringwald */ 700711e6c80SMatthias 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); 7016da84376SMilanka Ringwald 7026da84376SMilanka Ringwald /** 70379188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 70479188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 70579188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 7066da84376SMilanka Ringwald * @param callback 7076da84376SMilanka Ringwald * @param con_handle 7086da84376SMilanka Ringwald * @param descriptor_handle 70940faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 71040faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 711692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 712692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7136da84376SMilanka Ringwald */ 714711e6c80SMatthias 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); 7156da84376SMilanka Ringwald 7166da84376SMilanka Ringwald /** 71779188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 71879188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 71979188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 7206da84376SMilanka Ringwald * @param callback 7216da84376SMilanka Ringwald * @param con_handle 7226da84376SMilanka Ringwald * @param descriptor_handle 7236da84376SMilanka Ringwald * @param offset 72440faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 72540faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 726692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 727692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7286da84376SMilanka Ringwald */ 729711e6c80SMatthias 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); 7303deb3ec6SMatthias Ringwald 7313deb3ec6SMatthias Ringwald /** 73279188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 73379188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 73479188ed7SMilanka 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). 7356da84376SMilanka Ringwald * @param callback 7366da84376SMilanka Ringwald * @param con_handle 7376da84376SMilanka Ringwald * @param descriptor 738b45b7749SMilanka Ringwald * @param value_length 739b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 74040faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 74140faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 742692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 743692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7443deb3ec6SMatthias Ringwald */ 745b45b7749SMilanka 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); 7466da84376SMilanka Ringwald 7476da84376SMilanka Ringwald /** 74879188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 74979188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 75079188ed7SMilanka 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). 7516da84376SMilanka Ringwald * @param callback 7526da84376SMilanka Ringwald * @param con_handle 7536da84376SMilanka Ringwald * @param descriptor_handle 754b45b7749SMilanka Ringwald * @param value_length 755b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 75640faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 75740faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 758692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 759692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7606da84376SMilanka Ringwald */ 761b45b7749SMilanka 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); 7626da84376SMilanka Ringwald 7636da84376SMilanka Ringwald /** 76479188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 76579188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 76679188ed7SMilanka 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). 7676da84376SMilanka Ringwald * @param callback 7686da84376SMilanka Ringwald * @param con_handle 7696da84376SMilanka Ringwald * @param descriptor 770b45b7749SMilanka Ringwald * @param value_length 771b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 77240faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 77340faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 774692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 775692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7766da84376SMilanka Ringwald */ 777b45b7749SMilanka 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); 7786da84376SMilanka Ringwald 7796da84376SMilanka Ringwald /** 78079188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 78179188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 78279188ed7SMilanka 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). 7836da84376SMilanka Ringwald * @param callback 7846da84376SMilanka Ringwald * @param con_handle 7856da84376SMilanka Ringwald * @param descriptor_handle 786b45b7749SMilanka Ringwald * @param value_length 787b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 78840faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 78940faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 790692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 791692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7926da84376SMilanka Ringwald */ 793b45b7749SMilanka 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); 7946da84376SMilanka Ringwald 7956da84376SMilanka Ringwald /** 79679188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 79779188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 79879188ed7SMilanka 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). 7996da84376SMilanka Ringwald * @param callback 8006da84376SMilanka Ringwald * @param con_handle 8016da84376SMilanka Ringwald * @param descriptor_handle 8026da84376SMilanka Ringwald * @param offset of value 803b45b7749SMilanka Ringwald * @param value_length 804b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 80540faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 80640faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 807692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 808692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 8096da84376SMilanka Ringwald */ 810b45b7749SMilanka 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); 8113deb3ec6SMatthias Ringwald 8123deb3ec6SMatthias Ringwald /** 81379188ed7SMilanka Ringwald * @brief Writes the client characteristic configuration of the specified characteristic. 81479188ed7SMilanka Ringwald * It is used to subscribe for notifications or indications of the characteristic value. 81579188ed7SMilanka Ringwald * For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION 81679188ed7SMilanka Ringwald * resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value. 81779188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 81879188ed7SMilanka 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). 8196da84376SMilanka Ringwald * @param callback 8206da84376SMilanka Ringwald * @param con_handle 8216da84376SMilanka Ringwald * @param characteristic 822b7e5512fSMilanka Ringwald * @param configuration GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION, GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION 82340faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 82440faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 825692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 826b7e5512fSMilanka Ringwald * GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED if configuring notification, but characteristic has no notification property set 827b7e5512fSMilanka Ringwald * GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED if configuring indication, but characteristic has no indication property set 8286b04f675SMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if configuration is invalid 829b7e5512fSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 8303deb3ec6SMatthias Ringwald */ 831711e6c80SMatthias 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); 8329c662c9bSMatthias Ringwald 8339c662c9bSMatthias Ringwald /** 83479188ed7SMilanka Ringwald * @brief Register for notifications and indications of a characteristic enabled by 83579188ed7SMilanka Ringwald * the gatt_client_write_client_characteristic_configuration function. 8369c662c9bSMatthias Ringwald * @param notification struct used to store registration 8376da84376SMilanka Ringwald * @param callback 838b3f03c84SMatthias Ringwald * @param con_handle or GATT_CLIENT_ANY_CONNECTION to receive updates from all connected devices 839b3f03c84SMatthias Ringwald * @param characteristic or NULL to receive updates for all characteristics 8409c662c9bSMatthias Ringwald */ 8416da84376SMilanka 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); 8423deb3ec6SMatthias Ringwald 8433deb3ec6SMatthias Ringwald /** 84479188ed7SMilanka Ringwald * @brief Stop listening to characteristic value updates registered with 84579188ed7SMilanka Ringwald * the gatt_client_listen_for_characteristic_value_updates function. 8461f734b5fSMatthias Ringwald * @param notification struct used in gatt_client_listen_for_characteristic_value_updates 8471f734b5fSMatthias Ringwald */ 8481f734b5fSMatthias Ringwald void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification); 8491f734b5fSMatthias Ringwald 8501f734b5fSMatthias Ringwald /** 85179188ed7SMilanka Ringwald * @brief Transactional write. It can be called as many times as it is needed to write the characteristics within the same transaction. 85279188ed7SMilanka Ringwald * Call the gatt_client_execute_write function to commit the transaction. 8536da84376SMilanka Ringwald * @param callback 8546da84376SMilanka Ringwald * @param con_handle 8556da84376SMilanka Ringwald * @param attribute_handle 8566da84376SMilanka Ringwald * @param offset of value 857b45b7749SMilanka Ringwald * @param value_length 858b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 8593deb3ec6SMatthias Ringwald */ 860b45b7749SMilanka 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); 8613deb3ec6SMatthias Ringwald 8623deb3ec6SMatthias Ringwald /** 8636da84376SMilanka Ringwald * @brief Commit transactional write. GATT_EVENT_QUERY_COMPLETE is received. 8646da84376SMilanka Ringwald * @param callback 8656da84376SMilanka Ringwald * @param con_handle 86640faeb84SMilanka Ringwald * @return status 8673deb3ec6SMatthias Ringwald */ 868711e6c80SMatthias Ringwald uint8_t gatt_client_execute_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 8693deb3ec6SMatthias Ringwald 8703deb3ec6SMatthias Ringwald /** 8716da84376SMilanka Ringwald * @brief Abort transactional write. GATT_EVENT_QUERY_COMPLETE is received. 8726da84376SMilanka Ringwald * @param callback 8736da84376SMilanka Ringwald * @param con_handle 87440faeb84SMilanka Ringwald * @return status 8753deb3ec6SMatthias Ringwald */ 876711e6c80SMatthias Ringwald uint8_t gatt_client_cancel_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 8773deb3ec6SMatthias Ringwald 87859d34cd2SMatthias Ringwald /** 879*53e9c18fSMatthias Ringwald * @brief Request callback when regular gatt query can be sent 880*53e9c18fSMatthias Ringwald * @note callback might happen during call to this function 881*53e9c18fSMatthias Ringwald * @param callback_registration to point to callback function and context information 882*53e9c18fSMatthias Ringwald * @param con_handle 883*53e9c18fSMatthias Ringwald * @return ERROR_CODE_SUCCESS if ok, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if handle unknown, and ERROR_CODE_COMMAND_DISALLOWED if callback already registered 884*53e9c18fSMatthias Ringwald */ 885*53e9c18fSMatthias Ringwald uint8_t gatt_client_request_to_send_gatt_query(btstack_context_callback_registration_t * callback_registration, hci_con_handle_t con_handle); 886*53e9c18fSMatthias Ringwald 887*53e9c18fSMatthias Ringwald /** 88859d34cd2SMatthias Ringwald * @brief Request callback when writing characteristic value without response is possible 889*53e9c18fSMatthias Ringwald * @note callback might happen during call to this function 89059d34cd2SMatthias Ringwald * @param callback_registration to point to callback function and context information 89159d34cd2SMatthias Ringwald * @param con_handle 89259d34cd2SMatthias Ringwald * @return ERROR_CODE_SUCCESS if ok, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if handle unknown, and ERROR_CODE_COMMAND_DISALLOWED if callback already registered 89359d34cd2SMatthias Ringwald */ 89459d34cd2SMatthias Ringwald uint8_t gatt_client_request_to_write_without_response(btstack_context_callback_registration_t * callback_registration, hci_con_handle_t con_handle); 89559d34cd2SMatthias Ringwald 89659d34cd2SMatthias Ringwald 89759d34cd2SMatthias Ringwald // the following functions are marked as deprecated and will be removed eventually 89859d34cd2SMatthias Ringwald /** 89959d34cd2SMatthias Ringwald * @brief Requests GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE that guarantees 90059d34cd2SMatthias Ringwald * a single successful gatt_client_write_value_of_characteristic_without_response call. 90159d34cd2SMatthias Ringwald * @deprecated please use gatt_client_request_to_write_without_response instead 90259d34cd2SMatthias Ringwald * @param callback 90359d34cd2SMatthias Ringwald * @param con_handle 90459d34cd2SMatthias Ringwald * @return status 90559d34cd2SMatthias Ringwald */ 90659d34cd2SMatthias Ringwald uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 90759d34cd2SMatthias Ringwald 90859d34cd2SMatthias Ringwald 9093deb3ec6SMatthias Ringwald /* API_END */ 9103deb3ec6SMatthias Ringwald 9116ba2ad22SMatthias Ringwald // used by generated btstack_event.c 9126ba2ad22SMatthias Ringwald 913313e337bSMatthias Ringwald void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t * service); 914313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic); 915313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor); 9166ba2ad22SMatthias Ringwald 917a6121b51SMilanka Ringwald #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 918a6121b51SMilanka Ringwald void gatt_client_att_packet_handler_fuzz(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size); 91940faeb84SMilanka Ringwald uint8_t gatt_client_get_client(hci_con_handle_t con_handle, gatt_client_t ** gatt_client); 920a6121b51SMilanka Ringwald #endif 921a6121b51SMilanka Ringwald 9223deb3ec6SMatthias Ringwald #if defined __cplusplus 9233deb3ec6SMatthias Ringwald } 9243deb3ec6SMatthias Ringwald #endif 9253deb3ec6SMatthias Ringwald 9263deb3ec6SMatthias Ringwald #endif 927