Search code examples
androidnfcreconnect

Reconnect to NFC TAG without reintroduction


I've been struggling now for a long time to find out if it is possible to trigger tag_discovered without moving an NFC-tag away and then back. My findings show that on some devices it is possible by simply closing the NfcA connection using the following command nfcA.close(). It seems like different manufacturers implements this in different ways (?).

Are there other ways to destroy the NFC-field between the device and the TAG?

I have also tried disabling NfcAdapter and NfcManager. Which also seems to work on some devices but not all:

// Disable
nfcAdapter.disableForegroundDispatch(this)
nfcManager.defaultAdapter.disableReaderMode(this)

// Enable 
val option = Bundle()
option.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, 2000)
nfcAdapter.enableReaderMode(this, nfcManager, NfcAdapter.FLAG_READER_NFC_A, option)

Any help here will be appreciated.


Solution

  • Thanks Andrew.

    My guess is that you don't actually need to turn the field off but just need to get the Tag to the ISO14443-3 HALT state and then bring it back to ACTIVE state, but that is unknown. Again sending the low level ISO14443-3 commands of HLTA and WUPA to do this is problematic on Android as it is not designed for the user to send these commands.

    Looking closer on the ISO14443-3 standard and the HALT command I finally found a solution. Running the command below causes a TagLostException which in turn makes the onTagDiscovered method run. So by using HALT I can rediscover TAGs without a physical re-introduction.

    byte[] HaltCMD = {0x35, 0x30, 0x30,0x30, 0x00};