base.h 2.6 KB

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