Pergunta

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 :(

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top