mavlink_msg_auth_key.h 3.32 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 18 19 20 21 22
#define MAVLINK_MESSAGE_INFO_AUTH_KEY { \
	"AUTH_KEY", \
	1, \
	{  { "key", MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \
         } \
}


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 35 36
{
	msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;

lm's avatar
lm committed
37
	put_char_array_by_index(msg, 0, key, 32); // key
James Goppert's avatar
James Goppert committed
38

lm's avatar
lm committed
39
	return mavlink_finalize_message(msg, system_id, component_id, 32, 119);
James Goppert's avatar
James Goppert committed
40 41 42
}

/**
lm's avatar
lm committed
43
 * @brief Pack a auth_key message on a channel
James Goppert's avatar
James Goppert committed
44 45 46 47 48 49 50
 * @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
51 52 53
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
54 55 56
{
	msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;

lm's avatar
lm committed
57
	put_char_array_by_index(msg, 0, key, 32); // key
James Goppert's avatar
James Goppert committed
58

lm's avatar
lm committed
59
	return mavlink_finalize_message_chan(msg, system_id, component_id, chan, 32, 119);
James Goppert's avatar
James Goppert committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
}

/**
 * @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
81 82 83
#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
84
{
lm's avatar
lm committed
85
	MAVLINK_ALIGNED_MESSAGE(msg, 32);
LM's avatar
LM committed
86 87 88 89 90
	msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;

	put_char_array_by_index(msg, 0, key, 32); // key

	mavlink_finalize_message_chan_send(msg, chan, 32, 119);
James Goppert's avatar
James Goppert committed
91 92 93
}

#endif
lm's avatar
lm committed
94

James Goppert's avatar
James Goppert committed
95 96
// MESSAGE AUTH_KEY UNPACKING

lm's avatar
lm committed
97

James Goppert's avatar
James Goppert committed
98 99 100 101 102
/**
 * @brief Get field key from auth_key message
 *
 * @return key
 */
lm's avatar
lm committed
103
static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char *key)
James Goppert's avatar
James Goppert committed
104
{
lm's avatar
lm committed
105
	return MAVLINK_MSG_RETURN_char_array(msg, key, 32,  0);
James Goppert's avatar
James Goppert committed
106 107 108 109 110 111 112 113 114 115
}

/**
 * @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
116 117 118 119 120
#if MAVLINK_NEED_BYTE_SWAP
	mavlink_msg_auth_key_get_key(msg, auth_key->key);
#else
	memcpy(auth_key, MAVLINK_PAYLOAD(msg), 32);
#endif
James Goppert's avatar
James Goppert committed
121
}