base.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include "../types.h"
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. typedef struct SubGhzProtocolDecoderBase SubGhzProtocolDecoderBase;
  7. typedef void (
  8. *SubGhzProtocolDecoderBaseRxCallback)(SubGhzProtocolDecoderBase* instance, void* context);
  9. typedef void (
  10. *SubGhzProtocolDecoderBaseSerialize)(SubGhzProtocolDecoderBase* decoder_base, string_t output);
  11. struct SubGhzProtocolDecoderBase {
  12. // Decoder general section
  13. const SubGhzProtocol* protocol;
  14. // Callback section
  15. SubGhzProtocolDecoderBaseRxCallback callback;
  16. void* context;
  17. };
  18. /**
  19. * Set a callback upon completion of successful decoding of one of the protocols.
  20. * @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
  21. * @param callback Callback, SubGhzProtocolDecoderBaseRxCallback
  22. * @param context Context
  23. */
  24. void subghz_protocol_decoder_base_set_decoder_callback(
  25. SubGhzProtocolDecoderBase* decoder_base,
  26. SubGhzProtocolDecoderBaseRxCallback callback,
  27. void* context);
  28. /**
  29. * Getting a textual representation of the received data.
  30. * @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
  31. * @param output Resulting text
  32. */
  33. bool subghz_protocol_decoder_base_get_string(
  34. SubGhzProtocolDecoderBase* decoder_base,
  35. string_t output);
  36. /**
  37. * Serialize data SubGhzProtocolDecoderBase.
  38. * @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
  39. * @param flipper_format Pointer to a FlipperFormat instance
  40. * @param preset The modulation on which the signal was received, SubGhzPresetDefinition
  41. * @return true On success
  42. */
  43. bool subghz_protocol_decoder_base_serialize(
  44. SubGhzProtocolDecoderBase* decoder_base,
  45. FlipperFormat* flipper_format,
  46. SubGhzPresetDefinition* preset);
  47. /**
  48. * Deserialize data SubGhzProtocolDecoderBase.
  49. * @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
  50. * @param flipper_format Pointer to a FlipperFormat instance
  51. * @return true On success
  52. */
  53. bool subghz_protocol_decoder_base_deserialize(
  54. SubGhzProtocolDecoderBase* decoder_base,
  55. FlipperFormat* flipper_format);
  56. /**
  57. * Getting the hash sum of the last randomly received parcel.
  58. * @param decoder_base Pointer to a SubGhzProtocolDecoderBase instance
  59. * @return hash Hash sum
  60. */
  61. uint8_t subghz_protocol_decoder_base_get_hash_data(SubGhzProtocolDecoderBase* decoder_base);
  62. // Encoder Base
  63. typedef struct SubGhzProtocolEncoderBase SubGhzProtocolEncoderBase;
  64. struct SubGhzProtocolEncoderBase {
  65. // Decoder general section
  66. const SubGhzProtocol* protocol;
  67. // Callback section
  68. };
  69. #ifdef __cplusplus
  70. }
  71. #endif