transport.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. parent class for handling transports
  3. */
  4. #pragma once
  5. #include "mavlink_msgs.h"
  6. /*
  7. abstraction for opendroneid transports
  8. */
  9. class Transport {
  10. public:
  11. Transport();
  12. virtual void init(void) = 0;
  13. virtual void update(void) = 0;
  14. uint8_t arm_status_check(const char *&reason);
  15. const mavlink_open_drone_id_location_t &get_location(void) const {
  16. return location;
  17. }
  18. const mavlink_open_drone_id_basic_id_t &get_basic_id(void) const {
  19. return basic_id;
  20. }
  21. const mavlink_open_drone_id_authentication_t &get_authentication(void) const {
  22. return authentication;
  23. }
  24. const mavlink_open_drone_id_self_id_t &get_self_id(void) const {
  25. return self_id;
  26. }
  27. const mavlink_open_drone_id_system_t &get_system(void) const {
  28. return system;
  29. }
  30. const mavlink_open_drone_id_operator_id_t &get_operator_id(void) const {
  31. return operator_id;
  32. }
  33. uint32_t get_last_location_ms(void) const {
  34. return last_location_ms;
  35. }
  36. uint32_t get_last_system_ms(void) const {
  37. return last_system_ms;
  38. }
  39. void set_parse_fail(const char *msg) {
  40. parse_fail = msg;
  41. }
  42. const char *get_parse_fail(void) {
  43. return parse_fail;
  44. }
  45. protected:
  46. // common variables between transports. The last message of each
  47. // type, no matter what transport it was on, wins
  48. static const char *parse_fail;
  49. static uint32_t last_location_ms;
  50. static uint32_t last_basic_id_ms;
  51. static uint32_t last_self_id_ms;
  52. static uint32_t last_operator_id_ms;
  53. static uint32_t last_system_ms;
  54. static mavlink_open_drone_id_location_t location;
  55. static mavlink_open_drone_id_basic_id_t basic_id;
  56. static mavlink_open_drone_id_authentication_t authentication;
  57. static mavlink_open_drone_id_self_id_t self_id;
  58. static mavlink_open_drone_id_system_t system;
  59. static mavlink_open_drone_id_operator_id_t operator_id;
  60. void make_session_key(uint8_t key[8]) const;
  61. /*
  62. check signature in a command against public keys
  63. */
  64. bool check_signature(uint8_t sig_length, uint8_t data_len, uint32_t sequence, uint32_t operation,
  65. const uint8_t *data);
  66. uint8_t session_key[8];
  67. };