diff --git a/lib/nfc/protocols/type_4_tag/type_4_tag.h b/lib/nfc/protocols/type_4_tag/type_4_tag.h index e68895a2f..653785cba 100644 --- a/lib/nfc/protocols/type_4_tag/type_4_tag.h +++ b/lib/nfc/protocols/type_4_tag/type_4_tag.h @@ -14,6 +14,7 @@ typedef enum { Type4TagErrorWrongFormat, Type4TagErrorNotSupported, Type4TagErrorApduFailed, + Type4TagErrorCardUnformatted, Type4TagErrorCardLocked, Type4TagErrorCustomCommand, } Type4TagError; diff --git a/lib/nfc/protocols/type_4_tag/type_4_tag_poller.c b/lib/nfc/protocols/type_4_tag/type_4_tag_poller.c index 8eef2b70d..76a42459b 100644 --- a/lib/nfc/protocols/type_4_tag/type_4_tag_poller.c +++ b/lib/nfc/protocols/type_4_tag/type_4_tag_poller.c @@ -74,7 +74,7 @@ static NfcCommand type_4_tag_poller_handler_select_app(Type4TagPoller* instance) } else { FURI_LOG_E(TAG, "Failed to select application"); if(instance->mode == Type4TagPollerModeWrite && - instance->error == Type4TagErrorApduFailed) { + instance->error == Type4TagErrorCardUnformatted) { instance->state = Type4TagPollerStateCreateApplication; } else { instance->state = Type4TagPollerStateFailed; @@ -94,7 +94,7 @@ static NfcCommand type_4_tag_poller_handler_read_cc(Type4TagPoller* instance) { } else { FURI_LOG_E(TAG, "Failed to read CC"); if(instance->mode == Type4TagPollerModeWrite && - instance->error == Type4TagErrorApduFailed) { + instance->error == Type4TagErrorCardUnformatted) { instance->state = Type4TagPollerStateCreateCapabilityContainer; } else { instance->state = Type4TagPollerStateFailed; @@ -124,9 +124,6 @@ static NfcCommand type_4_tag_poller_handler_create_app(Type4TagPoller* instance) instance->state = Type4TagPollerStateSelectApplication; } else { FURI_LOG_E(TAG, "Failed to create application"); - if(instance->error == Type4TagErrorApduFailed) { - instance->error = Type4TagErrorCardLocked; - } instance->state = Type4TagPollerStateFailed; } @@ -140,9 +137,6 @@ static NfcCommand type_4_tag_poller_handler_create_cc(Type4TagPoller* instance) instance->state = Type4TagPollerStateReadCapabilityContainer; } else { FURI_LOG_E(TAG, "Failed to create CC"); - if(instance->error == Type4TagErrorApduFailed) { - instance->error = Type4TagErrorCardLocked; - } instance->state = Type4TagPollerStateFailed; } @@ -156,9 +150,6 @@ static NfcCommand type_4_tag_poller_handler_create_ndef(Type4TagPoller* instance instance->state = Type4TagPollerStateWriteNdefMessage; } else { FURI_LOG_E(TAG, "Failed to create NDEF"); - if(instance->error == Type4TagErrorApduFailed) { - instance->error = Type4TagErrorCardLocked; - } instance->state = Type4TagPollerStateFailed; } @@ -173,7 +164,7 @@ static NfcCommand type_4_tag_poller_handler_write_ndef(Type4TagPoller* instance) } else { FURI_LOG_E(TAG, "Failed to write NDEF"); if(instance->mode == Type4TagPollerModeWrite && - instance->error == Type4TagErrorApduFailed) { + instance->error == Type4TagErrorCardUnformatted) { instance->state = Type4TagPollerStateCreateNdefMessage; } else { instance->state = Type4TagPollerStateFailed; diff --git a/lib/nfc/protocols/type_4_tag/type_4_tag_poller_i.c b/lib/nfc/protocols/type_4_tag/type_4_tag_poller_i.c index 8bac81ce2..ea609e622 100644 --- a/lib/nfc/protocols/type_4_tag/type_4_tag_poller_i.c +++ b/lib/nfc/protocols/type_4_tag/type_4_tag_poller_i.c @@ -56,7 +56,10 @@ static Type4TagError type_5_tag_poller_iso_select_name( bit_buffer_append_byte(instance->tx_buffer, name_len); bit_buffer_append_bytes(instance->tx_buffer, name, name_len); - return type_4_tag_apdu_trx(instance, instance->tx_buffer, instance->rx_buffer); + Type4TagError error = type_4_tag_apdu_trx(instance, instance->tx_buffer, instance->rx_buffer); + if(error == Type4TagErrorApduFailed) error = Type4TagErrorCardUnformatted; + + return error; } static Type4TagError @@ -76,7 +79,10 @@ static Type4TagError sizeof(type_4_tag_iso_select_file_apdu)); bit_buffer_append_bytes(instance->tx_buffer, file_id_be, sizeof(file_id_be)); - return type_4_tag_apdu_trx(instance, instance->tx_buffer, instance->rx_buffer); + Type4TagError error = type_4_tag_apdu_trx(instance, instance->tx_buffer, instance->rx_buffer); + if(error == Type4TagErrorApduFailed) error = Type4TagErrorCardUnformatted; + + return error; } static Type4TagError type_5_tag_poller_iso_read(