flipperzero-firmware/applications/nfc/nfc_device.h
gornekich 49af516ec7
[FL-1547], [FL-1500] NFC app v1 (#593)
* nfc: remove mifare read debug view and scene
* nfc: change mifare ultralight data structure
* mifare_ultralight: add more commands
* nfc: add emulate mifare ul scene
* nfc: rework data structures, remove debug scenes and views
* nfc: add read emv scenes
* nfc: mifare emulation wip
* nfc cli: increase detecting time
* nfc: save nfc files with new format
* nfc: store Mifare Ultralight
* nfc: start loading mifare ultralight
* nfc: add delete scenes
* nfc: add edit UID and name
* nfc: finish parsing uid and mifare ul data
* nfc: delete success fix
* gui_widget: introduce GuiWidget
* gui_widget: add string element
* gui_widget: add button element
* gui_widget: move free elements into gui_widget
* nfc: rework info scene with GuiWidget
* nfc: rework device info scene
* nfc: rework delete scene gui
* nfc: add compatible script support
* nfc: rework emv reading scenes
* nfc: rework bank card save
* nfc: add bank card custom view
* gui_widget: add icon element
* nfc: add icon to bank card
* nfc: start worker after switching view

Co-authored-by: あく <alleteam@gmail.com>
2021-07-22 09:05:07 +03:00

75 lines
1.5 KiB
C

#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "mifare_ultralight.h"
#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,
NfcDeviceProtocolMifareUl,
} NfcProtocol;
typedef enum {
NfcDeviceSaveFormatUid,
NfcDeviceSaveFormatBankCard,
NfcDeviceSaveFormatMifareUl,
} NfcDeviceSaveFormat;
typedef struct {
uint8_t uid_len;
uint8_t uid[10];
uint8_t atqa[2];
uint8_t sak;
NfcDeviceType device;
NfcProtocol protocol;
} NfcDeviceCommomData;
typedef struct {
char name[32];
uint8_t aid[16];
uint16_t aid_len;
uint8_t number[8];
uint8_t exp_mon;
uint16_t exp_year;
char cardholder[32];
} NfcEmvData;
typedef struct {
NfcDeviceCommomData nfc_data;
union {
NfcEmvData emv_data;
MifareUlData mf_ul_data;
};
} NfcDeviceData;
typedef struct {
NfcDeviceData dev_data;
char dev_name[NFC_DEV_NAME_MAX_LEN];
char file_name[NFC_FILE_NAME_MAX_LEN];
NfcDeviceSaveFormat format;
} NfcDevice;
void nfc_device_set_name(NfcDevice* dev, const char* name);
bool nfc_device_save(NfcDevice* dev, const char* dev_name);
bool nfc_device_load(NfcDevice* dev, const char* file_path);
bool nfc_file_select(NfcDevice* dev);
void nfc_device_clear(NfcDevice* dev);
bool nfc_device_delete(NfcDevice* dev);