【发布时间】:2015-06-11 03:57:17
【问题描述】:
我正在研究 NFC(Mifare 经典标签)。我想知道如何将数据写入 mi fare classic 标签。我有空标签。请告诉我需要用于 mifare 经典标签的 APDU 命令。
我发送 APDU 命令如下:
\x00','\xA4', '\x04', '\x00','\x07','\xd2','\x76','\x00','\x00','\x85','\x01','\x00
如果我使用这个 apdu 命令,它不会给出任何成功响应(因为每个 APDU 命令都会有 9000),它会进入 else 部分。请告诉我正确的 apdu 命令。我正在用 C 语言编写代码。我的阅读器是 MFC 523。需要遵循哪些步骤?
// 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
【问题讨论】:
-
这个命令返回什么状态字。
-
@vikky 谢谢你这么多 vikky 你给我回复...
-
@vikky 我收到的响应是 6E00 类错误,我收到了
-
@vikky 请告诉我我在做什么错误。我也给了身份验证密钥
-
从哪里得到这个命令。