Merge remote-tracking branch 'RebornedBrain/reborned/nfc_ui_refactor_2' into nfc_refactors_fixes_merge

This commit is contained in:
MX 2024-01-30 22:57:32 +03:00
commit 67eb679435
No known key found for this signature in database
GPG key ID: 7CCC66B7DBDD1C83
25 changed files with 126 additions and 47 deletions

View file

@ -13,6 +13,7 @@ static void nfc_scene_info_on_enter_felica(NfcApp* instance) {
const FelicaData* data = nfc_device_get_data(device, NfcProtocolFelica);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_felica_info(data, NfcProtocolFormatTypeFull, temp_str);

View file

@ -13,6 +13,8 @@ static void nfc_scene_info_on_enter_iso14443_3a(NfcApp* instance) {
const Iso14443_3aData* data = nfc_device_get_data(device, NfcProtocolIso14443_3a);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_iso14443_3a_info(data, NfcProtocolFormatTypeFull, temp_str);

View file

@ -6,13 +6,17 @@ void nfc_render_iso14443_3a_format_bytes(FuriString* str, const uint8_t* const d
}
}
void nfc_render_iso14443_tech_type(const Iso14443_3aData* data, FuriString* str) {
const char iso_type = iso14443_3a_supports_iso14443_4(data) ? '4' : '3';
furi_string_cat_printf(str, "Tech: ISO 14443-%c (NFC-A)\n", iso_type);
}
void nfc_render_iso14443_3a_info(
const Iso14443_3aData* data,
NfcProtocolFormatType format_type,
FuriString* str) {
if(format_type == NfcProtocolFormatTypeFull) {
const char iso_type = iso14443_3a_supports_iso14443_4(data) ? '4' : '3';
furi_string_cat_printf(str, "ISO 14443-%c (NFC-A)\n", iso_type);
nfc_render_iso14443_tech_type(data, str);
}
nfc_render_iso14443_3a_brief(data, str);
@ -30,5 +34,5 @@ void nfc_render_iso14443_3a_brief(const Iso14443_3aData* data, FuriString* str)
void nfc_render_iso14443_3a_extra(const Iso14443_3aData* data, FuriString* str) {
furi_string_cat_printf(str, "\nATQA: %02X %02X ", data->atqa[1], data->atqa[0]);
furi_string_cat_printf(str, "SAK: %02X", data->sak);
furi_string_cat_printf(str, "\nSAK: %02X", data->sak);
}

View file

@ -9,6 +9,8 @@ void nfc_render_iso14443_3a_info(
NfcProtocolFormatType format_type,
FuriString* str);
void nfc_render_iso14443_tech_type(const Iso14443_3aData* data, FuriString* str);
void nfc_render_iso14443_3a_format_bytes(FuriString* str, const uint8_t* const data, size_t size);
void nfc_render_iso14443_3a_brief(const Iso14443_3aData* data, FuriString* str);

View file

@ -13,6 +13,7 @@ static void nfc_scene_info_on_enter_iso14443_3b(NfcApp* instance) {
const Iso14443_3bData* data = nfc_device_get_data(device, NfcProtocolIso14443_3b);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_iso14443_3b_info(data, NfcProtocolFormatTypeFull, temp_str);

View file

@ -6,7 +6,7 @@ void nfc_render_iso14443_3b_info(
FuriString* str) {
if(format_type == NfcProtocolFormatTypeFull) {
const char iso_type = iso14443_3b_supports_iso14443_4(data) ? '4' : '3';
furi_string_cat_printf(str, "ISO 14443-%c (NFC-B)\n", iso_type);
furi_string_cat_printf(str, "Tech: ISO 14443-%c (NFC-B)\n", iso_type);
}
furi_string_cat_printf(str, "UID:");
@ -20,7 +20,7 @@ void nfc_render_iso14443_3b_info(
if(format_type != NfcProtocolFormatTypeFull) return;
furi_string_cat_printf(str, "\n\e#Protocol info\n");
furi_string_cat_printf(str, "\n::::::::::::::::[Protocol info]:::::::::::::::\n");
if(iso14443_3b_supports_bit_rate(data, Iso14443_3bBitRateBoth106Kbit)) {
furi_string_cat(str, "Bit rate PICC <-> PCD:\n 106 kBit/s supported\n");
@ -68,7 +68,7 @@ void nfc_render_iso14443_3b_info(
iso14443_3b_supports_frame_option(data, Iso14443_3bFrameOptionCid) ? "" : "not ";
furi_string_cat_printf(str, "CID: %ssupported", cid_support_str);
furi_string_cat_printf(str, "\n\e#Application data\nRaw:");
furi_string_cat_printf(str, "\n::::::::::::[Application data]::::::::::::\nRaw:");
size_t app_data_size;
const uint8_t* app_data = iso14443_3b_get_application_data(data, &app_data_size);

View file

@ -14,6 +14,7 @@ static void nfc_scene_info_on_enter_iso14443_4a(NfcApp* instance) {
const Iso14443_4aData* data = nfc_device_get_data(device, NfcProtocolIso14443_4a);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_iso14443_4a_info(data, NfcProtocolFormatTypeFull, temp_str);

View file

@ -14,11 +14,12 @@ void nfc_render_iso14443_4a_info(
}
void nfc_render_iso14443_4a_brief(const Iso14443_4aData* data, FuriString* str) {
nfc_render_iso14443_tech_type(iso14443_4a_get_base_data(data), str);
nfc_render_iso14443_3a_brief(iso14443_4a_get_base_data(data), str);
}
void nfc_render_iso14443_4a_extra(const Iso14443_4aData* data, FuriString* str) {
furi_string_cat_printf(str, "\n\e#Protocol info\n");
furi_string_cat_printf(str, "\n::::::::::::::::[Protocol info]:::::::::::::::\n");
if(iso14443_4a_supports_bit_rate(data, Iso14443_4aBitRateBoth106Kbit)) {
furi_string_cat(str, "Bit rate PICC <-> PCD:\n 106 kBit/s supported\n");
@ -72,7 +73,7 @@ void nfc_render_iso14443_4a_extra(const Iso14443_4aData* data, FuriString* str)
const uint8_t* hist_bytes = iso14443_4a_get_historical_bytes(data, &hist_bytes_count);
if(hist_bytes_count > 0) {
furi_string_cat_printf(str, "\n\e#Historical bytes\nRaw:");
furi_string_cat_printf(str, "\n:::::::::::::[Historical bytes]:::::::::::::\nRaw:");
for(size_t i = 0; i < hist_bytes_count; ++i) {
furi_string_cat_printf(str, " %02X", hist_bytes[i]);

View file

@ -14,6 +14,7 @@ static void nfc_scene_info_on_enter_iso14443_4b(NfcApp* instance) {
const Iso14443_4bData* data = nfc_device_get_data(device, NfcProtocolIso14443_4b);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_iso14443_4b_info(data, NfcProtocolFormatTypeFull, temp_str);

View file

@ -14,16 +14,30 @@ static void nfc_scene_info_on_enter_iso15693_3(NfcApp* instance) {
const Iso15693_3Data* data = nfc_device_get_data(device, NfcProtocolIso15693_3);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_iso15693_3_info(data, NfcProtocolFormatTypeFull, temp_str);
widget_reset(instance->widget);
widget_add_text_scroll_element(
instance->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
furi_string_free(temp_str);
}
static void nfc_scene_more_info_on_enter_iso15693_3(NfcApp* instance) {
const NfcDevice* device = instance->nfc_device;
const Iso15693_3Data* data = nfc_device_get_data(device, NfcProtocolIso15693_3);
FuriString* temp_str = furi_string_alloc();
nfc_render_iso15693_3_system_info(data, temp_str);
widget_add_text_scroll_element(
instance->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
furi_string_free(temp_str);
}
static NfcCommand nfc_scene_read_poller_callback_iso15693_3(NfcGenericEvent event, void* context) {
furi_assert(event.protocol == NfcProtocolIso15693_3);
@ -104,13 +118,19 @@ static bool nfc_scene_saved_menu_on_event_iso15693_3(NfcApp* instance, uint32_t
}
const NfcProtocolSupportBase nfc_protocol_support_iso15693_3 = {
.features = NfcProtocolFeatureEmulateFull | NfcProtocolFeatureEditUid,
.features = NfcProtocolFeatureEmulateFull | NfcProtocolFeatureEditUid |
NfcProtocolFeatureMoreInfo,
.scene_info =
{
.on_enter = nfc_scene_info_on_enter_iso15693_3,
.on_event = nfc_protocol_support_common_on_event_empty,
},
.scene_more_info =
{
.on_enter = nfc_scene_more_info_on_enter_iso15693_3,
.on_event = nfc_protocol_support_common_on_event_empty,
},
.scene_read =
{
.on_enter = nfc_scene_read_on_enter_iso15693_3,

View file

@ -36,32 +36,7 @@ void nfc_render_iso15693_3_brief(const Iso15693_3Data* data, FuriString* str) {
}
}
void nfc_render_iso15693_3_extra(const Iso15693_3Data* data, FuriString* str) {
furi_string_cat(str, "\n\e#General info\n");
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_DSFID) {
furi_string_cat_printf(str, "DSFID: %02X\n", data->system_info.ic_ref);
}
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_AFI) {
furi_string_cat_printf(str, "AFI: %02X\n", data->system_info.afi);
}
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_IC_REF) {
furi_string_cat_printf(str, "IC Reference: %02X\n", data->system_info.ic_ref);
}
furi_string_cat(str, "\e#Lock bits\n");
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_DSFID) {
furi_string_cat_printf(
str, "DSFID: %s locked\n", data->settings.lock_bits.dsfid ? "" : "not");
}
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_AFI) {
furi_string_cat_printf(
str, "AFI: %s locked\n", data->settings.lock_bits.dsfid ? "" : "not");
}
void nfc_render_iso15693_3_system_info(const Iso15693_3Data* data, FuriString* str) {
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_MEMORY) {
furi_string_cat(str, "\e#Memory data\n\e*--------------------\n");
@ -88,5 +63,34 @@ void nfc_render_iso15693_3_extra(const Iso15693_3Data* data, FuriString* str) {
"(Data is too big. Showing only the first %u bytes.)",
display_block_count * block_size);
}
} else {
furi_string_cat(str, "\e#No available data\n");
}
}
void nfc_render_iso15693_3_extra(const Iso15693_3Data* data, FuriString* str) {
furi_string_cat(str, "\n::::::::::::::::[General info]:::::::::::::::::\n");
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_DSFID) {
furi_string_cat_printf(str, "DSFID: %02X\n", data->system_info.ic_ref);
}
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_AFI) {
furi_string_cat_printf(str, "AFI: %02X\n", data->system_info.afi);
}
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_IC_REF) {
furi_string_cat_printf(str, "IC Reference: %02X\n", data->system_info.ic_ref);
}
furi_string_cat(str, ":::::::::::::::::::[Lock bits]::::::::::::::::::::\n");
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_DSFID) {
furi_string_cat_printf(
str, "DSFID: %s locked\n", data->settings.lock_bits.dsfid ? "" : "not");
}
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_AFI) {
furi_string_cat_printf(
str, "AFI: %s locked\n", data->settings.lock_bits.dsfid ? "" : "not");
}
}

View file

@ -12,3 +12,5 @@ void nfc_render_iso15693_3_info(
void nfc_render_iso15693_3_brief(const Iso15693_3Data* data, FuriString* str);
void nfc_render_iso15693_3_extra(const Iso15693_3Data* data, FuriString* str);
void nfc_render_iso15693_3_system_info(const Iso15693_3Data* data, FuriString* str);

View file

@ -21,6 +21,7 @@ static void nfc_scene_info_on_enter_mf_classic(NfcApp* instance) {
const MfClassicData* data = nfc_device_get_data(device, NfcProtocolMfClassic);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
furi_string_replace(temp_str, "Mifare", "MIFARE");

View file

@ -14,8 +14,10 @@ static void nfc_scene_info_on_enter_mf_desfire(NfcApp* instance) {
const MfDesfireData* data = nfc_device_get_data(device, NfcProtocolMfDesfire);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
furi_string_replace(temp_str, "Mifare", "MIFARE");
nfc_render_mf_desfire_info(data, NfcProtocolFormatTypeFull, temp_str);
widget_add_text_scroll_element(
@ -56,6 +58,7 @@ static void nfc_scene_read_success_on_enter_mf_desfire(NfcApp* instance) {
FuriString* temp_str = furi_string_alloc();
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
furi_string_replace(temp_str, "Mifare", "MIFARE");
nfc_render_mf_desfire_info(data, NfcProtocolFormatTypeShort, temp_str);
widget_add_text_scroll_element(

View file

@ -20,6 +20,8 @@ static void nfc_scene_info_on_enter_mf_ultralight(NfcApp* instance) {
const MfUltralightData* data = nfc_device_get_data(device, NfcProtocolMfUltralight);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_mf_ultralight_info(data, NfcProtocolFormatTypeFull, temp_str);

View file

@ -565,11 +565,11 @@ static void nfc_protocol_support_scene_emulate_on_enter(NfcApp* instance) {
FuriString* temp_str = furi_string_alloc();
const NfcProtocol protocol = nfc_device_get_protocol(instance->nfc_device);
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_47x61);
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_51x64);
if(nfc_protocol_support_has_feature(protocol, NfcProtocolFeatureEmulateUid)) {
widget_add_string_element(
widget, 90, 13, AlignCenter, AlignTop, FontPrimary, "Emulating UID");
widget, 90, 26, AlignCenter, AlignCenter, FontPrimary, "Emulating UID");
size_t uid_len;
const uint8_t* uid = nfc_device_get_uid(instance->nfc_device, &uid_len);
@ -581,7 +581,8 @@ static void nfc_protocol_support_scene_emulate_on_enter(NfcApp* instance) {
furi_string_trim(temp_str);
} else {
widget_add_string_element(widget, 90, 13, AlignCenter, AlignTop, FontPrimary, "Emulating");
widget_add_string_element(
widget, 90, 26, AlignCenter, AlignCenter, FontPrimary, "Emulating");
if(!furi_string_empty(instance->file_name)) {
furi_string_printf(
temp_str,
@ -593,11 +594,12 @@ static void nfc_protocol_support_scene_emulate_on_enter(NfcApp* instance) {
temp_str,
"Unsaved\n%s",
nfc_device_get_name(instance->nfc_device, NfcDeviceNameTypeFull));
furi_string_replace_str(temp_str, "Mifare", "MIFARE");
}
}
widget_add_text_box_element(
widget, 56, 28, 71, 25, AlignCenter, AlignTop, furi_string_get_cstr(temp_str), false);
widget, 56, 33, 71, 25, AlignCenter, AlignTop, furi_string_get_cstr(temp_str), false);
furi_string_free(temp_str);

View file

@ -14,16 +14,30 @@ static void nfc_scene_info_on_enter_slix(NfcApp* instance) {
const SlixData* data = nfc_device_get_data(device, NfcProtocolSlix);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_slix_info(data, NfcProtocolFormatTypeFull, temp_str);
widget_reset(instance->widget);
widget_add_text_scroll_element(
instance->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
furi_string_free(temp_str);
}
static void nfc_scene_more_info_on_enter_slix(NfcApp* instance) {
const NfcDevice* device = instance->nfc_device;
const SlixData* data = nfc_device_get_data(device, NfcProtocolSlix);
FuriString* temp_str = furi_string_alloc();
nfc_render_iso15693_3_system_info(slix_get_base_data(data), temp_str);
widget_add_text_scroll_element(
instance->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str));
furi_string_free(temp_str);
}
static NfcCommand nfc_scene_read_poller_callback_slix(NfcGenericEvent event, void* context) {
furi_assert(event.protocol == NfcProtocolSlix);
@ -101,13 +115,18 @@ static bool nfc_scene_saved_menu_on_event_slix(NfcApp* instance, uint32_t event)
}
const NfcProtocolSupportBase nfc_protocol_support_slix = {
.features = NfcProtocolFeatureEmulateFull,
.features = NfcProtocolFeatureEmulateFull | NfcProtocolFeatureMoreInfo,
.scene_info =
{
.on_enter = nfc_scene_info_on_enter_slix,
.on_event = nfc_protocol_support_common_on_event_empty,
},
.scene_more_info =
{
.on_enter = nfc_scene_more_info_on_enter_slix,
.on_event = nfc_protocol_support_common_on_event_empty,
},
.scene_read =
{
.on_enter = nfc_scene_read_on_enter_slix,

View file

@ -1,14 +1,12 @@
#include "slix_render.h"
#include "../iso15693_3/iso15693_3_render.h"
void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_type, FuriString* str) {
nfc_render_iso15693_3_brief(slix_get_base_data(data), str);
if(format_type != NfcProtocolFormatTypeFull) return;
const SlixType slix_type = slix_get_type(data);
furi_string_cat(str, "\n\e#Passwords\n");
furi_string_cat(str, "\n::::::::::::::::::[Passwords]:::::::::::::::::\n");
static const char* slix_password_names[] = {
"Read",
@ -25,7 +23,7 @@ void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_typ
}
}
furi_string_cat(str, "\e#Lock bits\n");
furi_string_cat(str, ":::::::::::::::::::[Lock bits]::::::::::::::::::::\n");
if(slix_type_has_features(slix_type, SLIX_TYPE_FEATURE_EAS)) {
furi_string_cat_printf(
@ -38,7 +36,7 @@ void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_typ
const SlixProtection protection = data->system_info.protection;
furi_string_cat(str, "\e#Page protection\n");
furi_string_cat(str, "::::::::::::[Page protection]::::::::::::\n");
furi_string_cat_printf(str, "Pointer: H >= %02X\n", protection.pointer);
const char* rh = (protection.condition & SLIX_PP_CONDITION_RH) ? "" : "un";
@ -52,12 +50,12 @@ void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_typ
}
if(slix_type_has_features(slix_type, SLIX_TYPE_FEATURE_PRIVACY)) {
furi_string_cat(str, "\e#Privacy\n");
furi_string_cat(str, "::::::::::::::::::::[Privacy]::::::::::::::::::::::\n");
furi_string_cat_printf(str, "Privacy mode: %sabled\n", data->privacy ? "en" : "dis");
}
if(slix_type_has_features(slix_type, SLIX_TYPE_FEATURE_SIGNATURE)) {
furi_string_cat(str, "\e#Signature\n");
furi_string_cat(str, ":::::::::::::::::::[Signature]::::::::::::::::::\n");
for(uint32_t i = 0; i < 4; ++i) {
furi_string_cat_printf(str, "%02X ", data->signature[i]);
}

View file

@ -3,5 +3,6 @@
#include <nfc/protocols/slix/slix.h>
#include "../nfc_protocol_support_render_common.h"
#include "../iso15693_3/iso15693_3_render.h"
void nfc_render_slix_info(const SlixData* data, NfcProtocolFormatType format_type, FuriString* str);

View file

@ -13,6 +13,7 @@ static void nfc_scene_info_on_enter_st25tb(NfcApp* instance) {
const St25tbData* data = nfc_device_get_data(device, NfcProtocolSt25tb);
FuriString* temp_str = furi_string_alloc();
nfc_append_filename_string_when_present(instance, temp_str);
furi_string_cat_printf(
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
nfc_render_st25tb_info(data, NfcProtocolFormatTypeFull, temp_str);

View file

@ -445,6 +445,15 @@ void nfc_app_reset_detected_protocols(NfcApp* instance) {
instance->protocols_detected_num = 0;
}
void nfc_append_filename_string_when_present(NfcApp* instance, FuriString* string) {
furi_assert(instance);
furi_assert(string);
if(!furi_string_empty(instance->file_name)) {
furi_string_cat_printf(string, "Name:%s\n", furi_string_get_cstr(instance->file_name));
}
}
static bool nfc_is_hal_ready() {
if(furi_hal_nfc_is_hal_ready() != FuriHalNfcErrorNone) {
// No connection to the chip, show an error screen

View file

@ -193,3 +193,5 @@ void nfc_make_app_folder(NfcApp* instance);
void nfc_app_set_detected_protocols(NfcApp* instance, const NfcProtocol* types, uint32_t count);
void nfc_app_reset_detected_protocols(NfcApp* instance);
void nfc_append_filename_string_when_present(NfcApp* instance, FuriString* string);

View file

@ -29,6 +29,8 @@ void nfc_scene_select_protocol_on_enter(void* context) {
"%s %s",
prefix,
nfc_device_get_protocol_name(instance->protocols_detected[i]));
furi_string_replace_str(temp_str, "Mifare", "MIFARE");
submenu_add_item(
submenu,
furi_string_get_cstr(temp_str),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB