2021-07-02 16:44:10 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2021-11-09 00:55:06 +03:00
|
|
|
#include <storage/storage.h>
|
|
|
|
#include <dialogs/dialogs.h>
|
2021-07-02 16:44:10 +03:00
|
|
|
|
2021-07-22 09:05:07 +03:00
|
|
|
#include "mifare_ultralight.h"
|
|
|
|
|
2021-07-02 16:44:10 +03: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 09:05:07 +03:00
|
|
|
NfcDeviceProtocolMifareUl,
|
2021-07-02 16:44:10 +03:00
|
|
|
} NfcProtocol;
|
|
|
|
|
2021-07-22 09:05:07 +03:00
|
|
|
typedef enum {
|
|
|
|
NfcDeviceSaveFormatUid,
|
|
|
|
NfcDeviceSaveFormatBankCard,
|
|
|
|
NfcDeviceSaveFormatMifareUl,
|
|
|
|
} NfcDeviceSaveFormat;
|
|
|
|
|
2021-07-02 16:44:10 +03:00
|
|
|
typedef struct {
|
|
|
|
uint8_t uid_len;
|
|
|
|
uint8_t uid[10];
|
|
|
|
uint8_t atqa[2];
|
|
|
|
uint8_t sak;
|
|
|
|
NfcDeviceType device;
|
|
|
|
NfcProtocol protocol;
|
2021-09-01 02:07:53 +03:00
|
|
|
} NfcDeviceCommonData;
|
2021-07-02 16:44:10 +03:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[32];
|
2021-07-22 09:05:07 +03:00
|
|
|
uint8_t aid[16];
|
|
|
|
uint16_t aid_len;
|
2021-10-05 08:14:19 +03:00
|
|
|
uint8_t number[10];
|
|
|
|
uint8_t number_len;
|
2021-07-22 09:05:07 +03:00
|
|
|
uint8_t exp_mon;
|
2021-08-04 21:58:11 +03:00
|
|
|
uint8_t exp_year;
|
2021-08-20 22:56:43 +03:00
|
|
|
uint16_t country_code;
|
|
|
|
uint16_t currency_code;
|
2021-07-02 16:44:10 +03:00
|
|
|
} NfcEmvData;
|
|
|
|
|
|
|
|
typedef struct {
|
2021-09-01 02:07:53 +03:00
|
|
|
NfcDeviceCommonData nfc_data;
|
2021-07-22 09:05:07 +03:00
|
|
|
union {
|
|
|
|
NfcEmvData emv_data;
|
|
|
|
MifareUlData mf_ul_data;
|
|
|
|
};
|
|
|
|
} NfcDeviceData;
|
2021-07-02 16:44:10 +03:00
|
|
|
|
|
|
|
typedef struct {
|
2021-11-09 00:55:06 +03:00
|
|
|
Storage* storage;
|
|
|
|
DialogsApp* dialogs;
|
2021-07-22 09:05:07 +03:00
|
|
|
NfcDeviceData dev_data;
|
2021-10-05 08:14:19 +03:00
|
|
|
char dev_name[NFC_DEV_NAME_MAX_LEN + 1];
|
2021-07-02 16:44:10 +03:00
|
|
|
char file_name[NFC_FILE_NAME_MAX_LEN];
|
2021-07-22 09:05:07 +03:00
|
|
|
NfcDeviceSaveFormat format;
|
2021-08-17 00:45:04 +03:00
|
|
|
bool shadow_file_exist;
|
2021-07-02 16:44:10 +03:00
|
|
|
} NfcDevice;
|
|
|
|
|
2021-11-09 00:55:06 +03:00
|
|
|
NfcDevice* nfc_device_alloc();
|
|
|
|
|
|
|
|
void nfc_device_free(NfcDevice* nfc_dev);
|
|
|
|
|
2021-07-02 16:44:10 +03:00
|
|
|
void nfc_device_set_name(NfcDevice* dev, const char* name);
|
|
|
|
|
|
|
|
bool nfc_device_save(NfcDevice* dev, const char* dev_name);
|
|
|
|
|
2021-08-17 00:45:04 +03:00
|
|
|
bool nfc_device_save_shadow(NfcDevice* dev, const char* dev_name);
|
|
|
|
|
2021-07-16 00:39:21 +03:00
|
|
|
bool nfc_device_load(NfcDevice* dev, const char* file_path);
|
2021-07-02 16:44:10 +03:00
|
|
|
|
|
|
|
bool nfc_file_select(NfcDevice* dev);
|
2021-07-22 09:05:07 +03:00
|
|
|
|
|
|
|
void nfc_device_clear(NfcDevice* dev);
|
|
|
|
|
|
|
|
bool nfc_device_delete(NfcDevice* dev);
|
2021-08-17 00:45:04 +03:00
|
|
|
|
|
|
|
bool nfc_device_restore(NfcDevice* dev);
|