receiver.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include "types.h"
  3. #include "protocols/base.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct SubGhzReceiver SubGhzReceiver;
  8. typedef void (*SubGhzReceiverCallback)(
  9. SubGhzReceiver* decoder,
  10. SubGhzProtocolDecoderBase* decoder_base,
  11. void* context);
  12. /**
  13. * Allocate and init SubGhzReceiver.
  14. * @param environment Pointer to a SubGhzEnvironment instance
  15. * @return SubGhzReceiver* pointer to a SubGhzReceiver instance
  16. */
  17. SubGhzReceiver* subghz_receiver_alloc_init(SubGhzEnvironment* environment);
  18. /**
  19. * Free SubGhzReceiver.
  20. * @param instance Pointer to a SubGhzReceiver instance
  21. */
  22. void subghz_receiver_free(SubGhzReceiver* instance);
  23. /**
  24. * Parse a raw sequence of levels and durations received from the air.
  25. * @param instance Pointer to a SubGhzReceiver instance
  26. * @param level Signal level true-high false-low
  27. * @param duration Duration of this level in, us
  28. */
  29. void subghz_receiver_decode(SubGhzReceiver* instance, bool level, uint32_t duration);
  30. /**
  31. * Reset decoder SubGhzReceiver.
  32. * @param instance Pointer to a SubGhzReceiver instance
  33. */
  34. void subghz_receiver_reset(SubGhzReceiver* instance);
  35. /**
  36. * Set a callback upon completion of successful decoding of one of the protocols.
  37. * @param instance Pointer to a SubGhzReceiver instance
  38. * @param callback Callback, SubGhzReceiverCallback
  39. * @param context Context
  40. */
  41. void subghz_receiver_set_rx_callback(
  42. SubGhzReceiver* instance,
  43. SubGhzReceiverCallback callback,
  44. void* context);
  45. /**
  46. * Set the filter of receivers that will work at the moment.
  47. * @param instance Pointer to a SubGhzReceiver instance
  48. * @param filter Filter, SubGhzProtocolFlag
  49. */
  50. void subghz_receiver_set_filter(SubGhzReceiver* instance, SubGhzProtocolFlag filter);
  51. /**
  52. * Search for a cattery by his name.
  53. * @param instance Pointer to a SubGhzReceiver instance
  54. * @param decoder_name Receiver name
  55. * @return SubGhzProtocolDecoderBase* pointer to a SubGhzProtocolDecoderBase instance
  56. */
  57. SubGhzProtocolDecoderBase*
  58. subghz_receiver_search_decoder_base_by_name(SubGhzReceiver* instance, const char* decoder_name);
  59. #ifdef __cplusplus
  60. }
  61. #endif