From bf70f4b71a6d75204613fb0ce19c84598e9f0457 Mon Sep 17 00:00:00 2001 From: AloneLiberty <111039319+AloneLiberty@users.noreply.github.com> Date: Tue, 21 Mar 2023 15:03:14 +0300 Subject: [PATCH] NFC: Fixed writing gen1a magic tags with invalid BCC (#2511) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- applications/external/nfc_magic/lib/magic/magic.c | 5 ++--- applications/external/nfc_magic/nfc_magic_worker.c | 8 +++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/applications/external/nfc_magic/lib/magic/magic.c b/applications/external/nfc_magic/lib/magic/magic.c index a922bc7a..9a71daaa 100644 --- a/applications/external/nfc_magic/lib/magic/magic.c +++ b/applications/external/nfc_magic/lib/magic/magic.c @@ -6,8 +6,7 @@ #define MAGIC_CMD_WUPA (0x40) #define MAGIC_CMD_WIPE (0x41) -#define MAGIC_CMD_READ (0x43) -#define MAGIC_CMD_WRITE (0x43) +#define MAGIC_CMD_ACCESS (0x43) #define MAGIC_MIFARE_READ_CMD (0x30) #define MAGIC_MIFARE_WRITE_CMD (0xA0) @@ -70,7 +69,7 @@ bool magic_data_access_cmd() { FuriHalNfcReturn ret = 0; do { - tx_data[0] = MAGIC_CMD_WRITE; + tx_data[0] = MAGIC_CMD_ACCESS; ret = furi_hal_nfc_ll_txrx_bits( tx_data, 8, diff --git a/applications/external/nfc_magic/nfc_magic_worker.c b/applications/external/nfc_magic/nfc_magic_worker.c index 523c794f..92eb793a 100644 --- a/applications/external/nfc_magic/nfc_magic_worker.c +++ b/applications/external/nfc_magic/nfc_magic_worker.c @@ -85,15 +85,17 @@ void nfc_magic_worker_write(NfcMagicWorker* nfc_magic_worker) { card_found_notified = true; } furi_hal_nfc_sleep(); - if(!magic_wupa()) { - FURI_LOG_E(TAG, "Not Magic card"); + FURI_LOG_E(TAG, "No card response to WUPA (not a magic card)"); nfc_magic_worker->callback( NfcMagicWorkerEventWrongCard, nfc_magic_worker->context); break; } + furi_hal_nfc_sleep(); + } + if(magic_wupa()) { if(!magic_data_access_cmd()) { - FURI_LOG_E(TAG, "Not Magic card"); + FURI_LOG_E(TAG, "No card response to data access command (not a magic card)"); nfc_magic_worker->callback( NfcMagicWorkerEventWrongCard, nfc_magic_worker->context); break;