code cleanup, gui fixes

This commit is contained in:
Methodius
2024-02-02 17:32:02 +09:00
committed by Nikita Vostokov
parent b1674711a1
commit ec356626fa
6 changed files with 45 additions and 64 deletions

View File

@@ -63,11 +63,6 @@ void nfc_render_emv_pan(const uint8_t* data, const uint8_t len, FuriString* str)
furi_string_cat_printf(str, "\n");
}
void nfc_render_emv_expired(const EmvApplication* apl, FuriString* str) {
if(apl->exp_month == 0) return;
furi_string_cat_printf(str, "Exp: %02X/%02X\n", apl->exp_month, apl->exp_year);
}
void nfc_render_emv_currency(uint16_t cur_code, FuriString* str) {
if(!cur_code) return;
@@ -88,37 +83,9 @@ void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) {
return;
}
furi_string_cat_printf(str, "Application:\n");
if(strlen(apl->label)) {
furi_string_cat_printf(str, " Label: %s", apl->label);
furi_string_cat_printf(str, "\n");
}
if(strlen(apl->name)) {
furi_string_cat_printf(str, " Name: %s", apl->name);
furi_string_cat_printf(str, "\n");
}
furi_string_cat_printf(str, " AID:");
for(uint8_t i = 0; i < len; i++) furi_string_cat_printf(str, "%02X", apl->aid[i]);
furi_string_cat_printf(str, "\n");
if(apl->eff_month) {
furi_string_cat_printf(
str, " Effective: 20%02X/%02X/%02X", apl->eff_year, apl->eff_month, apl->eff_day);
furi_string_cat_printf(str, "\n");
}
if(apl->exp_month) {
furi_string_cat_printf(
str, " Expire: 20%02X/%02X/%02X", apl->exp_year, apl->exp_month, apl->exp_day);
furi_string_cat_printf(str, "\n");
}
}
static void nfc_render_emv_pin_try_counter(uint8_t counter, FuriString* str) {
if(counter == 0xff) return;
furi_string_cat_printf(str, "PIN attempts left: %d\n", counter);
}
void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) {
@@ -207,5 +174,4 @@ void nfc_render_emv_extra(const EmvData* data, FuriString* str) {
nfc_render_emv_currency(data->emv_application.currency_code, str);
nfc_render_emv_country(data->emv_application.country_code, str);
nfc_render_emv_pin_try_counter(data->emv_application.pin_try_counter, str);
}

View File

@@ -17,8 +17,6 @@ void nfc_render_emv_application(const EmvApplication* data, FuriString* str);
void nfc_render_emv_extra(const EmvData* data, FuriString* str);
void nfc_render_emv_expired(const EmvApplication* apl, FuriString* str);
void nfc_render_emv_country(uint16_t country_code, FuriString* str);
void nfc_render_emv_currency(uint16_t cur_code, FuriString* str);

View File

@@ -73,8 +73,8 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
const EmvApplication app = data->emv_application;
do {
if(strlen(app.label))
furi_string_cat_printf(parsed_data, "\e#%s\n", app.label);
if(strlen(app.payment_sys))
furi_string_cat_printf(parsed_data, "\e#%s\n", app.payment_sys);
else
furi_string_cat_printf(parsed_data, "\e#%s\n", "EMV");
@@ -87,12 +87,29 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) {
// Cut padding 'F' from card number
size_t end = furi_string_search_rchar(pan, 'F');
if(end) furi_string_left(pan, end);
furi_string_cat_printf(pan, "\n");
furi_string_cat(parsed_data, pan);
furi_string_free(pan);
}
if(app.exp_month | app.exp_year)
furi_string_cat_printf(parsed_data, "\nExp: %02X/%02X\n", app.exp_month, app.exp_year);
if(strlen(app.name)) furi_string_cat_printf(parsed_data, "Name: %s\n", app.name);
if(app.issue_month)
furi_string_cat_printf(
parsed_data,
"Issue: %02X.%02X.20%02X\n",
app.issue_day,
app.issue_month,
app.issue_year);
if(app.exp_month)
furi_string_cat_printf(
parsed_data,
"Expires: %02X.%02X.20%02X\n",
app.exp_day,
app.exp_month,
app.exp_year);
FuriString* str = furi_string_alloc();
bool storage_readed = emv_get_country_name(app.country_code, str);