mavlink_msg_auth_key.h 3.96 KB
Newer Older
James Goppert's avatar
James Goppert committed
1 2 3 4
// MESSAGE AUTH_KEY PACKING

#define MAVLINK_MSG_ID_AUTH_KEY 7

lm's avatar
lm committed
5
typedef struct __mavlink_auth_key_t
James Goppert's avatar
James Goppert committed
6
{
lm's avatar
lm committed
7
 char key[32]; ///< key
James Goppert's avatar
James Goppert committed
8
} mavlink_auth_key_t;
lm's avatar
lm committed
9 10 11 12

#define MAVLINK_MSG_ID_AUTH_KEY_LEN 32
#define MAVLINK_MSG_ID_7_LEN 32

James Goppert's avatar
James Goppert committed
13 14
#define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32

lm's avatar
lm committed
15 16 17
#define MAVLINK_MESSAGE_INFO_AUTH_KEY { \
	"AUTH_KEY", \
	1, \
lm's avatar
lm committed
18
	{  { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \
lm's avatar
lm committed
19 20 21 22
         } \
}


James Goppert's avatar
James Goppert committed
23 24 25 26 27 28 29 30 31
/**
 * @brief Pack a auth_key message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param key key
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
32 33
static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
						       const char *key)
James Goppert's avatar
James Goppert committed
34
{
LM's avatar
LM committed
35 36 37 38 39 40 41
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[32];

	_mav_put_char_array(buf, 0, key, 32);
        memcpy(_MAV_PAYLOAD(msg), buf, 32);
#else
	mavlink_auth_key_t packet;
James Goppert's avatar
James Goppert committed
42

LM's avatar
LM committed
43 44 45
	memcpy(packet.key, key, sizeof(char)*32);
        memcpy(_MAV_PAYLOAD(msg), &packet, 32);
#endif
James Goppert's avatar
James Goppert committed
46

LM's avatar
LM committed
47
	msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
lm's avatar
lm committed
48
	return mavlink_finalize_message(msg, system_id, component_id, 32, 119);
James Goppert's avatar
James Goppert committed
49 50 51
}

/**
lm's avatar
lm committed
52
 * @brief Pack a auth_key message on a channel
James Goppert's avatar
James Goppert committed
53 54 55 56 57 58 59
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message was sent over
 * @param msg The MAVLink message to compress the data into
 * @param key key
 * @return length of the message in bytes (excluding serial stream start sign)
 */
lm's avatar
lm committed
60 61 62
static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
							   mavlink_message_t* msg,
						           const char *key)
James Goppert's avatar
James Goppert committed
63
{
LM's avatar
LM committed
64 65
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[32];
James Goppert's avatar
James Goppert committed
66

LM's avatar
LM committed
67 68 69 70
	_mav_put_char_array(buf, 0, key, 32);
        memcpy(_MAV_PAYLOAD(msg), buf, 32);
#else
	mavlink_auth_key_t packet;
James Goppert's avatar
James Goppert committed
71

LM's avatar
LM committed
72 73 74 75 76
	memcpy(packet.key, key, sizeof(char)*32);
        memcpy(_MAV_PAYLOAD(msg), &packet, 32);
#endif

	msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
lm's avatar
lm committed
77
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 32, 119);
James Goppert's avatar
James Goppert committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
}

/**
 * @brief Encode a auth_key struct into a message
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param auth_key C-struct to read the message contents from
 */
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)
{
	return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key);
}

/**
 * @brief Send a auth_key message
 * @param chan MAVLink channel to send the message
 *
 * @param key key
 */
lm's avatar
lm committed
99 100 101
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char *key)
lm's avatar
lm committed
102
{
LM's avatar
LM committed
103 104
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
	char buf[32];
LM's avatar
LM committed
105

LM's avatar
LM committed
106 107 108 109
	_mav_put_char_array(buf, 0, key, 32);
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, 32, 119);
#else
	mavlink_auth_key_t packet;
LM's avatar
LM committed
110

LM's avatar
LM committed
111 112 113
	memcpy(packet.key, key, sizeof(char)*32);
	_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)&packet, 32, 119);
#endif
James Goppert's avatar
James Goppert committed
114 115 116
}

#endif
lm's avatar
lm committed
117

James Goppert's avatar
James Goppert committed
118 119
// MESSAGE AUTH_KEY UNPACKING

lm's avatar
lm committed
120

James Goppert's avatar
James Goppert committed
121 122 123 124 125
/**
 * @brief Get field key from auth_key message
 *
 * @return key
 */
lm's avatar
lm committed
126
static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char *key)
James Goppert's avatar
James Goppert committed
127
{
LM's avatar
LM committed
128
	return _MAV_RETURN_char_array(msg, key, 32,  0);
James Goppert's avatar
James Goppert committed
129 130 131 132 133 134 135 136 137 138
}

/**
 * @brief Decode a auth_key message into a struct
 *
 * @param msg The message to decode
 * @param auth_key C-struct to decode the message contents into
 */
static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key)
{
lm's avatar
lm committed
139 140 141
#if MAVLINK_NEED_BYTE_SWAP
	mavlink_msg_auth_key_get_key(msg, auth_key->key);
#else
LM's avatar
LM committed
142
	memcpy(auth_key, _MAV_PAYLOAD(msg), 32);
lm's avatar
lm committed
143
#endif
James Goppert's avatar
James Goppert committed
144
}