dronecan.remoteid.System.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <canard.h>
  5. #define DRONECAN_REMOTEID_SYSTEM_MAX_SIZE 53
  6. #define DRONECAN_REMOTEID_SYSTEM_SIGNATURE (0x9AC872F49BF32437ULL)
  7. #define DRONECAN_REMOTEID_SYSTEM_ID 20033
  8. #define DRONECAN_REMOTEID_SYSTEM_ODID_OPERATOR_LOCATION_TYPE_TAKEOFF 0
  9. #define DRONECAN_REMOTEID_SYSTEM_ODID_OPERATOR_LOCATION_TYPE_LIVE_GNSS 1
  10. #define DRONECAN_REMOTEID_SYSTEM_ODID_OPERATOR_LOCATION_TYPE_FIXED 2
  11. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASSIFICATION_TYPE_EU 0
  12. #define DRONECAN_REMOTEID_SYSTEM_ODID_CATEGORY_EU_UNDECLARED 0
  13. #define DRONECAN_REMOTEID_SYSTEM_ODID_CATEGORY_EU_OPEN 1
  14. #define DRONECAN_REMOTEID_SYSTEM_ODID_CATEGORY_EU_SPECIFIC 2
  15. #define DRONECAN_REMOTEID_SYSTEM_ODID_CATEGORY_EU_CERTIFIED 3
  16. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASS_EU_UNDECLARED 0
  17. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASS_EU_CLASS_0 1
  18. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASS_EU_CLASS_1 2
  19. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASS_EU_CLASS_2 3
  20. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASS_EU_CLASS_3 4
  21. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASS_EU_CLASS_4 5
  22. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASS_EU_CLASS_5 6
  23. #define DRONECAN_REMOTEID_SYSTEM_ODID_CLASS_EU_CLASS_6 7
  24. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  25. class dronecan_remoteid_System_cxx_iface;
  26. #endif
  27. struct dronecan_remoteid_System {
  28. #if defined(__cplusplus) && defined(DRONECAN_CXX_WRAPPERS)
  29. using cxx_iface = dronecan_remoteid_System_cxx_iface;
  30. #endif
  31. struct { uint8_t len; uint8_t data[20]; }id_or_mac;
  32. uint8_t operator_location_type;
  33. uint8_t classification_type;
  34. int32_t operator_latitude;
  35. int32_t operator_longitude;
  36. uint16_t area_count;
  37. uint16_t area_radius;
  38. float area_ceiling;
  39. float area_floor;
  40. uint8_t category_eu;
  41. uint8_t class_eu;
  42. float operator_altitude_geo;
  43. uint32_t timestamp;
  44. };
  45. #ifdef __cplusplus
  46. extern "C"
  47. {
  48. #endif
  49. uint32_t dronecan_remoteid_System_encode(struct dronecan_remoteid_System* msg, uint8_t* buffer
  50. #if CANARD_ENABLE_TAO_OPTION
  51. , bool tao
  52. #endif
  53. );
  54. bool dronecan_remoteid_System_decode(const CanardRxTransfer* transfer, struct dronecan_remoteid_System* msg);
  55. #if defined(CANARD_DSDLC_INTERNAL)
  56. static inline void _dronecan_remoteid_System_encode(uint8_t* buffer, uint32_t* bit_ofs, struct dronecan_remoteid_System* msg, bool tao);
  57. static inline bool _dronecan_remoteid_System_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct dronecan_remoteid_System* msg, bool tao);
  58. void _dronecan_remoteid_System_encode(uint8_t* buffer, uint32_t* bit_ofs, struct dronecan_remoteid_System* msg, bool tao) {
  59. (void)buffer;
  60. (void)bit_ofs;
  61. (void)msg;
  62. (void)tao;
  63. #pragma GCC diagnostic push
  64. #pragma GCC diagnostic ignored "-Wtype-limits"
  65. const uint8_t id_or_mac_len = msg->id_or_mac.len > 20 ? 20 : msg->id_or_mac.len;
  66. #pragma GCC diagnostic pop
  67. canardEncodeScalar(buffer, *bit_ofs, 5, &id_or_mac_len);
  68. *bit_ofs += 5;
  69. for (size_t i=0; i < id_or_mac_len; i++) {
  70. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->id_or_mac.data[i]);
  71. *bit_ofs += 8;
  72. }
  73. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->operator_location_type);
  74. *bit_ofs += 8;
  75. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->classification_type);
  76. *bit_ofs += 8;
  77. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->operator_latitude);
  78. *bit_ofs += 32;
  79. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->operator_longitude);
  80. *bit_ofs += 32;
  81. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->area_count);
  82. *bit_ofs += 16;
  83. canardEncodeScalar(buffer, *bit_ofs, 16, &msg->area_radius);
  84. *bit_ofs += 16;
  85. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->area_ceiling);
  86. *bit_ofs += 32;
  87. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->area_floor);
  88. *bit_ofs += 32;
  89. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->category_eu);
  90. *bit_ofs += 8;
  91. canardEncodeScalar(buffer, *bit_ofs, 8, &msg->class_eu);
  92. *bit_ofs += 8;
  93. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->operator_altitude_geo);
  94. *bit_ofs += 32;
  95. canardEncodeScalar(buffer, *bit_ofs, 32, &msg->timestamp);
  96. *bit_ofs += 32;
  97. }
  98. /*
  99. decode dronecan_remoteid_System, return true on failure, false on success
  100. */
  101. bool _dronecan_remoteid_System_decode(const CanardRxTransfer* transfer, uint32_t* bit_ofs, struct dronecan_remoteid_System* msg, bool tao) {
  102. (void)transfer;
  103. (void)bit_ofs;
  104. (void)msg;
  105. (void)tao;
  106. canardDecodeScalar(transfer, *bit_ofs, 5, false, &msg->id_or_mac.len);
  107. *bit_ofs += 5;
  108. #pragma GCC diagnostic push
  109. #pragma GCC diagnostic ignored "-Wtype-limits"
  110. if (msg->id_or_mac.len > 20) {
  111. return true; /* invalid value */
  112. }
  113. #pragma GCC diagnostic pop
  114. for (size_t i=0; i < msg->id_or_mac.len; i++) {
  115. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->id_or_mac.data[i]);
  116. *bit_ofs += 8;
  117. }
  118. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->operator_location_type);
  119. *bit_ofs += 8;
  120. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->classification_type);
  121. *bit_ofs += 8;
  122. canardDecodeScalar(transfer, *bit_ofs, 32, true, &msg->operator_latitude);
  123. *bit_ofs += 32;
  124. canardDecodeScalar(transfer, *bit_ofs, 32, true, &msg->operator_longitude);
  125. *bit_ofs += 32;
  126. canardDecodeScalar(transfer, *bit_ofs, 16, false, &msg->area_count);
  127. *bit_ofs += 16;
  128. canardDecodeScalar(transfer, *bit_ofs, 16, false, &msg->area_radius);
  129. *bit_ofs += 16;
  130. canardDecodeScalar(transfer, *bit_ofs, 32, true, &msg->area_ceiling);
  131. *bit_ofs += 32;
  132. canardDecodeScalar(transfer, *bit_ofs, 32, true, &msg->area_floor);
  133. *bit_ofs += 32;
  134. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->category_eu);
  135. *bit_ofs += 8;
  136. canardDecodeScalar(transfer, *bit_ofs, 8, false, &msg->class_eu);
  137. *bit_ofs += 8;
  138. canardDecodeScalar(transfer, *bit_ofs, 32, true, &msg->operator_altitude_geo);
  139. *bit_ofs += 32;
  140. canardDecodeScalar(transfer, *bit_ofs, 32, false, &msg->timestamp);
  141. *bit_ofs += 32;
  142. return false; /* success */
  143. }
  144. #endif
  145. #ifdef CANARD_DSDLC_TEST_BUILD
  146. struct dronecan_remoteid_System sample_dronecan_remoteid_System_msg(void);
  147. #endif
  148. #ifdef __cplusplus
  149. } // extern "C"
  150. #ifdef DRONECAN_CXX_WRAPPERS
  151. #include <canard/cxx_wrappers.h>
  152. BROADCAST_MESSAGE_CXX_IFACE(dronecan_remoteid_System, DRONECAN_REMOTEID_SYSTEM_ID, DRONECAN_REMOTEID_SYSTEM_SIGNATURE, DRONECAN_REMOTEID_SYSTEM_MAX_SIZE);
  153. #endif
  154. #endif