megacode.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #pragma once
  2. #include "base.h"
  3. #define SUBGHZ_PROTOCOL_MEGACODE_NAME "MegaCode"
  4. typedef struct SubGhzProtocolDecoderMegaCode SubGhzProtocolDecoderMegaCode;
  5. typedef struct SubGhzProtocolEncoderMegaCode SubGhzProtocolEncoderMegaCode;
  6. extern const SubGhzProtocolDecoder subghz_protocol_megacode_decoder;
  7. extern const SubGhzProtocolEncoder subghz_protocol_megacode_encoder;
  8. extern const SubGhzProtocol subghz_protocol_megacode;
  9. /**
  10. * Allocate SubGhzProtocolEncoderMegaCode.
  11. * @param environment Pointer to a SubGhzEnvironment instance
  12. * @return SubGhzProtocolEncoderMegaCode* pointer to a SubGhzProtocolEncoderMegaCode instance
  13. */
  14. void* subghz_protocol_encoder_megacode_alloc(SubGhzEnvironment* environment);
  15. /**
  16. * Free SubGhzProtocolEncoderMegaCode.
  17. * @param context Pointer to a SubGhzProtocolEncoderMegaCode instance
  18. */
  19. void subghz_protocol_encoder_megacode_free(void* context);
  20. /**
  21. * Deserialize and generating an upload to send.
  22. * @param context Pointer to a SubGhzProtocolEncoderMegaCode instance
  23. * @param flipper_format Pointer to a FlipperFormat instance
  24. * @return true On success
  25. */
  26. bool subghz_protocol_encoder_megacode_deserialize(void* context, FlipperFormat* flipper_format);
  27. /**
  28. * Forced transmission stop.
  29. * @param context Pointer to a SubGhzProtocolEncoderMegaCode instance
  30. */
  31. void subghz_protocol_encoder_megacode_stop(void* context);
  32. /**
  33. * Getting the level and duration of the upload to be loaded into DMA.
  34. * @param context Pointer to a SubGhzProtocolEncoderMegaCode instance
  35. * @return LevelDuration
  36. */
  37. LevelDuration subghz_protocol_encoder_megacode_yield(void* context);
  38. /**
  39. * Allocate SubGhzProtocolDecoderMegaCode.
  40. * @param environment Pointer to a SubGhzEnvironment instance
  41. * @return SubGhzProtocolDecoderMegaCode* pointer to a SubGhzProtocolDecoderMegaCode instance
  42. */
  43. void* subghz_protocol_decoder_megacode_alloc(SubGhzEnvironment* environment);
  44. /**
  45. * Free SubGhzProtocolDecoderMegaCode.
  46. * @param context Pointer to a SubGhzProtocolDecoderMegaCode instance
  47. */
  48. void subghz_protocol_decoder_megacode_free(void* context);
  49. /**
  50. * Reset decoder SubGhzProtocolDecoderMegaCode.
  51. * @param context Pointer to a SubGhzProtocolDecoderMegaCode instance
  52. */
  53. void subghz_protocol_decoder_megacode_reset(void* context);
  54. /**
  55. * Parse a raw sequence of levels and durations received from the air.
  56. * @param context Pointer to a SubGhzProtocolDecoderMegaCode instance
  57. * @param level Signal level true-high false-low
  58. * @param duration Duration of this level in, us
  59. */
  60. void subghz_protocol_decoder_megacode_feed(void* context, bool level, uint32_t duration);
  61. /**
  62. * Getting the hash sum of the last randomly received parcel.
  63. * @param context Pointer to a SubGhzProtocolDecoderMegaCode instance
  64. * @return hash Hash sum
  65. */
  66. uint8_t subghz_protocol_decoder_megacode_get_hash_data(void* context);
  67. /**
  68. * Serialize data SubGhzProtocolDecoderMegaCode.
  69. * @param context Pointer to a SubGhzProtocolDecoderMegaCode instance
  70. * @param flipper_format Pointer to a FlipperFormat instance
  71. * @param preset The modulation on which the signal was received, SubGhzPresetDefinition
  72. * @return true On success
  73. */
  74. bool subghz_protocol_decoder_megacode_serialize(
  75. void* context,
  76. FlipperFormat* flipper_format,
  77. SubGhzPresetDefinition* preset);
  78. /**
  79. * Deserialize data SubGhzProtocolDecoderMegaCode.
  80. * @param context Pointer to a SubGhzProtocolDecoderMegaCode instance
  81. * @param flipper_format Pointer to a FlipperFormat instance
  82. * @return true On success
  83. */
  84. bool subghz_protocol_decoder_megacode_deserialize(void* context, FlipperFormat* flipper_format);
  85. /**
  86. * Getting a textual representation of the received data.
  87. * @param context Pointer to a SubGhzProtocolDecoderMegaCode instance
  88. * @param output Resulting text
  89. */
  90. void subghz_protocol_decoder_megacode_get_string(void* context, string_t output);