|
| 1 | +#include "../nfc_i.h" |
| 2 | + |
| 3 | +void nfc_scene_mf_classic_info_widget_callback(GuiButtonType result, InputType type, void* context) { |
| 4 | + furi_assert(context); |
| 5 | + Nfc* nfc = context; |
| 6 | + |
| 7 | + if(type == InputTypeShort) { |
| 8 | + view_dispatcher_send_custom_event(nfc->view_dispatcher, result); |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +void nfc_scene_mf_classic_info_on_enter(void* context) { |
| 13 | + Nfc* nfc = context; |
| 14 | + NfcDeviceData* dev_data = &nfc->dev->dev_data; |
| 15 | + MfClassicData* mf_data = &dev_data->mf_classic_data; |
| 16 | + string_t str_tmp; |
| 17 | + string_init(str_tmp); |
| 18 | + |
| 19 | + // Setup view |
| 20 | + Widget* widget = nfc->widget; |
| 21 | + |
| 22 | + widget_add_string_element( |
| 23 | + widget, 0, 0, AlignLeft, AlignTop, FontSecondary, mf_classic_get_type_str(mf_data->type)); |
| 24 | + widget_add_string_element( |
| 25 | + widget, 0, 11, AlignLeft, AlignTop, FontSecondary, "ISO 14443-3 (Type A)"); |
| 26 | + string_printf(str_tmp, "UID:"); |
| 27 | + for(size_t i = 0; i < dev_data->nfc_data.uid_len; i++) { |
| 28 | + string_cat_printf(str_tmp, " %02X", dev_data->nfc_data.uid[i]); |
| 29 | + } |
| 30 | + widget_add_string_element( |
| 31 | + widget, 0, 22, AlignLeft, AlignTop, FontSecondary, string_get_cstr(str_tmp)); |
| 32 | + string_printf( |
| 33 | + str_tmp, |
| 34 | + "ATQA: %02X %02X SAK: %02X", |
| 35 | + dev_data->nfc_data.atqa[0], |
| 36 | + dev_data->nfc_data.atqa[1], |
| 37 | + dev_data->nfc_data.sak); |
| 38 | + widget_add_string_element( |
| 39 | + widget, 0, 33, AlignLeft, AlignTop, FontSecondary, string_get_cstr(str_tmp)); |
| 40 | + uint8_t sectors_total = mf_classic_get_total_sectors_num(mf_data->type); |
| 41 | + uint8_t keys_total = sectors_total * 2; |
| 42 | + uint8_t keys_found = 0; |
| 43 | + uint8_t sectors_read = 0; |
| 44 | + mf_classic_get_read_sectors_and_keys(mf_data, §ors_read, &keys_found); |
| 45 | + string_printf(str_tmp, "Keys Found: %d/%d", keys_found, keys_total); |
| 46 | + widget_add_string_element( |
| 47 | + widget, 0, 44, AlignLeft, AlignTop, FontSecondary, string_get_cstr(str_tmp)); |
| 48 | + string_printf(str_tmp, "Sectors Read: %d/%d", sectors_read, sectors_total); |
| 49 | + widget_add_string_element( |
| 50 | + widget, 0, 55, AlignLeft, AlignTop, FontSecondary, string_get_cstr(str_tmp)); |
| 51 | + |
| 52 | + string_clear(str_tmp); |
| 53 | + view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); |
| 54 | +} |
| 55 | + |
| 56 | +bool nfc_scene_mf_classic_info_on_event(void* context, SceneManagerEvent event) { |
| 57 | + Nfc* nfc = context; |
| 58 | + bool consumed = false; |
| 59 | + |
| 60 | + if(event.type == SceneManagerEventTypeBack) { |
| 61 | + consumed = scene_manager_previous_scene(nfc->scene_manager); |
| 62 | + } |
| 63 | + |
| 64 | + return consumed; |
| 65 | +} |
| 66 | + |
| 67 | +void nfc_scene_mf_classic_info_on_exit(void* context) { |
| 68 | + Nfc* nfc = context; |
| 69 | + |
| 70 | + // Clear view |
| 71 | + widget_reset(nfc->widget); |
| 72 | +} |
0 commit comments