gen1a_poller.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <nfc/nfc.h>
  3. #include <nfc/protocols/nfc_generic_event.h>
  4. #include <nfc/protocols/mf_classic/mf_classic.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef enum {
  9. Gen1aPollerEventTypeDetected,
  10. Gen1aPollerEventTypeRequestMode,
  11. Gen1aPollerEventTypeRequestDataToWrite,
  12. Gen1aPollerEventTypeSuccess,
  13. Gen1aPollerEventTypeFail,
  14. } Gen1aPollerEventType;
  15. typedef enum {
  16. Gen1aPollerModeWipe,
  17. Gen1aPollerModeWrite,
  18. } Gen1aPollerMode;
  19. typedef struct {
  20. Gen1aPollerMode mode;
  21. } Gen1aPollerEventDataRequestMode;
  22. typedef struct {
  23. const MfClassicData* mfc_data;
  24. } Gen1aPollerEventDataRequestDataToWrite;
  25. typedef union {
  26. Gen1aPollerEventDataRequestMode request_mode;
  27. Gen1aPollerEventDataRequestDataToWrite data_to_write;
  28. } Gen1aPollerEventData;
  29. typedef struct {
  30. Gen1aPollerEventType type;
  31. Gen1aPollerEventData* data;
  32. } Gen1aPollerEvent;
  33. typedef NfcCommand (*Gen1aPollerCallback)(Gen1aPollerEvent event, void* context);
  34. typedef struct Gen1aPoller Gen1aPoller;
  35. bool gen1a_poller_detect(Nfc* nfc);
  36. Gen1aPoller* gen1a_poller_alloc(Nfc* nfc);
  37. void gen1a_poller_free(Gen1aPoller* instance);
  38. void gen1a_poller_start(Gen1aPoller* instance, Gen1aPollerCallback callback, void* context);
  39. void gen1a_poller_stop(Gen1aPoller* instance);
  40. #ifdef __cplusplus
  41. }
  42. #endif