Fix retry loop (on Android HCE)

This commit is contained in:
Nikita Vostokov 2024-01-28 20:18:17 +00:00
parent 4b786fb77e
commit 786f3568c0
4 changed files with 20 additions and 9 deletions

View file

@ -79,6 +79,7 @@ Iso14443_4aError iso14443_4_layer_decode_block_pwt_ext(
furi_assert(instance);
Iso14443_4aError ret = Iso14443_4aErrorProtocol;
bit_buffer_reset(output_data);
do {
const uint8_t pcb_field = bit_buffer_get_byte(block_data, 0);
@ -89,8 +90,8 @@ Iso14443_4aError iso14443_4_layer_decode_block_pwt_ext(
bit_buffer_copy_right(output_data, block_data, 1);
ret = Iso14443_4aErrorNone;
} else {
// TODO: Need send request again
ret = Iso14443_4aErrorProtocol;
// send original request again
ret = Iso14443_4aErrorSendExtra;
}
break;
case ISO14443_4_BLOCK_PCB_R:
@ -103,12 +104,11 @@ Iso14443_4aError iso14443_4_layer_decode_block_pwt_ext(
const uint8_t wtxm = inf_field & 0b111111;
//uint32_t fwt_temp = MIN((fwt * wtxm), fwt_max);
bit_buffer_reset(output_data);
bit_buffer_append_byte(
output_data,
ISO14443_4_BLOCK_PCB_S | ISO14443_4_BLOCK_PCB_S_WTX | ISO14443_4_BLOCK_PCB);
bit_buffer_append_byte(output_data, wtxm);
ret = Iso14443_4aErrorSendCtrl;
ret = Iso14443_4aErrorSendExtra;
}
break;
}

View file

@ -208,6 +208,14 @@ static bool
success = true;
break;
}
case EMV_TAG_CARDHOLDER_NAME: {
char name[27];
memcpy(name, &buff[i], tlen);
name[tlen] = '\0';
success = true;
FURI_LOG_T(TAG, "found EMV_TAG_CARDHOLDER_NAME %x: %s", tag, name);
break;
}
case EMV_TAG_PAN:
memcpy(app->pan, &buff[i], tlen);
app->pan_len = tlen;
@ -654,11 +662,11 @@ EmvError emv_poller_read_log_entry(EmvPoller* instance) {
uint8_t records = instance->data->emv_application.log_records;
if(records == 0) {
return false;
return error;
}
error = emv_poller_get_log_format(instance);
if(error != EmvErrorNone) return false;
if(error != EmvErrorNone) return error;
FURI_LOG_D(TAG, "Read Transaction logs");

View file

@ -13,7 +13,7 @@ typedef enum {
Iso14443_4aErrorNotPresent,
Iso14443_4aErrorProtocol,
Iso14443_4aErrorTimeout,
Iso14443_4aErrorSendCtrl,
Iso14443_4aErrorSendExtra,
} Iso14443_4aError;
typedef enum {

View file

@ -88,6 +88,7 @@ Iso14443_4aError iso14443_4a_poller_send_block_pwt_ext(
BitBuffer* rx_buffer) {
furi_assert(instance);
uint8_t retry = 5;
bit_buffer_reset(instance->tx_buffer);
iso14443_4_layer_encode_block(instance->iso14443_4_layer, tx_buffer, instance->tx_buffer);
@ -108,9 +109,11 @@ Iso14443_4aError iso14443_4a_poller_send_block_pwt_ext(
} else {
error = iso14443_4_layer_decode_block_pwt_ext(
instance->iso14443_4_layer, rx_buffer, instance->rx_buffer);
if(error == Iso14443_4aErrorSendCtrl) {
if(error == Iso14443_4aErrorSendExtra) {
if(--retry == 0) break;
// Send response for Control message
bit_buffer_copy(instance->tx_buffer, rx_buffer);
if(bit_buffer_get_size_bytes(rx_buffer))
bit_buffer_copy(instance->tx_buffer, rx_buffer);
continue;
}
break;