raw.h 4.3 KB

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