receiver.h 2.0 KB

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