mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-24 05:23:06 +00:00
9c59bcd776
* nfc: add new read scene * lib: refactore nfc library * mifare desfire: add read card fuction * lib nfc: add auto read worker * nfc: add supported cards * nfc: add mifare classic read success scene * nfc: add troyka support * submodule: update protobuf * nfc: mifare classic keys cache * nfc: rework mifare classic key cache * Correct spelling * nfc: add user dictionary * nfc: introduce block read map in fff * nfc: rework dict attack * nfc: improve dict attack * nfc: rework mifare classic format * nfc: rework MFC read with Reader * nfc: add gui for MFC read success scene * nfc: fix dict attack view gui * nfc: add retry and exit confirm scenes * nfc: add retry and exit scenes navigation * nfc: check user dictionary * nfc: remove unused scenes * nfc: rename functions in nfc worker * nfc: rename mf_classic_dict_attack -> dict_attack * nfc: change scenes names * nfc: remove scene tick events * nfc: rework dict calls with buffer streams * nfc: fix notifications * nfc: fix mf desfire navigation * nfc: remove notification from mf classic read success * nfc: fix read sectors calculation * nfc: add fallback for unknown card * nfc: show file name while emulating * nfc: fix build * nfc: fix memory leak * nfc: fix desfire read * nfc: add no dict found navigation * nfc: add read views * nfc: update card fix * nfc: fix access bytes save * nfc: add exit and retry confirm to mf ultralight read success * nfc: introduce detect reader * nfc: change record open arg to macros * nfc: fix start from archive Co-authored-by: Astra <astra@astrra.space> Co-authored-by: あく <alleteam@gmail.com>
83 lines
2.9 KiB
C
Executable file
83 lines
2.9 KiB
C
Executable file
#include "../nfc_i.h"
|
|
#include <dolphin/dolphin.h>
|
|
|
|
void nfc_scene_read_card_success_widget_callback(
|
|
GuiButtonType result,
|
|
InputType type,
|
|
void* context) {
|
|
furi_assert(context);
|
|
Nfc* nfc = context;
|
|
|
|
if(type == InputTypeShort) {
|
|
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
|
|
}
|
|
}
|
|
|
|
void nfc_scene_read_card_success_on_enter(void* context) {
|
|
Nfc* nfc = context;
|
|
|
|
string_t data_str;
|
|
string_t uid_str;
|
|
string_init(data_str);
|
|
string_init(uid_str);
|
|
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
|
|
|
|
// Setup view
|
|
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
|
|
Widget* widget = nfc->widget;
|
|
string_set_str(data_str, nfc_get_dev_type(data->type));
|
|
string_set_str(uid_str, "UID:");
|
|
for(uint8_t i = 0; i < data->uid_len; i++) {
|
|
string_cat_printf(uid_str, " %02X", data->uid[i]);
|
|
}
|
|
|
|
widget_add_button_element(
|
|
widget, GuiButtonTypeLeft, "Retry", nfc_scene_read_card_success_widget_callback, nfc);
|
|
if(data->type == FuriHalNfcTypeA) {
|
|
widget_add_button_element(
|
|
widget, GuiButtonTypeRight, "Save", nfc_scene_read_card_success_widget_callback, nfc);
|
|
widget_add_icon_element(widget, 8, 13, &I_Medium_chip_22x21);
|
|
widget_add_string_element(
|
|
widget, 37, 12, AlignLeft, AlignBottom, FontPrimary, string_get_cstr(data_str));
|
|
string_printf(
|
|
data_str, "ATQA: %02X%02X\nSAK: %02X", data->atqa[0], data->atqa[1], data->sak);
|
|
widget_add_string_multiline_element(
|
|
widget, 37, 16, AlignLeft, AlignTop, FontSecondary, string_get_cstr(data_str));
|
|
widget_add_string_element(
|
|
widget, 64, 46, AlignCenter, AlignBottom, FontSecondary, string_get_cstr(uid_str));
|
|
} else {
|
|
widget_add_string_element(
|
|
widget, 64, 12, AlignCenter, AlignBottom, FontPrimary, string_get_cstr(data_str));
|
|
widget_add_string_element(
|
|
widget, 64, 32, AlignCenter, AlignCenter, FontSecondary, string_get_cstr(uid_str));
|
|
}
|
|
|
|
string_clear(data_str);
|
|
string_clear(uid_str);
|
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
|
}
|
|
|
|
bool nfc_scene_read_card_success_on_event(void* context, SceneManagerEvent event) {
|
|
Nfc* nfc = context;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
if(event.event == GuiButtonTypeLeft) {
|
|
consumed = scene_manager_previous_scene(nfc->scene_manager);
|
|
} else if(event.event == GuiButtonTypeRight) {
|
|
nfc->dev->format = NfcDeviceSaveFormatUid;
|
|
nfc_device_set_name(nfc->dev, "");
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
|
consumed = true;
|
|
}
|
|
}
|
|
return consumed;
|
|
}
|
|
|
|
void nfc_scene_read_card_success_on_exit(void* context) {
|
|
Nfc* nfc = context;
|
|
|
|
// Clear view
|
|
widget_reset(nfc->widget);
|
|
}
|