简体   繁体   中英

Read data from NFC that is put after NDEF content?

Let's say we've a custom chip that contains data stored as a NDEF and also custom data stored after the standard NDEF data. How could we read that data with Android?

That heavily depends on the type of tag hardware that you use. NDEF is an abstraction layer that lets you handle data the same way on any tag hardware. Behind the NDEF layer, each tag platform has its own memory organization and its own set of commands to access the data.

You can purchase the specifications for each of the standardized tag platforms on the NFC Forum's website as "Type X Tag Operation specification".


For instance, if you have a Type 2 tag (which has a flat memory structure and uses simple read/write commands to access that memory), an NDEF message will be stored from page 4 onwards. You could use higher pages to store proprietary data (eg starting from page 16) You could then access that tag from Android using the NfcA tag technology:

Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
NfcA nfcA = NfcA.get(tag);
nfcA.connect();

byte[] result = nfcA.transceive(new byte[] {
    (byte)0x30,  /* CMD = READ */
    (byte)0x10   /* PAGE = 16  */
});

Yes, this is possible. You can use the transceive(byte[] data) method to send RFID commands to the tag.

Which commands to send depends what type of tag you are using. You should read the command structure for your type of tag (ISO14443 or ISO15693). In oder to use such commands you may have to dig a bit deeper in the standards to learn how to create the correct command sequence.

Example for ISO15693, read single block, command code 0x20 (untested):

byte[] readSingleBlock(int block) throws IOException {

    byte[] command = new byte[3];
        command[0] = 0x12;          // flags
        command[1] = 0x20;          // read single block command
        command[2] = (byte) block;

    byte result[] = nfcv.transceive(command);
    return result;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM