Merge remote-tracking branch 'ofw/dev' into mntm-dev --nobuild

This commit is contained in:
Willy-JL
2025-04-01 01:40:05 +00:00
139 changed files with 1534 additions and 854 deletions

View File

@@ -37,11 +37,13 @@ void nfc_render_iso15693_3_brief(const Iso15693_3Data* data, FuriString* str) {
}
void nfc_render_iso15693_3_system_info(const Iso15693_3Data* data, FuriString* str) {
if(data->system_info.flags & ISO15693_3_SYSINFO_FLAG_MEMORY) {
const uint16_t block_count = iso15693_3_get_block_count(data);
const uint8_t block_size = iso15693_3_get_block_size(data);
if((data->system_info.flags & ISO15693_3_SYSINFO_FLAG_MEMORY) &&
(block_count > 0 && block_size > 0)) {
furi_string_cat(str, "\e#Memory data\n\e*--------------------\n");
const uint16_t block_count = iso15693_3_get_block_count(data);
const uint8_t block_size = iso15693_3_get_block_size(data);
const uint16_t display_block_count =
MIN(NFC_RENDER_ISO15693_3_MAX_BYTES / block_size, block_count);

View File

@@ -22,6 +22,7 @@
#include <nfc/protocols/slix/slix.h>
#include <bit_lib.h>
#include <toolbox/pretty_format.h>
#define TAG "NDEF"
@@ -248,7 +249,9 @@ static inline bool is_printable(char c) {
static bool is_text(const uint8_t* buf, size_t len) {
for(size_t i = 0; i < len; i++) {
if(!is_printable(buf[i])) return false;
if(!is_printable(buf[i]) && !(buf[i] == '\0' && i == len - 1)) {
return false;
}
}
return true;
}
@@ -264,7 +267,7 @@ static bool ndef_dump(Ndef* ndef, const char* prefix, size_t pos, size_t len, bo
for(size_t i = 0; i < len; i++) {
char c;
if(!ndef_get(ndef, pos + i, 1, &c)) return false;
if(!is_printable(c)) {
if(!is_printable(c) && !(c == '\0' && i == len - 1)) {
furi_string_left(ndef->output, string_prev);
force_hex = true;
break;
@@ -272,14 +275,18 @@ static bool ndef_dump(Ndef* ndef, const char* prefix, size_t pos, size_t len, bo
furi_string_push_back(ndef->output, c);
}
}
if(force_hex) {
for(size_t i = 0; i < len; i++) {
uint8_t b;
if(!ndef_get(ndef, pos + i, 1, &b)) return false;
furi_string_cat_printf(ndef->output, "%02X ", b);
if(!force_hex) {
furi_string_cat(ndef->output, "\n");
} else {
uint8_t buf[4];
for(size_t i = 0; i < len; i += sizeof(buf)) {
uint8_t buf_len = MIN(sizeof(buf), len - i);
if(!ndef_get(ndef, pos + i, buf_len, &buf)) return false;
pretty_format_bytes_hex_canonical(
ndef->output, 4, PRETTY_FORMAT_FONT_MONOSPACE, buf, buf_len);
furi_string_cat(ndef->output, "\n");
}
}
furi_string_cat(ndef->output, "\n");
return true;
}
@@ -289,9 +296,7 @@ static void
if(!force_hex && is_text(buf, len)) {
furi_string_cat_printf(ndef->output, "%.*s", len, (const char*)buf);
} else {
for(size_t i = 0; i < len; i++) {
furi_string_cat_printf(ndef->output, "%02X ", ((const uint8_t*)buf)[i]);
}
pretty_format_bytes_hex_canonical(ndef->output, 4, PRETTY_FORMAT_FONT_MONOSPACE, buf, len);
}
furi_string_cat(ndef->output, "\n");
}