【问题标题】:Mapping Nfc technology to tag types将NFC技术映射到标签类型
【发布时间】:2014-02-25 19:19:21
【问题描述】:

我正在编写一个应用程序,它应该能够读取和写入类型 1、2、3 和 4 的 nfc 标签。我有 tag1、tag2 和 tag4 标签,它们都支持 NfcA 技术,我想使用 NfcA使用 trancieve(byte[]) 函数向标签发送命令的类 (http://developer.android.com/reference/android/nfc/tech/NfcA.html)。我如何以编程方式区分标签,以便我知道要使用的通信协议(所有标签类型的命令都不同)。

例如,下面分别对 Tag1 和 Tag2 执行读取命令:

// Note: nfcATag is an instance of android.nfc.tech.NfcA
byte[] readTag1Bytes = nfcATag.transcieve(new byte[] {0x01, 0x00, 0x00, id[0], id[1], id[2], id[3]}); // Id[] is a byte array that contains tag id
byte[] readTag2Bytes = nfcATag.transcieve(new byte[] {0x30, 0x00})

任何帮助表示赞赏..

【问题讨论】:

    标签: android nfc rfid


    【解决方案1】:

    NfcA 等效于 ISO 14443 A 类,因此您可以通过评估应答器的 ATQA/SENS_RES(2 字节)响应来区分标签。
    请参阅here 了解可区分标签类型的列表。

    您可以使用以下命令:

    byte[]  getAtqa()    //Return the ATQA/SENS_RES bytes from tag discovery.
    Tag     getTag()     //Get the Tag object backing this TagTechnology object.
    

    【讨论】:

    • 谢谢,正是我需要的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-08
    • 2016-10-13
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    • 2020-05-16
    相关资源
    最近更新 更多