raw.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #pragma once
  2. #include "base.h"
  3. #define SUBGHZ_PROTOCOL_RAW_NAME "RAW"
  4. typedef void (*SubGhzProtocolEncoderRAWCallbackEnd)(void* context);
  5. typedef struct SubGhzProtocolDecoderRAW SubGhzProtocolDecoderRAW;
  6. typedef struct SubGhzProtocolEncoderRAW SubGhzProtocolEncoderRAW;
  7. extern const SubGhzProtocolDecoder subghz_protocol_raw_decoder;
  8. extern const SubGhzProtocolEncoder subghz_protocol_raw_encoder;
  9. extern const SubGhzProtocol subghz_protocol_raw;
  10. /**
  11. * Open file for writing
  12. * @param instance Pointer to a SubGhzProtocolDecoderRAW instance
  13. * @param dev_name File name
  14. * @param frequency The frequency at which the signal was received, Hz
  15. * @param preset The modulation on which the signal was received, FuriHalSubGhzPreset
  16. * @return true On success
  17. */
  18. bool subghz_protocol_raw_save_to_file_init(
  19. SubGhzProtocolDecoderRAW* instance,
  20. const char* dev_name,
  21. uint32_t frequency,
  22. FuriHalSubGhzPreset preset);
  23. /**
  24. * Stop writing file to flash
  25. * @param instance Pointer to a SubGhzProtocolDecoderRAW instance
  26. */
  27. void subghz_protocol_raw_save_to_file_stop(SubGhzProtocolDecoderRAW* instance);
  28. /**
  29. * Get the number of samples received SubGhzProtocolDecoderRAW.
  30. * @param instance Pointer to a SubGhzProtocolDecoderRAW instance
  31. * @return count of samples
  32. */
  33. size_t subghz_protocol_raw_get_sample_write(SubGhzProtocolDecoderRAW* instance);
  34. /**
  35. * Allocate SubGhzProtocolDecoderRAW.
  36. * @param environment Pointer to a SubGhzEnvironment instance
  37. * @return SubGhzProtocolDecoderRAW* pointer to a SubGhzProtocolDecoderRAW instance
  38. */
  39. void* subghz_protocol_decoder_raw_alloc(SubGhzEnvironment* environment);
  40. /**
  41. * Free SubGhzProtocolDecoderRAW.
  42. * @param context Pointer to a SubGhzProtocolDecoderRAW instance
  43. */
  44. void subghz_protocol_decoder_raw_free(void* context);
  45. /**
  46. * Reset decoder SubGhzProtocolDecoderRAW.
  47. * @param context Pointer to a SubGhzProtocolDecoderRAW instance
  48. */
  49. void subghz_protocol_decoder_raw_reset(void* context);
  50. /**
  51. * Parse a raw sequence of levels and durations received from the air.
  52. * @param context Pointer to a SubGhzProtocolDecoderRAW instance
  53. * @param level Signal level true-high false-low
  54. * @param duration Duration of this level in, us
  55. */
  56. void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t duration);
  57. /**
  58. * Getting a textual representation of the received data.
  59. * @param context Pointer to a SubGhzProtocolDecoderRAW instance
  60. * @param output Resulting text
  61. */
  62. void subghz_protocol_decoder_raw_get_string(void* context, string_t output);
  63. /**
  64. * Allocate SubGhzProtocolEncoderRAW.
  65. * @param environment Pointer to a SubGhzEnvironment instance
  66. * @return SubGhzProtocolEncoderRAW* pointer to a SubGhzProtocolEncoderRAW instance
  67. */
  68. void* subghz_protocol_encoder_raw_alloc(SubGhzEnvironment* environment);
  69. /**
  70. * Free SubGhzProtocolEncoderRAW.
  71. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  72. */
  73. void subghz_protocol_encoder_raw_free(void* context);
  74. /**
  75. * Forced transmission stop.
  76. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  77. */
  78. void subghz_protocol_encoder_raw_stop(void* context);
  79. /**
  80. * Сallback on completion of file transfer.
  81. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  82. */
  83. void subghz_protocol_raw_file_encoder_worker_callback_end(void* context);
  84. /**
  85. * Set callback on completion of file transfer.
  86. * @param instance Pointer to a SubGhzProtocolEncoderRAW instance
  87. * @param callback_end Callback, SubGhzProtocolEncoderRAWCallbackEnd
  88. * @param context_end Context
  89. */
  90. void subghz_protocol_raw_file_encoder_worker_set_callback_end(
  91. SubGhzProtocolEncoderRAW* instance,
  92. SubGhzProtocolEncoderRAWCallbackEnd callback_end,
  93. void* context_end);
  94. /**
  95. * File generation for RAW work.
  96. * @param flipper_format Pointer to a FlipperFormat instance
  97. * @param file_path File path
  98. */
  99. void subghz_protocol_raw_gen_fff_data(FlipperFormat* flipper_format, const char* file_path);
  100. /**
  101. * Deserialize and generating an upload to send.
  102. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  103. * @param flipper_format Pointer to a FlipperFormat instance
  104. * @return true On success
  105. */
  106. bool subghz_protocol_encoder_raw_deserialize(void* context, FlipperFormat* flipper_format);
  107. /**
  108. * Getting the level and duration of the upload to be loaded into DMA.
  109. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  110. * @return LevelDuration
  111. */
  112. LevelDuration subghz_protocol_encoder_raw_yield(void* context);