Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mavlink_msg_auth_key.h Source File

mavlink_msg_auth_key.h

00001 // MESSAGE AUTH_KEY PACKING
00002 
00003 #define MAVLINK_MSG_ID_AUTH_KEY 7
00004 
00005 typedef struct __mavlink_auth_key_t 
00006 {
00007     char key[32]; ///< key
00008 
00009 } mavlink_auth_key_t;
00010 
00011 #define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32
00012 
00013 
00014 /**
00015  * @brief Pack a auth_key message
00016  * @param system_id ID of this system
00017  * @param component_id ID of this component (e.g. 200 for IMU)
00018  * @param msg The MAVLink message to compress the data into
00019  *
00020  * @param key key
00021  * @return length of the message in bytes (excluding serial stream start sign)
00022  */
00023 static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const char* key)
00024 {
00025     uint16_t i = 0;
00026     msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
00027 
00028     i += put_array_by_index((const int8_t*)key, sizeof(char)*32, i, msg->payload); // key
00029 
00030     return mavlink_finalize_message(msg, system_id, component_id, i);
00031 }
00032 
00033 /**
00034  * @brief Pack a auth_key message
00035  * @param system_id ID of this system
00036  * @param component_id ID of this component (e.g. 200 for IMU)
00037  * @param chan The MAVLink channel this message was sent over
00038  * @param msg The MAVLink message to compress the data into
00039  * @param key key
00040  * @return length of the message in bytes (excluding serial stream start sign)
00041  */
00042 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)
00043 {
00044     uint16_t i = 0;
00045     msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
00046 
00047     i += put_array_by_index((const int8_t*)key, sizeof(char)*32, i, msg->payload); // key
00048 
00049     return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i);
00050 }
00051 
00052 /**
00053  * @brief Encode a auth_key struct into a message
00054  *
00055  * @param system_id ID of this system
00056  * @param component_id ID of this component (e.g. 200 for IMU)
00057  * @param msg The MAVLink message to compress the data into
00058  * @param auth_key C-struct to read the message contents from
00059  */
00060 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)
00061 {
00062     return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key);
00063 }
00064 
00065 /**
00066  * @brief Send a auth_key message
00067  * @param chan MAVLink channel to send the message
00068  *
00069  * @param key key
00070  */
00071 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
00072 
00073 static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char* key)
00074 {
00075     mavlink_message_t msg;
00076     mavlink_msg_auth_key_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, key);
00077     mavlink_send_uart(chan, &msg);
00078 }
00079 
00080 #endif
00081 // MESSAGE AUTH_KEY UNPACKING
00082 
00083 /**
00084  * @brief Get field key from auth_key message
00085  *
00086  * @return key
00087  */
00088 static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char* r_data)
00089 {
00090 
00091     memcpy(r_data, msg->payload, sizeof(char)*32);
00092     return sizeof(char)*32;
00093 }
00094 
00095 /**
00096  * @brief Decode a auth_key message into a struct
00097  *
00098  * @param msg The message to decode
00099  * @param auth_key C-struct to decode the message contents into
00100  */
00101 static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key)
00102 {
00103     mavlink_msg_auth_key_get_key(msg, auth_key->key);
00104 }