From 5ad79c64f91c3dbf065c19b741c567c75584f6ac Mon Sep 17 00:00:00 2001 From: Georgii Surkov Date: Wed, 18 Oct 2023 17:04:37 +0300 Subject: [PATCH] Use the card-supplied FWT for ISO14443-3,4B based cards --- lib/nfc/protocols/iso14443_3b/iso14443_3b.c | 4 +++- lib/nfc/protocols/iso14443_3b/iso14443_3b_i.h | 1 - lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c | 8 ++++---- lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.h | 3 +-- lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c | 5 ++--- lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.h | 3 +-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/nfc/protocols/iso14443_3b/iso14443_3b.c b/lib/nfc/protocols/iso14443_3b/iso14443_3b.c index 2cda90206ab..fd81e390da7 100644 --- a/lib/nfc/protocols/iso14443_3b/iso14443_3b.c +++ b/lib/nfc/protocols/iso14443_3b/iso14443_3b.c @@ -12,6 +12,8 @@ #define ISO14443_3B_APP_DATA_KEY "Application data" #define ISO14443_3B_PROTOCOL_INFO_KEY "Protocol info" +#define ISO14443_3B_FDT_POLL_DEFAULT_FC (ISO14443_3B_FDT_POLL_FC) + const NfcDeviceBase nfc_device_iso14443_3b = { .protocol_name = ISO14443_3B_PROTOCOL_NAME, .alloc = (NfcDeviceAlloc)iso14443_3b_alloc, @@ -217,5 +219,5 @@ uint32_t iso14443_3b_get_fwt_fc_max(const Iso14443_3bData* data) { furi_assert(data); const uint8_t fwi = data->protocol_info.fwi; - return fwi < 15 ? 4096UL << fwi : 0; + return fwi < 0x0F ? 4096UL << fwi : ISO14443_3B_FDT_POLL_DEFAULT_FC; } diff --git a/lib/nfc/protocols/iso14443_3b/iso14443_3b_i.h b/lib/nfc/protocols/iso14443_3b/iso14443_3b_i.h index 63a382644a7..f4ff36bd7e3 100644 --- a/lib/nfc/protocols/iso14443_3b/iso14443_3b_i.h +++ b/lib/nfc/protocols/iso14443_3b/iso14443_3b_i.h @@ -7,7 +7,6 @@ #define ISO14443_3B_GUARD_TIME_US (5000U) #define ISO14443_3B_FDT_POLL_FC (9000U) -#define ISO14443_3B_FDT_ATTRIB_FC (42000U) #define ISO14443_3B_POLL_POLL_MIN_US (1280U) #define ISO14443_3B_BIT_RATE_BOTH_106KBIT (0U << 0) diff --git a/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c b/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c index 4e311d203c0..95668ccf224 100644 --- a/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c +++ b/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c @@ -126,7 +126,7 @@ Iso14443_3bError bit_buffer_append_byte(instance->tx_buffer, 0x00); ret = iso14443_3b_poller_frame_exchange( - instance, instance->tx_buffer, instance->rx_buffer, ISO14443_3B_FDT_ATTRIB_FC); + instance, instance->tx_buffer, instance->rx_buffer, iso14443_3b_get_fwt_fc_max(data)); if(ret != Iso14443_3bErrorNone) { instance->state = Iso14443_3bPollerStateActivationFailed; break; @@ -179,15 +179,15 @@ Iso14443_3bError iso14443_3b_poller_halt(Iso14443_3bPoller* instance) { Iso14443_3bError iso14443_3b_poller_send_frame( Iso14443_3bPoller* instance, const BitBuffer* tx_buffer, - BitBuffer* rx_buffer, - uint32_t fwt) { + BitBuffer* rx_buffer) { Iso14443_3bError ret; do { ret = iso14443_3b_poller_prepare_trx(instance); if(ret != Iso14443_3bErrorNone) break; - ret = iso14443_3b_poller_frame_exchange(instance, tx_buffer, rx_buffer, fwt); + ret = iso14443_3b_poller_frame_exchange( + instance, tx_buffer, rx_buffer, iso14443_3b_get_fwt_fc_max(instance->data)); } while(false); return ret; diff --git a/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.h b/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.h index 03a97b64d60..5821d6373f5 100644 --- a/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.h +++ b/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.h @@ -42,8 +42,7 @@ Iso14443_3bError iso14443_3b_poller_halt(Iso14443_3bPoller* instance); Iso14443_3bError iso14443_3b_poller_send_frame( Iso14443_3bPoller* instance, const BitBuffer* tx_buffer, - BitBuffer* rx_buffer, - uint32_t fwt); + BitBuffer* rx_buffer); #ifdef __cplusplus } diff --git a/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c b/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c index 12fe670f2d0..82de1d538a3 100644 --- a/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c +++ b/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c @@ -18,8 +18,7 @@ Iso14443_4bError iso14443_4b_poller_halt(Iso14443_4bPoller* instance) { Iso14443_4bError iso14443_4b_poller_send_block( Iso14443_4bPoller* instance, const BitBuffer* tx_buffer, - BitBuffer* rx_buffer, - uint32_t fwt) { + BitBuffer* rx_buffer) { furi_assert(instance); bit_buffer_reset(instance->tx_buffer); @@ -29,7 +28,7 @@ Iso14443_4bError iso14443_4b_poller_send_block( do { Iso14443_3bError iso14443_3b_error = iso14443_3b_poller_send_frame( - instance->iso14443_3b_poller, instance->tx_buffer, instance->rx_buffer, fwt); + instance->iso14443_3b_poller, instance->tx_buffer, instance->rx_buffer); if(iso14443_3b_error != Iso14443_3bErrorNone) { error = iso14443_4b_process_error(iso14443_3b_error); diff --git a/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.h b/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.h index 5eeb4f380df..4df00adcf10 100644 --- a/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.h +++ b/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.h @@ -49,8 +49,7 @@ Iso14443_4bError iso14443_4b_poller_halt(Iso14443_4bPoller* instance); Iso14443_4bError iso14443_4b_poller_send_block( Iso14443_4bPoller* instance, const BitBuffer* tx_buffer, - BitBuffer* rx_buffer, - uint32_t fwt); + BitBuffer* rx_buffer); #ifdef __cplusplus }