How send NfcA command to the MIFARE card?

人盡茶涼 提交于 2019-12-06 15:44:06

It seems as if you are converting the command codes into null-terminated ASCII character strings before sending them with NfcA.transceive():

byte[] HaltCMD = {0x35, 0x30, 0x30,0x30, 0x00};
byte[] WakeUpCMD = {0x35, 0x32, 0x00};
  • 0x35 0x30 0x30 0x30 gives "5000"
  • 0x35 0x32 gives "52"

This does not make any sense as the commands (50 00 for HLTA, and 52 for WUPA) are hexadecimal representations of the command values already.

For the HLTA command, you would therefore need to send 50 00:

data = nfca.transceive(new byte[] { (byte)0x50, (byte)0x00 });

Note that S (start of communication), E (end of communication), and CRC_A will be automatically added by the NFC controller (or the NFC stack).

For the WUPA command, you could probably try to send 52:

data = nfca.transceive(new byte[] { (byte)0x52 });

However, it is very likely that the NFC stack does not permit you to send 7-bit commands using the transceive method. Instead, the stack may automatically use this command value as one full byte and add a CRC_A.

General note on sending ISO/IEC 14443-3 initialization and anti-collision commands

Sending such commands may or may not work (depending on the NFC stack implementation and the NFC controller). In general I would strongly recommend that you do not send such commands. Particularly the HLTA command will confuse the internal state keeping of the NFC stack on some devices and will lead to unexpected results. Normally, you don't need to exchange such commands, as anti-collision, initialization and activation are handled automatically by the NFC device.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!