a0e1e42f2d
* view: add custom event callback * nfc: rework nfc worker * gui: introduce view navigator * nfc_scences: introduce nfc scenes * nfc: add start scene * lib: add C application scene template * nfc: move nfc views to separate directory * view_dispatcher: add support for view_navigator * nfc views: rework nfc views * nfc scenes: add nfc application scenes * nfc: rework nfc main thread * view_dispatcher: add separate event for search back scene * nfc: set worker result address at worker start * nfc: update read nfc scenes * view_navigator: rework with M-LIB container * view_dispatcher: check that all views were freed * nfc: add debug menu with all functions * nfc read scene: add notification on success * api-hal-nfc: add API for UID emulation * nfc: add nfc emulation UID scene * assets: add NFC assets * nfc: update read and emulate scenes UI * nfc: fix memory leak * rfal: set custom analog configuration
83 lines
1.7 KiB
C
Executable File
83 lines
1.7 KiB
C
Executable File
#pragma once
|
|
|
|
typedef enum {
|
|
NfcDeviceNfca,
|
|
NfcDeviceNfcb,
|
|
NfcDeviceNfcf,
|
|
NfcDeviceNfcv,
|
|
} NfcDeviceType;
|
|
|
|
typedef enum {
|
|
NfcDeviceProtocolUnknown,
|
|
NfcDeviceProtocolEMV,
|
|
NfcDeviceProtocolMfUltralight,
|
|
} NfcProtocol;
|
|
|
|
typedef struct {
|
|
uint8_t uid_len;
|
|
uint8_t uid[10];
|
|
uint8_t atqa[2];
|
|
uint8_t sak;
|
|
NfcDeviceType device;
|
|
NfcProtocol protocol;
|
|
} NfcDeviceData;
|
|
|
|
typedef struct {
|
|
NfcDeviceData nfc_data;
|
|
char name[32];
|
|
uint8_t number[8];
|
|
} NfcEmvData;
|
|
|
|
typedef struct {
|
|
NfcDeviceData nfc_data;
|
|
uint8_t man_block[12];
|
|
uint8_t otp[4];
|
|
} NfcMifareUlData;
|
|
|
|
typedef struct {
|
|
union {
|
|
NfcDeviceData nfc_detect_data;
|
|
NfcEmvData nfc_emv_data;
|
|
NfcMifareUlData nfc_mifare_ul_data;
|
|
};
|
|
} NfcWorkerResult;
|
|
|
|
typedef struct NfcWorker NfcWorker;
|
|
|
|
typedef enum {
|
|
// Init states
|
|
NfcWorkerStateNone,
|
|
NfcWorkerStateBroken,
|
|
NfcWorkerStateReady,
|
|
// Main worker states
|
|
NfcWorkerStateDetect,
|
|
NfcWorkerStateEmulate,
|
|
NfcWorkerStateReadEMV,
|
|
NfcWorkerStateEmulateEMV,
|
|
NfcWorkerStateField,
|
|
NfcWorkerStateReadMfUltralight,
|
|
// Transition
|
|
NfcWorkerStateStop,
|
|
} NfcWorkerState;
|
|
|
|
typedef void (*NfcWorkerCallback)(void* context);
|
|
|
|
NfcWorker* nfc_worker_alloc();
|
|
|
|
NfcWorkerState nfc_worker_get_state(NfcWorker* nfc_worker);
|
|
|
|
ReturnCode nfc_worker_get_error(NfcWorker* nfc_worker);
|
|
|
|
void nfc_worker_set_emulation_params(NfcWorker* nfc_worker, NfcDeviceData* data);
|
|
|
|
void nfc_worker_free(NfcWorker* nfc_worker);
|
|
|
|
void nfc_worker_start(
|
|
NfcWorker* nfc_worker,
|
|
NfcWorkerState state,
|
|
NfcWorkerResult* result_dest,
|
|
NfcWorkerCallback callback,
|
|
void* context);
|
|
|
|
void nfc_worker_stop(NfcWorker* nfc_worker);
|