1d9f53676SMatthias Ringwald /* 2d9f53676SMatthias Ringwald * Copyright (C) 2017 BlueKitchen GmbH 3d9f53676SMatthias Ringwald * 4d9f53676SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5d9f53676SMatthias Ringwald * modification, are permitted provided that the following conditions 6d9f53676SMatthias Ringwald * are met: 7d9f53676SMatthias Ringwald * 8d9f53676SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9d9f53676SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10d9f53676SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11d9f53676SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12d9f53676SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13d9f53676SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14d9f53676SMatthias Ringwald * contributors may be used to endorse or promote products derived 15d9f53676SMatthias Ringwald * from this software without specific prior written permission. 16d9f53676SMatthias Ringwald * 17*2fca4dadSMilanka Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 18d9f53676SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19d9f53676SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 21*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22d9f53676SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23d9f53676SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 24d9f53676SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25d9f53676SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26d9f53676SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 27d9f53676SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28d9f53676SMatthias Ringwald * SUCH DAMAGE. 29d9f53676SMatthias Ringwald * 30d9f53676SMatthias Ringwald */ 31d9f53676SMatthias Ringwald 32fe5a6c4eSMilanka Ringwald /** 33fe5a6c4eSMilanka Ringwald * @title Tag-Value-Length Persistent Storage (TLV) 34d9f53676SMatthias Ringwald * 35d9f53676SMatthias Ringwald * Inteface for BTstack's Tag Value Length Persistent Storage implementations 36fe5a6c4eSMilanka Ringwald * used to store pairing/bonding data. 37fe5a6c4eSMilanka Ringwald * 38d9f53676SMatthias Ringwald */ 39d9f53676SMatthias Ringwald 4080e33422SMatthias Ringwald #ifndef BTSTACK_TLV_H 4180e33422SMatthias Ringwald #define BTSTACK_TLV_H 42d9f53676SMatthias Ringwald 43d9f53676SMatthias Ringwald #include <stdint.h> 44d9f53676SMatthias Ringwald 45d9f53676SMatthias Ringwald #if defined __cplusplus 46d9f53676SMatthias Ringwald extern "C" { 47d9f53676SMatthias Ringwald #endif 48d9f53676SMatthias Ringwald 49fe5a6c4eSMilanka Ringwald /* API_START */ 50fe5a6c4eSMilanka Ringwald 51d9f53676SMatthias Ringwald typedef struct { 52d9f53676SMatthias Ringwald 53d9f53676SMatthias Ringwald /** 54d9f53676SMatthias Ringwald * Get Value for Tag 55d9f53676SMatthias Ringwald * @param context 56d9f53676SMatthias Ringwald * @param tag 57d9f53676SMatthias Ringwald * @param buffer 58d9f53676SMatthias Ringwald * @param buffer_size 596b65794dSMilanka Ringwald * @return size of value 60d9f53676SMatthias Ringwald */ 61d9f53676SMatthias Ringwald int (*get_tag)(void * context, uint32_t tag, uint8_t * buffer, uint32_t buffer_size); 62d9f53676SMatthias Ringwald 63d9f53676SMatthias Ringwald /** 64d9f53676SMatthias Ringwald * Store Tag 65d9f53676SMatthias Ringwald * @param context 66d9f53676SMatthias Ringwald * @param tag 67d9f53676SMatthias Ringwald * @param data 68d9f53676SMatthias Ringwald * @param data_size 696b65794dSMilanka Ringwald * @return 0 on success 70d9f53676SMatthias Ringwald */ 71c7f4b25fSMatthias Ringwald int (*store_tag)(void * context, uint32_t tag, const uint8_t * data, uint32_t data_size); 72d9f53676SMatthias Ringwald 73d9f53676SMatthias Ringwald /** 74d9f53676SMatthias Ringwald * Delete Tag 750fe46bc1SMatthias Ringwald * @note it is not expected that delete operation fails, please use at least log_error in case of errors 76d9f53676SMatthias Ringwald * @param context 77d9f53676SMatthias Ringwald * @param tag 78d9f53676SMatthias Ringwald */ 79d9f53676SMatthias Ringwald void (*delete_tag)(void * context, uint32_t tag); 80d9f53676SMatthias Ringwald 81d9f53676SMatthias Ringwald } btstack_tlv_t; 82d9f53676SMatthias Ringwald 83853ebd39SMatthias Ringwald /** 84853ebd39SMatthias Ringwald * @brief Make TLV implementation available to BTstack components via Singleton 85853ebd39SMatthias Ringwald * @note Usually called by port after BD_ADDR was retrieved from Bluetooth Controller 86853ebd39SMatthias Ringwald * @param tlv_impl 87853ebd39SMatthias Ringwald * @param tlv_context 88853ebd39SMatthias Ringwald */ 89661f177dSMatthias Ringwald void btstack_tlv_set_instance(const btstack_tlv_t * tlv_impl, void * tlv_context); 90853ebd39SMatthias Ringwald 91853ebd39SMatthias Ringwald /** 92853ebd39SMatthias Ringwald * @brief Get current TLV implementation. Used for bonding information, but can be used by application, too. 93853ebd39SMatthias Ringwald * @param tlv_impl 94853ebd39SMatthias Ringwald * @param tlv_context 95853ebd39SMatthias Ringwald */ 96661f177dSMatthias Ringwald void btstack_tlv_get_instance(const btstack_tlv_t ** tlv_impl, void ** tlv_context); 97853ebd39SMatthias Ringwald 98fe5a6c4eSMilanka Ringwald /* API_END */ 99fe5a6c4eSMilanka Ringwald 100d9f53676SMatthias Ringwald #if defined __cplusplus 101d9f53676SMatthias Ringwald } 102d9f53676SMatthias Ringwald #endif 10380e33422SMatthias Ringwald #endif // BTSTACK_TLV_H 104