2022-07-04 11:16:59 +00:00
|
|
|
#include "../nfc_i.h"
|
2022-12-10 13:02:34 +00:00
|
|
|
#include "lib/nfc/helpers/nfc_generators.h"
|
2022-07-04 11:16:59 +00:00
|
|
|
|
|
|
|
void nfc_scene_generate_info_dialog_callback(DialogExResult result, void* context) {
|
|
|
|
Nfc* nfc = context;
|
|
|
|
|
|
|
|
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_scene_generate_info_on_enter(void* context) {
|
|
|
|
Nfc* nfc = context;
|
|
|
|
|
|
|
|
// Setup dialog view
|
|
|
|
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
|
|
|
|
DialogEx* dialog_ex = nfc->dialog_ex;
|
|
|
|
dialog_ex_set_right_button_text(dialog_ex, "More");
|
|
|
|
|
|
|
|
// Create info text
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* info_str = furi_string_alloc_printf(
|
|
|
|
"%s\n%s\nUID:", nfc->generator->name, nfc_get_dev_type(data->type));
|
|
|
|
|
2022-07-04 11:16:59 +00:00
|
|
|
// Append UID
|
|
|
|
for(int i = 0; i < data->uid_len; ++i) {
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_cat_printf(info_str, " %02X", data->uid[i]);
|
2022-07-04 11:16:59 +00:00
|
|
|
}
|
2022-10-05 15:15:23 +00:00
|
|
|
nfc_text_store_set(nfc, furi_string_get_cstr(info_str));
|
|
|
|
furi_string_free(info_str);
|
2022-07-04 11:16:59 +00:00
|
|
|
|
|
|
|
dialog_ex_set_text(dialog_ex, nfc->text_store, 0, 0, AlignLeft, AlignTop);
|
|
|
|
dialog_ex_set_context(dialog_ex, nfc);
|
|
|
|
dialog_ex_set_result_callback(dialog_ex, nfc_scene_generate_info_dialog_callback);
|
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDialogEx);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nfc_scene_generate_info_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
Nfc* nfc = context;
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
if(event.event == DialogExResultRight) {
|
2022-12-10 13:02:34 +00:00
|
|
|
// Switch either to NfcSceneMfClassicMenu or NfcSceneMfUltralightMenu
|
|
|
|
if(nfc->dev->dev_data.protocol == NfcDeviceProtocolMifareClassic) {
|
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicMenu);
|
|
|
|
} else if(nfc->dev->dev_data.protocol == NfcDeviceProtocolMifareUl) {
|
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightMenu);
|
|
|
|
}
|
2022-07-04 11:16:59 +00:00
|
|
|
consumed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_scene_generate_info_on_exit(void* context) {
|
|
|
|
Nfc* nfc = context;
|
|
|
|
|
|
|
|
// Clean views
|
|
|
|
dialog_ex_reset(nfc->dialog_ex);
|
|
|
|
}
|