Arduino Mavlink
Loading...
Searching...
No Matches
mavlink_msg_auth_key.h
Go to the documentation of this file.
1#pragma once
2// MESSAGE AUTH_KEY PACKING
3
4#define MAVLINK_MSG_ID_AUTH_KEY 7
5
6
7typedef struct __mavlink_auth_key_t {
8 char key[32]; /*< key*/
9} mavlink_auth_key_t;
10
11#define MAVLINK_MSG_ID_AUTH_KEY_LEN 32
12#define MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN 32
13#define MAVLINK_MSG_ID_7_LEN 32
14#define MAVLINK_MSG_ID_7_MIN_LEN 32
15
16#define MAVLINK_MSG_ID_AUTH_KEY_CRC 119
17#define MAVLINK_MSG_ID_7_CRC 119
18
19#define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32
20
21#if MAVLINK_COMMAND_24BIT
22#define MAVLINK_MESSAGE_INFO_AUTH_KEY {
23 7,
24 "AUTH_KEY",
25 1,
26 { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) },
27 } \
28}
29#else
30#define MAVLINK_MESSAGE_INFO_AUTH_KEY {
31 "AUTH_KEY",
32 1,
33 { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) },
34 } \
35}
36#endif
37
38/**
39 * @brief Pack a auth_key message
40 * @param system_id ID of this system
41 * @param component_id ID of this component (e.g. 200 for IMU)
42 * @param msg The MAVLink message to compress the data into
43 *
44 * @param key key
45 * @return length of the message in bytes (excluding serial stream start sign)
46 */
47static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
48 const char *key)
49{
50#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
52
53 _mav_put_char_array(buf, 0, key, 32);
54 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN);
55#else
56 mavlink_auth_key_t packet;
57
58 mav_array_memcpy(packet.key, key, sizeof(char)*32);
59 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN);
60#endif
61
62 msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
63 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
64}
65
66/**
67 * @brief Pack a auth_key message
68 * @param system_id ID of this system
69 * @param component_id ID of this component (e.g. 200 for IMU)
70 * @param status MAVLink status structure
71 * @param msg The MAVLink message to compress the data into
72 *
73 * @param key key
74 * @return length of the message in bytes (excluding serial stream start sign)
75 */
76static inline uint16_t mavlink_msg_auth_key_pack_status(uint8_t system_id, uint8_t component_id, mavlink_status_t *_status, mavlink_message_t* msg,
77 const char *key)
78{
79#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
81
82 _mav_put_char_array(buf, 0, key, 32);
83 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN);
84#else
85 mavlink_auth_key_t packet;
86
87 mav_array_memcpy(packet.key, key, sizeof(char)*32);
88 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN);
89#endif
90
91 msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
92#if MAVLINK_CRC_EXTRA
93 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
94#else
95 return mavlink_finalize_message_buffer(msg, system_id, component_id, _status, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN);
96#endif
97}
98
99/**
100 * @brief Pack a auth_key message on a channel
101 * @param system_id ID of this system
102 * @param component_id ID of this component (e.g. 200 for IMU)
103 * @param chan The MAVLink channel this message will be sent over
104 * @param msg The MAVLink message to compress the data into
105 * @param key key
106 * @return length of the message in bytes (excluding serial stream start sign)
107 */
108static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
109 mavlink_message_t* msg,
110 const char *key)
111{
112#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
114
115 _mav_put_char_array(buf, 0, key, 32);
116 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN);
117#else
118 mavlink_auth_key_t packet;
119
120 mav_array_memcpy(packet.key, key, sizeof(char)*32);
121 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN);
122#endif
123
124 msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
125 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
126}
127
128/**
129 * @brief Encode a auth_key struct
130 *
131 * @param system_id ID of this system
132 * @param component_id ID of this component (e.g. 200 for IMU)
133 * @param msg The MAVLink message to compress the data into
134 * @param auth_key C-struct to read the message contents from
135 */
136static inline uint16_t mavlink_msg_auth_key_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key)
137{
138 return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key);
139}
140
141/**
142 * @brief Encode a auth_key struct on a channel
143 *
144 * @param system_id ID of this system
145 * @param component_id ID of this component (e.g. 200 for IMU)
146 * @param chan The MAVLink channel this message will be sent over
147 * @param msg The MAVLink message to compress the data into
148 * @param auth_key C-struct to read the message contents from
149 */
150static inline uint16_t mavlink_msg_auth_key_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key)
151{
152 return mavlink_msg_auth_key_pack_chan(system_id, component_id, chan, msg, auth_key->key);
153}
154
155/**
156 * @brief Encode a auth_key struct with provided status structure
157 *
158 * @param system_id ID of this system
159 * @param component_id ID of this component (e.g. 200 for IMU)
160 * @param status MAVLink status structure
161 * @param msg The MAVLink message to compress the data into
162 * @param auth_key C-struct to read the message contents from
163 */
164static inline uint16_t mavlink_msg_auth_key_encode_status(uint8_t system_id, uint8_t component_id, mavlink_status_t* _status, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key)
165{
166 return mavlink_msg_auth_key_pack_status(system_id, component_id, _status, msg, auth_key->key);
167}
168
169/**
170 * @brief Send a auth_key message
171 * @param chan MAVLink channel to send the message
172 *
173 * @param key key
174 */
175#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
176
177static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char *key)
178{
179#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
180 char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN];
181
182 _mav_put_char_array(buf, 0, key, 32);
183 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
184#else
185 mavlink_auth_key_t packet;
186
187 mav_array_memcpy(packet.key, key, sizeof(char)*32);
188 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)&packet, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
189#endif
190}
191
192/**
193 * @brief Send a auth_key message
194 * @param chan MAVLink channel to send the message
195 * @param struct The MAVLink struct to serialize
196 */
197static inline void mavlink_msg_auth_key_send_struct(mavlink_channel_t chan, const mavlink_auth_key_t* auth_key)
198{
199#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
200 mavlink_msg_auth_key_send(chan, auth_key->key);
201#else
202 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)auth_key, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
203#endif
204}
205
206#if MAVLINK_MSG_ID_AUTH_KEY_LEN <= MAVLINK_MAX_PAYLOAD_LEN
207/*
208 This variant of _send() can be used to save stack space by reusing
209 memory from the receive buffer. The caller provides a
210 mavlink_message_t which is the size of a full mavlink message. This
211 is usually the receive buffer for the channel, and allows a reply to an
212 incoming message with minimum stack space usage.
213 */
214static inline void mavlink_msg_auth_key_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, const char *key)
215{
216#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
217 char *buf = (char *)msgbuf;
218
219 _mav_put_char_array(buf, 0, key, 32);
220 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
221#else
222 mavlink_auth_key_t *packet = (mavlink_auth_key_t *)msgbuf;
223
224 mav_array_memcpy(packet->key, key, sizeof(char)*32);
225 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)packet, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
226#endif
227}
228#endif
229
230#endif
231
232// MESSAGE AUTH_KEY UNPACKING
233
234
235/**
236 * @brief Get field key from auth_key message
237 *
238 * @return key
239 */
240static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char *key)
241{
242 return _MAV_RETURN_char_array(msg, key, 32, 0);
243}
244
245/**
246 * @brief Decode a auth_key message into a struct
247 *
248 * @param msg The message to decode
249 * @param auth_key C-struct to decode the message contents into
250 */
251static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key)
252{
253#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
254 mavlink_msg_auth_key_get_key(msg, auth_key->key);
255#else
256 uint8_t len = msg->len < MAVLINK_MSG_ID_AUTH_KEY_LEN? msg->len : MAVLINK_MSG_ID_AUTH_KEY_LEN;
257 memset(auth_key, 0, MAVLINK_MSG_ID_AUTH_KEY_LEN);
258 memcpy(auth_key, _MAV_PAYLOAD(msg), len);
259#endif
260}