OLE Developer Guide  Latest Git
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
stream_decoder.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * stream_decoder.h
17  * Copyright (C) 2015 Simon Newton
18  */
19 
30 #ifndef FIRMWARE_SRC_STREAM_DECODER_H_
31 #define FIRMWARE_SRC_STREAM_DECODER_H_
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include <stdint.h>
38 #include <stdbool.h>
39 
43 typedef struct {
44  uint8_t token;
45  uint16_t command;
46  uint16_t length;
47  const uint8_t* payload;
48 } Message;
49 
50 
55 typedef void (*MessageHandler)(const Message*);
56 
57 
66 
74 
79 
88 void StreamDecoder_Process(const uint8_t* data, unsigned int size);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif // FIRMWARE_SRC_STREAM_DECODER_H_
95 
uint8_t token
The token associated with this message.
Definition: stream_decoder.h:44
void StreamDecoder_ClearFragmentedFrameFlag()
Clear the fragmented frame flag.
void(* MessageHandler)(const Message *)
A function pointer used to handle new messages.
Definition: stream_decoder.h:55
void StreamDecoder_Initialize(MessageHandler handler)
Initialize the Stream Decoder.
A de-serialized message.
Definition: message.h:39
bool StreamDecoder_GetFragmentedFrameFlag()
Get the value of the fragmented frame flag.
void StreamDecoder_Process(const uint8_t *data, unsigned int size)
Decode data from an input stream.