Dependents:   AIT_UWB_Range

Committer:
bhepp
Date:
Mon Apr 04 11:18:57 2016 +0000
Revision:
10:bd4a08d39e94
Parent:
0:28183cc7963f
nop

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bhepp 0:28183cc7963f 1 // MESSAGE HEARTBEAT PACKING
bhepp 0:28183cc7963f 2
bhepp 0:28183cc7963f 3 #define MAVLINK_MSG_ID_HEARTBEAT 0
bhepp 0:28183cc7963f 4
bhepp 0:28183cc7963f 5 typedef struct __mavlink_heartbeat_t
bhepp 0:28183cc7963f 6 {
bhepp 0:28183cc7963f 7 uint32_t custom_mode; /*< A bitfield for use for autopilot-specific flags.*/
bhepp 0:28183cc7963f 8 uint8_t type; /*< Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)*/
bhepp 0:28183cc7963f 9 uint8_t autopilot; /*< Autopilot type / class. defined in MAV_AUTOPILOT ENUM*/
bhepp 0:28183cc7963f 10 uint8_t base_mode; /*< System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h*/
bhepp 0:28183cc7963f 11 uint8_t system_status; /*< System status flag, see MAV_STATE ENUM*/
bhepp 0:28183cc7963f 12 uint8_t mavlink_version; /*< MAVLink version, not writable by user, gets added by protocol because of magic data type: uint8_t_mavlink_version*/
bhepp 0:28183cc7963f 13 } mavlink_heartbeat_t;
bhepp 0:28183cc7963f 14
bhepp 0:28183cc7963f 15 #define MAVLINK_MSG_ID_HEARTBEAT_LEN 9
bhepp 0:28183cc7963f 16 #define MAVLINK_MSG_ID_0_LEN 9
bhepp 0:28183cc7963f 17
bhepp 0:28183cc7963f 18 #define MAVLINK_MSG_ID_HEARTBEAT_CRC 50
bhepp 0:28183cc7963f 19 #define MAVLINK_MSG_ID_0_CRC 50
bhepp 0:28183cc7963f 20
bhepp 0:28183cc7963f 21
bhepp 0:28183cc7963f 22
bhepp 0:28183cc7963f 23 #define MAVLINK_MESSAGE_INFO_HEARTBEAT { \
bhepp 0:28183cc7963f 24 "HEARTBEAT", \
bhepp 0:28183cc7963f 25 6, \
bhepp 0:28183cc7963f 26 { { "custom_mode", NULL, MAVLINK_TYPE_UINT32_T, 0, 0, offsetof(mavlink_heartbeat_t, custom_mode) }, \
bhepp 0:28183cc7963f 27 { "type", NULL, MAVLINK_TYPE_UINT8_T, 0, 4, offsetof(mavlink_heartbeat_t, type) }, \
bhepp 0:28183cc7963f 28 { "autopilot", NULL, MAVLINK_TYPE_UINT8_T, 0, 5, offsetof(mavlink_heartbeat_t, autopilot) }, \
bhepp 0:28183cc7963f 29 { "base_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 6, offsetof(mavlink_heartbeat_t, base_mode) }, \
bhepp 0:28183cc7963f 30 { "system_status", NULL, MAVLINK_TYPE_UINT8_T, 0, 7, offsetof(mavlink_heartbeat_t, system_status) }, \
bhepp 0:28183cc7963f 31 { "mavlink_version", NULL, MAVLINK_TYPE_UINT8_T, 0, 8, offsetof(mavlink_heartbeat_t, mavlink_version) }, \
bhepp 0:28183cc7963f 32 } \
bhepp 0:28183cc7963f 33 }
bhepp 0:28183cc7963f 34
bhepp 0:28183cc7963f 35
bhepp 0:28183cc7963f 36 /**
bhepp 0:28183cc7963f 37 * @brief Pack a heartbeat message
bhepp 0:28183cc7963f 38 * @param system_id ID of this system
bhepp 0:28183cc7963f 39 * @param component_id ID of this component (e.g. 200 for IMU)
bhepp 0:28183cc7963f 40 * @param msg The MAVLink message to compress the data into
bhepp 0:28183cc7963f 41 *
bhepp 0:28183cc7963f 42 * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)
bhepp 0:28183cc7963f 43 * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM
bhepp 0:28183cc7963f 44 * @param base_mode System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h
bhepp 0:28183cc7963f 45 * @param custom_mode A bitfield for use for autopilot-specific flags.
bhepp 0:28183cc7963f 46 * @param system_status System status flag, see MAV_STATE ENUM
bhepp 0:28183cc7963f 47 * @return length of the message in bytes (excluding serial stream start sign)
bhepp 0:28183cc7963f 48 */
bhepp 0:28183cc7963f 49 static inline uint16_t mavlink_msg_heartbeat_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
bhepp 0:28183cc7963f 50 uint8_t type, uint8_t autopilot, uint8_t base_mode, uint32_t custom_mode, uint8_t system_status)
bhepp 0:28183cc7963f 51 {
bhepp 0:28183cc7963f 52 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
bhepp 0:28183cc7963f 53 char buf[MAVLINK_MSG_ID_HEARTBEAT_LEN];
bhepp 0:28183cc7963f 54 _mav_put_uint32_t(buf, 0, custom_mode);
bhepp 0:28183cc7963f 55 _mav_put_uint8_t(buf, 4, type);
bhepp 0:28183cc7963f 56 _mav_put_uint8_t(buf, 5, autopilot);
bhepp 0:28183cc7963f 57 _mav_put_uint8_t(buf, 6, base_mode);
bhepp 0:28183cc7963f 58 _mav_put_uint8_t(buf, 7, system_status);
bhepp 0:28183cc7963f 59 _mav_put_uint8_t(buf, 8, 3);
bhepp 0:28183cc7963f 60
bhepp 0:28183cc7963f 61 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 62 #else
bhepp 0:28183cc7963f 63 mavlink_heartbeat_t packet;
bhepp 0:28183cc7963f 64 packet.custom_mode = custom_mode;
bhepp 0:28183cc7963f 65 packet.type = type;
bhepp 0:28183cc7963f 66 packet.autopilot = autopilot;
bhepp 0:28183cc7963f 67 packet.base_mode = base_mode;
bhepp 0:28183cc7963f 68 packet.system_status = system_status;
bhepp 0:28183cc7963f 69 packet.mavlink_version = 3;
bhepp 0:28183cc7963f 70
bhepp 0:28183cc7963f 71 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 72 #endif
bhepp 0:28183cc7963f 73
bhepp 0:28183cc7963f 74 msg->msgid = MAVLINK_MSG_ID_HEARTBEAT;
bhepp 0:28183cc7963f 75 #if MAVLINK_CRC_EXTRA
bhepp 0:28183cc7963f 76 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
bhepp 0:28183cc7963f 77 #else
bhepp 0:28183cc7963f 78 return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 79 #endif
bhepp 0:28183cc7963f 80 }
bhepp 0:28183cc7963f 81
bhepp 0:28183cc7963f 82 /**
bhepp 0:28183cc7963f 83 * @brief Pack a heartbeat message on a channel
bhepp 0:28183cc7963f 84 * @param system_id ID of this system
bhepp 0:28183cc7963f 85 * @param component_id ID of this component (e.g. 200 for IMU)
bhepp 0:28183cc7963f 86 * @param chan The MAVLink channel this message will be sent over
bhepp 0:28183cc7963f 87 * @param msg The MAVLink message to compress the data into
bhepp 0:28183cc7963f 88 * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)
bhepp 0:28183cc7963f 89 * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM
bhepp 0:28183cc7963f 90 * @param base_mode System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h
bhepp 0:28183cc7963f 91 * @param custom_mode A bitfield for use for autopilot-specific flags.
bhepp 0:28183cc7963f 92 * @param system_status System status flag, see MAV_STATE ENUM
bhepp 0:28183cc7963f 93 * @return length of the message in bytes (excluding serial stream start sign)
bhepp 0:28183cc7963f 94 */
bhepp 0:28183cc7963f 95 static inline uint16_t mavlink_msg_heartbeat_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
bhepp 0:28183cc7963f 96 mavlink_message_t* msg,
bhepp 0:28183cc7963f 97 uint8_t type,uint8_t autopilot,uint8_t base_mode,uint32_t custom_mode,uint8_t system_status)
bhepp 0:28183cc7963f 98 {
bhepp 0:28183cc7963f 99 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
bhepp 0:28183cc7963f 100 char buf[MAVLINK_MSG_ID_HEARTBEAT_LEN];
bhepp 0:28183cc7963f 101 _mav_put_uint32_t(buf, 0, custom_mode);
bhepp 0:28183cc7963f 102 _mav_put_uint8_t(buf, 4, type);
bhepp 0:28183cc7963f 103 _mav_put_uint8_t(buf, 5, autopilot);
bhepp 0:28183cc7963f 104 _mav_put_uint8_t(buf, 6, base_mode);
bhepp 0:28183cc7963f 105 _mav_put_uint8_t(buf, 7, system_status);
bhepp 0:28183cc7963f 106 _mav_put_uint8_t(buf, 8, 3);
bhepp 0:28183cc7963f 107
bhepp 0:28183cc7963f 108 memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 109 #else
bhepp 0:28183cc7963f 110 mavlink_heartbeat_t packet;
bhepp 0:28183cc7963f 111 packet.custom_mode = custom_mode;
bhepp 0:28183cc7963f 112 packet.type = type;
bhepp 0:28183cc7963f 113 packet.autopilot = autopilot;
bhepp 0:28183cc7963f 114 packet.base_mode = base_mode;
bhepp 0:28183cc7963f 115 packet.system_status = system_status;
bhepp 0:28183cc7963f 116 packet.mavlink_version = 3;
bhepp 0:28183cc7963f 117
bhepp 0:28183cc7963f 118 memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 119 #endif
bhepp 0:28183cc7963f 120
bhepp 0:28183cc7963f 121 msg->msgid = MAVLINK_MSG_ID_HEARTBEAT;
bhepp 0:28183cc7963f 122 #if MAVLINK_CRC_EXTRA
bhepp 0:28183cc7963f 123 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
bhepp 0:28183cc7963f 124 #else
bhepp 0:28183cc7963f 125 return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 126 #endif
bhepp 0:28183cc7963f 127 }
bhepp 0:28183cc7963f 128
bhepp 0:28183cc7963f 129 /**
bhepp 0:28183cc7963f 130 * @brief Encode a heartbeat struct
bhepp 0:28183cc7963f 131 *
bhepp 0:28183cc7963f 132 * @param system_id ID of this system
bhepp 0:28183cc7963f 133 * @param component_id ID of this component (e.g. 200 for IMU)
bhepp 0:28183cc7963f 134 * @param msg The MAVLink message to compress the data into
bhepp 0:28183cc7963f 135 * @param heartbeat C-struct to read the message contents from
bhepp 0:28183cc7963f 136 */
bhepp 0:28183cc7963f 137 static inline uint16_t mavlink_msg_heartbeat_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_heartbeat_t* heartbeat)
bhepp 0:28183cc7963f 138 {
bhepp 0:28183cc7963f 139 return mavlink_msg_heartbeat_pack(system_id, component_id, msg, heartbeat->type, heartbeat->autopilot, heartbeat->base_mode, heartbeat->custom_mode, heartbeat->system_status);
bhepp 0:28183cc7963f 140 }
bhepp 0:28183cc7963f 141
bhepp 0:28183cc7963f 142 /**
bhepp 0:28183cc7963f 143 * @brief Encode a heartbeat struct on a channel
bhepp 0:28183cc7963f 144 *
bhepp 0:28183cc7963f 145 * @param system_id ID of this system
bhepp 0:28183cc7963f 146 * @param component_id ID of this component (e.g. 200 for IMU)
bhepp 0:28183cc7963f 147 * @param chan The MAVLink channel this message will be sent over
bhepp 0:28183cc7963f 148 * @param msg The MAVLink message to compress the data into
bhepp 0:28183cc7963f 149 * @param heartbeat C-struct to read the message contents from
bhepp 0:28183cc7963f 150 */
bhepp 0:28183cc7963f 151 static inline uint16_t mavlink_msg_heartbeat_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_heartbeat_t* heartbeat)
bhepp 0:28183cc7963f 152 {
bhepp 0:28183cc7963f 153 return mavlink_msg_heartbeat_pack_chan(system_id, component_id, chan, msg, heartbeat->type, heartbeat->autopilot, heartbeat->base_mode, heartbeat->custom_mode, heartbeat->system_status);
bhepp 0:28183cc7963f 154 }
bhepp 0:28183cc7963f 155
bhepp 0:28183cc7963f 156 /**
bhepp 0:28183cc7963f 157 * @brief Send a heartbeat message
bhepp 0:28183cc7963f 158 * @param chan MAVLink channel to send the message
bhepp 0:28183cc7963f 159 *
bhepp 0:28183cc7963f 160 * @param type Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)
bhepp 0:28183cc7963f 161 * @param autopilot Autopilot type / class. defined in MAV_AUTOPILOT ENUM
bhepp 0:28183cc7963f 162 * @param base_mode System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h
bhepp 0:28183cc7963f 163 * @param custom_mode A bitfield for use for autopilot-specific flags.
bhepp 0:28183cc7963f 164 * @param system_status System status flag, see MAV_STATE ENUM
bhepp 0:28183cc7963f 165 */
bhepp 0:28183cc7963f 166 #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
bhepp 0:28183cc7963f 167
bhepp 0:28183cc7963f 168 static inline void mavlink_msg_heartbeat_send(mavlink_channel_t chan, uint8_t type, uint8_t autopilot, uint8_t base_mode, uint32_t custom_mode, uint8_t system_status)
bhepp 0:28183cc7963f 169 {
bhepp 0:28183cc7963f 170 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
bhepp 0:28183cc7963f 171 char buf[MAVLINK_MSG_ID_HEARTBEAT_LEN];
bhepp 0:28183cc7963f 172 _mav_put_uint32_t(buf, 0, custom_mode);
bhepp 0:28183cc7963f 173 _mav_put_uint8_t(buf, 4, type);
bhepp 0:28183cc7963f 174 _mav_put_uint8_t(buf, 5, autopilot);
bhepp 0:28183cc7963f 175 _mav_put_uint8_t(buf, 6, base_mode);
bhepp 0:28183cc7963f 176 _mav_put_uint8_t(buf, 7, system_status);
bhepp 0:28183cc7963f 177 _mav_put_uint8_t(buf, 8, 3);
bhepp 0:28183cc7963f 178
bhepp 0:28183cc7963f 179 #if MAVLINK_CRC_EXTRA
bhepp 0:28183cc7963f 180 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, buf, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
bhepp 0:28183cc7963f 181 #else
bhepp 0:28183cc7963f 182 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, buf, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 183 #endif
bhepp 0:28183cc7963f 184 #else
bhepp 0:28183cc7963f 185 mavlink_heartbeat_t packet;
bhepp 0:28183cc7963f 186 packet.custom_mode = custom_mode;
bhepp 0:28183cc7963f 187 packet.type = type;
bhepp 0:28183cc7963f 188 packet.autopilot = autopilot;
bhepp 0:28183cc7963f 189 packet.base_mode = base_mode;
bhepp 0:28183cc7963f 190 packet.system_status = system_status;
bhepp 0:28183cc7963f 191 packet.mavlink_version = 3;
bhepp 0:28183cc7963f 192
bhepp 0:28183cc7963f 193 #if MAVLINK_CRC_EXTRA
bhepp 0:28183cc7963f 194 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, (const char *)&packet, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
bhepp 0:28183cc7963f 195 #else
bhepp 0:28183cc7963f 196 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, (const char *)&packet, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 197 #endif
bhepp 0:28183cc7963f 198 #endif
bhepp 0:28183cc7963f 199 }
bhepp 0:28183cc7963f 200
bhepp 0:28183cc7963f 201 #if MAVLINK_MSG_ID_HEARTBEAT_LEN <= MAVLINK_MAX_PAYLOAD_LEN
bhepp 0:28183cc7963f 202 /*
bhepp 0:28183cc7963f 203 This varient of _send() can be used to save stack space by re-using
bhepp 0:28183cc7963f 204 memory from the receive buffer. The caller provides a
bhepp 0:28183cc7963f 205 mavlink_message_t which is the size of a full mavlink message. This
bhepp 0:28183cc7963f 206 is usually the receive buffer for the channel, and allows a reply to an
bhepp 0:28183cc7963f 207 incoming message with minimum stack space usage.
bhepp 0:28183cc7963f 208 */
bhepp 0:28183cc7963f 209 static inline void mavlink_msg_heartbeat_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t type, uint8_t autopilot, uint8_t base_mode, uint32_t custom_mode, uint8_t system_status)
bhepp 0:28183cc7963f 210 {
bhepp 0:28183cc7963f 211 #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
bhepp 0:28183cc7963f 212 char *buf = (char *)msgbuf;
bhepp 0:28183cc7963f 213 _mav_put_uint32_t(buf, 0, custom_mode);
bhepp 0:28183cc7963f 214 _mav_put_uint8_t(buf, 4, type);
bhepp 0:28183cc7963f 215 _mav_put_uint8_t(buf, 5, autopilot);
bhepp 0:28183cc7963f 216 _mav_put_uint8_t(buf, 6, base_mode);
bhepp 0:28183cc7963f 217 _mav_put_uint8_t(buf, 7, system_status);
bhepp 0:28183cc7963f 218 _mav_put_uint8_t(buf, 8, 3);
bhepp 0:28183cc7963f 219
bhepp 0:28183cc7963f 220 #if MAVLINK_CRC_EXTRA
bhepp 0:28183cc7963f 221 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, buf, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
bhepp 0:28183cc7963f 222 #else
bhepp 0:28183cc7963f 223 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, buf, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 224 #endif
bhepp 0:28183cc7963f 225 #else
bhepp 0:28183cc7963f 226 mavlink_heartbeat_t *packet = (mavlink_heartbeat_t *)msgbuf;
bhepp 0:28183cc7963f 227 packet->custom_mode = custom_mode;
bhepp 0:28183cc7963f 228 packet->type = type;
bhepp 0:28183cc7963f 229 packet->autopilot = autopilot;
bhepp 0:28183cc7963f 230 packet->base_mode = base_mode;
bhepp 0:28183cc7963f 231 packet->system_status = system_status;
bhepp 0:28183cc7963f 232 packet->mavlink_version = 3;
bhepp 0:28183cc7963f 233
bhepp 0:28183cc7963f 234 #if MAVLINK_CRC_EXTRA
bhepp 0:28183cc7963f 235 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, (const char *)packet, MAVLINK_MSG_ID_HEARTBEAT_LEN, MAVLINK_MSG_ID_HEARTBEAT_CRC);
bhepp 0:28183cc7963f 236 #else
bhepp 0:28183cc7963f 237 _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_HEARTBEAT, (const char *)packet, MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 238 #endif
bhepp 0:28183cc7963f 239 #endif
bhepp 0:28183cc7963f 240 }
bhepp 0:28183cc7963f 241 #endif
bhepp 0:28183cc7963f 242
bhepp 0:28183cc7963f 243 #endif
bhepp 0:28183cc7963f 244
bhepp 0:28183cc7963f 245 // MESSAGE HEARTBEAT UNPACKING
bhepp 0:28183cc7963f 246
bhepp 0:28183cc7963f 247
bhepp 0:28183cc7963f 248 /**
bhepp 0:28183cc7963f 249 * @brief Get field type from heartbeat message
bhepp 0:28183cc7963f 250 *
bhepp 0:28183cc7963f 251 * @return Type of the MAV (quadrotor, helicopter, etc., up to 15 types, defined in MAV_TYPE ENUM)
bhepp 0:28183cc7963f 252 */
bhepp 0:28183cc7963f 253 static inline uint8_t mavlink_msg_heartbeat_get_type(const mavlink_message_t* msg)
bhepp 0:28183cc7963f 254 {
bhepp 0:28183cc7963f 255 return _MAV_RETURN_uint8_t(msg, 4);
bhepp 0:28183cc7963f 256 }
bhepp 0:28183cc7963f 257
bhepp 0:28183cc7963f 258 /**
bhepp 0:28183cc7963f 259 * @brief Get field autopilot from heartbeat message
bhepp 0:28183cc7963f 260 *
bhepp 0:28183cc7963f 261 * @return Autopilot type / class. defined in MAV_AUTOPILOT ENUM
bhepp 0:28183cc7963f 262 */
bhepp 0:28183cc7963f 263 static inline uint8_t mavlink_msg_heartbeat_get_autopilot(const mavlink_message_t* msg)
bhepp 0:28183cc7963f 264 {
bhepp 0:28183cc7963f 265 return _MAV_RETURN_uint8_t(msg, 5);
bhepp 0:28183cc7963f 266 }
bhepp 0:28183cc7963f 267
bhepp 0:28183cc7963f 268 /**
bhepp 0:28183cc7963f 269 * @brief Get field base_mode from heartbeat message
bhepp 0:28183cc7963f 270 *
bhepp 0:28183cc7963f 271 * @return System mode bitfield, see MAV_MODE_FLAG ENUM in mavlink/include/mavlink_types.h
bhepp 0:28183cc7963f 272 */
bhepp 0:28183cc7963f 273 static inline uint8_t mavlink_msg_heartbeat_get_base_mode(const mavlink_message_t* msg)
bhepp 0:28183cc7963f 274 {
bhepp 0:28183cc7963f 275 return _MAV_RETURN_uint8_t(msg, 6);
bhepp 0:28183cc7963f 276 }
bhepp 0:28183cc7963f 277
bhepp 0:28183cc7963f 278 /**
bhepp 0:28183cc7963f 279 * @brief Get field custom_mode from heartbeat message
bhepp 0:28183cc7963f 280 *
bhepp 0:28183cc7963f 281 * @return A bitfield for use for autopilot-specific flags.
bhepp 0:28183cc7963f 282 */
bhepp 0:28183cc7963f 283 static inline uint32_t mavlink_msg_heartbeat_get_custom_mode(const mavlink_message_t* msg)
bhepp 0:28183cc7963f 284 {
bhepp 0:28183cc7963f 285 return _MAV_RETURN_uint32_t(msg, 0);
bhepp 0:28183cc7963f 286 }
bhepp 0:28183cc7963f 287
bhepp 0:28183cc7963f 288 /**
bhepp 0:28183cc7963f 289 * @brief Get field system_status from heartbeat message
bhepp 0:28183cc7963f 290 *
bhepp 0:28183cc7963f 291 * @return System status flag, see MAV_STATE ENUM
bhepp 0:28183cc7963f 292 */
bhepp 0:28183cc7963f 293 static inline uint8_t mavlink_msg_heartbeat_get_system_status(const mavlink_message_t* msg)
bhepp 0:28183cc7963f 294 {
bhepp 0:28183cc7963f 295 return _MAV_RETURN_uint8_t(msg, 7);
bhepp 0:28183cc7963f 296 }
bhepp 0:28183cc7963f 297
bhepp 0:28183cc7963f 298 /**
bhepp 0:28183cc7963f 299 * @brief Get field mavlink_version from heartbeat message
bhepp 0:28183cc7963f 300 *
bhepp 0:28183cc7963f 301 * @return MAVLink version, not writable by user, gets added by protocol because of magic data type: uint8_t_mavlink_version
bhepp 0:28183cc7963f 302 */
bhepp 0:28183cc7963f 303 static inline uint8_t mavlink_msg_heartbeat_get_mavlink_version(const mavlink_message_t* msg)
bhepp 0:28183cc7963f 304 {
bhepp 0:28183cc7963f 305 return _MAV_RETURN_uint8_t(msg, 8);
bhepp 0:28183cc7963f 306 }
bhepp 0:28183cc7963f 307
bhepp 0:28183cc7963f 308 /**
bhepp 0:28183cc7963f 309 * @brief Decode a heartbeat message into a struct
bhepp 0:28183cc7963f 310 *
bhepp 0:28183cc7963f 311 * @param msg The message to decode
bhepp 0:28183cc7963f 312 * @param heartbeat C-struct to decode the message contents into
bhepp 0:28183cc7963f 313 */
bhepp 0:28183cc7963f 314 static inline void mavlink_msg_heartbeat_decode(const mavlink_message_t* msg, mavlink_heartbeat_t* heartbeat)
bhepp 0:28183cc7963f 315 {
bhepp 0:28183cc7963f 316 #if MAVLINK_NEED_BYTE_SWAP
bhepp 0:28183cc7963f 317 heartbeat->custom_mode = mavlink_msg_heartbeat_get_custom_mode(msg);
bhepp 0:28183cc7963f 318 heartbeat->type = mavlink_msg_heartbeat_get_type(msg);
bhepp 0:28183cc7963f 319 heartbeat->autopilot = mavlink_msg_heartbeat_get_autopilot(msg);
bhepp 0:28183cc7963f 320 heartbeat->base_mode = mavlink_msg_heartbeat_get_base_mode(msg);
bhepp 0:28183cc7963f 321 heartbeat->system_status = mavlink_msg_heartbeat_get_system_status(msg);
bhepp 0:28183cc7963f 322 heartbeat->mavlink_version = mavlink_msg_heartbeat_get_mavlink_version(msg);
bhepp 0:28183cc7963f 323 #else
bhepp 0:28183cc7963f 324 memcpy(heartbeat, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_HEARTBEAT_LEN);
bhepp 0:28183cc7963f 325 #endif
bhepp 0:28183cc7963f 326 }