lfrfid_reader.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. /**
  3. * @file lfrfid_reader.h
  4. * @brief EM4100 tag reader, inspired by applications/main/lfrfid/lfrfid_cli.c
  5. * @details This file contains the declaration of the LFRFIDReader structure and its functions. You typically allocate a new LFRFIDReader, set the tag detection callback, start the reader. The tag detection callback is called each time a tag is detected. Once you are done, you stop the reader and free it.
  6. * @author CodeAllNight (MrDerekJamison)
  7. */
  8. #include <furi.h>
  9. typedef struct LFRFIDReader LFRFIDReader;
  10. /**
  11. * @brief Callback function for tag detection.
  12. * @param data Tag data.
  13. * @param length Tag data length.
  14. * @param context Callback context.
  15. */
  16. typedef void (*LFRFIDReaderTagCallback)(uint8_t* data, uint8_t length, void* context);
  17. /**
  18. * @brief Allocates a new LFRFIDReader.
  19. * @return LFRFIDReader* Pointer to the allocated LFRFIDReader.
  20. */
  21. LFRFIDReader* lfrfid_reader_alloc();
  22. /**
  23. * @brief Sets the tag detection callback.
  24. * @param reader LFRFIDReader to set the callback for.
  25. * @param requested_protocol Requested protocol, e.g. "EM4100".
  26. * @param callback Callback function.
  27. * @param context Callback context.
  28. */
  29. void lfrfid_reader_set_tag_callback(
  30. LFRFIDReader* reader,
  31. char* requested_protocol,
  32. LFRFIDReaderTagCallback callback,
  33. void* context);
  34. /**
  35. * @brief Starts the LFRFIDReader.
  36. * @param reader LFRFIDReader to start.
  37. */
  38. void lfrfid_reader_start(LFRFIDReader* reader);
  39. /**
  40. * @brief Stops the LFRFIDReader.
  41. * @param reader LFRFIDReader to stop.
  42. */
  43. void lfrfid_reader_stop(LFRFIDReader* reader);
  44. /**
  45. * @brief Frees the LFRFIDReader.
  46. * @param reader LFRFIDReader to free.
  47. */
  48. void lfrfid_reader_free(LFRFIDReader* reader);