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 * 17d9f53676SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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 20d9f53676SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 21d9f53676SMatthias Ringwald * RINGWALD 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 32d9f53676SMatthias Ringwald /* 33d9f53676SMatthias Ringwald * btstack_tlv_.h 34d9f53676SMatthias Ringwald * 35d9f53676SMatthias Ringwald * Inteface for BTstack's Tag Value Length Persistent Storage implementations 36d9f53676SMatthias Ringwald * used to store pairing/bonding data 37d9f53676SMatthias Ringwald */ 38d9f53676SMatthias Ringwald 39*80e33422SMatthias Ringwald #ifndef BTSTACK_TLV_H 40*80e33422SMatthias Ringwald #define BTSTACK_TLV_H 41d9f53676SMatthias Ringwald 42d9f53676SMatthias Ringwald #include <stdint.h> 43d9f53676SMatthias Ringwald 44d9f53676SMatthias Ringwald #if defined __cplusplus 45d9f53676SMatthias Ringwald extern "C" { 46d9f53676SMatthias Ringwald #endif 47d9f53676SMatthias Ringwald 48d9f53676SMatthias Ringwald typedef struct { 49d9f53676SMatthias Ringwald 50d9f53676SMatthias Ringwald /** 51d9f53676SMatthias Ringwald * Get Value for Tag 52d9f53676SMatthias Ringwald * @param context 53d9f53676SMatthias Ringwald * @param tag 54d9f53676SMatthias Ringwald * @param buffer 55d9f53676SMatthias Ringwald * @param buffer_size 56d9f53676SMatthias Ringwald * @returns size of value 57d9f53676SMatthias Ringwald */ 58d9f53676SMatthias Ringwald int (*get_tag)(void * context, uint32_t tag, uint8_t * buffer, uint32_t buffer_size); 59d9f53676SMatthias Ringwald 60d9f53676SMatthias Ringwald /** 61d9f53676SMatthias Ringwald * Store Tag 62d9f53676SMatthias Ringwald * @param context 63d9f53676SMatthias Ringwald * @param tag 64d9f53676SMatthias Ringwald * @param data 65d9f53676SMatthias Ringwald * @param data_size 66c7f4b25fSMatthias Ringwald * @returns 0 on success 67d9f53676SMatthias Ringwald */ 68c7f4b25fSMatthias Ringwald int (*store_tag)(void * context, uint32_t tag, const uint8_t * data, uint32_t data_size); 69d9f53676SMatthias Ringwald 70d9f53676SMatthias Ringwald /** 71d9f53676SMatthias Ringwald * Delete Tag 72d9f53676SMatthias Ringwald * @param context 73d9f53676SMatthias Ringwald * @param tag 74d9f53676SMatthias Ringwald */ 75d9f53676SMatthias Ringwald void (*delete_tag)(void * context, uint32_t tag); 76d9f53676SMatthias Ringwald 77d9f53676SMatthias Ringwald } btstack_tlv_t; 78d9f53676SMatthias Ringwald 79853ebd39SMatthias Ringwald /** 80853ebd39SMatthias Ringwald * @brief Make TLV implementation available to BTstack components via Singleton 81853ebd39SMatthias Ringwald * @note Usually called by port after BD_ADDR was retrieved from Bluetooth Controller 82853ebd39SMatthias Ringwald * @param tlv_impl 83853ebd39SMatthias Ringwald * @param tlv_context 84853ebd39SMatthias Ringwald */ 85661f177dSMatthias Ringwald void btstack_tlv_set_instance(const btstack_tlv_t * tlv_impl, void * tlv_context); 86853ebd39SMatthias Ringwald 87853ebd39SMatthias Ringwald /** 88853ebd39SMatthias Ringwald * @brief Get current TLV implementation. Used for bonding information, but can be used by application, too. 89853ebd39SMatthias Ringwald * @param tlv_impl 90853ebd39SMatthias Ringwald * @param tlv_context 91853ebd39SMatthias Ringwald */ 92661f177dSMatthias Ringwald void btstack_tlv_get_instance(const btstack_tlv_t ** tlv_impl, void ** tlv_context); 93853ebd39SMatthias Ringwald 94d9f53676SMatthias Ringwald #if defined __cplusplus 95d9f53676SMatthias Ringwald } 96d9f53676SMatthias Ringwald #endif 97*80e33422SMatthias Ringwald #endif // BTSTACK_TLV_H 98