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, 1331450cdc6SMatthias Ringwald 1341450cdc6SMatthias Ringwald P_W2_SDP_QUERY, 1351450cdc6SMatthias Ringwald P_W4_SDP_QUERY, 1361450cdc6SMatthias Ringwald P_W4_L2CAP_CONNECTION, 1373deb3ec6SMatthias Ringwald } gatt_client_state_t; 1383deb3ec6SMatthias Ringwald 1393deb3ec6SMatthias Ringwald 1403deb3ec6SMatthias Ringwald typedef enum{ 1413deb3ec6SMatthias Ringwald SEND_MTU_EXCHANGE, 1423deb3ec6SMatthias Ringwald SENT_MTU_EXCHANGE, 1435cf6c434SJakob Krantz MTU_EXCHANGED, 1445cf6c434SJakob Krantz MTU_AUTO_EXCHANGE_DISABLED 1453deb3ec6SMatthias Ringwald } gatt_client_mtu_t; 1463deb3ec6SMatthias Ringwald 1473deb3ec6SMatthias Ringwald typedef struct gatt_client{ 148665d90f2SMatthias Ringwald btstack_linked_item_t item; 1493deb3ec6SMatthias Ringwald // TODO: rename gatt_client_state -> state 1503deb3ec6SMatthias Ringwald gatt_client_state_t gatt_client_state; 1513deb3ec6SMatthias Ringwald 1529c662c9bSMatthias Ringwald // user callback 1539c662c9bSMatthias Ringwald btstack_packet_handler_t callback; 1543deb3ec6SMatthias Ringwald 15547181045SMatthias Ringwald // can write without response callback 15647181045SMatthias Ringwald btstack_packet_handler_t write_without_response_callback; 15747181045SMatthias Ringwald 15859d34cd2SMatthias Ringwald // can write without response requests 15959d34cd2SMatthias Ringwald btstack_linked_list_t write_without_response_requests; 16059d34cd2SMatthias Ringwald 16153e9c18fSMatthias Ringwald // regular gatt query requests 16253e9c18fSMatthias Ringwald btstack_linked_list_t query_requests; 16353e9c18fSMatthias Ringwald 164fc64f94aSMatthias Ringwald hci_con_handle_t con_handle; 165f4b33574SMatthias Ringwald 1661450cdc6SMatthias Ringwald #ifdef ENABLE_GATT_OVER_CLASSIC 1671450cdc6SMatthias Ringwald bd_addr_t addr; 1681450cdc6SMatthias Ringwald uint16_t l2cap_psm; 1691450cdc6SMatthias Ringwald uint16_t l2cap_cid; 1701450cdc6SMatthias Ringwald btstack_context_callback_registration_t sdp_query_request; 1711450cdc6SMatthias Ringwald #endif 1721450cdc6SMatthias Ringwald 1733deb3ec6SMatthias Ringwald uint16_t mtu; 1743deb3ec6SMatthias Ringwald gatt_client_mtu_t mtu_state; 1753deb3ec6SMatthias Ringwald 1763deb3ec6SMatthias Ringwald uint16_t uuid16; 1773deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 1783deb3ec6SMatthias Ringwald 1793deb3ec6SMatthias Ringwald uint16_t start_group_handle; 1803deb3ec6SMatthias Ringwald uint16_t end_group_handle; 1813deb3ec6SMatthias Ringwald 1823deb3ec6SMatthias Ringwald uint16_t query_start_handle; 1833deb3ec6SMatthias Ringwald uint16_t query_end_handle; 1843deb3ec6SMatthias Ringwald 1853deb3ec6SMatthias Ringwald uint8_t characteristic_properties; 1863deb3ec6SMatthias Ringwald uint16_t characteristic_start_handle; 1873deb3ec6SMatthias Ringwald 1883deb3ec6SMatthias Ringwald uint16_t attribute_handle; 1893deb3ec6SMatthias Ringwald uint16_t attribute_offset; 1903deb3ec6SMatthias Ringwald uint16_t attribute_length; 1913deb3ec6SMatthias Ringwald uint8_t* attribute_value; 1923deb3ec6SMatthias Ringwald 1933deb3ec6SMatthias Ringwald // read multiple characteristic values 1943deb3ec6SMatthias Ringwald uint16_t read_multiple_handle_count; 1953deb3ec6SMatthias Ringwald uint16_t * read_multiple_handles; 1963deb3ec6SMatthias Ringwald 1973deb3ec6SMatthias Ringwald uint16_t client_characteristic_configuration_handle; 1983deb3ec6SMatthias Ringwald uint8_t client_characteristic_configuration_value[2]; 1993deb3ec6SMatthias Ringwald 2003deb3ec6SMatthias Ringwald uint8_t filter_with_uuid; 2013deb3ec6SMatthias Ringwald uint8_t send_confirmation; 2023deb3ec6SMatthias Ringwald 2033deb3ec6SMatthias Ringwald int le_device_index; 2043deb3ec6SMatthias Ringwald uint8_t cmac[8]; 2053deb3ec6SMatthias Ringwald 206ec820d77SMatthias Ringwald btstack_timer_source_t gc_timeout; 207f4b33574SMatthias Ringwald 208f4b33574SMatthias Ringwald uint8_t security_counter; 2093503dc74SMatthias Ringwald uint8_t wait_for_authentication_complete; 210f4b33574SMatthias Ringwald uint8_t pending_error_code; 211f4b33574SMatthias Ringwald 2128918bbdaSMatthias Ringwald bool reencryption_active; 2138918bbdaSMatthias Ringwald uint8_t reencryption_result; 2148918bbdaSMatthias Ringwald 2151dfae9c7SMatthias Ringwald gap_security_level_t security_level; 2161dfae9c7SMatthias Ringwald 2173deb3ec6SMatthias Ringwald } gatt_client_t; 2183deb3ec6SMatthias Ringwald 2199c662c9bSMatthias Ringwald typedef struct gatt_client_notification { 220665d90f2SMatthias Ringwald btstack_linked_item_t item; 221b6e96f14SMatthias Ringwald btstack_packet_handler_t callback; 222711e6c80SMatthias Ringwald hci_con_handle_t con_handle; 2239c662c9bSMatthias Ringwald uint16_t attribute_handle; 2249c662c9bSMatthias Ringwald } gatt_client_notification_t; 2253deb3ec6SMatthias Ringwald 2263deb3ec6SMatthias Ringwald /* API_START */ 2273deb3ec6SMatthias Ringwald 228d25c33e5SMatthias Ringwald typedef struct { 2293deb3ec6SMatthias Ringwald uint16_t start_group_handle; 2303deb3ec6SMatthias Ringwald uint16_t end_group_handle; 2313deb3ec6SMatthias Ringwald uint16_t uuid16; 2323deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 233d25c33e5SMatthias Ringwald } gatt_client_service_t; 2343deb3ec6SMatthias Ringwald 235d25c33e5SMatthias Ringwald typedef struct { 2363deb3ec6SMatthias Ringwald uint16_t start_handle; 2373deb3ec6SMatthias Ringwald uint16_t value_handle; 2383deb3ec6SMatthias Ringwald uint16_t end_handle; 2393deb3ec6SMatthias Ringwald uint16_t properties; 2403deb3ec6SMatthias Ringwald uint16_t uuid16; 2413deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 242d25c33e5SMatthias Ringwald } gatt_client_characteristic_t; 2433deb3ec6SMatthias Ringwald 244d25c33e5SMatthias Ringwald typedef struct { 2453deb3ec6SMatthias Ringwald uint16_t handle; 2463deb3ec6SMatthias Ringwald uint16_t uuid16; 2473deb3ec6SMatthias Ringwald uint8_t uuid128[16]; 248d25c33e5SMatthias Ringwald } gatt_client_characteristic_descriptor_t; 2493deb3ec6SMatthias Ringwald 2503deb3ec6SMatthias Ringwald /** 2513deb3ec6SMatthias Ringwald * @brief Set up GATT client. 2523deb3ec6SMatthias Ringwald */ 2533deb3ec6SMatthias Ringwald void gatt_client_init(void); 2543deb3ec6SMatthias Ringwald 2553deb3ec6SMatthias Ringwald /** 25611279da7SMatthias Ringwald * @brief Set minimum required security level for GATT Client 25711279da7SMatthias Ringwald * @note The Bluetooth specification makes the GATT Server responsible to check for security. 258b11289a8SMatthias Ringwald * This allows an attacker to spoof an existing device with a GATT Servers, but skip the authentication part. 259b11289a8SMatthias Ringwald * If your application is exchanging sensitive data with a remote device, you would need to manually check 260b11289a8SMatthias Ringwald * the security level before sending/receive such data. 261b11289a8SMatthias Ringwald * With level > 0, the GATT Client triggers authentication for all GATT Requests and defers any exchange 262b11289a8SMatthias Ringwald * until the required security level is established. 263b11289a8SMatthias Ringwald * gatt_client_request_can_write_without_response_event does not trigger authentication 26459d34cd2SMatthias Ringwald * gatt_client_request_to_write_without_response does not trigger authentication 26511279da7SMatthias Ringwald * @pram level, default LEVEL_0 (no encryption required) 26611279da7SMatthias Ringwald */ 26711279da7SMatthias Ringwald void gatt_client_set_required_security_level(gap_security_level_t level); 26811279da7SMatthias Ringwald 26911279da7SMatthias Ringwald /** 2701450cdc6SMatthias Ringwald * @brief Connect to remote GATT Server over Classic (BR/EDR) Connection 271*effecf77SMatthias Ringwald * GATT_EVENT_CONNECTED with status and con_handle for other API functions 272*effecf77SMatthias Ringwald * is emitted on connection complete. 273*effecf77SMatthias Ringwald * @note requires ENABLE_GATT_OVER_CLASSIC. 2741450cdc6SMatthias Ringwald * @param addr 2751450cdc6SMatthias Ringwald * @return status 2761450cdc6SMatthias Ringwald */ 2771450cdc6SMatthias Ringwald uint8_t gatt_client_classic_connect(btstack_packet_handler_t callback, bd_addr_t addr); 2781450cdc6SMatthias Ringwald 2791450cdc6SMatthias Ringwald /** 2801450cdc6SMatthias Ringwald * @brief Disconnect o Classic (BR/EDR) connection to a remote GATT Server 2811450cdc6SMatthias Ringwald * @note requires ENABLE_GATT_OVER_CLASSIC 282*effecf77SMatthias Ringwald * @param con_handle 2831450cdc6SMatthias Ringwald * @return status 2841450cdc6SMatthias Ringwald */ 2851450cdc6SMatthias Ringwald uint8_t gatt_client_classic_disconnect(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 2861450cdc6SMatthias Ringwald 2871450cdc6SMatthias Ringwald /** 28879188ed7SMilanka Ringwald * @brief MTU is available after the first query has completed. If status is equal to ERROR_CODE_SUCCESS, it returns the real value, 28979188ed7SMilanka Ringwald * otherwise the default value ATT_DEFAULT_MTU (see bluetooth.h). 2906da84376SMilanka Ringwald * @param con_handle 2916da84376SMilanka Ringwald * @param mtu 29240faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 29340faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 294692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if MTU is not exchanged and MTU auto-exchange is disabled 295692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 2963deb3ec6SMatthias Ringwald */ 297fc64f94aSMatthias Ringwald uint8_t gatt_client_get_mtu(hci_con_handle_t con_handle, uint16_t * mtu); 2983deb3ec6SMatthias Ringwald 2993deb3ec6SMatthias Ringwald /** 30079188ed7SMilanka Ringwald * @brief Sets whether a MTU Exchange Request shall be automatically send before the 30179188ed7SMilanka Ringwald * first attribute read request is send. Default is enabled. 3026da84376SMilanka Ringwald * @param enabled 3035cf6c434SJakob Krantz */ 3045cf6c434SJakob Krantz void gatt_client_mtu_enable_auto_negotiation(uint8_t enabled); 3055cf6c434SJakob Krantz 3065cf6c434SJakob Krantz /** 30779188ed7SMilanka Ringwald * @brief Sends a MTU Exchange Request, this allows for the client to exchange MTU 30879188ed7SMilanka Ringwald * when gatt_client_mtu_enable_auto_negotiation is disabled. 3096da84376SMilanka Ringwald * @param callback 3106da84376SMilanka Ringwald * @param con_handle 3115cf6c434SJakob Krantz */ 3125cf6c434SJakob Krantz void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 3135cf6c434SJakob Krantz 3145cf6c434SJakob Krantz /** 315aacf1b1aSMilanka Ringwald * @brief Returns 1 if the GATT client is ready to receive a query. It is used with daemon. 3166da84376SMilanka Ringwald * @param con_handle 317692bf1adSMilanka Ringwald * @return is_ready_status 0 - if no GATT client for con_handle is found, or is not ready, otherwise 1 3183deb3ec6SMatthias Ringwald */ 319fc64f94aSMatthias Ringwald int gatt_client_is_ready(hci_con_handle_t con_handle); 3203deb3ec6SMatthias Ringwald 3213deb3ec6SMatthias Ringwald /** 32279188ed7SMilanka Ringwald * @brief Discovers all primary services. 32379188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 32479188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3256da84376SMilanka Ringwald * @param callback 3266da84376SMilanka Ringwald * @param con_handle 327692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 328692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 329692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3303deb3ec6SMatthias Ringwald */ 331711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 3323deb3ec6SMatthias Ringwald 3333deb3ec6SMatthias Ringwald /** 33479188ed7SMilanka Ringwald * @brief Discovers all secondary services. 33579188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 33679188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3378d1f34d3SMatheus Eduardo Garbelini * @param callback 3388d1f34d3SMatheus Eduardo Garbelini * @param con_handle 3398d1f34d3SMatheus Eduardo Garbelini * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 3408d1f34d3SMatheus Eduardo Garbelini * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 3418d1f34d3SMatheus Eduardo Garbelini * ERROR_CODE_SUCCESS , if query is successfully registered 3428d1f34d3SMatheus Eduardo Garbelini */ 3438d1f34d3SMatheus Eduardo Garbelini uint8_t gatt_client_discover_secondary_services(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 3448d1f34d3SMatheus Eduardo Garbelini 3458d1f34d3SMatheus Eduardo Garbelini /** 34679188ed7SMilanka Ringwald * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. 34779188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 34879188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3496da84376SMilanka Ringwald * @param callback 3506da84376SMilanka Ringwald * @param con_handle 3516da84376SMilanka Ringwald * @param uuid16 352692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 353692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 354692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3553deb3ec6SMatthias Ringwald */ 356711e6c80SMatthias Ringwald uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16); 3576da84376SMilanka Ringwald 3586da84376SMilanka Ringwald /** 35979188ed7SMilanka Ringwald * @brief Discovers a specific primary service given its UUID. This service may exist multiple times. 36079188ed7SMilanka Ringwald * For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted. 36179188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3626da84376SMilanka Ringwald * @param callback 3636da84376SMilanka Ringwald * @param con_handle 3646da84376SMilanka Ringwald * @param uuid128 365692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 366692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 367692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3686da84376SMilanka Ringwald */ 3696da84376SMilanka 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); 3703deb3ec6SMatthias Ringwald 3713deb3ec6SMatthias Ringwald /** 37279188ed7SMilanka Ringwald * @brief Finds included services within the specified service. 37379188ed7SMilanka Ringwald * For each found included service a GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT event will be emitted. 37479188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 37579188ed7SMilanka Ringwald * Information about included service type (primary/secondary) can be retrieved either by sending 37679188ed7SMilanka Ringwald * an ATT find information request for the returned start group handle 37779188ed7SMilanka Ringwald * (returning the handle and the UUID for primary or secondary service) or by comparing the service 37879188ed7SMilanka Ringwald * to the list of all primary services. 3796da84376SMilanka Ringwald * @param callback 3806da84376SMilanka Ringwald * @param con_handle 3816da84376SMilanka Ringwald * @param service 382692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 383692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 384692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3853deb3ec6SMatthias Ringwald */ 386711e6c80SMatthias 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); 3873deb3ec6SMatthias Ringwald 3883deb3ec6SMatthias Ringwald /** 38979188ed7SMilanka Ringwald * @brief Discovers all characteristics within the specified service. 39079188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will be emited. 39179188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 3926da84376SMilanka Ringwald * @param callback 3936da84376SMilanka Ringwald * @param con_handle 3946da84376SMilanka Ringwald * @param service 395692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 396692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 397692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 3983deb3ec6SMatthias Ringwald */ 399711e6c80SMatthias 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); 4003deb3ec6SMatthias Ringwald 4013deb3ec6SMatthias Ringwald /** 40279188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within 40379188ed7SMilanka Ringwald * the specified service or handle range, and return those that match the given UUID. 40479188ed7SMilanka Ringwald * 40579188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 40679188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4076da84376SMilanka Ringwald * @param callback 4086da84376SMilanka Ringwald * @param con_handle 4096da84376SMilanka Ringwald * @param start_handle 4106da84376SMilanka Ringwald * @param end_handle 4116da84376SMilanka Ringwald * @param uuid16 412692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 413692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 414692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4153deb3ec6SMatthias Ringwald */ 416711e6c80SMatthias 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); 4176da84376SMilanka Ringwald 4186da84376SMilanka Ringwald /** 41979188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 42079188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 42179188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 42279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4236da84376SMilanka Ringwald * @param callback 4246da84376SMilanka Ringwald * @param con_handle 4256da84376SMilanka Ringwald * @param start_handle 4266da84376SMilanka Ringwald * @param end_handle 4276da84376SMilanka Ringwald * @param uuid128 428692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 429692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 430692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4316da84376SMilanka Ringwald */ 432045d700dSDavid 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); 4336da84376SMilanka Ringwald 4346da84376SMilanka Ringwald /** 43579188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 43679188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 43779188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 43879188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4396da84376SMilanka Ringwald * @param callback 4406da84376SMilanka Ringwald * @param con_handle 4416da84376SMilanka Ringwald * @param service 4426da84376SMilanka Ringwald * @param uuid16 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 4466da84376SMilanka Ringwald */ 447711e6c80SMatthias 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); 4486da84376SMilanka Ringwald 4496da84376SMilanka Ringwald /** 45079188ed7SMilanka Ringwald * @brief The following four functions are used to discover all characteristics within the 45179188ed7SMilanka Ringwald * specified service or handle range, and return those that match the given UUID. 45279188ed7SMilanka Ringwald * For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will emitted. 45379188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4546da84376SMilanka Ringwald * @param callback 4556da84376SMilanka Ringwald * @param con_handle 4566da84376SMilanka Ringwald * @param service 4576da84376SMilanka Ringwald * @param uuid128 458692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 459692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 460692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4616da84376SMilanka Ringwald */ 462045d700dSDavid 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); 4633deb3ec6SMatthias Ringwald 4643deb3ec6SMatthias Ringwald /** 46579188ed7SMilanka Ringwald * @brief Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic. 46679188ed7SMilanka Ringwald * For each found descriptor a GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT event will be emitted. 46779188ed7SMilanka Ringwald * 46879188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery. 4696da84376SMilanka Ringwald * @param callback 4706da84376SMilanka Ringwald * @param con_handle 4716da84376SMilanka Ringwald * @param characteristic 472692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 473692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 474692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4753deb3ec6SMatthias Ringwald */ 476711e6c80SMatthias Ringwald uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic); 4773deb3ec6SMatthias Ringwald 4783deb3ec6SMatthias Ringwald /** 47979188ed7SMilanka Ringwald * @brief Reads the characteristic value using the characteristic's value handle. 48079188ed7SMilanka Ringwald * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 48179188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4826da84376SMilanka Ringwald * @param callback 4836da84376SMilanka Ringwald * @param con_handle 4846da84376SMilanka Ringwald * @param characteristic 485692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 486692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 487692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 4883deb3ec6SMatthias Ringwald */ 489711e6c80SMatthias 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); 4906da84376SMilanka Ringwald 4916da84376SMilanka Ringwald /** 49279188ed7SMilanka Ringwald * @brief Reads the characteristic value using the characteristic's value handle. 49379188ed7SMilanka Ringwald * If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 49479188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 4956da84376SMilanka Ringwald * @param callback 4966da84376SMilanka Ringwald * @param con_handle 497b45b7749SMilanka Ringwald * @param value_handle 498692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 499692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 500692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5016da84376SMilanka Ringwald */ 502b45b7749SMilanka 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); 5033deb3ec6SMatthias Ringwald 5043deb3ec6SMatthias Ringwald /** 50579188ed7SMilanka Ringwald * @brief Reads the characteric value of all characteristics with the uuid. 50679188ed7SMilanka Ringwald * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 50779188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5086da84376SMilanka Ringwald * @param callback 5096da84376SMilanka Ringwald * @param con_handle 5106da84376SMilanka Ringwald * @param start_handle 5116da84376SMilanka Ringwald * @param end_handle 5126da84376SMilanka Ringwald * @param uuid16 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_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); 5186da84376SMilanka Ringwald 5196da84376SMilanka Ringwald /** 52079188ed7SMilanka Ringwald * @brief Reads the characteric value of all characteristics with the uuid. 52179188ed7SMilanka Ringwald * For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted. 52279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5236da84376SMilanka Ringwald * @param callback 5246da84376SMilanka Ringwald * @param con_handle 5256da84376SMilanka Ringwald * @param start_handle 5266da84376SMilanka Ringwald * @param end_handle 5276da84376SMilanka Ringwald * @param uuid128 528692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 529692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 530692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5316da84376SMilanka Ringwald */ 532045d700dSDavid 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); 5333deb3ec6SMatthias Ringwald 5343deb3ec6SMatthias Ringwald /** 53579188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 53679188ed7SMilanka Ringwald * The value will be returned in several blobs. 53779188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 53879188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5396da84376SMilanka Ringwald * @param callback 5406da84376SMilanka Ringwald * @param con_handle 5416da84376SMilanka Ringwald * @param characteristic 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 5453deb3ec6SMatthias Ringwald */ 546711e6c80SMatthias 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); 5476da84376SMilanka Ringwald 5486da84376SMilanka Ringwald /** 54979188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 55079188ed7SMilanka Ringwald * The value will be returned in several blobs. 55179188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 55279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5536da84376SMilanka Ringwald * @param callback 5546da84376SMilanka Ringwald * @param con_handle 555b45b7749SMilanka Ringwald * @param value_handle 556692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 557692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 558692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5596da84376SMilanka Ringwald */ 560b45b7749SMilanka 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); 5616da84376SMilanka Ringwald 5626da84376SMilanka Ringwald /** 56379188ed7SMilanka Ringwald * @brief Reads the long characteristic value using the characteristic's value handle. 56479188ed7SMilanka Ringwald * The value will be returned in several blobs. 56579188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_LONG_CHARACTERISTIC_VALUE_QUERY_RESULT event with updated value offset will be emitted. 56679188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 5676da84376SMilanka Ringwald * @param callback 5686da84376SMilanka Ringwald * @param con_handle 569b45b7749SMilanka Ringwald * @param value_handle 5706da84376SMilanka Ringwald * @param offset 571692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 572692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 573692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5746da84376SMilanka Ringwald */ 575b45b7749SMilanka 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); 5763deb3ec6SMatthias Ringwald 5773deb3ec6SMatthias Ringwald /* 57879188ed7SMilanka Ringwald * @brief Read multiple characteristic values. 57979188ed7SMilanka Ringwald * The all results are emitted via single GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event, 58079188ed7SMilanka Ringwald * followed by the GATT_EVENT_QUERY_COMPLETE event, which marks the end of read. 5816da84376SMilanka Ringwald * @param callback 5826da84376SMilanka Ringwald * @param con_handle 5836da84376SMilanka Ringwald * @param num_value_handles 5846da84376SMilanka Ringwald * @param value_handles list of handles 58579188ed7SMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 58679188ed7SMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 58779188ed7SMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 5883deb3ec6SMatthias Ringwald */ 589711e6c80SMatthias 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); 5903deb3ec6SMatthias Ringwald 5913deb3ec6SMatthias Ringwald /** 59279188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle without 59379188ed7SMilanka Ringwald * an acknowledgment that the write was successfully performed. 5946da84376SMilanka Ringwald * @param con_handle 595b45b7749SMilanka Ringwald * @param value_handle 596b45b7749SMilanka Ringwald * @param value_length 5977e6f0853SDavid Lechner * @param value is copied on success and does not need to be retained 598692bf1adSMilanka Ringwald * @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found 599692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready 600692bf1adSMilanka Ringwald * BTSTACK_ACL_BUFFERS_FULL , if L2CAP cannot send, there are no free ACL slots 601692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS , if query is successfully registered 6023deb3ec6SMatthias Ringwald */ 603b45b7749SMilanka 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); 6043deb3ec6SMatthias Ringwald 6053deb3ec6SMatthias Ringwald /** 60679188ed7SMilanka Ringwald * @brief Writes the authenticated characteristic value using the characteristic's value handle 60779188ed7SMilanka Ringwald * without an acknowledgment that the write was successfully performed. 60879188ed7SMilanka Ringwald * @note GATT_EVENT_QUERY_COMPLETE is emitted with ATT_ERROR_SUCCESS for success, 60979188ed7SMilanka Ringwald * or ATT_ERROR_BONDING_INFORMATION_MISSING if there is no bonding information stored. 6106da84376SMilanka Ringwald * @param callback 6116da84376SMilanka Ringwald * @param con_handle 6126da84376SMilanka Ringwald * @param value_handle 6136da84376SMilanka Ringwald * @param message_len 6146da84376SMilanka Ringwald * @param message is not copied, make sure memory is accessible until write is done 61540faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 61640faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 617692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 618692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6193deb3ec6SMatthias Ringwald */ 6206da84376SMilanka 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); 6213deb3ec6SMatthias Ringwald 6223deb3ec6SMatthias Ringwald /** 623b2468039SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 624b2468039SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 625b2468039SMilanka Ringwald * The write is successfully performed, if the event's att_status field is set to 626b2468039SMilanka Ringwald * ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes). 6276da84376SMilanka Ringwald * @param callback 6286da84376SMilanka Ringwald * @param con_handle 629b45b7749SMilanka Ringwald * @param value_handle 630b45b7749SMilanka Ringwald * @param value_length 631b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 63240faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 63340faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 634692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 635692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6363deb3ec6SMatthias Ringwald */ 637b45b7749SMilanka 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); 6386da84376SMilanka Ringwald 6396da84376SMilanka Ringwald /** 64079188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 64179188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 64279188ed7SMilanka 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). 6436da84376SMilanka Ringwald * @param callback 6446da84376SMilanka Ringwald * @param con_handle 645b45b7749SMilanka Ringwald * @param value_handle 646b45b7749SMilanka Ringwald * @param value_length 647b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 64840faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 64940faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 650692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 651692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6526da84376SMilanka Ringwald */ 653b45b7749SMilanka 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); 6546da84376SMilanka Ringwald 6556da84376SMilanka Ringwald /** 65679188ed7SMilanka Ringwald * @brief Writes the characteristic value using the characteristic's value handle. 65779188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 65879188ed7SMilanka 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). 6596da84376SMilanka Ringwald * @param callback 6606da84376SMilanka Ringwald * @param con_handle 661b45b7749SMilanka Ringwald * @param value_handle 6626da84376SMilanka Ringwald * @param offset of value 663b45b7749SMilanka Ringwald * @param value_length 664b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 66540faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 66640faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 667692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 668692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6696da84376SMilanka Ringwald */ 670b45b7749SMilanka 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); 6713deb3ec6SMatthias Ringwald 6723deb3ec6SMatthias Ringwald /** 67379188ed7SMilanka Ringwald * @brief Writes of the long characteristic value using the characteristic's value handle. 67479188ed7SMilanka Ringwald * It uses server response to validate that the write was correctly received. 67579188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE EVENT marks the end of write. 67679188ed7SMilanka 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). 6776da84376SMilanka Ringwald * @param callback 6786da84376SMilanka Ringwald * @param con_handle 679b45b7749SMilanka Ringwald * @param value_handle 680b45b7749SMilanka Ringwald * @param value_length 681b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 68240faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 68340faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 684692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 685692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 6863deb3ec6SMatthias Ringwald */ 687b45b7749SMilanka 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); 6883deb3ec6SMatthias Ringwald 6893deb3ec6SMatthias Ringwald /** 69079188ed7SMilanka Ringwald * @brief Reads the characteristic descriptor using its handle. 69179188ed7SMilanka Ringwald * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 69279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 6936da84376SMilanka Ringwald * @param callback 6946da84376SMilanka Ringwald * @param con_handle 6956da84376SMilanka Ringwald * @param descriptor 69640faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 69740faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 698692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 699692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7003deb3ec6SMatthias Ringwald */ 701711e6c80SMatthias 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); 7026da84376SMilanka Ringwald 7036da84376SMilanka Ringwald /** 70479188ed7SMilanka Ringwald * @brief Reads the characteristic descriptor using its handle. 70579188ed7SMilanka Ringwald * If the characteristic descriptor is found, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 70679188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 7076da84376SMilanka Ringwald * @param callback 7086da84376SMilanka Ringwald * @param con_handle 7096da84376SMilanka Ringwald * @param descriptor 71040faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 71140faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 712692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 713692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7146da84376SMilanka Ringwald */ 715711e6c80SMatthias 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); 7163deb3ec6SMatthias Ringwald 7173deb3ec6SMatthias Ringwald /** 71879188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 71979188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 72079188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 7216da84376SMilanka Ringwald * @param callback 7226da84376SMilanka Ringwald * @param con_handle 723b45b7749SMilanka Ringwald * @param descriptor 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 7283deb3ec6SMatthias Ringwald */ 729711e6c80SMatthias 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); 7306da84376SMilanka Ringwald 7316da84376SMilanka Ringwald /** 73279188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 73379188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 73479188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 7356da84376SMilanka Ringwald * @param callback 7366da84376SMilanka Ringwald * @param con_handle 7376da84376SMilanka Ringwald * @param descriptor_handle 73840faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 73940faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 740692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 741692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7426da84376SMilanka Ringwald */ 743711e6c80SMatthias 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); 7446da84376SMilanka Ringwald 7456da84376SMilanka Ringwald /** 74679188ed7SMilanka Ringwald * @brief Reads the long characteristic descriptor using its handle. It will be returned in several blobs. 74779188ed7SMilanka Ringwald * For each blob, a GATT_EVENT_CHARACTERISTIC_DESCRIPTOR_QUERY_RESULT event will be emitted. 74879188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of read. 7496da84376SMilanka Ringwald * @param callback 7506da84376SMilanka Ringwald * @param con_handle 7516da84376SMilanka Ringwald * @param descriptor_handle 7526da84376SMilanka Ringwald * @param offset 75340faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 75440faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 755692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 756692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7576da84376SMilanka Ringwald */ 758711e6c80SMatthias 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); 7593deb3ec6SMatthias Ringwald 7603deb3ec6SMatthias Ringwald /** 76179188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 76279188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 76379188ed7SMilanka 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). 7646da84376SMilanka Ringwald * @param callback 7656da84376SMilanka Ringwald * @param con_handle 7666da84376SMilanka Ringwald * @param descriptor 767b45b7749SMilanka Ringwald * @param value_length 768b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 76940faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 77040faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 771692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 772692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7733deb3ec6SMatthias Ringwald */ 774b45b7749SMilanka 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); 7756da84376SMilanka Ringwald 7766da84376SMilanka Ringwald /** 77779188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 77879188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 77979188ed7SMilanka 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). 7806da84376SMilanka Ringwald * @param callback 7816da84376SMilanka Ringwald * @param con_handle 7826da84376SMilanka Ringwald * @param descriptor_handle 783b45b7749SMilanka Ringwald * @param value_length 784b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 78540faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 78640faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 787692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 788692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 7896da84376SMilanka Ringwald */ 790b45b7749SMilanka 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); 7916da84376SMilanka Ringwald 7926da84376SMilanka Ringwald /** 79379188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 79479188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 79579188ed7SMilanka 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 descriptor 799b45b7749SMilanka Ringwald * @param value_length 800b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 80140faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 80240faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 803692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 804692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 8056da84376SMilanka Ringwald */ 806b45b7749SMilanka 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); 8076da84376SMilanka Ringwald 8086da84376SMilanka Ringwald /** 80979188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 81079188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 81179188ed7SMilanka 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). 8126da84376SMilanka Ringwald * @param callback 8136da84376SMilanka Ringwald * @param con_handle 8146da84376SMilanka Ringwald * @param descriptor_handle 815b45b7749SMilanka Ringwald * @param value_length 816b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 81740faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 81840faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 819692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 820692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 8216da84376SMilanka Ringwald */ 822b45b7749SMilanka 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); 8236da84376SMilanka Ringwald 8246da84376SMilanka Ringwald /** 82579188ed7SMilanka Ringwald * @brief Writes the characteristic descriptor using its handle. 82679188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 82779188ed7SMilanka 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). 8286da84376SMilanka Ringwald * @param callback 8296da84376SMilanka Ringwald * @param con_handle 8306da84376SMilanka Ringwald * @param descriptor_handle 8316da84376SMilanka Ringwald * @param offset of value 832b45b7749SMilanka Ringwald * @param value_length 833b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 83440faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 83540faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 836692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 837692bf1adSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 8386da84376SMilanka Ringwald */ 839b45b7749SMilanka 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); 8403deb3ec6SMatthias Ringwald 8413deb3ec6SMatthias Ringwald /** 84279188ed7SMilanka Ringwald * @brief Writes the client characteristic configuration of the specified characteristic. 84379188ed7SMilanka Ringwald * It is used to subscribe for notifications or indications of the characteristic value. 84479188ed7SMilanka Ringwald * For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION 84579188ed7SMilanka Ringwald * resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value. 84679188ed7SMilanka Ringwald * The GATT_EVENT_QUERY_COMPLETE event marks the end of write. 84779188ed7SMilanka 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). 8486da84376SMilanka Ringwald * @param callback 8496da84376SMilanka Ringwald * @param con_handle 8506da84376SMilanka Ringwald * @param characteristic 851b7e5512fSMilanka Ringwald * @param configuration GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION, GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION 85240faeb84SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found 85340faeb84SMilanka Ringwald * BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated 854692bf1adSMilanka Ringwald * GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready 855b7e5512fSMilanka Ringwald * GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED if configuring notification, but characteristic has no notification property set 856b7e5512fSMilanka Ringwald * GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED if configuring indication, but characteristic has no indication property set 8576b04f675SMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if configuration is invalid 858b7e5512fSMilanka Ringwald * ERROR_CODE_SUCCESS if query is successfully registered 8593deb3ec6SMatthias Ringwald */ 860711e6c80SMatthias 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); 8619c662c9bSMatthias Ringwald 8629c662c9bSMatthias Ringwald /** 86379188ed7SMilanka Ringwald * @brief Register for notifications and indications of a characteristic enabled by 86479188ed7SMilanka Ringwald * the gatt_client_write_client_characteristic_configuration function. 8659c662c9bSMatthias Ringwald * @param notification struct used to store registration 8666da84376SMilanka Ringwald * @param callback 867b3f03c84SMatthias Ringwald * @param con_handle or GATT_CLIENT_ANY_CONNECTION to receive updates from all connected devices 868b3f03c84SMatthias Ringwald * @param characteristic or NULL to receive updates for all characteristics 8699c662c9bSMatthias Ringwald */ 8706da84376SMilanka 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); 8713deb3ec6SMatthias Ringwald 8723deb3ec6SMatthias Ringwald /** 87379188ed7SMilanka Ringwald * @brief Stop listening to characteristic value updates registered with 87479188ed7SMilanka Ringwald * the gatt_client_listen_for_characteristic_value_updates function. 8751f734b5fSMatthias Ringwald * @param notification struct used in gatt_client_listen_for_characteristic_value_updates 8761f734b5fSMatthias Ringwald */ 8771f734b5fSMatthias Ringwald void gatt_client_stop_listening_for_characteristic_value_updates(gatt_client_notification_t * notification); 8781f734b5fSMatthias Ringwald 8791f734b5fSMatthias Ringwald /** 88079188ed7SMilanka Ringwald * @brief Transactional write. It can be called as many times as it is needed to write the characteristics within the same transaction. 88179188ed7SMilanka Ringwald * Call the gatt_client_execute_write function to commit the transaction. 8826da84376SMilanka Ringwald * @param callback 8836da84376SMilanka Ringwald * @param con_handle 8846da84376SMilanka Ringwald * @param attribute_handle 8856da84376SMilanka Ringwald * @param offset of value 886b45b7749SMilanka Ringwald * @param value_length 887b45b7749SMilanka Ringwald * @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received 8883deb3ec6SMatthias Ringwald */ 889b45b7749SMilanka 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); 8903deb3ec6SMatthias Ringwald 8913deb3ec6SMatthias Ringwald /** 8926da84376SMilanka Ringwald * @brief Commit transactional write. GATT_EVENT_QUERY_COMPLETE is received. 8936da84376SMilanka Ringwald * @param callback 8946da84376SMilanka Ringwald * @param con_handle 89540faeb84SMilanka Ringwald * @return status 8963deb3ec6SMatthias Ringwald */ 897711e6c80SMatthias Ringwald uint8_t gatt_client_execute_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 8983deb3ec6SMatthias Ringwald 8993deb3ec6SMatthias Ringwald /** 9006da84376SMilanka Ringwald * @brief Abort transactional write. GATT_EVENT_QUERY_COMPLETE is received. 9016da84376SMilanka Ringwald * @param callback 9026da84376SMilanka Ringwald * @param con_handle 90340faeb84SMilanka Ringwald * @return status 9043deb3ec6SMatthias Ringwald */ 905711e6c80SMatthias Ringwald uint8_t gatt_client_cancel_write(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 9063deb3ec6SMatthias Ringwald 90759d34cd2SMatthias Ringwald /** 90853e9c18fSMatthias Ringwald * @brief Request callback when regular gatt query can be sent 90953e9c18fSMatthias Ringwald * @note callback might happen during call to this function 91053e9c18fSMatthias Ringwald * @param callback_registration to point to callback function and context information 91153e9c18fSMatthias Ringwald * @param con_handle 91253e9c18fSMatthias Ringwald * @return ERROR_CODE_SUCCESS if ok, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if handle unknown, and ERROR_CODE_COMMAND_DISALLOWED if callback already registered 91353e9c18fSMatthias Ringwald */ 91453e9c18fSMatthias Ringwald uint8_t gatt_client_request_to_send_gatt_query(btstack_context_callback_registration_t * callback_registration, hci_con_handle_t con_handle); 91553e9c18fSMatthias Ringwald 91653e9c18fSMatthias Ringwald /** 91759d34cd2SMatthias Ringwald * @brief Request callback when writing characteristic value without response is possible 91853e9c18fSMatthias Ringwald * @note callback might happen during call to this function 91959d34cd2SMatthias Ringwald * @param callback_registration to point to callback function and context information 92059d34cd2SMatthias Ringwald * @param con_handle 92159d34cd2SMatthias Ringwald * @return ERROR_CODE_SUCCESS if ok, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if handle unknown, and ERROR_CODE_COMMAND_DISALLOWED if callback already registered 92259d34cd2SMatthias Ringwald */ 92359d34cd2SMatthias Ringwald uint8_t gatt_client_request_to_write_without_response(btstack_context_callback_registration_t * callback_registration, hci_con_handle_t con_handle); 92459d34cd2SMatthias Ringwald 92559d34cd2SMatthias Ringwald 92659d34cd2SMatthias Ringwald // the following functions are marked as deprecated and will be removed eventually 92759d34cd2SMatthias Ringwald /** 92859d34cd2SMatthias Ringwald * @brief Requests GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE that guarantees 92959d34cd2SMatthias Ringwald * a single successful gatt_client_write_value_of_characteristic_without_response call. 93059d34cd2SMatthias Ringwald * @deprecated please use gatt_client_request_to_write_without_response instead 93159d34cd2SMatthias Ringwald * @param callback 93259d34cd2SMatthias Ringwald * @param con_handle 93359d34cd2SMatthias Ringwald * @return status 93459d34cd2SMatthias Ringwald */ 93559d34cd2SMatthias Ringwald uint8_t gatt_client_request_can_write_without_response_event(btstack_packet_handler_t callback, hci_con_handle_t con_handle); 93659d34cd2SMatthias Ringwald 93759d34cd2SMatthias Ringwald 9383deb3ec6SMatthias Ringwald /* API_END */ 9393deb3ec6SMatthias Ringwald 9406ba2ad22SMatthias Ringwald // used by generated btstack_event.c 9416ba2ad22SMatthias Ringwald 942313e337bSMatthias Ringwald void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t * service); 943313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic); 944313e337bSMatthias Ringwald void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor); 9456ba2ad22SMatthias Ringwald 946a6121b51SMilanka Ringwald #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 947a6121b51SMilanka Ringwald void gatt_client_att_packet_handler_fuzz(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size); 94840faeb84SMilanka Ringwald uint8_t gatt_client_get_client(hci_con_handle_t con_handle, gatt_client_t ** gatt_client); 949a6121b51SMilanka Ringwald #endif 950a6121b51SMilanka Ringwald 9513deb3ec6SMatthias Ringwald #if defined __cplusplus 9523deb3ec6SMatthias Ringwald } 9533deb3ec6SMatthias Ringwald #endif 9543deb3ec6SMatthias Ringwald 9553deb3ec6SMatthias Ringwald #endif 956