Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_setup_signing.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE SETUP_SIGNING PACKING
3
4#define MAVLINK_MSG_ID_SETUP_SIGNING 256
5
6
8 uint64_t initial_timestamp; /*< initial timestamp*/
9 uint8_t target_system; /*< system id of the target*/
10 uint8_t target_component; /*< component ID of the target*/
11 uint8_t secret_key[32]; /*< signing key*/
12} mavlink_setup_signing_t;
13
14#define MAVLINK_MSG_ID_SETUP_SIGNING_LEN 42
15#define MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN 42
16#define MAVLINK_MSG_ID_256_LEN 42
17#define MAVLINK_MSG_ID_256_MIN_LEN 42
18
19#define MAVLINK_MSG_ID_SETUP_SIGNING_CRC 71
20#define MAVLINK_MSG_ID_256_CRC 71
21
22#define MAVLINK_MSG_SETUP_SIGNING_FIELD_SECRET_KEY_LEN 32
23
24#if MAVLINK_COMMAND_24BIT
25#define MAVLINK_MESSAGE_INFO_SETUP_SIGNING {
26 256,
27 "SETUP_SIGNING",
28 4,
29 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_setup_signing_t, target_system) },
30 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_setup_signing_t, target_component) },
31 { "secret_key", NULL, MAVLINK_TYPE_UINT8_T, 32, 10, offsetof(mavlink_setup_signing_t, secret_key) },
32 { "initial_timestamp", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_setup_signing_t, initial_timestamp) },
33 } \
34}
35#else
36#define MAVLINK_MESSAGE_INFO_SETUP_SIGNING {
37 "SETUP_SIGNING",
38 4,
39 { { "target_system", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_setup_signing_t, target_system) },
40 { "target_component", NULL, MAVLINK_TYPE_UINT8_T, 0, 9, offsetof(mavlink_setup_signing_t, target_component) },
41 { "secret_key", NULL, MAVLINK_TYPE_UINT8_T, 32, 10, offsetof(mavlink_setup_signing_t, secret_key) },
42 { "initial_timestamp", NULL, MAVLINK_TYPE_UINT64_T, 0, 0, offsetof(mavlink_setup_signing_t, initial_timestamp) },
43 } \
44}
45#endif
46
47/**
48 * @brief Pack a setup_signing message
49 * @param system_id ID of this system
50 * @param component_id ID of this component (e.g. 200 for IMU)
51 * @param msg The MAVLink message to compress the data into
52 *
53 * @param target_system system id of the target
54 * @param target_component component ID of the target
55 * @param secret_key signing key
56 * @param initial_timestamp initial timestamp
57 * @return length of the message in bytes (excluding serial stream start sign)
58 */
59static inline uint16_t mavlink_msg_setup_signing_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
60 uint8_t target_system, uint8_t target_component, const uint8_t *secret_key, uint64_t initial_timestamp)
61{
62#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
64 _mav_put_uint64_t(buf, 0, initial_timestamp);
65 _mav_put_uint8_t(buf, 8, target_system);
66 _mav_put_uint8_t(buf, 9, target_component);
67 _mav_put_uint8_t_array(buf, 10, secret_key, 32);
68 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
69#else
70 mavlink_setup_signing_t packet;
71 packet.initial_timestamp = initial_timestamp;
72 packet.target_system = target_system;
73 packet.target_component = target_component;
74 mav_array_memcpy(packet.secret_key, secret_key, sizeof(uint8_t)*32);
75 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
76#endif
77
79 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC);
80}
81
82/**
83 * @brief Pack a setup_signing message
84 * @param system_id ID of this system
85 * @param component_id ID of this component (e.g. 200 for IMU)
86 * @param status MAVLink status structure
87 * @param msg The MAVLink message to compress the data into
88 *
89 * @param target_system system id of the target
90 * @param target_component component ID of the target
91 * @param secret_key signing key
92 * @param initial_timestamp initial timestamp
93 * @return length of the message in bytes (excluding serial stream start sign)
94 */
95static inline uint16_t mavlink_msg_setup_signing_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
96 uint8_t target_system, uint8_t target_component, const uint8_t *secret_key, uint64_t initial_timestamp)
97{
98#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
100 _mav_put_uint64_t(buf, 0, initial_timestamp);
101 _mav_put_uint8_t(buf, 8, target_system);
102 _mav_put_uint8_t(buf, 9, target_component);
103 _mav_put_uint8_t_array(buf, 10, secret_key, 32);
104 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
105#else
106 mavlink_setup_signing_t packet;
107 packet.initial_timestamp = initial_timestamp;
108 packet.target_system = target_system;
109 packet.target_component = target_component;
110 mav_array_memcpy(packet.secret_key, secret_key, sizeof(uint8_t)*32);
111 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
112#endif
113
114 msg->msgid = MAVLINK_MSG_ID_SETUP_SIGNING;
115#if MAVLINK_CRC_EXTRA
116 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC);
117#else
118 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
119#endif
120}
121
122/**
123 * @brief Pack a setup_signing message on a channel
124 * @param system_id ID of this system
125 * @param component_id ID of this component (e.g. 200 for IMU)
126 * @param chan The MAVLink channel this message will be sent over
127 * @param msg The MAVLink message to compress the data into
128 * @param target_system system id of the target
129 * @param target_component component ID of the target
130 * @param secret_key signing key
131 * @param initial_timestamp initial timestamp
132 * @return length of the message in bytes (excluding serial stream start sign)
133 */
134static inline uint16_t mavlink_msg_setup_signing_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
135 mavlink_message_t* msg,
136 uint8_t target_system,uint8_t target_component,const uint8_t *secret_key,uint64_t initial_timestamp)
137{
138#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
140 _mav_put_uint64_t(buf, 0, initial_timestamp);
141 _mav_put_uint8_t(buf, 8, target_system);
142 _mav_put_uint8_t(buf, 9, target_component);
143 _mav_put_uint8_t_array(buf, 10, secret_key, 32);
144 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
145#else
146 mavlink_setup_signing_t packet;
147 packet.initial_timestamp = initial_timestamp;
148 packet.target_system = target_system;
149 packet.target_component = target_component;
150 mav_array_memcpy(packet.secret_key, secret_key, sizeof(uint8_t)*32);
151 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
152#endif
153
154 msg->msgid = MAVLINK_MSG_ID_SETUP_SIGNING;
155 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC);
156}
157
158/**
159 * @brief Encode a setup_signing struct
160 *
161 * @param system_id ID of this system
162 * @param component_id ID of this component (e.g. 200 for IMU)
163 * @param msg The MAVLink message to compress the data into
164 * @param setup_signing C-struct to read the message contents from
165 */
166static inline uint16_t mavlink_msg_setup_signing_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_setup_signing_t* setup_signing)
167{
168 return mavlink_msg_setup_signing_pack(system_id, component_id, msg, setup_signing->target_system, setup_signing->target_component, setup_signing->secret_key, setup_signing->initial_timestamp);
169}
170
171/**
172 * @brief Encode a setup_signing struct on a channel
173 *
174 * @param system_id ID of this system
175 * @param component_id ID of this component (e.g. 200 for IMU)
176 * @param chan The MAVLink channel this message will be sent over
177 * @param msg The MAVLink message to compress the data into
178 * @param setup_signing C-struct to read the message contents from
179 */
180static inline uint16_t mavlink_msg_setup_signing_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_setup_signing_t* setup_signing)
181{
182 return mavlink_msg_setup_signing_pack_chan(system_id, component_id, chan, msg, setup_signing->target_system, setup_signing->target_component, setup_signing->secret_key, setup_signing->initial_timestamp);
183}
184
185/**
186 * @brief Encode a setup_signing struct with provided status structure
187 *
188 * @param system_id ID of this system
189 * @param component_id ID of this component (e.g. 200 for IMU)
190 * @param status MAVLink status structure
191 * @param msg The MAVLink message to compress the data into
192 * @param setup_signing C-struct to read the message contents from
193 */
194static inline uint16_t mavlink_msg_setup_signing_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_setup_signing_t* setup_signing)
195{
196 return mavlink_msg_setup_signing_pack_status(system_id, component_id, _status, msg, setup_signing->target_system, setup_signing->target_component, setup_signing->secret_key, setup_signing->initial_timestamp);
197}
198
199/**
200 * @brief Send a setup_signing message
201 * @param chan MAVLink channel to send the message
202 *
203 * @param target_system system id of the target
204 * @param target_component component ID of the target
205 * @param secret_key signing key
206 * @param initial_timestamp initial timestamp
207 */
208#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
209
210static inline void mavlink_msg_setup_signing_send(mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const uint8_t *secret_key, uint64_t initial_timestamp)
211{
212#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
213 char buf[MAVLINK_MSG_ID_SETUP_SIGNING_LEN];
214 _mav_put_uint64_t(buf, 0, initial_timestamp);
215 _mav_put_uint8_t(buf, 8, target_system);
216 _mav_put_uint8_t(buf, 9, target_component);
217 _mav_put_uint8_t_array(buf, 10, secret_key, 32);
218 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETUP_SIGNING, buf, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC);
219#else
220 mavlink_setup_signing_t packet;
221 packet.initial_timestamp = initial_timestamp;
222 packet.target_system = target_system;
223 packet.target_component = target_component;
224 mav_array_memcpy(packet.secret_key, secret_key, sizeof(uint8_t)*32);
225 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETUP_SIGNING, (const char *)&packet, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC);
226#endif
227}
228
229/**
230 * @brief Send a setup_signing message
231 * @param chan MAVLink channel to send the message
232 * @param struct The MAVLink struct to serialize
233 */
234static inline void mavlink_msg_setup_signing_send_struct(mavlink_channel_t chan, const mavlink_setup_signing_t* setup_signing)
235{
236#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
237 mavlink_msg_setup_signing_send(chan, setup_signing->target_system, setup_signing->target_component, setup_signing->secret_key, setup_signing->initial_timestamp);
238#else
239 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETUP_SIGNING, (const char *)setup_signing, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC);
240#endif
241}
242
243#if MAVLINK_MSG_ID_SETUP_SIGNING_LEN <= MAVLINK_MAX_PAYLOAD_LEN
244/*
245 This variant of _send() can be used to save stack space by reusing
246 memory from the receive buffer. The caller provides a
247 mavlink_message_t which is the size of a full mavlink message. This
248 is usually the receive buffer for the channel, and allows a reply to an
249 incoming message with minimum stack space usage.
250 */
251static inline void mavlink_msg_setup_signing_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_system, uint8_t target_component, const uint8_t *secret_key, uint64_t initial_timestamp)
252{
253#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
254 char *buf = (char *)msgbuf;
255 _mav_put_uint64_t(buf, 0, initial_timestamp);
256 _mav_put_uint8_t(buf, 8, target_system);
257 _mav_put_uint8_t(buf, 9, target_component);
258 _mav_put_uint8_t_array(buf, 10, secret_key, 32);
259 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETUP_SIGNING, buf, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC);
260#else
261 mavlink_setup_signing_t *packet = (mavlink_setup_signing_t *)msgbuf;
262 packet->initial_timestamp = initial_timestamp;
263 packet->target_system = target_system;
264 packet->target_component = target_component;
265 mav_array_memcpy(packet->secret_key, secret_key, sizeof(uint8_t)*32);
266 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_SETUP_SIGNING, (const char *)packet, MAVLINK_MSG_ID_SETUP_SIGNING_MIN_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_LEN, MAVLINK_MSG_ID_SETUP_SIGNING_CRC);
267#endif
268}
269#endif
270
271#endif
272
273// MESSAGE SETUP_SIGNING UNPACKING
274
275
276/**
277 * @brief Get field target_system from setup_signing message
278 *
279 * @return system id of the target
280 */
281static inline uint8_t mavlink_msg_setup_signing_get_target_system(const mavlink_message_t* msg)
282{
283 return _MAV_RETURN_uint8_t(msg, 8);
284}
285
286/**
287 * @brief Get field target_component from setup_signing message
288 *
289 * @return component ID of the target
290 */
291static inline uint8_t mavlink_msg_setup_signing_get_target_component(const mavlink_message_t* msg)
292{
293 return _MAV_RETURN_uint8_t(msg, 9);
294}
295
296/**
297 * @brief Get field secret_key from setup_signing message
298 *
299 * @return signing key
300 */
301static inline uint16_t mavlink_msg_setup_signing_get_secret_key(const mavlink_message_t* msg, uint8_t *secret_key)
302{
303 return _MAV_RETURN_uint8_t_array(msg, secret_key, 32, 10);
304}
305
306/**
307 * @brief Get field initial_timestamp from setup_signing message
308 *
309 * @return initial timestamp
310 */
311static inline uint64_t mavlink_msg_setup_signing_get_initial_timestamp(const mavlink_message_t* msg)
312{
313 return _MAV_RETURN_uint64_t(msg, 0);
314}
315
316/**
317 * @brief Decode a setup_signing message into a struct
318 *
319 * @param msg The message to decode
320 * @param setup_signing C-struct to decode the message contents into
321 */
322static inline void mavlink_msg_setup_signing_decode(const mavlink_message_t* msg, mavlink_setup_signing_t* setup_signing)
323{
324#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
325 setup_signing->initial_timestamp = mavlink_msg_setup_signing_get_initial_timestamp(msg);
326 setup_signing->target_system = mavlink_msg_setup_signing_get_target_system(msg);
327 setup_signing->target_component = mavlink_msg_setup_signing_get_target_component(msg);
328 mavlink_msg_setup_signing_get_secret_key(msg, setup_signing->secret_key);
329#else
330 uint8_t len = msg->len < MAVLINK_MSG_ID_SETUP_SIGNING_LEN? msg->len : MAVLINK_MSG_ID_SETUP_SIGNING_LEN;
331 memset(setup_signing, 0, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
332 memcpy(setup_signing, _MAV_PAYLOAD(msg), len);
333#endif
334}