Nfc: add basic Mifare DESFire support (#1024)

* Fix TextBox word wrap behavior
* Wrap width is 120 pixels, not 140. (140 is larger than the screen!)
* Glyph width already includes spacing; don't add 1 additional px
* When starting a new line, include wrapped glyph width in new line_width.
* Call canvas_set_font before text_box_insert_endline so that glyph
  width is calculated using correct font.
  Previous approach worked somewhat well using default TextBoxFontText but
  this version is more robust, particularly when using TextBoxFontHex.
* Add basic Mifare DESFire reading, file/app browser
* Fix build with APP_ARCHIVE=0
* Add bool type to flipper_format
* Add ability to save and load DESFire card data
* Skip over NfcSceneDeviceInfo when viewing saved DESFire info
* mf_df_clear: don't leak master key settings key versions
* When opening a DESFire card from Archive, retain UID emulation behavior
* rm unnecessary \r\n
* show Popup instead of leaving view in bad state
* Move NfcReaderRequestData out of union
  This makes it safe to emulate DESFire/EMV without clobbering card data.
* Display saved DESFire cards via NfcSceneDeviceInfo
* Display and save file metadata even when contents are missing
  This can happen when a file doesn't allow unauthenticated reads (see the
  call to mf_df_parse_read_data_response in nfc_worker.c).

Co-authored-by: Kevin Wallace <git+flipperzero@kevin.wallace.seattle.wa.us>
Co-authored-by: あく <alleteam@gmail.com>
Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
Kevin Wallace
2022-03-23 06:45:37 -07:00
committed by GitHub
parent d075e00ae1
commit 3857cd7d5f
26 changed files with 1941 additions and 14 deletions

View File

@@ -50,6 +50,8 @@ bool nfc_scene_card_menu_on_event(void* context, SceneManagerEvent event) {
nfc->scene_manager, NfcSceneCardMenu, SubmenuIndexRunApp);
if(nfc->dev->dev_data.nfc_data.protocol == NfcDeviceProtocolMifareUl) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadMifareUl);
} else if(nfc->dev->dev_data.nfc_data.protocol == NfcDeviceProtocolMifareDesfire) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadMifareDesfire);
} else if(nfc->dev->dev_data.nfc_data.protocol == NfcDeviceProtocolEMV) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadEmvApp);
}

View File

@@ -19,6 +19,11 @@ ADD_SCENE(nfc, mifare_ul_menu, MifareUlMenu)
ADD_SCENE(nfc, emulate_mifare_ul, EmulateMifareUl)
ADD_SCENE(nfc, read_emv_app, ReadEmvApp)
ADD_SCENE(nfc, read_emv_app_success, ReadEmvAppSuccess)
ADD_SCENE(nfc, read_mifare_desfire, ReadMifareDesfire)
ADD_SCENE(nfc, read_mifare_desfire_success, ReadMifareDesfireSuccess)
ADD_SCENE(nfc, mifare_desfire_menu, MifareDesfireMenu)
ADD_SCENE(nfc, mifare_desfire_data, MifareDesfireData)
ADD_SCENE(nfc, mifare_desfire_app, MifareDesfireApp)
ADD_SCENE(nfc, device_info, DeviceInfo)
ADD_SCENE(nfc, delete, Delete)
ADD_SCENE(nfc, delete_success, DeleteSuccess)

27
applications/nfc/scenes/nfc_scene_device_info.c Executable file → Normal file
View File

@@ -32,7 +32,7 @@ void nfc_scene_device_info_on_enter(void* context) {
// Setup Custom Widget view
widget_add_text_box_element(
nfc->widget, 0, 0, 128, 22, AlignCenter, AlignCenter, nfc->dev->dev_name);
nfc->widget, 0, 0, 128, 22, AlignCenter, AlignTop, nfc->dev->dev_name);
widget_add_button_element(
nfc->widget, GuiButtonTypeLeft, "Back", nfc_scene_device_info_widget_callback, nfc);
widget_add_button_element(
@@ -64,7 +64,8 @@ void nfc_scene_device_info_on_enter(void* context) {
widget_add_string_element(nfc->widget, 64, 21, AlignCenter, AlignTop, FontSecondary, uid_str);
const char* protocol_name = NULL;
if(data->protocol == NfcDeviceProtocolEMV) {
if(data->protocol == NfcDeviceProtocolEMV ||
data->protocol == NfcDeviceProtocolMifareDesfire) {
protocol_name = nfc_guess_protocol(data->protocol);
} else if(data->protocol == NfcDeviceProtocolMifareUl) {
protocol_name = nfc_mf_ul_type(nfc->dev->dev_data.mf_ul_data.type, false);
@@ -101,6 +102,25 @@ void nfc_scene_device_info_on_enter(void* context) {
nfc->text_box_store, "%02X%02X ", mf_ul_data->data[i], mf_ul_data->data[i + 1]);
}
text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
} else if(nfc->dev->format == NfcDeviceSaveFormatMifareDesfire) {
MifareDesfireData* mf_df_data = &nfc->dev->dev_data.mf_df_data;
uint16_t n_apps = 0;
uint16_t n_files = 0;
for(MifareDesfireApplication* app = mf_df_data->app_head; app; app = app->next) {
n_apps++;
for(MifareDesfireFile* file = app->file_head; file; file = file->next) {
n_files++;
}
}
nfc_text_store_set(
nfc,
"%d application%s, %d file%s",
n_apps,
n_apps == 1 ? "" : "s",
n_files,
n_files == 1 ? "" : "s");
widget_add_string_element(
nfc->widget, 64, 17, AlignCenter, AlignBottom, FontSecondary, nfc->text_store);
} else if(nfc->dev->format == NfcDeviceSaveFormatBankCard) {
NfcEmvData* emv_data = &nfc->dev->dev_data.emv_data;
BankCard* bank_card = nfc->bank_card;
@@ -162,6 +182,9 @@ bool nfc_scene_device_info_on_event(void* context, SceneManagerEvent event) {
nfc->scene_manager, NfcSceneDeviceInfo, NfcSceneDeviceInfoData);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewBankCard);
consumed = true;
} else if(nfc->dev->format == NfcDeviceSaveFormatMifareDesfire) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMifareDesfireData);
consumed = true;
}
} else if(state == NfcSceneDeviceInfoData && event.event == NfcCustomEventViewExit) {
scene_manager_set_scene_state(

View File

@@ -0,0 +1,119 @@
#include "../nfc_i.h"
#define TAG "NfcSceneMifareDesfireApp"
enum SubmenuIndex {
SubmenuIndexAppInfo,
SubmenuIndexDynamic, // dynamic indexes start here
};
MifareDesfireApplication* nfc_scene_mifare_desfire_app_get_app(Nfc* nfc) {
uint32_t app_idx =
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMifareDesfireApp) >> 1;
MifareDesfireApplication* app = nfc->dev->dev_data.mf_df_data.app_head;
for(int i = 0; i < app_idx && app; i++) {
app = app->next;
}
return app;
}
void nfc_scene_mifare_desfire_app_submenu_callback(void* context, uint32_t index) {
Nfc* nfc = (Nfc*)context;
view_dispatcher_send_custom_event(nfc->view_dispatcher, index);
}
void nfc_scene_mifare_desfire_app_on_enter(void* context) {
Nfc* nfc = (Nfc*)context;
Submenu* submenu = nfc->submenu;
MifareDesfireApplication* app = nfc_scene_mifare_desfire_app_get_app(nfc);
if(!app) {
popup_set_icon(nfc->popup, 5, 5, &I_WarningDolphin_45x42);
popup_set_header(nfc->popup, "Internal Error!", 55, 12, AlignLeft, AlignBottom);
popup_set_text(
nfc->popup,
"No app selected.\nThis should\nnever happen,\nplease file a bug.",
55,
15,
AlignLeft,
AlignTop);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
FURI_LOG_E(TAG, "Bad state. No app selected?");
return;
}
text_box_set_font(nfc->text_box, TextBoxFontHex);
submenu_add_item(
submenu,
"App info",
SubmenuIndexAppInfo,
nfc_scene_mifare_desfire_app_submenu_callback,
nfc);
uint16_t cap = NFC_TEXT_STORE_SIZE;
char* buf = nfc->text_store;
int idx = SubmenuIndexDynamic;
for(MifareDesfireFile* file = app->file_head; file; file = file->next) {
int size = snprintf(buf, cap, "File %d", file->id);
if(size < 0 || size >= cap) {
FURI_LOG_W(
TAG,
"Exceeded NFC_TEXT_STORE_SIZE when preparing file id strings; menu truncated");
break;
}
char* label = buf;
cap -= size + 1;
buf += size + 1;
submenu_add_item(
submenu, label, idx++, nfc_scene_mifare_desfire_app_submenu_callback, nfc);
}
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
}
bool nfc_scene_mifare_desfire_app_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = (Nfc*)context;
uint32_t state = scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMifareDesfireApp);
if(event.type == SceneManagerEventTypeCustom) {
MifareDesfireApplication* app = nfc_scene_mifare_desfire_app_get_app(nfc);
TextBox* text_box = nfc->text_box;
string_reset(nfc->text_box_store);
if(event.event == SubmenuIndexAppInfo) {
mf_df_cat_application_info(app, nfc->text_box_store);
} else {
uint16_t index = event.event - SubmenuIndexDynamic;
MifareDesfireFile* file = app->file_head;
for(int i = 0; file && i < index; i++) {
file = file->next;
}
if(!file) {
return false;
}
mf_df_cat_file(file, nfc->text_box_store);
}
text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
scene_manager_set_scene_state(nfc->scene_manager, NfcSceneMifareDesfireApp, state | 1);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
return true;
} else if(event.type == SceneManagerEventTypeBack) {
if(state & 1) {
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneMifareDesfireApp, state & ~1);
return true;
}
}
return false;
}
void nfc_scene_mifare_desfire_app_on_exit(void* context) {
Nfc* nfc = (Nfc*)context;
text_box_reset(nfc->text_box);
string_reset(nfc->text_box_store);
submenu_reset(nfc->submenu);
}

View File

@@ -0,0 +1,108 @@
#include "../nfc_i.h"
#define TAG "NfcSceneMifareDesfireData"
enum {
MifareDesfireDataStateMenu,
MifareDesfireDataStateItem, // MUST be last, states >= this correspond with submenu index
};
enum SubmenuIndex {
SubmenuIndexCardInfo,
SubmenuIndexDynamic, // dynamic indexes start here
};
void nfc_scene_mifare_desfire_data_submenu_callback(void* context, uint32_t index) {
Nfc* nfc = (Nfc*)context;
view_dispatcher_send_custom_event(nfc->view_dispatcher, index);
}
void nfc_scene_mifare_desfire_data_on_enter(void* context) {
Nfc* nfc = (Nfc*)context;
Submenu* submenu = nfc->submenu;
uint32_t state = scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMifareDesfireData);
MifareDesfireData* data = &nfc->dev->dev_data.mf_df_data;
text_box_set_font(nfc->text_box, TextBoxFontHex);
submenu_add_item(
submenu,
"Card info",
SubmenuIndexCardInfo,
nfc_scene_mifare_desfire_data_submenu_callback,
nfc);
uint16_t cap = NFC_TEXT_STORE_SIZE;
char* buf = nfc->text_store;
int idx = SubmenuIndexDynamic;
for(MifareDesfireApplication* app = data->app_head; app; app = app->next) {
int size = snprintf(buf, cap, "App %02x%02x%02x", app->id[0], app->id[1], app->id[2]);
if(size < 0 || size >= cap) {
FURI_LOG_W(
TAG, "Exceeded NFC_TEXT_STORE_SIZE when preparing app id strings; menu truncated");
break;
}
char* label = buf;
cap -= size + 1;
buf += size + 1;
submenu_add_item(
submenu, label, idx++, nfc_scene_mifare_desfire_data_submenu_callback, nfc);
}
if(state >= MifareDesfireDataStateItem) {
submenu_set_selected_item(
nfc->submenu, state - MifareDesfireDataStateItem + SubmenuIndexDynamic);
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneMifareDesfireData, MifareDesfireDataStateMenu);
}
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
}
bool nfc_scene_mifare_desfire_data_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = (Nfc*)context;
uint32_t state = scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMifareDesfireData);
MifareDesfireData* data = &nfc->dev->dev_data.mf_df_data;
if(event.type == SceneManagerEventTypeCustom) {
TextBox* text_box = nfc->text_box;
string_reset(nfc->text_box_store);
if(event.event == SubmenuIndexCardInfo) {
mf_df_cat_card_info(data, nfc->text_box_store);
text_box_set_text(text_box, string_get_cstr(nfc->text_box_store));
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextBox);
scene_manager_set_scene_state(
nfc->scene_manager,
NfcSceneMifareDesfireData,
MifareDesfireDataStateItem + SubmenuIndexCardInfo);
return true;
} else {
uint16_t index = event.event - SubmenuIndexDynamic;
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneMifareDesfireData, MifareDesfireDataStateItem + index);
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneMifareDesfireApp, index << 1);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMifareDesfireApp);
return true;
}
} else if(event.type == SceneManagerEventTypeBack) {
if(state >= MifareDesfireDataStateItem) {
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneMifareDesfireData, MifareDesfireDataStateMenu);
return true;
}
}
return false;
}
void nfc_scene_mifare_desfire_data_on_exit(void* context) {
Nfc* nfc = (Nfc*)context;
text_box_reset(nfc->text_box);
string_reset(nfc->text_box_store);
submenu_reset(nfc->submenu);
}

View File

@@ -0,0 +1,52 @@
#include "../nfc_i.h"
enum SubmenuIndex {
SubmenuIndexSave,
};
void nfc_scene_mifare_desfire_menu_submenu_callback(void* context, uint32_t index) {
Nfc* nfc = (Nfc*)context;
view_dispatcher_send_custom_event(nfc->view_dispatcher, index);
}
void nfc_scene_mifare_desfire_menu_on_enter(void* context) {
Nfc* nfc = (Nfc*)context;
Submenu* submenu = nfc->submenu;
submenu_add_item(
submenu,
"Name and save",
SubmenuIndexSave,
nfc_scene_mifare_desfire_menu_submenu_callback,
nfc);
submenu_set_selected_item(
nfc->submenu,
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMifareDesfireMenu));
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
}
bool nfc_scene_mifare_desfire_menu_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = (Nfc*)context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexSave) {
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneMifareDesfireMenu, SubmenuIndexSave);
nfc->dev->format = NfcDeviceSaveFormatMifareDesfire;
// Clear device name
nfc_device_set_name(nfc->dev, "");
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
return true;
}
}
return false;
}
void nfc_scene_mifare_desfire_menu_on_exit(void* context) {
Nfc* nfc = (Nfc*)context;
submenu_reset(nfc->submenu);
}

View File

@@ -0,0 +1,56 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_read_mifare_desfire_worker_callback(void* context) {
Nfc* nfc = (Nfc*)context;
view_dispatcher_send_custom_event(nfc->view_dispatcher, NfcCustomEventWorkerExit);
}
void nfc_scene_read_mifare_desfire_on_enter(void* context) {
Nfc* nfc = (Nfc*)context;
DOLPHIN_DEED(DolphinDeedNfcRead);
// Setup view
Popup* popup = nfc->popup;
popup_set_header(popup, "Reading\nDESFire", 70, 34, AlignLeft, AlignTop);
popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
// Start worker
nfc_worker_start(
nfc->worker,
NfcWorkerStateReadMifareDesfire,
&nfc->dev->dev_data,
nfc_read_mifare_desfire_worker_callback,
nfc);
}
bool nfc_scene_read_mifare_desfire_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = (Nfc*)context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventWorkerExit) {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadMifareDesfireSuccess);
return true;
}
} else if(event.type == SceneManagerEventTypeTick) {
notification_message(nfc->notifications, &sequence_blink_blue_10);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
return true;
}
return false;
}
void nfc_scene_read_mifare_desfire_on_exit(void* context) {
Nfc* nfc = (Nfc*)context;
// Stop worker
nfc_worker_stop(nfc->worker);
// Clear view
Popup* popup = nfc->popup;
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_icon(popup, 0, 0, NULL);
}

View File

@@ -0,0 +1,106 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
#define NFC_SCENE_READ_SUCCESS_SHIFT " "
enum {
ReadMifareDesfireSuccessStateShowUID,
ReadMifareDesfireSuccessStateShowData,
};
void nfc_scene_read_mifare_desfire_success_dialog_callback(DialogExResult result, void* context) {
Nfc* nfc = (Nfc*)context;
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
}
void nfc_scene_read_mifare_desfire_success_on_enter(void* context) {
Nfc* nfc = (Nfc*)context;
MifareDesfireData* data = &nfc->dev->dev_data.mf_df_data;
DialogEx* dialog_ex = nfc->dialog_ex;
dialog_ex_set_left_button_text(dialog_ex, "Back");
dialog_ex_set_center_button_text(dialog_ex, "Data");
dialog_ex_set_right_button_text(dialog_ex, "More");
dialog_ex_set_icon(dialog_ex, 8, 16, &I_Medium_chip_22x21);
uint16_t n_apps = 0;
uint16_t n_files = 0;
for(MifareDesfireApplication* app = data->app_head; app; app = app->next) {
n_apps++;
for(MifareDesfireFile* file = app->file_head; file; file = file->next) {
n_files++;
}
}
nfc_text_store_set(
nfc,
"UID: %02X %02X %02X %02X %02X %02X %02X\n" NFC_SCENE_READ_SUCCESS_SHIFT
"%d%s bytes\n" NFC_SCENE_READ_SUCCESS_SHIFT "%d bytes free\n"
"%d application%s, %d file%s",
data->version.uid[0],
data->version.uid[1],
data->version.uid[2],
data->version.uid[3],
data->version.uid[4],
data->version.uid[5],
data->version.uid[6],
1 << (data->version.sw_storage >> 1),
(data->version.sw_storage & 1) ? "+" : "",
data->free_memory ? data->free_memory->bytes : 0,
n_apps,
n_apps == 1 ? "" : "s",
n_files,
n_files == 1 ? "" : "s");
dialog_ex_set_text(dialog_ex, nfc->text_store, 8, 6, AlignLeft, AlignTop);
dialog_ex_set_context(dialog_ex, nfc);
dialog_ex_set_result_callback(
dialog_ex, nfc_scene_read_mifare_desfire_success_dialog_callback);
scene_manager_set_scene_state(
nfc->scene_manager,
NfcSceneReadMifareDesfireSuccess,
ReadMifareDesfireSuccessStateShowUID);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDialogEx);
}
bool nfc_scene_read_mifare_desfire_success_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = context;
uint32_t state =
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadMifareDesfireSuccess);
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(state == ReadMifareDesfireSuccessStateShowUID && event.event == DialogExResultLeft) {
scene_manager_previous_scene(nfc->scene_manager);
consumed = true;
} else if(
state == ReadMifareDesfireSuccessStateShowUID && event.event == DialogExResultCenter) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMifareDesfireData);
consumed = true;
} else if(state == ReadMifareDesfireSuccessStateShowUID && event.event == DialogExResultRight) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMifareDesfireMenu);
consumed = true;
}
} else if(event.type == SceneManagerEventTypeBack) {
if(state == ReadMifareDesfireSuccessStateShowData) {
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDialogEx);
scene_manager_set_scene_state(
nfc->scene_manager,
NfcSceneReadMifareDesfireSuccess,
ReadMifareDesfireSuccessStateShowUID);
consumed = true;
}
}
return consumed;
}
void nfc_scene_read_mifare_desfire_success_on_exit(void* context) {
Nfc* nfc = (Nfc*)context;
// Clean dialog
DialogEx* dialog_ex = nfc->dialog_ex;
dialog_ex_reset(dialog_ex);
}

4
applications/nfc/scenes/nfc_scene_save_success.c Executable file → Normal file
View File

@@ -33,6 +33,10 @@ bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) {
} else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) {
consumed = scene_manager_search_and_switch_to_another_scene(
nfc->scene_manager, NfcSceneFileSelect);
} else if(scene_manager_has_previous_scene(
nfc->scene_manager, NfcSceneMifareDesfireMenu)) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneMifareDesfireMenu);
} else {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneStart);

17
applications/nfc/scenes/nfc_scene_saved_menu.c Executable file → Normal file
View File

@@ -18,9 +18,22 @@ void nfc_scene_saved_menu_on_enter(void* context) {
Nfc* nfc = (Nfc*)context;
Submenu* submenu = nfc->submenu;
if(nfc->dev->format != NfcDeviceSaveFormatBankCard) {
if(nfc->dev->format == NfcDeviceSaveFormatUid ||
nfc->dev->format == NfcDeviceSaveFormatMifareDesfire ||
nfc->dev->format == NfcDeviceSaveFormatBankCard) {
submenu_add_item(
submenu, "Emulate", SubmenuIndexEmulate, nfc_scene_saved_menu_submenu_callback, nfc);
submenu,
"Emulate UID",
SubmenuIndexEmulate,
nfc_scene_saved_menu_submenu_callback,
nfc);
} else if(nfc->dev->format == NfcDeviceSaveFormatMifareUl) {
submenu_add_item(
submenu,
"Emulate Ultralight",
SubmenuIndexEmulate,
nfc_scene_saved_menu_submenu_callback,
nfc);
}
submenu_add_item(
submenu, "Edit UID and name", SubmenuIndexEdit, nfc_scene_saved_menu_submenu_callback, nfc);

View File

@@ -3,6 +3,7 @@
enum SubmenuIndex {
SubmenuIndexBankCard,
SubmenuIndexMifareUltralight,
SubmenuIndexMifareDesfire,
};
void nfc_scene_scripts_menu_submenu_callback(void* context, uint32_t index) {
@@ -27,6 +28,12 @@ void nfc_scene_scripts_menu_on_enter(void* context) {
SubmenuIndexMifareUltralight,
nfc_scene_scripts_menu_submenu_callback,
nfc);
submenu_add_item(
submenu,
"Read Mifare DESFire",
SubmenuIndexMifareDesfire,
nfc_scene_scripts_menu_submenu_callback,
nfc);
submenu_set_selected_item(
nfc->submenu, scene_manager_get_scene_state(nfc->scene_manager, NfcSceneScriptsMenu));
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
@@ -46,6 +53,11 @@ bool nfc_scene_scripts_menu_on_event(void* context, SceneManagerEvent event) {
nfc->scene_manager, NfcSceneScriptsMenu, SubmenuIndexMifareUltralight);
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadMifareUl);
return true;
} else if(event.event == SubmenuIndexMifareDesfire) {
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneScriptsMenu, SubmenuIndexMifareDesfire);
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadMifareDesfire);
return true;
}
}