Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / libraries / mavlink / v1.0 / common / mavlink_msg_auth_key.h
blob429526c98ddd0f09763b630b1b9e5705b517716f
1 // MESSAGE AUTH_KEY PACKING
3 #define MAVLINK_MSG_ID_AUTH_KEY 7
5 typedef struct __mavlink_auth_key_t {
6 char key[32]; ///< key
7 } mavlink_auth_key_t;
9 #define MAVLINK_MSG_ID_AUTH_KEY_LEN 32
10 #define MAVLINK_MSG_ID_7_LEN 32
12 #define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32
14 #define MAVLINK_MESSAGE_INFO_AUTH_KEY \
15 { \
16 "AUTH_KEY", \
17 1, \
18 { \
19 { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \
20 } \
24 /**
25 * @brief Pack a auth_key message
26 * @param system_id ID of this system
27 * @param component_id ID of this component (e.g. 200 for IMU)
28 * @param msg The MAVLink message to compress the data into
30 * @param key key
31 * @return length of the message in bytes (excluding serial stream start sign)
33 static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t *msg,
34 const char *key)
36 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
37 char buf[32];
39 _mav_put_char_array(buf, 0, key, 32);
40 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32);
41 #else
42 mavlink_auth_key_t packet;
44 mav_array_memcpy(packet.key, key, sizeof(char) * 32);
45 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32);
46 #endif
48 msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
49 return mavlink_finalize_message(msg, system_id, component_id, 32, 119);
52 /**
53 * @brief Pack a auth_key message on a channel
54 * @param system_id ID of this system
55 * @param component_id ID of this component (e.g. 200 for IMU)
56 * @param chan The MAVLink channel this message was sent over
57 * @param msg The MAVLink message to compress the data into
58 * @param key key
59 * @return length of the message in bytes (excluding serial stream start sign)
61 static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
62 mavlink_message_t *msg,
63 const char *key)
65 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
66 char buf[32];
68 _mav_put_char_array(buf, 0, key, 32);
69 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, 32);
70 #else
71 mavlink_auth_key_t packet;
73 mav_array_memcpy(packet.key, key, sizeof(char) * 32);
74 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, 32);
75 #endif
77 msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
78 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 32, 119);
81 /**
82 * @brief Encode a auth_key struct into a message
84 * @param system_id ID of this system
85 * @param component_id ID of this component (e.g. 200 for IMU)
86 * @param msg The MAVLink message to compress the data into
87 * @param auth_key C-struct to read the message contents from
89 static 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)
91 return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key);
94 /**
95 * @brief Send a auth_key message
96 * @param chan MAVLink channel to send the message
98 * @param key key
100 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
102 static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char *key)
104 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
105 char buf[32];
107 _mav_put_char_array(buf, 0, key, 32);
108 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, 32, 119);
109 #else
110 mavlink_auth_key_t packet;
112 mav_array_memcpy(packet.key, key, sizeof(char) * 32);
113 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)&packet, 32, 119);
114 #endif
117 #endif
119 // MESSAGE AUTH_KEY UNPACKING
123 * @brief Get field key from auth_key message
125 * @return key
127 static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t *msg, char *key)
129 return _MAV_RETURN_char_array(msg, key, 32, 0);
133 * @brief Decode a auth_key message into a struct
135 * @param msg The message to decode
136 * @param auth_key C-struct to decode the message contents into
138 static inline void mavlink_msg_auth_key_decode(const mavlink_message_t *msg, mavlink_auth_key_t *auth_key)
140 #if MAVLINK_NEED_BYTE_SWAP
141 mavlink_msg_auth_key_get_key(msg, auth_key->key);
142 #else
143 memcpy(auth_key, _MAV_PAYLOAD(msg), 32);
144 #endif