protocol_generic.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include "stdint.h"
  3. #include "stdbool.h"
  4. class ProtocolGeneric {
  5. public:
  6. /**
  7. * @brief Get the encoded data size
  8. *
  9. * @return uint8_t size of encoded data in bytes
  10. */
  11. virtual uint8_t get_encoded_data_size() = 0;
  12. /**
  13. * @brief Get the decoded data size
  14. *
  15. * @return uint8_t size of decoded data in bytes
  16. */
  17. virtual uint8_t get_decoded_data_size() = 0;
  18. /**
  19. * @brief encode decoded data
  20. *
  21. * @param decoded_data
  22. * @param decoded_data_size
  23. * @param encoded_data
  24. * @param encoded_data_size
  25. */
  26. virtual void encode(
  27. const uint8_t* decoded_data,
  28. const uint8_t decoded_data_size,
  29. uint8_t* encoded_data,
  30. const uint8_t encoded_data_size) = 0;
  31. /**
  32. * @brief decode encoded data
  33. *
  34. * @param encoded_data
  35. * @param encoded_data_size
  36. * @param decoded_data
  37. * @param decoded_data_size
  38. */
  39. virtual void decode(
  40. const uint8_t* encoded_data,
  41. const uint8_t encoded_data_size,
  42. uint8_t* decoded_data,
  43. const uint8_t decoded_data_size) = 0;
  44. /**
  45. * @brief fast check that data can be correctly decoded
  46. *
  47. * @param encoded_data
  48. * @param encoded_data_size
  49. * @return true - can be correctly decoded
  50. * @return false - cannot be correctly decoded
  51. */
  52. virtual bool can_be_decoded(const uint8_t* encoded_data, const uint8_t encoded_data_size) = 0;
  53. virtual ~ProtocolGeneric(){};
  54. };