base.h 2.5 KB

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