mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 15:38:35 -07:00
Merge branch 'dev' into astra/3746-mfp-detect
This commit is contained in:
@@ -506,7 +506,7 @@ bool mosgortrans_parse_transport_block(const MfClassicBlock* block, FuriString*
|
||||
|
||||
if(data_block.valid_from_date == 0 || data_block.valid_to_date == 0) {
|
||||
furi_string_cat(result, "\e#No ticket");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
//remaining_trips
|
||||
furi_string_cat_printf(result, "Trips: %d\n", data_block.total_trips);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "../iso14443_4a/iso14443_4a_render.h"
|
||||
|
||||
#define MF_DESFIRE_RENDER_MAX_RECORD_SIZE (256U)
|
||||
|
||||
void nfc_render_mf_desfire_info(
|
||||
const MfDesfireData* data,
|
||||
NfcProtocolFormatType format_type,
|
||||
@@ -212,8 +214,6 @@ void nfc_render_mf_desfire_file_settings_data(
|
||||
uint32_t record_count = 1;
|
||||
uint32_t record_size = 0;
|
||||
|
||||
const uint32_t total_size = simple_array_get_count(data->data);
|
||||
|
||||
switch(settings->type) {
|
||||
case MfDesfireFileTypeStandard:
|
||||
case MfDesfireFileTypeBackup:
|
||||
@@ -257,17 +257,14 @@ void nfc_render_mf_desfire_file_settings_data(
|
||||
return;
|
||||
}
|
||||
|
||||
for(uint32_t rec = 0; rec < record_count; rec++) {
|
||||
const uint32_t size_offset = rec * record_size;
|
||||
const uint32_t size_remaining = total_size > size_offset ? total_size - size_offset : 0;
|
||||
// Limit record size
|
||||
bool trim_data = record_size > MF_DESFIRE_RENDER_MAX_RECORD_SIZE;
|
||||
if(trim_data) {
|
||||
record_size = MF_DESFIRE_RENDER_MAX_RECORD_SIZE;
|
||||
}
|
||||
|
||||
if(size_remaining < record_size) {
|
||||
furi_string_cat_printf(
|
||||
str, "record %lu (partial %lu of %lu)\n", rec, size_remaining, record_size);
|
||||
record_size = size_remaining;
|
||||
} else {
|
||||
furi_string_cat_printf(str, "record %lu\n", rec);
|
||||
}
|
||||
for(uint32_t rec = 0; rec < record_count; rec++) {
|
||||
furi_string_cat_printf(str, "record %lu\n", rec);
|
||||
|
||||
for(uint32_t ch = 0; ch < record_size; ch += 4) {
|
||||
furi_string_cat_printf(str, "%03lx|", ch);
|
||||
@@ -296,6 +293,9 @@ void nfc_render_mf_desfire_file_settings_data(
|
||||
|
||||
furi_string_push_back(str, '\n');
|
||||
}
|
||||
if(trim_data) {
|
||||
furi_string_cat_str(str, "...");
|
||||
}
|
||||
|
||||
furi_string_push_back(str, '\n');
|
||||
}
|
||||
|
||||
@@ -83,6 +83,20 @@ static const MfClassicKeyPair troika_4k_keys[] = {
|
||||
{.a = 0xBB52F8CCE07F, .b = 0x6B6119752C70}, //40
|
||||
};
|
||||
|
||||
static void troika_render_section_header(
|
||||
FuriString* str,
|
||||
const char* name,
|
||||
uint8_t prefix_separator_cnt,
|
||||
uint8_t suffix_separator_cnt) {
|
||||
for(uint8_t i = 0; i < prefix_separator_cnt; i++) {
|
||||
furi_string_cat_printf(str, ":");
|
||||
}
|
||||
furi_string_cat_printf(str, "[ %s ]", name);
|
||||
for(uint8_t i = 0; i < suffix_separator_cnt; i++) {
|
||||
furi_string_cat_printf(str, ":");
|
||||
}
|
||||
}
|
||||
|
||||
static bool troika_get_card_config(TroikaCardConfig* config, MfClassicType type) {
|
||||
bool success = true;
|
||||
|
||||
@@ -204,18 +218,19 @@ static bool troika_parse(const NfcDevice* device, FuriString* parsed_data) {
|
||||
bool result3 = mosgortrans_parse_transport_block(&data->block[16], tat_result);
|
||||
|
||||
furi_string_cat_printf(parsed_data, "\e#Troyka card\n");
|
||||
if(result1) {
|
||||
furi_string_cat_printf(
|
||||
parsed_data, "\e#Metro\n%s\n", furi_string_get_cstr(metro_result));
|
||||
if(result1 && !furi_string_empty(metro_result)) {
|
||||
troika_render_section_header(parsed_data, "Metro", 22, 21);
|
||||
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(metro_result));
|
||||
}
|
||||
|
||||
if(result2) {
|
||||
furi_string_cat_printf(
|
||||
parsed_data, "\n\e#Ediniy\n%s\n", furi_string_get_cstr(ground_result));
|
||||
if(result2 && !furi_string_empty(ground_result)) {
|
||||
troika_render_section_header(parsed_data, "Ediny", 22, 22);
|
||||
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(ground_result));
|
||||
}
|
||||
|
||||
if(result3) {
|
||||
furi_string_cat_printf(parsed_data, "\n\e#TAT\n%s", furi_string_get_cstr(tat_result));
|
||||
if(result3 && !furi_string_empty(tat_result)) {
|
||||
troika_render_section_header(parsed_data, "TAT", 24, 23);
|
||||
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(tat_result));
|
||||
}
|
||||
|
||||
furi_string_free(tat_result);
|
||||
|
||||
Reference in New Issue
Block a user