You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

213 lines
7.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #pragma once
  2. // MESSAGE AUTH_KEY PACKING
  3. #define MAVLINK_MSG_ID_AUTH_KEY 7
  4. MAVPACKED(
  5. typedef struct __mavlink_auth_key_t {
  6. char key[32]; /*< key*/
  7. }) mavlink_auth_key_t;
  8. #define MAVLINK_MSG_ID_AUTH_KEY_LEN 32
  9. #define MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN 32
  10. #define MAVLINK_MSG_ID_7_LEN 32
  11. #define MAVLINK_MSG_ID_7_MIN_LEN 32
  12. #define MAVLINK_MSG_ID_AUTH_KEY_CRC 119
  13. #define MAVLINK_MSG_ID_7_CRC 119
  14. #define MAVLINK_MSG_AUTH_KEY_FIELD_KEY_LEN 32
  15. #if MAVLINK_COMMAND_24BIT
  16. #define MAVLINK_MESSAGE_INFO_AUTH_KEY { \
  17. 7, \
  18. "AUTH_KEY", \
  19. 1, \
  20. { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \
  21. } \
  22. }
  23. #else
  24. #define MAVLINK_MESSAGE_INFO_AUTH_KEY { \
  25. "AUTH_KEY", \
  26. 1, \
  27. { { "key", NULL, MAVLINK_TYPE_CHAR, 32, 0, offsetof(mavlink_auth_key_t, key) }, \
  28. } \
  29. }
  30. #endif
  31. /**
  32. * @brief Pack a auth_key message
  33. * @param system_id ID of this system
  34. * @param component_id ID of this component (e.g. 200 for IMU)
  35. * @param msg The MAVLink message to compress the data into
  36. *
  37. * @param key key
  38. * @return length of the message in bytes (excluding serial stream start sign)
  39. */
  40. static inline uint16_t mavlink_msg_auth_key_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
  41. const char *key)
  42. {
  43. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  44. char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN];
  45. _mav_put_char_array(buf, 0, key, 32);
  46. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN);
  47. #else
  48. mavlink_auth_key_t packet;
  49. mav_array_memcpy(packet.key, key, sizeof(char)*32);
  50. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN);
  51. #endif
  52. msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
  53. return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
  54. }
  55. /**
  56. * @brief Pack a auth_key message on a channel
  57. * @param system_id ID of this system
  58. * @param component_id ID of this component (e.g. 200 for IMU)
  59. * @param chan The MAVLink channel this message will be sent over
  60. * @param msg The MAVLink message to compress the data into
  61. * @param key key
  62. * @return length of the message in bytes (excluding serial stream start sign)
  63. */
  64. static inline uint16_t mavlink_msg_auth_key_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
  65. mavlink_message_t* msg,
  66. const char *key)
  67. {
  68. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  69. char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN];
  70. _mav_put_char_array(buf, 0, key, 32);
  71. memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_AUTH_KEY_LEN);
  72. #else
  73. mavlink_auth_key_t packet;
  74. mav_array_memcpy(packet.key, key, sizeof(char)*32);
  75. memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_AUTH_KEY_LEN);
  76. #endif
  77. msg->msgid = MAVLINK_MSG_ID_AUTH_KEY;
  78. return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
  79. }
  80. /**
  81. * @brief Encode a auth_key struct
  82. *
  83. * @param system_id ID of this system
  84. * @param component_id ID of this component (e.g. 200 for IMU)
  85. * @param msg The MAVLink message to compress the data into
  86. * @param auth_key C-struct to read the message contents from
  87. */
  88. 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)
  89. {
  90. return mavlink_msg_auth_key_pack(system_id, component_id, msg, auth_key->key);
  91. }
  92. /**
  93. * @brief Encode a auth_key struct on a channel
  94. *
  95. * @param system_id ID of this system
  96. * @param component_id ID of this component (e.g. 200 for IMU)
  97. * @param chan The MAVLink channel this message will be sent over
  98. * @param msg The MAVLink message to compress the data into
  99. * @param auth_key C-struct to read the message contents from
  100. */
  101. static inline uint16_t mavlink_msg_auth_key_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_auth_key_t* auth_key)
  102. {
  103. return mavlink_msg_auth_key_pack_chan(system_id, component_id, chan, msg, auth_key->key);
  104. }
  105. /**
  106. * @brief Send a auth_key message
  107. * @param chan MAVLink channel to send the message
  108. *
  109. * @param key key
  110. */
  111. #ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
  112. static inline void mavlink_msg_auth_key_send(mavlink_channel_t chan, const char *key)
  113. {
  114. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  115. char buf[MAVLINK_MSG_ID_AUTH_KEY_LEN];
  116. _mav_put_char_array(buf, 0, key, 32);
  117. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
  118. #else
  119. mavlink_auth_key_t packet;
  120. mav_array_memcpy(packet.key, key, sizeof(char)*32);
  121. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)&packet, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
  122. #endif
  123. }
  124. /**
  125. * @brief Send a auth_key message
  126. * @param chan MAVLink channel to send the message
  127. * @param struct The MAVLink struct to serialize
  128. */
  129. static inline void mavlink_msg_auth_key_send_struct(mavlink_channel_t chan, const mavlink_auth_key_t* auth_key)
  130. {
  131. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  132. mavlink_msg_auth_key_send(chan, auth_key->key);
  133. #else
  134. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)auth_key, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
  135. #endif
  136. }
  137. #if MAVLINK_MSG_ID_AUTH_KEY_LEN <= MAVLINK_MAX_PAYLOAD_LEN
  138. /*
  139. This varient of _send() can be used to save stack space by re-using
  140. memory from the receive buffer. The caller provides a
  141. mavlink_message_t which is the size of a full mavlink message. This
  142. is usually the receive buffer for the channel, and allows a reply to an
  143. incoming message with minimum stack space usage.
  144. */
  145. static inline void mavlink_msg_auth_key_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, const char *key)
  146. {
  147. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  148. char *buf = (char *)msgbuf;
  149. _mav_put_char_array(buf, 0, key, 32);
  150. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, buf, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
  151. #else
  152. mavlink_auth_key_t *packet = (mavlink_auth_key_t *)msgbuf;
  153. mav_array_memcpy(packet->key, key, sizeof(char)*32);
  154. _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_AUTH_KEY, (const char *)packet, MAVLINK_MSG_ID_AUTH_KEY_MIN_LEN, MAVLINK_MSG_ID_AUTH_KEY_LEN, MAVLINK_MSG_ID_AUTH_KEY_CRC);
  155. #endif
  156. }
  157. #endif
  158. #endif
  159. // MESSAGE AUTH_KEY UNPACKING
  160. /**
  161. * @brief Get field key from auth_key message
  162. *
  163. * @return key
  164. */
  165. static inline uint16_t mavlink_msg_auth_key_get_key(const mavlink_message_t* msg, char *key)
  166. {
  167. return _MAV_RETURN_char_array(msg, key, 32, 0);
  168. }
  169. /**
  170. * @brief Decode a auth_key message into a struct
  171. *
  172. * @param msg The message to decode
  173. * @param auth_key C-struct to decode the message contents into
  174. */
  175. static inline void mavlink_msg_auth_key_decode(const mavlink_message_t* msg, mavlink_auth_key_t* auth_key)
  176. {
  177. #if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
  178. mavlink_msg_auth_key_get_key(msg, auth_key->key);
  179. #else
  180. uint8_t len = msg->len < MAVLINK_MSG_ID_AUTH_KEY_LEN? msg->len : MAVLINK_MSG_ID_AUTH_KEY_LEN;
  181. memset(auth_key, 0, MAVLINK_MSG_ID_AUTH_KEY_LEN);
  182. memcpy(auth_key, _MAV_PAYLOAD(msg), len);
  183. #endif
  184. }