I am working on NFC (Mifare classic tag). I want to know how to write data to the mi fare classic tag. I have empty Tag. Please tell the APDU commands which I need to use for mifare classic tag.
I am sending APDU commands as follows :
\x00','\xA4', '\x04', '\x00','\x07','\xd2','\x76','\x00','\x00','\x85','\x01','\x00
If I am using this apdu command s its not giving any success response (as every APDU commands will have 9000) its going into the else part. Please tell me the correct apdu commands. I am writing code into the C language. The reader I have is MFC 523. What are steps need to follow?
// code i am using its for the Mobile POS
int ret;
sendtoUSB("going to the auth",17); // for display purpose
// for authentication we will use the basic authentication between the reader and writer
Sys_ClearScreen();
char cRecvBuf[128];
int i,j;
char cSendBuf[10]= {0xFF,0x86,0x00,0x00,0x05,0x01,0x00,0x05,0x60,0x01}; // authenticaton key
char msg[128];
u32 rlen; // response length
Sys_PcdOpen();
while(1)
{
sendtoUSB("in while",8);
if(Sys_Kbhit()==KEY_CANCEL)
break;
ret = Sys_PiccPresent();
// activation of the NFC
ret = Sys_PiccActivate();
uchar key[16]= {0xFF,0x82,0x20,0x01,0x06,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF} ; //Load keys command
char cSendBuf[10]= {0xFF,0x86,0x00,0x00,0x05,0x01,0x00,0x05,0x60,0x01}; // authentication command
ret = Sys_PiccCommand(key,11,&rlen,cRecvBuf); // sending the command
sendtoUSB("In send cmd",11);
sendtoUSB(key,strlen(key)); // here i am getting the key as i am sending
sendtoUSB(cRecvBuf,rlen); // in recvbuf i am agetting as 6E00
if(ret==0) // checking the returing value
{
// its coming into the if also
sendtoUSB("sucess",6);
if(rlen>=0)
{
if((cRecvBuf[rlen-2]==0x90) && (cRecvBuf[rlen-1]==0x00)) // checking the 90 00 response
{
// not coming here
sendtoUSB("in if",5);
strcpy(msg, "ankita");
for(i=0;i<rlen-2;i++)
sprintf(msg+strlen(msg), "%02X", cRecvBuf[i]);
Sys_DisplayLine( 2, msg, 0, ALIGN_LEFT) ;
}
else
{
// its coming here
sendtoUSB("In else",7);
sprintf(msg, "In else 02X%02X", cRecvBuf[rlen-2],cRecvBuf[rlen-1]);
Sys_DisplayLine( 2, msg, 1, ALIGN_CENTER) ;
sendtoUSB ("fail data",9);
sendtoUSB(cRecvBuf,rlen);
sendtoUSB(msg,strlen(msg));
}
}
}
Sys_PiccDeselect(RM_WAIT);
break;
}
Sys_PcdClose();
Sys_WaitReturn();
Sys_Buzzer(KB_BEEP_DURATION);
}
// i am following the same steps for the authentication also
//open NFC
// check NFC is there or not
//activate
// send command