raw.h 4.7 KB

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