2021-07-02 13:44:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2021-07-22 06:05:07 +00:00
|
|
|
#include "mifare_ultralight.h"
|
|
|
|
|
2021-07-02 13:44:10 +00:00
|
|
|
#define NFC_DEV_NAME_MAX_LEN 22
|
|
|
|
#define NFC_FILE_NAME_MAX_LEN 120
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
NfcDeviceNfca,
|
|
|
|
NfcDeviceNfcb,
|
|
|
|
NfcDeviceNfcf,
|
|
|
|
NfcDeviceNfcv,
|
|
|
|
} NfcDeviceType;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
NfcDeviceProtocolUnknown,
|
|
|
|
NfcDeviceProtocolEMV,
|
2021-07-22 06:05:07 +00:00
|
|
|
NfcDeviceProtocolMifareUl,
|
2021-07-02 13:44:10 +00:00
|
|
|
} NfcProtocol;
|
|
|
|
|
2021-07-22 06:05:07 +00:00
|
|
|
typedef enum {
|
|
|
|
NfcDeviceSaveFormatUid,
|
|
|
|
NfcDeviceSaveFormatBankCard,
|
|
|
|
NfcDeviceSaveFormatMifareUl,
|
|
|
|
} NfcDeviceSaveFormat;
|
|
|
|
|
2021-07-02 13:44:10 +00:00
|
|
|
typedef struct {
|
|
|
|
uint8_t uid_len;
|
|
|
|
uint8_t uid[10];
|
|
|
|
uint8_t atqa[2];
|
|
|
|
uint8_t sak;
|
|
|
|
NfcDeviceType device;
|
|
|
|
NfcProtocol protocol;
|
2021-07-22 06:05:07 +00:00
|
|
|
} NfcDeviceCommomData;
|
2021-07-02 13:44:10 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[32];
|
2021-07-22 06:05:07 +00:00
|
|
|
uint8_t aid[16];
|
|
|
|
uint16_t aid_len;
|
2021-07-02 13:44:10 +00:00
|
|
|
uint8_t number[8];
|
2021-07-22 06:05:07 +00:00
|
|
|
uint8_t exp_mon;
|
2021-08-04 18:58:11 +00:00
|
|
|
uint8_t exp_year;
|
2021-07-22 06:05:07 +00:00
|
|
|
char cardholder[32];
|
2021-07-02 13:44:10 +00:00
|
|
|
} NfcEmvData;
|
|
|
|
|
|
|
|
typedef struct {
|
2021-07-22 06:05:07 +00:00
|
|
|
NfcDeviceCommomData nfc_data;
|
|
|
|
union {
|
|
|
|
NfcEmvData emv_data;
|
|
|
|
MifareUlData mf_ul_data;
|
|
|
|
};
|
|
|
|
} NfcDeviceData;
|
2021-07-02 13:44:10 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2021-07-22 06:05:07 +00:00
|
|
|
NfcDeviceData dev_data;
|
2021-07-02 13:44:10 +00:00
|
|
|
char dev_name[NFC_DEV_NAME_MAX_LEN];
|
|
|
|
char file_name[NFC_FILE_NAME_MAX_LEN];
|
2021-07-22 06:05:07 +00:00
|
|
|
NfcDeviceSaveFormat format;
|
2021-08-16 21:45:04 +00:00
|
|
|
bool shadow_file_exist;
|
2021-07-02 13:44:10 +00:00
|
|
|
} NfcDevice;
|
|
|
|
|
|
|
|
void nfc_device_set_name(NfcDevice* dev, const char* name);
|
|
|
|
|
|
|
|
bool nfc_device_save(NfcDevice* dev, const char* dev_name);
|
|
|
|
|
2021-08-16 21:45:04 +00:00
|
|
|
bool nfc_device_save_shadow(NfcDevice* dev, const char* dev_name);
|
|
|
|
|
2021-07-15 21:39:21 +00:00
|
|
|
bool nfc_device_load(NfcDevice* dev, const char* file_path);
|
2021-07-02 13:44:10 +00:00
|
|
|
|
|
|
|
bool nfc_file_select(NfcDevice* dev);
|
2021-07-22 06:05:07 +00:00
|
|
|
|
|
|
|
void nfc_device_clear(NfcDevice* dev);
|
|
|
|
|
|
|
|
bool nfc_device_delete(NfcDevice* dev);
|
2021-08-16 21:45:04 +00:00
|
|
|
|
|
|
|
bool nfc_device_restore(NfcDevice* dev);
|