Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading multiple NFC tags simultaneously in Android

The new 2.3.3 SDK includes improved NFC support, and I'd like to write an app that relies on this. Ultimately, I'd like to be able to read data from multiple tags that enter the field simultaneously, but Android only seems to trigger on the first one that enters the field - subsequent ones are ignored.

From reading the NFC spec (ISO/IEC 14443-3) for the tags I'm using (Mifare Classic), I should be able to send a 'halt' command to the tag, which will cause it to stop responding, and allow me to read the next tag in the field. Android doesn't support the halt command directly on any of the TagTechnology subclasses, so I tried sending it myself directly using transceive(new byte[] {0x50, 0x00}). This throws an IOException, with the message 'transceive failed'.

Admittedly I'm doing all this from the main thread, which I understand is a bad idea, but I just want to test the concept as easily as possible.

Is it possible to communicate with multiple tags in the field at the same time? What am I doing wrong?

like image 916
Nick Johnson Avatar asked Mar 13 '11 05:03

Nick Johnson


People also ask

Can one NFC tag do multiple things?

You can, but when you scan a tag, it can only have one data type that Android uses to determine what type of tag it is. This data type is determined by the first NDEF record in your NDEF message.

Can NFC tags talk to each other?

Unlike RFID, which is typically one-way communication between a reader and a tag, NFC allows for two-way communication.

How many times can an NFC tag be read?

The most common Chips support up to 100,000 read/write cycles, meaning they can be read or programmed up to 100,000 times.


2 Answers

What you want is unfortunately not possible at the moment, unless you do some pretty advanced hackery, which is almost never a good idea :)

Probably you could halt the card if you send the right bytes in the transceive(), as you're trying to do now. But since the halt (or rather, the HLTA which you're trying to send) is an ISO14443-3A command, this will not work through the MifareClassic interface - which uses an "encrypted" pipe. Directly transmitting over the NfcA interface unfortunately doesn't work with the current stack either.

Even if you could get the card to halt, this will not automatically cause the NFC chip in the phone to resume polling for new tags - since you are "going around" the stack.

like image 122
Martijn Coenen Avatar answered Sep 22 '22 20:09

Martijn Coenen


Depending on my short experience you can not work with multiple tags. If two tags are in the field you do not receive an ID from the tag, it's binary zero. So my guess is that, at this point, you can only access one tag and no more than one can be in the field.

like image 43
Nolife Avatar answered Sep 21 '22 20:09

Nolife