1

I'm getting a "Tag was lost" exception with the code below. However, data is written successfully despite the exception. Why is the data successfully written eventhough an exception is thrown?

   nfc.connect();
   byte[] arrByt = new byte[7];
   arrByt[0] = 0x01; //Command Flag 0x02 works fine
   arrByt[1] = 0x21;
   arrByt[2] = 0x06;
   arrByt[3] = 0x00;
   arrByt[4] = 0x00;
   arrByt[5] = 0x00;
   arrByt[6] = 0x00;           
   byte[] response = nfc.transceive(arrByt);

My NFC Chip

Type V (ISO/IEC 15693 / Vicinity), Tag Type SL2 ICS2001 (ICODE SLI), Manufacturer NXP Semiconductors (Germany)

here talked over But no result :(

Community
  • 1
  • 1
Last Warrior
  • 1,307
  • 1
  • 11
  • 20

1 Answers1

2

When NfcV tag returns non-success code android's NFC stack assumes it is an exception and it throws "Tag was Lost".
To avoid this exception you can use the command 0x02 and the proper byte arrays becomes:
arrByte = {0x02, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00}; where 0x02 is flag command, 0x21 is write single block command, 0x06 is block number and the remaing is 4bytes of data. Hope this will help.

Imran Zulfiqar
  • 108
  • 1
  • 1
  • 10
  • Imran - good advice, except there are ISO15693 tags which are requiring the use of the option flag for write and lock operations, which then requires an EOF to be sent some time after that is transmitted out to get the no error response back from the tag. (TI and other mfgs. use this method - both methods (with and without option flag) are allowed in the ISO standard) This has been repaired with the latest NFC stack in Nexus 4/Nexus 10 and above, but their should be some effort probably made here to the older versions of Android NFC stacks to allow the writing to take place without throwing th – Josh Wyatt May 31 '13 at 12:44
  • Sorry @ImranZulfiqar, I'm a bit confused. I need to send command `0x80, 0x44, ...` to a NFC tag but I'm getting this exception. So am I to send the `0x02, 0x21, ...` first then my command or something? – ericn Dec 03 '13 at 15:00