Hello,
I’ve got NFC Shield 1.0v connected to Arduino. I would like to read multiple tags ID (one by one, not at once). Correct me if I wrong, but from what I have read - if I put mifare tag into a NFC field and after activation I send HALT (HLTA) it should stay inactive until I take it away from the field and put it again. So, until it is inactive (halt) I should be able to read another tag that comes into the field. My problem is, I don’t know how to send HALT to the tag.
I made little change in the PN532 library in function ‘readPassiveTargetID’. In order to PN532 datasheet I can add UID of specified tag I want to find and activate to InListPassiveTarget command. So I modified function in PN532.cpp to do that:
uint32_t PN532::readPassiveTargetID(uint8_t UIDx[4]) // Pass 4-bytes UID
{
uint32_t cid;
pn532_packetbuffer[0] = PN532_INLISTPASSIVETARGET;
pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this to 2)
pn532_packetbuffer[2] = PN532_MIFARE_ISO14443A;
pn532_packetbuffer[3] = UIDx[0];
pn532_packetbuffer[4] = UIDx[1];
pn532_packetbuffer[5] = UIDx[2];
pn532_packetbuffer[6] = UIDx[3];
if (! sendCommandCheckAck(pn532_packetbuffer, 7))
return 0x0; // no cards read
...
}
It works well. I thought I could use this function in a loop passing UIDs I want to find, so I did something like this (arduino code):
for(int t = 0; t < 6; t++)
{
delay(1000);
boolean found = nfc.readPassiveTargetID(tags[t]);
if(found)
{
Serial.print("Found tag nr: ");
Serial.println(t+1);
}
}
‘tags[]’ array contains known UIDs of six tags. It works good for 3-4 tags. If I add more then communication hangs. I would like to try send HLTA (InDeselect) to the found tag and then put ‘new’ tags one by one in order to get their IDs. I was trying to use InDeselect command in that way:
boolean releaseTarget()
{
pn532_packetbuffer[0] = 0x52;
pn532_packetbuffer[1] = 0x00; // realese all targets
if (sendCommandCheckAck(pn532_packetbuffer, 2) )
return true;
return false;
}
But it did not work I suppose… Could you please help with this?
Thanks,
Adrian