Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
MAVlink/include/common/mavlink_msg_auth_key.h@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | // MESSAGE AUTH_KEY PACKING |
shimniok | 0:826c6171fc1b | 2 | |
shimniok | 0:826c6171fc1b | 3 | #define MAVLINK_MSG_ID_AUTH_KEY 7 |
shimniok | 0:826c6171fc1b | 4 | |
shimniok | 0:826c6171fc1b | 5 | typedef struct __mavlink_auth_key_t |
shimniok | 0:826c6171fc1b | 6 | { |
shimniok | 0:826c6171fc1b | 7 | char key[32]; ///< key |
shimniok | 0:826c6171fc1b | 8 | |
shimniok | 0:826c6171fc1b | 9 | } mavlink_auth_key_t; |
shimniok | 0:826c6171fc1b | 10 | |
shimniok | 0:826c6171fc1b | 11 | #define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32 |
shimniok | 0:826c6171fc1b | 12 | |
shimniok | 0:826c6171fc1b | 13 | |
shimniok | 0:826c6171fc1b | 14 | /** |
shimniok | 0:826c6171fc1b | 15 | * @brief Pack a auth_key message |
shimniok | 0:826c6171fc1b | 16 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 17 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 18 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 19 | * |
shimniok | 0:826c6171fc1b | 20 | * @param key key |
shimniok | 0:826c6171fc1b | 21 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 22 | */ |
shimniok | 0:826c6171fc1b | 23 | static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const char* key) |
shimniok | 0:826c6171fc1b | 24 | { |
shimniok | 0:826c6171fc1b | 25 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 26 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; |
shimniok | 0:826c6171fc1b | 27 | |
shimniok | 0:826c6171fc1b | 28 | i += put_array_by_index((const int8_t*)key, sizeof(char)*32, i, msg->payload); // key |
shimniok | 0:826c6171fc1b | 29 | |
shimniok | 0:826c6171fc1b | 30 | return mavlink_finalize_message(msg, system_id, component_id, i); |
shimniok | 0:826c6171fc1b | 31 | } |
shimniok | 0:826c6171fc1b | 32 | |
shimniok | 0:826c6171fc1b | 33 | /** |
shimniok | 0:826c6171fc1b | 34 | * @brief Pack a auth_key message |
shimniok | 0:826c6171fc1b | 35 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 36 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 37 | * @param chan The MAVLink channel this message was sent over |
shimniok | 0:826c6171fc1b | 38 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 39 | * @param key key |
shimniok | 0:826c6171fc1b | 40 | * @return length of the message in bytes (excluding serial stream start sign) |
shimniok | 0:826c6171fc1b | 41 | */ |
shimniok | 0:826c6171fc1b | 42 | 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) |
shimniok | 0:826c6171fc1b | 43 | { |
shimniok | 0:826c6171fc1b | 44 | uint16_t i = 0; |
shimniok | 0:826c6171fc1b | 45 | msg->msgid = MAVLINK_MSG_ID_AUTH_KEY; |
shimniok | 0:826c6171fc1b | 46 | |
shimniok | 0:826c6171fc1b | 47 | i += put_array_by_index((const int8_t*)key, sizeof(char)*32, i, msg->payload); // key |
shimniok | 0:826c6171fc1b | 48 | |
shimniok | 0:826c6171fc1b | 49 | return mavlink_finalize_message_chan(msg, system_id, component_id, chan, i); |
shimniok | 0:826c6171fc1b | 50 | } |
shimniok | 0:826c6171fc1b | 51 | |
shimniok | 0:826c6171fc1b | 52 | /** |
shimniok | 0:826c6171fc1b | 53 | * @brief Encode a auth_key struct into a message |
shimniok | 0:826c6171fc1b | 54 | * |
shimniok | 0:826c6171fc1b | 55 | * @param system_id ID of this system |
shimniok | 0:826c6171fc1b | 56 | * @param component_id ID of this component (e.g. 200 for IMU) |
shimniok | 0:826c6171fc1b | 57 | * @param msg The MAVLink message to compress the data into |
shimniok | 0:826c6171fc1b | 58 | * @param auth_key C-struct to read the message contents from |
shimniok | 0:826c6171fc1b | 59 | */ |
shimniok | 0:826c6171fc1b | 60 | 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) |
shimniok | 0:826c6171fc1b | 61 | { |
shimniok | 0:826c6171fc1b | 62 | return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key); |
shimniok | 0:826c6171fc1b | 63 | } |
shimniok | 0:826c6171fc1b | 64 | |
shimniok | 0:826c6171fc1b | 65 | /** |
shimniok | 0:826c6171fc1b | 66 | * @brief Send a auth_key message |
shimniok | 0:826c6171fc1b | 67 | * @param chan MAVLink channel to send the message |
shimniok | 0:826c6171fc1b | 68 | * |
shimniok | 0:826c6171fc1b | 69 | * @param key key |
shimniok | 0:826c6171fc1b | 70 | */ |
shimniok | 0:826c6171fc1b | 71 | #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS |
shimniok | 0:826c6171fc1b | 72 | |
shimniok | 0:826c6171fc1b | 73 | static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char* key) |
shimniok | 0:826c6171fc1b | 74 | { |
shimniok | 0:826c6171fc1b | 75 | mavlink_message_t msg; |
shimniok | 0:826c6171fc1b | 76 | mavlink_msg_auth_key_pack_chan(mavlink_system.sysid, mavlink_system.compid, chan, &msg, key); |
shimniok | 0:826c6171fc1b | 77 | mavlink_send_uart(chan, &msg); |
shimniok | 0:826c6171fc1b | 78 | } |
shimniok | 0:826c6171fc1b | 79 | |
shimniok | 0:826c6171fc1b | 80 | #endif |
shimniok | 0:826c6171fc1b | 81 | // MESSAGE AUTH_KEY UNPACKING |
shimniok | 0:826c6171fc1b | 82 | |
shimniok | 0:826c6171fc1b | 83 | /** |
shimniok | 0:826c6171fc1b | 84 | * @brief Get field key from auth_key message |
shimniok | 0:826c6171fc1b | 85 | * |
shimniok | 0:826c6171fc1b | 86 | * @return key |
shimniok | 0:826c6171fc1b | 87 | */ |
shimniok | 0:826c6171fc1b | 88 | static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char* r_data) |
shimniok | 0:826c6171fc1b | 89 | { |
shimniok | 0:826c6171fc1b | 90 | |
shimniok | 0:826c6171fc1b | 91 | memcpy(r_data, msg->payload, sizeof(char)*32); |
shimniok | 0:826c6171fc1b | 92 | return sizeof(char)*32; |
shimniok | 0:826c6171fc1b | 93 | } |
shimniok | 0:826c6171fc1b | 94 | |
shimniok | 0:826c6171fc1b | 95 | /** |
shimniok | 0:826c6171fc1b | 96 | * @brief Decode a auth_key message into a struct |
shimniok | 0:826c6171fc1b | 97 | * |
shimniok | 0:826c6171fc1b | 98 | * @param msg The message to decode |
shimniok | 0:826c6171fc1b | 99 | * @param auth_key C-struct to decode the message contents into |
shimniok | 0:826c6171fc1b | 100 | */ |
shimniok | 0:826c6171fc1b | 101 | static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key) |
shimniok | 0:826c6171fc1b | 102 | { |
shimniok | 0:826c6171fc1b | 103 | mavlink_msg_auth_key_get_key(msg, auth_key->key); |
shimniok | 0:826c6171fc1b | 104 | } |