Merge branch 'ofw_dev' into nfcrefactoring

This commit is contained in:
MX
2023-10-29 02:23:02 +03:00
16 changed files with 55 additions and 26 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ env.Append(
libenv = env.Clone(FW_LIB_NAME="nfc")
libenv.ApplyLibFlags()
sources = libenv.GlobRecursive("*.c*", exclude="deprecated/*c")
sources = libenv.GlobRecursive("*.c*")
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
@@ -29,6 +29,7 @@ extern "C" {
#define MF_DESFIRE_UID_SIZE (7)
#define MF_DESFIRE_BATCH_SIZE (5)
#define MF_DESFIRE_APP_ID_SIZE (3)
#define MF_DESFIRE_VALUE_SIZE (4)
typedef struct {
uint8_t hw_vendor;
@@ -6,7 +6,8 @@
#define TAG "MfDesfirePoller"
#define MF_DESFIRE_BUF_SIZE_MAX (64U)
#define MF_DESFIRE_BUF_SIZE (64U)
#define MF_DESFIRE_RESULT_BUF_SIZE (512U)
typedef NfcCommand (*MfDesfirePollerReadHandler)(MfDesfirePoller* instance);
@@ -20,10 +21,10 @@ static MfDesfirePoller* mf_desfire_poller_alloc(Iso14443_4aPoller* iso14443_4a_p
MfDesfirePoller* instance = malloc(sizeof(MfDesfirePoller));
instance->iso14443_4a_poller = iso14443_4a_poller;
instance->data = mf_desfire_alloc();
instance->tx_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE_MAX);
instance->rx_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE_MAX);
instance->input_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE_MAX);
instance->result_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE_MAX);
instance->tx_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE);
instance->rx_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE);
instance->input_buffer = bit_buffer_alloc(MF_DESFIRE_BUF_SIZE);
instance->result_buffer = bit_buffer_alloc(MF_DESFIRE_RESULT_BUF_SIZE);
instance->mf_desfire_event.data = &instance->mf_desfire_event_data;
@@ -59,7 +59,15 @@ MfDesfireError mf_desfire_send_chunks(
break;
}
bit_buffer_append_right(rx_buffer, instance->rx_buffer, sizeof(uint8_t));
const size_t rx_size = bit_buffer_get_size_bytes(instance->rx_buffer);
const size_t rx_capacity_remaining =
bit_buffer_get_capacity_bytes(rx_buffer) - bit_buffer_get_size_bytes(rx_buffer);
if(rx_size <= rx_capacity_remaining) {
bit_buffer_append_right(rx_buffer, instance->rx_buffer, sizeof(uint8_t));
} else {
FURI_LOG_W(TAG, "RX buffer overflow: ignoring %zu bytes", rx_size);
}
}
} while(false);
@@ -353,7 +361,7 @@ MfDesfireError mf_desfire_poller_async_read_file_records(
furi_assert(instance);
bit_buffer_reset(instance->input_buffer);
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_DATA);
bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_RECORDS);
bit_buffer_append_byte(instance->input_buffer, id);
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&offset, 3);
bit_buffer_append_bytes(instance->input_buffer, (const uint8_t*)&size, 3);
@@ -297,7 +297,7 @@ bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t vers
uint32_t pages_total = 0;
if(!flipper_format_read_uint32(ff, MF_ULTRALIGHT_PAGES_TOTAL_KEY, &pages_total, 1)) break;
uint32_t pages_read = 0;
if(data_format_version < mf_ultralight_data_format_version) {
if(data_format_version < mf_ultralight_data_format_version) { //-V547
pages_read = pages_total;
} else {
if(!flipper_format_read_uint32(ff, MF_ULTRALIGHT_PAGES_READ_KEY, &pages_read, 1))
@@ -518,6 +518,8 @@ static uint16_t mf_ultralight_get_upper_page_bound(MfUltralightType type) {
upper_page_bound = 511;
else if(type == MfUltralightTypeNTAGI2C2K)
upper_page_bound = 479;
else if(type == MfUltralightTypeNTAGI2C1K)
upper_page_bound = 225;
else {
upper_page_bound = mf_ultralight_get_config_page_num(type) - 2;
}
@@ -68,7 +68,7 @@ Iso15693Parser* iso15693_parser_alloc(const GpioPin* pin, size_t max_frame_size)
signal_reader_set_sample_rate(
instance->signal_reader, SignalReaderTimeUnit64Mhz, ISO15693_PARSER_BITRATE_F64MHZ);
signal_reader_set_pull(instance->signal_reader, GpioPullDown);
signal_reader_set_polarity(instance->signal_reader, SignalReaderPolarityInverted);
signal_reader_set_polarity(instance->signal_reader, SignalReaderPolarityNormal);
signal_reader_set_trigger(instance->signal_reader, SignalReaderTriggerRisingFallingEdge);
return instance;