raw.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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, SubGhzPresetDefinition
  18. * @return true On success
  19. */
  20. bool subghz_protocol_raw_save_to_file_init(
  21. SubGhzProtocolDecoderRAW* instance,
  22. const char* dev_name,
  23. SubGhzPresetDefinition* 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 true On success
  63. */
  64. bool subghz_protocol_decoder_raw_deserialize(void* context, FlipperFormat* flipper_format);
  65. /**
  66. * Getting a textual representation of the received data.
  67. * @param context Pointer to a SubGhzProtocolDecoderRAW instance
  68. * @param output Resulting text
  69. */
  70. void subghz_protocol_decoder_raw_get_string(void* context, FuriString* output);
  71. /**
  72. * Allocate SubGhzProtocolEncoderRAW.
  73. * @param environment Pointer to a SubGhzEnvironment instance
  74. * @return SubGhzProtocolEncoderRAW* pointer to a SubGhzProtocolEncoderRAW instance
  75. */
  76. void* subghz_protocol_encoder_raw_alloc(SubGhzEnvironment* environment);
  77. /**
  78. * Free SubGhzProtocolEncoderRAW.
  79. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  80. */
  81. void subghz_protocol_encoder_raw_free(void* context);
  82. /**
  83. * Forced transmission stop.
  84. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  85. */
  86. void subghz_protocol_encoder_raw_stop(void* context);
  87. /**
  88. * Set callback on completion of file transfer.
  89. * @param instance Pointer to a SubGhzProtocolEncoderRAW instance
  90. * @param callback_end Callback, SubGhzProtocolEncoderRAWCallbackEnd
  91. * @param context_end Context
  92. */
  93. void subghz_protocol_raw_file_encoder_worker_set_callback_end(
  94. SubGhzProtocolEncoderRAW* instance,
  95. SubGhzProtocolEncoderRAWCallbackEnd callback_end,
  96. void* context_end);
  97. /**
  98. * File generation for RAW work.
  99. * @param flipper_format Pointer to a FlipperFormat instance
  100. * @param file_path File path
  101. */
  102. void subghz_protocol_raw_gen_fff_data(FlipperFormat* flipper_format, const char* file_path);
  103. /**
  104. * Deserialize and generating an upload to send.
  105. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  106. * @param flipper_format Pointer to a FlipperFormat instance
  107. * @return true On success
  108. */
  109. bool subghz_protocol_encoder_raw_deserialize(void* context, FlipperFormat* flipper_format);
  110. /**
  111. * Getting the level and duration of the upload to be loaded into DMA.
  112. * @param context Pointer to a SubGhzProtocolEncoderRAW instance
  113. * @return LevelDuration
  114. */
  115. LevelDuration subghz_protocol_encoder_raw_yield(void* context);
  116. #ifdef __cplusplus
  117. }
  118. #endif