Merge pull request #10476 from radiolinkW/RADIOLINKF722
[inav.git] / lib / main / MAVLink / common / mavlink_msg_setup_signing.h
blobe9bab0cbaa6a596689d81f587532661c9a798f46
1 #pragma once
2 // MESSAGE SETUP_SIGNING PACKING
4 #define MAVLINK_MSG_ID_SETUP_SIGNING 256
7 typedef struct __mavlink_setup_signing_t {
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;
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
19 #define MAVLINK_MSG_ID_SETUP_SIGNING_CRC 71
20 #define MAVLINK_MSG_ID_256_CRC 71
22 #define MAVLINK_MSG_SETUP_SIGNING_FIELD_SECRET_KEY_LEN 32
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 } \
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 } \
45 #endif
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
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)
59 static 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)
62 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
63 char buf[MAVLINK_MSG_ID_SETUP_SIGNING_LEN];
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
78 msg->msgid = MAVLINK_MSG_ID_SETUP_SIGNING;
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);
82 /**
83 * @brief Pack a setup_signing message on a channel
84 * @param system_id ID of this system
85 * @param component_id ID of this component (e.g. 200 for IMU)
86 * @param chan The MAVLink channel this message will be sent over
87 * @param msg The MAVLink message to compress the data into
88 * @param target_system system id of the target
89 * @param target_component component ID of the target
90 * @param secret_key signing key
91 * @param initial_timestamp initial timestamp
92 * @return length of the message in bytes (excluding serial stream start sign)
94 static inline uint16_t mavlink_msg_setup_signing_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
95 mavlink_message_t* msg,
96 uint8_t target_system,uint8_t target_component,const uint8_t *secret_key,uint64_t initial_timestamp)
98 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
99 char buf[MAVLINK_MSG_ID_SETUP_SIGNING_LEN];
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
114 msg->msgid = MAVLINK_MSG_ID_SETUP_SIGNING;
115 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);
119 * @brief Encode a setup_signing struct
121 * @param system_id ID of this system
122 * @param component_id ID of this component (e.g. 200 for IMU)
123 * @param msg The MAVLink message to compress the data into
124 * @param setup_signing C-struct to read the message contents from
126 static 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)
128 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);
132 * @brief Encode a setup_signing struct on a channel
134 * @param system_id ID of this system
135 * @param component_id ID of this component (e.g. 200 for IMU)
136 * @param chan The MAVLink channel this message will be sent over
137 * @param msg The MAVLink message to compress the data into
138 * @param setup_signing C-struct to read the message contents from
140 static 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)
142 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);
146 * @brief Send a setup_signing message
147 * @param chan MAVLink channel to send the message
149 * @param target_system system id of the target
150 * @param target_component component ID of the target
151 * @param secret_key signing key
152 * @param initial_timestamp initial timestamp
154 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
156 static 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)
158 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
159 char buf[MAVLINK_MSG_ID_SETUP_SIGNING_LEN];
160 _mav_put_uint64_t(buf, 0, initial_timestamp);
161 _mav_put_uint8_t(buf, 8, target_system);
162 _mav_put_uint8_t(buf, 9, target_component);
163 _mav_put_uint8_t_array(buf, 10, secret_key, 32);
164 _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);
165 #else
166 mavlink_setup_signing_t packet;
167 packet.initial_timestamp = initial_timestamp;
168 packet.target_system = target_system;
169 packet.target_component = target_component;
170 mav_array_memcpy(packet.secret_key, secret_key, sizeof(uint8_t)*32);
171 _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);
172 #endif
176 * @brief Send a setup_signing message
177 * @param chan MAVLink channel to send the message
178 * @param struct The MAVLink struct to serialize
180 static inline void mavlink_msg_setup_signing_send_struct(mavlink_channel_t chan, const mavlink_setup_signing_t* setup_signing)
182 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
183 mavlink_msg_setup_signing_send(chan, setup_signing->target_system, setup_signing->target_component, setup_signing->secret_key, setup_signing->initial_timestamp);
184 #else
185 _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);
186 #endif
189 #if MAVLINK_MSG_ID_SETUP_SIGNING_LEN <= MAVLINK_MAX_PAYLOAD_LEN
191 This varient of _send() can be used to save stack space by re-using
192 memory from the receive buffer. The caller provides a
193 mavlink_message_t which is the size of a full mavlink message. This
194 is usually the receive buffer for the channel, and allows a reply to an
195 incoming message with minimum stack space usage.
197 static 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)
199 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 char *buf = (char *)msgbuf;
201 _mav_put_uint64_t(buf, 0, initial_timestamp);
202 _mav_put_uint8_t(buf, 8, target_system);
203 _mav_put_uint8_t(buf, 9, target_component);
204 _mav_put_uint8_t_array(buf, 10, secret_key, 32);
205 _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);
206 #else
207 mavlink_setup_signing_t *packet = (mavlink_setup_signing_t *)msgbuf;
208 packet->initial_timestamp = initial_timestamp;
209 packet->target_system = target_system;
210 packet->target_component = target_component;
211 mav_array_memcpy(packet->secret_key, secret_key, sizeof(uint8_t)*32);
212 _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);
213 #endif
215 #endif
217 #endif
219 // MESSAGE SETUP_SIGNING UNPACKING
223 * @brief Get field target_system from setup_signing message
225 * @return system id of the target
227 static inline uint8_t mavlink_msg_setup_signing_get_target_system(const mavlink_message_t* msg)
229 return _MAV_RETURN_uint8_t(msg, 8);
233 * @brief Get field target_component from setup_signing message
235 * @return component ID of the target
237 static inline uint8_t mavlink_msg_setup_signing_get_target_component(const mavlink_message_t* msg)
239 return _MAV_RETURN_uint8_t(msg, 9);
243 * @brief Get field secret_key from setup_signing message
245 * @return signing key
247 static inline uint16_t mavlink_msg_setup_signing_get_secret_key(const mavlink_message_t* msg, uint8_t *secret_key)
249 return _MAV_RETURN_uint8_t_array(msg, secret_key, 32, 10);
253 * @brief Get field initial_timestamp from setup_signing message
255 * @return initial timestamp
257 static inline uint64_t mavlink_msg_setup_signing_get_initial_timestamp(const mavlink_message_t* msg)
259 return _MAV_RETURN_uint64_t(msg, 0);
263 * @brief Decode a setup_signing message into a struct
265 * @param msg The message to decode
266 * @param setup_signing C-struct to decode the message contents into
268 static inline void mavlink_msg_setup_signing_decode(const mavlink_message_t* msg, mavlink_setup_signing_t* setup_signing)
270 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
271 setup_signing->initial_timestamp = mavlink_msg_setup_signing_get_initial_timestamp(msg);
272 setup_signing->target_system = mavlink_msg_setup_signing_get_target_system(msg);
273 setup_signing->target_component = mavlink_msg_setup_signing_get_target_component(msg);
274 mavlink_msg_setup_signing_get_secret_key(msg, setup_signing->secret_key);
275 #else
276 uint8_t len = msg->len < MAVLINK_MSG_ID_SETUP_SIGNING_LEN? msg->len : MAVLINK_MSG_ID_SETUP_SIGNING_LEN;
277 memset(setup_signing, 0, MAVLINK_MSG_ID_SETUP_SIGNING_LEN);
278 memcpy(setup_signing, _MAV_PAYLOAD(msg), len);
279 #endif