mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 22:40:25 +00:00
Read SFI until PAN find
* get rid of input result buffers
This commit is contained in:
parent
92a25af3c3
commit
51d8b18f3e
4 changed files with 16 additions and 20 deletions
|
@ -6,9 +6,8 @@
|
|||
|
||||
#define TAG "EMVPoller"
|
||||
|
||||
// SKOLKO?????????????????????????????????????????????????????????????????
|
||||
// MAX Le is 255 bytes + 2 for CRC
|
||||
#define EMV_BUF_SIZE (512U)
|
||||
#define EMV_RESULT_BUF_SIZE (512U)
|
||||
|
||||
typedef NfcCommand (*EmvPollerReadHandler)(EmvPoller* instance);
|
||||
|
||||
|
@ -24,8 +23,6 @@ static EmvPoller* emv_poller_alloc(Iso14443_4aPoller* iso14443_4a_poller) {
|
|||
instance->data = emv_alloc();
|
||||
instance->tx_buffer = bit_buffer_alloc(EMV_BUF_SIZE);
|
||||
instance->rx_buffer = bit_buffer_alloc(EMV_BUF_SIZE);
|
||||
instance->input_buffer = bit_buffer_alloc(EMV_BUF_SIZE);
|
||||
instance->result_buffer = bit_buffer_alloc(EMV_RESULT_BUF_SIZE);
|
||||
|
||||
instance->state = EmvPollerStateIdle;
|
||||
|
||||
|
@ -44,14 +41,10 @@ static void emv_poller_free(EmvPoller* instance) {
|
|||
emv_free(instance->data);
|
||||
bit_buffer_free(instance->tx_buffer);
|
||||
bit_buffer_free(instance->rx_buffer);
|
||||
bit_buffer_free(instance->input_buffer);
|
||||
bit_buffer_free(instance->result_buffer);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
static NfcCommand emv_poller_handler_idle(EmvPoller* instance) {
|
||||
bit_buffer_reset(instance->input_buffer);
|
||||
bit_buffer_reset(instance->result_buffer);
|
||||
bit_buffer_reset(instance->tx_buffer);
|
||||
bit_buffer_reset(instance->rx_buffer);
|
||||
|
||||
|
@ -106,21 +99,14 @@ static NfcCommand emv_poller_handler_get_processing_options(EmvPoller* instance)
|
|||
}
|
||||
|
||||
static NfcCommand emv_poller_handler_read_files(EmvPoller* instance) {
|
||||
instance->error = emv_poller_read_afl(instance);
|
||||
|
||||
if(instance->error == EmvErrorNone) {
|
||||
FURI_LOG_D(TAG, "Read files success");
|
||||
instance->state = EmvPollerStateReadExtra;
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Failed to read files");
|
||||
instance->state = EmvPollerStateReadFailed;
|
||||
}
|
||||
emv_poller_read_afl(instance);
|
||||
emv_poller_read_log_entry(instance);
|
||||
|
||||
instance->state = EmvPollerStateReadExtra;
|
||||
return NfcCommandContinue;
|
||||
}
|
||||
|
||||
static NfcCommand emv_poller_handler_read_extra_data(EmvPoller* instance) {
|
||||
emv_poller_read_log_entry(instance);
|
||||
emv_poller_get_last_online_atc(instance);
|
||||
emv_poller_get_pin_try_counter(instance);
|
||||
|
||||
|
|
|
@ -619,6 +619,12 @@ EmvError emv_poller_read_afl(EmvPoller* instance) {
|
|||
error = EmvErrorProtocol;
|
||||
FURI_LOG_T(TAG, "Failed to parse SFI 0x%X record %d", sfi, record);
|
||||
}
|
||||
|
||||
// Some READ RECORD returns 1 byte response 0x12/0x13 (IDK WTF),
|
||||
// then poller return Timeout to all subsequent requests.
|
||||
// TODO: remove below lines when it was fixed
|
||||
if(instance->data->emv_application.pan_len != 0)
|
||||
return EmvErrorNone; // Card number fetched
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@ struct EmvPoller {
|
|||
EmvData* data;
|
||||
BitBuffer* tx_buffer;
|
||||
BitBuffer* rx_buffer;
|
||||
BitBuffer* input_buffer;
|
||||
BitBuffer* result_buffer;
|
||||
EmvPollerEventData emv_event_data;
|
||||
EmvPollerEvent emv_event;
|
||||
NfcGenericEvent general_event;
|
||||
|
|
|
@ -103,6 +103,12 @@ Iso14443_4aError iso14443_4a_poller_send_block_pwt_ext(
|
|||
iso14443_4a_get_fwt_fc_max(instance->data));
|
||||
|
||||
if(iso14443_3a_error != Iso14443_3aErrorNone) {
|
||||
FURI_LOG_RAW_T("RAW RX(%d):", bit_buffer_get_size_bytes(instance->rx_buffer));
|
||||
for(size_t x = 0; x < bit_buffer_get_size_bytes(instance->rx_buffer); x++) {
|
||||
FURI_LOG_RAW_T("%02X ", bit_buffer_get_byte(instance->rx_buffer, x));
|
||||
}
|
||||
FURI_LOG_RAW_T("\r\n");
|
||||
|
||||
error = iso14443_4a_process_error(iso14443_3a_error);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue