mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-24 03:33:08 +00:00
d31578508a
* digital signal: introduce digital signal * nfca: add nfca signal encoder * nfc: add mifare classic emulation scene * nfca: add classic emulation support to lib and hal * mifare classic: support basic read commands * nfc: add mifare classic menu scene * mifare classic: start parsing commands in emulation * mifare classic: add nested auth * nfc: fix errors * mifare classic: add encrypt function * nfc: fix mifare classic save * lib hex: add hex uint64_t ASCII parser * flipper format: add uint64 hex format support * nfc: add mifare classic key map * nfc: hide mifare classic keys on emulation * mifare classic: add NACK responce * nfc: add partial bytes support in transparent mode * nfc: mifare classic add shadow file support * digital signal: move arr buffer from BSS to heap * mifare classic: process access bits more careful * nfca: fix memory leack * nfc: format sources * mifare classic: cleun up Co-authored-by: あく <alleteam@gmail.com>
64 lines
2.1 KiB
C
64 lines
2.1 KiB
C
#include "../nfc_i.h"
|
|
#include <dolphin/dolphin.h>
|
|
|
|
#define NFC_MF_CLASSIC_DATA_NOT_CHANGED (0UL)
|
|
#define NFC_MF_CLASSIC_DATA_CHANGED (1UL)
|
|
|
|
void nfc_emulate_mifare_classic_worker_callback(NfcWorkerEvent event, void* context) {
|
|
UNUSED(event);
|
|
Nfc* nfc = context;
|
|
|
|
scene_manager_set_scene_state(
|
|
nfc->scene_manager, NfcSceneEmulateMifareClassic, NFC_MF_CLASSIC_DATA_CHANGED);
|
|
}
|
|
|
|
void nfc_scene_emulate_mifare_classic_on_enter(void* context) {
|
|
Nfc* nfc = context;
|
|
DOLPHIN_DEED(DolphinDeedNfcEmulate);
|
|
|
|
// Setup view
|
|
Popup* popup = nfc->popup;
|
|
if(strcmp(nfc->dev->dev_name, "")) {
|
|
nfc_text_store_set(nfc, "%s", nfc->dev->dev_name);
|
|
}
|
|
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
|
|
popup_set_header(popup, "Emulating\nMf Classic", 56, 31, AlignLeft, AlignTop);
|
|
|
|
// Setup and start worker
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
|
|
nfc_worker_start(
|
|
nfc->worker,
|
|
NfcWorkerStateEmulateMifareClassic,
|
|
&nfc->dev->dev_data,
|
|
nfc_emulate_mifare_classic_worker_callback,
|
|
nfc);
|
|
}
|
|
|
|
bool nfc_scene_emulate_mifare_classic_on_event(void* context, SceneManagerEvent event) {
|
|
Nfc* nfc = context;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeTick) {
|
|
notification_message(nfc->notifications, &sequence_blink_blue_10);
|
|
consumed = true;
|
|
} else if(event.type == SceneManagerEventTypeBack) {
|
|
// Stop worker
|
|
nfc_worker_stop(nfc->worker);
|
|
// Check if data changed and save in shadow file
|
|
if(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneEmulateMifareClassic) ==
|
|
NFC_MF_CLASSIC_DATA_CHANGED) {
|
|
scene_manager_set_scene_state(
|
|
nfc->scene_manager, NfcSceneEmulateMifareClassic, NFC_MF_CLASSIC_DATA_NOT_CHANGED);
|
|
nfc_device_save_shadow(nfc->dev, nfc->dev->dev_name);
|
|
}
|
|
consumed = false;
|
|
}
|
|
return consumed;
|
|
}
|
|
|
|
void nfc_scene_emulate_mifare_classic_on_exit(void* context) {
|
|
Nfc* nfc = context;
|
|
|
|
// Clear view
|
|
popup_reset(nfc->popup);
|
|
}
|