Process error codes

This commit is contained in:
Nikita Vostokov
2024-01-23 21:34:39 +00:00
parent 3f6092d95c
commit 3fce83eb79
2 changed files with 20 additions and 6 deletions
+2 -1
View File
@@ -24,9 +24,10 @@ extern "C" {
#define EMV_TAG_CURRENCY_CODE 0x9F42
#define EMV_TAG_CARDHOLDER_NAME 0x5F20
#define EMV_TAG_TRACK_2_DATA 0x9F6B
#define EMV_TAG_GPO_FMT1 0x80
#define EMV_TAG_RESP_BUF_SIZE 0x6C
#define EMV_TAG_GPO_FMT1 0x80
#define EMV_TAG_RESP_BYTES_AVAILABLE 0x61
typedef struct {
uint16_t tag;
+18 -5
View File
@@ -117,6 +117,24 @@ static bool emv_decode_response(const uint8_t* buff, uint16_t len, EmvApplicatio
while(i < len) {
first_byte = buff[i];
if((len == 2) && ((first_byte >> 4) == 6)) {
switch(buff[i]) {
case EMV_TAG_RESP_BUF_SIZE:
FURI_LOG_T(TAG, " Wrong length. Read %02X bytes", buff[i + 1]);
// Need to request SFI again with this length value
return success;
case EMV_TAG_RESP_BYTES_AVAILABLE:
FURI_LOG_T(TAG, " Bytes available: %02X", buff[i + 1]);
// Need to request one more time
return success;
default:
FURI_LOG_T(TAG, " Error/warning code: %02X %02X", buff[i], buff[i + 1]);
return success;
}
}
if((first_byte & 31) == 31) { // 2-byte tag
tag = buff[i] << 8 | buff[i + 1];
i++;
@@ -154,11 +172,6 @@ static bool emv_decode_response(const uint8_t* buff, uint16_t len, EmvApplicatio
success = true;
FURI_LOG_T(TAG, "found EMV_TAG_GPO_FMT1 %X: ", tag);
break;
case EMV_TAG_RESP_BUF_SIZE:
//success = true;
FURI_LOG_T(TAG, "found EMV_TAG_RESP_BUF_SIZE %X: %d", tag, buff[i]);
// Need to request SFI again with this length value
break;
case EMV_TAG_AID:
app->aid_len = tlen;
memcpy(app->aid, &buff[i], tlen);