flipperzero-firmware/lib/nfc/nfc_worker.h
gornekich 93a6e17ce5
[FL-2933] Mf Classic initial write, update, detect reader (#1941)
* nfc: introduce nfc write
* nfc: add write logic
* nfc worker: add write state
* nfc: add mfc update logic
* nfc: add update success logic
* nfc: add custom card for detect reader
* nfc: update write logic
* nfc: add halt command, add notifications
* nfc: add write fail scene
* nfc: fixes and clean up
* nfc: fix navigation ad notifications
* nfc: fix detect reader nfc data setter

Co-authored-by: あく <alleteam@gmail.com>
2022-10-29 01:10:16 +09:00

89 lines
2.2 KiB
C

#pragma once
#include "nfc_device.h"
typedef struct NfcWorker NfcWorker;
typedef enum {
// Init states
NfcWorkerStateNone,
NfcWorkerStateBroken,
NfcWorkerStateReady,
// Main worker states
NfcWorkerStateRead,
NfcWorkerStateUidEmulate,
NfcWorkerStateMfUltralightEmulate,
NfcWorkerStateMfClassicEmulate,
NfcWorkerStateMfClassicWrite,
NfcWorkerStateMfClassicUpdate,
NfcWorkerStateReadMfUltralightReadAuth,
NfcWorkerStateMfClassicDictAttack,
NfcWorkerStateAnalyzeReader,
// Debug
NfcWorkerStateEmulateApdu,
NfcWorkerStateField,
// Transition
NfcWorkerStateStop,
} NfcWorkerState;
typedef enum {
// Reserve first 50 events for application events
NfcWorkerEventReserved = 50,
// Nfc read events
NfcWorkerEventReadUidNfcB,
NfcWorkerEventReadUidNfcV,
NfcWorkerEventReadUidNfcF,
NfcWorkerEventReadUidNfcA,
NfcWorkerEventReadMfUltralight,
NfcWorkerEventReadMfDesfire,
NfcWorkerEventReadMfClassicDone,
NfcWorkerEventReadMfClassicLoadKeyCache,
NfcWorkerEventReadMfClassicDictAttackRequired,
NfcWorkerEventReadBankCard,
// Nfc worker common events
NfcWorkerEventSuccess,
NfcWorkerEventFail,
NfcWorkerEventAborted,
NfcWorkerEventCardDetected,
NfcWorkerEventNoCardDetected,
NfcWorkerEventWrongCardDetected,
// Read Mifare Classic events
NfcWorkerEventNoDictFound,
NfcWorkerEventNewSector,
NfcWorkerEventNewDictKeyBatch,
NfcWorkerEventFoundKeyA,
NfcWorkerEventFoundKeyB,
// Write Mifare Classic events
NfcWorkerEventWrongCard,
// Detect Reader events
NfcWorkerEventDetectReaderDetected,
NfcWorkerEventDetectReaderLost,
NfcWorkerEventDetectReaderMfkeyCollected,
// Mifare Ultralight events
NfcWorkerEventMfUltralightPassKey,
} NfcWorkerEvent;
typedef bool (*NfcWorkerCallback)(NfcWorkerEvent event, void* context);
NfcWorker* nfc_worker_alloc();
NfcWorkerState nfc_worker_get_state(NfcWorker* nfc_worker);
void nfc_worker_free(NfcWorker* nfc_worker);
void nfc_worker_start(
NfcWorker* nfc_worker,
NfcWorkerState state,
NfcDeviceData* dev_data,
NfcWorkerCallback callback,
void* context);
void nfc_worker_stop(NfcWorker* nfc_worker);