Search code examples
c#androidxamarinnfciso-15693

Android NfcV read tag always prepend 0x00


I got a problem with NFC-V tag reading. The tag type is Tag-it HF-I Plus (TMS37112). Here is the code I use to read data:

private void GetTagInfo(Tag tag){
        String[] techList = tag.GetTechList();
        for (int i = 0; i < techList.Length; i++) {
            if(techList[i].Contains("NfcV")){
                NfcV nfcv = NfcV.Get (tag);
                nfcv.Connect ();

                var response = nfcv.Transceive(new byte[] {
                    (byte)0x00,
                    (byte)0x23,
                    (byte)0x00,
                    (byte)0x01 });
            }
        }
    }

Writing in c# but not the purpose here (working on Xamarin).

Regardless of what I use as the first block number, I got an 0x00 before my data. Is this normal?


Solution

  • What you see is the flags byte. This byte is part of every NFC-V response frame and provides information about the command status. If this byte is 0x00 (or possibly 0x80), then the command was executed successfully and the remaining bytes contain the response parameters/data for your command (in your case one block starting at block zero requested by the READ MULTIPLE BLOCKS command).

    If bit 0 of the flags byte is set, this indicates an execution error, the second byte will encode error information as defined in the ISO/IEC 15693-3 standard.

    Thus a typical NFC-V command frame (when exchanged using NfcV.transceive()) looks like this:

    +-------+--------------+--------------------------------+-------------------------+
    | FLAGS | COMMAND CODE | [ADDRESS, if Addressed_flag=1] | COMMAND PARAMETERS/DATA |
    +-------+--------------+--------------------------------+-------------------------+
    

    and the response frame looks like this:

    +-------+--------------------------+
    | FLAGS | RESPONSE PARAMETERS/DATA |
    +-------+--------------------------+