MAV'RIC
mavlink_message_handler.h
1 /*******************************************************************************
2  * Copyright (c) 2009-2014, MAV'RIC Development Team
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * \file mavlink_message_handler.h
34  *
35  * \author MAV'RIC Team
36  * \author Julien Lecoeur
37  *
38  * \brief This module handles of all incoming MAVLink message by calling the
39  * appropriate functions
40  *
41  ******************************************************************************/
42 
43 
44 #ifndef MAVLINK_MESSAGE_HANDLING_H_
45 #define MAVLINK_MESSAGE_HANDLING_H_
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 // #include "onboard_parameters.h"
52 #include "mavlink_stream.h"
53 
54 
55 #define MAV_SYS_ID_ALL 0
56 #define MAV_MSG_ENUM_END 255
57 
63 typedef void* handling_module_struct_t;
64 
69 typedef enum MAV_RESULT mav_result_t;
70 
74 typedef void (*mavlink_msg_callback_function_t) (handling_module_struct_t, uint32_t sysid, mavlink_message_t*);
75 
76 
80 typedef mav_result_t (*mavlink_cmd_callback_function_t) (handling_module_struct_t, mavlink_command_long_t*);
81 
82 
87 typedef enum MAV_COMPONENT mav_component_t;
88 
89 
93 typedef struct
94 {
95  const uint32_t* sys_id;
96  uint8_t message_id;
97  uint8_t sysid_filter;
98  mav_component_t compid_filter;
99  mavlink_msg_callback_function_t function;
100  handling_module_struct_t module_struct;
102 
103 
107 typedef struct
108 {
109  uint16_t command_id;
110  uint8_t sysid_filter;
111  mav_component_t compid_filter;
112  mav_component_t compid_target;
113  mavlink_cmd_callback_function_t function;
114  handling_module_struct_t module_struct;
116 
117 
124 typedef struct
125 {
126  uint32_t callback_count;
130 
131 
138 typedef struct
139 {
140  uint32_t callback_count;
144 
145 
152 typedef struct
153 {
156  bool debug;
157  const mavlink_stream_t* mavlink_stream;
159 
160 
164 typedef struct
165 {
168  bool debug;
170 
171 
181 bool mavlink_message_handler_init( mavlink_message_handler_t* message_handler,
182  const mavlink_message_handler_conf_t* config,
183  const mavlink_stream_t* mavlink_stream);
184 
185 
196 bool mavlink_message_handler_add_msg_callback( mavlink_message_handler_t* message_handler,
198 
199 
210 bool mavlink_message_handler_add_cmd_callback( mavlink_message_handler_t* message_handler,
212 
213 
220 void mavlink_message_handler_msg_default_dbg(mavlink_message_t* msg);
221 
222 
229 void mavlink_message_handler_cmd_default_dbg(mavlink_command_long_t* cmd);
230 
231 
238 void mavlink_message_handler_receive(mavlink_message_handler_t* message_handler, mavlink_received_t* rec);
239 
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 
245 #endif /* MAVLINK_MESSAGE_HANDLING_H */