add support for a new kind Magic Chinese UID changable Mifare Classic card

This commit is contained in:
douniwan5788 2016-04-21 15:50:26 +08:00
commit 13b71e58fd
2 changed files with 10 additions and 18 deletions

View file

@ -1059,10 +1059,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
break;
};
if(mifare_classic_halt(NULL, cuid)) {
if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
break;
};
mifare_classic_halt(NULL, cuid);
};
// reset chip
@ -1079,10 +1076,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
break;
};
if(mifare_classic_halt(NULL, cuid)) {
if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
break;
};
mifare_classic_halt(NULL, cuid);
};
// write block
@ -1115,10 +1109,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
};
if (workFlags & 0x04) {
if (mifare_classic_halt(NULL, cuid)) {
if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
break;
};
mifare_classic_halt(NULL, cuid);
}
isOK = 1;
@ -1192,10 +1183,7 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
memcpy(data, receivedAnswer, 18);
if (workFlags & 0x04) {
if (mifare_classic_halt(NULL, cuid)) {
if (MF_DBGLEVEL >= 1) Dbprintf("Halt error");
break;
};
mifare_classic_halt(NULL, cuid);
}
isOK = 1;
@ -1222,6 +1210,7 @@ void MifareCIdent(){
// card commands
uint8_t wupC1[] = { 0x40 };
uint8_t wupC2[] = { 0x43 };
uint8_t halt_ret = 0;
// variables
byte_t isOK = 1;
@ -1239,7 +1228,8 @@ void MifareCIdent(){
isOK = 0;
};
if (mifare_classic_halt(NULL, 0)) {
halt_ret = mifare_classic_halt(NULL, 0);
if (halt_ret && halt_ret != 4) {
isOK = 0;
};

View file

@ -511,7 +511,9 @@ int mifare_classic_halt(struct Crypto1State *pcs, uint32_t uid)
len = mifare_sendcmd_short(pcs, pcs == NULL ? false:true, 0x50, 0x00, receivedAnswer, receivedAnswerPar, NULL);
if (len != 0) {
if (MF_DBGLEVEL >= MF_DBG_ERROR)
Dbprintf("halt error. response len: %x", len);
Dbprintf("halt error. response len: %x data:%02X %02X %02X %02X", len, receivedAnswer[0],receivedAnswer[1],receivedAnswer[2],receivedAnswer[3]);
if (len == 1 && receivedAnswer[0]==0x04)
return 4;
return 1;
}