从MF0ICU2区分NTAG213 [英] Distinguish NTAG213 from MF0ICU2

查看:265
本文介绍了从MF0ICU2区分NTAG213的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将 NTAG213 MF0ICU2 标签基于其UID,ATQA或SAK值?由于必须对标签进行不同的编程(NTAG213使用PWD/PACK或MF0ICU2使用3DES),因此必须有一种方法可以调用一个或另一个方法.

Is there any way to distinguish a NTAG213 from a MF0ICU2 tag based on its UID, ATQA or SAK values? As I have to program the tags differently (PWD/PACK for NTAG213 or 3DES for MF0ICU2) there must be a way to call either one or another method.

不幸的是,Android框架告诉我,两个标签都是MifareUltralight,类型为TYPE_ULTRALIGHT_C. ATQA(0x0044)和SAK(0x00)也相同.

Unfortunately, the Android framework tells me that both tags are MifareUltralight with type TYPE_ULTRALIGHT_C. The ATQA (0x0044) and SAK (0x00) are identical, too.

其他应用程序,例如 NXP的NFC TagInfo 可以告诉我标签的确切类型,所以我知道必须有某种方法.

Other apps like NFC TagInfo by NXP can tell me the exact type of a tag, so I know that there must be some way.

推荐答案

一旦您知道该标签是NXP标签(UID以0x04开头),您便会

Once you know that the tag is an NXP tag (UID starts with 0x04), you would

  1. 首先发送GET_VERSION命令.如果此命令成功,您将知道该标签是EV1或更高版本(MIFARE Ultralight EV1,NTAG21x).否则,您可以假定它是第一代标签(MIFARE Ultralight,Ultralight C,NTAG203).

  1. first send a GET_VERSION command. If this command succeeds, you know that the tag is EV1 or later (MIFARE Ultralight EV1, NTAG21x). Otherwise, you can assume that it is a first generation tag (MIFARE Ultralight, Ultralight C, NTAG203).

如果标签是EV1标签,则可以通过分析对GET_VERSION命令的响应来继续操作.这将显示产品类型(NTAG或Ultralight EV1)以及产品子类型,产品版本和存储大小(可让您确定确切的芯片类型:

If the tag is an EV1 tag, you can continue by analyzing the resonse to the GET_VERSION command. This will reveal the product type (NTAG or Ultralight EV1) as well as product subtype, product version and storage size (which allows you to determine the exact chip type:


+------------+------+---------+-----------+--------------+
| Chip       | Type | Subtype | Version   | Storage size |
+------------+------+---------+-----------+--------------+
| NTAG210    | 0x04 | 0x01    | 0x01 0x00 | 0x0B         |
| NTAG212    | 0x04 | 0x01    | 0x01 0x00 | 0x0E         |
| NTAG213    | 0x04 | 0x02    | 0x01 0x00 | 0x0F         |
| NTAG213F   | 0x04 | 0x04    | 0x01 0x00 | 0x0F         |
| NTAG215    | 0x04 | 0x02    | 0x01 0x00 | 0x11         |
| NTAG216    | 0x04 | 0x02    | 0x01 0x00 | 0x13         |
| NTAG216F   | 0x04 | 0x04    | 0x01 0x00 | 0x13         |
+------------+------+---------+-----------+--------------+
| NT3H1101   | 0x04 | 0x02    | 0x01 0x01 | 0x13         |
| NT3H1101W0 | 0x04 | 0x05    | 0x02 0x01 | 0x13         |
| NT3H2111W0 | 0x04 | 0x05    | 0x02 0x02 | 0x13         |
| NT3H2101   | 0x04 | 0x02    | 0x01 0x01 | 0x15         |
| NT3H1201W0 | 0x04 | 0x05    | 0x02 0x01 | 0x15         |
| NT3H2211W0 | 0x04 | 0x05    | 0x02 0x02 | 0x15         |
+------------+------+---------+-----------+--------------+
| MF0UL1101  | 0x03 | 0x01    | 0x01 0x00 | 0x0B         |
| MF0ULH1101 | 0x03 | 0x02    | 0x01 0x00 | 0x0B         |
| MF0UL2101  | 0x03 | 0x01    | 0x01 0x00 | 0x0E         |
| MF0ULH2101 | 0x03 | 0x02    | 0x01 0x00 | 0x0E         |
+------------+------+---------+-----------+--------------+

  • 如果标签不是EV1标签,则可以发送AUTHENTICATE(第1部分)命令.如果此命令成功执行,则说明标签为MIFARE UltralightC.否则,可以假定标签为Ultralight或NTAG203.

  • If the tag is not an EV1 tag, you can send an AUTHENTICATE (part 1) command. If this command succeeds, you know that the tag is MIFARE Ultralight C. Otherwise, you can assume that the tag is either Ultralight or NTAG203.

    为了区分MIFARE Ultralight和NTAG203,您可以尝试读取Ultralight上不存在的页面(例如,阅读第41页).

    In order to distinguish between MIFARE Ultralight and NTAG203, you can try to read pages that do not exist on Ultralight (e.g. read page 41).

    您可以使用NfcAMifareUltralight(如果甚至可用于标签)标签技术将命令发送到标签:

    You can send commands to the tag using the NfcA or MifareUltralight (if even available for the tag) tag technologies:

    boolean testCommand(NfcA nfcA, byte[] command) throws IOException {
        final boolean leaveConnected = nfcA.isConnected();
    
        boolean commandAvailable = false;
    
        if (!leaveConnected) {
            nfcA.connect();
        }
    
        try {
            byte[] result = nfcA.transceive(command);
            if ((result != null) &&
                (result.length > 0) &&
                !((result.length == 1) && ((result[0] & 0x00A) == 0x000))) {
                // some response received and response is not a NACK response
                commandAvailable = true;
    
                // You might also want to check if you received a response
                // that is plausible for the specific command before you
                // assume that the command is actualy available and what
                // you expected...
            }
        } catch (IOException e) {
            // IOException (including TagLostException) could indicate that
            // either the tag is no longer in range or that the command is
            // not supported by the tag 
        }
    
        try {
            nfcA.close();
        } catch (Exception e) {}
    
        if (leaveConnected) {
            nfcA.connect();
        }
    
        return commandAvailable;
    }
    

    请注意,当标签不支持命令时,某些NFC堆栈会生成IOException(通常为TagLostException).无论收到NACK响应或不支持命令的IOException,都应先断开连接并重新连接标签,以便在继续发送其他命令之前重置标签的状态.

    Note that some NFC stacks will generate an IOException (typically a TagLostException) when a command is not supported by the tag. Regardless of receiving a NACK response or an IOException for an unsupported command, you should disconnect and reconnect the tag afterwards in order to reset the state of the tag before you continue to send other commands.

    这篇关于从MF0ICU2区分NTAG213的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆