2021-07-02 13:44:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2021-11-08 21:55:06 +00:00
|
|
|
#include <storage/storage.h>
|
|
|
|
#include <dialogs/dialogs.h>
|
2021-07-02 13:44:10 +00:00
|
|
|
|
2022-04-19 15:23:58 +00:00
|
|
|
#include <furi_hal_nfc.h>
|
|
|
|
#include <lib/nfc_protocols/emv.h>
|
2022-03-23 22:14:34 +00:00
|
|
|
#include <lib/nfc_protocols/mifare_ultralight.h>
|
|
|
|
#include <lib/nfc_protocols/mifare_classic.h>
|
|
|
|
#include <lib/nfc_protocols/mifare_desfire.h>
|
2021-07-22 06:05:07 +00:00
|
|
|
|
2021-07-02 13:44:10 +00:00
|
|
|
#define NFC_DEV_NAME_MAX_LEN 22
|
2022-05-27 19:18:35 +00:00
|
|
|
#define NFC_FILE_NAME_MAX_LEN 120
|
2022-02-02 19:59:28 +00:00
|
|
|
#define NFC_READER_DATA_MAX_SIZE 64
|
2021-07-02 13:44:10 +00:00
|
|
|
|
2022-01-29 09:39:10 +00:00
|
|
|
#define NFC_APP_FOLDER "/any/nfc"
|
|
|
|
#define NFC_APP_EXTENSION ".nfc"
|
|
|
|
#define NFC_APP_SHADOW_EXTENSION ".shd"
|
|
|
|
|
2021-07-02 13:44:10 +00:00
|
|
|
typedef enum {
|
|
|
|
NfcDeviceProtocolUnknown,
|
|
|
|
NfcDeviceProtocolEMV,
|
2021-07-22 06:05:07 +00:00
|
|
|
NfcDeviceProtocolMifareUl,
|
2022-03-23 22:14:34 +00:00
|
|
|
NfcDeviceProtocolMifareClassic,
|
2022-03-23 13:45:37 +00:00
|
|
|
NfcDeviceProtocolMifareDesfire,
|
2021-07-02 13:44:10 +00:00
|
|
|
} NfcProtocol;
|
|
|
|
|
2021-07-22 06:05:07 +00:00
|
|
|
typedef enum {
|
|
|
|
NfcDeviceSaveFormatUid,
|
|
|
|
NfcDeviceSaveFormatBankCard,
|
|
|
|
NfcDeviceSaveFormatMifareUl,
|
2022-03-23 22:14:34 +00:00
|
|
|
NfcDeviceSaveFormatMifareClassic,
|
2022-03-23 13:45:37 +00:00
|
|
|
NfcDeviceSaveFormatMifareDesfire,
|
2021-07-22 06:05:07 +00:00
|
|
|
} NfcDeviceSaveFormat;
|
|
|
|
|
2022-02-02 19:59:28 +00:00
|
|
|
typedef struct {
|
|
|
|
uint8_t data[NFC_READER_DATA_MAX_SIZE];
|
|
|
|
uint16_t size;
|
|
|
|
} NfcReaderRequestData;
|
|
|
|
|
2021-07-02 13:44:10 +00:00
|
|
|
typedef struct {
|
2022-04-19 15:23:58 +00:00
|
|
|
FuriHalNfcDevData nfc_data;
|
|
|
|
NfcProtocol protocol;
|
2022-03-23 13:45:37 +00:00
|
|
|
NfcReaderRequestData reader_data;
|
2021-07-22 06:05:07 +00:00
|
|
|
union {
|
2022-04-19 15:23:58 +00:00
|
|
|
EmvData emv_data;
|
|
|
|
MfUltralightData mf_ul_data;
|
2022-03-23 22:14:34 +00:00
|
|
|
MfClassicData mf_classic_data;
|
2022-03-23 13:45:37 +00:00
|
|
|
MifareDesfireData mf_df_data;
|
2021-07-22 06:05:07 +00:00
|
|
|
};
|
|
|
|
} NfcDeviceData;
|
2021-07-02 13:44:10 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2021-11-08 21:55:06 +00:00
|
|
|
Storage* storage;
|
|
|
|
DialogsApp* dialogs;
|
2021-07-22 06:05:07 +00:00
|
|
|
NfcDeviceData dev_data;
|
2021-10-05 05:14:19 +00:00
|
|
|
char dev_name[NFC_DEV_NAME_MAX_LEN + 1];
|
2022-05-27 19:18:35 +00:00
|
|
|
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;
|
|
|
|
|
2021-11-08 21:55:06 +00:00
|
|
|
NfcDevice* nfc_device_alloc();
|
|
|
|
|
|
|
|
void nfc_device_free(NfcDevice* nfc_dev);
|
|
|
|
|
2021-07-02 13:44:10 +00:00
|
|
|
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
|
|
|
|
2022-03-23 13:45:37 +00:00
|
|
|
void nfc_device_data_clear(NfcDeviceData* dev);
|
|
|
|
|
2021-07-22 06:05:07 +00:00
|
|
|
void nfc_device_clear(NfcDevice* dev);
|
|
|
|
|
2022-05-27 19:18:35 +00:00
|
|
|
bool nfc_device_delete(NfcDevice* dev);
|
2021-08-16 21:45:04 +00:00
|
|
|
|
2022-05-27 19:18:35 +00:00
|
|
|
bool nfc_device_restore(NfcDevice* dev);
|