nfc_device.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #define NFC_DEV_NAME_MAX_LEN 22
  5. #define NFC_FILE_NAME_MAX_LEN 120
  6. typedef enum {
  7. NfcDeviceNfca,
  8. NfcDeviceNfcb,
  9. NfcDeviceNfcf,
  10. NfcDeviceNfcv,
  11. } NfcDeviceType;
  12. typedef enum {
  13. NfcDeviceProtocolUnknown,
  14. NfcDeviceProtocolEMV,
  15. NfcDeviceProtocolMfUltralight,
  16. } NfcProtocol;
  17. typedef struct {
  18. uint8_t uid_len;
  19. uint8_t uid[10];
  20. uint8_t atqa[2];
  21. uint8_t sak;
  22. NfcDeviceType device;
  23. NfcProtocol protocol;
  24. } NfcDeviceData;
  25. typedef struct {
  26. NfcDeviceData nfc_data;
  27. char name[32];
  28. uint8_t number[8];
  29. } NfcEmvData;
  30. typedef struct {
  31. NfcDeviceData nfc_data;
  32. uint8_t man_block[12];
  33. uint8_t otp[4];
  34. } NfcMifareUlData;
  35. typedef struct {
  36. NfcDeviceData data;
  37. char dev_name[NFC_DEV_NAME_MAX_LEN];
  38. char file_name[NFC_FILE_NAME_MAX_LEN];
  39. } NfcDevice;
  40. void nfc_device_set_name(NfcDevice* dev, const char* name);
  41. bool nfc_device_save(NfcDevice* dev, const char* dev_name);
  42. bool nfc_device_load(NfcDevice* dev, const char* dev_name);
  43. bool nfc_file_select(NfcDevice* dev);