xref: /btstack/src/btstack_tlv.c (revision 853ebd39af751c69a8d6092b67b8e4810744e64b)
1*853ebd39SMatthias Ringwald /*
2*853ebd39SMatthias Ringwald  * Copyright (C) 2017 BlueKitchen GmbH
3*853ebd39SMatthias Ringwald  *
4*853ebd39SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5*853ebd39SMatthias Ringwald  * modification, are permitted provided that the following conditions
6*853ebd39SMatthias Ringwald  * are met:
7*853ebd39SMatthias Ringwald  *
8*853ebd39SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9*853ebd39SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10*853ebd39SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11*853ebd39SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12*853ebd39SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13*853ebd39SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14*853ebd39SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15*853ebd39SMatthias Ringwald  *    from this software without specific prior written permission.
16*853ebd39SMatthias Ringwald  *
17*853ebd39SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
18*853ebd39SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19*853ebd39SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20*853ebd39SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
21*853ebd39SMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22*853ebd39SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23*853ebd39SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24*853ebd39SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25*853ebd39SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26*853ebd39SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27*853ebd39SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28*853ebd39SMatthias Ringwald  * SUCH DAMAGE.
29*853ebd39SMatthias Ringwald  *
30*853ebd39SMatthias Ringwald  */
31*853ebd39SMatthias Ringwald 
32*853ebd39SMatthias Ringwald /*
33*853ebd39SMatthias Ringwald  *  btstack_tlv.c
34*853ebd39SMatthias Ringwald  *
35*853ebd39SMatthias Ringwald  *  Singleton for BTstack's Tag Value Length Persistent Storage implementation
36*853ebd39SMatthias Ringwald  */
37*853ebd39SMatthias Ringwald 
38*853ebd39SMatthias Ringwald #include "btstack_tlv.h"
39*853ebd39SMatthias Ringwald 
40*853ebd39SMatthias Ringwald static btstack_tlv_t * btstack_tlv_singleton_impl;
41*853ebd39SMatthias Ringwald static void * 		   btstack_tlv_singleton_context;
42*853ebd39SMatthias Ringwald 
43*853ebd39SMatthias Ringwald void btstack_tlv_set_instance(btstack_tlv_t * tlv_impl, void * tlv_context){
44*853ebd39SMatthias Ringwald 	btstack_tlv_singleton_impl 	  = tlv_impl;
45*853ebd39SMatthias Ringwald 	btstack_tlv_singleton_context = tlv_context;
46*853ebd39SMatthias Ringwald }
47*853ebd39SMatthias Ringwald 
48*853ebd39SMatthias Ringwald void btstack_tlv_get_instance(btstack_tlv_t ** tlv_impl, void ** tlv_context){
49*853ebd39SMatthias Ringwald 	*tlv_impl    = btstack_tlv_singleton_impl;
50*853ebd39SMatthias Ringwald 	*tlv_context = btstack_tlv_singleton_context;
51*853ebd39SMatthias Ringwald }
52