Don't keep unsupported tags selected.
Currently, when the libfreefare finds a NFC target, it checks whether it's a supported one looking at it's ATQA. If the target's ATQA is not in the supported ATQA list, the target was not deselected. While this is buggy, it allowed to detect 2 tags with colliding ATQA on a single NFC device and still have the ATQA of each tag (on ATQA collision, the ATQA is set to 0x0000 by the NFC chip, but as the tag is not deselected, it will have a second chance to tell it's ATQA when it will be idle again): computer PCD PICC1 PICC2 | | ATQA: 0x1234 0x6789 | | | | |- InListTargets ->| | | | |------ REQA ----->(===============) | |<---- ATQA 1234 ------| | } Both reply | |<---- ATQA 6789 --------------| } simultaneously | | S | | | // Collision detected PICC1 only is selected because | | // only a single tag was wanted. It's ATQA is set | | // to 0x0000. |<-- ATQA 0x0000 --| S | | // Unsuported ATQA, skipped S | | | S | | // DESELECT IS MISSING HERE! S | | | S | |- InListTargets ->| S | | |------ REQA ----->(===============) | |<---- ATQA 6789 --------------S // PICC1 won't reply |<-- ATQA 0x6789 --| | S // it is still selected | // Supported, deselect it | S |--- InDeselect -->| | S | |-------- HALT --------------->X | | | X |- InListTargets ->| | X | |------ REQA ----->(===============) | |<---- ATQA 1234 ------S X // PICC2 won't reply |<-- ATQA 0x1234 --| S X // it is deselected | // Supported, deselect it S X |--- InDeselect -->| S X | |-------- HALT ------->X X | | X X |--- InDeselect -->| X X | |------ REQA ----->(===============) | | X X // No reply | | X X Tag timeline legend: | - Target idle S - Target selected X - Target deselected Since PN53x devices can only known about 2 tags simultaneously, presenting 3 targets to the NFC device caused an infinite loop. This commit prevents this infinite loop to occur, and will be completed later by another commit for not relying on the ATQA to determine targets type.
This commit is contained in:
parent
88a4cbbe53
commit
bef4ec342f
1 changed files with 2 additions and 1 deletions
|
@ -90,7 +90,7 @@ freefare_get_tags (nfc_device_t *device)
|
|||
}
|
||||
|
||||
if (!found)
|
||||
continue;
|
||||
goto deselect;
|
||||
|
||||
tag_count++;
|
||||
|
||||
|
@ -128,6 +128,7 @@ freefare_get_tags (nfc_device_t *device)
|
|||
(tags[tag_count-1])->tag_info = tag_info;
|
||||
tags[tag_count] = NULL;
|
||||
|
||||
deselect:
|
||||
nfc_initiator_deselect_target (device);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue