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>
|
2022-08-03 17:07:35 +00:00
|
|
|
#include <lib/nfc/helpers/mf_classic_dict.h>
|
2022-07-26 15:30:49 +00:00
|
|
|
#include <lib/nfc/protocols/emv.h>
|
|
|
|
#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
|
|
|
|
2022-11-04 07:01:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-07-02 13:44:10 +00:00
|
|
|
#define NFC_DEV_NAME_MAX_LEN 22
|
2022-02-02 19:59:28 +00:00
|
|
|
#define NFC_READER_DATA_MAX_SIZE 64
|
2022-12-27 09:14:03 +00:00
|
|
|
#define NFC_DICT_KEY_BATCH_SIZE 10
|
2021-07-02 13:44:10 +00:00
|
|
|
|
2022-01-29 09:39:10 +00:00
|
|
|
#define NFC_APP_EXTENSION ".nfc"
|
|
|
|
#define NFC_APP_SHADOW_EXTENSION ".shd"
|
|
|
|
|
[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)
* Ibutton, Infrared, LfRFID GUI fixes
* Loading screens update
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 07:41:16 +00:00
|
|
|
typedef void (*NfcLoadingCallback)(void* context, bool state);
|
|
|
|
|
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;
|
|
|
|
|
2022-08-03 17:07:35 +00:00
|
|
|
typedef struct {
|
|
|
|
MfClassicDict* dict;
|
2022-12-27 09:14:03 +00:00
|
|
|
uint8_t current_sector;
|
2022-08-03 17:07:35 +00:00
|
|
|
} NfcMfClassicDictAttackData;
|
|
|
|
|
2022-11-10 16:29:57 +00:00
|
|
|
typedef enum {
|
|
|
|
NfcReadModeAuto,
|
|
|
|
NfcReadModeMfClassic,
|
|
|
|
NfcReadModeMfUltralight,
|
|
|
|
NfcReadModeMfDesfire,
|
|
|
|
NfcReadModeEMV,
|
|
|
|
NfcReadModeNFCA,
|
|
|
|
} NfcReadMode;
|
|
|
|
|
2021-07-02 13:44:10 +00:00
|
|
|
typedef struct {
|
2022-04-19 15:23:58 +00:00
|
|
|
FuriHalNfcDevData nfc_data;
|
|
|
|
NfcProtocol protocol;
|
2022-11-10 16:29:57 +00:00
|
|
|
NfcReadMode read_mode;
|
2022-08-03 17:07:35 +00:00
|
|
|
union {
|
|
|
|
NfcReaderRequestData reader_data;
|
|
|
|
NfcMfClassicDictAttackData mf_classic_dict_attack_data;
|
2022-11-28 18:16:22 +00:00
|
|
|
MfUltralightAuth mf_ul_auth;
|
2022-08-03 17:07:35 +00:00
|
|
|
};
|
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
|
|
|
};
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* parsed_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-10-05 15:15:23 +00:00
|
|
|
FuriString* load_path;
|
2022-12-19 19:57:48 +00:00
|
|
|
FuriString* folder;
|
2021-07-22 06:05:07 +00:00
|
|
|
NfcDeviceSaveFormat format;
|
2021-08-16 21:45:04 +00:00
|
|
|
bool shadow_file_exist;
|
[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)
* Ibutton, Infrared, LfRFID GUI fixes
* Loading screens update
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 07:41:16 +00:00
|
|
|
|
|
|
|
NfcLoadingCallback loading_cb;
|
|
|
|
void* loading_cb_ctx;
|
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);
|
|
|
|
|
2022-07-04 13:09:46 +00:00
|
|
|
bool nfc_device_load(NfcDevice* dev, const char* file_path, bool show_dialog);
|
2021-07-02 13:44:10 +00:00
|
|
|
|
2022-07-26 15:30:49 +00:00
|
|
|
bool nfc_device_load_key_cache(NfcDevice* dev);
|
|
|
|
|
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 11:19:21 +00:00
|
|
|
bool nfc_device_delete(NfcDevice* dev, bool use_load_path);
|
2021-08-16 21:45:04 +00:00
|
|
|
|
2022-05-27 11:19:21 +00:00
|
|
|
bool nfc_device_restore(NfcDevice* dev, bool use_load_path);
|
[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)
* Ibutton, Infrared, LfRFID GUI fixes
* Loading screens update
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 07:41:16 +00:00
|
|
|
|
|
|
|
void nfc_device_set_loading_callback(NfcDevice* dev, NfcLoadingCallback callback, void* context);
|
2022-11-04 07:01:44 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|