nfc_device.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #define NFC_MIFARE_UL_MAX_SIZE 256
  7. typedef enum {
  8. NfcDeviceNfca,
  9. NfcDeviceNfcb,
  10. NfcDeviceNfcf,
  11. NfcDeviceNfcv,
  12. } NfcDeviceType;
  13. typedef enum {
  14. NfcDeviceProtocolUnknown,
  15. NfcDeviceProtocolEMV,
  16. NfcDeviceProtocolMfUltralight,
  17. } NfcProtocol;
  18. typedef struct {
  19. uint8_t uid_len;
  20. uint8_t uid[10];
  21. uint8_t atqa[2];
  22. uint8_t sak;
  23. NfcDeviceType device;
  24. NfcProtocol protocol;
  25. } NfcDeviceData;
  26. typedef struct {
  27. NfcDeviceData nfc_data;
  28. char name[32];
  29. uint8_t number[8];
  30. } NfcEmvData;
  31. typedef struct {
  32. NfcDeviceData nfc_data;
  33. uint8_t full_dump[NFC_MIFARE_UL_MAX_SIZE];
  34. uint16_t dump_size;
  35. // TODO delete with debug view
  36. uint8_t man_block[12];
  37. uint8_t otp[4];
  38. } NfcMifareUlData;
  39. typedef struct {
  40. NfcDeviceData data;
  41. char dev_name[NFC_DEV_NAME_MAX_LEN];
  42. char file_name[NFC_FILE_NAME_MAX_LEN];
  43. } NfcDevice;
  44. void nfc_device_set_name(NfcDevice* dev, const char* name);
  45. bool nfc_device_save(NfcDevice* dev, const char* dev_name);
  46. bool nfc_device_load(NfcDevice* dev, const char* file_path);
  47. bool nfc_file_select(NfcDevice* dev);