xref: /btstack/src/btstack_slip.h (revision ab67bfbb5af443d3b854a8f4f0d060783f448aff)
1*ab67bfbbSMatthias Ringwald /*
2*ab67bfbbSMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
3*ab67bfbbSMatthias Ringwald  *
4*ab67bfbbSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5*ab67bfbbSMatthias Ringwald  * modification, are permitted provided that the following conditions
6*ab67bfbbSMatthias Ringwald  * are met:
7*ab67bfbbSMatthias Ringwald  *
8*ab67bfbbSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9*ab67bfbbSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10*ab67bfbbSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11*ab67bfbbSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12*ab67bfbbSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13*ab67bfbbSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14*ab67bfbbSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15*ab67bfbbSMatthias Ringwald  *    from this software without specific prior written permission.
16*ab67bfbbSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17*ab67bfbbSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18*ab67bfbbSMatthias Ringwald  *    monetary gain.
19*ab67bfbbSMatthias Ringwald  *
20*ab67bfbbSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21*ab67bfbbSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*ab67bfbbSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*ab67bfbbSMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24*ab67bfbbSMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25*ab67bfbbSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26*ab67bfbbSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27*ab67bfbbSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28*ab67bfbbSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29*ab67bfbbSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30*ab67bfbbSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*ab67bfbbSMatthias Ringwald  * SUCH DAMAGE.
32*ab67bfbbSMatthias Ringwald  *
33*ab67bfbbSMatthias Ringwald  * Please inquire about commercial licensing options at
34*ab67bfbbSMatthias Ringwald  * [email protected]
35*ab67bfbbSMatthias Ringwald  *
36*ab67bfbbSMatthias Ringwald  */
37*ab67bfbbSMatthias Ringwald 
38*ab67bfbbSMatthias Ringwald /*
39*ab67bfbbSMatthias Ringwald  *  btstack_slip.h
40*ab67bfbbSMatthias Ringwald  *  SLIP encoder/decoder
41*ab67bfbbSMatthias Ringwald  */
42*ab67bfbbSMatthias Ringwald 
43*ab67bfbbSMatthias Ringwald #ifndef __BTSTACK_SLIP_H
44*ab67bfbbSMatthias Ringwald #define __BTSTACK_SLIP_H
45*ab67bfbbSMatthias Ringwald 
46*ab67bfbbSMatthias Ringwald #include <stdint.h>
47*ab67bfbbSMatthias Ringwald 
48*ab67bfbbSMatthias Ringwald #if defined __cplusplus
49*ab67bfbbSMatthias Ringwald extern "C" {
50*ab67bfbbSMatthias Ringwald #endif
51*ab67bfbbSMatthias Ringwald 
52*ab67bfbbSMatthias Ringwald #define BTSTACK_SLIP_SOF 0xc0
53*ab67bfbbSMatthias Ringwald 
54*ab67bfbbSMatthias Ringwald // ENCODER
55*ab67bfbbSMatthias Ringwald 
56*ab67bfbbSMatthias Ringwald /**
57*ab67bfbbSMatthias Ringwald  * @brief Initialise SLIP encoder with data
58*ab67bfbbSMatthias Ringwald  * @param data
59*ab67bfbbSMatthias Ringwald  * @param len
60*ab67bfbbSMatthias Ringwald  */
61*ab67bfbbSMatthias Ringwald void btstack_slip_encoder_start(const uint8_t * data, uint16_t len);
62*ab67bfbbSMatthias Ringwald 
63*ab67bfbbSMatthias Ringwald /**
64*ab67bfbbSMatthias Ringwald  * @brief Check if encoder has data ready
65*ab67bfbbSMatthias Ringwald  * @return True if data ready
66*ab67bfbbSMatthias Ringwald  */
67*ab67bfbbSMatthias Ringwald int  btstack_slip_encoder_has_data(void);
68*ab67bfbbSMatthias Ringwald 
69*ab67bfbbSMatthias Ringwald /**
70*ab67bfbbSMatthias Ringwald  * @brief Get next byte from encoder
71*ab67bfbbSMatthias Ringwald  * @return Next bytes from encoder
72*ab67bfbbSMatthias Ringwald  */
73*ab67bfbbSMatthias Ringwald uint8_t btstack_slip_encoder_get_byte(void);
74*ab67bfbbSMatthias Ringwald 
75*ab67bfbbSMatthias Ringwald #if defined __cplusplus
76*ab67bfbbSMatthias Ringwald }
77*ab67bfbbSMatthias Ringwald #endif
78*ab67bfbbSMatthias Ringwald 
79*ab67bfbbSMatthias Ringwald #endif
80