xref: /btstack/src/btstack_tlv.h (revision d9f53676a5b1911619269e9d31f823cd6a3ac49d)
1*d9f53676SMatthias Ringwald /*
2*d9f53676SMatthias Ringwald  * Copyright (C) 2017 BlueKitchen GmbH
3*d9f53676SMatthias Ringwald  *
4*d9f53676SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5*d9f53676SMatthias Ringwald  * modification, are permitted provided that the following conditions
6*d9f53676SMatthias Ringwald  * are met:
7*d9f53676SMatthias Ringwald  *
8*d9f53676SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9*d9f53676SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10*d9f53676SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11*d9f53676SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12*d9f53676SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13*d9f53676SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14*d9f53676SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15*d9f53676SMatthias Ringwald  *    from this software without specific prior written permission.
16*d9f53676SMatthias Ringwald  *
17*d9f53676SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
18*d9f53676SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*d9f53676SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20*d9f53676SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
21*d9f53676SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22*d9f53676SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23*d9f53676SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24*d9f53676SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25*d9f53676SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26*d9f53676SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27*d9f53676SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28*d9f53676SMatthias Ringwald  * SUCH DAMAGE.
29*d9f53676SMatthias Ringwald  *
30*d9f53676SMatthias Ringwald  */
31*d9f53676SMatthias Ringwald 
32*d9f53676SMatthias Ringwald /*
33*d9f53676SMatthias Ringwald  *  btstack_tlv_.h
34*d9f53676SMatthias Ringwald  *
35*d9f53676SMatthias Ringwald  *  Inteface for BTstack's Tag Value Length Persistent Storage implementations
36*d9f53676SMatthias Ringwald  *  used to store pairing/bonding data
37*d9f53676SMatthias Ringwald  */
38*d9f53676SMatthias Ringwald 
39*d9f53676SMatthias Ringwald #ifndef __BTSTACK_TLV_H
40*d9f53676SMatthias Ringwald #define __BTSTACK_TLV_H
41*d9f53676SMatthias Ringwald 
42*d9f53676SMatthias Ringwald #include <stdint.h>
43*d9f53676SMatthias Ringwald 
44*d9f53676SMatthias Ringwald #if defined __cplusplus
45*d9f53676SMatthias Ringwald extern "C" {
46*d9f53676SMatthias Ringwald #endif
47*d9f53676SMatthias Ringwald 
48*d9f53676SMatthias Ringwald typedef struct {
49*d9f53676SMatthias Ringwald 
50*d9f53676SMatthias Ringwald 	/**
51*d9f53676SMatthias Ringwald 	 * Get Value for Tag
52*d9f53676SMatthias Ringwald 	 * @param context
53*d9f53676SMatthias Ringwald 	 * @param tag
54*d9f53676SMatthias Ringwald 	 * @param buffer
55*d9f53676SMatthias Ringwald 	 * @param buffer_size
56*d9f53676SMatthias Ringwald 	 * @returns size of value
57*d9f53676SMatthias Ringwald 	 */
58*d9f53676SMatthias Ringwald 	int (*get_tag)(void * context, uint32_t tag, uint8_t * buffer, uint32_t buffer_size);
59*d9f53676SMatthias Ringwald 
60*d9f53676SMatthias Ringwald 	/**
61*d9f53676SMatthias Ringwald 	 * Store Tag
62*d9f53676SMatthias Ringwald 	 * @param context
63*d9f53676SMatthias Ringwald 	 * @param tag
64*d9f53676SMatthias Ringwald 	 * @param data
65*d9f53676SMatthias Ringwald 	 * @param data_size
66*d9f53676SMatthias Ringwald 	 */
67*d9f53676SMatthias Ringwald 	void (*store_tag)(void * context, uint32_t tag, const uint8_t * data, uint32_t data_size);
68*d9f53676SMatthias Ringwald 
69*d9f53676SMatthias Ringwald 	/**
70*d9f53676SMatthias Ringwald 	 * Delete Tag
71*d9f53676SMatthias Ringwald 	 * @param context
72*d9f53676SMatthias Ringwald 	 * @param tag
73*d9f53676SMatthias Ringwald 	 */
74*d9f53676SMatthias Ringwald 	void (*delete_tag)(void * context,  uint32_t tag);
75*d9f53676SMatthias Ringwald 
76*d9f53676SMatthias Ringwald } btstack_tlv_t;
77*d9f53676SMatthias Ringwald 
78*d9f53676SMatthias Ringwald #if defined __cplusplus
79*d9f53676SMatthias Ringwald }
80*d9f53676SMatthias Ringwald #endif
81*d9f53676SMatthias Ringwald #endif // __BTSTACK_TLV_H
82