From c6f18a202e62ff057b3cd9628d2c83ed3623b238 Mon Sep 17 00:00:00 2001 From: Fl0-0 Date: Fri, 7 Jul 2017 09:50:36 +0200 Subject: [PATCH] gen1b: don't issue wipe command and don't expect response from WUPC1 magic command after a SELECT_UID: old UID display works in hf mf csetuid --- armsrc/mifarecmd.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index e2f19622..90d174a1 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1212,11 +1212,9 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai // get UID from chip if (workFlags & 0x01) { - // do no get UID for gen1b magic tag - if (!(workFlags & 0x40)) { - if(!iso14443a_select_card(uid, NULL, &cuid, true, 0)) { - if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card"); - break; + if(!iso14443a_select_card(uid, NULL, &cuid, true, 0)) { + if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card"); + break; }; if(mifare_classic_halt(NULL, cuid)) { @@ -1224,11 +1222,11 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai // Continue, some magic tags misbehavies and send an answer to it. // break; }; - }; }; // reset chip - if (needWipe){ + // Wipe command don't work with gen1b + if (needWipe && !(workFlags & 0x40)){ ReaderTransmitBitsPar(wupC1,7,0, NULL); if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) { if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error"); @@ -1251,13 +1249,15 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai // write block if (workFlags & 0x02) { ReaderTransmitBitsPar(wupC1,7,0, NULL); - if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) { - if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error"); - break; - }; - // do no issue for gen1b magic tag + // gen1b magic tag : do no issue wupC2 and don't expect 0x0a response after SELECT_UID (after getting UID from chip in 'hf mf csetuid' command) if (!(workFlags & 0x40)) { + + if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) { + if (MF_DBGLEVEL >= 1) Dbprintf("wupC1 error"); + break; + }; + ReaderTransmit(wupC2, sizeof(wupC2), NULL); if(!ReaderReceive(receivedAnswer, receivedAnswerPar) || (receivedAnswer[0] != 0x0a)) { if (MF_DBGLEVEL >= 1) Dbprintf("wupC2 error");