1591423b2SMatthias Ringwald /* 2591423b2SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 3591423b2SMatthias Ringwald * 4591423b2SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5591423b2SMatthias Ringwald * modification, are permitted provided that the following conditions 6591423b2SMatthias Ringwald * are met: 7591423b2SMatthias Ringwald * 8591423b2SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9591423b2SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10591423b2SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11591423b2SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12591423b2SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13591423b2SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14591423b2SMatthias Ringwald * contributors may be used to endorse or promote products derived 15591423b2SMatthias Ringwald * from this software without specific prior written permission. 16591423b2SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17591423b2SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18591423b2SMatthias Ringwald * monetary gain. 19591423b2SMatthias Ringwald * 20591423b2SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21591423b2SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22591423b2SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23591423b2SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24591423b2SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25591423b2SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26591423b2SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27591423b2SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28591423b2SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29591423b2SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30591423b2SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31591423b2SMatthias Ringwald * SUCH DAMAGE. 32591423b2SMatthias Ringwald * 33591423b2SMatthias Ringwald * Please inquire about commercial licensing options at 34591423b2SMatthias Ringwald * [email protected] 35591423b2SMatthias Ringwald * 36591423b2SMatthias Ringwald */ 37591423b2SMatthias Ringwald 38*fe5a6c4eSMilanka Ringwald /** 39*fe5a6c4eSMilanka Ringwald * @title ATT Database Engine 40*fe5a6c4eSMilanka Ringwald * 41*fe5a6c4eSMilanka Ringwald */ 42591423b2SMatthias Ringwald 4347a0820cSMatthias Ringwald #ifndef ATT_DB_H 4447a0820cSMatthias Ringwald #define ATT_DB_H 45591423b2SMatthias Ringwald 46591423b2SMatthias Ringwald #include <stdint.h> 47711e6c80SMatthias Ringwald #include "bluetooth.h" 488ac574d6SMatthias Ringwald #include "btstack_linked_list.h" 495d07396bSMatthias Ringwald #include "btstack_defines.h" 504d5915b3SMatthias Ringwald #include "btstack_bool.h" 51591423b2SMatthias Ringwald 52591423b2SMatthias Ringwald #if defined __cplusplus 53591423b2SMatthias Ringwald extern "C" { 54591423b2SMatthias Ringwald #endif 55591423b2SMatthias Ringwald 5609f91c9fSMatthias Ringwald // MARK: Attribute PDU Opcodes 5709f91c9fSMatthias Ringwald #define ATT_ERROR_RESPONSE 0x01 5809f91c9fSMatthias Ringwald 5909f91c9fSMatthias Ringwald #define ATT_EXCHANGE_MTU_REQUEST 0x02 6009f91c9fSMatthias Ringwald #define ATT_EXCHANGE_MTU_RESPONSE 0x03 6109f91c9fSMatthias Ringwald 6209f91c9fSMatthias Ringwald #define ATT_FIND_INFORMATION_REQUEST 0x04 6309f91c9fSMatthias Ringwald #define ATT_FIND_INFORMATION_REPLY 0x05 6409f91c9fSMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_REQUEST 0x06 6509f91c9fSMatthias Ringwald #define ATT_FIND_BY_TYPE_VALUE_RESPONSE 0x07 6609f91c9fSMatthias Ringwald 6709f91c9fSMatthias Ringwald #define ATT_READ_BY_TYPE_REQUEST 0x08 6809f91c9fSMatthias Ringwald #define ATT_READ_BY_TYPE_RESPONSE 0x09 6909f91c9fSMatthias Ringwald #define ATT_READ_REQUEST 0x0a 7009f91c9fSMatthias Ringwald #define ATT_READ_RESPONSE 0x0b 7109f91c9fSMatthias Ringwald #define ATT_READ_BLOB_REQUEST 0x0c 7209f91c9fSMatthias Ringwald #define ATT_READ_BLOB_RESPONSE 0x0d 7309f91c9fSMatthias Ringwald #define ATT_READ_MULTIPLE_REQUEST 0x0e 7409f91c9fSMatthias Ringwald #define ATT_READ_MULTIPLE_RESPONSE 0x0f 7509f91c9fSMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_REQUEST 0x10 7609f91c9fSMatthias Ringwald #define ATT_READ_BY_GROUP_TYPE_RESPONSE 0x11 7709f91c9fSMatthias Ringwald 7809f91c9fSMatthias Ringwald #define ATT_WRITE_REQUEST 0x12 7909f91c9fSMatthias Ringwald #define ATT_WRITE_RESPONSE 0x13 8009f91c9fSMatthias Ringwald 8109f91c9fSMatthias Ringwald #define ATT_PREPARE_WRITE_REQUEST 0x16 8209f91c9fSMatthias Ringwald #define ATT_PREPARE_WRITE_RESPONSE 0x17 8309f91c9fSMatthias Ringwald #define ATT_EXECUTE_WRITE_REQUEST 0x18 8409f91c9fSMatthias Ringwald #define ATT_EXECUTE_WRITE_RESPONSE 0x19 8509f91c9fSMatthias Ringwald 8609f91c9fSMatthias Ringwald #define ATT_HANDLE_VALUE_NOTIFICATION 0x1b 8709f91c9fSMatthias Ringwald #define ATT_HANDLE_VALUE_INDICATION 0x1d 8809f91c9fSMatthias Ringwald #define ATT_HANDLE_VALUE_CONFIRMATION 0x1e 8909f91c9fSMatthias Ringwald 906d6595cfSMatthias Ringwald #define ATT_READ_MULTIPLE_VARIABLE_REQ 0x20 916d6595cfSMatthias Ringwald #define ATT_READ_MULTIPLE_VARIABLE_RSP 0x21 926d6595cfSMatthias Ringwald #define ATT_MULTIPLE_HANDLE_VALUE_NTF 0x23 9309f91c9fSMatthias Ringwald 9409f91c9fSMatthias Ringwald #define ATT_WRITE_COMMAND 0x52 9509f91c9fSMatthias Ringwald #define ATT_SIGNED_WRITE_COMMAND 0xD2 9609f91c9fSMatthias Ringwald 970ff1f3d8SMatthias Ringwald // map ATT ERROR CODES on to att_read_callback length 980ff1f3d8SMatthias Ringwald #define ATT_READ_ERROR_CODE_OFFSET 0xfe00 990ff1f3d8SMatthias Ringwald 100beb20288SMatthias Ringwald // custom BTstack ATT Response Pending for att_read_callback 101e404a688SMatthias Ringwald #define ATT_READ_RESPONSE_PENDING 0xffff 102e404a688SMatthias Ringwald 10356c3a347SMatthias Ringwald // internally used to signal write response pending 10456c3a347SMatthias Ringwald #define ATT_INTERNAL_WRITE_RESPONSE_PENDING 0xfffe 10556c3a347SMatthias Ringwald 10609f91c9fSMatthias Ringwald // internal additions 10709f91c9fSMatthias Ringwald // 128 bit UUID used 10809f91c9fSMatthias Ringwald #define ATT_PROPERTY_UUID128 0x200 10909f91c9fSMatthias Ringwald // Read/Write Permission bits 11009f91c9fSMatthias Ringwald #define ATT_PROPERTY_READ_PERMISSION_BIT_0 0x0400 11109f91c9fSMatthias Ringwald #define ATT_PROPERTY_READ_PERMISSION_BIT_1 0x0800 11209f91c9fSMatthias Ringwald #define ATT_PROPERTY_WRITE_PERMISSION_BIT_0 0x0001 11309f91c9fSMatthias Ringwald #define ATT_PROPERTY_WRITE_PERMISSION_BIT_1 0x0010 11409f91c9fSMatthias Ringwald #define ATT_PROPERTY_READ_PERMISSION_SC 0x0020 11509f91c9fSMatthias Ringwald #define ATT_PROPERTY_WRITE_PERMISSION_SC 0x0080 11609f91c9fSMatthias Ringwald 11709f91c9fSMatthias Ringwald 118591423b2SMatthias Ringwald typedef struct att_connection { 119711e6c80SMatthias Ringwald hci_con_handle_t con_handle; 120591423b2SMatthias Ringwald uint16_t mtu; // initialized to ATT_DEFAULT_MTU (23), negotiated during MTU exchange 121591423b2SMatthias Ringwald uint16_t max_mtu; // local maximal L2CAP_MTU, set to l2cap_max_le_mtu() 122dde9ff1eSMatthias Ringwald bool mtu_exchanged; 123591423b2SMatthias Ringwald uint8_t encryption_key_size; 124591423b2SMatthias Ringwald uint8_t authenticated; 125591423b2SMatthias Ringwald uint8_t authorized; 12613eb7322SMatthias Ringwald uint8_t secure_connection; 127591423b2SMatthias Ringwald } att_connection_t; 128591423b2SMatthias Ringwald 129591423b2SMatthias Ringwald // ATT Client Read Callback for Dynamic Data 130591423b2SMatthias Ringwald // - if buffer == NULL, don't copy data, just return size of value 131591423b2SMatthias Ringwald // - if buffer != NULL, copy data and return number bytes copied 132e404a688SMatthias Ringwald // If ENABLE_ATT_DELAYED_READ_RESPONSE is defined, you may return ATT_READ_RESPONSE_PENDING if data isn't available yet 133591423b2SMatthias Ringwald // @param con_handle of hci le connection 134591423b2SMatthias Ringwald // @param attribute_handle to be read 135591423b2SMatthias Ringwald // @param offset defines start of attribute value 136591423b2SMatthias Ringwald // @param buffer 137591423b2SMatthias Ringwald // @param buffer_size 138711e6c80SMatthias Ringwald typedef uint16_t (*att_read_callback_t)(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size); 139591423b2SMatthias Ringwald 140591423b2SMatthias Ringwald // ATT Client Write Callback for Dynamic Data 141591423b2SMatthias Ringwald // @param con_handle of hci le connection 142591423b2SMatthias Ringwald // @param attribute_handle to be written 1439b31df63SMatthias Ringwald // @param transaction - ATT_TRANSACTION_MODE_NONE for regular writes. For prepared writes: ATT_TRANSACTION_MODE_ACTIVE, ATT_TRANSACTION_MODE_VALIDATE, ATT_TRANSACTION_MODE_EXECUTE, ATT_TRANSACTION_MODE_CANCEL 144591423b2SMatthias Ringwald // @param offset into the value - used for queued writes and long attributes 145591423b2SMatthias Ringwald // @param buffer 146591423b2SMatthias Ringwald // @param buffer_size 147591423b2SMatthias Ringwald // @param signature used for signed write commmands 148591423b2SMatthias Ringwald // @returns 0 if write was ok, ATT_ERROR_PREPARE_QUEUE_FULL if no space in queue, ATT_ERROR_INVALID_OFFSET if offset is larger than max buffer 1499b31df63SMatthias Ringwald // 1509b31df63SMatthias Ringwald // Each Prepared Write Request triggers a callback with transaction mode ATT_TRANSACTION_MODE_ACTIVE. 1519b31df63SMatthias Ringwald // On Execute Write, the callback will be called with ATT_TRANSACTION_MODE_VALIDATE and allows to validate all queued writes and return an application error. 1529b31df63SMatthias Ringwald // If none of the registered callbacks return an error for ATT_TRANSACTION_MODE_VALIDATE and the callback will be called with ATT_TRANSACTION_MODE_EXECUTE. 1539b31df63SMatthias Ringwald // Otherwise, all callbacks will be called with ATT_TRANSACTION_MODE_CANCEL. 1549b31df63SMatthias Ringwald // 1559b31df63SMatthias Ringwald // If the additional validation step is not needed, just return 0 for all callbacks with transaction mode ATT_TRANSACTION_MODE_VALIDATE. 1569b31df63SMatthias Ringwald // 157711e6c80SMatthias Ringwald typedef int (*att_write_callback_t)(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size); 158591423b2SMatthias Ringwald 1598ac574d6SMatthias Ringwald // Read & Write Callbacks for handle range 1608ac574d6SMatthias Ringwald typedef struct att_service_handler { 1618ac574d6SMatthias Ringwald btstack_linked_item_t * item; 1628ac574d6SMatthias Ringwald uint16_t start_handle; 1638ac574d6SMatthias Ringwald uint16_t end_handle; 1648ac574d6SMatthias Ringwald att_read_callback_t read_callback; 1658ac574d6SMatthias Ringwald att_write_callback_t write_callback; 1665d07396bSMatthias Ringwald btstack_packet_handler_t packet_handler; 1678ac574d6SMatthias Ringwald } att_service_handler_t; 1688ac574d6SMatthias Ringwald 169591423b2SMatthias Ringwald // MARK: ATT Operations 170591423b2SMatthias Ringwald 171591423b2SMatthias Ringwald /* 172591423b2SMatthias Ringwald * @brief setup ATT database 173591423b2SMatthias Ringwald */ 174591423b2SMatthias Ringwald void att_set_db(uint8_t const * db); 175591423b2SMatthias Ringwald 176591423b2SMatthias Ringwald /* 177591423b2SMatthias Ringwald * @brief set callback for read of dynamic attributes 178591423b2SMatthias Ringwald * @param callback 179591423b2SMatthias Ringwald */ 180591423b2SMatthias Ringwald void att_set_read_callback(att_read_callback_t callback); 181591423b2SMatthias Ringwald 182591423b2SMatthias Ringwald /* 183591423b2SMatthias Ringwald * @brief set callback for write of dynamic attributes 184591423b2SMatthias Ringwald * @param callback 185591423b2SMatthias Ringwald */ 186591423b2SMatthias Ringwald void att_set_write_callback(att_write_callback_t callback); 187591423b2SMatthias Ringwald 188591423b2SMatthias Ringwald /* 189591423b2SMatthias Ringwald * @brief debug helper, dump ATT database to stdout using log_info 190591423b2SMatthias Ringwald */ 191591423b2SMatthias Ringwald void att_dump_attributes(void); 192591423b2SMatthias Ringwald 193591423b2SMatthias Ringwald /* 194591423b2SMatthias Ringwald * @brief process ATT request against database and put response into response buffer 195591423b2SMatthias Ringwald * @param att_connection used for mtu and security properties 196591423b2SMatthias Ringwald * @param request_buffer, request_len: ATT request from clinet 197591423b2SMatthias Ringwald * @param response_buffer for result 198e404a688SMatthias Ringwald * @returns len of data in response buffer. 0 = no response, 199e404a688SMatthias Ringwald * ATT_READ_RESPONSE_PENDING if it was returned at least once for dynamic data (requires ENABLE_ATT_DELAYED_READ_RESPONSE) 200591423b2SMatthias Ringwald */ 201591423b2SMatthias Ringwald uint16_t att_handle_request(att_connection_t * att_connection, 202591423b2SMatthias Ringwald uint8_t * request_buffer, 203591423b2SMatthias Ringwald uint16_t request_len, 204591423b2SMatthias Ringwald uint8_t * response_buffer); 205591423b2SMatthias Ringwald 206591423b2SMatthias Ringwald /* 207591423b2SMatthias Ringwald * @brief setup value notification in response buffer for a given handle and value 208591423b2SMatthias Ringwald * @param att_connection 209fc64f94aSMatthias Ringwald * @param attribute_handle 210fc64f94aSMatthias Ringwald * @param value 211fc64f94aSMatthias Ringwald * @param value_len 212591423b2SMatthias Ringwald * @param response_buffer for notification 213591423b2SMatthias Ringwald */ 214591423b2SMatthias Ringwald uint16_t att_prepare_handle_value_notification(att_connection_t * att_connection, 215fc64f94aSMatthias Ringwald uint16_t attribute_handle, 2163bb3035fSMilanka Ringwald const uint8_t *value, 217591423b2SMatthias Ringwald uint16_t value_len, 218591423b2SMatthias Ringwald uint8_t * response_buffer); 219591423b2SMatthias Ringwald 220591423b2SMatthias Ringwald /* 221591423b2SMatthias Ringwald * @brief setup value indication in response buffer for a given handle and value 222591423b2SMatthias Ringwald * @param att_connection 223fc64f94aSMatthias Ringwald * @param attribute_handle 224fc64f94aSMatthias Ringwald * @param value 225fc64f94aSMatthias Ringwald * @param value_len 226591423b2SMatthias Ringwald * @param response_buffer for indication 227591423b2SMatthias Ringwald */ 228591423b2SMatthias Ringwald uint16_t att_prepare_handle_value_indication(att_connection_t * att_connection, 229fc64f94aSMatthias Ringwald uint16_t attribute_handle, 2303bb3035fSMilanka Ringwald const uint8_t *value, 231591423b2SMatthias Ringwald uint16_t value_len, 232591423b2SMatthias Ringwald uint8_t * response_buffer); 233591423b2SMatthias Ringwald 234591423b2SMatthias Ringwald /* 235591423b2SMatthias Ringwald * @brief transcation queue of prepared writes, e.g., after disconnect 236591423b2SMatthias Ringwald */ 237591423b2SMatthias Ringwald void att_clear_transaction_queue(att_connection_t * att_connection); 238591423b2SMatthias Ringwald 239bfd413f0SMatthias Ringwald // att_read_callback helpers for a various data types 240bfd413f0SMatthias Ringwald 241bfd413f0SMatthias Ringwald /* 242bfd413f0SMatthias Ringwald * @brief Handle read of blob like data for att_read_callback 243bfd413f0SMatthias Ringwald * @param blob of data 244bfd413f0SMatthias Ringwald * @param blob_size of blob 245bfd413f0SMatthias Ringwald * @param offset from att_read_callback 246bfd413f0SMatthias Ringwald * @param buffer from att_read_callback 247bfd413f0SMatthias Ringwald * @param buffer_size from att_read_callback 248bfd413f0SMatthias Ringwald * @returns value size for buffer == 0 and num bytes copied otherwise 249bfd413f0SMatthias Ringwald */ 250bfd413f0SMatthias Ringwald uint16_t att_read_callback_handle_blob(const uint8_t * blob, uint16_t blob_size, uint16_t offset, uint8_t * buffer, uint16_t buffer_size); 251bfd413f0SMatthias Ringwald 252bfd413f0SMatthias Ringwald /* 253bfd413f0SMatthias Ringwald * @brief Handle read of little endian unsigned 32 bit value for att_read_callback 254bfd413f0SMatthias Ringwald * @param value 255bfd413f0SMatthias Ringwald * @param offset from att_read_callback 256bfd413f0SMatthias Ringwald * @param buffer from att_read_callback 257bfd413f0SMatthias Ringwald * @param buffer_size from att_read_callback 258bfd413f0SMatthias Ringwald * @returns value size for buffer == 0 and num bytes copied otherwise 259bfd413f0SMatthias Ringwald */ 260bfd413f0SMatthias Ringwald uint16_t att_read_callback_handle_little_endian_32(uint32_t value, uint16_t offset, uint8_t * buffer, uint16_t buffer_size); 261bfd413f0SMatthias Ringwald 262bfd413f0SMatthias Ringwald /* 263bfd413f0SMatthias Ringwald * @brief Handle read of little endian unsigned 16 bit value for att_read_callback 264bfd413f0SMatthias Ringwald * @param value 265bfd413f0SMatthias Ringwald * @param offset from att_read_callback 266bfd413f0SMatthias Ringwald * @param buffer from att_read_callback 267bfd413f0SMatthias Ringwald * @param buffer_size from att_read_callback 268bfd413f0SMatthias Ringwald * @returns value size for buffer == 0 and num bytes copied otherwise 269bfd413f0SMatthias Ringwald */ 270bfd413f0SMatthias Ringwald uint16_t att_read_callback_handle_little_endian_16(uint16_t value, uint16_t offset, uint8_t * buffer, uint16_t buffer_size); 271bfd413f0SMatthias Ringwald 272bfd413f0SMatthias Ringwald /* 273bfd413f0SMatthias Ringwald * @brief Handle read of single byte for att_read_callback 274bfd413f0SMatthias Ringwald * @param blob of data 275bfd413f0SMatthias Ringwald * @param blob_size of blob 276bfd413f0SMatthias Ringwald * @param offset from att_read_callback 277bfd413f0SMatthias Ringwald * @param buffer from att_read_callback 278bfd413f0SMatthias Ringwald * @param buffer_size from att_read_callback 279bfd413f0SMatthias Ringwald * @returns value size for buffer == 0 and num bytes copied otherwise 280bfd413f0SMatthias Ringwald */ 281bfd413f0SMatthias Ringwald uint16_t att_read_callback_handle_byte(uint8_t value, uint16_t offset, uint8_t * buffer, uint16_t buffer_size); 282bfd413f0SMatthias Ringwald 283bfd413f0SMatthias Ringwald 284591423b2SMatthias Ringwald // experimental client API 285fc64f94aSMatthias Ringwald uint16_t att_uuid_for_handle(uint16_t attribute_handle); 286591423b2SMatthias Ringwald 287660ce368SMatthias Ringwald 288660ce368SMatthias Ringwald // experimental GATT Server API 289660ce368SMatthias Ringwald 2904d5915b3SMatthias Ringwald // returns true if service found. only primary service. 2914d5915b3SMatthias Ringwald bool gatt_server_get_get_handle_range_for_service_with_uuid16(uint16_t uuid16, uint16_t * start_handle, uint16_t * end_handle); 292660ce368SMatthias Ringwald 293660ce368SMatthias Ringwald // returns 0 if not found 294660ce368SMatthias Ringwald uint16_t gatt_server_get_value_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t uuid16); 295660ce368SMatthias Ringwald 296660ce368SMatthias Ringwald // returns 0 if not found 297c7774db7SMilanka Ringwald uint16_t gatt_server_get_descriptor_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t characteristic_uuid16, uint16_t descriptor_uuid16); 298c7774db7SMilanka Ringwald uint16_t gatt_server_get_client_configuration_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t characteristic_uuid16); 299c7774db7SMilanka Ringwald uint16_t gatt_server_get_server_configuration_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t characteristic_uuid16); 300660ce368SMatthias Ringwald 30115f22304SMatthias Ringwald 30215f22304SMatthias Ringwald // returns 1 if service found. only primary service. 30315f22304SMatthias Ringwald int gatt_server_get_get_handle_range_for_service_with_uuid128(const uint8_t * uuid128, uint16_t * start_handle, uint16_t * end_handle); 30415f22304SMatthias Ringwald 30515f22304SMatthias Ringwald // returns 0 if not found 30615f22304SMatthias Ringwald uint16_t gatt_server_get_value_handle_for_characteristic_with_uuid128(uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128); 30715f22304SMatthias Ringwald 30815f22304SMatthias Ringwald // returns 0 if not found 30915f22304SMatthias Ringwald uint16_t gatt_server_get_client_configuration_handle_for_characteristic_with_uuid128(uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128); 31015f22304SMatthias Ringwald 3118b1d64c6SMatthias Ringwald // non-user functionality for att_server 3128b1d64c6SMatthias Ringwald 3138b1d64c6SMatthias Ringwald /* 3148b1d64c6SMatthias Ringwald * @brief Check if writes to handle should be persistent 3158b1d64c6SMatthias Ringwald * @param handle 3168b1d64c6SMatthias Ringwald * @returns 1 if persistent 3178b1d64c6SMatthias Ringwald */ 3184d5915b3SMatthias Ringwald bool att_is_persistent_ccc(uint16_t handle); 3198b1d64c6SMatthias Ringwald 32044127f43SMatthias Ringwald // auto-pts testing, returns response size 32144127f43SMatthias Ringwald #ifdef ENABLE_BTP 32244127f43SMatthias Ringwald uint16_t btp_att_get_attributes_by_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t uuid16, uint8_t * response_buffer, uint16_t response_buffer_size); 32344127f43SMatthias Ringwald uint16_t btp_att_get_attributes_by_uuid128(uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128, uint8_t * response_buffer, uint16_t response_buffer_size); 3246de29f25SMatthias Ringwald uint16_t btp_att_get_attribute_value(att_connection_t * att_connection, uint16_t attribute_handle, uint8_t * response_buffer, uint16_t response_buffer_size); 32544127f43SMatthias Ringwald #endif 3268b1d64c6SMatthias Ringwald 327591423b2SMatthias Ringwald #if defined __cplusplus 328591423b2SMatthias Ringwald } 329591423b2SMatthias Ringwald #endif 330591423b2SMatthias Ringwald 33180e33422SMatthias Ringwald #endif // ATT_H 332