Skip to content

Commit

Permalink
Use the card-supplied FWT for ISO14443-3,4B based cards
Browse files Browse the repository at this point in the history
  • Loading branch information
gsurkov committed Oct 18, 2023
1 parent 0fc4d3d commit 5ad79c6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lib/nfc/protocols/iso14443_3b/iso14443_3b.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
1 change: 0 additions & 1 deletion lib/nfc/protocols/iso14443_3b/iso14443_3b_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5ad79c6

Please sign in to comment.