From 379066f069e1f90a1f4e298060c127101bac77a2 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 30 Jun 2010 14:54:34 +0000 Subject: [PATCH] nfc-mfultralight: on write failure, continue if authenticate works. --- examples/nfc-mfultralight.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/nfc-mfultralight.c b/examples/nfc-mfultralight.c index c6130f4..f9c2f43 100644 --- a/examples/nfc-mfultralight.c +++ b/examples/nfc-mfultralight.c @@ -100,23 +100,23 @@ write_card (void) for (page = 0x4; page <= 0xF; page++) { // Show if the readout went well if (bFailure) { -// printf("x"); // When a failure occured we need to redo the anti-collision if (!nfc_initiator_select_tag (pnd, NM_ISO14443A_106, NULL, 0, &nti)) { ERR ("tag was removed"); return false; } bFailure = false; - } else { - // For the Mifare Ultralight, this write command can be used - // in compatibility mode, which only actually writes the first - // page (4 bytes). The Ultralight-specific Write command only - // writes one page at a time. - uiBlock = page / 4; - memcpy (mp.mpd.abtData, mtDump.amb[uiBlock].mbd.abtData + ((page % 4) * 4), 16); - if (!nfc_initiator_mifare_cmd (pnd, MC_WRITE, page, &mp)) - bFailure = true; } + + // For the Mifare Ultralight, this write command can be used + // in compatibility mode, which only actually writes the first + // page (4 bytes). The Ultralight-specific Write command only + // writes one page at a time. + uiBlock = page / 4; + memcpy (mp.mpd.abtData, mtDump.amb[uiBlock].mbd.abtData + ((page % 4) * 4), 16); + if (!nfc_initiator_mifare_cmd (pnd, MC_WRITE, page, &mp)) + bFailure = true; + print_success_or_failure (bFailure, &uiWritenPages); } printf ("|\n");