raw.h 4.6 KB

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